<?php
include("include/data.php");
Init_boutique();
global $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $myart, $result, $NbLigne, $semaine, $limitesuivante, $limiteprecedente, 
$total, $Nom_plu_intrant, $dlc_plu_intrant, $page ;
// entete de la page

/*
http://192.168.1.100/horius/modif_nonconform.php?ordre=1&numconform=1
*/
if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['numconform'])) { $numconform=$_POST['numconform']; }  else {$numconform=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$num_ordre=$_GET['ordre'];
		if (isset($_GET['numconform'])) { $numconform=$_GET['numconform']; } else {$numconform=''; }
		$valForm="GET" ;
}


include 'menu/header.php';

$sql="Select * FROM Table_Non_Conformite WHERE Num_ligne_Conformite=$numconform" ;

$req = mysqli_query($link, $sql);  
while ($row = mysqli_fetch_assoc($req)) {
        $Num_ligne_Conformite = $row["Num_ligne_Conformite"];
        $Date_Conformite = $row["Date_Conformite"];
        $Num_Conformite = $row["Num_Conformite"];
        $Conformite_courte = $row["Conformite_courte"];
        $Conformite_longue = $row["Conformite_longue"];
				$Etat_conformite = $row["Etat_conformite"];
        $action_corrective_courte = $row["action_corrective_courte"];
        $action_corrective_longue = $row["action_corrective_longue"];
      }
				$sql = "SELECT categorie_cft FROM categorie_conformite WHERE num_cate_cft='$Num_Conformite'";  
				$req = mysqli_query($link, $sql);
				while ($row = mysqli_fetch_assoc($req)) {$Nom_Conformite = $row["categorie_cft"];} 

$Date_Conformite=date("d/m/Y", strtotime($Date_Conformite));
$Date_Conformite_lg=DateFr($Date_Conformite) ;


echo "<div class='titre-text'><center>Modification Non Conformit&eacute;e N&deg; $numconform</div></center>" ;

echo "<center><HR size='1' width='500'></center>";
echo "<center><br>" ;
echo "<form name='FormIntrant' method='GET' action='traitement_modif_conformite.php'>";
echo "<input type='hidden' name='numconform' value='$numconform'/>";
echo "<input type='hidden' name='ordre' value='1'/>";

echo "<center>" ;
echo "<table width='600' id='customers'>";
echo "<tr>";
echo "<th width='50'>Num ligne :</th>" ;
echo "<td width='550'>$Num_ligne_Conformite</td>" ;
echo "</tr><tr>";
echo "<th width='50'>Cat&eacute;gorie :</th>" ;
echo "<td><select style=' width: 200px;' name='Num_CatConf' id='Num_CatConf'>";
echo "<option value='0'>Toutes</option>";
$myart =new categorieplu;
$select = 'select * FROM categorie_conformite';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_cate_cft=$myart->num_cate_cft ;
  $categorie_cft=$myart->categorie_cft ;
  if ($num_cate_cft==$Num_Conformite){
  echo "<option value='$num_cate_cft' SELECTED>$num_cate_cft | $categorie_cft</option>";	
  } ELSE {
  echo "<option value='$num_cate_cft'>$num_cate_cft | $categorie_cft</option>";	
  }
  
}
echo "</select>";
echo "</tr><tr>";
echo "<th width='150'>Titre Non Conformit&eacute;e</th>" ;
echo "<td width='550'><textarea name='Conformite_courte' rows='1' cols='60'>$Conformite_courte</textarea></td>" ;
echo "</tr><tr>";
echo "<th width='150'>Non Conformit&eacute;e :</th>" ;
echo "<td width='550'><textarea name='Conformite_longue' rows='5' cols='60'>$Conformite_longue</textarea></td>" ;
echo "</tr><tr>";
echo "<th width='150'>Etat non-conformit&eacute;e :</th>" ;
echo "<td><select style=' width: 200px;' name='Etat_conformite' id='Etat_conformite'>";
switch ($Etat_conformite) {
	case 0 :
	echo "<option value='0' SELECTED>En cours</option>";
	echo "<option value='1'	>Clotur&eacute;e sans action corretive Clotur&eacute;e</option>";
	echo "<option value='2'	>Clotur&eacute;e avec action corretive Clotur&eacute;e</option>";
	break ;
	case 1 :
	echo "<option value='0' >En cours</option>";
	echo "<option value='1' SELECTED>Clotur&eacute;e sans action corretive Clotur&eacute;e</option>";
	echo "<option value='2'>Clotur&eacute;e avec action corretive Clotur&eacute;e</option>";
	break ;
	case 2 :
echo "<option value='0' 	>En cours</option>";
	echo "<option value='1' >Clotur&eacute;e sans action corretive Clotur&eacute;e</option>";
	echo "<option value='2' SELECTED>Clotur&eacute;e avec action corretive Clotur&eacute;e</option>";
	break ;
}

echo "</select></td>";
echo "</tr><tr>";
echo "<th width='50'>Titre Action Corrective</th>" ;
echo "<td width='550'><textarea name='action_corrective_courte' rows='1' cols='60'>$action_corrective_courte</textarea></td>" ;
echo "</tr><tr>";
echo "<th width='50'>Action Corrective : </th>" ;
echo "<td width='550'><textarea name='action_corrective_longue' rows='5' cols='60'>$action_corrective_longue</textarea></td>" ;
echo "</tr></table>";

echo "<br>";
echo "<th colspan='4' align='center' valign='middle'>
	  <input type='submit' name='ok' id='ok' value='Valider' accesskey='11' tabindex='11'>
	  &#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;
	  <input name='an' type='button' id='an' accesskey='12' tabindex='12' value='Retour' onClick='history.back()'></th>";
echo " </tr></div>";
echo "</table>";
echo "</form>";
echo "</center><br>" ;


include 'menu/footer.php';
?>
