<?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, $totalPoids ;
// entete de la page
Init_Head ();
Entete_Menu ();
Menu ();
Menu_SaisieH ();
$Num_entre=$_GET['Num_entre'];
$totalPoids = 0 ;
$date = date("d-m-Y");

$myart =new table_dechets;
$select = "SELECT * FROM table_dechets WHERE num_ligne_dechets='$Num_entre'";
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $num_ligne_dechets =$myart->num_ligne_dechets ;
  $Num_bon_dechets =$myart->Num_bon_dechets ;
  $Num_prestataire =$myart->Num_prestataire ;
  $num_cat_dechets =$myart->num_cate_dechets ;
  $mrs =$myart->mrs ;
  $poids_dechets =$myart->poids_dechets ;
  $sem_dechets =$myart->sem_dechets ;
  $date_enleve_dechets =$myart->date_enleve_dechets ;
  $observations =$myart->observations ;
}
//echo $num_ligne_dechets." | ".$Num_bon_dechets." | ".$Num_prestataire." | ".$poids_dechets." | ".$num_cat_dechets."<br>" ;
// menu haut new-supp-modif

echo "<center>";
//
// TITRE Page //
echo "<center><HR size='1' width='500'>";
echo "<b>Modification bon d'equarissage</b>";
echo "<center><HR size='1' width='500'>";
//
//$date_e=date("d/m/Y", strtotime($date_enleve_dechets));
//echo  date("d/m/Y", strtotime($date_enleve_dechets))." ".$date_enleve_dechets;
//

echo "<form id='form1' name='form1' method='post' action='modif_dechets_check.php'>";
echo "<table class='t-text' width='500' border='1' cellspacing='2' cellpadding='2'>";
echo "<tr>";
echo "<td width='100'>Prestataire : </td>";
echo "<td width='100'><select style='width:100px' name='id_presta' id='id_presta'>";

$myart =new fournisseurs;
$select = 'select * FROM fournisseurs WHERE `num_cate_four`=1';
$result = mysqli_query($link, $select);
$myart->getnum($result);
  while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $id_presta=$myart->Num_fournisseur ;
  $Ident_four=$myart->Ident_four ;
echo "<option value='$id_presta'>$Ident_four</option>";
}

echo "</select>";
echo "</td>";
echo "<td width='100'>Date enl&#232;vement</td>";
echo "<td>";
  
  $class = '';
  $fyear='2010';
  $lyear='2050';
  $name = 'DateEntre';

  $yr=date("Y", strtotime($date_enleve_dechets));
  $mo=date("m", strtotime($date_enleve_dechets));
  $dy=date("d", strtotime($date_enleve_dechets));

  
 // 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 "</td></tr>";
echo "<tr>";
echo "<td>cat&#233;gorie :</td>";
echo "<td><select style='width:100px' name='Num_categorie' id='Num_categorie' STYLE='width:90' >";

$myart =new categorie_dechets ;
$select = 'select * FROM categorie_dechets';
$result = mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_cate_dechets=$myart->num_cate_dechets ;
  $categorie_dechets=$myart->categorie_dechets ;

if  ($Num_cate_dechets==$num_cat_dechets)   
  echo "<option value='$Num_cate_dechets'selected='selected' >$categorie_dechets</option>";
else
  echo "<option value='$Num_cate_dechets'>$categorie_dechets</option>";
echo "<option value='$Num_cate_dechets'>$categorie_dechets</option>";
}
echo "</select></td>";

echo "<td>Num Bon : </td>";
echo "<td><input name='Num_bon_dechets' type='text' id='Num_bon_dechets' accesskey='2' tabindex='2' size='12' maxlength='12' value='$Num_bon_dechets'>
     </td>";
 
echo "</td>";
echo "</tr>";

echo "<tr>";
echo "<td>Poids :</td>";
echo "<td><input name='poids_dechets' type='text' id='poids_dechets' accesskey='2' tabindex='2' size='10' maxlength='10' value='$poids_dechets'></td>";
echo "<td>M.R.S ? : </td>";
if ($mrs==1) {
echo "<td colspan='1'>oui <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='1' checked>
non <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='0'></td>";
} else {
echo "<td colspan='1'>oui <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='1'>
non <input name='mrs' type='radio' id='mrs' accesskey='2' tabindex='2' value='0' checked></td>";
}
echo "</tr>";

echo "<input type='hidden' name='num_ligne' value='$Num_entre'/>";
echo "<tr>";
echo "<td>Observations</td>";
echo "<td colspan='4'><input name='Observations' type='text' id='Observations' accesskey='2' tabindex='2' size='30' maxlength='30' value='$observations'></td>";
echo "</tr>";
echo "<td colspan='4'><div align='center'>
	  <form id='form1' name='form1' method='post' action='modif_dechets_check.php'>
      <input type='submit' value='Modifications Dechets'>
      </form></div></td>";
echo "<tr>";
echo "</table></form>";


//
// Detail MRS Si Mrs Ok
//

if ($mrs==1) {
echo "<center><HR size='1' width='500'>";
echo "<b>Detail Mrs</b>";
echo "<center><HR size='1' width='500'>";

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'>Num Bon</td></span>";
echo "<td width='50' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Date Bon</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='50' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Prestataire</td></span>";
echo "<td width='30' 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'>Md</td></span>";
echo "</tr>";

$myart =new table_mrs;
$select = "select * FROM table_mrs WHERE Num_Bon_Mrs = '$Num_bon_dechets' ORDER BY Date_Entre DESC";
$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."<br>";
//echo  date("d/m/Y", strtotime($Date_Bon))." ".$date_b."<br>";
//echo $Num_ligne_mrs."|".$Num_ident_Animal."|".$Poids_Mrs."|".$Num_Bon_Mrs."|".$Prestataire."|".$enleve."<br>" ;
  
    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'>$Num_Bon_Mrs</div></td></span>";
    echo "<td width='50' height='20' valign='center'>
	<div align='center'><span class='t-text'>$date_b</div></td></span>";
    echo "<td width='50' height='20' valign='center'>
	<div align='center'><span class='t-text'>$Poids_Mrs</div></td></span>";
    echo "<td width='30' height='20' valign='center'>
	<div align='center'><span class='t-text'>$Prestataire</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'><a class='' href='modif_det_mrs.php?Num_ligne_mrs=$Num_ligne_mrs&Num_entre=$Num_entre'><img src='images/modifie.png' width='20' height='20'></a></div></td>";

$totalPoids = number_format($Poids_Mrs + $totalPoids, 2, ',', ' ');



} 
echo "<table border='1' cellpadding='1' cellspacing='1' width='500' height='22'><tr>";
echo "<td width='167' height='20' valign='center' >
	<div align='center'><span class='t-text'>Total MrS : </div></td></span>";
echo "<td width='70' height='20' valign='center' >
	<div align='center'><span class='t-text'>".$totalPoids." Kg </div></td></span>";
echo "<td width='70' height='20' valign='center' >
	<div align='center'><span class='t-text'></td></span>";
echo "</tr>";
echo "</tr></table>";

} else {

}


include 'menu/footer.php';
?>
