<?php
include("include/data.php");
Init_boutique();
global $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $myart, $result, $Nom_untie_intrant , 
$NbLigne, $semaine, $limitesuivante, $limiteprecedente, $total, $page, $i ;
// entete de la page

include 'menu/header.php';

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['num_bl'])) { $num_bl=$_POST['num_bl']; }  else {$num_bl=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$num_ordre=$_GET['ordre'];
		if (isset($_GET['num_bl'])) { $num_bl=$_GET['num_bl']; }  else {$num_bl=''; }
		$valForm="GET" ;
}

/*
echo "<br>num entre : $num_entre | $select<br>" ;
echo "$Date_Fabric | $date_e | $DLC_Fabric | $date_dlc | $Num_Lot_Fabric | $Traca_Fabric<br>" ;
echo "$Client_Fabric | $Unite_Fabric | $Observation | $Etat | $Timestamp<br>" ;
echo "$num_plu_intant | $nom_plu_intrant | $num_cate_intrant | $num_unite_plu_intrant | $dlc_plu_intrants<br>" ;
//
//<a class='' href='consult_intrants.php?num_entre=$Num_entre_intrant&ordre=2'></a>
*/

echo "<br><center><b>Modification du Bon de Livraison N&deg; $num_bl </b></center>" ;
Menu_CSD ($num_ordre) ;
$sql ="SELECT * FROM gestion_bl_haut";
$sql.=" WHERE num_bl='".$num_bl."'";
$sql.=" AND IdNumClient='".$IdNumClient."'";  
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
  $num_li_bl = $row["num_li_bl"];
  $num_bl_base = $row["num_bl"];
  $date_bl = $row["date_bl"];
  $semaine_bl = $row["semaine_bl"];	
  $num_client_bl = $row["num_client_bl"];
  $date_livraison = $row["date_livraison"];
  $montant_ht = $row["montant_ht"];
  $poids_livre = $row["poids_livre"];
  $num_paie = $row["num_paie"];	
  $num_trsp = $row["num_trsp"];
  $message_bl = $row["message_bl"];
  $Etat = $row["etat"];
  $Timestamp = $row["Timestamp"];

$sqlb = "SELECT * FROM clients_base WHERE Num_Client='$num_client_bl'"; 
$reqb = mysqli_query($link, $sqlb);
while ($row = mysqli_fetch_assoc($reqb)) {
        $Nom_Client = $row["Nom_Client"];
    }  
}


echo "<center><HR size='1' width='500'></center>";
echo "<form id='ChgCateFabric' id='thing-alerts' name ='ChgCateFabric' method='GET' action='traitement_maj_bl_haut.php'>";
//echo "<input type='hidden' name='num_entre' value='$num_entre'/>";
echo "<input type='hidden' name='ordre' value='$num_ordre'/>";
echo "<input type='hidden' name='num_bl' value='$num_bl'/>";
echo "<table class='t-text' width='750' border='1' cellspacing='1' cellpadding='1'>";
echo "<tr>";
echo "<th colspan=4>Date du Bl : <input type='date' name='date_bl' value ='$date_bl' required></th>";
echo "</tr>";
echo "<th width='120' align='center' valign='middle'>Client : </th>
 	    <th width='120' align='left' valign='middle'>";
echo "<select name='Num_client_liv' id='Num_client_liv' onchange='submit()'>";
echo "<OPTION VALUE='0' SELECTED>Toutes</OPTION>\n";

$select = "SELECT * FROM clients_base WHERE `IdNumClient`='".$IdNumClient."'";
$req = mysqli_query($link, $select);
while ($row = mysqli_fetch_assoc($req)) {
        $Num_Client = $row["Num_Client"];
        $Nom_Client = $row["Nom_Client"];
       
    if ($Num_Client===$num_client_bl) {
    echo "<option value='$Num_Client' Selected>$Nom_Client</option>";
    } else {
    echo "<option value='$Num_Client'>$Nom_Client</option>";
    }
}
echo "</select>";

echo "<th align='center' valign='middle' scope='row'>Code Transport</th>";
echo "<td><select style=' width: 200px;' name='CodeTrsp' id='CodeTrsp' accesskey='13' tabindex='13'>";

$sql = 'SELECT * FROM categorie_trsp';
$sql.=" WHERE `IdNumClient`='".$IdNumClient."'";  
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
  $num_li_trsp = $row["Num_Ligne_Cate_Trsp"];
  $Code_Trsp = $row["Code_Trsp"];
//  echo "$num_li_bl | $num_bl_base <br>" ;
 
 if ($num_trsp==$num_li_trsp){
  echo "<option value='$num_li_trsp' selected>$num_li_trsp | $Code_Trsp</option>";
	} else {
	echo "<option value='$num_li_trsp'>$num_li_trsp | $Code_Trsp</option>";
	}
}

echo "</select></td>";	
	echo "<tr>";
echo "<th align='center' valign='middle' >Code Paiement</th>";
echo "<td><select style=' width: 200px;' name='CodePaiement' id='CodePaiement' accesskey='14' tabindex='14'>";

$sql1 = 'SELECT * FROM categorie_paiement';
$sql1.=" WHERE `IdNumClient`='".$IdNumClient."'";  
$req1 = mysqli_query($link, $sql1);
while ($row = mysqli_fetch_assoc($req1)) {
  $num_li_paiement = $row["Num_Ligne_Cate_Paiement"];
  $Code_paiement = $row["Code_Paiement"];
//  echo "$num_li_bl | $num_bl_base <br>" ;
	
	if ($num_paie==$num_li_paiement){
	echo "<option value='$num_li_paiement' selected>$num_li_paiement | $Code_paiement</option>";
	} else {
	echo "<option value='$num_li_paiement'>$num_li_paiement | $Code_paiement</option>";
		}
  
}

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

echo "<th align='center' valign='middle'>Date de livaison :</th>";
echo "<th width='120' align='left' valign='middle'><input type='date' name='date_livr' value='$date_livraison' required></th> ";
echo "</th></tr> ";
echo "<tr><td colspan ='4'><center> Observations :";
echo "<TEXTAREA name='observations' id='observations' accesskey='15' tabindex='15' rows='5' cols='50' >$message_bl</TEXTAREA></td>";
       

echo "<tr>";
echo "<th colspan='4' align='center' valign='middle'>
	  <input type='submit' name='ok' id='ok' value='Valider' accesskey='11' tabindex='11'>
	  &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
	  <input name='an' type='button' id='an' accesskey='12' tabindex='12' value='Retour' onClick='history.back()'></th>";
echo " </tr></div>";
echo "</table>";
echo "</form>";
echo "</center><br>" ;


include 'menu/footer.php';
?>
