<?php
error_reporting(0); //7dec25
if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start();
session_start();
session_cache_limiter('private');
$cache_limiter 	= session_cache_limiter();
session_cache_expire(60);
$cache_expire 	= session_cache_expire(); 
date_default_timezone_set('Asia/Manila'); 
$CURRENT_DATE 	= date('Y-m-d H:i:s');
include_once('../config/minho.php');
include_once('../config/autoloadClass.php');
$autoload	=	new autoloadClass();
$mecon		=	new condbClass();
$mecon2		=	new condbClass();
$main		=	array();
$main2		=	array();
$arr3		=	array();
$main3		=	array();
$main4		=	array();
$cmid		=	(isset($_POST['cmid']))	?	$_POST['cmid']	:	""; //CMID

//ChequeStatus  - Cleared
//PenaltyStatus - Paid
//Transcode 	- Penalty &amp; Interest

$mecon->query("SELECT * FROM buyer_cheque_monitoring_past_due WHERE Transcode IN ('Penalty', 'Penalty &amp; Interest') AND ChequeStatus = :chequestatus AND PenaltyStatus = :penaltystatus AND ChequeMonitorId = :cmid ORDER BY Id DESC");
$mecon->bind(':chequestatus', 'Cleared'); //AND Transcode = :transcode 
$mecon->bind(':penaltystatus', 'Paid'); 
$mecon->bind(':cmid', $cmid);


$main 		= $mecon->resultset(); 
$counter 	= count($main); 
$arr1 		= array(); 
$arr2 		= array(); 
$arr3 		= array(); 
for($a=0; $a<$counter; $a++){ 
		$cheque_monitor_id	=  trim(stripslashes(html_entity_decode($main[$a]['ChequeMonitorId']))); 

		//PenaltyStatus
		//ChequeMonitorId of buyer_cheque_monitoring_past_due is the ID of buyer_cheque_monitoring table
		//UPDATING THE STATUS IN BUYER_CHEQUE_MONITORING TABLE TO BE CONSISTENT 
		$output 					= "";   
		$mainArr 					= array();
		$condArr 					= array(); 
		$condArr['Id'] 				= $cheque_monitor_id;  
		$mainArr['PenaltyStatus']   = "Paid"; 
		$output 					= $mecon2->updateQuery($mainArr,"buyer_cheque_monitoring",$condArr);
 
} 


$resultArr 						= array();
$resultArr['output']	  		= $output;  
echo json_encode($resultArr);
exit();
ob_end_flush();