<?php 
include "../config.php";
$customer = $_POST['customer'];
//echo $customer;
if ($customer != '')
{
    $cash_balance = mysqli_query($connect,"select ifnull(sum(amount),0)as amount,ifnull(sum(otheramount),0)as otheramount,ifnull(sum(advance),0)as advance from debitdetails where customer='$customer'&& status!='deleted'");
    $dis_cash = mysqli_fetch_assoc($cash_balance);
    $cash_value = $dis_cash['amount'];
    $other_value = $dis_cash['otheramount'];
    $advance_value = $dis_cash['advance'];
    $advance_amount = mysqli_query($connect,"select ifnull(sum(advance),0)as advance from advance where customer='$customer'&& status!='deleted'");
    $advance_dis = mysqli_fetch_assoc($advance_amount);
    $advance_total = $advance_dis['advance']-$advance_value;
echo $advance_total;
}
else
{
 echo "";
}

?>
