<?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;
// entete de la page

$date = date("Y/m/d");
$timestamp = date('Y-m-d G:i:s');
//$semaine = date("w");
// menu haut new-supp-modif

echo "<center><br>";

/*
http://192.168.1.200/orius/traitement_maj_bl_haut.php?ordre=3
num_bl=09-95
date_bl=2017-09-26
Num_client_liv=10+520
CodeTrsp=1
CodePaiement=1
date_livr=2017-09-27
observations=
ok=Valider
*/
if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		if (isset($_POST['ordre'])) { $num_ordre=$_POST['ordre']; }  else {$num_ordre=''; }
		if (isset($_POST['num_bl'])) { $num_bl=$_POST['num_bl']; }  else {$num_bl=''; }
		if (isset($_POST['date_bl'])) { $date_bl=$_POST['date_bl']; }  else {$date_bl=''; }
		if (isset($_POST['Num_client_liv'])) { $Num_client_liv=$_POST['Num_client_liv']; } else {$Num_client_liv=''; }
		if (isset($_POST['CodeTrsp'])) { $CodeTrsp=$_POST['CodeTrsp']; }  else {$CodeTrsp=''; }
		if (isset($_POST['CodePaiement'])) { $CodePaiement=$_POST['CodePaiement']; } else {$CodePaiement=''; }
		if (isset($_POST['date_livr'])) { $date_livr=$_POST['date_livr']; }  else {$date_livr=''; }
		if (isset($_POST['observations'])) { $observations=$_POST['observations']; }  else {$observations=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		if (isset($_GET['ordre'])) { $num_ordre=$_GET['ordre']; }  else {$num_ordre=''; }
		if (isset($_GET['num_bl'])) { $num_bl=$_GET['num_bl']; }  else {$num_bl=''; }
		if (isset($_GET['date_bl'])) { $date_bl=$_GET['date_bl']; }  else {$date_bl=''; }
		if (isset($_GET['Num_client_liv'])) { $Num_client_liv=$_GET['Num_client_liv']; } else {$Num_client_liv=''; }
		if (isset($_GET['CodeTrsp']) ){$CodeTrsp = $_GET['CodeTrsp'];} else {$CodeTrsp = '';}
		if (isset($_GET['CodePaiement'])) { $CodePaiement=$_GET['CodePaiement']; } else {$CodePaiement=''; }
		if (isset($_GET['date_livr'])) { $date_livr=$_GET['date_livr']; }  else {$date_livr=''; }
		if (isset($_GET['observations'])) { $observations=$_GET['observations']; }  else {$observations=''; }
		$valForm="GET" ;
}

//echo "$valForm | Valider<br>";

$semaine_bl = date("W", strtotime($date_bl));

$observations = htmlspecialchars($observations, ENT_QUOTES);

// mise a jour haut bl montant et qte
$sql = "UPDATE gestion_bl_haut SET 
`date_bl` = '$date_bl', 
`semaine_bl` = '$semaine_bl' ,
`num_client_bl` = '$Num_client_liv' ,
`date_livraison` = '$date_livr' ,
`num_paie` = '$CodePaiement' ,
`num_trsp` = '$CodeTrsp' ,
`message_bl` = '$observations' WHERE `num_bl` = '$num_bl'";
$sql.=" AND IdNumClient='".$IdNumClient."'";

$Req = mysqli_query($link, $sql); 
//echo "$sql | $Req<br>";


Header("Location: bon_de_livraison.php?limite=0");
?>