<?php 
include "../config.php";
$customer = $_POST['customer'];
//echo $customer;
if ($customer != '')
{
$opening_balance = mysqli_query($connect,"select salesopening from customerdetails where code='$customer'&& status!='deleted'");
$dis_opening = mysqli_fetch_assoc($opening_balance);
$opening_value = $dis_opening['salesopening'];
$sales_balance = mysqli_query($connect,"select ifnull(sum(totalamount),0)as sales from second_transaction where customer='$customer'&& status!='deleted'");
$dis_sales = mysqli_fetch_assoc($sales_balance);
$sales_value = $dis_sales['sales'];
$sales_balance_est = mysqli_query($connect,"select ifnull(sum(totalamount),0)as sales from second_transaction_est where customer='$customer'&& status!='deleted'");
$dis_sales_est = mysqli_fetch_assoc($sales_balance_est);
$sales_value_est = $dis_sales_est['sales'];
$cash_balance = mysqli_query($connect,"select ifnull(sum(amount),0)as amount,ifnull(sum(otheramount),0)as otheramount from creditdetails where customer='$customer'&& status!='deleted'");
$dis_cash = mysqli_fetch_assoc($cash_balance);
$cash_value = $dis_cash['amount'];
$other_value = $dis_cash['otheramount'];
$total_amount = $opening_value + $sales_value + $sales_value_est;
$pending_amount = $total_amount-$cash_value-$other_value;
$output = $total_amount."||".$pending_amount;
echo $output;
}
else
{
 echo "";
}

?>
