<?php 
if(!isset($_SESSION)) { 
  session_start(); 
  include('../includes/dbcon.php');
}
if(empty($_SESSION['rm_id'])):
header('Location:../index.php');
endif;
if (isset($_POST['grnd_no'])) { 
$grnd_no= trim($_POST['grnd_no']);

}


    $deleteHeaderQuery = "DELETE FROM grn_temp_header where grnd_no=$grnd_no ";
    if (mysqli_query($con, $deleteHeaderQuery)) {
         $deleteDetailQuery = "DELETE FROM grn_temp_detail  where grnd_no=$grnd_no";
           if (!mysqli_query($con, $deleteDetailQuery)) {
             echo "<script>document.location='item_grn.php'</script>";
           }
        // If both deletes are successful, redirect
       
    } else {
        // If the delete from inv_temp_header fails, show error
      
        die("Error deleting from inv_temp_header: " . mysqli_error($con));
    }



   
  echo "<script>document.location='item_grn.php'</script>";
  

// Close the database connection
mysqli_close($con);