<?php
ob_start();
session_start();
require_once("../conn/conn.php");
//include('../utility/chksession.php');
date_default_timezone_set("Asia/Bangkok");


$Cli_id=$_POST['Cli_id'];
$Cli_date=$_POST['Cli_date'];
$Item_id=$_POST['Item_id'];
$Cli_code=$_POST['Cli_code'];
$Cli_ref=$_POST['Cli_ref'];
$Cli_record=$_POST['Cli_record'];
$Cli_checker=$_POST['Cli_checker'];
$Cli_note=$_POST['Cli_note'];

//echo $Item_id.$Item_name;

//exit;


if($Cli_date == "" || $Item_id == ""){
    ?>
        <script language="JavaScript" type="text/javascript">
			<!--
			alert("กรุณากรอกข้อมูลให้ครบถ้วน !!! ");
			location.href='../admin/edit_datainout.php?Cli_id=<?=$Cli_id;?>';
			//-->
		</script>
    <?php 
}else{
    
    
    $strSQL = "SELECT * FROM qc_item where Item_id='$Item_id' ";
    $objQuery = mysqli_query($con,$strSQL);    
    $objResult = mysqli_fetch_array($objQuery);
    
    $Item_name=$objResult['Item_name'];
    //echo $Item_name;
    
    $sql = "UPDATE qc_checklistitem SET Cli_date = '$Cli_date',
    Item_id = '$Item_id',Item_name = '$Item_name',
    Cli_code = '$Cli_code',Cli_ref = '$Cli_ref',
    Cli_record = '$Cli_record',Cli_checker = '$Cli_checker',
    Cli_note = '$Cli_note',Cli_datechecker=NOW()  
    WHERE Cli_id = '$Cli_id'";
	$query = mysqli_query($con,$sql);
        if($query){
            ?>
             <script language="JavaScript" type="text/javascript">
                    <!--
                    alert("บันทึกข้อมูลเรียบร้อย");
                    location.href='../admin/data_inouttest.php';
                    //-->
                </script>   
            <?php
        }else{
            
           // echo "Error: " . $sql . "<br>" . mysqli_error($con);

        }
        mysqli_close($con);
}




?>