<?php include_once("settings.php");
echo '<br>';
$cautare=$_POST['istoric']; 
$sql = mysqli_query($connect, "SELECT * FROM `clienti` WHERE firma LIKE '%$cautare%' OR agent LIKE '%$cautare%' ORDER BY `id` asc");

$suma=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 LIKE '%$cautare%' GROUP BY firma order by id asc");

echo'<center><b>'.$cautare.'</b></center>';
echo '<form method="post" action="index.php?page=incarca-stoc" enctype="multipart/form_data">';
echo '<table width="100%" border="1" align="center" cellpadding="0" cellspacing="0">';
echo '<tr>
		<td >Data</td>
		<td >Agent</td>
		<td >Data Document</td>
		<td >Document</td>
		<td width="180px">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>
		<td >Observatii</td>
		<td >Modifica stoc</td>
	</tr>';

while ($row=mysqli_fetch_row($sql)) {
	echo '
		<tr>
		
		<td>'.$row[1].'</td>
		<td>'.$row[2].'</td>
		<td>'.$row[3].'</td>
		<td>'.$row[4].'</td>
		<td>'.$row[5].'</br>CUI '.$row[20].'</td>
		<td>'.$row[6].'</td>
		<td>'.$row[7].'</td>
		<td>'.$row[17].'</td>
		<td>'.$row[8].'</td>
		<td>'.$row[9].'</td>
		<td>'.$row[10].'</td>
		<td>'.$row[11].'</td>
		<td>'.$row[12].'</td>
		<td>'.$row[13].'</td>
		<td>'.$row[14].'</td>
		<td>'.$row[15].'</td>
		<td>'.$row[18].'</td>
		<td>'.$row[19].'</td>
		<td width="180px">'.$row[16].'</td>
		<td>
			<input name="incarca" type="hidden" value="'.$row['5'].'">
			<input name="submit" type="submit" value="Modifica">
			</td>
		</tr>';
}
while ($rand=mysqli_fetch_row($suma)) {
echo '
	<tr >
    <td colspan="5" rowspan="2"><b><font size="4" color="">TOTAL GENERAL PE ARTICOLE</font></b></td>
	<td >'.$rand['2'].'</td>
	<td >'.$rand['3'].'</td>
	<td >'.$rand['12'].'</td>
	<td >'.$rand['4'].'</td>
	<td >'.$rand['5'].'</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['13'].'</td>
	<td >'.$rand['14'].'</td>
	<td  colspan="2" rowspan="2"></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>';
?>	