<?php
  require_once('includes/load.php');
  // Checkin What level user has permission to view this page
  page_require_level(1);
?>
<?php
  $rawmaterial = find_by_id_new('rawmaterialdetails',(int)$_GET['RawMaterialId'],'RawMaterialId');
  if(!$rawmaterial){
    $session->msg("d","Missing Article id.");
    redirect('rawmaterial.php');
  }
  
   $stockcheck = find_by_column("stockdetails",(int)$_GET['RawMaterialId'],"RawMaterialId");
  $prodcheck = find_by_column("productdetails",(int)$_GET['RawMaterialId'],"RawMaterialId");
  $subcatcheck = find_by_column("subcategorydetails",(int)$_GET['RawMaterialId'],"RawMaterialId");

  if(isset($stockcheck['RawMaterialId']) || isset($prodcheck['RawMaterialId']) || isset($subcatcheck['RawMaterialId'])) {
    $session->msg("d","Unable to detele!... A dependend entry is existing in the database ");
    redirect('RawMaterialId.php');
  }
  
?>
<?php
  $delete_id = delete_by_id_new('rawmaterialdetails',(int)$rawmaterial['RawMaterialId'],'RawMaterialId');
  if($delete_id){
      $session->msg("s","RawMaterial deleted.");
      redirect('rawmaterial.php');
  } else {
      $session->msg("d","RawMaterial deletion failed.");
      redirect('rawmaterial.php');
  }
?>
