<?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'];
$upi_number = $_POST['upi_number'];
$remark = $_POST['remark'];
$invoice = $_POST['invoice'];
$accountyear    = $financialYearStart."-".$financialYearEnd;
$year_code = substr($financialYearEnd,2);
$code_validate = mysqli_query($connect,"select count(code) as code from creditdetails where code='$code' && status!='deleted'");
$code_count=mysqli_fetch_assoc($code_validate);
$code_val = $code_count['code'];
if($code_val==0)
{
$sql = "INSERT INTO creditdetails(date, customer,sales_code, totalamount, pendingamount,paymentmethod,amount, otheramount,upi_number, remark, cheque, code, user, time,financialyear, editdate, edittime, status) VALUES ('$date','$customer','$invoice','$total_amount','$pending_amount','$payment_method','$cash','$other_cash','$upi_number','$remark','$cheque','$code','$user',CURRENT_TIME(),'$accountyear','','','')";
echo $sql;
 $go = mysqli_query($connect,$sql);
}
  header('Location:credit.php');

?>