<?php
   
include("include/data.php");
Init_boutique();

// entete de la page

include 'menu/header.php';

// TITRE Page //
echo "<div class='titre-text'><center>Edition des Importations etiquettes</div></center><HR size='2' width='500'><br>" ;


	$Nb_etiq_import = 0 ;
	$sql1 = "SELECT count(num_etiq_ligne) FROM temp_import_csv";  
	$sql1.=" WHERE `IdNumClient`='".$IdNumClient."'";
	$sql1.=" AND RsltImport ='1'";
	$sql1.=" AND RsltLot='1'";
	$sql1.=" AND RsltStock='1'";
	$req1 = mysqli_query($link, $sql1); 
	$row = mysqli_fetch_row($req1);
	$Nb_etiq_import = $row[0];
	
	$Nb_clients_import = 0 ;
	$sql1 = "SELECT COUNT(DISTINCT num_client) FROM temp_import_csv";  
	$sql1.=" WHERE `IdNumClient`='".$IdNumClient."'";
	$sql1.=" AND RsltImport ='1'";
	$sql1.=" AND RsltLot='1'";
	$sql1.=" AND RsltStock='1'";
	$req1 = mysqli_query($link, $sql1); 
	$row = mysqli_fetch_row($req1);
	$Nb_clients_import = $row[0];

echo "<center>";	
echo "<div class='t-text12'>Lecture base importation ...... <br> Nombre d'&#233;tiquettes a traiter : $Nb_etiq_import - Pour : $Nb_clients_import clients</div>"; 
echo "<br><center>";

echo "<form id='form1' name='form1' method='get' action='edition_recap_etiq.php' TARGET=_BLANK>";
echo "<input type='hidden' name='ordre' value='1'/>"; 
Echo "<table width='900' cellpadding='2' cellspacing='2' align=center border=1><tr>";
Echo "<tr height='30'><td colspan=5><span class='t-text'><center>FILTRES<br></center></td></tr>";
echo "<tr height='30' class='text'>";
echo "<td>Par ann&eacute;e :";

  $class = '';
  $fyear='2011';
  $lyear='2050';
  $name = 'SelAnne';

  $yr=date("Y");
  // 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>";
echo "<td>Par semaine :";

  $class = '';
  $fyear='1';
  $lyear='53';
  $name = 'SelSem';

  $yr=date("W");
  // Année 
  
  $s="<SELECT style=' width: 65px;' NAME=\"${name}_w\" class='$class'>\n";
  $s.="<OPTION VALUE='0' SELECTED>Toutes</OPTION>\n";
  $s.="<OPTION VALUE=$yr>$yr</OPTION>\n";
  $sclt=""; 
  for ($i=$fyear;$i<=$lyear;$i++)
  { 
  $i2="$i"; 
  if ($i2==$yr) 
  //$sclt=" SELECTED";
  $sclt=""; 
  else 
  $sclt=""; 
  $s.="<OPTION VALUE=\"$i\"$sclt>$i</OPTION>\n"; 
  } 
  $s.="</SELECT>\n"; 
    echo"$s";
echo "</td>";
echo "<td>Par Lot : <select style=' width: 120px;' name='Num_lot_sel' id='Num_lot_sel'>";
echo "<option value='0'>Toutes</option>";
$sql5 ="SELECT DISTINCT `num_lot` FROM temp_import_csv";
	$sql5.=" WHERE IdNumClient='".$IdNumClient."' ";  
	$sql5.=" ORDER BY `temp_import_csv`.`num_lot` ASC";
	$req5=mysqli_query($link, $sql5);
//	echo "<br>$sql5<br>";
	while ($row = mysqli_fetch_assoc($req5)) {
		 $num_lot_sel=  $row["num_lot"];
	  echo "<option value='$num_lot_sel'>$num_lot_sel</option>";
}

echo "</select>";
echo "</td>";
echo "<td rowspan='3'>Par Client : <select style=' width: 120px;' name='Num_Client' id='Num_Client'>";
echo "<option value='0'>Tous</option>";
/*
$sql5 ="SELECT DISTINCT `num_client` FROM temp_import_csv";
	$sql5.=" WHERE IdNumClient='".$IdNumClient."' ";  
	$sql5.=" ORDER BY `temp_import_csv`.`num_client` ASC";
	$req5=mysqli_query($link, $sql5);
//	echo "<br>$sql5<br>";
	while ($row = mysqli_fetch_assoc($req5)) {
		 $num_client_sel=  $row["num_client"];
		 
		$sql6 = "SELECT Nom_Client FROM clients_base WHERE Num_Client='$num_client_sel'";  
		$req6 = mysqli_query($link, $sql6);
		while ($row = mysqli_fetch_assoc($req6)) {$Nom_Client = $row["Nom_Client"];}  
		 
	  echo "<option value='$num_client_sel'>$num_client_sel | $Nom_Client</option>";
}
*/
echo "</select>";
echo "</td></tr>";
echo "<tr>";
echo "<tr height='30' class='text'>";
echo "<td class='text'> intrerval de date : </td>";
echo "<td class='text'> Date D&eacute;but : <input type='date' name='date_debut'> </td>";
echo "<td class='text'> Date Fin : <input type='date' name='date_fin'> </td>";
echo "</td></tr>";
echo "<td colspan='4' align='center'><input type='submit' value='ok'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type='reset'</td>";
Echo "</tr>";
Echo "</table>";
echo "</form></center>";
echo "<br>";
include 'menu/footer.php';

?>
