<?php 
include "config.php";
include "financial_year_calculation.php";
session_start();
$user=$_SESSION['log'];
$code = $_POST['code'];
$date = $_POST['date'];
$customer = $_POST['customer'];
$total_amount = $_POST['totalamount'];
$pending_amount=$_POST['pendingamount'];
$payment_method = $_POST['paymentmethod'];
$cash = $_POST['cash'];
$other_cash=$_POST['othercash'];
$cheque = $_POST['cheque'];
$remark = $_POST['remark'];
$advance = $_POST['advanceamount'];
$accountyear = $financialYearStart."-".$financialYearEnd;
$code_validate = mysqli_query($connect,"select count(code) as code from debitdetails where code='$code' && status!='deleted'");
$code_count=mysqli_fetch_assoc($code_validate);
$code_val = $code_count['code'];
if($code_val==0)
{
$sql = "INSERT INTO debitdetails(date, customer, totalamount, pendingamount,paymentmethod,amount, otheramount, remark, cheque,advance, code, user, time,financialyear, editdate, edittime, status) VALUES ('$date','$customer','$total_amount','$pending_amount','$payment_method','$cash','$other_cash','$remark','$cheque','$advance','$code','$user',CURRENT_TIME(),'$accountyear','','','')";
echo $sql;
 $go = mysqli_query($connect,$sql);
}
header('Location:debit.php');

?>