<?php
include("include/data.php");
Init_boutique();
global $link, $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $myart, $result, $NbLigne, $semaine, $limitesuivante, $limiteprecedente, $total, $page ;
// entete de la page
/*
http://192.168.1.200/horius/traitement_modif_base_tarif.php?ordre=4
num_plu=120
Code_Tarif=744
Num_Code_Tarifs=1
Code_Tva=2
TTCClt=12.80
TTTVA=5.500
MTTVA=
HTCClt=
MGEVD=25
TXMGE=
PVHT=8.50
cpt_plu=70120000
*/



if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$ordre=$_POST['ordre'];
		if (isset($_POST['num_plu'])) { $num_plu=$_POST['num_plu']; }  else {$num_plu=''; }
		if (isset($_POST['Code_Tarif'])) { $Code_Tarif=$_POST['Code_Tarif']; } else {$Code_Tarif=''; }
		if (isset($_POST['Num_Code_Tarifs'])) { $Num_Code_Tarifs=$_POST['Num_Code_Tarifs']; } else {$Num_Code_Tarifs=''; }		
		if (isset($_POST['PVHT'])) { $PVHT=$_POST['PVHT']; } else {$PVHT=''; }
		if (isset($_POST['TTCClt'])) { $TTCClt=$_POST['TTCClt']; } else {$TTCClt=''; }
		if (isset($_POST['cpt_plu'])) { $cpt_plu=$_POST['cpt_plu']; } else {$cpt_plu=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$ordre=$_GET['ordre'];
		if (isset($_GET['num_plu'])) { $num_plu=$_GET['num_plu']; }  else {$num_plu=''; }
		if (isset($_GET['Code_Tarif'])) { $Code_Tarif=$_GET['Code_Tarif']; } else {$Code_Tarif=''; }
		if (isset($_POST['Num_Code_Tarifs'])) { $Num_Code_Tarifs=$_POST['Num_Code_Tarifs']; } else {$Num_Code_Tarifs=''; }
		if (isset($_GET['PVHT'])) { $PVHT=$_GET['PVHT']; } else {$PVHT=''; }
		if (isset($_GET['TTCClt'])) { $TTCClt=$_GET['TTCClt']; } else {$TTCClt=''; }
		if (isset($_GET['cpt_plu'])) { $cpt_plu=$_GET['cpt_plu']; } else {$cpt_plu=''; }
		$valForm="GET" ;
}

//include 'menu/header.php';

$last_num_entre = 0 ;
$sql = 'SELECT max(Num_Base_Tarifs) FROM Base_Tarifs';
$req = mysqli_query($link, $sql); 
$row = mysqli_fetch_row($req);
$last_num_entre = $row[0];
$last_num_entre = $last_num_entre + 1 ;

echo " Num ordre : ".$ordre." | ident plu : ".$num_plu." | NumLigne : ".$Code_Tarif."<br> 
num tarifs : ".$Num_Code_Tarifs."<br> pvttc :".$TTCClt."<br>
pvht : ".$PVHT."<br> LastNum :".$last_num_entre."<br>" ;

$sql = "UPDATE Base_Tarifs SET 
`Num_PLU` = '$num_plu', 
`Prix_HT` = '$PVHT', 
`Prix_TTC` = '$TTCClt', 
`Compte_Cpta` = '$cpt_plu' ,
`Timestamp` = '$timestamp'
WHERE `Num_Base_Tarifs` = '$Code_Tarif'";



echo $sql;
 
$res = mysqli_query($link, $sql);

echo "<br>Requette : ".$res ;

Header("Location: base_tarifs.php?limite=0");

?>
