<?php 
include "config.php";
session_start();
$user=$_SESSION['log'];
$code = $_POST['code'];
$date = $_POST['date'];
$time = $_POST['time'];
$customer = $_POST['customer'];
$advance = $_POST['advance'];
$remark = $_POST['remark'];
$update = mysqli_query($connect,"update advance set status='deleted',editdate=CURRENT_DATE(),edittime=CURRENT_TIME() where code ='$code'");
$code_validate = mysqli_query($connect,"select count(code) as code from advance where code='$code' && status!='deleted'");
$code_count=mysqli_fetch_assoc($code_validate);
$code_val = $code_count['code'];
if($code_val==0)
{
$sql = "INSERT INTO advance(code, date, time, customer, advance, editby, editdate, edittime, status,remark) VALUES ('$code','$date',CURRENT_TIME(),'$customer','$advance','$user','','','','$remark')";
echo $sql;
$go = mysqli_query($connect,$sql);
}
header("Location:advance.php");
?>