<?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, $mrs ;
// entete de la page
include 'menu/header.php';

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

$num_entre=$_GET['num_entre'];
$num_ordre=$_GET['ordre'];
//
//echo "<br>Num Entre : $num_entre | Num ordre : $num_ordre <br>" ;
//

$select = "SELECT * FROM intrants WHERE Num_entre_intrant='$num_entre'";

$myart =new intrants;
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_entre_intrant=$myart->Num_entre_intrant ;
  $Num_Fournisseur=$myart->Num_Fournisseur ;
  $Date_Entre=$myart->Date_Entre ;
  $Date_DLC=$myart->Date_DLC;	
  $Num_Bl=$myart->Num_Bl ;
  $Poids=$myart->Poids ;
  $num_unite=$myart->num_unite ;
  $Num_Cate_Intrants=$myart->Num_Cate_Intrants ;	
  $Observations=$myart->Observations ;
  $Num_Plu=$myart->Num_Plu ;
  $Num_Lot_intrants=$myart->Num_Lot ;
  $semaine_intrant=$myart->semaine_intrant ;
  $etat=$myart->etat ;
  
	$Date_Dlc_calc =date("Y-m-d", strtotime($Date_DLC)) ;
	$semaine_entree=date("W", strtotime($Date_Entre));
    $Date_Entre=date("d/m/Y", strtotime($Date_Entre));
	$Date_DLC=date("d/m/Y", strtotime($Date_DLC)) ;
	$Date_jour=date("d/m/Y", strtotime($date)) ;
	

	$Date_today =date("Y-m-d", strtotime($date)) ;
	}	
// menu haut new-supp-modif

$sql = "SELECT Nom_Fournisseur FROM fournisseurs WHERE Num_fournisseur='$Num_Fournisseur'";  
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
        $nom_prestataire = $row["Nom_Fournisseur"];
    } 
// echo "<br>".$sql;

$sql = "SELECT nom_unite_ini FROM unitee WHERE num_unite='$num_unite'";  
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
        $nom_untite = $row["nom_unite_ini"];
    } 

// echo "<br>".$sql;

$sql = "SELECT categorie_plu_intran FROM categorie_intrant WHERE num_cate_plu_intran='$Num_Cate_Intrants'";  
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
        $categorie_plu_intran = $row["categorie_plu_intran"];
    } 

//echo "<br>".$sql;

$sql = "SELECT nom_plu_intrant FROM plu_intrant WHERE num_plu_intrant='$Num_Plu'";  
$req = mysqli_query($link, $sql);
while ($row = mysqli_fetch_assoc($req)) {
        $nom_plu_intrant = $row["nom_plu_intrant"];
    } 

echo "<center><HR size='1' width='500'>";
echo "<b>Fiche d'entr&#233;e intrant N&deg; $Num_entre_intrant pour le lot N&deg; $Num_Lot_intrants de le semaine $semaine_intrant</b>";
echo "<center><HR size='1' width='500'>";

Menu_CSD ($num_ordre) ;

echo "<br>";
echo "<form id='form1' name='form1' method='POST' action='".$_SERVER["HTTP_REFERER"]."'>";
echo "<table class='t-text' width='600' border='0' cellspacing='2' cellpadding='6'>";
echo "<tr>";
echo "<td width='150'>Intant : </td>";
echo "<td width='150'><b>$nom_plu_intrant</b></td>";
echo "<td width='150'>Cat&#233;gorie Intrant : </td>";
echo "<td width='150'>$categorie_plu_intran</td>";; 
echo "</tr>";
echo "<tr>";
echo "<td width='150'>Fournisseur  Intrant : </td>";
echo "<td width='150'>$nom_prestataire</td>";
echo "<td width='100'>Date entr&#233;e : </td>";
echo "<td width='100'>$Date_Entre</td>"; 
echo "</tr>";
echo "<tr>";
echo "<td width='150'>N&deg; BL Intrant : </td>";
echo "<td width='150'>$Num_Bl</td>"; 
echo "<td width='150'>Date DLC : ";

$dateFrom = strtotime($Date_today);
$dateNow =  strtotime($Date_Dlc_calc) ;
$interval = $dateNow - $dateFrom ;
$jours = round(-($interval)/(24*3600));

//echo "Dj : $dateFrom  | Dlc : $dateNow | ec : $interval | Nbj: : $jours<br>" ;

if ($jours > 0) {
		echo "<FONT color='red'> d&#233;pass&#233;e </FONT></td>" ;
	} else {
		echo "</td>" ;
	}
echo "<td width='150'>".$Date_DLC ;

	if ($jours > 0) {
		
		echo "<FONT color='red'> +".$jours." jours</FONT></td>" ;
	} else {
		echo "</td>" ;
	}
	
echo "</tr>";
echo "<tr>";
echo "<td width='150'>Poids Intrant : </td>";
echo "<td width='150'>$Poids $nom_untite</td>";
echo "<td width='150'>Etat intrant : </td>";
echo "<td width='150'>"; 

	if ($etat==0) {
	echo "<FONT color='green'>En Cours</FONT></td>" ;
	} else {
	echo "<b>Cl&#244;turer</b></td>" ;
	}
echo "</tr>";

echo "<td>Observations</td>";
echo "<td colspan='4'>$Observations</td>";
echo "</tr>";
echo "<td colspan='4'><div align='center'>";
// <form id='form1' name='form1' method='post' action='modif_abattoir_check.php?Num_entre=$Num_entre'>
echo "<input type='submit' value='* OK *'>
      </div></td>";
echo "<tr>";
echo "</table></form>";



include 'menu/footer.php';
?>
