<?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(); 
$utility	=	new utilityClass(); 
$bcmId 						= isset($_POST['mainid']) ? trim(strip_tags($_POST['mainid'])) : ""; 
$bcmReserveId				= isset($_POST['mainrid']) ? trim(strip_tags($_POST['mainrid'])) : ""; 
$penaltyStatus				= isset($_POST['val']) ? trim(strip_tags($_POST['val'])) : ""; 
$trans						= isset($_POST['trans']) ? trim(strip_tags($_POST['trans'])) : ""; 
$cmid						= isset($_POST['cmid']) ? trim(strip_tags($_POST['cmid'])) : ""; 
$cstat						= isset($_POST['cstat']) ? trim(strip_tags($_POST['cstat'])) : ""; 



$currentUser 				= $_SESSION['danvilles_username'];
$timeStamp					= date('Y-m-d H:i:s');
$output 					= "";  
$output2					= "";
$mainArr 					= array();
$condArr 					= array();
$mainArr2 					= array();
$condArr2 					= array();
$condArr['Id'] 				= $bcmId;  
$mainArr['PenaltyStatus']   = $penaltyStatus; 
$output 					= $mecon->updateQuery($mainArr,"buyer_cheque_monitoring_past_due",$condArr);

//if($trans=='Re-Deposit' && $penaltyStatus=='Paid' && $cstat=='Cleared'){
if(strtoupper($penaltyStatus)=='PAID' && strtoupper($cstat)=='CLEARED'){ //15NOV25
	$condArr2['Id'] 			= $cmid;  
	$mainArr2['PenaltyStatus']  = $penaltyStatus; 
	$output2 					= $mecon->updateQuery($mainArr2,"buyer_cheque_monitoring",$condArr2);
}
//LOG TASK
			$actArr['UserType']			= "assistant_accountant,accountant"; 
			$actArr['Remarks']			= "Update Penalty Status : [$currentId]";
			$actArr['Action']			= "edit";
			$actArr['TransId']			= $currentId;
			$actArr['ActionType']		= "buyer_cheque_monitoring_past_due";
			$actArr['ActionContent']	= json_encode($mainArr);
			$actArr['ActionBy'] 		= $currentUser;	
			$actArr['ActionDate']		= $timeStamp;
			$utility->encodeActivityLog($actArr); 
			


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