<?php 
include("../../config.php");
$status = 'false';
if(!empty($_POST)){

	$account_code 			= $_POST['account_code'];
	$account_name 			= $_POST['account_name'];
	$transaction_balance_cr = $_POST['transaction_balance_cr'];
	$transaction_balance_dr = $_POST['transaction_balance_dr'];
	$closing_balance_cr 	= $_POST['closing_balance_cr'];
	$closing_balance_dr 	= $_POST['closing_balance_dr'];
	$closing_balance 		= $_POST['closing_balance'];
	$closing_balance_flag 	= $_POST['closing_balance_flag'];
	$opening_debit 			= $_POST['opening_debit'];
	$opening_credit 		= $_POST['opening_credit'];
	$opening_balance 		= $_POST['opening_balance'];
	$opening_flag 			= $_POST['opening_flag'];
	$array_data 			= $_POST['data'];
	$created_id 			= $_SESSION['user_detail']['id'];

	$delete = mysqli_query($conn, "DELETE FROM `ledger_print` WHERE `act_code` = '".$account_code."' AND `user_id` = '".$created_id."'");
    
	if(count($array_data) > 0){
		foreach ($array_data as $key => $array_datas) {
		    
			$insert = mysqli_query($conn, "INSERT INTO `ledger_print`(`act_code`, `act_name`, `date`, `voucher`, `type`, `account`, `debit`, `credit`, `balance`, `flag`, `remarks`, `cl_date`, `tr_bal_dr`, `tr_bal_cr`, `cl_bal_dr`, `cl_bal_cr`, `cl_bal_flag`, `opening_debit`, `opening_credit`, `opening_balance`, `opening_flag`, `user_id`) VALUES ('".$account_code."','".$account_name."','".$array_datas['voucher_date']."','".$array_datas['voucher_no']."','".$array_datas['type']."','".$array_datas['account_name']."','".$array_datas['damount']."','".$array_datas['camount']."','".$array_datas['tclosing']."','".$array_datas['bflag']."','".$array_datas['remark']."','','".$transaction_balance_dr."','".$transaction_balance_cr."','".$closing_balance_dr."','".$closing_balance_cr."','".$closing_balance_flag."','".$opening_debit."','".$opening_credit."','".$opening_balance."','".$opening_flag."','".$created_id."')");
		}
	}
	$status = 'true';
}
echo json_encode(array('status' => $status,'account_code' => $account_code,'created_id' => $created_id));
die();
?>