<?php
include("include/data.php");
Init_boutique();
global $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $myart, $A_NumArt,$i, $result, $NbLigne, 
$mygroupeart, $mysousgroupeart, $semaine, $limitesuivante, $limiteprecedente, $limite, $total, 
$page, $Nom_Client, $NumAbat;
// entete de la page
//include 'menu/header.php';

$date = date("d-m-Y");

// menu haut new-supp-modif

echo "<center><br>";

/*
num_entre=1
Num_Plu=3
num_cate_plu_intran=4
id_presta=9
Date_Entre_d=01
Date_Entre_m=02
Date_Entre_y=2016
Num_Bl=6566
Date_DLC_d=04
Date_DLC_m=02
Date_DLC_y=2016
Poids=4.00
num_unite=1
etat=0
observations=
*/

if (!isset($_GET['num_entre']))
{
    $Num_entre=($_POST['num_entre']);
	$Num_entre.=" Post";
   } else {
    $Num_entre=($_GET['num_entre']);
	$Num_entre.=" Get";
    }

echo "<br>Num Entre : ".$Num_entre."<br>" ;

$Date_Entre_y = $_POST['Date_Entre_y'];
$Date_Entre_m = $_POST['Date_Entre_m'];
$Date_Entre_d = $_POST['Date_Entre_d'];

$Date_Entre_sql=date("Y-m-d", mktime(0,0,0,$Date_Entre_m,$Date_Entre_d,$Date_Entre_y));
$Date_Entre=date("d/m/y", mktime(0,0,0,$Date_Entre_m,$Date_Entre_d,$Date_Entre_y));

$Date_DLC_y = $_POST['Date_DLC_y'];
$Date_DLC_m = $_POST['Date_DLC_m'];
$Date_DLC_d = $_POST['Date_DLC_d'];

$Date_DLC_sql=date("Y-m-d", mktime(0,0,0,$Date_DLC_m,$Date_DLC_d,$Date_DLC_y));
$Date_DLC=date("d/m/y", mktime(0,0,0,$Date_DLC_m,$Date_DLC_d,$Date_DLC_y));
$semaine_intrant=date("W", strtotime($Date_Entre_sql));

$Num_Plu= $_POST['Num_Plu'];
$num_ligne=htmlentities($_POST['num_entre']);
$poid_decoupe=htmlentities($_POST['Poids']);
$Num_CatPlu=htmlentities($_POST['num_cate_plu_intran']);
$id_presta=htmlentities($_POST['id_presta']);
$Num_Bl=htmlentities($_POST['Num_Bl']);
$num_unite=htmlentities($_POST['num_unite']);
$etat=htmlentities($_POST['etat']);
$Observations=htmlentities($_POST['Observations']);
$Num_Lot_intrants= $_POST['Num_Lot_intrants'];



Echo "<center><font color='red'>Enregistrement</font></center>";

echo "<br>";
echo "num_ligne : ".$num_ligne." <br>";
echo "Date Entre : ".$Date_Entre." date sql : ".$Date_Entre_sql." /y= ".$Date_Entre_y."  /m= ".$Date_Entre_m." /d= ".$Date_Entre_d."<br>";
echo "Date DLC : ".$Date_DLC." date sql : ".$Date_DLC_sql." /y= ".$Date_DLC_y."  /m= ".$Date_DLC_m." /d= ".$Date_DLC_d."<br>";
echo "Num semaine : ".$semaine_intrant." <br>";
echo "Num Plu: ".$Num_Plu." <br>";
echo "Num fournisseur : ".$id_presta." <br>";
echo "Num_Categorie PLu: ".$Num_CatPlu." <br>";
echo "Num Bl: ".$Num_Bl." <br>";
echo "Num Lot : ".$Num_Lot_intrants." <br>";
echo "Poids Froid : ".$poid_decoupe." <br>";
echo "unite : ".$num_unite." <br>";
echo "Observations : ".$Observations." <br>";
echo "clos ? : ".$etat." <br>";

$sql = "UPDATE intrants SET 
`Num_Fournisseur` = '$id_presta', 
`Date_Entre` = '$Date_Entre_sql', 
`Date_DLC` = '$Date_DLC_sql', 
`Num_Bl` = '$Num_Bl', 
`Poids` = '$poid_decoupe', 
`num_unite` = '$num_unite', 
`Num_Cate_Intrants` = '$Num_CatPlu', 
`Observations` = '$Observations',
`Num_Plu` = '$Num_Plu', 
`Num_Lot` = '$Num_Lot_intrants',
`semaine_intrant` = '$semaine_intrant',
`etat` = '$etat' 
WHERE `Num_entre_intrant` = '$num_ligne'";

echo "requet : ".$sql." <br>";

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

echo "resultat requet : ".$res." <br>";

$sql = "UPDATE intrants_stock SET 
`Date_Mvt` = '$Date_Entre_sql', 
`Poids` = '$poid_decoupe', 
`semaine_intrant` = '$semaine_intrant'
WHERE num_lot='$Num_Lot_intrants' AND etat='0'";

echo "requet : ".$sql." <br>";

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

echo "resultat requet : ".$res." <br>";

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