<!--<html>
<head>
<title>Supplierdiary Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body {
    font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 14px;
}
h1 {
font-size: 20px;
vertical-align: top;
}

table{
      border-collapse: collapse;
}
table.pagehead {
  width: 100%;

}

table.pagehead td.bborder, th.bborder{

  border-bottom: 1px solid black;
   vertical-align: middle;
}

table.pagehead th.bborder{
  border-bottom: 1px solid black;
  border-right: 1px solid black;
  border-left: 1px solid black;
  vertical-align: baseline;

  }

table.pagehead td.rborder{
  border-right: 1px solid black;
  border-left: 1px solid black;
  vertical-align: middle;
     width:100%;
 }


</style>

</head>
<body>
<div align="center"><img src="images/shared/M-Grill-new123.jpg"  align="center" valign="top" alt="Posics Technologies" width="220" height="60"/><br>
             <?php echo $companyinfo[0]->COMPANYNAME.', '.$companyinfo[0]->ADDRESS1.', '; ?><br>
               <?php echo $companyinfo[0]->ADDRESS2.', '.$companyinfo[0]->CITY.', '.$companyinfo[0]->REGION ; ?>
                    <br>
                    Phone: <?php echo $companyinfo[0]->PHONE1.', '.$companyinfo[0]->PHONE2.', Fax: '.$companyinfo[0]->FAX ?>
                    <br>
                     Email: <?php echo $companyinfo[0]->EMAIL.', Web: '.$companyinfo[0]->WEBSITE?>
<h3><u><big>SupplierDiary</big></u></h3></div>
<table class="pagehead">
<tbody>
<tr>
       <td width="30%" align="right" class="bborder">
   Date: <?php echo date('d-m-Y', time()); ?><br>
               <br>
        </td>
</tr>
</tbody>
</table>

<?php
//echo "<table class='pagehead' cellpadding='5'>";
//echo "<tbody>";
//echo "<thead><tr>
//    <th width='20%' align='center' class='bborder'>Suppliers</th><th width='15%' align='center' class='bborder'>TICKET NO.</th><th width='15%' align='center' class='bborder'>TAX NO.</th><th width='25%' align='center' class='bborder'>DATE</th><th width='20%' align='center' class='bborder'>PAYMENT</th><th width='15%' align='center' class='bborder'>TOTAL</th></tr></thead>";
//$totallines=0;
//$LINETOTAL=0;
//foreach ($supplierdiary as $value) {
//$totallines=$totallines+1;
//$value->REASON=='Purchase';
//if($value->REASON==1)
//{
//    $reason = 'Purchase';
//}
//echo "
//<tr>
//<td class='rborder' align='left'>".$value->NAME."</td>
//<td class='rborder' align='center'>".$value->TICKET."</td>
//<td class='rborder' align='center'>".$value->TAX."</td>
// <td class='rborder' align='center'>".$value->DATE."</td>
// <td class='rborder' align='left'>".$reason."</td>
//    <td class='rborder' align='right'>".$value->TOTAL."</td>
// </tr>";
//$LINETOTAL = $LINETOTAL+($value->TOTAL);
//}
//while($totallines<30)
//{
//       $totallines=$totallines+1;
//    echo "<tr>
//    <td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
//    <td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
//    <td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
//    <td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
//     <td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
//       <td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
//       </tr>";
//}
//echo "<tr>
//   <td class='bborder'></td>
//    <td class='bborder'></td>
//    <td class='bborder'></td>
//    <td class='bborder'></td>
//    <td class='bborder'></td>
//      <td class='bborder'></td>
//        </tr>";
//
//echo "</tbody>";
//echo "</table>";
?>
    <br><br>
    <table class="pagehead" width="100%">
    <tr>
    <td width="50%">&nbsp;</td>
    <td width="40%">&nbsp;</td>
    <td width="10%">&nbsp;</td>
    </tr>
           <?php
//    echo "<table align='right'>";
//echo "<tbody>";
//echo "<tr>
//
//         <td align='right'><b>Grand Total:".$LINETOTAL."<b></td>
//      </tr>";
//  echo "</tbody>";
//echo "</table>";
?>
</table>
</body>
</html>-->


             <html>
<head>
<title>Supplierdiary Report</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style>
body {
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 14px;
}
h1 {
font-size: 20px;
vertical-align: top;
}

table{
border-collapse: collapse;
}
table.pagehead {
width: 100%;

}

table.pagehead td.bborder, th.bborder{

border-bottom: 1px solid black;
vertical-align: middle;
}

table.pagehead th.bborder{
border-bottom: 1px solid black;
border-right: 1px solid black;
border-left: 1px solid black;
vertical-align: baseline;

}

table.pagehead td.rborder{
border-right: 1px solid black;
border-left: 1px solid black;
vertical-align: middle;
width:100%;
}


</style>

</head>
<body>
<div align="center"><img src="images/shared/M-Grill-new123.jpg" align="center" valign="top" alt="Posics Technologies" width="220" height="60"/><br>
<?php echo $companyinfo[0]->COMPANYNAME.', '.$companyinfo[0]->ADDRESS1.', '; ?><br>
<?php echo $companyinfo[0]->ADDRESS2.', '.$companyinfo[0]->CITY.', '.$companyinfo[0]->REGION ; ?>
<br>
Phone: <?php echo $companyinfo[0]->PHONE1.', '.$companyinfo[0]->PHONE2.', Fax: '.$companyinfo[0]->FAX ?>
<br>
Email: <?php echo $companyinfo[0]->EMAIL.', Web: '.$companyinfo[0]->WEBSITE?>
<h3><u><big>SupplierDiary</big></u></h3></div>
<table class="pagehead">
<tbody>
<tr>
<td width="30%" align="right" class="bborder">
Date: <?php echo date('d-m-Y', time()); ?><br>
<br>
</td>
</tr>
</tbody>
</table>







<?php
echo "<table class='pagehead' cellpadding='5'>";
echo "<tbody>";
echo "<thead><tr>
<th width='20%' align='center' class='bborder'>Supplier</th><th width='25%' align='center' class='bborder'>Date</th><th width='20%' align='center' class='bborder'>PurchaseTotal</th><th width='15%' align='center' class='bborder'>Payment</th><th width='15%' align='center' class='bborder'>Balance</th></tr></thead>";
$totallines=0;
$LINETOTAL=0;
$s1='';
$s2='';
$status=0;
$ptotal=0;
$paytotal=0;
$btotal=0;
foreach ($supplierdiary as $value) {
$totallines=$totallines+1;
$s1=$value->SUPPLIER;
if($s2=='')
{
$s2=$s1;
}
if($s2!=$s1)
{
$btotal=$ptotal-$paytotal;
echo "<tr>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
</tr>";
echo "
<tr>
<td class='rborder' align='left'>Total</td>
<td class='rborder' align='center'></td>
<td class='rborder' align='left'>".$ptotal."</td>
<td class='rborder' align='center'>".$paytotal."</td>
<td class='rborder' align='right'>".$btotal."</td>
</tr>";

}
else{
if($status==0)
{
$status=1;


$ptotal=$ptotal+$value->PURCHASETOTAL;
//$paytotal=$paytotal;
$paytotal=$paytotal+$value->PAYMENT;
echo "
<tr>
<td class='rborder' align='left'>".$value->SUPPLIER."</td>
<td class='rborder' align='center'>".$value->DATENEW."</td>
<td class='rborder' align='left'>".$value->PURCHASETOTAL."</td>
<td class='rborder' align='center'>".$value->PAYMENT."</td>
<td class='rborder' align='right'></td>
</tr>";
}


else{
$ptotal=$ptotal+$value->PURCHASETOTAL;
$paytotal=$paytotal+$value->PAYMENT;
echo "
<tr>
<td class='rborder' align='left'></td>
<td class='rborder' align='center'>".$value->DATENEW."</td>
<td class='rborder' align='left'>".$value->PURCHASETOTAL."</td>
<td class='rborder' align='center'>".$value->PAYMENT."</td>
<td class='rborder' align='right'></td>
</tr>";
}
$btotal=$ptotal-$paytotal;
echo "<tr>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
</tr>";
echo "
<tr>
<td class='rborder' align='left'>Total</td>
<td class='rborder' align='center'></td>
<td class='rborder' align='left'>".$ptotal."</td>
<td class='rborder' align='center'>".$paytotal."</td>
<td class='rborder' align='right'>".$btotal."</td>
</tr>";

}
//$btotal=$ptotal-$paytotal;
// echo "<tr>
// <td class='bborder'></td>
// <td class='bborder'></td>
// <td class='bborder'></td>
// <td class='bborder'></td>
// <td class='bborder'></td>
// </tr>";
// echo "
//<tr>
//<td class='rborder' align='left'>Total</td>
// <td class='rborder' align='center'></td>
// <td class='rborder' align='left'>".$ptotal."</td>
// <td class='rborder' align='center'>".$paytotal."</td>
// <td class='rborder' align='right'>".$btotal."</td>
// </tr>";



//$LINETOTAL = $LINETOTAL+($value->TOTAL);
}//(end for)
while($totallines<20)
{
$totallines=$totallines+1;
echo "<tr>
<td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
<td class='rborder'>&nbsp;&nbsp;&nbsp;&nbsp;</td>
</tr>";
}
echo "<tr>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
<td class='bborder'></td>
</tr>";

echo "</tbody>";
echo "</table>";
?>
<br><br>
<table class="pagehead" width="100%">
<tr>
<td width="50%">&nbsp;</td>
<td width="40%">&nbsp;</td>
<td width="10%">&nbsp;</td>
</tr>
<?php
echo "<table align='right'>";
echo "<tbody>";
echo "<tr>

<td align='right'><b>Grand Total:".$LINETOTAL."<b></td>
</tr>";
echo "</tbody>";
echo "</table>";
?>
</table>
</body>
</html>
