<?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
/*
traitement_ajout_base_cf.php?
ordre=1
Num_CF=2
Num_CatPlu=1
Nom_plu_intrant=Pr%C3%A9paration+Froide
temp_min=6.00
temp_max=12.00
hydro_min=0
hydro_max=0
ok=Valider
*/

if (!isset($_GET['ordre'])) { 
		// Transmis en POST
		$num_ordre=$_POST['ordre'];
		if (isset($_POST['Num_CatPlu'])) { $Num_CatPlu=$_POST['Num_CatPlu']; }  else {$Num_CatPlu=''; }
		if (isset($_POST['Nom_plu_intrant'])) { $Nom_plu_intrant=$_POST['Nom_plu_intrant']; } else {$Nom_plu_intrant=''; }
		if (isset($_POST['Num_CF'])) { $Num_CF=$_POST['Num_CF']; } else {$Num_CF=''; }
		if (isset($_POST['temp_min'])) { $temp_min=$_POST['temp_min']; } else {$temp_min=''; }
		if (isset($_POST['temp_max'])) { $temp_max=$_POST['temp_max']; } else {$temp_max=''; }
		if (isset($_POST['hydro_min'])) { $hydro_min=$_POST['hydro_min']; } else {$hydro_min=''; }
		if (isset($_POST['hydro_max'])) { $hydro_max=$_POST['hydro_max']; } else {$hydro_max=''; }
		$valForm="POST" ;
} else {
		// Transmis en GET
		$num_ordre=$_GET['ordre'];
		if (isset($_GET['Num_CatPlu'])) { $Num_CatPlu=$_GET['Num_CatPlu']; }  else {$Num_CatPlu=''; }
		if (isset($_GET['Nom_plu_intrant'])) { $Nom_plu_intrant=$_GET['Nom_plu_intrant']; } else {$Nom_plu_intrant=''; }
		if (isset($_GET['Num_CF'])) { $Num_CF=$_GET['Num_CF']; } else {$Num_CF=''; }
		if (isset($_GET['temp_min'])) { $temp_min=$_GET['temp_min']; } else {$temp_min=''; }
		if (isset($_GET['temp_max'])) { $temp_max=$_GET['temp_max']; } else {$temp_max=''; }
		if (isset($_GET['hydro_min'])) { $hydro_min=$_GET['hydro_min']; } else {$hydro_min=''; }
		if (isset($_GET['hydro_max'])) { $hydro_max=$_GET['hydro_max']; } else {$hydro_max=''; }
		$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>" ;

$Nom_plu_intrant = htmlspecialchars($Nom_plu_intrant, ENT_QUOTES);

$sql = "INSERT INTO Base_CF VALUES (
'".$last_num_entre."',
'".$IdNumClient."',
'".$IdNomClient."',
'".$Num_CF."', 
'".$Nom_plu_intrant."', 
'".$temp_min."', 
'".$temp_max."', 
'".$hydro_min."', 
'".$hydro_max."', 
'".$Num_CatPlu."',  
'".$timestamp."')";


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

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

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

?>
