<?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, $num_ligne_lot_dispo_sel ;
// 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 decoupe WHERE num_decoupe='$num_entre'";

$myart =new decoupe;
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
	$myart->readrow($result);
	$num_decoupe=$myart->num_decoupe ;
	$date_decoupe=$myart->date_decoupe ;
	$semaine_decoupe=$myart->semaine_decoupe ;
	$num_client_decoupe=$myart->num_client ;
	$num_lot_decoupe=$myart->num_lot_decoupe ;
	$tracabilite_decoupe=$myart->tracabilite_decoupe ;
	$categorie_decoupe=$myart->categorie_decoupe ;
	$categorie_plu_decoupe=$myart->categorie_plu ;
	$poid_decoupe=$myart->poid_decoupe ;
	$cloture=$myart->cloture ;
	$observations=$myart->observations ;
	
	$num_lot_decoupe=strtoupper ($num_lot_decoupe) ;
	$tracabilite_decoupe=strtoupper ($tracabilite_decoupe) ;
	$semaine_decoupe=date("W", strtotime($date_decoupe));
}
// menu haut new-supp-modif

echo "<div class='titre-text'><center>Modification de la  fiche de d&#233;coupe pour le lot N&deg; $num_lot_decoupe </div></center>";
echo "<HR size='1' width='500'>";

Menu_CSD ($num_ordre) ;

echo "<br>";
echo "<form id='form1' name='form1' method='GET' action='modif_decoupe_check.php'>";
echo "<table class='t-text' width='600' border='0' cellspacing='1' cellpadding='1'>";
echo "<tr>";
echo "<td width='100'>categorie PLU</td>";
echo "<td><select style='width:100px' name='Num_CatPlu' id='Num_CatPlu' disabled>";

$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==$categorie_plu_decoupe)   
  echo "<option value='$Num_CatPluf' selected='selected' >$Num_CatPluf | $CategoriePlu</option>";
else
  echo "<option value='$Num_CatPluf'>$Num_CatPluf | $CategoriePlu</option>";
}
echo "</td>";
echo "<td width='100'>Date D&eacute;coupe</td>";
echo "<td>"; //.$Date_Entre;
  
  $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'date_decoupe';

  $yr=date("Y", strtotime($date_decoupe));
  $mo=date("m", strtotime($date_decoupe));
  $dy=date("d", strtotime($date_decoupe));
  
 // 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_decoupe' id='num_client_decoupe' STYLE='width:80' disabled>";

$myart =new clients;
$select = 'select * FROM clients';
$result = mysqli_query($link, $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 ;

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


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

echo "<td>Num lot : </td>";
echo "<td><select name='num_ligne_lot_decoupe' id='num_ligne_lot_decoupe' STYLE='width:110' disabled>";

$myart =new lot_dispo;
$select = "select * FROM lot_dispo WHERE `num_lot_dispo`='$num_lot_decoupe' ORDER BY num_ligne_lot_dispo ASC ";
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_ligne_lot_dispo=$myart->num_ligne_lot_dispo ;
  $num_lot_dispo=$myart->num_lot_dispo ;
  $num_lot_dispo_trac=$myart->num_lot_dispo_trac ;

if  (($num_lot_decoupe==$num_lot_dispo) && ($tracabilite_decoupe==$num_lot_dispo_trac)) {
  echo "<option value='$num_ligne_lot_dispo' selected='selected' >$num_lot_dispo | $num_lot_dispo_trac</option>";
  $num_ligne_lot_dispo_sel = $num_ligne_lot_dispo ;
} else {
  echo "<option value='$num_ligne_lot_dispo' >$num_lot_dispo | $num_lot_dispo_trac</option>";
}
}


echo "</select></td>";
//echo "$num_lot_decoupe | $num_lot_dispo";
echo "</tr>";
echo "<tr>";

echo "<td>Cat&#233;gorie d&#233;coupe</td>";
// echo "categorie decoupe : $categorie_decoupe" ; //
echo "<td><select style='width:100px' name='num_nat_decoupe' id='num_cate_decoupe' accesskey='7' tabindex='7'>";

$myart =new categorie_decoupe;
$select = 'select * FROM categorie_decoupe';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_cate_decoupe=$myart->num_cate_decoupe ;
  $cate_decoupe=$myart->cate_decoupe ;
  $lettre_trace=$myart->lettre_trace ;
  
if  ($categorie_decoupe==$num_cate_decoupe)   

  echo "<option value='$num_cate_decoupe' selected='selected' >$num_cate_decoupe | $cate_decoupe</option>";
else
  echo "<option value='$num_cate_decoupe'>$num_cate_decoupe | $cate_decoupe</option>";
}
echo "</select></td>";

echo "<input type='hidden' name='num_entre' value='$num_entre'/>";
echo "<input type='hidden' name='num_ligne_lot_decoupe' value='$num_ligne_lot_dispo_sel'/>";
echo "<input type='hidden' name='Num_CatPlu' value='$categorie_plu_decoupe'/>";
echo "<input type='hidden' name='num_client_decoupe' value='$num_client_decoupe'/>";
echo "<input type='hidden' name='semaine_decoupe' value='$semaine_decoupe'/>";
echo "<input type='hidden' name='num_lot_decoupe' value='$num_lot_decoupe'/>";
echo "<input type='hidden' name='tracabilite_decoupe' value='$tracabilite_decoupe'/>";
echo "<input type='hidden' name='num_ligne_lot_dispo' value='$num_ligne_lot_dispo'/>";
echo "<input type='hidden' name='num_entre' value='$num_entre'/>";

//echo "NumEntre : $num_entre | semaine decoupe : $semaine_decoupe" ;

echo "<td>Num Tra&#231;abilit&#233;</td>";
echo "<td><input name='tracabilite_decoupe' type='text' id='tracabilite_decoupe' accesskey='8' tabindex='8' size='19'  value='$tracabilite_decoupe' disabled></td>";
echo "</tr>";
echo "<tr>";
echo "<td>Cl&#244;turer ? : </td>";
if ($cloture==1) {
echo "<td colspan='1'>oui <input name='cloture' type='radio' id='cloture' accesskey='9' tabindex='9' value='1' checked>
non <input name='cloture' type='radio' id='cloture' accesskey='9' tabindex='9' value='0'></td>";
} else {
echo "<td colspan='1'>oui <input name='cloture' type='radio' id='cloture' accesskey='9' tabindex='9' value='1'>
non <input name='cloture' type='radio' id='cloture' accesskey='9' tabindex='9' value='0' checked></td>";
}
// echo "</tr>";
// echo "<tr>";

echo "<td>Poids : </td>";
echo "<td colspan='1'><input name='poid_decoupe' type='text' id='poid_decoupe' accesskey='10' tabindex='10' size='10' maxlength='10' value='$poid_decoupe'> Kg</td>";
echo "</tr>";
echo "<tr>";
echo "<td>Observations</td>";
echo "<td colspan='4'><input name='observations' type='text' id='observations' accesskey='11' tabindex='11' size='50' maxlength='50' value='$observations'></td>";
echo "</tr>";
echo "<td colspan='4'><div align='center'>";
echo "<input type='submit' value='* OK *'>
      </div></td>";
echo "<tr>";
echo "</table></form>";



include 'menu/footer.php';
?>
