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

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