<?php 
include "config.php";
session_start();
$user=$_SESSION['log'];
$code = $_POST['code'];
$date = $_POST['date'];
$time = $_POST['time'];

$jaw_feeder_opening = $_POST['jaw_feeder_opening'];
$jaw_feeder_closing = $_POST['jaw_feeder_closing'];
$jaw_machine_opening=$_POST['jaw_machine_opening'];
$jaw_machine_closing=$_POST['jaw_machine_closing'];

$cone_feeder_opening = $_POST['cone_feeder_opening'];
$cone_feeder_closing = $_POST['cone_feeder_closing'];
$cone_machine_opening=$_POST['cone_machine_opening'];
$cone_machine_closing=$_POST['cone_machine_closing'];

$vsi_feeder_opening = $_POST['vsi_feeder_opening'];
$vsi_feeder_closing = $_POST['vsi_feeder_closing'];
$vsi_machine_opening=$_POST['vsi_machine_opening'];
$vsi_machine_closing=$_POST['vsi_machine_closing'];


$eb_opening = $_POST['eb_opening'];
$eb_closing = $_POST['eb_closing'];

$financial_year = $_POST['financialyear'];
$update = mysqli_query($connect,"update machine_units set status='deleted',editdate=CURRENT_DATE(),edittime=CURRENT_TIME() where code ='$code'");
$code_validate = mysqli_query($connect,"select count(code) as code from machine_units where code='$code' && status!='deleted'");
$code_count=mysqli_fetch_assoc($code_validate);
$code_val = $code_count['code'];
if($code_val==0)
{
$sql = "INSERT INTO machine_units(date, code, jaw_feeder_opening, jaw_feeder_closing, jaw_machine_opening, jaw_machine_closing, cone_feeder_opening, cone_feeder_closing, cone_machine_opening, cone_machine_closing, vsi_feeder_opening, vsi_feeder_closing, vsi_machine_opening, vsi_machine_closing, eb_opening, eb_closing, user, time,financialyear, editdate, edittime, status) VALUES ('$date','$code', '$jaw_feeder_opening', '$jaw_feeder_closing', '$jaw_machine_opening', '$jaw_machine_closing', '$cone_feeder_opening', '$cone_feeder_closing', '$cone_machine_opening', '$cone_machine_closing', '$vsi_feeder_opening', '$vsi_feeder_closing', '$vsi_machine_opening', '$vsi_machine_closing', '$eb_opening', '$eb_closing','$user',CURRENT_TIME(),'$accountyear','','','')";
echo $sql;
 $go = mysqli_query($connect,$sql);
}
 header('Location:machine_units.php');

?>