<?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/delete_ligne_bl.php?
ligne=1175
plu=18
lot=CO40HACC17
trac=276T
num_bl=17-10001-10-17
*/

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['ligne'])) { $Num_ligne=$_POST['ligne']; }  else {$Num_ligne=''; }
		if (isset($_POST['plu'])) { $plu=$_POST['plu']; } else {$plu=''; }
		if (isset($_POST['lot'])) { $lot=$_POST['lot']; } else {$lot=''; }
		if (isset($_POST['trac'])) { $trac=$_POST['trac']; } else {$trac=''; }
		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['ligne'])) { $Num_ligne=$_GET['ligne']; }  else {$Num_ligne=''; }
		if (isset($_GET['plu'])) { $plu=$_GET['plu']; } else {$plu=''; }
		if (isset($_GET['lot'])) { $lot=$_GET['lot']; } else {$lot=''; }
		if (isset($_GET['trac'])) { $trac=$_GET['trac']; } else {$trac=''; }
		if (isset($_GET['num_bl'])) { $num_bl=$_GET['num_bl']; } else {$num_bl=''; }
		$valForm="GET" ;
}


// supp ligne detail BL table gestion_bl_detail
echo "supp ligne detail BL table gestion_bl_detail : $Num_ligne<br>";
$sql = "DELETE FROM gestion_br_detail WHERE num_ligne='".$Num_ligne."'";
$sql.=" AND IdNumClient='".$IdNumClient."'";

$res = mysqli_query($link, $sql); 
echo "Sql : ".$sql." | ".$res ;
echo "<br><br>";

// Suppression ligne stock
echo "supp ligne Stock table gestion_bl_detail : $Num_ligne<br>";
$sql = "DELETE FROM stock WHERE `Observations`=\"".$num_bl."\" AND `Num_Lot`=\"".$lot."\" AND `Num_Traca`=\"".$trac."\" AND `Num_Plu`=".$plu;
$sql.=" AND IdNumClient='".$IdNumClient."'";

$res = mysqli_query($link, $sql); 
echo "Sql : ".$sql." | ".$res ;



$refere = $_SERVER['HTTP_REFERER'] ;

Header("Location:  $refere") ;
?>
