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

include 'menu/header.php';

echo "<section class='workspace'>";
echo "<p class='small-only'>↑ This ugly stuff is why you should design mobile first!</p>";
echo "<center><h2>Gestion SLQ</h2></center>";
echo "<br>";

		echo "<center>";
		echo "<a href='sql_bases.php'><b>Bases</b><b> | </b>";
		echo "<a href='sql_donnes.php'><b>Données</b></a><b> | </b>";
		echo "<a href='sql_corrections.php'><b>Corrections</b></a><b> | </b>";
		echo "<a href='sql_suppression.php'><b>Suppression</b></a>";
		echo "<tr></td>";
		echo "</table>";
		echo "</center>";

echo "<br>";
echo "<br>";
$Nb_Enrg=0;
$SelDeb = date("Y-m-d", mktime(0,0,0,01,01,2017));
$SelFin = date("Y-m-d", mktime(0,0,0,12,31,2020));
echo "<center><table width='900' border='1' cellspacing='2' cellpadding='2'>";	

	//$sql1 = "SELECT IdNumStock,Num_Lot,TRIM(`Num_Lot`) AS Num_Lot_MAj,Num_Traca, TRIM(`Num_Traca`) AS Num_Traca_MAj,Date FROM `stock`"; 
	$sql1 = "SELECT * FROM `stock`"; 
  $sql1.=" WHERE Date BETWEEN '".$SelDeb."' AND '".$SelFin."'";
  //$sql1.=" WHERE Num_Lot like 'A03310020%' ";
  $sql1.=" ORDER BY `Date` DESC";
	$req1 = mysqli_query($link, $sql1); 
	while ($row = mysqli_fetch_assoc($req1)) {
	$IdNumStock =	$row["IdNumStock"];
  $Num_Lot = $row["Num_Lot"];
 	//$Num_Lot_MAj = $row["Num_Lot_MAj"];
  $Num_Traca = $row["Num_Traca"];
 // $Num_Traca_MAj = $row["Num_Traca_MAj"];
  
  $Num_Lot_nb=strlen($Num_Lot);
 // $Num_Lot_MAj_nb=strlen($Num_Lot_MAj);
  
  $Num_Traca_nb=strlen($Num_Traca);
 // $Num_Traca_MAj_nb=strlen($Num_Traca_MAj);
  
  $Num_Lot_MAj = trim($Num_Lot);
  $Num_Traca_MAj = trim($Num_Traca);
  
  $Num_Lot_MAj_nb=strlen($Num_Lot_MAj);
  $Num_Traca_MAj_nb=strlen($Num_Traca_MAj);
  

  
  
  if ($Num_Lot_nb <> $Num_Lot_MAj_nb OR $Num_Traca_nb <> $Num_Traca_MAj_nb) {
  $Nb_Enrg=$Nb_Enrg+1;
  echo "<tr><th>$Nb_Enrg</th><th>$IdNumStock</th><th>Num_Lot :</th><td>$Num_Lot | $Num_Lot_nb | $Num_Lot_MAj | <font color='red'>$Num_Lot_MAj_nb</font></td>";
  if ($Num_Traca_nb <> $Num_Traca_MAj_nb) {
	echo "<th>Num_trace :</th><td>$Num_Traca | $Num_Traca_nb | $Num_Traca_MAj |<font color='red'>$Num_Traca_MAj_nb</font></td></th></tr>";
	}	ELSE {
	echo "<th>Num_trace :</th><td>$Num_Traca | $Num_Traca_nb | $Num_Traca_MAj |<font color='green'>$Num_Traca_MAj_nb</font></td></th></tr>";	
		}
	
	/*
  } ELSE {
  echo "<tr><th>$IdNumStock</th><th>Num_Lot :</th><td>$Num_Lot | $Num_Lot_nb | $Num_Lot_MAj | <font color='green'>$Num_Lot_MAj_nb</font></td>
	<th>Num_trace :</th><td>$Num_Traca | $Num_Traca_nb | $Num_Traca_MAj |<font color='green'>$Num_Traca_MAj_nb</font></td></th></tr>";	
  }
  */				
$sql = "UPDATE stock SET 
`Num_Lot` = '$Num_Lot_MAj', 
`Num_Traca` = '$Num_Traca_MAj'

WHERE `IdNumStock` = '$IdNumStock'";


 
//$res = mysqli_query($link, $sql);

echo "<br>Requette : ".$sql." | rslt : ".$res ;
	
	}}
echo "<tr><th></th></tr>";
echo "</table></center>";

  echo "<p><br>".$sql1."<br></p>";
/*
echo "<p>Lorem ipsum dolor sit amet,  Duis sit amet neque blandit, facilisis est sit amet, hendrerit odio. Curabitur euismod sapien elit, quis.</p>";
echo "<p>amet. Curabitur nec mauris e Curabitur in enim ac tellus varius blandit non sit amet erat. Ut et sodales quam. Sed quis eros sit amet ante ultrices accumsan.</p>";
echo "<p>dolorum facere quas qui ipsum repellendus sit quaerat totam quasi ut reprehenderit labore.</p>";
echo "<p> aliquet mi. Nulla eget facilisis leo. Suspendisse potenti. Etiam auctor varius metus, quis iaculis turpis.</p>";
echo "<p>Corpont distinctio enim laborum aliquid vel eveniet fugit! Adipisci architecto alias esse rem.</p>";
echo "<p> auctor, mi non tempor ultricies, sapien nisi sodales orci, non cursus nunc ipsum non libero. In neque ipsum.</p>";
echo "<p>Numquam  culpa laudantium quo totam vero dolore rerum quidem nisi voluptates quaerat in alias?</p>";
echo "<p> lorem metus, a volutpat nisl luctus a. Suspendisse feugiat ut libero a pulvinar. Cras sed iaculis purus.</p>";
echo "<p>Duis  lacinia urna nibh sit amet est. Fusce in erat interdum, mattis dolor et, fringilla nibh.</p>";
*/
include 'menu/footer.php';
?>