<?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.100/horius/traitement_ajout_conformite.php?ordre=1
Num_ligne_Conformite=3
dateconformite=2017-10-31
Num_CatConf=1
Conformite_courte=Num%C3%A9ro+de+lot+sans+D%C3%A9finition+du+quanti%C3%A8me
Conformite_longue=num%C3%A9ro+H44514117-345+a+%C3%A9t%C3%A9+%C3%A9tiquet%C3%A9+sans+la+lettre+de+D%C3%A9coupe+soit+sans+le+D
Etat_conformite=2
action_corrective_courte=Rappel+a+adh%C3%A9rent
action_corrective_longue=Rappel+de+la+proc%C3%A9dure+d%27attribution+du+num%C3%A9ro+de+lot
ok=Valider
*/

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['Num_ligne_Conformite'])) { $Num_ligne_Conformite=$_POST['Num_ligne_Conformite']; }  else {$Num_ligne_Conformite=''; }
		if (isset($_POST['dateconformite'])) { $dateconformite=$_POST['dateconformite']; }  else {$dateconformite=''; }
		if (isset($_POST['Num_CatConf'])) { $Num_CatConf=$_POST['Num_CatConf']; }  else {$Num_CatConf=''; }
		if (isset($_POST['Conformite_courte'])) { $Conformite_courte=$_POST['Conformite_courte']; } else {$Conformite_courte=''; }
		if (isset($_POST['Conformite_longue'])) { $Conformite_longue=$_POST['Conformite_longue']; } else {$Conformite_longue=''; }
		if (isset($_POST['Etat_conformite'])) { $Etat_conformite=$_POST['Etat_conformite']; } else {$Etat_conformite=''; }
		if (isset($_POST['action_corrective_courte'])) { $action_corrective_courte=$_POST['action_corrective_courte']; } else {$action_corrective_courte=''; }
		if (isset($_POST['action_corrective_longue'])) { $action_corrective_longue=$_POST['action_corrective_longue']; } else {$action_corrective_longue=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$num_ordre=$_GET['ordre'];
		if (isset($_GET['Num_ligne_Conformite'])) { $Num_ligne_Conformite=$_GET['Num_ligne_Conformite']; }  else {$Num_ligne_Conformite=''; }
		if (isset($_GET['dateconformite'])) { $dateconformite=$_GET['dateconformite']; }  else {$dateconformite=''; }
		if (isset($_GET['Num_CatConf'])) { $Num_CatConf=$_GET['Num_CatConf']; }  else {$Num_CatConf=''; }
		if (isset($_GET['Conformite_courte'])) { $Conformite_courte=$_GET['Conformite_courte']; } else {$Conformite_courte=''; }
		if (isset($_GET['Conformite_longue'])) { $Conformite_longue=$_GET['Conformite_longue']; } else {$Conformite_longue=''; }
		if (isset($_GET['Etat_conformite'])) { $Etat_conformite=$_GET['Etat_conformite']; } else {$Etat_conformite=''; }
		if (isset($_GET['action_corrective_courte'])) { $action_corrective_courte=$_GET['action_corrective_courte']; } else {$action_corrective_courte=''; }
		if (isset($_GET['action_corrective_longue'])) { $action_corrective_longue=$_GET['action_corrective_longue']; } else {$action_corrective_longue=''; }
		$valForm="GET" ;
}


echo "<center>";
echo "Form : ".$valForm." | Num ordre : ".$num_ordre."<br>" ;
/*
echo "Num CF : ".$Num_CF." | Num Cate CF : ".$Num_CatPlu." | Nom CF : ".$Nom_plu_intrant."<br>" ;
echo "temp min : ".$temp_min." temps max : ".$temp_max."<br>" ;
echo "Hydro min : ".$hydro_min." Hydro max : ".$hydro_max."<br>" ;
echo "LastNum :".$last_num_entre."<br>" ;
*/

$Conformite_courte = htmlspecialchars_decode($Conformite_courte, ENT_HTML5);
$Conformite_longue = htmlspecialchars_decode($Conformite_longue, ENT_HTML5);
$action_corrective_courte = htmlspecialchars_decode($action_corrective_courte, ENT_HTML5);
$action_corrective_longue = htmlspecialchars_decode($action_corrective_longue, ENT_HTML5);


$sql = "INSERT INTO Table_Non_Conformite VALUES (
'".$Num_ligne_Conformite."', 
'".$IdNumClient."',
'".$IdNomClient."',  
'".$dateconformite."', 
'".$Num_CatConf."', 
'".$Conformite_courte."', 
'".$Conformite_longue."', 
'".$Etat_conformite."', 
'".$action_corrective_courte."', 
'".$action_corrective_longue."', 
'".$timestamp."')";

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

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

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

?>
