<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Supplier Statement</title>
<link rel="stylesheet" href="<?php echo base_url()?>css/stylesheets.css" type="text/css" />
<style media="print" type="text/css">
	/*body{FONT-SIZE: 14px;FONT-FAMILY: Arial;COLOR: #000000}*/
	.printButton { display: none; }
</style>
<script language="javascript" type="text/javascript">	
function do_print(){
	window.print();
}
/*function do_printexcel(){
	var url = "<?php //echo base_url()?>aptransaction/printDebitNote_excel/<?php //echo $dateFrom?>/<?php //echo $dateTo?>";
	window.location.href = url;
}*/
</script>
</head>
<div class="printButton" align="center">
<table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
    <tr>
        <td align="center" colspan="2">
        	<?php 
			$js = 'onClick="do_print()" class="btn btn-primary Print" title="Print"';
			echo form_button('Print','<span class="i-printer">',$js);?>&nbsp;&nbsp; <?php
			$js = 'onClick="do_printexcel()" class="btn btn-primary EXCEL" title="Download"';
			echo form_button('EXCEL','<span class="i-download">',$js);?>&nbsp;&nbsp; <?php
			$js = 'onClick="javascript:window.close();" class="btn btn-warning Close" title="Close"';
			echo form_button('Close','<span class="i-switch">',$js);?>
        </td>
    </tr>
</table>
</div>
<div>
	<table border="0" cellpadding="1" cellspacing="0" width="100%">
		<thead>
		<tr>
			<th width="20%"></th>
			<th width="20%"></th>
			<th width="20%"><?php
                     echo $companyInfo->companyName;?></th>
			<th colspan="2" rowspan="3"><h2><?php echo $this->lang->line('titledetail') ?></h2></th>
		  </tr>
        <tr>
			<th></th>
			<th></th>
			<th><?php echo $companyInfo->companyNo;?></th>
		  </tr>
        <tr>
			<th></th>
			<th></th>
			<td class="tac"><?php echo $companyInfo->line1;?><br><?php echo $companyInfo->line2;?></td>
		  </tr>
		</thead>
		<tbody>
        <tr><td width="20%"></td>
        	<td width="20%"></td>
            <td width="20%" class="tac"><?php echo $companyInfo->line3;?><br/><?php echo $companyInfo->companyPostCode;?><?php echo $companyInfo->city;?></td>
            <td>&nbsp;</td>
            <td width="30%"></td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td class="tac"><?php echo $companyInfo->phoneNo;?></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
        	<td></td>
            <td class="tac"><?php echo $companyInfo->faxNo;?></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<b><?php echo $supplierDetails->supplierName;?></b></td>
        	<td></td>
            <td></td>
            <td></td>
            <td class="tac"><b><?php echo "Date :"." ".date('d-m-Y', strtotime($dateFrom))." "."To"." ".date('d-m-Y', strtotime($dateTo)); ?></b></td>
        </tr>
        <tr>
       	  <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $supplierDetails->line1;?><br></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $supplierDetails->line2;?><br/></td>
        	<td></td>
            <td></td>
            <td></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $supplierDetails->line3;?></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $supplierDetails->supplierPostCode;?><?php echo $supplierDetails->city;?></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $supplierDetails->phoneNumber1;?></td>
        	<td></td>
            <td></td>
            <td></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
        	<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $supplierDetails->fax;?></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td></td>
            <td></td>
            <td></td>
        </tr>
        </tbody>
        </table>
        <table border="0" cellpadding="1" cellspacing="0" width="100%">
		<thead>
        <tr style="border-top:0pt solid black; border-bottom:0pt solid black;" bgcolor="#FFCC00">
              			<th style="display:none"></th>
            			<th><?php echo form_label($this->lang->line('ID'),'ID');?></th>
            			<th><?php echo form_label($this->lang->line('transDate'),'transDate');?></th>
                        <th><?php echo form_label($this->lang->line('refNo'),'refNo');?></th>
                        <td><?php echo form_label($this->lang->line('formNo'),'formNo');?></td>   
                        <th><?php echo form_label($this->lang->line('description'),'description');?></th>
                		<th class="tar"><?php echo form_label($this->lang->line('debit'),'debit');?></th>    
                        <th class="tar"><?php echo form_label($this->lang->line('credit'),'credit');?></th>   
                        <th class="tar"><?php echo form_label($this->lang->line('balance'),'balance');?></th>   
            		</tr>
        </thead>
        <tbody>
	<?php $bil = 0;
			//echo var_dump($datatbls); 
				$balance = 0;                    
				foreach($supplierStatement as $row):
				$bil++?>
            	<tr>
                	<td style="display:none" ><?php echo $row->ID; ?></td>	
                	<td class="tac"><?php echo $bil; ?></td>
                	
                	<td class="tac"><?php echo date('d-m-Y', strtotime($row->transDate)); ?></td>
                    <td><?php echo $row->refNo ?></td>
                    <td><?php echo $row->formNo ?></td>
                	<td class="tac">
                            <?php 
                            //echo $row->transType;
                            switch ($row->transType){
                                case "Payment":
                                    echo $this->lang->line('Payment');
                                    break;
                                case "DebitNote" :
                                    echo $this->lang->line('PurchaseDebitNote');
                                    break;
                                case "CreditNote" :
                                    echo $this->lang->line('PurchaseCreditNote');
                                    break;
                                case "Invoice" :
                                    echo $this->lang->line('PurchaseInvoice');
                                    break;
                            }
                        ?>
                        
                        </td>
                    <?php
					$balance += $row->dr;
					$balance -= $row->cr;
                     echo '<td class="tar">'.number_format($row->dr,2,'.',',').'</td>'; //dr
					 echo '<td class="tar">'.number_format($row->cr,2,'.',',').'</td>'; //cr
					 echo '<td class="tar">'.number_format($balance,2,'.',',').'</td>'; //balance?>
                </tr>
            <?php endforeach; ?>
            <tr style="border-top:1pt solid black;">
            <td colspan="8" class="tar"><h8><?php echo $this->lang->line('total').' '.
			number_format ($balance,2,'.',','); ?></h8></td>
            </tr>
            <tr>
        		<td></td>
            	<td></td>
            	<td></td>
            	<td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
        	</tr>
            <tr>
        		<td height="40"></td>
            	<td></td>
            	<td></td>
            	<td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
        	</tr>
            <tr>
        		<td colspan="10"><table border="1" width="100%">
                <tr>
                  <th width="17%"><?php echo $this->lang->line('current'); ?></th>
                  <th width="17%"><?php echo $this->lang->line('1M'); ?></th>
                  <th width="17%"><?php echo $this->lang->line('2M'); ?></th>
                  <th width="17%"><?php echo $this->lang->line('3M'); ?></th>
                  <th width="18%"><?php echo $this->lang->line('4M'); ?></th>
                  <th width="14%"><?php echo $this->lang->line('5M'); ?></th>
                </tr>
                <tr>  
                  <?php
				 // echo var_dump($supplierAging);
				    if($supplierAging)		
					foreach($supplierAging as $row1){
					   echo '<tr><td class="tar">'.number_format($row1->current, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month1, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month2, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month3, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month4, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month5, 2).'</td>';
		               echo '</tr>';
              			echo '</table><br/>'; 
   			 			echo '<table border="1" width="100%">';
                		echo '<tr>';
                  		echo '<th width="17%">'. $this->lang->line('current').'</th>';
                  		echo '<th width="17%">'. $this->lang->line('6M').'</th>';
                  		echo '<th width="17%">'. $this->lang->line('7M').'</th>';
                  		echo '<th width="17%">'. $this->lang->line('8M').'</th>';
                  		echo '<th width="18%">'. $this->lang->line('9M').'</th>';
						echo '<th width="18%">'. $this->lang->line('10M').'</th>';
						echo '<th width="18%">'. $this->lang->line('11M').'</th>';
                		echo '</tr><tr>';
					   echo '<td class="tar">'.number_format($row1->month6, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month7, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month8, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month9, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month10, 2).'</td>';
					   echo '<td class="tar">'.number_format($row1->month11, 2).'</td>';
		               echo '</tr>';
             			echo '</table><br/>'; 
			}?></td>
        	</tr>
            <tr>
        		<td></td>
            	<td></td>
            	<td></td>
            	<td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
        	</tr>
            <tr>
        		<td colspan="10"><div align="right"><?php echo $this->lang->line('buttom1')?></div></td>
        	</tr>
            <tr>
        		<td colspan="10">
                <table border="1" width="100%">
           <tr>
             <td><?php echo $this->lang->line('buttom2')?><br /><?php echo $this->lang->line('buttom3')?><br /><?php echo $this->lang->line('buttom4')?></td>
             </tr>
             <tr>
                <td>
                <div align="justify"><?php echo $this->lang->line('buttom5')?></div></td>
        	</tr></table>
            <tr>
        		<td></td>
            	<td></td>
            	<td></td>
            	<td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
                <td></td>
        	</tr>
		</tbody>
	</table>                                         
</div>
<div style="page-break-after:always"></div>
</html>
