<?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';

/*
modif_qtv.php?
num_entre=3
ordre=4
*/

$date = date("d-m-Y");
$num_ordre=$_GET['ordre'];
$Num_ligne_qtv =$_GET['num_entre'];

/*
echo "<br>Num : $Num_ligne_qtv | Num ordre : $num_ordre | SERVER : ".$_SERVER['PHP_SELF']."<br>" ;
*/

// menu haut new-supp-modif



echo "<center><HR size='1' width='500'>";
echo "<b>Fiche de d&#233;coupe quantitatve</b>";
echo "<center><HR size='1' width='500'>";

Menu_CSD ($num_ordre) ;

echo "<br>";
echo "<table width='650' border='1' cellspacing='1' cellpadding='1'>";
echo "<tr>";
echo "<td width='100'>Num Lot Utilis&#233; :</td>";
echo "<form id='chglotdispo' name ='chglotdispo' method='GET' action='".$_SERVER['PHP_SELF']."'>";
echo "<input type='hidden' name='ordre' value='$num_ordre'/>";
echo "<td><select name='Num_ligne_qtv' id='Num_ligne_qtv' STYLE='width:120' onchange='submit()'>";

$myart =new quantitative_haut;
$select = "select * FROM quantitative_haut ORDER BY `num_lot` ASC ";
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_ligne_qtv_diso=$myart->Num_ligne_qtv ;
  $num_lot=$myart->num_lot ;
  $tracabilite=$myart->tracabilite ;
  $poid_decoupe=$myart->poid_decoupe ;
  $cloture=$myart->cloture ;
  $observations=$myart->observations ;

if  ($Num_ligne_qtv==$Num_ligne_qtv_diso)  {
   echo "<option value='$Num_ligne_qtv_diso' selected='selected' >$num_lot | $tracabilite</option>";
  $Num_ligne_qtv=$Num_ligne_qtv_diso ;
  $num_lot_sel=$num_lot ;
  $poid_entre=$poid_decoupe;

} else {
 echo "<option value='$Num_ligne_qtv_diso'>$num_lot | $tracabilite</option>";
}
}
echo "</select></td>";
//

//
$myart =new entreabat;
$select = "select * FROM entreabat WHERE `Num_Lot`='$num_lot_sel' ";

$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
$Num_Client=$myart->Num_Client ;
$Num_categoriePlu=$myart->Num_categoriePlu ;
$Num_Lot=$myart->Num_Lot ;
$Date_decoupe=$myart-> DateDecoupe ;

}
/*
echo "Num Lot : $num_lot|$num_lot_sel  | Client : $Num_Client | Cateplu :$Num_categoriePlu " ;
*/

echo "</form>";
echo "<form id='form1' name='form1' method='get' action='modif_qtv_check.php'>";
echo "<input type='hidden' name='ordre' value='$num_ordre'/>";
echo "<input type='hidden' name='num_ligne_lot_decoupe' value='$Num_ligne_qtv'/>";
echo "<input type='hidden' name='num_lot_decoupe' value='$num_lot_sel'/>";
//echo "<input type='hidden' name='num_client_decoupe' value='$Num_Client'/>";
//echo "<input type='hidden' name='poid_decoupe' value='$poid_entre'/>";
echo "<input type='hidden' name='Num_CatPlu' value='$Num_categoriePlu'/>";
echo "<input type='hidden' name='tracabilite' value='$tracabilite'/>";


$myart =new categorieplu;
$select = "select * FROM categorieplu WHERE Num_CatPlu='$Num_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 ;
 }
echo "<td width='100'>Categorie : </td>";
echo "<td width='190'>$CategoriePlu" ;
echo "</tr><tr>" ;
echo "<td>Client :</td>";
echo "<td><select name='num_client_decoupe' id='num_client_decoupe' STYLE='width:90'>";

$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_sel=$myart->Num_Client ;
  $Let_Client=$myart->Let_Client ;
  $Nom_Client=$myart->Nom_Client ;

if  ($Num_Client_sel==$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 "<td width='100'>Date D&eacute;coupe</td>";
echo "<td width='190'>"; //.$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 "<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 "<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='3'><input name='observations' type='text' id='observations' accesskey='11' tabindex='11' size='50' maxlength='50' value='$observations'></td>";
echo "</tr><tr></td>";
echo "<td colspan='4'><div align='center'>";
echo "<input type='submit' value='* OK *'>
      </div></td>";
echo "<tr>";
echo "</table></form>";


include 'menu/footer.php';
?>
