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

$date = date("d-m-Y");
// recuperation donnee transmises
$Num_bon =$_GET['num_bon'];
$y =$_GET['y'];
$m =$_GET['m'];
$d =$_GET['d'];
$prestataire_s =$_GET['presta'];


$nombre = 10;  // on va afficher 5 résultats par page.
$limite=$_GET['limite'];
if (!isset($limite)) $limite = 0; // si on arrive sur la page pour la première fois 
               // on met limite à 0.
$limitesuivante = $limite + $nombre;
$limiteprecedente = $limite - $nombre;
$selectc = 'SELECT count(num_ligne) FROM saisies_abat';
$req = mysqli_query($link, $sql); 
$row = mysqli_fetch_row($req);
$total= $row[0];
$NbPage =floor($total/10);

// menu haut new-supp-modif
echo "<div class='titre-text'><center> Saisie des M.R.S.</div></center><br>" ;

Menu_CSD (1) ;

/*
echo $prestataire_s."<br>";
echo "total : ".$total."| limite  ".$limite."<br> limite suivante ".$limitesuivante."| limite precedente".$limiteprecedente ."<br>";
*/


echo "<table border='1' cellpadding='1' cellspacing='1' width='500' height='22'>";
echo "<tr><td width='30' height='20' valign='center' bgcolor='#CCCCCC'>
      <div align='center'><span class='t-text'>Num Bon : </div></td></span>";
echo "<td width='50' height='20' valign='center'>
      <div align='center'>
      <input name='Num_bon_Mrs' type='text' id='Num_bon_Mrs' accesskey='2' tabindex='2' size='10' maxlength='20' value='$Num_bon'>";
echo "<td width='30' height='20' valign='center' bgcolor='#CCCCCC'>
      <div align='center'><span class='t-text'>Date du bon : </div></td></span>";
echo "</div></td></span>";
echo "<td width='150' height='20' valign='center'><div align='center'>";

  $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'Date_Bon_Mrs';

  $yr=$y;
  $mo=$m;
  $dy=$d;

//echo "y : ".$yr." | m : ".$mo." | d: ".$dy ;
  
 // Jour 
  
  $s="<SELECT NAME=\"${name}_d\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$dy>$dy</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=31;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$dy) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i2\"$sclt>$i</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Mois 
  
  $s.="<SELECT NAME=\"${name}_m\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$mo>$mo</OPTION>\n";
  $sclt=""; 
  for ($i=1;$i<=12;$i++) 
  { 
  $i2="0$i"; 
  $i2=substr($i2, -2); 
  if ($i2==$mo) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $mon2=date("M", mktime(0, 0, 0, $i, 1, 2001));
  $s.="<OPTION VALUE=\"$i2\"$sclt>$mon2</OPTION>\n";
  } 
  $s.="</SELECT> / "; 

 // Année 
  
  $s.="<SELECT NAME=\"${name}_y\" class='$class'>\n"; 
  $s.="<OPTION VALUE=$yr>$yr</OPTION>\n";
  $sclt=""; 
  for ($i=$fyear;$i<=$lyear;$i++)
  { 
  $i2="$i"; 
  if ($i2==$yr) 
  $sclt=" SELECTED"; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i\"$sclt>$i</OPTION>\n"; 
  } 
  $s.="</SELECT>\n"; 
    echo"$s";

    echo "</div></td></span>";
echo "</tr></table><br>";

echo "<table border='1' cellpadding='1' cellspacing='1' width='500' height='22'><tr>";
echo "<td width='30' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Date entre</div></td></span>";
echo "<td width='30' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Num Ident</div></td></span>";
echo "<td width='50' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Poids Mrs</td></span>";
echo "<td width='20' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>elvmt ? </td></span>";
echo "<td width='20' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Aj</td></span>";
echo "<td width='20' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Md</td></span>";
echo "</tr>";
$fi=0;

$myart =new table_mrs;
$select = 'select * FROM table_mrs WHERE `Enlevement_mrs`=0 ';
$select.= " AND IdNumClient='".$IdNumClient."'";
$select.=  'ORDER BY Date_Entre ASC limit '.$limite.','.$nombre;

$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_ligne_mrs=$myart->Num_ligne_mrs ;
  $Num_ident_Animal=$myart->Num_ident_animal ;
  $Date_Entre=$myart->Date_Entre ;
  $Date_Bon=$myart->Date_Bon_Mrs ;
  $Poids_Mrs=$myart->Poids_Mrs ;
  $Num_Bon_Mrs=$myart->Num_Bon_Mrs ;
  $Prestataire=$myart->Prestataire ;
  $enleve=$myart->Enlevement_mrs ;

$date_e=date("d/m/Y", strtotime($Date_Entre));

$date_b=date("d/m/Y", strtotime($Date_Bon));
/*
echo  date("d/m/Y", strtotime($Date_Entre))." | ".$date_e." | ".date("d/m/Y", strtotime($Date_Bon))." | ".$date_b."<br>";
echo $Num_ligne_mrs." | ".$Num_ident_Animal." | ".$Poids_Mrs." | ".$Num_Bon_Mrs." | ".$Prestataire." | ".$date_e." | ".$enleve."<br>" ;
*/
echo "<form id='form2' name='form2' method='post' action='maj_mrs.php'>"; 
echo "<input type='hidden' name='Num_bon_mrs' value='$Num_bon'/>";
echo "<input type='hidden' name='y' value='$y'/>";
echo "<input type='hidden' name='m' value='$m'/>";
echo "<input type='hidden' name='d' value='$d'/>";
echo "<input type='hidden' name='id_presta_s' value='$prestataire_s'/>";
echo "<input type='hidden' name='Num_ligne_mrs' value='$Num_ligne_mrs'/>";



    echo "<tr><td width='30' height='20' valign='center'><div align='center'><span class='t-text'>$date_e</div></td></span>";
    echo "<td width='30' height='20' valign='center'><div align='center'><span class='t-text'>$Num_ident_Animal</div></td></span>";
    echo "<td width='50' height='20' valign='center'><div align='center'><span class='t-text'>
					<input name='Poids_Mrs' type='text' id='Poids_Mrs' accesskey='2' tabindex='2' size='5' maxlength='7' value='$Poids_Mrs'>
					</div></td></span>";
    
   if ($enleve != 1 ) {
	echo "<td width='20' height='20' valign='center'>
	<div align='center'><img src='images/croix.gif' width='20' height='20'></div></td>";	
	} else {
	echo "<td width='20' height='20' valign='center'>
	<div align='center'><img src='images/coche.gif' width='20' height='20'></div></td>";
	}
echo "<td width='20' height='20' valign='center'><div align='center'><input type='submit' value='ok'></div></td>";
echo "<td width='20' height='20' valign='center'><div align='center'><a class='' href='modif_det_mrs.php?Num_ligne_mrs=$Num_ligne_mrs'><img src='images/modifie.png' width='20' height='20'></a></div></td>";

echo "";
echo "</form>";
} 
//echo "<input type='hidden' name='Num_ligne_mrs' value='$Num_ligne_mrs'/>";

echo "</tr></table>";
echo "<br><br>";
echo "<table border='1' cellpadding='0' cellspacing='0' width='500' height='22'><tr>";
echo "<td width='120' height='20' valign='center'><div align='center'><span class='t-text'>";
	 
if($limite != 0) {
    echo '<a href="'.$page.'?limite='.$limiteprecedente.'">Page precedente</a>';
}
echo "</div></td></span>";
echo "<td width='120' height='20' valign='center'><div align='center'><span class='t-text'>";
if($limitesuivante < $total) {
    echo '<a href="'.$page.'?limite='.$limitesuivante.'">Page Suivante</a>';
}
echo "</div></td></span>";
echo "</tr></table>";
echo "<br>";
echo "<a href='dechets.php?limite=0'>O.K.</a>";
echo "<br>";



include 'menu/footer.php';
?>
