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

include 'menu/header.php';
?>
<html>
  <script type="text/javascript">
  -->
function calculer(){
                var a = document.getElementById("a").value;
				var b1 = document.getElementById("b1").value;
				var d1 = document.getElementById("d1").value;
				
				var options = {style: "currency", currency: "EUR"};
				var numberFormat = new Intl.NumberFormat("fr-FR", options);
				
				var b = a-(a/(1+(b1/100)));
				var c = a-b ;
				var d = c-(c/(1+(d1/100)));
				var e = c-d ;
				
				b = format (b,2," ") ;
				c = format (c,2," ") ;
				d = format (d,2," ") ;
				e = format (e,2," ") ;
				
				--> alert (b) ;			
				--> alert (c) ;
				
				document.getElementById("b").value = b ;
				document.getElementById("c").value = c ;
				document.getElementById("d").value = d ;
				document.getElementById("e").value = e ;             
						
				} 
 
  
function clearFields() {
				document.getElementById("a").value="";
				document.getElementById("b").value="";
				document.getElementById("c").value="";
				document.getElementById("d").value="";
				document.getElementById("e").value="";
}
    -->
  </script>
</html>
<?php
$num_ordre=$_GET['ordre'];
$Num_Code_Tarifs=$_GET['Num_Code_Tarifs'];

// echo $num_ordre." | ".$Num_Code_Tarifs."<br>" ;

$sql = "SELECT * FROM Base_Tarifs WHERE Num_Base_Tarifs='$Num_Code_Tarifs'";
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
	$Num_Base_Tarifs= $row["Num_Base_Tarifs"] ;
  $Num_Code_Tarif= $row["Num_Code_Tarif"] ;
  $Num_PLU= $row["Num_PLU"] ;
  $Prix_HT = $row["Prix_HT"] ;
  $Prix_TTC= $row["Prix_TTC"] ;
  $Compte_Cpta= $row["Compte_Cpta"] ;
}

//echo "$Num_Base_Tarifs | $Num_Code_Tarif | $Num_PLU | $Prix_HT | $Prix_TTC |<br>";

echo "<center><HR size='1' width='500'>";
echo "<center><b>Base Tarifs</b></center>" ;
echo "<center><HR size='1' width='500'>";

Menu_CSD ($num_ordre) ;
echo "<br>";
echo "<form id='form1' name='form1' method='get' action='traitement_modif_base_tarif_plu.php'>";
echo "<input type='hidden' name='ordre' value='$num_ordre'/>";
echo "<input type='hidden' name='num_plu' value='$Num_PLU'/>";
echo "<input type='hidden' name='Code_Tarif' value='$Num_Code_Tarifs'/>";
echo "<input type='hidden' name='Num_Code_Tarifs' value='$Num_Code_Tarif'/>";
echo "<br>";
echo "<table width='500' border='0' cellspacing='1' cellpadding='1'>";
echo "<tr>";
echo "<td width='150'>PLU :</td>";
echo "<td width='150'>";

$sql = 'SELECT * FROM `plu` WHERE `Num_PLU`='.$Num_PLU ;
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
	
	$num_plu_base = $row["Num_PLU"] ;
  $nom_plu =  $row["PLU"] ;
  $cpmpl_plu = $row["Plu_complement"] ;

echo $num_plu_base." - ".$nom_plu." ".$cpmpl_plu ;
}

$Code_Tva = 0 ;
echo "</td>";
echo "</tr><tr>";
echo "<td width='150'>Code Tarif : </td>";
echo "<td width='150'>";

$myart =new categorie_tarif ;
$sql = 'SELECT * FROM `categorie_tarif` WHERE `Num_Code_Tarif`='.$Num_Code_Tarif ;
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
 
  $Num_Code_Tarifs_base =  $row["Num_Code_Tarif"];
  $Code_Tarif =  $row["Code_Tarif"];
  $Code_Tva_base =  $row["Code_Tva"];
  
echo "$Num_Code_Tarifs_base - $Code_Tarif";  
}
echo "<input type='hidden' name='Code_Tva' value='$Code_Tva_base'/>";
echo "</td>";
echo "</tr><tr>" ;
echo "</table>";
echo "<br>";

echo "<table width='800' border='1' cellspacing='2' cellpadding='2'>";

$sql = "SELECT Taux_Tva FROM TVA WHERE Code_Tva='$Code_Tva_base'";  
$req = mysqli_query($link, $sql);  
while ($row = mysqli_fetch_assoc($req)) {
        $Taux_Tva_Base = $row["Taux_Tva"];
    }     
$TauxTva = number_format($Taux_Tva_Base, 3, '.', ' ')	;
//echo "Code TVA : $Code_Tva | Code Tarif : $Code_Tarif | Taux Tva : $TauxTva" ; //
echo "<tr>
<td width='250' height='20' valign='center'><center>Prix TTC Client : </td>
<td width='50' height='20' valign='center'><center><input type='text' id='a' name='TTCClt' value=$Prix_TTC onkeyup='calculer()' onclick='calculer()' size='5'></center></td>";
echo "<tr>
<td><center>Tva : <input type='text' id='b1' size='4' name='TTTVA' value=$TauxTva onkeyup='calculer()'>%</td>
<td><center><input type='text' id='b' name='MTTVA' size='5'></center></td>"; 
echo "<tr>
<td><center>Prix HT Client : </td>
<td><center><input type='text' id='c' name='HTCClt' size='5'></center></td>";
echo "<tr>
<td><center>Taux Mge Vendeur :<input type='text' id='d1'size  ='4' name='MGEVD' value='25' onkeyup='calculer()'>%</td>
<td><center><input type='text' id='d' name='TXMGE' size='5'></center></td>";
echo "<tr>
<td><center>Prix HT : </td>
<td><center><input type='text' name='PVHT' id='e' value=$Prix_HT size='5'></center></td></tr>";

echo "<tr>";
echo "<td align='center' valign='middle'>Compte Compta : </td>
	  <th align='left' valign='middle'>";
echo "<select name='cpt_plu' id='cpt_plu' accesskey='7' tabindex='7'>";


$sql1 = "SELECT * FROM `Plan_Comptable` WHERE `Compte_Cpta` BETWEEN 70000000 AND 71000000";
$sql1.= " AND IdNumClient='".$IdNumClient."'";
$sql1.= " ORDER BY `Compte_Cpta` ASC";

$req = mysqli_query($link, $sql1);  
while ($row = mysqli_fetch_assoc($req)) {
        $cpt_plu_sel = $row["Compte_Cpta"];
        $cpt_plu_nom = $row["Nom_Compte_Cpta"];
      

 if ($cpt_plu_sel==$Compte_Cpta) {
	echo "<option value='$cpt_plu_sel' selected='selected'>$cpt_plu_sel | $cpt_plu_nom</option>";
 } else {
	echo "<option value='$cpt_plu_sel'>$cpt_plu_sel | $cpt_plu_nom</option>";
}}
echo "</select>";

echo "</td></tr> ";

echo "<tr>
<td colspan=2><center><input type='button' value='Effacer Saisie' onclick='clearFields()' ></center></td>"; 
echo "</tr>";
echo "</table>";
echo "<br><br><center><input type='submit' value='* Envoyer *'></center>";      

echo "</form>";
// Pied de Page


include 'menu/footer.php';
?>
