
<!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; }
	
	.footer
	{
    	position:absolute;
    	left:0;
    	bottom:0;
    	width:100%;
	}
	
	@media print {
                .td-print,.td-print*{display:none !important;}
				.printTbl hr{
					margin:0 !important;
				}
				.thPrint th{
					/*background:url(<?php echo base_url() ?>img/rptPaymentAdvice.png) !important;*/
                	/*-webkit-print-color-adjust: exact;*/
					
				}
                /*body{overflow:visible !important;}*/
                @page{ 
                    size: auto;   /* auto is the initial value */ 

                    /* this affects the margin in the printer settings */ 
                    margin: 10px 10px 10px 10px;  
                } 
                .compLogo{
                    width: 150px;
                }

            }
</style>
<script language="javascript" type="text/javascript">	
function do_print(){
	window.print();
}
function do_printexcel(){
	var url = "<?php echo base_url()?>supplierStatement/get_bySupplierID2Excel/<?php echo $dateFrom?>/<?php echo $dateTo?>/<?php echo $idFad ?>";
	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">
            <div class="printButton" align="center">
            <?php 
            /*$js = 'onClick="do_print()" class="btn-icon btn-success-form Print" title="Print"';
            echo form_button('Print','<span class="i-printer">',$js);?>&nbsp;&nbsp; <?php
            $js = 'onClick="do_printexcel()" class="btn-icon btn-warning-form EXCEL" title="Download"';
            echo form_button('EXCEL','<span class="i-download">',$js);?>&nbsp;&nbsp; <?php
            $js = 'onClick="javascript:window.close();" class="btn-icon btn-danger-form Close" title="Close"';
            echo form_button('Close','<span class="i-switch">',$js);*/?>
            </div>
        </td>
    </tr>
</table>
</div>-->
<div>

<table border="0" cellpadding="1" cellspacing="0" width="98%" align="center">
<tr>
	<td colspan="2"  style="overflow:hidden;border-bottom:1px solid #eeeeee; padding-bottom:10px;">
    	<p style="text-align: right; margin:0; padding-right: 10px; font-weight: 500; line-height: 2; padding-bottom: 0px; padding-top: 0px; color: black; font-size: 25px;">
        	<?php echo $this->lang->line('titledetail');//if(isset($rptTitle)) echo $rptTitle; ?>
        </p>
        <img class="compLogo fl" src="<?php echo base_url(). 'images/'.element('logo', $this->session->userdata('logged_in'));?>" style="max-width:150px;" />
        <p style="text-align:center; font-size:16px; width:355px;margin:0 auto;">
        	<span style=" font-weight:800;"><?php echo $companyInfo->companyName; ?></span> <span style="font-size:10px;"><?php echo "(".$companyInfo->companyNo.")";?></span><br />
            <span style="font-size:10px;"><?php echo "GST Registration No : ".$companyInfo->gstRegisteredNo; ?></span><br />
        </p>
        <p style="width: 355px; text-align:center; font-size:10px; line-height:1.4; padding:0 0 5px; margin:0 auto; ">
			<?php if(!empty($companyInfo->line1)): ?><span><?php echo $companyInfo->line1; ?></span><br /><?php endif; ?>
            <?php if(!empty($companyInfo->line2) || !empty($companyInfo->line3)): ?><span><?php echo $companyInfo->line2.", ".$companyInfo->line3; ?></span><br /><?php endif; ?>
            <?php if(!empty($companyInfo->companyPostCode) || !empty($companyInfo->city)): ?><span><?php echo $companyInfo->companyPostCode . '  ' . $companyInfo->city; ?> </span><br /><?php endif; ?>
            <?php if(!empty($companyInfo->fldname) || !empty($companyInfo->fldcountry)): ?><span><?php echo $companyInfo->fldname . '  ' . $companyInfo->fldcountry; ?> </span><br /><?php endif; ?>
            <?php if(!empty($companyInfo->phoneNo) || !empty($companyInfo->faxNo)): ?><span><?php echo 'Phone : ' . $companyInfo->phoneNo . '  Fax : ' . $companyInfo->faxNo; ?> </span><?php endif; ?>
        </p>
     </td>
</tr>
</table>
	<table border="0" cellpadding="0" cellspacing="0" width="98%" align="center">
		<thead>
		<tr height="10">
        	<td></td>
        	<td></td>
            <td></td>
            <td></td>
            <td></td>
        </tr>
        <tr>
        	<td><b><?php echo $supplierDetails->supplierName;?></b></td>
        	<td></td>
            <td></td>
            <td></td>
            <td class="tar"><b><?php echo "As at :"." ".date('d-m-Y'); ?></b></td>
        </tr>
        <tr>
       	  <td><?php echo $supplierDetails->line1;?><br></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td><?php echo $supplierDetails->line2;?><br/></td>
        	<td></td>
            <td></td>
            <td></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
        	<td><?php echo $supplierDetails->line3;?></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td><?php echo $supplierDetails->supplierPostCode;?>&nbsp;<?php echo $supplierDetails->city;?></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td><?php echo $supplierDetails->fldname;?>&nbsp;<?php echo $supplierDetails->fldcountry;?></td>
        	<td></td>
            <td></td>
            <td></td>
            <td>&nbsp;</td>
        </tr>
        <tr>
        	<td><?php echo $supplierDetails->phoneNumber1;?></td>
        	<td></td>
            <td></td>
            <td></td>
          <td>&nbsp;</td>
        </tr>
        <tr>
        	<td><?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>
        <script type="text/javascript" src="<?php echo base_url(); ?>js/jquery/jquery-2.0.0.min.js"></script>
        <script type="text/javascript">
			$(window).load(function(){      
				$(window).resize();
			});
        	$(window).resize(function(){ 
				if($('.image').length){
					$('.image').width($('.image').parents('thead').width());
					$('.image').height($('.image').parents('thead').find('tr:nth-child(2)').height());
				}
			});
        </script>
        <table border="0" cellpadding="1" cellspacing="0" width="98%" style="position:relative;" align="center">
		<thead>
        <tr>
        	<td colspan="9">
                <img class="image" style="position:absolute;left:0;top:0;z-index: -1000;width:100%" alt="" src="<?php echo base_url() ?>img/rptPaymentAdvice.png" />
            </td>
        </tr>
        <tr>
        	<th style="display:none"></th>
            <th><?php echo form_label($this->lang->line('no'),'no');?></th>
            <th><?php echo form_label($this->lang->line('transDate'),'transDate');?></th>
            <th><?php echo form_label($this->lang->line('refNo'),'refNo');?></th>
            <th><?php echo form_label($this->lang->line('formNo'),'formNo');?></th>
            <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 "Discount":
                                    echo $this->lang->line('Discount');
                                    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;
								default : echo $this->lang->line('Others');
									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
				if(($row->transType == "Discount") && ($row->dr >0) && ($row->cr >0)){
                echo"<tr>
                	<td style='display:none' >".$row->ID."</td>	
                	<td class='tac'>".$bil."</td>
                	
                	<td class='tac'>".date('d-m-Y', strtotime($row->transDate))."</td>
                    <td>".$row->refNo."</td>
                    <td>".$row->formNo."</td>
                	<td class='tac'>";
                            switch ($row->transType){
                                case "Payment":
                                    echo $this->lang->line('Payment');
                                    break;
								case "Discount":
                                    echo $this->lang->line('Discount');
                                    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;
//								default : echo $this->lang->line('Others');
								default : echo $row->transType; 
									break;
                            }
                        
                        echo "</td>";
					$balance += $row->dr;
					$balance -= $row->cr;
                     echo "<td class='tar'>".number_format($row->dr,2,'.',',')."</td>
					       <td class='tar'>".number_format($row->cr,2,'.',',')."</td>
					       <td class='tar'>".number_format($balance,2,'.',',')."</td>";
                echo "</tr>";
				}
				else if($row->transType != "Discount"){
					echo"<tr>
                	<td style='display:none' >".$row->ID."</td>	
                	<td class='tac'>".$bil."</td>
                	
                	<td class='tac'>".date('d-m-Y', strtotime($row->transDate))."</td>
                    <td>".$row->refNo."</td>
                    <td>".$row->formNo."</td>
                	<td class='tac'>";
                            switch ($row->transType){
                                case "Payment":
                                    echo $this->lang->line('Payment');
                                    break;
								case "Discount":
                                    echo $this->lang->line('Discount');
                                    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;
//								default : echo $this->lang->line('Others');
								default : echo $row->transType; 
									break;
                            }
                        
                        echo "</td>";
					$balance += $row->dr;
					$balance -= $row->cr;
                     echo "<td class='tar'>".number_format($row->dr,2,'.',',')."</td>
					       <td class='tar'>".number_format($row->cr,2,'.',',')."</td>
					       <td class='tar'>".number_format($balance,2,'.',',')."</td>";
                echo "</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"><!--<div class="footer">--><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('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>';
			}?>
        	</tr>
            </table>
            <table border="0" width="100%">
            <br />
            <tr>
        		<td colspan="10" align="right"><?php echo $this->lang->line('buttom1')?></td>
        	</tr>
            <tr>
        		<td colspan="10">
                <table border="1" width="100%">
           			<tr>
             			<td>
                			<?php echo $this->session->userdata('footerLine1'); ?><br />
                			<?php echo $this->session->userdata('footerLine2'); ?><br />
                			<?php echo $this->session->userdata('footerLine3'); ?></td>
            			</td>
             		</tr>
             		<tr>
                		<td align="justify"><?php echo $this->lang->line('buttom5')?></td>
        			</tr>
                 </table>
             </tr>
            </table>
            <!--</div>-->
          </td>
		</tbody>
	</table>
    <div class="printButton" align="center">
        <table width="100%" border="0" align="center" cellpadding="1" cellspacing="0">
            <tr>
                <td align="center" colspan="2">
                <br />
                    <div class="printButton" align="left">
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <?php 
                    $js = 'onClick="do_print()" class="btn-icon btn-success-form Print" title="Print"';
                    echo form_button('Print','<span class="icon-print">',$js);?> <?php
                    $js = 'onClick="do_printexcel()" class="btn-icon btn-warning-form EXCEL" title="Download"';
                    echo form_button('EXCEL','<span class="icon-download">',$js);?> <?php
                    $js = 'onClick="javascript:window.close();" class="btn-icon btn-danger-form Close" title="Close"';
                    echo form_button('Close','<span class="icon-off">',$js);?>
                    </div>
                </td>
            </tr>
        </table>
    </div>                                         
</div>
<div style="page-break-after:always"></div>
</html>
