<?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, $NewNumLot;
// 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'];
$id_abat=htmlentities($_POST['id_abat']);
$DateEntre_y = $_POST['DateEntre_y'];
$DateEntre_m = $_POST['DateEntre_m'];
$DateEntre_d = $_POST['DateEntre_d'];
$DateAbat_y = $_POST['DateAbat_y'];
$DateAbat_m = $_POST['DateAbat_m'];
$DateAbat_d = $_POST['DateAbat_d'];
$Num_ClientForm=htmlentities($_POST['Num_Client']);
$NumIdent=htmlentities($_POST['NumIdent']);
$NumAbat=htmlentities($_POST['NumAbat']);
$Poids=htmlentities($_POST['Poids']);
$Num_CatPlu=htmlentities($_POST['Num_CatPlu']);
$Observations=htmlentities($_POST['Observations']);
$plu=htmlentities($_POST['plu']);
$mrs=htmlentities($_POST['mrs']);
$NumTicket=htmlentities($_POST['NumTicket']);
$Num_Lot=htmlentities($_POST['Num_Lot']);

$Date_Entre=date("d/m/y", mktime(0,0,0,$DateEntre_m,$DateEntre_d,$DateEntre_y));
$DataAbat=date("d/m/y", mktime(0,0,0,$DateAbat_m,$DateAbat_d,$DateAbat_y));

$NumIdent=strtoupper($NumIdent);

$myart =new clients;
$select = "SELECT * FROM clients WHERE Num_Client='$Num_ClientForm'";
$result = mysql_query($select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_Client=$myart->Num_Client ;
  $Let_Client=$myart->Let_Client ;
  $Nom_Client=$myart->Nom_Client ;
  $Adr_Client1=$myart->adresse_1 ;
  $Adr_Client2=$myart->Adresse_2 ;
  $Adr_Client3=$myart->Adresse_3 ;
  $Telephone=$myart->Telephone ;
  $Portable=$myart->Portable ;
} 
//

//echo $id_abat." <br>";
//echo $Date_Entre." <br>".$DateEntre_d." / ".$DateEntre_m." / ".$DateEntre_y."<br>";
//echo $DataAbat." <br>".$DateAbat_d." / ".$DateAbat_m." / ".$DateAbat_y."<br>";
//echo "Num Client ".$Num_Client." <br>";
//echo "Let Client ".$Let_Client." <br>";
//echo "Nom Client ".$Nom_Client." <br>";
//echo $NumIdent." <br>";
//echo $NumAbat." <br>";
//echo $Poids." <br>";
//echo $Num_CatPlu." <br>";
//echo $Observations." <br>";
//echo $plu." <br>";

$date_e=$Date_Entre;
//echo  date("d/m/Y", mktime(0,0,0,$DateEntre_m,$DateEntre_d,$DateEntre_y))." ".$date_e." <br>";
$date_a=$DataAbat;
//echo  date("d/m/Y", mktime(0,0,0,$DateAbat_m,$DateAbat_d,$DateAbat_y))." ".$date_a." <br>";
$DateAbat_yc=date("y", mktime(0,0,0,$DateAbat_m,$DateAbat_d,$DateAbat_y));

$semaine = date("W", mktime(0,0,0,$DateAbat_m,$DateAbat_d,$DateAbat_y));
//echo  "jour d'abbatage : ".$DateAbat_d." <br>";
//echo  "mois d'abbatage : ".$DateAbat_m." <br>";
//echo  "anne d'abbatage : ".$DateAbat_y." <br>";
//echo  "Anne courte :".$DateAbat_yc." <br>";
//echo  "semaine d'abbatage : ".$semaine." <br><br>";

// creation du numéro de lot
$ident=substr($NumIdent, -4);

//$Num_Lot = printf("%s%s%s%s",$Let_Client,$semaine,$ident,$DateAbat_yc);
//$Num_Lot = $Let_Client.$semaine.$ident.$DateAbat_yc ;
//echo "<br>Num lot : ".$Num_Lot."<br>";

Echo "<center><font color='red'>Verification ligne $Num_entre</font><br></center>";

echo "<table class='t-text' width='500' border='1' cellspacing='1' cellpadding='1'>";
echo "<tr>";
echo "<td width='100'>Num Abattoir</td>";
echo "<td width='100'>$id_abat</td>";
echo "<td width='100'>Date Entre</td>";
echo "<td>$date_e</td></tr>";
echo "<tr>";
echo "<td>Client :</td>";
echo "<td>$Nom_Client</td>";
echo "<td>Date abatage</td>";
echo "<td>$date_a</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Num Identification</td>";
echo "<td>$NumIdent</td>";
echo "<td>Num abatage</td>";
echo "<td>$NumAbat</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Num Ticket :</td>";
echo "<td colspan='4'>$NumTicket</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Poids</td>";
echo "<td>$Poids</td>";
echo "<td>Categorie Plu</td>";
echo "<td>$Num_CatPlu</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Observations</td>";
echo "<td colspan='4'>$Observations</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Numero de Lot : </td>";
echo "<td>$Num_Lot</td>";
echo "<td>mrs ? : </td>";
if ($mrs==1)
echo "<td>Oui</td>";
else
echo "<td>Non</td>";
echo "</tr>";
echo "<td colspan='4'>";
echo "<tr>";
echo "</table></form>";

echo "<center>";
Echo "<table cellspacing=0 cellpadding=0 align=center border=0>";
Echo "<tbody>";

echo "<form id='form1' name='form1' method='post' action='modif_abattoir_check.php?Num_entre=$Num_entre'>";
echo "<input type='hidden' name='id_abat' value='$id_abat'/>";
echo "<input type='hidden' name='date_e' value='$date_e'/>";
echo "<input type='hidden' name='date_a' value='$date_a'/>";
echo "<input type='hidden' name='semaine' value='$semaine'/>";
echo "<input type='hidden' name='NumIdent' value='$NumIdent'/>";
echo "<input type='hidden' name='NumAbat' value='$NumAbat'/>";
echo "<input type='hidden' name='Poids' value='$Poids'/>";
echo "<input type='hidden' name='Num_CatPlu' value='$Num_CatPlu'/>";
echo "<input type='hidden' name='Observations' value='$Observations'/>";
echo "<input type='hidden' name='Num_Client' value='$Num_Client'/>";
echo "<input type='hidden' name='plu' value='950'/>";
echo "<input type='hidden' name='Num_Lot' value='$Num_Lot'/>";
echo "<input type='hidden' name='mrs' value='$mrs'/>";
echo "<input type='hidden' name='Num_entre' value='$Num_entre'/>";
echo "<input type='hidden' name='DateEntre_y' value='$DateEntre_y'/>";
echo "<input type='hidden' name='DateEntre_m' value='$DateEntre_m'/>";
echo "<input type='hidden' name='DateEntre_d' value='$DateEntre_d'/>";
echo "<input type='hidden' name='DateAbat_y' value='$DateAbat_y'/>";
echo "<input type='hidden' name='DateAbat_m' value='$DateAbat_m'/>";
echo "<input type='hidden' name='DateAbat_d' value='$DateAbat_d'/>";
echo "<input type='hidden' name='NumTicket' value='$NumTicket'/>";

echo "<a href='javascript:history.go(-1)'><b>Precedent</b></a> <b> | </b>";
echo "<a href='saisie_abattoir.php?limite=0'><b>Liste</b></a> <b> | </b>";
echo "<a href='javascript:history.go(-1)'><b>Modifier</b></a>";
echo "<input type='submit' value='Modification Lot'>";
Echo "</td></tr>";
Echo "</form></tbody>";
Echo "</table><br>";

include 'menu/footer.php';
?>