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

include 'menu/header.php';
/*
http://192.168.1.200/horius/detail_plu.php?ordre=2&num_plu=1
*/

// Get ou Post existe ou pas ?
if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['num_plu'])) { $num_plu=$_POST['num_plu']; }  else {$num_plu=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$num_ordre=$_GET['ordre'];
		if (isset($_GET['num_plu'])) { $num_plu=$_GET['num_plu']; }  else {$num_plu=''; }
		$valForm="GET" ;
}

$sql = "SELECT * FROM plu WHERE Num_PLU='$num_plu'";
$sql.=" AND IdNumClient='".$IdNumClient."'";

$result =mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($result)) {
        $num_plu = $row["Num_PLU"]; 
			  $nom_plu = $row["PLU"];
			  $nom_plu_compl = $row["Plu_complement"];  
			  $num_cate = $row["Num_CatPlu"];
			  $num_type = $row["Num_TypePlu"]; 
			  $attribu_plu = $row["attribu_plu"]; 
			  $dlc_plu = $row["dlc_plu"];
			  $Cpt_plu = $row["Cpt_cpta"];
}

$sql1 = "SELECT * FROM plu_textes WHERE Num_PLU='$num_plu'";
$sql1.=" AND IdNumClient='".$IdNumClient."'";

$result1 =mysqli_query($link, $sql1);
while ($row = mysqli_fetch_assoc($result1)) {
        $num_plu = $row["Num_PLU"]; 
			  $ingredients = $row["ingredients"];
			  $mlegal_1 = $row["mlegal_1"];  
			  $mlegal_2 = $row["mlegal_2"];
			  $Tmin = $row["Tmin"]; 
			  $Tmax = $row["Tmax"]; 
			  $Tx_tva = $row["Tx_tva"];
			 
}

/*
echo "<br>num entre : $num_plu | $sql<br>" ;
echo "$num_plu | $nom_plu | $nom_plu_compl | $num_cate | $num_type | $attribu_plu | $dlc_plu | $Cpt_plu<br>" ;
*/

echo "<br><center><b>Consultation du d&#233;tail Plu N&#176; $num_plu - $nom_plu  $nom_plu_compl </b></center>" ;

echo "<center><HR size='1' width='500'>";
echo "<a href='plu_detail.php?ordre=$num_ordre&num_plu=$num_plu'><button>P.L.U</button></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='detail_plu.php?ordre=$num_ordre&num_plu=$num_plu'><button>D&#233;tail</button></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href='detail_plu_tarif.php?ordre=$num_ordre&num_plu=$num_plu'><button>Tarif</button></a>";
echo "<br><br>" ;
echo "<table id='t01' border='1' cellpadding='1' cellspacing='1' width='800' height='22'>";
echo "<th width='30' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>N&#176;</div></th></span>";
echo "<th width='30' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>Code Tarif</div></th></span>";
echo "<th width='100' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>Nom Tarif</th></span>";
echo "<th width='50' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>Prix HT vente</th></span>";
echo "<th width='50' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>Prix TTC public</th></span>";
echo "<th width='50' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>Compte Compta</th></span>";
echo "<td width='32' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>M</td></span>";
echo "<td width='32' height='20' valign='center' bgcolor='#CCCCCC'><div align='center'><span class='t-text'>D</td></span>";
echo "</tr>";

$i=0;

$sql2 = "SELECT * FROM Base_Tarifs WHERE Num_PLU='$num_plu'";
$sql2.=" AND IdNumClient='".$IdNumClient."'";
$sql2.=" ORDER BY `Num_Code_Tarif` ASC";

$result2 =mysqli_query($link, $sql2);
while ($row = mysqli_fetch_assoc($result2)) {
$i++ ;               
		$Num_Base_Tarifs= $row["Num_Base_Tarifs"];
		$Prix_HT = $row["Prix_HT"];
		$Prix_TTC = $row["Prix_TTC"];  
		$Num_Code_Tarif = $row["Num_Code_Tarif"];
		$Compte_Cpta = $row["Compte_Cpta"];
  
$sql3 = "SELECT * FROM categorie_tarif WHERE `Num_Code_Tarif`='$Num_Code_Tarif'";  
$sql3.=" AND IdNumClient='".$IdNumClient."'";
$req3=   mysqli_query($link, $sql3) ;
 while ($row = mysqli_fetch_assoc($req3)) {
        $PLU = $row["Code_Tarif"];
    }
/*
echo "<br>".$categorie_plu_intran ;
$date_e=date("d/m/Y", strtotime($Date_Entre));
echo  date("d/m/Y", strtotime($Date_Entre))." ".$date_e;
*/
  
echo "<tr>";
echo "<td width='30' height='20' valign='center'><div align='center'><span class='t-text'>$i</div></td></span>";
echo "<td width='30' height='20' valign='center'><div align='center'><span class='t-text'>$Num_Code_Tarif</div></td></span>";

echo "<td width='100' height='20' valign='center'><div align='center'><span class='t-text'>$PLU</div></a></td></span>";
echo "<td width='50' height='20' valign='center'><div align='center'><span class='t-text'>$Prix_HT &#128;</div></td></span>";
echo "<td width='50' height='20' valign='center'><div align='center'><span class='t-text'>$Prix_TTC &#128;</div></td></span>";
echo "<td width='50' height='20' valign='center'><div align='center'><span class='t-text'>$Compte_Cpta</div></td></span>";
echo "<td width='20' height='20' valign='center'><div align='center'><a class='' href='modif_base_tarifs_plu.php?ordre=4&Num_Code_Tarifs=$Num_Base_Tarifs'><img src='images/modifie.png' width='20' height='20'></a></div></td>";
echo "<td width='20' height='20' valign='center'><div align='center'><a class='' href='delette_base_tarifs_plu.php?ordre=4&Num_Code_Tarifs=$Num_Base_Tarifs'><img src='images/pblle.jpg' width='20' height='20'></a></div></td></tr>";

} 
echo "</tr>";
echo "<tr>";
echo "<th colspan='8' align='center' valign='middle'><a href='plu.php?ordre=1&limite=0'><button>Retour</button></th>";
echo "</tr>";
echo "</table><br>";
echo "</center><br>" ;
//echo $sql1;

include 'menu/footer.php';
?>
