<?php 
include "config.php";
include "financial_year_calculation.php";
include "current_date_time.php";
session_start();
$user=$_SESSION['log'];
$ticket = $_POST['ticket'];
$vehicleno = $_POST['vehicle'];
$customer = $_POST['customer'];
$tripno = $_POST['trip'];
$delivery = $_POST['delivery'];
$mattype = $_POST['matentrytype'];
$product = $_POST['product'];
$salestype = $_POST['salestype'];
$emptyweight = $_POST['emptyweight'];
$loadweight = $_POST['loadweight'];
$netweight = $_POST['netweight'];
$quantity = $_POST['quantity'];
$quantityori = $_POST['quantityori'];
$remark= $_POST['remark'];
$adjustment =$_POST['adjustment'];
$date = $_POST['datesinen'];
$time = $_POST['timesinen'];
$accountyear    = $financialYearStart."-".$financialYearEnd;
echo $vehicleno;

              error_reporting(0);
              $tktcode = 0;
              $singleCount = 0;

              $ticketResult = mysqli_query($connect, "select count(id) as count from ticket where status !='deleted' && financialyear ='$accountyear'");
              if ($ticketResult) {
                $ticketRow = mysqli_fetch_assoc($ticketResult);
                $tktcode = $ticketRow['count'];
              }

              $singleResult = mysqli_query($connect, "select count(id) as single_count from single_transaction where status !='deleted' && financialyear ='$accountyear'");
              if ($singleResult) {
                $singleRow = mysqli_fetch_assoc($singleResult);
                $singleCount = $singleRow['single_count'];
              }

              $codee = $tktcode + $singleCount;
              $year_code = substr($financialYearEnd,2);
              $codeco = $year_code."-". ($codee+1);
             
//foreach ($productcode as $id => $value ){
$sql = "insert into single_transaction (ticket,vehicleno,customer,trip,delivery,entrydate,entrytime,matentrytype,product,salestype,emptyweight,loadweight,netweight,quantity,quantityori,adjustment,remark,editby,edittime,editdate,status,financialyear) values('T$codeco','$vehicleno','$customer','$tripno','$delivery','$date','$time','$mattype','$product','$salestype','$emptyweight','$loadweight','$netweight','$quantity','$quantityori','$adjustment','$remark','$user',CURTIME(),CURDATE(),'','$accountyear')";
echo $sql;
 $go = mysqli_query($connect,$sql);

 header('Location:singleentry.php');
// }
?>
