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


$id_posub=$_POST['id_posub'];
$id_po=$_POST['id_po'];
$wh_datechecker=$_POST['wh_datechecker'];
$part_qtywh=$_POST['part_qtywh'];
$wh_checker=$_POST['wh_checker'];
$part_qty=$_POST['part_qty'];


echo $id_posub.$part_status;

//exit;


if($part_qtywh > $part_qty){
    ?>
                <script language="JavaScript" type="text/javascript">
                    <!--
                    alert("โปรตรวจสอบจำนวนตรวจรับ เนื่องจากเกินจำนวน !!!");
                    location.href='../user/sent_jobwh.php?id_posub=<?=$id_posub;?>';
                    //-->
                </script>
            <?php

}else{
    
     $sql = "UPDATE pd_posub SET part_qtywh = '$part_qtywh',wh_checker = '$wh_checker',wh_datechecker = '$wh_datechecker',part_status='ดำเนินการเรียบร้อย'  WHERE id_posub = '$id_posub'";
	$query = mysqli_query($con,$sql);
	
    $sql1 = "UPDATE pd_po SET po_status='ดำเนินการเรียบร้อย'  WHERE id_po = '$id_po'";
	$query1 = mysqli_query($con,$sql1);
	
	$sql2 = "UPDATE pd_job SET 	jobh_status	='ดำเนินการเรียบร้อย'  WHERE id_posub = '$id_posub'";
	$query2 = mysqli_query($con,$sql2);
	

        if($query){
            ?>
                <script language="JavaScript" type="text/javascript">
                    <!--
                    alert("บันทึกข้อมูลเรียบร้อย");
                    location.href='../user/home_wh.php';
                    //-->
                </script>
            <?php
        }else{
            
            echo "Error: " . $sql . "<br>" . mysqli_error($con);

        }
        mysqli_close($con);

    
}


?>