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

$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), cui AS sticlaH FROM clienti GROUP BY firma");

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

$suma= mysqli_query($connect, "SELECT id, date, 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` ");

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 ></td>
		<td >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'].'" size="40">
	</td>
	<td >'.$row['1'].'</br>CUI '.$row['15'].'</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>';
}
while ($rand=mysqli_fetch_row($suma)) {
echo '
	<tr >
    <td rowspan="2"><center><b><font size="4" color="">TOTAL GENERAL PE ARTICOLE</font></b></center></td>
	<td >'.$rand['4'].'</td>
	<td >'.$rand['5'].'</td>
	<td >'.$rand['14'].'</td>
	<td >'.$rand['6'].'</td>
	<td >'.$rand['7'].'</td>
	<td >'.$rand['8'].'</td>
	<td >'.$rand['9'].'</td>
	<td >'.$rand['10'].'</td>
	<td >'.$rand['11'].'</td>
	<td >'.$rand['12'].'</td>
	<td >'.$rand['13'].'</td>
	<td >'.$rand['15'].'</td>
	<td >'.$rand['16'].'</td>
	</tr>';
}
echo '<tr>		
		<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>";
?>

