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

$rsub_id= $_REQUEST['rsub_id'];
echo $rsub_id;

$strSQLc = "SELECT * FROM qc_resultinout
where rsub_id='$rsub_id'";									
$objQueryc = mysqli_query($con,$strSQLc); 
$objResultc = mysqli_fetch_array($objQueryc);
                                        
$Item_id=$objResultc['Item_id'];
$Cli_code=$objResultc['Cli_code'];
$per_id=$objResultc['per_id'];

$strSQL1 = "SELECT * FROM qc_resultinsub
where Item_id='$Item_id'
and Cli_code='$Cli_code'
and per_id='$per_id'";									
$objQuery1 = mysqli_query($con,$strSQL1); 
$objResult1 = mysqli_fetch_array($objQuery1);
  

//exit;

    $sql1 = "DELETE FROM qc_resultinsub WHERE where Item_id='$objResult1[Item_id]'
    and Cli_code='$objResult1[Cli_code]'
    and per_id='$objResult1[per_id]'";
	$query1 = mysqli_query($con,$sql1);

    $sql = "DELETE FROM qc_resultinout WHERE rsub_id='$rsub_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);

?>