<table border="0" cellpadding="1" cellspacing="0" width="98%" style="position:relative;" align="center">
	<tr>
		<td colspan="8"  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>
        
        	<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 colspan="8"></td>
        </tr>
        <tr>
        	<td colspan="7"><b><?php echo $customerDetails->customerName;?></b></td>
            <td class="tar"><b><?php echo "As at :"." ".date('d-m-Y'); ?></b></td>
        </tr>
        <tr>
       	    <td colspan="8"><?php echo $customerDetails->line1;?><br></td>
        </tr>
        <tr>
        	<td colspan="8"><?php echo $customerDetails->line2;?><br/></td>
        </tr>
        <tr>
        	<td colspan="8"><?php echo $customerDetails->line3;?></td>
        </tr>
        <tr>
        	<td colspan="8"><?php echo $customerDetails->customerPostCode;?>&nbsp;<?php echo $customerDetails->city;?></td>
        </tr>
        <tr>
        	<td colspan="8"><?php echo $customerDetails->fldname;?>&nbsp;<?php echo $customerDetails->fldcountry;?></td>
        </tr>
        <tr>
        	<td colspan="8"></td>
        </tr>
        </tbody>
        </table>

<table border="0" cellpadding="1" cellspacing="0" width="98%" style="position:relative;" align="center">
		<thead>
        
        <tr>
            <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($customerStatement as $row):
				$bil++?>
                <?php
				if(($row->transType == "Discount") && ($row->dr >0) && ($row->cr >0)){
                echo"<tr>
                	<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');
									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 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');
									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($customerAging)		
					foreach($customerAging 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>