<?php include_once("settings.php"); 


$order=$_POST['order']; 
$desc=$_POST['desc']; 

$sql=mysqli_query($connect, "SELECT agent, firma, sum(sticlaH), sum(navetaH), sum(keg30H), sum(keg50H), sum(sticlaT), sum(navetaT), sum(keg30T), sum(keg50T), sum(palet_euro), sum(palet_neuro), sum(keg20H), sum(vitrina_romaqua), sum(vitrina_aquacarpatica) FROM clienti GROUP BY firma ORDER BY $order $desc");

echo "<br>";
$rows=mysqli_num_rows($sql);
echo "<b>$rows</b> Clienti inregistrati<p>";

echo '<form method="POST" action="index.php?page=arata-istoric">';

echo '<table width="98%" border="1" align="center" cellpadding="0" cellspacing="0">';
echo '<tr>	
		<td width="300px">Firma</td>
		<td >Sticle<br />Heineken</td>
		<td >Navete<br />Heineken</td>
		<td >Keg 20L<br />Heineken</td>
		<td >Keg 30L<br />Heineken</td>
		<td >Keg 50L<br />Heineken</td>
		<td >Sticle<br />Tuborg</td>
		<td >Navete<br />Tuborg</td>
		<td >Keg 30L<br />Tuborg</td>
		<td >Keg 50L<br />Tuborg</td>
		<td >Palet<br />EURO</td>
		<td >Palet<br />N-EURO</td>
		<td >Palet CHEP<br />Albastru</td>
		<td >Palet<br />ROSE</td>
	</tr>';
while ($row=mysqli_fetch_row($sql)) {
echo '<tr>
		
		<td ><input name="istoric" type="submit" alt="'.$row[1].'" title="Vezi toate tranzactiile acestui client" border="0" value="'.$row[1].'" style="width: 98%;"></td>
		<td>'.$row[2].'</td>
		<td>'.$row[3].'</td>
		<td>'.$row[12].'</td>
		<td>'.$row[4].'</td>
		<td>'.$row[5].'</td>
		<td>'.$row[6].'</td>
		<td>'.$row[7].'</td>
		<td>'.$row[8].'</td>
		<td>'.$row[9].'</td>
		<td>'.$row[10].'</td>
		<td>'.$row[11].'</td>
		<td>'.$row[13].'</td>
		<td>'.$row[14].'</td>
	</tr>';
}
echo '<tr>	
		<td width="300px">Firma</td>
		<td >Sticle<br />Heineken</td>
		<td >Navete<br />Heineken</td>
			<td >Keg 20L<br />Heineken</td>
		<td >Keg 30L<br />Heineken</td>
		<td >Keg 50L<br />Heineken</td>
		<td >Sticle<br />Tuborg</td>
		<td >Navete<br />Tuborg</td>
		<td >Keg 30L<br />Tuborg</td>
		<td >Keg 50L<br />Tuborg</td>
		<td >Palet<br />EURO</td>
		<td >Palet<br />N-EURO</td>
		<td >Palet CHEP<br />Albastru</td>
		<td >Palet<br />ROSE</td>
	</tr>';
echo "</table>";
echo "</form>";

?> 

