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

$refere = $_SERVER['HTTP_REFERER'] ;

echo "<center><br>";

/*
http://192.168.1.200/horius/traitement_ajout_plu.php?str=0
Num_entre=124
ordre=1
nom_plu=Cote+de+veau
nom_plu_compl=%C3%A0+La+Milanaise
num_cate_plu=2
num_type_plu=1
attribu_plu=COVM
dlc_plu=15
cpt_plu=70700000
ok=Valider
*/

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$ordre=$_POST['ordre'];
		if (isset($_POST['Num_entre'])) { $Num_entre=$_POST['Num_entre']; }  else {$Num_entre=''; }
		if (isset($_POST['nom_plu'])) { $nom_plu=$_POST['nom_plu']; } else {$nom_plu=''; }
		if (isset($_POST['nom_plu_compl'])) { $nom_plu_compl=$_POST['nom_plu_compl']; } else {$nom_plu_compl=''; }
		if (isset($_POST['num_cate_plu'])) { $num_cate_plu=$_POST['num_cate_plu']; } else {$num_cate_plu=''; }
		if (isset($_POST['num_type_plu'])) { $num_type_plu=$_POST['num_type_plu']; } else {$num_type_plu=''; }
		if (isset($_POST['attribu_plu'])) { $attribu_plu=$_POST['attribu_plu']; } else {$attribu_plu=''; }
		if (isset($_POST['dlc_plu'])) { $dlc_plu=$_POST['dlc_plu']; } else {$dlc_plu=''; }
		if (isset($_POST['str'])) { $str=$_POST['str']; } else {$str=''; }
		
		$valForm="POST" ;
} else {
		// Transmis en GET
		$ordre=$_GET['ordre'];
		if (isset($_GET['Num_entre'])) { $Num_entre=$_GET['Num_entre']; }  else {$Num_entre=''; }
		if (isset($_GET['nom_plu'])) { $nom_plu=$_GET['nom_plu']; } else {$nom_plu=''; }
		if (isset($_GET['nom_plu_compl'])) { $nom_plu_compl=$_GET['nom_plu_compl']; } else {$nom_plu_compl=''; }
		if (isset($_GET['num_cate_plu'])) { $num_cate_plu=$_GET['num_cate_plu']; } else {$num_cate_plu=''; }
		if (isset($_GET['num_type_plu'])) { $num_type_plu=$_GET['num_type_plu']; } else {$num_type_plu=''; }
		if (isset($_GET['attribu_plu'])) { $attribu_plu=$_GET['attribu_plu']; } else {$attribu_plu=''; }
		if (isset($_GET['dlc_plu'])) { $dlc_plu=$_GET['dlc_plu']; } else {$dlc_plu=''; }
		if (isset($_GET['str'])) { $str=$_GET['str']; } else {$str=''; }
				
		$valForm="GET" ;
}

if ($str==1) {
Header("Location:  http://192.168.1.200/horius/ajout_plu.php?str=$str&num_plu=$Num_entre&ordre=$ordre&nom_plu=$nom_plu&nom_plu_compl=$nom_plu_compl&num_cate_plu=$num_cate_plu&num_type_plu=$num_type_plu&attribu_plu=$attribu_plu&dlc_plu=$dlc_plu") ;
} else {
	
$timestamp = date('Y-m-d G:i:s');
$nom_plu_compl = htmlentities($nom_plu_compl, ENT_QUOTES);
$nom_plu = htmlentities($nom_plu, ENT_QUOTES);

$date = date("d-m-Y");

Echo "<center><font color='red'>Enregistrement</font></center>";

echo "<br>";
echo "num_ligne : ".$Num_entre." | Str : $str<br>";
echo "Nom Plu: ".$nom_plu." <br>";
echo "Nom Plu Complement: ".$nom_plu_compl."<br>";
echo "Num_Categorie PLu : ".$num_cate_plu." <br>";
echo "Num_Type PLu : ".$num_type_plu." <br>";
echo "Atribu plu ".$attribu_plu." <br>";
echo "DLC : ".$dlc_plu." <br>";
echo "timestamp : ".$timestamp." <br>";


$sql = "INSERT INTO plu VALUES (
'".$Num_entre."',
'".$IdNumClient."',   
'".$nom_plu."', 
'".$nom_plu_compl."', 
'".$num_cate_plu."', 
'".$num_type_plu."', 
'".$attribu_plu."', 
'".$dlc_plu."', 
'".$timestamp."')";

echo "requet : ".$sql." <br>";

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

echo "resultat requet : ".$res." <br>";


Header("Location: plu.php?ordre=1&limite=0");
}
?>