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

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

$num_entre=$_GET['num_entre'];
$num_ordre=$_GET['ordre'];
//
//echo "<br>Num Entre : $num_entre | Num ordre : $num_ordre <br>" ;
//

$select = "SELECT * FROM intrants WHERE Num_entre_intrant='$num_entre'";

$myart =new intrants;
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_entre_intrant=$myart->Num_entre_intrant ;
  $Num_Fournisseur=$myart->Num_Fournisseur ;
  $Date_Entre=$myart->Date_Entre ;
  $Date_DLC=$myart->Date_DLC;	
  $Num_Bl=$myart->Num_Bl ;
  $Poids=$myart->Poids ;
  $num_unite=$myart->num_unite ;
  $Num_Cate_Intrants=$myart->Num_Cate_Intrants ;	
  $Observations=$myart->Observations ;
  $Num_Plu=$myart->Num_Plu ;
  $Num_Lot_intrants=$myart->Num_Lot ;
  $semaine_intrant=$myart->semaine_intrant ;
  $etat=$myart->etat ;
	
	$semaine_entree=date("W", strtotime($Date_Entre));
   // $Date_Entre=date("d/m/Y", strtotime($Date_Entre));
   // $Date_DLC=date("d/m/Y", strtotime($Date_DLC)) ;
	$Date_jour=date("d/m/Y", strtotime($date)) ;
}
// menu haut new-supp-modif

echo "<center><HR size='1' width='500'>";
echo "<b>Fiche d'entr&#233;e intrant N&deg; $Num_entre_intrant pour le lot N&deg; $Num_Lot_intrants de le semaine $semaine_intrant</b>";
echo "<center><HR size='1' width='500'>";

Menu_CSD ($num_ordre) ;

echo "<br>";
echo "<form id='form1' name='form1' method='POST' action='modif_intrants_check.php'>";
echo "<input type='hidden' name='num_entre' value='$num_entre'/>";
echo "<input type='hidden' name='Num_Lot_intrants' value='$Num_Lot_intrants'/>";
echo "<table class='t-text' width='650' border='1' cellspacing='2' cellpadding='4'>";
echo "<tr>";
echo "<td width='150'>Intant :</td>";
echo "<td width='150'><select style='width:120px' name='Num_Plu' id='Num_Plu'>";

$myart =new plu_intrant;
$select = 'select * FROM plu_intrant';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_plu_intrant=$myart->num_plu_intrant ;
  $nom_plu_intrant=$myart->nom_plu_intrant ;
  $dlc_plu_intrant=$myart->dlc_plu_intrant ;
  
if  ($Num_Plu==$num_plu_intrant) {  
  echo "<option value='$num_plu_intrant' selected='selected' >$nom_plu_intrant</option>";
$dlc_plu_intrant_sel=$dlc_plu_intrant ;
} else {
  echo "<option value='$num_plu_intrant'>$nom_plu_intrant</option>";
}}
echo "</select></td>";


echo "<td width='150'>Cat&#233;gorie Intrant : </td>";
echo "<td width='200'><select style='width:100px' name='num_cate_plu_intran' id='num_cate_plu_intran'>";

$myart =new categorie_intrant;
$select = 'select * FROM categorie_intrant';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_cate_plu_intran=$myart->num_cate_plu_intran ;
  $categorie_plu_intran=$myart->categorie_plu_intran ;
  
if  ($num_cate_plu_intran==$Num_Cate_Intrants) {
  echo "<option value='$num_cate_plu_intran' selected='selected' >$categorie_plu_intran</option>";

} else {
  echo "<option value='$num_cate_plu_intran'>$categorie_plu_intran</option>";
}}
echo "</select></td>";
echo "</tr>";
echo "<tr>";
echo "<td width='150'>Fournisseur  Intrant :</td>";
echo "<td width='150'><select style='width:120px' name='id_presta' id='id_presta'>";

$myart =new fournisseurs;
$select = 'select * FROM fournisseurs WHERE `num_cate_four`>1';
$result = mysqli_query($link, $select);
$myart->getnum($result);
  while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $id_presta=$myart->Num_fournisseur ;
  $Ident_four=$myart->Ident_four ;
  
  if  ($Num_Fournisseur==$id_presta)   
  echo "<option value='$id_presta' selected='selected' >$Ident_four</option>";
else
  echo "<option value='$id_presta'>$Ident_four</option>";

}

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


echo "<td width='150'>Date entr&#233;e :</td>";
echo "<td width='200'>";
 
 $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'Date_Entre';

  $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 width='150'>N&deg; BL Intrant :</td>";
echo "<td width='150'><input name='Num_Bl' type='text' id='Num_Bl' accesskey='2' tabindex='2' size='15' maxlength='20' value='$Num_Bl'></td>"; 
echo "<td width='150'>Date DLC : + $dlc_plu_intrant_sel jours</td>";
echo "<td width='150'>";
$class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'Date_DLC';

  $yr=date("Y", strtotime($Date_DLC));
  $mo=date("m", strtotime($Date_DLC));
  $dy=date("d", strtotime($Date_DLC));
  
 // 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 width='150'>Poids Intrant : $nom_untite</td>";
echo "<td width='150'><input name='Poids' type='text' id='Poids' accesskey='2' tabindex='2' size='5' maxlength='5' value='$Poids'>  ";
echo "<select style='width:50px' name='num_unite' id='num_unite'>";
$myart =new unitee;
$select = 'select * FROM unitee';
$result = mysqli_query($link, $select);
$myart->getnum($result);
  while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_unite_base=$myart->num_unite ;
  $nom_unite_ini=$myart->nom_unite_ini ;
  
  if  ($num_unite==$num_unite_base)   
  echo "<option value='$num_unite' selected='selected' >$nom_unite_ini</option>";
else
  echo "<option value='$num_unite'>$nom_unite_ini</option>";

}
echo "</td>";
echo "<td width='150'>Etat intrant : </td>";
echo "<td width='150'>"; 

	if ($etat==0) {
	echo "En Cours <input name='etat' type='radio' id='etat' accesskey='9' tabindex='9' value='0' checked>
		Fermer <input name='etat' type='radio' id='etat' accesskey='9' tabindex='9' value='1'></td>";
	} else {
	echo "En Cours <input name='etat' type='radio' id='etat' accesskey='9' tabindex='9' value='0'>
	Fermer <input name='etat' type='radio' id='etat' accesskey='9' tabindex='9' value='1' checked></td>";
}
echo "</tr>";

echo "<td>Observations :</td>";
echo "<td colspan='4'><input name='Observations' type='text' id='Observations' accesskey='2' tabindex='2' size='50' maxlength='30' value='$Observations'></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'>
echo "<input type='submit' value='* OK *'>
      </div></td>";
echo "<tr>";
echo "</table></form>";


include 'menu/footer.php';
?>
