<!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" />
<link rel="shortcut icon" href="<?php echo base_url()?>img/salihin_logo.png">
<title>Account Details For <?php echo $period.'dd'.$year ?></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() ?>glreports/accountDetailsfc_excel/<?php echo $ID;?>/<?php echo $year;?>/<?php echo $period;?>";
	window.location.href = url;
}
function do_printexcel2(){
	var url = "<?php echo base_url() ?>glreports/accountDetailsfc_excel2/<?php echo $ID;?>/<?php echo $year;?>";
	window.location.href = url;
}
</script>
<style>        
    .tots {
        border-top:1px solid black;
        border-bottom:double black;
    }
    .sep {
        border-bottom:1px solid black;
    }
    .sep {
        border-top:1px solid black;
    }
    .sep td {
        padding-bottom:5px;
    }
</style>
</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-icon btn-success-form Print" title="Print"';
			echo form_button('Print','<span class="i-printer">',$js);?>&nbsp;&nbsp; <?php
			if($period=='' || $period==0){
				$js = 'onClick="do_printexcel2()" class="btn-icon btn-warning-form EXCEL" title="Download"';
				echo form_button('EXCEL','<span class="i-download">',$js);
			}
			else{
				$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-form btn-danger-form Close" title="Close"';
			echo form_button('Close','<span class="i-switch">',$js);?>
        </td>
    </tr>
</table>
</div>
<div>
	<table cellpadding="0" cellspacing="0" width="100%" id="oTable" class="editable">
                	<thead>
                    <tr>
                    	<td colspan="7"><?php $this->load->view('layouts/report/header2'); ?></td>
                    </tr>
                    <?php
						if($ID <> ''){
							echo"<tr>";
                    		echo"<th colspan='7' class='tal'>".substr($accountHead->acctCode,0, 4).'-'.substr($accountHead->acctCode,4, 3).'-'.substr($accountHead->acctCode,7, 2) ?>&nbsp;&nbsp;&nbsp;&nbsp;
							<?php echo $accountHead->acctName."</th>";
                    		echo"</tr>";
						}
					?>
                    <tr class="sep">
            			<th style="display:none"></th>
            			<th width="5" class="tac">#</th>
            			<th width="12%">&nbsp;&nbsp;<?php echo $this->lang->line('date')?></th>
            			<th width="12%">&nbsp;&nbsp;<?php echo $this->lang->line('journalNo')?></th>
                        <th><?php echo $this->lang->line('referenceNo')?></th>
            			<th><?php echo $this->lang->line('description')?></th>
            			<th class="tar" width="15%"><?php echo $this->lang->line('amount_dr')?></th>
                        <th width="1%"></th>
            			<th class="tar" width="15%"><?php echo $this->lang->line('amount_cr')?></th>
            			<th class="tar" width="15%"><?php echo $this->lang->line('balance')?></th>
            		</tr>
        			</thead>
       				<tbody>
            		<tr>
                		<td style="display:none" ></td>
                		<td class="tac">1</td>
                		<td class="tac">&nbsp;</td>
                        <td class="tac">&nbsp;</td>
                        <td class="tac">&nbsp;</td>
                		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $this->lang->line('openbalance')?></td>
                        <td class="tac">&nbsp;</td>
                        <td width="1%"></td>
                        <td class="tac">&nbsp;</td>
                		<td class="tar"><?php echo ($accountHead->acctTypeID != '3' && $accountHead->acctTypeID != '4' )?number_format($openingBalance,2):number_format(0,2); ?></td>
                	</tr>
			<?php $bil = 1; 
				//$balanceAmount = $accountdetails->total;
				$balanceAmount = 0;
				$totalDebit=0;
				$totalCredit=0;
				if($datatbls){
					foreach($datatbls as $datatbl):
					if($bil == 1){
					$balanceAmount = $datatbl->amount_dr - $datatbl->amount_cr;
					$totalDebit = $datatbl->amount_dr + $totalDebit;
					$totalCredit = $datatbl->amount_cr + $totalCredit;
					$bil++?>
            		<tr>
                		<td style="display:none" ><?php echo $datatbl->ID; ?></td>
                		<td class="tac"><?php echo $bil; ?></td>
                		<td class="tac">&nbsp;&nbsp;<?php echo date("d-m-Y",strtotime($datatbl->effective_date)); ?></td>
                        <td class="tac">&nbsp;&nbsp;<?php echo $datatbl->journalID?></td>
                		<td class="tac">&nbsp;&nbsp;<?php echo $datatbl->refNo; ?></td>
                		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo substr($datatbl->description, 0, 30)?></td>
                		<td class="tar"><?php echo number_format($datatbl->amount_dr,2); ?></td>
                        <td width="1%"></td>
                		<td class="tar"><?php echo number_format($datatbl->amount_cr,2); ?></td>
                		<td class="tar"><?php echo number_format($balanceAmount,2); ?></td>
                	</tr>
            <?php
					}
					else{
					$balanceAmount = $balanceAmount + $datatbl->amount_dr - $datatbl->amount_cr;
					$totalDebit = $datatbl->amount_dr + $totalDebit;
					$totalCredit = $datatbl->amount_cr + $totalCredit;
					$bil++?>
            		<tr>
                		<td style="display:none" ><?php echo $datatbl->ID; ?></td>
                		<td class="tac"><?php echo $bil; ?></td>
                		<td class="tac">&nbsp;&nbsp;<?php echo date("d-m-Y",strtotime($datatbl->effective_date)); ?></td>
                		<td class="tac">&nbsp;&nbsp;<?php echo $datatbl->journalID?></td>
                        <td class="tac">&nbsp;&nbsp;<?php echo $datatbl->refNo; ?></td>
                		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo  substr($datatbl->description, 0, 30)?></td>
                		<td class="tar"><?php echo number_format($datatbl->amount_dr,2); ?></td>
                        <td width="1%"></td>
                		<td class="tar"><?php echo number_format($datatbl->amount_cr,2); ?></td>
                		<td class="tar"><?php echo number_format($balanceAmount,2); ?></td>
                	</tr>
            <?php
					}
			endforeach; 
				}?>
                	<tr>
                		<td style="display:none" ></td>
                		<td></td>
                		<td></td>
                        <td></td>
                		<td></td>
                		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $this->lang->line('total')?></td>
                		<td class="tar sep"><?php echo number_format($totalDebit,2); ?></td>
                        <td width="1%"></td>
                		<td class="tar sep"><?php echo number_format($totalCredit,2); ?></td>
                		<td></td>
                	</tr>
					</tbody>
			</table>                                        
</div>
<div style="page-break-after:always"></div>
</html>
