<?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_modif_conformite.php?
numconform=1
ordre=1
Num_CatConf=1
Conformite_courte=Default+%EF%BF%BDtiquetage+erreur+num%EF%BF%BDro+de+lot
Conformite_longue=Erreur+sur+num%EF%BF%BDro+de+lot+%EF%BF%BDtiquetage%2Csur+Lot+A45141517-245D+erreur+oublie+du+quantieme+sur+etiquatage.++
Etat_conformite=2
action_corrective_courte=Rappel+a+d%27adh%EF%BF%BDrent
action_corrective_longue=Rappel+a+d%27adh%EF%BF%BDrent+que+le+num%EF%BF%BDro+de+lot+sur+%EF%BF%BDtiquette+doit+%EF%BF%BDtre+complet%2C+a+savoir+lot%2Bquantieme
ok=Valider
*/

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['numconform'])) { $numconform=$_POST['numconform']; }  else {$numconform=''; }
		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['numconform'])) { $numconform=$_GET['numconform']; }  else {$numconform=''; }
		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" ;
}

//include 'menu/header.php';
/*
$last_num_entre = 0 ;
$sql = 'SELECT max(Num_ligne_CF) FROM Base_CF';
$req = mysqli_query($link, $sql); 
$row = mysqli_fetch_row($req);
$last_num_entre = $row[0];
$last_num_entre = $last_num_entre + 1 ;
*/
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($Conformite_courte, ENT_QUOTES);
$Conformite_longue = htmlspecialchars($Conformite_longue, ENT_QUOTES);
$action_corrective_courte = htmlspecialchars($action_corrective_courte, ENT_QUOTES);
$action_corrective_longue = htmlspecialchars($action_corrective_longue, ENT_QUOTES);

$sql = "UPDATE Table_Non_Conformite SET 

`Num_Conformite` = '$Num_CatConf', 
`IdNomClient` = '$IdNomClient', 
`Conformite_courte` = '$Conformite_courte', 
`Conformite_longue` = '$Conformite_longue', 
`Etat_conformite` = '$Etat_conformite', 
`action_corrective_courte` = '$action_corrective_courte',
`action_corrective_longue` = '$action_corrective_longue', 
`Timestamp` = '$timestamp' 

WHERE `Num_ligne_Conformite` = '$numconform'";


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

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

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

?>
