<?php 

$no++;
$payment_id = $resultStatement["payment_id"];
$amount = $resultStatement["amount"];
$date_created = $resultStatement["date_created"];
$pay_info = $resultStatement["pay_info"];
$issue_date = $resultStatement["issue_date"];
$status_payment = $resultStatement["status_payment"];
$info = $resultStatement["info"];
$pay_type = $resultStatement["pay_type"];
$payment_info = $resultStatement["payment_info"];



$date_created = date("d/m/Y", strtotime($date_created));

if (strpos($issue_date, '/') !== false) {
	$issue_date = $resultStatement["issue_date"];
	$slashPosition = strpos($issue_date,"/");
	$month = substr($issue_date, 0, $slashPosition);
	$year = substr($issue_date, $slashPosition + 1 , 6);
	$issue_date = $year . "-" . $month ."-01";
	$RP_rentalMonth = $year . "-" . $month ."-07";
	$cutOff_rentalMonth = $year . "-" . $month ."-08";
	$issue_date = date("M Y", strtotime($issue_date));
	$RP_rentalMonth = date("Y-m-d", strtotime($RP_rentalMonth));
	$cutOff_rentalMonth = date("Y-m-d", strtotime($cutOff_rentalMonth));
}
else{
	$issue_date = date("M Y", strtotime($issue_date));
	$RP_rentalMonth = date("Y-m-07", strtotime($issue_date));
	$cutOff_rentalMonth = date("Y-m-08", strtotime($issue_date));
}
if (strpos($pay_info, '00:00:00') !== false) {
	$pay_info = $issue_date;
}
else{
	$pay_info = $pay_info . " " . $issue_date;
}

if($totalBaki == 0 && abs($totalBF_water) != 0){
	$totalBaki =  $totalBF_water;
	
}

if (strpos($info, 'payment') !== false) {
	$id = strstr($info, ' payment ', true);
	$bill_id_smartsewa = $bill_id;
	$totalPaidList .= $amount;
	$totalPaid += $amount;
	$payment = $amount;
	//$totalBaki = abs($totalBaki) - $payment;
	$totalBaki = $totalBaki - $payment;
}
if (strpos($info, 'bill') !== false) {
	$totalUnpaid += $amount;
	$totalUnpaidList .= $amount;
	$id = strstr($info, ' bill ', true);
	$bill = $amount;
	//$totalBaki = $bill - abs($totalBaki);
	$totalBaki = $totalBaki + $bill;
	
	
}
/* if($totalBaki == 0){
	$totalBaki = 0.00;
} */
?>