
<?php include_once("settings.php");
echo '<br>';
$cautare=$_POST['cautare']; 
//$sql = mysql_query("SELECT * FROM `clienti` WHERE firma LIKE '%$cautare%' OR agent LIKE '%$cautare%' ORDER BY `id` 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) AS firma FROM clienti WHERE firma like '%".$cautare."%' OR agent = '".$cautare."' GROUP BY firma");

$rows = mysqli_num_rows($sql);
if ($rows == '0'){
echo "<script>alert('Acest client nu exista in baza de date')</script>";
echo "<script>location.replace('index.php')</script>";	
}

echo '<form method="POST" action="index.php?page=arata-istoric">';
//echo '<form method="post" action="index.php?page=incarca-stoc" enctype="multipart/form_data">';
//echo '<form method="post" action="index.php?page=descarca-stoc" enctype="multipart/form_data">';

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" style="width: 300px" alt="'.$row['1'].'" title="Vezi toate tranzactiile acestui client" border="0" id="submit" value="'.$row['1'].'" size="40"></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>
</form>';
?>	
