<?php
include("include/data.php");
Init_boutique();
global $base, $MySQL_Host, $MySQL_User, $MySQL_Passw, $CodeArt, $myart, $NomArticle, $PrixArt, $PrixArtPd, $NumArt, $CodeArts, $A_NumArt,$i, $result, $NbLigne, $mygroupeart, $mysousgroupeart, $semaine, $limitesuivante, $limiteprecedente, $limite, $total, $page, $pagemax ;
// entete de la page

include 'menu/header.php';
$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_fournisseur) FROM fournisseurs';
$selectc.=" WHERE `IdNumClient`='".$IdNumClient."'";
$result = mysqli_query($link, $selectc);
$row = mysqli_fetch_row($result);
$total = $row[0];
$NbPage = floor($total/10);
$pagemax = (floor($total/10))*10;

//echo "<center>total : ".$total."| limite : ".$limite."| limite suivante : ".$limitesuivante."| limite precedente :".$limiteprecedente ."| Page Max : ".$pagemax."</center>";
//
echo "<center><b>Fournisseurs</b></center>" ;

echo "<center><HR size='1' width='500'>";
echo "<span class='t-text'>";
Echo "<table cellspacing=0 cellpadding=0 align=center border=0>";
Echo "<td>";
echo "<a href='ajout_four.php'><b>Nouveau</b></a> <b> | </b>";
echo "<a href=''><b>Consulter</b></a> <b> | </b>";
echo "<a href=''><b>Supprimer</b></a> <b> | </b>";
echo "<a href=''><b>Modifier</b></a><b></b>";
Echo "</td></tr>";
Echo "</table></span>";
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'>Num Frs</div></td></span>";
echo "<td width='20' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Ident</td></span>";
echo "<td width='120' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Nom Fournisseur</td></span>";
echo "<td width='120' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>Adresse</td></span>";
echo "<td width='32' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>M</td></span>";
echo "<td width='32' height='20' valign='center' bgcolor='#CCCCCC'>
	<div align='center'><span class='t-text'>D</td></span>";
echo "</tr>";

$myart =new fournisseurs;
$select = 'select * FROM fournisseurs ';
$select.=" WHERE `IdNumClient`='".$IdNumClient."'";
$select.=' ORDER BY Num_fournisseur ASC limit '.$limite.','.$nombre;
$result =mysqli_query($link, $select);
$myart->getnum($result);
while ($myart->z < $myart->num) {
  $myart->readrow($result);
  $Num_fournisseur=$myart->Num_fournisseur ;
  $Ident_four=$myart->Ident_four ;
  $Nom_Fournisseur=$myart->Nom_Fournisseur ;
  $Adr_four=$myart->adresse_1 ;
 
  echo "<tr><td width='30' height='20' valign='center'>
	<div align='center'><span class='t-text'><a class='' href='four_fiche.php?Num_fournisseur=$Num_fournisseur'>$Num_fournisseur</a></div></td></span>";
	echo "<td width='20' height='20' valign='center'>
	<div align='center'><span class='t-text'>$Ident_four</div></td></span>";
	echo "<td width='120' height='20' valign='center'>
	<div align='center'><span class='t-text'>$Nom_Fournisseur</div></td></span>";
	echo "<td width='120' height='20' valign='center'>
	<div align='center'><span class='t-text'>$Adr_four</div></td></span>";
	echo "<td width='20' height='20' valign='center'>
	<div align='center'><a class='' href='four_fiche.php?Num_fournisseur=$Num_fournisseur'>
	<img src='images/modifie.png' width='20' height='20'></a></div></td>";
	echo "<td width='20' height='20' valign='center'><a class='' href='delette_fournisseurs.php?Num_fournisseur=$Num_fournisseur'>
	<div align='center'><img src='images/trash.png' width='20' height='20'></div></td></tr>";
} 
echo "</tr></table>";
echo "<br><br>";

//

echo "<table border='0' cellpadding='0' cellspacing='0' width='250' height='22'><tr>";
echo "<td width='120' height='20' valign='center'><div align='center'><span class='t-text'>";
echo '<a href="'.$page.'?limite=0"><img src="images/debut.png" width="20" height="20">Premier</a>';
echo "<td width='120' height='20' valign='center'><div align='center'><span class='t-text'>";	 
if($limite != 0) {
    echo '<a href="'.$page.'?limite='.$limiteprecedente.'"><img src="images/precedent.png" width="20" height="20">precedent</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.'"><img src="images/suivant.png" width="20" height="20">suivant</a>';
}
echo "<td width='120' height='20' valign='center'><div align='center'><span class='t-text'>";
echo '<a href="'.$page.'?limite='.$pagemax.'"><img src="images/fin.png" width="20" height="20">Fin</a>';
echo "</div></td></span>";
echo "</tr></table>";

include 'menu/footer.php';
?>
