<?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

/*
traitement_modif_clients_base.php?num_entre=53
Num_Client=10+001
Nom_Client=RELIER+Jean+Loup
observations=
Adresse_1=Le+Bourg
Adresse_2=A+coté+Eglise
Adresse_3=Face+Cimetière
Code_postal=46+240
Ville=USSEL
Telephone=05+65+20+00+39
Portable=06+61+33+49+46
Email=jean.loup.relier%40gmail.com
Ccpta=411RELIER
CodeTrsp=1
CodePaiement=2
num_cate_clt=1
Tarifs=3
ok=Valider
*/

if (!isset($_GET['num_entre'])) { 
		// Transmis en POST
		$last_num_entre=$_POST['num_entre'];
if (isset($_POST['Num_Client'])) { $Num_Client=$_POST['Num_Client']; }  else {$Num_Client=''; }
		if (isset($_POST['Nom_Client'])) { $Nom_Client=$_POST['Nom_Client']; }  else {$Nom_Client=''; }
		if (isset($_POST['let_client'])) { $Ident_Client=$_POST['let_client']; }  else {$Ident_Client=''; }
		if (isset($_POST['Adresse_1'])) { $Adr_Client1=$_POST['Adresse_1']; } else {$Adr_Client1=''; }
		if (isset($_POST['Adresse_2'])) { $Adr_Client2=$_POST['Adresse_2']; }  else {$Adr_Client2=''; }
		if (isset($_POST['Adresse_3'])) { $Adr_Client3=$_POST['Adresse_3']; } else {$Adr_Client3=''; }
		if (isset($_POST['Telephone'])) { $Telephone=$_POST['Telephone']; }  else {$Telephone=''; }
		if (isset($_POST['Code_postal'])) { $Code_postal=$_POST['Code_postal']; } else {$Code_postal=''; }
		if (isset($_POST['Ville'])) { $Ville=$_POST['Ville']; }  else {$Ville=''; }
		if (isset($_POST['Portable'])) { $Portable=$_POST['Portable']; } else {$Portable=''; }
		if (isset($_POST['observations'])) { $observations=$_POST['observations']; }  else {$observations=''; }
		if (isset($_POST['Ccpta'])) { $Ccpta=$_POST['Ccpta']; }  else {$Ccpta=''; }
		if (isset($_POST['num_cate_clt'])) { $num_cate_clt=$_POST['num_cate_clt']; }  else {$num_cate_clt=''; }
		if (isset($_POST['Email'])) { $Email=$_POST['Email']; } else {$Email=''; }
		if (isset($_POST['Tarifs'])) { $Tarifs=$_POST['Tarifs']; }  else {$Tarifs=''; }
		if (isset($_POST['CodeTrsp'])) { $CodeTrsp=$_POST['CodeTrsp']; }  else {$CodeTrsp=''; }
		if (isset($_POST['CodePaiement'])) { $CodePaiement=$_POST['CodePaiement']; }  else {$CodePaiement=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$last_num_entre=$_GET['num_entre'];
	if (isset($_GET['Nom_Client'])) { $Nom_Client=$_GET['Nom_Client']; }  else {$Nom_Client=''; }
		if (isset($_GET['let_client'])) { $Ident_Client=$_GET['let_client']; }  else {$Ident_Client=''; }
		if (isset($_GET['Adresse_1'])) { $Adr_Client1=$_GET['Adresse_1']; } else {$Adr_Client1=''; }
		if (isset($_GET['Adresse_2'])) { $Adr_Client2=$_GET['Adresse_2']; }  else {$Adr_Client2=''; }
		if (isset($_GET['Adresse_3'])) { $Adr_Client3=$_GET['Adresse_3']; } else {$Adr_Client3=''; }
		if (isset($_GET['Telephone'])) { $Telephone=$_GET['Telephone']; }  else {$Telephone=''; }
		if (isset($_GET['Code_postal'])) { $Code_postal=$_GET['Code_postal']; } else {$Code_postal=''; }
		if (isset($_GET['Ville'])) { $Ville=$_GET['Ville']; }  else {$Ville=''; }
		if (isset($_GET['Portable'])) { $Portable=$_GET['Portable']; } else {$Portable=''; }
		if (isset($_GET['observations'])) { $observations=$_GET['observations']; }  else {$observations=''; }
		if (isset($_GET['Ccpta'])) { $Ccpta=$_GET['Ccpta']; }  else {$Ccpta=''; }
		if (isset($_GET['num_cate_clt'])) { $num_cate_clt=$_GET['num_cate_clt']; }  else {$num_cate_clt=''; }
		if (isset($_GET['Email'])) { $Email=$_GET['Email']; } else {$Email=''; }
		if (isset($_GET['Tarifs'])) { $Tarifs=$_GET['Tarifs']; }  else {$Tarifs=''; }
		if (isset($_GET['CodeTrsp'])) { $CodeTrsp=$_GET['CodeTrsp']; }  else {$CodeTrsp=''; }
		if (isset($_GET['CodePaiement'])) { $CodePaiement=$_GET['CodePaiement']; }  else {$CodePaiement=''; }
		$valForm="GET" ;
}

/*
$Nom_Client=htmlentities($_POST['Nom_Client']);
$Adr_Client1=htmlentities($_POST['Adresse_1']);
$Adr_Client2=htmlentities($_POST['Adresse_2']);
$Adr_Client3=htmlentities($_POST['Adresse_3']);
$Telephone=htmlentities($_POST['Telephone']);
$Code_postal=htmlentities($_POST['Code_postal']);
$Ville=htmlentities($_POST['Ville']);
$Portable=htmlentities($_POST['Portable']);
$observations=htmlentities($_POST['observations']);
$Email= htmlentities($_POST['Email']);
$Tarifs= htmlentities($_POST['Tarifs']);
*/
//include 'menu/header.php';

// convserson html pour caracteres spéciaux
$Nom_Client = htmlspecialchars($Nom_Client, ENT_QUOTES);
$Adr_Client1 = htmlspecialchars($Adr_Client1, ENT_QUOTES);
$Adr_Client2 = htmlspecialchars($Adr_Client2, ENT_QUOTES);
$Adr_Client3 = htmlspecialchars($Adr_Client3, ENT_QUOTES);
$observations = htmlspecialchars($observations, ENT_QUOTES);

//
echo " Num Clt : ".$last_num_entre." | ident Clt : ".$Ident_Client."<br> 
nom clt : ".$Nom_Client."<br> adr 1 :".$Adr_Client1."<br>
adr 2 : ".$Adr_Client2."<br> adr 3 : ".$Adr_Client3."<br>
CodePostal : ".$Code_postal."<br> Ville : ".$Ville."<br>
tel : ".$Telephone."<br> Port : ".$Portable."<br> 
num_cate_clt :".$num_cate_clt."<br>Ccpta : ".$Ccpta."<br> 
observations : ".$observations."<br> Code Tarifs : ".$Tarifs."
<br> Email : ".$Email."<br>" ;
//

$sql = "UPDATE clients_base SET 
`Nom_Client` = '$Nom_Client', 
`Adresse_1` = '$Adr_Client1', 
`Adresse_2` = '$Adr_Client2', 
`Adresse_3` = '$Adr_Client3', 
`Code_Postal` = '$Code_postal', 
`Ville` = '$Ville', 
`Telephone` = '$Telephone',
`Portable` = '$Portable', 
`Email` = '$Email',
`Code_tarif` = '$Tarifs',
`Code_trsp` = '$CodeTrsp',
`Code_paiement` = '$CodePaiement',
`CompteComptable` = '$Ccpta',
`Code_categorie` = '$num_cate_clt',
`observations` = '$observations' 
WHERE `Num_Client_Base` = '$last_num_entre'";


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

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

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

?>
