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

/*
http://192.168.1.200/orius/maj_haut_bl.php?ordre=3&num_bl=44
*/
if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		if (isset($_POST['ordre'])) { $num_ordre=$_POST['ordre'];}
		if (isset($_POST['num_bl'])) { $num_bl_base=$_POST['num_bl']; }  else {$num_bl_base=''; }
		if (isset($_POST['num_bl_ligne'])) { $num_bl_ligne=$_POST['num_bl_ligne']; }  else {$num_bl_ligne=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		if (isset($_GET['ordre'])) { $num_ordre=$_GET['ordre']; }
		if (isset($_GET['num_bl'])) { $num_bl=$_GET['num_bl']; }  else {$num_bl=''; }
		if (isset($_GET['num_bl_ligne'])) { $num_bl_ligne=$_GET['num_bl_ligne']; }  else {$num_bl_ligne=''; }
		$valForm="GET" ;
}


// menu haut new-supp-modif



//
echo "<center><br>MAJ Haut Bl<br>";
echo "<br>Num Ordre :$num_ordre | Num Ligne BL : $num_bl_ligne Num BL : $num_bl<br>";


$sql3 ="SELECT SUM(poids), SUM(nb_pi), SUM(montant_ht) FROM gestion_bl_detail";
	$sql3.=" WHERE num_bl='".$num_bl."'";
	$sql3.=" AND num_bl_ligne='".$num_bl_ligne."'";
	$sql3.=" AND IdNumClient='".$IdNumClient."'";  
	$req3=mysqli_query($link, $sql3);  
	while ($row = mysqli_fetch_assoc($req3)) {

	        $poids_total_bl = $row["SUM(poids)"];
	        $nb_pi_total_bl = $row["SUM(nb_pi)"];
	        $montant_total_bl = $row["SUM(montant_ht)"];
	}
	echo "<br>sql : $sql3<br>";
$poids_total_bl = number_format($poids_total_bl, 2, '.', '')	;	
$montant_total_bl = number_format($montant_total_bl, 2, '.', '')	;
$nb_pi_total_bl = number_format($nb_pi_total_bl, 0, '.', '')	;	
	
// mise a jour haut bl montant et qte
$sql_maj_ht_bl = "UPDATE gestion_bl_haut SET 
`poids_livre` = '$poids_total_bl', 
`nb_pi_livre` = '$nb_pi_total_bl', 
`montant_ht` = '$montant_total_bl',
`etat`= 0  
WHERE `num_li_bl` = $num_bl_ligne 
AND `IdNumClient` ='$IdNumClient' ";  

$Req_maj_ht_bl = mysqli_query($link, $sql_maj_ht_bl); 

echo "$sql_maj_ht_bl | $Req_maj_ht_bl<br>";


$refere = $_SERVER['HTTP_REFERER'] ;
echo "<br>$refere<br>";
Header("Location:  $refere") ;
?>
