<?php
include("include/data.php");
Init_boutique();
global $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $myart, $result, $NbLigne, $semaine, $limitesuivante, $limiteprecedente, $total, $page ;
/* entete de la page
 traitement_ajout_plu_intrant.php?
 num_cate_plu_intran=3&
 Nom_plu_intrant=Gras+de+proc&
 num_unitee_plu_intran=1&
 dlc_plu_intrant=15&
 ok=Valider
*/

//include 'menu/header.php';

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['num_cate_plu_intran'])) { $num_cate_plu_intran=$_POST['num_cate_plu_intran']; }  else {$num_cate_plu_intran=''; }
		if (isset($_POST['Nom_plu_intrant'])) { $Nom_plu_intrant=$_POST['Nom_plu_intrant']; } else {$Nom_plu_intrant=''; }
		if (isset($_POST['num_unitee_plu_intran'])) { $num_unitee_plu_intran=$_POST['num_unitee_plu_intran']; } else {$num_unitee_plu_intran=''; }
		if (isset($_POST['dlc_plu_intrant'])) { $dlc_plu_intrant=$_POST['dlc_plu_intrant']; } else {$dlc_plu_intrant=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$num_ordre=$_GET['ordre'];
		if (isset($_GET['num_cate_plu_intran'])) { $num_cate_plu_intran=$_GET['num_cate_plu_intran']; }  else {$num_cate_plu_intran=''; }
		if (isset($_GET['Nom_plu_intrant'])) { $Nom_plu_intrant=$_GET['Nom_plu_intrant']; } else {$Nom_plu_intrant=''; }
		if (isset($_GET['num_unitee_plu_intran'])) { $num_unitee_plu_intran=$_GET['num_unitee_plu_intran']; } else {$num_unitee_plu_intran=''; }
		if (isset($_GET['dlc_plu_intrant'])) { $dlc_plu_intrant=$_GET['dlc_plu_intrant']; } else {$dlc_plu_intrant=''; }
		$valForm="GET" ;
}



$last_num_entre = 0 ;
$sql = "SELECT max(num_plu_intrant) FROM plu_intrant";  
$req = mysqli_query($link, $sql); 
$row = mysqli_fetch_row($req);
$last_num_entre = $row[0];
$last_num_entre = $last_num_entre + 1 ;

echo "cate intrant : ".$num_cate_plu_intran." nom intrant : ".$Nom_plu_intrant."<br>unite : ".$num_unitee_plu_intran." dlc  :".$dlc_plu_intrant."<br>" ;

$sql = "INSERT INTO plu_intrant VALUES ('".$last_num_entre."', '".$IdNumClient."', '".$Nom_plu_intrant."', '".$num_cate_plu_intran."', '".$num_unitee_plu_intran."', '".$dlc_plu_intrant."')";

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

echo "<br>".$res ;

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

?>
