<?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, $mrs ;
// entete de la page
include 'menu/header.php';

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

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

$myart =new entreabat;
$select = "SELECT * FROM entreabat WHERE Num_entre='$Num_entre'";
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_entre=$myart->Num_entre ;
  $Num_Abattoir=$myart->Num_Abattoir ;
  $Date_Entre=$myart->Date_Entre ;
  $DataAbat=$myart->DataAbat ;
  $DateDecoup=$myart->DateDecoupe ;
  $SemaineAbat=$myart->SemaineAbat ;
  $NumIdentAn=$myart->NumIdentAn ;
  $Num_Abatage=$myart->Num_Abatage ;
  $Poid=$myart->Poid ;
  $Poid_Chaud=$myart->Poid_Chaud ;
  $TempRecep=$myart->TempRecep ;
  $Num_categoriePlu=$myart->Num_categoriePlu ;
  $Observations=$myart->Observations ;
  $Num_Client=$myart->Num_Client ;
  $Num_Plu=$myart->Num_Plu ;
  $Num_Lot=$myart->Num_Lot ;
  $NumTicket=$myart->NumTicket ;
  $mrs=$myart->mrs ;
  $qtv=$myart->qtv ;
}
// 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 "<b>Modifier</b>";
Echo "</td></tr>";
Echo "</tbody>";
Echo "</table>";

echo "<center><HR size='1' width='500'>";
echo "<b>Modification d'une Entr&eacute;e de Carcasse N&deg; $Num_entre</b>";
echo "<center><HR size='1' width='500'>";


$Num_Abattoirs=$Num_Abattoir;


echo "<form id='form1' name='form1' method='post' action='modif_abattoir_check.php?Num_entre=$Num_entre'>";
echo "<table class='t-text' width='600' border='1' cellspacing='1' cellpadding='1'>";
echo "<tr>";
echo "<td width='100'>Num Abattoir</td>";
echo "<td width='100'><select name='id_abat' id='id_abat'>";

$myart =new abattoir;
$select = 'select * FROM abattoir';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $id_abat=$myart->id_abat ;
  $Num_Abattoirf=$myart->Num_Abattoir ;
  $Nom_abattoir=$myart->Nom_abattoir ;
  $Ville_Abat=$myart->Ville_Abat;

if ($id_abat==$Num_Abattoirs)
	echo "<option value='$id_abat' selected='selected'>$Ville_Abat</option>";
else
	echo "<option value='$id_abat'>$Ville_Abat</option>";
}
echo "</select>";
echo "</td>";
echo "<td width='100'>Date Entre</td>";
echo "<td>"; //.$Date_Entre;
  
  $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'DateEntre';

  $yr=date("Y", strtotime($Date_Entre));
  $mo=date("m", strtotime($Date_Entre));
  $dy=date("d", strtotime($Date_Entre));
  
 // Jour 
  
  $s="<SELECT NAME=\"${name}_d\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$dy>$dy</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=31;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$dy) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i2\"$sclt>$i</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Mois 
  
  $s.="<SELECT NAME=\"${name}_m\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$mo>$mo</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=12;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$mo) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $mon2=date("M", mktime(0, 0, 0, $i, 1, 2001));
  $s.="<OPTION VALUE=\"$i2\"$sclt>$mon2</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Année 
  
  $s.="<SELECT NAME=\"${name}_y\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$yr>$yr</OPTION>\n";
  $sclt=""; 
  for ($i=$fyear;$i<=$lyear;$i++)
  { 
  $i2="$i"; 
  if ($i2==$yr) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i\"$sclt>$i</OPTION>\n"; 
  } 
  $s.="</SELECT>\n"; 
    echo"$s";
echo "</td></tr>";
echo "<tr>";
echo "<td>Client : </td>";
echo "<td><select name='Num_Client' id='Num_Client' STYLE='width:70'>";

$myart =new clients;
$select = "SELECT * FROM clients WHERE `IdNumClient`=$IdNumClient" ;
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_Clientf=$myart->Num_Client ;
  $Let_Client=$myart->Let_Client ;
  $Nom_Client=$myart->Nom_Client ;

if  ($Num_Client==$Num_Clientf) 
echo "<option value='$Num_Clientf' selected='selected'>$Let_Client | $Nom_Client</option>";
else
echo "<option value='$Num_Clientf'>$Let_Client | $Nom_Client</option>";


}



echo "</select></td>";
echo "<td>Date abatage</td>";
echo "<td>";
  $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'DateAbat';

  $yr=date("Y", strtotime($DataAbat));
  $mo=date("m", strtotime($DataAbat));
  $dy=date("d", strtotime($DataAbat));

  
 // Jour 
  
  $s="<SELECT NAME=\"${name}_d\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$dy>$dy</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=31;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$dy) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i2\"$sclt>$i</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Mois 
  
  $s.="<SELECT NAME=\"${name}_m\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$mo>$mo</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=12;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$mo) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $mon2=date("M", mktime(0, 0, 0, $i, 1, 2001));
  $s.="<OPTION VALUE=\"$i2\"$sclt>$mon2</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Année 
  
  $s.="<SELECT NAME=\"${name}_y\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$yr>$yr</OPTION>\n";
  $sclt=""; 
  for ($i=$fyear;$i<=$lyear;$i++)
  { 
  $i2="$i"; 
  if ($i2==$yr) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i\"$sclt>$i</OPTION>\n"; 
  } 
  $s.="</SELECT>\n"; 
    echo"$s";
echo "</td>";
echo "</tr>";
echo "<tr>";

echo "<td>Categorie Plu</td>";
echo "<td><select style='width:100px' name='Num_CatPlu' id='Num_CatPlu'>";

$myart =new categorieplu;
$select = 'select * FROM categorieplu';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_CatPluf=$myart->Num_CatPlu ;
  $CategoriePlu=$myart->CategoriePlu ;
  
if  ($Num_CatPluf==$Num_categoriePlu)   
  echo "<option value='$Num_CatPluf' selected='selected' >$Num_CatPluf | $CategoriePlu</option>";
else
  echo "<option value='$Num_CatPluf'>$Num_CatPluf | $CategoriePlu</option>";
}
echo "<input type='hidden' name='plu' value='950'/>";
echo "<input type='hidden' name='$Num_entre' value='$Num_entre'/>";

echo "</select></td>";

echo "<td>Date D&eacute;coupe</td>";
echo "<td>";
  $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'Date_decoupe';
//$DateDecoup
  $yr=date("Y", strtotime($DateDecoup));
  $mo=date("m", strtotime($DateDecoup));
  $dy=date("d", strtotime($DateDecoup));

  
 // Jour 
  
  $s="<SELECT NAME=\"${name}_d\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$dy>$dy</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=31;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$dy) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i2\"$sclt>$i</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Mois 
  
  $s.="<SELECT NAME=\"${name}_m\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$mo>$mo</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=12;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$mo) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $mon2=date("M", mktime(0, 0, 0, $i, 1, 2001));
  $s.="<OPTION VALUE=\"$i2\"$sclt>$mon2</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Année 
  
  $s.="<SELECT NAME=\"${name}_y\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$yr>$yr</OPTION>\n";
  $sclt=""; 
  for ($i=$fyear;$i<=$lyear;$i++)
  { 
  $i2="$i"; 
  if ($i2==$yr) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i\"$sclt>$i</OPTION>\n"; 
  } 
  $s.="</SELECT>\n"; 
    echo"$s";
echo "</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Num Identification</td>";
echo "<td><input name='NumIdent' type='text' id='NumIdent' accesskey='2' tabindex='2' size='12' maxlength='12' value='$NumIdentAn'></td>";
echo "<td>Num abatage</td>";
echo "<td><input name='NumAbat' type='text' id='NumAbat' accesskey='2' tabindex='2' size='10' maxlength='10' value='$Num_Abatage'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Num Ticket :</td>";
echo "<td><input name='NumTicket' type='text' id='NumTicket' accesskey='2' tabindex='2' size='10' maxlength='10'value='$NumTicket'></td>";
echo "<td>Quantitative : </td>";
if ($qtv==1) {
echo "<td colspan='1'>oui <input name='qtv' type='radio' id='qtv' accesskey='2' tabindex='2' value='1' checked>
non <input name='qtv' type='radio' id='qtv' accesskey='2' tabindex='2' value='0'></td>";
} else {
echo "<td colspan='1'>oui <input name='qtv' type='radio' id='qtv' accesskey='2' tabindex='2' value='1'>
non <input name='qtv' type='radio' id='qtv' accesskey='2' tabindex='2' value='0' checked></td>";
}
echo "</tr>";
echo "<tr>";
echo "<td>Poids</td>";
echo "<td><input name='Poids' type='text' id='Poids' accesskey='2' tabindex='2' size='10' maxlength='10' value='$Poid'></td>";
echo "<td>Poids Chaud</td>";
echo "<td><input name='Poids_chd' type='text' id='Poids_chd' accesskey='2' tabindex='2' size='10' maxlength='10' value='$Poid_Chaud'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>M.R.S ? : </td>";
if ($mrs==1) {
echo "<td colspan='1'>oui <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='1' checked>
non <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='0'></td>";
} else {
echo "<td colspan='1'>oui <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='1'>
non <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='0' checked></td>";
}
// echo "</tr>";
// echo "<tr>";
echo "<td>Num Lot : </td>";
echo "<td colspan='1'><input name='Num_Lot' type='text' id='Num_Lot' accesskey='2' tabindex='2' size='10' maxlength='10' value='$Num_Lot'></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Observations</td>";
echo "<td><input name='Observations' type='text' id='Observations' accesskey='2' tabindex='2' size='10' maxlength='10' value='$Observations'></td>";
echo "<td>Temp&eacute;ratue entr&eacute;e :</td>";
echo "<td><input name='TempRecep' type='text' id='TempRecep' accesskey='2' tabindex='2' size='4' maxlength='10' value='$TempRecep'>C&deg;</td>";

echo "</tr>";
echo "<td colspan='4'><div align='center'>
	  <form id='form1' name='form1' method='post' action='modif_abattoir_check.php?Num_entre=$Num_entre'>
      <input type='submit' value='* OK *'>
      </form></div></td>";
echo "<tr>";
echo "</table></form>";





include 'menu/footer.php';
?>
