<?php
error_reporting(0);
ob_start("ob_gzhandler");
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(); 
$task				= 	isset($_POST['action'])		? trim($_POST['action']) : "";
$mainid				= 	isset($_POST['mainid'])		? trim($_POST['mainid']) : "";
 
 
$contractor				= 	isset($_POST['contractor']) 	? trim(strip_tags($_POST['contractor'])) : ""; 
$block					= 	isset($_POST['block']) 			? trim(strip_tags($_POST['block'])) : ""; 
$lot					= 	isset($_POST['lot']) 			? trim(strip_tags($_POST['lot'])) : ""; 
$number_units			= 	isset($_POST['number_units']) 	? trim(strip_tags($_POST['number_units'])) : ""; 
$po_issued				= 	isset($_POST['po_issued']) 		? trim(strip_tags($_POST['po_issued'])) : ""; 
$date_issued			= 	isset($_POST['date_issued']) 		? trim(strip_tags($_POST['date_issued'])) : ""; 
$retention_processed	= 	isset($_POST['retention_processed']) 		? trim(strip_tags($_POST['retention_processed'])) : ""; 
$contract_price			= 	isset($_POST['contract_price']) 	? trim(strip_tags($_POST['contract_price'])) : ""; 
$withholding_tax		= 	isset($_POST['withholding_tax']) 	? trim(strip_tags($_POST['withholding_tax'])) : ""; 
$net_contract_price		= 	isset($_POST['net_contract_price']) 	? trim(strip_tags($_POST['net_contract_price'])) : ""; 
$downpayment_checkbox	= 	isset($_POST['downpayment_checkbox']) 	? trim(strip_tags($_POST['downpayment_checkbox'])) : ""; 
$downpayment_recoup		= 	isset($_POST['downpayment_recoup']) 	? trim(strip_tags($_POST['downpayment_recoup'])) : ""; 
$downpayment_date		= 	isset($_POST['downpayment_date']) 		? trim(strip_tags($_POST['downpayment_date'])) : ""; 
   
$first_checkbox			= 	isset($_POST['first_checkbox']) 		? trim(strip_tags($_POST['first_checkbox'])) : ""; 
$first_percentage		= 	isset($_POST['first_percentage']) 		? trim(strip_tags($_POST['first_percentage'])) : ""; 
$first_amount			= 	isset($_POST['first_amount']) 			? trim(strip_tags($_POST['first_amount'])) : ""; 
$first_wht				= 	isset($_POST['first_wht']) 				? trim(strip_tags($_POST['first_wht'])) : ""; 
$first_recoup			= 	isset($_POST['first_recoup']) 			? trim(strip_tags($_POST['first_recoup'])) : ""; 
$first_retention		= 	isset($_POST['first_retention']) 		? trim(strip_tags($_POST['first_retention'])) : ""; 
$first_electricity		= 	isset($_POST['first_electricity']) 		? trim(strip_tags($_POST['first_electricity'])) : ""; 
$first_others			= 	isset($_POST['first_others']) 			? trim(strip_tags($_POST['first_others'])) : ""; 
$first_net				= 	isset($_POST['first_net']) 				? trim(strip_tags($_POST['first_net'])) : ""; 
$first_date				= 	isset($_POST['first_date']) 			? trim(strip_tags($_POST['first_date'])) : ""; 

$second_checkbox		= 	isset($_POST['second_checkbox']) 		? trim(strip_tags($_POST['second_checkbox'])) : ""; 
$second_percentage		= 	isset($_POST['second_percentage']) 		? trim(strip_tags($_POST['second_percentage'])) : ""; 
$second_amount			= 	isset($_POST['second_amount']) 			? trim(strip_tags($_POST['second_amount'])) : ""; 
$second_wht				= 	isset($_POST['second_wht']) 			? trim(strip_tags($_POST['second_wht'])) : ""; 
$second_recoup			= 	isset($_POST['second_recoup']) 			? trim(strip_tags($_POST['second_recoup'])) : ""; 
$second_retention		= 	isset($_POST['second_retention']) 		? trim(strip_tags($_POST['second_retention'])) : ""; 
$second_electricity		= 	isset($_POST['second_electricity']) 	? trim(strip_tags($_POST['second_electricity'])) : ""; 
$second_others			= 	isset($_POST['second_others']) 			? trim(strip_tags($_POST['second_others'])) : ""; 
$second_net				= 	isset($_POST['second_net']) 			? trim(strip_tags($_POST['second_net'])) : ""; 
$second_date			= 	isset($_POST['second_date']) 			? trim(strip_tags($_POST['second_date'])) : ""; 

$third_checkbox			= 	isset($_POST['third_checkbox']) 		? trim(strip_tags($_POST['third_checkbox'])) : ""; 
$third_percentage		= 	isset($_POST['third_percentage']) 		? trim(strip_tags($_POST['third_percentage'])) : ""; 
$third_amount			= 	isset($_POST['third_amount']) 			? trim(strip_tags($_POST['third_amount'])) : ""; 
$third_wht				= 	isset($_POST['third_wht']) 				? trim(strip_tags($_POST['third_wht'])) : ""; 
$third_recoup			= 	isset($_POST['third_recoup']) 			? trim(strip_tags($_POST['third_recoup'])) : ""; 
$third_retention		= 	isset($_POST['third_retention']) 		? trim(strip_tags($_POST['third_retention'])) : ""; 
$third_electricity		= 	isset($_POST['third_electricity']) 		? trim(strip_tags($_POST['third_electricity'])) : ""; 
$third_others			= 	isset($_POST['third_others']) 			? trim(strip_tags($_POST['third_others'])) : ""; 
$third_net				= 	isset($_POST['third_net']) 				? trim(strip_tags($_POST['third_net'])) : ""; 
$third_date				= 	isset($_POST['third_date']) 			? trim(strip_tags($_POST['third_date'])) : ""; 

$fourth_checkbox		= 	isset($_POST['fourth_checkbox']) 		? trim(strip_tags($_POST['fourth_checkbox'])) : ""; 
$fourth_percentage		= 	isset($_POST['fourth_percentage']) 		? trim(strip_tags($_POST['fourth_percentage'])) : ""; 
$fourth_amount			= 	isset($_POST['fourth_amount']) 			? trim(strip_tags($_POST['fourth_amount'])) : ""; 
$fourth_wht				= 	isset($_POST['fourth_wht']) 			? trim(strip_tags($_POST['fourth_wht'])) : ""; 
$fourth_recoup			= 	isset($_POST['fourth_recoup']) 			? trim(strip_tags($_POST['fourth_recoup'])) : ""; 
$fourth_retention		= 	isset($_POST['fourth_retention']) 		? trim(strip_tags($_POST['fourth_retention'])) : ""; 
$fourth_electricity		= 	isset($_POST['fourth_electricity']) 	? trim(strip_tags($_POST['fourth_electricity'])) : ""; 
$fourth_others			= 	isset($_POST['fourth_others']) 			? trim(strip_tags($_POST['fourth_others'])) : ""; 
$fourth_net				= 	isset($_POST['fourth_net']) 			? trim(strip_tags($_POST['fourth_net'])) : ""; 
$fourth_date			= 	isset($_POST['fourth_date']) 			? trim(strip_tags($_POST['fourth_date'])) : ""; 

$fifth_checkbox			= 	isset($_POST['fifth_checkbox']) 		? trim(strip_tags($_POST['fifth_checkbox'])) : ""; 
$fifth_percentage		= 	isset($_POST['fifth_percentage']) 		? trim(strip_tags($_POST['fifth_percentage'])) : ""; 
$fifth_amount			= 	isset($_POST['fifth_amount']) 			? trim(strip_tags($_POST['fifth_amount'])) : ""; 
$fifth_wht				= 	isset($_POST['fifth_wht']) 				? trim(strip_tags($_POST['fifth_wht'])) : ""; 
$fifth_recoup			= 	isset($_POST['fifth_recoup']) 			? trim(strip_tags($_POST['fifth_recoup'])) : ""; 
$fifth_retention		= 	isset($_POST['fifth_retention']) 		? trim(strip_tags($_POST['fifth_retention'])) : ""; 
$fifth_electricity		= 	isset($_POST['fifth_electricity']) 		? trim(strip_tags($_POST['fifth_electricity'])) : ""; 
$fifth_others			= 	isset($_POST['fifth_others']) 			? trim(strip_tags($_POST['fifth_others'])) : ""; 
$fifth_net				= 	isset($_POST['fifth_net']) 				? trim(strip_tags($_POST['fifth_net'])) : ""; 
$fifth_date				= 	isset($_POST['fifth_date']) 			? trim(strip_tags($_POST['fifth_date'])) : ""; 

$sixth_checkbox			= 	isset($_POST['sixth_checkbox']) 		? trim(strip_tags($_POST['sixth_checkbox'])) : ""; 
$sixth_percentage		= 	isset($_POST['sixth_percentage']) 		? trim(strip_tags($_POST['sixth_percentage'])) : ""; 
$sixth_amount			= 	isset($_POST['sixth_amount']) 			? trim(strip_tags($_POST['sixth_amount'])) : ""; 
$sixth_wht				= 	isset($_POST['sixth_wht']) 				? trim(strip_tags($_POST['sixth_wht'])) : ""; 
$sixth_recoup			= 	isset($_POST['sixth_recoup']) 			? trim(strip_tags($_POST['sixth_recoup'])) : ""; 
$sixth_retention		= 	isset($_POST['sixth_retention']) 		? trim(strip_tags($_POST['sixth_retention'])) : ""; 
$sixth_electricity		= 	isset($_POST['sixth_electricity']) 		? trim(strip_tags($_POST['sixth_electricity'])) : ""; 
$sixth_others			= 	isset($_POST['sixth_others']) 			? trim(strip_tags($_POST['sixth_others'])) : ""; 
$sixth_net				= 	isset($_POST['sixth_net']) 				? trim(strip_tags($_POST['sixth_net'])) : ""; 
$sixth_date				= 	isset($_POST['sixth_date']) 			? trim(strip_tags($_POST['sixth_date'])) : ""; 

$seventh_checkbox		= 	isset($_POST['seventh_checkbox']) 		? trim(strip_tags($_POST['seventh_checkbox'])) : ""; 
$seventh_percentage		= 	isset($_POST['seventh_percentage']) 	? trim(strip_tags($_POST['seventh_percentage'])) : ""; 
$seventh_amount			= 	isset($_POST['seventh_amount']) 		? trim(strip_tags($_POST['seventh_amount'])) : ""; 
$seventh_wht			= 	isset($_POST['seventh_wht']) 			? trim(strip_tags($_POST['seventh_wht'])) : ""; 
$seventh_recoup			= 	isset($_POST['seventh_recoup']) 		? trim(strip_tags($_POST['seventh_recoup'])) : ""; 
$seventh_retention		= 	isset($_POST['seventh_retention']) 		? trim(strip_tags($_POST['seventh_retention'])) : ""; 
$seventh_electricity	= 	isset($_POST['seventh_electricity']) 	? trim(strip_tags($_POST['seventh_electricity'])) : ""; 
$seventh_others			= 	isset($_POST['seventh_others']) 		? trim(strip_tags($_POST['seventh_others'])) : ""; 
$seventh_net			= 	isset($_POST['seventh_net']) 			? trim(strip_tags($_POST['seventh_net'])) : ""; 
$seventh_date			= 	isset($_POST['seventh_date']) 			? trim(strip_tags($_POST['seventh_date'])) : ""; 

$eight_checkbox			= 	isset($_POST['eight_checkbox']) 		? trim(strip_tags($_POST['eight_checkbox'])) : ""; 
$eight_percentage		= 	isset($_POST['eight_percentage']) 		? trim(strip_tags($_POST['eight_percentage'])) : ""; 
$eight_amount			= 	isset($_POST['eight_amount']) 			? trim(strip_tags($_POST['eight_amount'])) : ""; 
$eight_wht				= 	isset($_POST['eight_wht']) 				? trim(strip_tags($_POST['eight_wht'])) : ""; 
$eight_recoup			= 	isset($_POST['eight_recoup']) 			? trim(strip_tags($_POST['eight_recoup'])) : ""; 
$eight_retention		= 	isset($_POST['eight_retention']) 		? trim(strip_tags($_POST['eight_retention'])) : ""; 
$eight_electricity		= 	isset($_POST['eight_electricity']) 		? trim(strip_tags($_POST['eight_electricity'])) : ""; 
$eight_others			= 	isset($_POST['eight_others']) 			? trim(strip_tags($_POST['eight_others'])) : ""; 
$eight_net				= 	isset($_POST['eight_net']) 				? trim(strip_tags($_POST['eight_net'])) : ""; 
$eight_date				= 	isset($_POST['eight_date']) 			? trim(strip_tags($_POST['eight_date'])) : ""; 

$nine_checkbox			= 	isset($_POST['nine_checkbox']) 			? trim(strip_tags($_POST['nine_checkbox'])) : ""; 
$nine_percentage		= 	isset($_POST['nine_percentage']) 		? trim(strip_tags($_POST['nine_percentage'])) : ""; 
$nine_amount			= 	isset($_POST['nine_amount']) 			? trim(strip_tags($_POST['nine_amount'])) : ""; 
$nine_wht				= 	isset($_POST['nine_wht']) 				? trim(strip_tags($_POST['nine_wht'])) : ""; 
$nine_recoup			= 	isset($_POST['nine_recoup']) 			? trim(strip_tags($_POST['nine_recoup'])) : ""; 
$nine_retention			= 	isset($_POST['nine_retention']) 		? trim(strip_tags($_POST['nine_retention'])) : ""; 
$nine_electricity		= 	isset($_POST['nine_electricity']) 		? trim(strip_tags($_POST['nine_electricity'])) : ""; 
$nine_others			= 	isset($_POST['nine_others']) 			? trim(strip_tags($_POST['nine_others'])) : ""; 
$nine_net				= 	isset($_POST['nine_net']) 				? trim(strip_tags($_POST['nine_net'])) : ""; 
$nine_date				= 	isset($_POST['nine_date']) 				? trim(strip_tags($_POST['nine_date'])) : ""; 

$ten_checkbox			= 	isset($_POST['ten_checkbox']) 			? trim(strip_tags($_POST['ten_checkbox'])) : ""; 
$ten_percentage			= 	isset($_POST['ten_percentage']) 		? trim(strip_tags($_POST['ten_percentage'])) : ""; 
$ten_amount				= 	isset($_POST['ten_amount']) 			? trim(strip_tags($_POST['ten_amount'])) : ""; 
$ten_wht				= 	isset($_POST['ten_wht']) 				? trim(strip_tags($_POST['ten_wht'])) : ""; 
$ten_recoup				= 	isset($_POST['ten_recoup']) 			? trim(strip_tags($_POST['ten_recoup'])) : ""; 
$ten_retention			= 	isset($_POST['ten_retention']) 			? trim(strip_tags($_POST['ten_retention'])) : ""; 
$ten_electricity		= 	isset($_POST['ten_electricity']) 		? trim(strip_tags($_POST['ten_electricity'])) : ""; 
$ten_others				= 	isset($_POST['ten_others']) 			? trim(strip_tags($_POST['ten_others'])) : ""; 
$ten_net				= 	isset($_POST['ten_net']) 				? trim(strip_tags($_POST['ten_net'])) : ""; 
$ten_date				= 	isset($_POST['ten_date']) 				? trim(strip_tags($_POST['ten_date'])) : ""; 


$total_percentage		= 	isset($_POST['total_percentage']) 		? trim(strip_tags($_POST['total_percentage'])) : ""; 
$total_amount			= 	isset($_POST['total_amount']) 			? trim(strip_tags($_POST['total_amount'])) : ""; 
$total_wht				= 	isset($_POST['total_wht']) 				? trim(strip_tags($_POST['total_wht'])) : ""; 
$total_recoup			= 	isset($_POST['total_recoup']) 			? trim(strip_tags($_POST['total_recoup'])) : ""; 
$total_retention		= 	isset($_POST['total_retention']) 		? trim(strip_tags($_POST['total_retention'])) : ""; 
$total_electricity		= 	isset($_POST['total_electricity']) 		? trim(strip_tags($_POST['total_electricity'])) : ""; 
$total_water			= 	isset($_POST['total_water']) 		? trim(strip_tags($_POST['total_water'])) : ""; 
$total_others			= 	isset($_POST['total_others']) 			? trim(strip_tags($_POST['total_others'])) : ""; 
$total_net				= 	isset($_POST['total_net']) 				? trim(strip_tags($_POST['total_net'])) : ""; 
$balance_amount			= 	isset($_POST['balance_amount']) 		? trim(strip_tags($_POST['balance_amount'])) : ""; 
$balance_wht			= 	isset($_POST['balance_wht']) 			? trim(strip_tags($_POST['balance_wht'])) : ""; 
$balance_recoup			= 	isset($_POST['balance_recoup']) 		? trim(strip_tags($_POST['balance_recoup'])) : ""; 


$releases_status		= 	isset($_POST['releases_status']) 		? trim(strip_tags($_POST['releases_status'])) : ""; 
$releases_remarks		= 	isset($_POST['releases_remarks']) 		? trim(strip_tags($_POST['releases_remarks'])) : ""; 

$downpayment_check		= 	isset($_POST['downpayment_check']) 		? trim(strip_tags($_POST['downpayment_check'])) : ""; 
$first_check			= 	isset($_POST['first_check']) 		? trim(strip_tags($_POST['first_check'])) : ""; 
$second_check			= 	isset($_POST['second_check']) 		? trim(strip_tags($_POST['second_check'])) : ""; 
$third_check			= 	isset($_POST['third_check']) 		? trim(strip_tags($_POST['third_check'])) : ""; 
$fourth_check			= 	isset($_POST['fourth_check']) 		? trim(strip_tags($_POST['fourth_check'])) : ""; 
$fifth_check			= 	isset($_POST['fifth_check']) 		? trim(strip_tags($_POST['fifth_check'])) : ""; 
$sixth_check			= 	isset($_POST['sixth_check']) 		? trim(strip_tags($_POST['sixth_check'])) : ""; 
$seventh_check			= 	isset($_POST['seventh_check']) 		? trim(strip_tags($_POST['seventh_check'])) : ""; 
$eight_check			= 	isset($_POST['eight_check']) 		? trim(strip_tags($_POST['eight_check'])) : ""; 
$nine_check				= 	isset($_POST['nine_check']) 		? trim(strip_tags($_POST['nine_check'])) : ""; 
$ten_check				= 	isset($_POST['ten_check']) 			? trim(strip_tags($_POST['ten_check'])) : "";  


$first_water			= 	isset($_POST['first_water']) 		? trim(strip_tags($_POST['first_water'])) : ""; 
$second_water			= 	isset($_POST['second_water']) 		? trim(strip_tags($_POST['second_water'])) : ""; 
$third_water			= 	isset($_POST['third_water']) 		? trim(strip_tags($_POST['third_water'])) : ""; 
$fourth_water			= 	isset($_POST['fourth_water']) 		? trim(strip_tags($_POST['fourth_water'])) : ""; 
$fifth_water			= 	isset($_POST['fifth_water']) 		? trim(strip_tags($_POST['fifth_water'])) : ""; 
$sixth_water			= 	isset($_POST['sixth_water']) 		? trim(strip_tags($_POST['sixth_water'])) : ""; 
$seventh_water			= 	isset($_POST['seventh_water']) 		? trim(strip_tags($_POST['seventh_water'])) : ""; 
$eight_water			= 	isset($_POST['eight_water']) 		? trim(strip_tags($_POST['eight_water'])) : ""; 
$nine_water				= 	isset($_POST['nine_water']) 		? trim(strip_tags($_POST['nine_water'])) : ""; 
$ten_water				= 	isset($_POST['ten_water']) 			? trim(strip_tags($_POST['ten_water'])) : "";      

$ewt_type				= 	isset($_POST['ewt_type']) 			? $_POST['ewt_type'] : "";      
  
     
$currentUser 	= $_SESSION['danvillee_username'];
$timeStamp		= date('Y-m-d H:i:s');
//SAVING CHECKLIST DETAILS   
$mainArr	= array();
$output 	= "";
 
$mainArr['DatePOIssued'] 			= date('Y-m-d', strtotime($po_issued)); 
$mainArr['DateIssued'] 				= date('Y-m-d', strtotime($date_issued)); 

$mainArr['RetentionProcessed']		= date('Y-m-d', strtotime($retention_processed)); 




$mainArr['ReleasesStatus']			= $releases_status;
$mainArr['ReleasesRemarks']			= $releases_remarks;
$mainArr['Contractor']				= $contractor;
$mainArr['Block']					= $block;
$mainArr['Lot']						= $lot;
$mainArr['Units']					= $number_units;
$mainArr['ContractPrice']			= str_replace(',','',$contract_price); 
$mainArr['WHT']						= str_replace(',','',$withholding_tax); 
$mainArr['EWTType']					= $ewt_type; 


$mainArr['NetContractPrice'] 		= str_replace(',','',$net_contract_price);

$details = array();
$details['downpayment_checkbox'] 	= $downpayment_checkbox;
$details['downpayment_recoup'] 		= str_replace(',','',$downpayment_recoup);
$details['downpayment_date'] 		= date('Y-m-d', strtotime($downpayment_date)); 

$details['first_checkbox'] 			= $first_checkbox;
$details['first_percentage'] 		= $first_percentage;
$details['first_amount'] 			= str_replace(',','',$first_amount);
$details['first_wht'] 				= str_replace(',','',$first_wht);
$details['first_recoup'] 			= str_replace(',','',$first_recoup);
$details['first_retention'] 		= str_replace(',','',$first_retention);
$details['first_electricity'] 		= str_replace(',','',$first_electricity);
$details['first_others'] 			= str_replace(',','',$first_others);
$details['first_net'] 				= str_replace(',','',$first_net);
$details['first_date'] 				= date('Y-m-d', strtotime($first_date));  

$details['second_checkbox'] 		= $second_checkbox;
$details['second_percentage'] 		= $second_percentage;
$details['second_amount'] 			= str_replace(',','',$second_amount);
$details['second_wht'] 				= str_replace(',','',$second_wht);
$details['second_recoup'] 			= str_replace(',','',$second_recoup);
$details['second_retention'] 		= str_replace(',','',$second_retention);
$details['second_electricity'] 		= str_replace(',','',$second_electricity);
$details['second_others'] 			= str_replace(',','',$second_others);
$details['second_net'] 				= str_replace(',','',$second_net);
$details['second_date'] 			= date('Y-m-d', strtotime($second_date));  

$details['third_checkbox'] 			= $third_checkbox;
$details['third_percentage'] 		= $third_percentage;
$details['third_amount'] 			= str_replace(',','',$third_amount);
$details['third_wht'] 				= str_replace(',','',$third_wht);
$details['third_recoup'] 			= str_replace(',','',$third_recoup);
$details['third_retention'] 		= str_replace(',','',$third_retention);
$details['third_electricity'] 		= str_replace(',','',$third_electricity);
$details['third_others'] 			= str_replace(',','',$third_others);
$details['third_net'] 				= str_replace(',','',$third_net);
$details['third_date'] 				= date('Y-m-d', strtotime($third_date));  

$details['fourth_checkbox'] 		= $fourth_checkbox;
$details['fourth_percentage'] 		= $fourth_percentage;
$details['fourth_amount'] 			= str_replace(',','',$fourth_amount);
$details['fourth_wht'] 				= str_replace(',','',$fourth_wht);
$details['fourth_recoup'] 			= str_replace(',','',$fourth_recoup);
$details['fourth_retention'] 		= str_replace(',','',$fourth_retention);
$details['fourth_electricity'] 		= str_replace(',','',$fourth_electricity);
$details['fourth_others'] 			= str_replace(',','',$fourth_others);
$details['fourth_net'] 				= str_replace(',','',$fourth_net);
$details['fourth_date'] 			= date('Y-m-d', strtotime($fourth_date));  

$details['fifth_checkbox'] 			= $fifth_checkbox;
$details['fifth_percentage'] 		= $fifth_percentage;
$details['fifth_amount'] 			= str_replace(',','',$fifth_amount);
$details['fifth_wht'] 				= str_replace(',','',$fifth_wht);
$details['fifth_recoup'] 			= str_replace(',','',$fifth_recoup);
$details['fifth_retention'] 		= str_replace(',','',$fifth_retention);
$details['fifth_electricity'] 		= str_replace(',','',$fifth_electricity);
$details['fifth_others'] 			= str_replace(',','',$fifth_others);
$details['fifth_net'] 				= str_replace(',','',$fifth_net);
$details['fifth_date'] 				= date('Y-m-d', strtotime($fifth_date));  

$details['sixth_checkbox'] 			= $sixth_checkbox;
$details['sixth_percentage'] 		= $sixth_percentage;
$details['sixth_amount'] 			= str_replace(',','',$sixth_amount);
$details['sixth_wht'] 				= str_replace(',','',$sixth_wht);
$details['sixth_recoup'] 			= str_replace(',','',$sixth_recoup);
$details['sixth_retention'] 		= str_replace(',','',$sixth_retention);
$details['sixth_electricity'] 		= str_replace(',','',$sixth_electricity);
$details['sixth_others'] 			= str_replace(',','',$sixth_others);
$details['sixth_net'] 				= str_replace(',','',$sixth_net);
$details['sixth_date'] 				= date('Y-m-d', strtotime($sixth_date));  

$details['seventh_checkbox'] 		= $seventh_checkbox;
$details['seventh_percentage'] 		= $seventh_percentage;
$details['seventh_amount'] 			= str_replace(',','',$seventh_amount);
$details['seventh_wht'] 			= str_replace(',','',$seventh_wht);
$details['seventh_recoup'] 			= str_replace(',','',$seventh_recoup);
$details['seventh_retention'] 		= str_replace(',','',$seventh_retention);
$details['seventh_electricity'] 	= str_replace(',','',$seventh_electricity);
$details['seventh_others'] 			= str_replace(',','',$seventh_others);
$details['seventh_net'] 			= str_replace(',','',$seventh_net);
$details['seventh_date'] 			= date('Y-m-d', strtotime($seventh_date));  

$details['eight_checkbox'] 			= $eight_checkbox;
$details['eight_percentage'] 		= $eight_percentage;
$details['eight_amount'] 			= str_replace(',','',$eight_amount);
$details['eight_wht'] 				= str_replace(',','',$eight_wht);
$details['eight_recoup'] 			= str_replace(',','',$eight_recoup);
$details['eight_retention'] 		= str_replace(',','',$eight_retention);
$details['eight_electricity'] 		= str_replace(',','',$eight_electricity);
$details['eight_others'] 			= str_replace(',','',$eight_others);
$details['eight_net'] 				= str_replace(',','',$eight_net);
$details['eight_date'] 				= date('Y-m-d', strtotime($eight_date));  

$details['nine_checkbox'] 			= $nine_checkbox;
$details['nine_percentage'] 		= $nine_percentage;
$details['nine_amount'] 			= str_replace(',','',$nine_amount);
$details['nine_wht'] 				= str_replace(',','',$nine_wht);
$details['nine_recoup'] 			= str_replace(',','',$nine_recoup);
$details['nine_retention'] 			= str_replace(',','',$nine_retention);
$details['nine_electricity'] 		= str_replace(',','',$nine_electricity);
$details['nine_others'] 			= str_replace(',','',$nine_others);
$details['nine_net'] 				= str_replace(',','',$nine_net);
$details['nine_date'] 				= date('Y-m-d', strtotime($nine_date));  

$details['ten_checkbox'] 			= $ten_checkbox;
$details['ten_percentage'] 			= $ten_percentage;
$details['ten_amount'] 				= str_replace(',','',$ten_amount);
$details['ten_wht'] 				= str_replace(',','',$ten_wht);
$details['ten_recoup'] 				= str_replace(',','',$ten_recoup);
$details['ten_retention'] 			= str_replace(',','',$ten_retention);
$details['ten_electricity'] 		= str_replace(',','',$ten_electricity);
$details['ten_others'] 				= str_replace(',','',$ten_others);
$details['ten_net'] 				= str_replace(',','',$ten_net);
$details['ten_date'] 				= date('Y-m-d', strtotime($ten_date));  


$details['total_percentage'] 		= $total_percentage; 
$details['total_amount'] 			= str_replace(',','',$total_amount);
$details['total_wht'] 				= str_replace(',','',$total_wht);
$details['total_recoup'] 			= str_replace(',','',$total_recoup);
$details['total_retention'] 		= str_replace(',','',$total_retention);
$details['total_electricity'] 		= str_replace(',','',$total_electricity);
$details['total_others'] 			= str_replace(',','',$total_others);
$details['total_net'] 				= str_replace(',','',$total_net);

$details['balance_amount'] 			= str_replace(',','',$balance_amount);
$details['balance_wht'] 			= str_replace(',','',$balance_wht);
$details['balance_recoup'] 			= str_replace(',','',$balance_recoup);

$details['downpayment_check'] 		= $downpayment_check; 
$details['first_check'] 			= $first_check; 
$details['second_check'] 			= $second_check; 
$details['third_check'] 			= $third_check; 
$details['fourth_check'] 			= $fourth_check; 
$details['fifth_check'] 			= $fifth_check; 
$details['sixth_check'] 			= $sixth_check; 
$details['seventh_check'] 			= $seventh_check; 
$details['eight_check'] 			= $eight_check; 
$details['nine_check'] 				= $nine_check; 
$details['ten_check'] 				= $ten_check; 

$details['first_water'] 			= str_replace(',','',$first_water);
$details['second_water'] 			= str_replace(',','',$second_water); 
$details['third_water'] 			= str_replace(',','',$third_water); 
$details['fourth_water'] 			= str_replace(',','',$fourth_water); 
$details['fifth_water'] 			= str_replace(',','',$fifth_water); 
$details['sixth_water'] 			= str_replace(',','',$sixth_water); 
$details['seventh_water'] 			= str_replace(',','',$seventh_water); 
$details['eight_water'] 			= str_replace(',','',$eight_water); 
$details['nine_water'] 				= str_replace(',','',$nine_water); 
$details['ten_water'] 				= str_replace(',','',$ten_water);
$details['total_water'] 			= str_replace(',','',$total_water); 

$mainArr['Details']   = serialize($details);
  
	$condArr  = array(); 
	$condArr2 = array(); 
	$mainArr2 = array();
 	  
	if($task=='create'){
		//insert
			$mainArr['Id']				= $mecon->getNextId("Id","releases_to_contractor");
			$mainArr['CreatedDate'] 	= $timeStamp;
			$mainArr['CreatedBy'] 		= $currentUser; 
			$output2 					= $mecon->insertSingleQuery($mainArr,"releases_to_contractor"); 
 			//SAVING TO RELEASES TO CONTRACTOR DETAILS
			$mainArr2[0]['release_contractor_id'] 		= $mainArr['Id']; 
			$mainArr2[0]['releases'] 					= 'downpayment';
			$mainArr2[0]['releases_checkbox'] 			= $details['downpayment_checkbox'];
			$mainArr2[0]['accomplishment_percentage'] 	= $details['downpayment_percentage'];
			$mainArr2[0]['accomplishment_amount'] 		= $details['downpayment_amount'];
			$mainArr2[0]['wht'] 						= $details['downpayment_wht'];
 			$mainArr2[0]['recoup'] 						= $details['downpayment_recoup'];
 			$mainArr2[0]['retention'] 					= $details['downpayment_retention'];
			$mainArr2[0]['electricity'] 				= $details['downpayment_electricity'];
			$mainArr2[0]['water'] 						= $details['downpayment_water'];
			$mainArr2[0]['others'] 						= $details['downpayment_others'];
			$mainArr2[0]['net'] 						= $details['downpayment_net'];
			$mainArr2[0]['date_processed'] 				= $details['downpayment_date'];
 			$mainArr2[0]['check_no'] 					= $details['downpayment_check'];
    
			$mainArr2[1]['release_contractor_id'] 		= $mainArr['Id'];
			$mainArr2[1]['releases'] 					= 'first';
			$mainArr2[1]['releases_checkbox'] 			= $details['first_checkbox'];
			$mainArr2[1]['accomplishment_percentage'] 	= $details['first_percentage'];
			$mainArr2[1]['accomplishment_amount'] 		= $details['first_amount'];
			$mainArr2[1]['wht'] 						= $details['first_wht'];
 			$mainArr2[1]['recoup'] 						= $details['first_recoup'];
 			$mainArr2[1]['retention'] 					= $details['first_retention'];
			$mainArr2[1]['electricity'] 				= $details['first_electricity'];
			$mainArr2[1]['water'] 						= $details['first_water'];
			$mainArr2[1]['others'] 						= $details['first_others'];
			$mainArr2[1]['net'] 						= $details['first_net'];
			$mainArr2[1]['date_processed'] 				= $details['first_date'];
 			$mainArr2[1]['check_no'] 					= $details['first_check'];

			$mainArr2[2]['release_contractor_id'] 		= $mainArr['Id'];
			$mainArr2[2]['releases'] 					= 'second';
			$mainArr2[2]['releases_checkbox'] 			= $details['second_checkbox'];
			$mainArr2[2]['accomplishment_percentage'] 	= $details['second_percentage'];
			$mainArr2[2]['accomplishment_amount'] 		= $details['second_amount'];
			$mainArr2[2]['wht'] 						= $details['second_wht'];
 			$mainArr2[2]['recoup'] 						= $details['second_recoup'];
 			$mainArr2[2]['retention'] 					= $details['second_retention'];
			$mainArr2[2]['electricity'] 				= $details['second_electricity'];
			$mainArr2[2]['water'] 						= $details['second_water'];
			$mainArr2[2]['others'] 						= $details['second_others'];
			$mainArr2[2]['net'] 						= $details['second_net'];
			$mainArr2[2]['date_processed'] 				= $details['second_date'];
 			$mainArr2[2]['check_no'] 					= $details['second_check'];

			$mainArr2[3]['release_contractor_id'] 		= $mainArr['Id']; 
			$mainArr2[3]['releases'] 					= 'third'; 
			$mainArr2[3]['releases_checkbox'] 			= $details['third_checkbox'];
			$mainArr2[3]['accomplishment_percentage'] 	= $details['third_percentage'];
			$mainArr2[3]['accomplishment_amount'] 		= $details['third_amount'];
			$mainArr2[3]['wht'] 						= $details['third_wht'];
 			$mainArr2[3]['recoup'] 						= $details['third_recoup'];
 			$mainArr2[3]['retention'] 					= $details['third_retention'];
			$mainArr2[3]['electricity'] 				= $details['third_electricity'];
			$mainArr2[3]['water'] 						= $details['third_water'];
			$mainArr2[3]['others'] 						= $details['third_others'];
			$mainArr2[3]['net'] 						= $details['third_net'];
			$mainArr2[3]['date_processed'] 				= $details['third_date'];
 			$mainArr2[3]['check_no'] 					= $details['third_check'];

			$mainArr2[4]['release_contractor_id'] 		= $mainArr['Id'];
			$mainArr2[4]['releases'] 					= 'fourth';
			$mainArr2[4]['releases_checkbox'] 			= $details['fourth_checkbox'];
			$mainArr2[4]['accomplishment_percentage'] 	= $details['fourth_percentage'];
			$mainArr2[4]['accomplishment_amount'] 		= $details['fourth_amount'];
			$mainArr2[4]['wht'] 						= $details['fourth_wht'];
 			$mainArr2[4]['recoup'] 						= $details['fourth_recoup'];
 			$mainArr2[4]['retention'] 					= $details['fourth_retention'];
			$mainArr2[4]['electricity'] 				= $details['fourth_electricity'];
			$mainArr2[4]['water'] 						= $details['fourth_water'];
			$mainArr2[4]['others'] 						= $details['fourth_others'];
			$mainArr2[4]['net'] 						= $details['fourth_net'];
			$mainArr2[4]['date_processed'] 				= $details['fourth_date'];
 			$mainArr2[4]['check_no'] 					= $details['fourth_check'];

			$mainArr2[5]['release_contractor_id'] 		= $mainArr['Id']; 
			$mainArr2[5]['releases'] 					= 'fifth';
			$mainArr2[5]['releases_checkbox'] 			= $details['fifth_checkbox'];
			$mainArr2[5]['accomplishment_percentage'] 	= $details['fifth_percentage'];
			$mainArr2[5]['accomplishment_amount'] 		= $details['fifth_amount'];
			$mainArr2[5]['wht'] 						= $details['fifth_wht'];
 			$mainArr2[5]['recoup'] 						= $details['fifth_recoup'];
 			$mainArr2[5]['retention'] 					= $details['fifth_retention'];
			$mainArr2[5]['electricity'] 				= $details['fifth_electricity'];
			$mainArr2[5]['water'] 						= $details['fifth_water'];
			$mainArr2[5]['others'] 						= $details['fifth_others'];
			$mainArr2[5]['net'] 						= $details['fifth_net'];
			$mainArr2[5]['date_processed'] 				= $details['fifth_date'];
 			$mainArr2[5]['check_no'] 					= $details['fifth_check'];

			$mainArr2[6]['release_contractor_id'] 		= $mainArr['Id'];
			$mainArr2[6]['releases'] 					= 'sixth';
			$mainArr2[6]['releases_checkbox'] 			= $details['sixth_checkbox'];
			$mainArr2[6]['accomplishment_percentage'] 	= $details['sixth_percentage'];
			$mainArr2[6]['accomplishment_amount'] 		= $details['sixth_amount'];
			$mainArr2[6]['wht'] 						= $details['sixth_wht'];
 			$mainArr2[6]['recoup'] 						= $details['sixth_recoup'];
 			$mainArr2[6]['retention'] 					= $details['sixth_retention'];
			$mainArr2[6]['electricity'] 				= $details['sixth_electricity'];
			$mainArr2[6]['water'] 						= $details['sixth_water'];
			$mainArr2[6]['others'] 						= $details['sixth_others'];
			$mainArr2[6]['net'] 						= $details['sixth_net'];
			$mainArr2[6]['date_processed'] 				= $details['sixth_date'];
 			$mainArr2[6]['check_no'] 					= $details['sixth_check'];

			$mainArr2[7]['release_contractor_id'] 		= $mainArr['Id'];
			$mainArr2[7]['releases'] 					= 'seventh';
			$mainArr2[7]['releases_checkbox'] 			= $details['seventh_checkbox'];
			$mainArr2[7]['accomplishment_percentage'] 	= $details['seventh_percentage'];
			$mainArr2[7]['accomplishment_amount'] 		= $details['seventh_amount'];
			$mainArr2[7]['wht'] 						= $details['seventh_wht'];
 			$mainArr2[7]['recoup'] 						= $details['seventh_recoup'];
 			$mainArr2[7]['retention'] 					= $details['seventh_retention'];
			$mainArr2[7]['electricity'] 				= $details['seventh_electricity'];
			$mainArr2[7]['water'] 						= $details['seventh_water'];
			$mainArr2[7]['others'] 						= $details['seventh_others'];
			$mainArr2[7]['net'] 						= $details['seventh_net'];
			$mainArr2[7]['date_processed'] 				= $details['seventh_date'];
 			$mainArr2[7]['check_no'] 					= $details['seventh_check'];

			$mainArr2[8]['release_contractor_id'] 		= $mainArr['Id'];
 			$mainArr2[8]['releases'] 					= 'eight';
 			$mainArr2[8]['releases_checkbox'] 			= $details['eight_checkbox'];
			$mainArr2[8]['accomplishment_percentage'] 	= $details['eight_percentage'];
			$mainArr2[8]['accomplishment_amount'] 		= $details['eight_amount'];
			$mainArr2[8]['wht'] 						= $details['eight_wht'];
 			$mainArr2[8]['recoup'] 						= $details['eight_recoup'];
 			$mainArr2[8]['retention'] 					= $details['eight_retention'];
			$mainArr2[8]['electricity'] 				= $details['eight_electricity'];
			$mainArr2[8]['water'] 						= $details['eight_water'];
			$mainArr2[8]['others'] 						= $details['eight_others'];
			$mainArr2[8]['net'] 						= $details['eight_net'];
			$mainArr2[8]['date_processed'] 				= $details['eight_date'];
 			$mainArr2[8]['check_no'] 					= $details['eight_check'];

			$mainArr2[9]['release_contractor_id'] 		= $mainArr['Id'];
 			$mainArr2[9]['releases'] 					= 'nine';
 			$mainArr2[9]['releases_checkbox'] 			= $details['nine_checkbox'];
			$mainArr2[9]['accomplishment_percentage'] 	= $details['nine_percentage'];
			$mainArr2[9]['accomplishment_amount'] 		= $details['nine_amount'];
			$mainArr2[9]['wht'] 						= $details['nine_wht'];
 			$mainArr2[9]['recoup'] 						= $details['nine_recoup'];
 			$mainArr2[9]['retention'] 					= $details['nine_retention'];
			$mainArr2[9]['electricity'] 				= $details['nine_electricity'];
			$mainArr2[9]['water'] 						= $details['nine_water'];
			$mainArr2[9]['others'] 						= $details['nine_others'];
			$mainArr2[9]['net'] 						= $details['nine_net'];
			$mainArr2[9]['date_processed'] 				= $details['nine_date'];
 			$mainArr2[9]['check_no'] 					= $details['nine_check'];

			$mainArr2[10]['release_contractor_id'] 		= $mainArr['Id'];
		 	$mainArr2[10]['releases'] 					= 'ten';
		  	$mainArr2[10]['releases_checkbox'] 			= $details['ten_checkbox'];
			$mainArr2[10]['accomplishment_percentage'] 	= $details['ten_percentage'];
			$mainArr2[10]['accomplishment_amount'] 		= $details['ten_amount'];
			$mainArr2[10]['wht'] 						= $details['ten_wht'];
 			$mainArr2[10]['recoup'] 					= $details['ten_recoup'];
 			$mainArr2[10]['retention'] 					= $details['ten_retention'];
			$mainArr2[10]['electricity'] 				= $details['ten_electricity'];
			$mainArr2[10]['water'] 						= $details['ten_water'];
			$mainArr2[10]['others'] 					= $details['ten_others'];
			$mainArr2[10]['net'] 						= $details['ten_net'];
			$mainArr2[10]['date_processed'] 			= $details['ten_date'];
 			$mainArr2[10]['check_no'] 					= $details['ten_check'];

			$output 					= $mecon->insertMultipleQuery($mainArr2,"releases_to_contractor_details"); 

 
	}else{
		//reservation exist update record
			$mainArr['UpdatedDate'] 	= $timeStamp;
			$mainArr['UpdatedBy'] 		= $currentUser;
			$condArr['Id']				= $mainid;
			$output 					= $mecon->updateQuery($mainArr,"releases_to_contractor",$condArr);
			


			//check exist record if yes delete if not then no need to delete existing and proceed to insert
			$existRecords = $utility->checkExistField('release_contractor_id','releases_to_contractor_details','release_contractor_id',$mainid);
			if($existRecords === true){
				/*
				//DELETE EXISTING DETAILS
				$condArr2['release_contractor_id']			= $mainid;
				$mecon->deleteQuery('releases_to_contractor_details',$condArr2);
				*/
			}
			


/*
			//SAVING TO RELEASES TO CONTRACTOR DETAILS
			$mainArr2[0]['release_contractor_id'] 		= $mainid; 
			$mainArr2[0]['releases'] 					= 'downpayment';
			$mainArr2[0]['releases_checkbox'] 			= $details['downpayment_checkbox'];
			$mainArr2[0]['accomplishment_percentage'] 	= $details['downpayment_percentage'];
			$mainArr2[0]['accomplishment_amount'] 		= $details['downpayment_amount'];
			$mainArr2[0]['wht'] 						= $details['downpayment_wht'];
 			$mainArr2[0]['recoup'] 						= $details['downpayment_recoup'];
 			$mainArr2[0]['retention'] 					= $details['downpayment_retention'];
			$mainArr2[0]['electricity'] 				= $details['downpayment_electricity'];
			$mainArr2[0]['water'] 						= $details['downpayment_water'];
			$mainArr2[0]['others'] 						= $details['downpayment_others'];
			$mainArr2[0]['net'] 						= $details['downpayment_net'];
			$mainArr2[0]['date_processed'] 				= $details['downpayment_date'];
 			$mainArr2[0]['check_no'] 					= $details['downpayment_check'];
    
			$mainArr2[1]['release_contractor_id'] 		= $mainid;
			$mainArr2[1]['releases'] 					= 'first';
			$mainArr2[1]['releases_checkbox'] 			= $details['first_checkbox'];
			$mainArr2[1]['accomplishment_percentage'] 	= $details['first_percentage'];
			$mainArr2[1]['accomplishment_amount'] 		= $details['first_amount'];
			$mainArr2[1]['wht'] 						= $details['first_wht'];
 			$mainArr2[1]['recoup'] 						= $details['first_recoup'];
 			$mainArr2[1]['retention'] 					= $details['first_retention'];
			$mainArr2[1]['electricity'] 				= $details['first_electricity'];
			$mainArr2[1]['water'] 						= $details['first_water'];
			$mainArr2[1]['others'] 						= $details['first_others'];
			$mainArr2[1]['net'] 						= $details['first_net'];
			$mainArr2[1]['date_processed'] 				= $details['first_date'];
 			$mainArr2[1]['check_no'] 					= $details['first_check'];

			$mainArr2[2]['release_contractor_id'] 		= $mainid;
			$mainArr2[2]['releases'] 					= 'second';
			$mainArr2[2]['releases_checkbox'] 			= $details['second_checkbox'];
			$mainArr2[2]['accomplishment_percentage'] 	= $details['second_percentage'];
			$mainArr2[2]['accomplishment_amount'] 		= $details['second_amount'];
			$mainArr2[2]['wht'] 						= $details['second_wht'];
 			$mainArr2[2]['recoup'] 						= $details['second_recoup'];
 			$mainArr2[2]['retention'] 					= $details['second_retention'];
			$mainArr2[2]['electricity'] 				= $details['second_electricity'];
			$mainArr2[2]['water'] 						= $details['second_water'];
			$mainArr2[2]['others'] 						= $details['second_others'];
			$mainArr2[2]['net'] 						= $details['second_net'];
			$mainArr2[2]['date_processed'] 				= $details['second_date'];
 			$mainArr2[2]['check_no'] 					= $details['second_check'];

			$mainArr2[3]['release_contractor_id'] 		= $mainid; 
			$mainArr2[3]['releases'] 					= 'third'; 
			$mainArr2[3]['releases_checkbox'] 			= $details['third_checkbox'];
			$mainArr2[3]['accomplishment_percentage'] 	= $details['third_percentage'];
			$mainArr2[3]['accomplishment_amount'] 		= $details['third_amount'];
			$mainArr2[3]['wht'] 						= $details['third_wht'];
 			$mainArr2[3]['recoup'] 						= $details['third_recoup'];
 			$mainArr2[3]['retention'] 					= $details['third_retention'];
			$mainArr2[3]['electricity'] 				= $details['third_electricity'];
			$mainArr2[3]['water'] 						= $details['third_water'];
			$mainArr2[3]['others'] 						= $details['third_others'];
			$mainArr2[3]['net'] 						= $details['third_net'];
			$mainArr2[3]['date_processed'] 				= $details['third_date'];
 			$mainArr2[3]['check_no'] 					= $details['third_check'];

			$mainArr2[4]['release_contractor_id'] 		= $mainid;
			$mainArr2[4]['releases'] 					= 'fourth';
			$mainArr2[4]['releases_checkbox'] 			= $details['fourth_checkbox'];
			$mainArr2[4]['accomplishment_percentage'] 	= $details['fourth_percentage'];
			$mainArr2[4]['accomplishment_amount'] 		= $details['fourth_amount'];
			$mainArr2[4]['wht'] 						= $details['fourth_wht'];
 			$mainArr2[4]['recoup'] 						= $details['fourth_recoup'];
 			$mainArr2[4]['retention'] 					= $details['fourth_retention'];
			$mainArr2[4]['electricity'] 				= $details['fourth_electricity'];
			$mainArr2[4]['water'] 						= $details['fourth_water'];
			$mainArr2[4]['others'] 						= $details['fourth_others'];
			$mainArr2[4]['net'] 						= $details['fourth_net'];
			$mainArr2[4]['date_processed'] 				= $details['fourth_date'];
 			$mainArr2[4]['check_no'] 					= $details['fourth_check'];

			$mainArr2[5]['release_contractor_id'] 		= $mainid; 
			$mainArr2[5]['releases'] 					= 'fifth';
			$mainArr2[5]['releases_checkbox'] 			= $details['fifth_checkbox'];
			$mainArr2[5]['accomplishment_percentage'] 	= $details['fifth_percentage'];
			$mainArr2[5]['accomplishment_amount'] 		= $details['fifth_amount'];
			$mainArr2[5]['wht'] 						= $details['fifth_wht'];
 			$mainArr2[5]['recoup'] 						= $details['fifth_recoup'];
 			$mainArr2[5]['retention'] 					= $details['fifth_retention'];
			$mainArr2[5]['electricity'] 				= $details['fifth_electricity'];
			$mainArr2[5]['water'] 						= $details['fifth_water'];
			$mainArr2[5]['others'] 						= $details['fifth_others'];
			$mainArr2[5]['net'] 						= $details['fifth_net'];
			$mainArr2[5]['date_processed'] 				= $details['fifth_date'];
 			$mainArr2[5]['check_no'] 					= $details['fifth_check'];

			$mainArr2[6]['release_contractor_id'] 		= $mainid;
			$mainArr2[6]['releases'] 					= 'sixth';
			$mainArr2[6]['releases_checkbox'] 			= $details['sixth_checkbox'];
			$mainArr2[6]['accomplishment_percentage'] 	= $details['sixth_percentage'];
			$mainArr2[6]['accomplishment_amount'] 		= $details['sixth_amount'];
			$mainArr2[6]['wht'] 						= $details['sixth_wht'];
 			$mainArr2[6]['recoup'] 						= $details['sixth_recoup'];
 			$mainArr2[6]['retention'] 					= $details['sixth_retention'];
			$mainArr2[6]['electricity'] 				= $details['sixth_electricity'];
			$mainArr2[6]['water'] 						= $details['sixth_water'];
			$mainArr2[6]['others'] 						= $details['sixth_others'];
			$mainArr2[6]['net'] 						= $details['sixth_net'];
			$mainArr2[6]['date_processed'] 				= $details['sixth_date'];
 			$mainArr2[6]['check_no'] 					= $details['sixth_check'];

			$mainArr2[7]['release_contractor_id'] 		= $mainid;
			$mainArr2[7]['releases'] 					= 'seventh';
			$mainArr2[7]['releases_checkbox'] 			= $details['seventh_checkbox'];
			$mainArr2[7]['accomplishment_percentage'] 	= $details['seventh_percentage'];
			$mainArr2[7]['accomplishment_amount'] 		= $details['seventh_amount'];
			$mainArr2[7]['wht'] 						= $details['seventh_wht'];
 			$mainArr2[7]['recoup'] 						= $details['seventh_recoup'];
 			$mainArr2[7]['retention'] 					= $details['seventh_retention'];
			$mainArr2[7]['electricity'] 				= $details['seventh_electricity'];
			$mainArr2[7]['water'] 						= $details['seventh_water'];
			$mainArr2[7]['others'] 						= $details['seventh_others'];
			$mainArr2[7]['net'] 						= $details['seventh_net'];
			$mainArr2[7]['date_processed'] 				= $details['seventh_date'];
 			$mainArr2[7]['check_no'] 					= $details['seventh_check'];

			$mainArr2[8]['release_contractor_id'] 		= $mainid;
 			$mainArr2[8]['releases'] 					= 'eight';
 			$mainArr2[8]['releases_checkbox'] 			= $details['eight_checkbox'];
			$mainArr2[8]['accomplishment_percentage'] 	= $details['eight_percentage'];
			$mainArr2[8]['accomplishment_amount'] 		= $details['eight_amount'];
			$mainArr2[8]['wht'] 						= $details['eight_wht'];
 			$mainArr2[8]['recoup'] 						= $details['eight_recoup'];
 			$mainArr2[8]['retention'] 					= $details['eight_retention'];
			$mainArr2[8]['electricity'] 				= $details['eight_electricity'];
			$mainArr2[8]['water'] 						= $details['eight_water'];
			$mainArr2[8]['others'] 						= $details['eight_others'];
			$mainArr2[8]['net'] 						= $details['eight_net'];
			$mainArr2[8]['date_processed'] 				= $details['eight_date'];
 			$mainArr2[8]['check_no'] 					= $details['eight_check'];

			$mainArr2[9]['release_contractor_id'] 		= $mainid;
 			$mainArr2[9]['releases'] 					= 'nine';
 			$mainArr2[9]['releases_checkbox'] 			= $details['nine_checkbox'];
			$mainArr2[9]['accomplishment_percentage'] 	= $details['nine_percentage'];
			$mainArr2[9]['accomplishment_amount'] 		= $details['nine_amount'];
			$mainArr2[9]['wht'] 						= $details['nine_wht'];
 			$mainArr2[9]['recoup'] 						= $details['nine_recoup'];
 			$mainArr2[9]['retention'] 					= $details['nine_retention'];
			$mainArr2[9]['electricity'] 				= $details['nine_electricity'];
			$mainArr2[9]['water'] 						= $details['nine_water'];
			$mainArr2[9]['others'] 						= $details['nine_others'];
			$mainArr2[9]['net'] 						= $details['nine_net'];
			$mainArr2[9]['date_processed'] 				= $details['nine_date'];
 			$mainArr2[9]['check_no'] 					= $details['nine_check'];

			$mainArr2[10]['release_contractor_id'] 		= $mainid;
		 	$mainArr2[10]['releases'] 					= 'ten';
		  	$mainArr2[10]['releases_checkbox'] 			= $details['ten_checkbox'];
			$mainArr2[10]['accomplishment_percentage'] 	= $details['ten_percentage'];
			$mainArr2[10]['accomplishment_amount'] 		= $details['ten_amount'];
			$mainArr2[10]['wht'] 						= $details['ten_wht'];
 			$mainArr2[10]['recoup'] 					= $details['ten_recoup'];
 			$mainArr2[10]['retention'] 					= $details['ten_retention'];
			$mainArr2[10]['electricity'] 				= $details['ten_electricity'];
			$mainArr2[10]['water'] 						= $details['ten_water'];
			$mainArr2[10]['others'] 					= $details['ten_others'];
			$mainArr2[10]['net'] 						= $details['ten_net'];
			$mainArr2[10]['date_processed'] 			= $details['ten_date'];
 			$mainArr2[10]['check_no'] 					= $details['ten_check'];

			$output 					= $mecon->insertMultipleQuery($mainArr2,"releases_to_contractor_details"); 
  */

			//SAVING TO RELEASES TO CONTRACTOR DETAILS
			/*
			$mainArr2[0]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[0]['release_contractor_id'] 		= $mainid; 
			$mainArr2[0]['releases'] 					= 'downpayment';
			$mainArr2[0]['releases_checkbox'] 			= $details['downpayment_checkbox'];
			$mainArr2[0]['accomplishment_percentage'] 	= $details['downpayment_percentage'];
			$mainArr2[0]['accomplishment_amount'] 		= $details['downpayment_amount'];
			$mainArr2[0]['wht'] 						= $details['downpayment_wht'];
 			$mainArr2[0]['recoup'] 						= $details['downpayment_recoup'];
 			$mainArr2[0]['retention'] 					= $details['downpayment_retention'];
			$mainArr2[0]['electricity'] 				= $details['downpayment_electricity'];
			$mainArr2[0]['water'] 						= $details['downpayment_water'];
			$mainArr2[0]['others'] 						= $details['downpayment_others'];
			$mainArr2[0]['net'] 						= $details['downpayment_net'];
			$mainArr2[0]['date_processed'] 				= $details['downpayment_date'];
 			$mainArr2[0]['check_no'] 					= $details['downpayment_check'];
    
			$mainArr2[1]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[1]['release_contractor_id'] 		= $mainid;
			$mainArr2[1]['releases'] 					= 'first';
			$mainArr2[1]['releases_checkbox'] 			= $details['first_checkbox'];
			$mainArr2[1]['accomplishment_percentage'] 	= $details['first_percentage'];
			$mainArr2[1]['accomplishment_amount'] 		= $details['first_amount'];
			$mainArr2[1]['wht'] 						= $details['first_wht'];
 			$mainArr2[1]['recoup'] 						= $details['first_recoup'];
 			$mainArr2[1]['retention'] 					= $details['first_retention'];
			$mainArr2[1]['electricity'] 				= $details['first_electricity'];
			$mainArr2[1]['water'] 						= $details['first_water'];
			$mainArr2[1]['others'] 						= $details['first_others'];
			$mainArr2[1]['net'] 						= $details['first_net'];
			$mainArr2[1]['date_processed'] 				= $details['first_date'];
 			$mainArr2[1]['check_no'] 					= $details['first_check'];

			$mainArr2[2]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[2]['release_contractor_id'] 		= $mainid;
			$mainArr2[2]['releases'] 					= 'second';
			$mainArr2[2]['releases_checkbox'] 			= $details['second_checkbox'];
			$mainArr2[2]['accomplishment_percentage'] 	= $details['second_percentage'];
			$mainArr2[2]['accomplishment_amount'] 		= $details['second_amount'];
			$mainArr2[2]['wht'] 						= $details['second_wht'];
 			$mainArr2[2]['recoup'] 						= $details['second_recoup'];
 			$mainArr2[2]['retention'] 					= $details['second_retention'];
			$mainArr2[2]['electricity'] 				= $details['second_electricity'];
			$mainArr2[2]['water'] 						= $details['second_water'];
			$mainArr2[2]['others'] 						= $details['second_others'];
			$mainArr2[2]['net'] 						= $details['second_net'];
			$mainArr2[2]['date_processed'] 				= $details['second_date'];
 			$mainArr2[2]['check_no'] 					= $details['second_check'];

			$mainArr2[3]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[3]['release_contractor_id'] 		= $mainid;
			$mainArr2[3]['releases'] 					= 'third'; 
			$mainArr2[3]['releases_checkbox'] 			= $details['third_checkbox'];
			$mainArr2[3]['accomplishment_percentage'] 	= $details['third_percentage'];
			$mainArr2[3]['accomplishment_amount'] 		= $details['third_amount'];
			$mainArr2[3]['wht'] 						= $details['third_wht'];
 			$mainArr2[3]['recoup'] 						= $details['third_recoup'];
 			$mainArr2[3]['retention'] 					= $details['third_retention'];
			$mainArr2[3]['electricity'] 				= $details['third_electricity'];
			$mainArr2[3]['water'] 						= $details['third_water'];
			$mainArr2[3]['others'] 						= $details['third_others'];
			$mainArr2[3]['net'] 						= $details['third_net'];
			$mainArr2[3]['date_processed'] 				= $details['third_date'];
 			$mainArr2[3]['check_no'] 					= $details['third_check'];

			$mainArr2[4]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[4]['release_contractor_id'] 		= $mainid;
			$mainArr2[4]['releases'] 					= 'fourth';
			$mainArr2[4]['releases_checkbox'] 			= $details['fourth_checkbox'];
			$mainArr2[4]['accomplishment_percentage'] 	= $details['fourth_percentage'];
			$mainArr2[4]['accomplishment_amount'] 		= $details['fourth_amount'];
			$mainArr2[4]['wht'] 						= $details['fourth_wht'];
 			$mainArr2[4]['recoup'] 						= $details['fourth_recoup'];
 			$mainArr2[4]['retention'] 					= $details['fourth_retention'];
			$mainArr2[4]['electricity'] 				= $details['fourth_electricity'];
			$mainArr2[4]['water'] 						= $details['fourth_water'];
			$mainArr2[4]['others'] 						= $details['fourth_others'];
			$mainArr2[4]['net'] 						= $details['fourth_net'];
			$mainArr2[4]['date_processed'] 				= $details['fourth_date'];
 			$mainArr2[4]['check_no'] 					= $details['fourth_check'];

 			$mainArr2[5]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[5]['release_contractor_id'] 		= $mainid;
			$mainArr2[5]['releases'] 					= 'fifth';
			$mainArr2[5]['releases_checkbox'] 			= $details['fifth_checkbox'];
			$mainArr2[5]['accomplishment_percentage'] 	= $details['fifth_percentage'];
			$mainArr2[5]['accomplishment_amount'] 		= $details['fifth_amount'];
			$mainArr2[5]['wht'] 						= $details['fifth_wht'];
 			$mainArr2[5]['recoup'] 						= $details['fifth_recoup'];
 			$mainArr2[5]['retention'] 					= $details['fifth_retention'];
			$mainArr2[5]['electricity'] 				= $details['fifth_electricity'];
			$mainArr2[5]['water'] 						= $details['fifth_water'];
			$mainArr2[5]['others'] 						= $details['fifth_others'];
			$mainArr2[5]['net'] 						= $details['fifth_net'];
			$mainArr2[5]['date_processed'] 				= $details['fifth_date'];
 			$mainArr2[5]['check_no'] 					= $details['fifth_check'];

			$mainArr2[6]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[6]['release_contractor_id'] 		= $mainid;
			$mainArr2[6]['releases'] 					= 'sixth';
			$mainArr2[6]['releases_checkbox'] 			= $details['sixth_checkbox'];
			$mainArr2[6]['accomplishment_percentage'] 	= $details['sixth_percentage'];
			$mainArr2[6]['accomplishment_amount'] 		= $details['sixth_amount'];
			$mainArr2[6]['wht'] 						= $details['sixth_wht'];
 			$mainArr2[6]['recoup'] 						= $details['sixth_recoup'];
 			$mainArr2[6]['retention'] 					= $details['sixth_retention'];
			$mainArr2[6]['electricity'] 				= $details['sixth_electricity'];
			$mainArr2[6]['water'] 						= $details['sixth_water'];
			$mainArr2[6]['others'] 						= $details['sixth_others'];
			$mainArr2[6]['net'] 						= $details['sixth_net'];
			$mainArr2[6]['date_processed'] 				= $details['sixth_date'];
 			$mainArr2[6]['check_no'] 					= $details['sixth_check'];

			$mainArr2[7]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[7]['release_contractor_id'] 		= $mainid;
			$mainArr2[7]['releases'] 					= 'seventh';
			$mainArr2[7]['releases_checkbox'] 			= $details['seventh_checkbox'];
			$mainArr2[7]['accomplishment_percentage'] 	= $details['seventh_percentage'];
			$mainArr2[7]['accomplishment_amount'] 		= $details['seventh_amount'];
			$mainArr2[7]['wht'] 						= $details['seventh_wht'];
 			$mainArr2[7]['recoup'] 						= $details['seventh_recoup'];
 			$mainArr2[7]['retention'] 					= $details['seventh_retention'];
			$mainArr2[7]['electricity'] 				= $details['seventh_electricity'];
			$mainArr2[7]['water'] 						= $details['seventh_water'];
			$mainArr2[7]['others'] 						= $details['seventh_others'];
			$mainArr2[7]['net'] 						= $details['seventh_net'];
			$mainArr2[7]['date_processed'] 				= $details['seventh_date'];
 			$mainArr2[7]['check_no'] 					= $details['seventh_check'];

			$mainArr2[8]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[8]['release_contractor_id'] 		= $mainid;
 			$mainArr2[8]['releases'] 					= 'eight';
 			$mainArr2[8]['releases_checkbox'] 			= $details['eight_checkbox'];
			$mainArr2[8]['accomplishment_percentage'] 	= $details['eight_percentage'];
			$mainArr2[8]['accomplishment_amount'] 		= $details['eight_amount'];
			$mainArr2[8]['wht'] 						= $details['eight_wht'];
 			$mainArr2[8]['recoup'] 						= $details['eight_recoup'];
 			$mainArr2[8]['retention'] 					= $details['eight_retention'];
			$mainArr2[8]['electricity'] 				= $details['eight_electricity'];
			$mainArr2[8]['water'] 						= $details['eight_water'];
			$mainArr2[8]['others'] 						= $details['eight_others'];
			$mainArr2[8]['net'] 						= $details['eight_net'];
			$mainArr2[8]['date_processed'] 				= $details['eight_date'];
 			$mainArr2[8]['check_no'] 					= $details['eight_check'];

			$mainArr2[9]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[9]['release_contractor_id'] 		= $mainid;
 			$mainArr2[9]['releases'] 					= 'nine';
 			$mainArr2[9]['releases_checkbox'] 			= $details['nine_checkbox'];
			$mainArr2[9]['accomplishment_percentage'] 	= $details['nine_percentage'];
			$mainArr2[9]['accomplishment_amount'] 		= $details['nine_amount'];
			$mainArr2[9]['wht'] 						= $details['nine_wht'];
 			$mainArr2[9]['recoup'] 						= $details['nine_recoup'];
 			$mainArr2[9]['retention'] 					= $details['nine_retention'];
			$mainArr2[9]['electricity'] 				= $details['nine_electricity'];
			$mainArr2[9]['water'] 						= $details['nine_water'];
			$mainArr2[9]['others'] 						= $details['nine_others'];
			$mainArr2[9]['net'] 						= $details['nine_net'];
			$mainArr2[9]['date_processed'] 				= $details['nine_date'];
 			$mainArr2[9]['check_no'] 					= $details['nine_check'];

			$mainArr2[10]['id']							= $mecon->getNextId("id","releases_to_contractor_details");
			$mainArr2[10]['release_contractor_id'] 		= $mainid;
		 	$mainArr2[10]['releases'] 					= 'ten';
		  	$mainArr2[10]['releases_checkbox'] 			= $details['ten_checkbox'];
			$mainArr2[10]['accomplishment_percentage'] 	= $details['ten_percentage'];
			$mainArr2[10]['accomplishment_amount'] 		= $details['ten_amount'];
			$mainArr2[10]['wht'] 						= $details['ten_wht'];
 			$mainArr2[10]['recoup'] 					= $details['ten_recoup'];
 			$mainArr2[10]['retention'] 					= $details['ten_retention'];
			$mainArr2[10]['electricity'] 				= $details['ten_electricity'];
			$mainArr2[10]['water'] 						= $details['ten_water'];
			$mainArr2[10]['others'] 					= $details['ten_others'];
			$mainArr2[10]['net'] 						= $details['ten_net'];
			$mainArr2[10]['date_processed'] 			= $details['ten_date'];
 			$mainArr2[10]['check_no'] 					= $details['ten_check'];


			$output 					= $mecon->insertMultipleQuery($mainArr2,"releases_to_contractor_details"); 
		*/

	} 
	/***********************/
 
	//LOG TASK 
			$actArr['UserType']			= "accounting2";  
			$actArr['Remarks']			= "Updated Releases to Contractor : [$mainid] - $contractor";
			$actArr['TransId']			= $mainid; 
			$actArr['Action']			= "edit";
			$actArr['ActionType']		= "releases_to_contractor";
			$actArr['ActionContent']	= json_encode($mainArr);
			$actArr['ActionBy'] 		= $currentUser;	
			$actArr['ActionDate']		= $timeStamp; 
			$utility->encodeActivityLog($actArr);
//endif;

$resultArr 						= array();
$resultArr['output']	  		= $output;

echo json_encode($resultArr); 
exit();
ob_end_flush();