<?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

$num_ligne= $_POST['num_ligne'];
$DateSaisie_y = $_POST['DateSaisie_y'];
$DateSaisie_m = $_POST['DateSaisie_m'];
$DateSaisie_d = $_POST['DateSaisie_d'];
$Num_certificat=htmlentities($_POST['Num_certificat']);
$Num_abat=htmlentities($_POST['Num_abat']);
$Poid_Saisie=htmlentities($_POST['Poid_Saisie']);
$PoidFinal=htmlentities($_POST['PoidFinal']);


$DateSaisie=date("Y-m-d", mktime(0,0,0,$DateSaisie_m,$DateSaisie_d,$DateSaisie_y));

Echo "<center><font color='red'>Enregistrement Ligne Num ".$num_ligne."</font></center>";

echo $num_ligne." <br>";
echo $DateSaisie." <br>";
echo " date Entre Sql ".$DateSaisie." /y=".$DateSaisie_y."  /m=".$DateSaisie_d." /d=".$DateSaisie_m."<br>";
echo $Num_certificat." <br>";
echo $Num_abat." <br>";
echo $Poid_Saisie." <br>";
echo $PoidFinal." <br>";

echo "<br><br>";

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

$sql = "UPDATE saisies_abat SET
`num_certificat` = '$Num_certificat',
`date_saisie` = '$DateSaisie',
`num_abat` = '$Num_abat',
`poid_saisie` = '$Poid_Saisie'
WHERE num_ligne = '$num_ligne'";

echo $sql;
$res = mysqli_query($link, $sql);
echo "<br>Res ; $res <br>";


// UPDATE `entreabat` SET `Poid_saisie` = '15,4',`Poid_entre` = '4.5' WHERE `entreabat`.`Num_entre` =79;

$sql = "UPDATE entreabat SET Poid_saisie = '".$Poid_Saisie."' , Poid_entre = '".$PoidFinal."' WHERE Num_Abatage = '".$Num_abat."'";
echo $sql;
$res = mysqli_query($link, $sql);
echo "<br>Res ; $res <br>";

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