<?php
include("include/data.php");
Init_boutique();
global $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $myart, $A_NumArt,$i, $result, $NbLigne, 
$mygroupeart, $mysousgroupeart, $semaine, $limitesuivante, $limiteprecedente, $limite, $total, 
$page, $Nom_Client, $NumAbat,$res;
// entete de la page

//include 'menu/header.php';

$date = date("d-m-Y");

// menu haut new-supp-modif

echo "<center>";
Echo "<table cellspacing=0 cellpadding=0 align=center border=0>";
Echo "<tbody>";
echo "<a href='saisie_ajout_abattoir.php'><b>Nouveau</b></a> <b> | </b>";
echo "<a href=''><b>Consulter</b></a> <b> | </b>";
echo "<a href=''><b>Supprimer</b></a> <b> | </b>";
echo "<a href=''><b>Modifier</b></a>";
Echo "</td></tr>";
Echo "</tbody>";
Echo "</table><br>";

$Num_entre=$_GET['Num_entre'];
echo "<br>Num Entre : ".$Num_entre."<br>" ;

$myart =new entreabat;
$select = "SELECT * FROM entreabat WHERE Num_entre='$Num_entre' AND `IdNumClient`=$IdNumClient";
echo "<br>$select<br>" ;
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_entre=$myart->Num_entre ;
  $NumIdentAn=$myart->NumIdentAn ;
	$Num_Lot=$myart->Num_Lot ;
  $mrs=$myart->mrs ;
  $Qtv=$myart->qtv ;
}

echo "Num entre : ".$Num_entre." <br>";
echo "Num Ident Animal : ".$NumIdentAn." <br>";
echo "Num Lot : ".$Num_Lot." <br>";
echo "Semaine : ".$semaine." <br>";
echo "<br>";

if ($mrs==1) {
echo "mrs ? : Oui  =>".$mrs." <br>";

$sql = "DELETE FROM table_mrs WHERE 'Num_ident_animal'=$NumIdentAn";
echo $sql."<br>";
$res = mysqli_query($link, $sql);
echo "Resultat : $res";

} else {
echo "mrs ? : Non  =>".$mrs." | ";
}

if ($Qtv==1) {
echo "Qtv ? : Oui  =>".$Qtv." | ";

$sql = "DELETE FROM quantitative_haut WHERE 'num_lot'='$Num_Lot'";
echo $sql."<br>";
$res = mysqli_query($link, $sql);
echo "Resultat : $res";

} else {
echo "Qtv ? : Non  =>".$Qtv." <br>";
}

$sql = "DELETE FROM entreabat WHERE Num_entre='$Num_entre'";
echo "<br>".$sql."<br>";
$res = mysqli_query($link, $sql);
echo "Resultat : $res";

$sql = "DELETE FROM lot_dispo WHERE 'num_lot_dispo' ='$Num_Lot'";
echo "<br>".$sql."<br>";
$res = mysqli_query($link, $sql);
echo "Resultat : $res"; 

$sql = "DELETE FROM lot WHERE `num_ligne_detail` ='$Num_entre'";
echo "<br>".$sql."<br>";
$res = mysqli_query($link, $sql);
echo "Resultat : $res";  

Header("Location: saisie_abattoir.php?limite=0");
?>