<?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_bon_haut.php?ordre=3&num_bon=115&num_bl=17-10001-10-17
*/

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

switch  ($valide) {
	case "NO" :
	include 'menu/header.php';
			echo "<form id='form1' name='form1' method='get' action=''>";
			echo "<input type='hidden' name='num_bon' value='$Num_ligne'/>";
			echo "<input type='hidden' name='num_bl' value='$num_bl'/>";
			echo "<input type='hidden' name='ordre' value='$num_ordre'/>";
			echo "<center>";
			echo "<table border='0' cellpadding='0' cellspacing='0' width='600' height='22'><tr>";
			echo "<td width='600' colspan='3' height='20' valign='center'><div align='center'><span class='t-text'>Souhaitez-vous Supprimer ce Bon de livraison N&deg; $num_bl</center></td>";
			echo "</tr><tr>" ;
			echo "<td width='300' height='30' valign='center'><div align='center'><span class='t-text'><input type='submit' name='valide' value='OUI'><td>";
			echo "<td width='300' height='30' valign='center'><div align='center'><span class='t-text'><input type='submit' name='valide' value='NON'><td>";
			echo "</tr>" ;
			echo "</form>";
	break ;
	
	case "NON" :

	Header("Location: bon_de_livraison.php?limite=0") ;
	break ;
	
	case "OUI" :


// Delette => Gestion Bl Haut
echo "<center>Effacer une saisie $valForm";
//
echo "<br>Num ligne Gestion Bl Haut : ".$Num_ligne." | ";

$sql = "DELETE FROM gestion_bl_haut WHERE num_li_bl='".$Num_ligne."'";
$sql.=" AND IdNumClient='".$IdNumClient."'";
$res = mysqli_query($link, $sql); 

echo "Sql : ".$sql." | ".$res ;

// Delette => Gestion Bl Detail
echo "<br>lignes Gestion Bl detail : ".$Num_ligne." | ";
$sql = "DELETE FROM gestion_bl_detail WHERE num_bl_ligne='".$Num_ligne."'";
$sql.=" AND IdNumClient='".$IdNumClient."'";
$res = mysqli_query($link, $sql); 

echo "Sql : ".$sql." | ".$res ;

// Delette => Temps Bl
echo "<br>lignes Gestion temp_detail_bl detail : ".$Num_ligne." | ";
$sql = "DELETE FROM temp_detail_bl WHERE num_bl_ligne='".$Num_ligne."'";
$sql.=" AND IdNumClient='".$IdNumClient."'";
$res = mysqli_query($link, $sql); 

echo "Sql : ".$sql." | ".$res ;


// Delette => Stock
echo "<br>lignes Stock BL : ".$num_bl." | ";
$sql = "DELETE FROM stock WHERE Observations='".$num_bl."'";
$sql.=" AND IdNumClient='".$IdNumClient."'";
$res = mysqli_query($link, $sql); 

echo "Sql : ".$sql." | ".$res ;


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