<script>
$(document).ready(function(){
	$('select').select2();
//	$('#acctCodel').select2();savedetails
	jQuery('.datepicker2').datepicker({
			dateFormat : 'dd-mm-yy',
			changeMonth : true,
			changeYear : true
			});
   var oTable = $("#test").dataTable( {
        "iDisplayLength": 10,
		 "aLengthMenu": [5,10,25,50,100],
		 "sPaginationType": "full_numbers", 
		 "aoColumns": [ 
		 	{"bSortable": false }, 
			null, 
			null, 
			null, 
			null, 
			null,
			null,
			null,
			null ]});
//     oTable.fnSort( [ [1,'asc'] ] );
});

function do_print(){
	window.open("<?php echo base_url() ?>glreports/accountDetailsfc_print/<?php echo $ID;?>/<?php echo $year;?>/<?php echo $period;?>");
}

function do_print2(){
	window.open("<?php echo base_url() ?>glreports/accountDetailsfc_print2/<?php echo $ID;?>/<?php echo $year;?>");
}
</script>
<div id="content-wrapper">
	<!-- Content Header (Page header) -->
    <section class="content-header">
      <h1>
        <?php echo $this->lang->line("title"); ?>
        <small><?php echo $this->lang->line('module'); ?></small>
      </h1>
      <ol class="breadcrumb">
        <li><a href="#"><i class="fa fa-dashboard"></i> Home</a></li>
        <li><a href="#"><?php echo $this->lang->line('module'); ?></a></li>
        <li class="active"><?php echo $this->lang->line('title'); ?></li>
      </ol>
    </section>
    <!-- Main content -->
    <section class="content">
	    <div class="row">
	        <div class="col-xs-12">
	          	<div class="box box-primary">
					<div class="box-header with-border">
						<h3  class="box-title"><?php echo $this->lang->line('title') ?></h3>
					</div><!-- head -->
					<form class="form-horizontal">
						<div class="box-body">
							<div class="form-group col-sm-5"><!-- Row 1-->
								<label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('acctCode');?></label>
								<div class="col-sm-7">
								<?php
								$data = array(
									'name'=>'acctCode', 
									'id'=>'acctCode', 
									'disabled'=>'disabled', 
									'class'=>'form-control',); 
									echo form_input($data,  substr($accountHead->acctCode,0,4).'-'.substr($accountHead->acctCode,4,3).'-'.substr($accountHead->acctCode,7)); ?>
								</div>
							</div><!-- End Row 1-->
							<div class="form-group col-sm-5"><!-- Row 2-->
								<label for="dateFrom" class="col-sm-5 control-label"><?php echo $this->lang->line('acctName');?></label>
								<div class="col-sm-7">
	                        	<?php 								
								$data = array(
									'name'=>'acctName', 
									'id'=>'acctName', 
									'disabled'=>'disabled', 
									'class'=>'form-control',); 
									echo form_input($data, $accountHead->acctName); ?>
								</div>
							</div><!-- End Row 2-->
						</div><!-- content np-->
					</form>	
				</div>  <!-- box box-primary -->  
				<div class="box box-primary">
					<div class="box-header with-border">
	                    <h3 class="pull-left"><?php echo $this->lang->line('titlelist') ?></h3>
	                    <?php /*
	                    <div class="box-title pull-right">
	                        <?php
								if($period=='' || $period==0):

							?>
								<a href="javascript:" class="btn btn-primary btn-sm" onclick="do_print2()"><span class="glyphicon glyphicon glyphicon-print"></span></a>
							<?php	
								else:
							?>
								<a href="javascript:" class="btn btn-primary btn-sm" onclick="do_print()"><span class="glyphicon glyphicon glyphicon-print"></span></a>
							<?php
								endif;
								?>
	                    </div>
	                    */?>
	                </div><!-- /.box-header -->
	                <div class="box-body table-scroll-xs">
	                	<table cellpadding="0" cellspacing="0" width="100%" id="oTable" class="table table-bordered table-striped">
							<thead>
								<tr>
									<th style="display:none"></th>
									<th width="5">#</th>
									<th class="tac"><?php echo $this->lang->line('date')?></th>
									<th><?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"><?php echo $this->lang->line('amount_dr')?></th>
									<th class="tar"><?php echo $this->lang->line('amount_cr')?></th>
									<th class="tar"><?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 colspan="5"><?php echo $this->lang->line('openbalance')?></td>
									<td class="tar"><?php echo (($accountHead->acctTypeID != '3' && $accountHead->acctTypeID != '4') || !$yearPrev )?number_format($openingBalance,2):number_format(0,2); ?></td>
								</tr>
								<?php $bil = 1; 
								//$balanceAmount = $accountdetails->total;
								$balanceAmount = $openingBalance;
								$totalDebit=0;
								$totalCredit=0;
								if($datatbls){
									foreach($datatbls as $datatbl):
								if($bil == 1){
									$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"><?php echo date("d-m-Y",strtotime($datatbl->effective_date)); ?></td>
									<td><a href="<?php echo base_url()?>report/journalDetails/<?php echo $datatbl->journalNo ?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-mini btn-link edit"><?php echo $datatbl->journalID?></a></td>
									<td><?php echo $datatbl->refNo; ?></td>
									<td><?php echo $datatbl->description; ?></td>
									<td class="tar"><?php echo number_format($datatbl->amount_dr,2); ?></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"><?php echo date("d-m-Y",strtotime($datatbl->effective_date)); ?></td>
									<td><a href="<?php echo base_url()?>report/journalDetails/<?php echo $datatbl->journalNo ?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-mini btn-link edit"><?php echo $datatbl->journalID?></a></td>
									<td><?php echo $datatbl->refNo; ?></td>
									<td><?php echo $datatbl->description?></td>
									<td class="tar"><?php echo number_format($datatbl->amount_dr,2); ?></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> <!--Farid-->
									<td class="tar"><?php echo "Total"; ?></td>
									<td class="tar"><?php echo number_format($totalDebit,2); ?></td>
									<td class="tar"><?php echo number_format($totalCredit,2); ?></td>
									<td></td>
								</tr>
							</tbody>
						</table> 
	                </div>
				</div>  <!-- box box-primary -->  
			</div> <!-- col-xs-12-->  
		</div>
	</section> 
</div> <!--content id -->                      
