<script type="text/javascript">
$(document).ready(function() {
    /* Build the DataTable with third column using our custom sort functions */
   $('select').select2();
  /* var oTable = $("#test").dataTable( {
        "iDisplayLength": 100,
     "aLengthMenu": [5,10,25,50,100],
     "sPaginationType": "full_numbers", "aoColumns": [ { 
      "bSortable": false }, 
      null, 
      null,
      null ]});
    $("table.editable").on("click",".edit",function(){
        rRow = $(this).parents("tr");
        ID = $('td:first', $(this).parents('tr')).text(); 
        $("#row_edit").dialog("open");
    });
  */
  $('select').select2();
    /*$("table.editable").on("click",".edit",function(){
        rRow = $(this).parents("tr");
        ID = $('td:first', $(this).parents('tr')).text(); 
    var selyear = <?php echo $selyear;?>;
        $("#row_edit").dialog("open");
    });
  
   $("#row_edit").dialog({
        autoOpen: false,
        resizable: false,        
        modal: true,
        buttons: {
            "Continue...": function() {
        window.location.href = "<?php echo base_url(); ?>glreports/accountDetailsfc/" + ID + "/<?php echo $selyear;?>";   
                $(this).dialog("close");
            },
            Cancel: function() {
                $(this).dialog("close");
            }
        }
    });*/ 
  
     
}); 
function do_print(){
  var addyear = $('#add_year option:selected').val();
  var add_period = $('#add_period option:selected').val();
  window.open("<?php echo base_url() ?>glreports/financialPosition_print/"+addyear+"/"+add_period);
}
 
function changeList(){
  var addyear = $('#add_year option:selected').val();
  var add_period = $('#add_period option:selected').val();
  if(add_period == null){
    var urls = "<?php echo base_url();?>glreports/financialposition/"+addyear+"/"+0;
    window.location = urls;
  }
  else{
    var urls = "<?php echo base_url();?>glreports/financialposition/"+addyear+"/"+add_period;
    window.location = urls;
  }
}
  function selectYearPeriod(obj){
    var year = obj.value;
//    alert(year);
      jQuery("#add_period").empty();
      $.ajax({
          type: "POST",
          dataType: "json",
        url: "<?php echo base_url()?>glreports/get_TrialBalance_year/"+year,
        data: year,
          async: false,
          success: function(content){
          if(content.status == "success") {
          var items = [];
          //items.push('<option value=""><?php echo $this->lang->line('pleaseselect') ?></option>');
          for ( var i = 0; i < content.message.length; i++) {
          items.push('<option value="'+content.message[i].period+'">'
            + content.message[i].financialPeriodAsat + '</option>');
          }  //end for
          jQuery("#add_period").empty();
          jQuery("#add_period").append(items.join('</br>'));
          $("#add_period").select2();
        } else {
          $("#error").html('<p>'+content.message+'</p>');
          $("#add_period").select2('val',null);
        } //end if
          
      } //end success
        
      }); //end ajax
//  window.location.reload(true); 
}

</script>
<div id="content">                        
<div class="wrap">
  <div class="head">
    <div class="info">
      <!--<h1><?php echo element('compName', $this->session->userdata('logged_in')) ?> [ 
      <?php echo element('compNo', $this->session->userdata('logged_in')) ?> ]</h1>-->
      <ul class="breadcrumb">
              <li><a href="#"><?php echo $this->lang->line('dashboard') ?></a> <span class="divider">-</span></li>
                <li><a href="<?php echo base_url()?>generalLedger/home"><?php echo $this->lang->line('module') ?></a> <span class="divider">-</span></li>
                <li class="active"><?php echo $this->lang->line('statFinPos') ?></li>
            </ul>
    </div><!-- info -->
  <div class="search">
    <form action="<?php echo base_url() ?>admin/search" method="post">
      <input name="search_text" type="text" placeholder="search..."/>                                
            <button type="submit"><span class="i-magnifier"></span></button>
    </form>
  </div>                        
</div><!-- head --> 
<div class="content">
  <div class="wrap">    
    <div class="row-fluid">
      <div class="span12">
              <div class="block">
                  <div class="head">
                      <h2><?php echo $this->lang->line('statFinPos') ?></h2>
            <div class="side fr">
              <button class="btn-form btn-success-form" onClick="do_print()"><?php echo $this->lang->line('print') ?></button>
            </div>
                    </div><!-- head -->
        <div class="content np">    
                  <div class="controls-row"><!-- Row 4-->
            <div class="span5 tac">
                      <div class="span2 tar"><?php echo form_label($this->lang->line('year'),'add_year');?></div>
            <?php
              $preselyear = $selyear;
              $options = '';
              $options[] = $this->lang->line('selectyear');
              if(!empty($yrs)){
                foreach($yrs as $row){
                  $options[$row['financialYear']] = $row['financialYear'];
                }
              }
              $js='onchange="selectYearPeriod(this)" class="input-medium" id="add_year"';
              echo form_dropdown('add_year', $options, $preselyear, $js);
            ?>       
                        </div>
            <div class="span5 tac">
                      <div class="span2 tar"><?php echo form_label($this->lang->line('period'),'add_period');?></div>
            <?php
              $preselperiod = $selperiod;
              $options = '';
              $options[] = $this->lang->line('period');
              if(!empty($period)){
                foreach($period as $row){
                  $options[$row->period] = $row->financialPeriodAsat;
                }
              }
              $js='class="input-medium" id="add_period" style="width:75%"';

              echo form_dropdown('add_period', $options, $preselperiod, $js);
            ?>       
                        </div>
            <div class="span2 tac">
                        <?php 
              $data = array(
                  'name'=>'mysubmit', 
                  'class'=>'btn-form btn-warning-form');
                  $js="onClick='changeList()'";
              echo form_button($data,$this->lang->line('generatereport'),$js);
              ?>
                        </div>
                  </div><!-- End Row 4-->
        </div><!-- content -->
              <div class="content np">
              <table class="editable" cellpadding="0" cellspacing="0" width="100%">
                  <thead>
                    <tr>
                        <th><?php echo $this->lang->line('description') ?></th>
                        <th width="20%" class="tar"><h4><?php echo $this->lang->line('thisyear') ?></h4></th>
                        <th width="10px">&nbsp;</th>
                        <th width="20%" class="tar"><h4><?php echo $this->lang->line('lastyear') ?></h4></th>
                </tr>
              </thead>
               <tbody>
      <?php 
        if(isset($accountGroup) && !empty($accountdetails)){
        foreach($accountGroup as $datatbl):
              $total_thisyear = 0;
              $total_lastyear = 0;
              $thisyear_amount = 0;
              $lastyear_amount = 0;
              $tyear_amount = 0;
              $lyear_amount = 0;
        ?>
        <?php if ($datatbl->title == 1) {?>
            <tr>
                  <td colspan="4"><h5><?php echo $this->lang->line($datatbl->acctGroupName)?></h5></td>
                </tr>
                <?php } ?>
                  <?php foreach($groupdetails as $rowdet):
                  $rowdet_thisyeartotal = 0;
                  $rowdet_lastyeartotal = 0;
              if($rowdet->parentID == $datatbl->ID){?>
              <?php if ($rowdet->title == 1) {?>
                      <tr>
                          <td colspan="4">&nbsp;&nbsp;&nbsp;<strong><?php echo $this->lang->line($rowdet->acctGroupName)?></strong></td>
                        </tr>
                <?php } ?>
                        <?php foreach($groupdetails as $rowdet1):
                  $rowdet1_thisyeartotal = 0;
                  $rowdet1_lastyeartotal = 0;
                    if($rowdet1->parentID == $rowdet->ID){?>
                        <?php if ($rowdet1->title == 1) {?>
                            <tr>
                                <td colspan="4">&nbsp;&nbsp;&nbsp;<strong><?php echo $this->lang->line($rowdet1->acctGroupName)?></strong></td>
                              </tr>
                <?php } ?>
                        <?php if($accountdetails){ ?>
                        <?php foreach($accountdetails as $row):
                    if($row->acctGroupID == $rowdet1->ID){?>
                                       <?php  if($row->lastyeardebit == 0 && $row->lastyearcredit == 0 && $row->currentyeardebit == 0 && $row->currentyearcredit == 0){ }else{ ?>
                                       <?php $tyear_amount = ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                       <?php $lyear_amount = $row->lastyeardebit-$row->lastyearcredit;
                                              if(floatval($tyear_amount) == 0 && floatval($lyear_amount)==0) continue;
                                       ?>
                            <tr>
                          <td style="display:none" ><?php echo $row->ID; ?></td>
                            <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url(); ?>glreports/accountDetailsfc/<?php echo $row->ID; ?>/<?php echo $selyear;?>/<?php echo $selperiod;?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-link edit"><?php echo substr($row->acctCode,0, 4).'-'.substr($row->acctCode,4, 3).'-'.substr($row->acctCode,7, 2).' [ '.$row->acctName.' ]'?></td>
                                                <?php if($rowdet1->status == 1){?>
                                  <td class="tar"><?php echo ($tyear_amount <= 0 )?number_format($tyear_amount * -1,2):'('.number_format($tyear_amount,2).')'?></td>
                                                  <td>&nbsp;</td>
                                  <td class="tar"><?php echo ($lyear_amount <= 0 )?number_format($lyear_amount * -1,2):'('.number_format($lyear_amount,2).')'?></td>
                                <?php }else{?>
                                  <td class="tar"><?php echo ($tyear_amount >= 0 )?number_format($tyear_amount,2):'('.number_format($tyear_amount * -1,2).')'?></td>
                                                  <td>&nbsp;</td>
                                  <td class="tar"><?php echo ($lyear_amount >= 0 )?number_format($lyear_amount,2):'('.number_format($lyear_amount * -1,2).')'?></td>
                                <?php }?>
                              </tr>
                                            <?php $rowdet1_thisyeartotal = $rowdet1_thisyeartotal + 
                        ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                            <?php $rowdet1_lastyeartotal = $rowdet1_lastyeartotal + ($row->lastyeardebit-$row->lastyearcredit);?>
                                            <?php $rowdet_thisyeartotal = $rowdet_thisyeartotal + 
                        ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                            <?php $rowdet_lastyeartotal = $rowdet_lastyeartotal + ($row->lastyeardebit-$row->lastyearcredit);?>
                                            <?php $total_thisyear = $total_thisyear + ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                            <?php $total_lastyear = $total_lastyear + ($row->lastyeardebit-$row->lastyearcredit);?>
                                    <?php } ?>        
                      <?php   }
                endforeach;?>
                                <?php } ?>
                      <tr>
                          <td>&nbsp;&nbsp;&nbsp;<?php echo $this->lang->line('subtotal') ?> <?php echo $this->lang->line($rowdet1->acctGroupName)?> </td>
                                    <?php if($rowdet1->status == 1){?>
                        <td class="tar sep"><?php echo ($rowdet1_thisyeartotal <= 0 )?number_format($rowdet1_thisyeartotal * -1,2):'('.number_format($rowdet1_thisyeartotal,2).')'?></td>
                                        <td>&nbsp;</td>
                        <td class="tar sep"><?php echo ($rowdet1_lastyeartotal <= 0 )?number_format($rowdet1_lastyeartotal * -1,2):'('.number_format($rowdet1_lastyeartotal,2).')'?></td>
                      <?php }else{?>
                          <td class="tar sep"><?php echo ($rowdet1_thisyeartotal >= 0 )?number_format($rowdet1_thisyeartotal,2):'('.number_format($rowdet1_thisyeartotal * -1,2).')'?></td>
                                        <td>&nbsp;</td>
                          <td class="tar sep"><?php echo ($rowdet1_lastyeartotal >= 0 )?number_format($rowdet1_lastyeartotal,2):'('.number_format($rowdet1_lastyeartotal * -1,2).')'?></td>
                      <?php }?>
                        </tr>
                                <tr><td colspan="4">&nbsp;</td></tr>
                      <?php   }
                endforeach;?>
                        <?php if($accountdetails){ ?>
                        <?php foreach($accountdetails as $row):

                        //print_r($row);
                    if($row->acctGroupID == $rowdet->ID){  ?>
                                <?php    if($row->acctCode == '130000000') {?>
                                <?php       $thisyear_amount = $currentretained;?>
                                <?php       $lastyear_amount = $lastyearretained; //$row->lastyeardebit-$row->lastyearcredit 
                                            if(floatval($thisyear_amount) == 0 && floatval($lastyear_amount)==0) continue;
                                ?>
                            <tr>
                              <td style="display:none" ><?php echo $row->ID; ?></td>
                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url(); ?>glreports/accountDetailsfc/<?php echo $row->ID; ?>/<?php echo $selyear;?>/<?php echo $selperiod;?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-mini btn-link edit"><?php echo  substr($row->acctCode,0, 4).'-'.substr($row->acctCode,4, 3).'-'.substr($row->acctCode,7, 2).' [ '.$row->acctName.' ]'?></a></td>
                                    <?php if($rowdet->status == 1){?>
                        <td class="tar"><?php echo ($thisyear_amount <= 0 )?number_format($thisyear_amount * -1,2):'('.number_format($thisyear_amount,2).')'?></td>
                                        <td>&nbsp;</td>
                        <td class="tar"><?php echo ($lastyear_amount <= 0 )?number_format($lastyear_amount * -1,2):'('.number_format($lastyear_amount,2).')'?></td>
                      <?php }else{?>
                          <td class="tar"><?php echo ($thisyear_amount >= 0 )?number_format($thisyear_amount,2):'('.number_format($thisyear_amount * -1,2).')'?></td>
                                        <td>&nbsp;</td>
                          <td class="tar"><?php echo ($lastyear_amount >= 0 )?number_format($lastyear_amount,2):'('.number_format($lastyear_amount * -1,2).')'?></td>
                      <?php }?>
                              </tr>
                                            <?php $total_thisyear = $total_thisyear + $thisyear_amount;?>
                                            <?php $total_lastyear = $total_lastyear + $lastyear_amount;?>
                                            <?php $rowdet_thisyeartotal = $rowdet_thisyeartotal + ($row->lastyeardebit-$row->lastyearcredit)+$thisyear_amount;?>
                                            <?php $rowdet_lastyeartotal = $rowdet_lastyeartotal + $lastyear_amount;?>
                                <?php }elseif($row->acctCode == '120000000') {?>
                                    <?php       $lastyear_amount = $lastRetained; ?>
                                    <?php       $thisyear_amount = $currRetain;//$currentretained * -1;                                        
                                          
                                                if(floatval($thisyear_amount) == 0 && floatval($lastyear_amount)==0) continue;
                                    ?>
                              <tr>
                                <td style="display:none" ><?php echo $row->ID; ?></td>
                                  <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url(); ?>glreports/accountDetailsfc/<?php echo $row->ID; ?>/<?php echo $selyear;?>/<?php echo $selperiod;?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-mini btn-link edit"><?php echo  substr($row->acctCode,0, 4).'-'.substr($row->acctCode,4, 3).'-'.substr($row->acctCode,7, 2).' [ '.$row->acctName.' ]'?></a></td>
                                <?php if($rowdet->status == 1){?>
                                  <td class="tar"><?php echo ($thisyear_amount <= 0 )?number_format($thisyear_amount * -1,2):'('.number_format($thisyear_amount,2).')'?></td>
                                  <td>&nbsp;</td>
                                  <td class="tar"><?php echo ($lastyear_amount <= 0 )?number_format($lastyear_amount * -1,2):'('.number_format($lastyear_amount,2).')'?></td>
                                <?php }else{?>
                                  <td class="tar"><?php echo ($thisyear_amount >= 0 )?number_format($thisyear_amount,2):'('.number_format($thisyear_amount * -1,2).')'?></td>
                                  <td>&nbsp;</td>
                                  <td class="tar"><?php echo ($lastyear_amount >= 0 )?number_format($lastyear_amount,2):'('.number_format($lastyear_amount * -1,2).')'?></td>
                                <?php }?>
                              </tr>
                                            <?php $total_thisyear = $total_thisyear + $thisyear_amount;?>
                                            <?php $total_lastyear = $total_lastyear + $lastyear_amount;?>
                                            <?php $rowdet_thisyeartotal = $rowdet_thisyeartotal +$thisyear_amount;//+ ($row->lastyeardebit-$row->lastyearcredit)+$thisyear_amount;?>
                                            <?php $rowdet_lastyeartotal = $rowdet_lastyeartotal + $lastyear_amount;?>
                                <?php } ?>
                                       <?php  if($row->lastyeardebit == 0 && $row->lastyearcredit == 0 && $row->currentyeardebit == 0 && $row->currentyearcredit == 0 ){ }
                                       elseif($row->acctCode != '130000000' && $row->acctCode != '120000000'){ ?>
                                       <?php $tyear_amount = ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                       <?php $lyear_amount = $row->lastyeardebit-$row->lastyearcredit;
                                              
                                              if(floatval($tyear_amount) == 0 && floatval($lyear_amount)==0) continue;
                                       ?>
                            <tr>
                              <td style="display:none" ><?php echo $row->ID; ?></td>
                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url(); ?>glreports/accountDetailsfc/<?php echo $row->ID; ?>/<?php echo $selyear;?>/<?php echo $selperiod;?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-mini btn-link edit"><?php echo substr($row->acctCode,0, 4).'-'.substr($row->acctCode,4, 3).'-'.substr($row->acctCode,7, 2).' [ '.$row->acctName.' ]'?></td>
                                    <?php if($rowdet->status == 1){?>
                                      <td class="tar"><?php echo ($tyear_amount <= 0 )?number_format($tyear_amount * -1,2):'('.number_format($tyear_amount,2).')'?></td>
                                                      <td>&nbsp;</td>
                                      <td class="tar"><?php echo ($lyear_amount <= 0 )?number_format($lyear_amount * -1,2):'('.number_format($lyear_amount,2).')'?></td>
                                    <?php }else{?>
                                        <td class="tar"><?php echo ($tyear_amount >= 0 )?number_format($tyear_amount,2):'('.number_format($tyear_amount * -1,2).')'?></td>
                                                      <td>&nbsp;</td>
                                        <td class="tar"><?php echo ($lyear_amount >= 0 )?number_format($lyear_amount,2):'('.number_format($lyear_amount * -1,2).')'?></td>
                                    <?php }?>
                              </tr>
                                            <?php $total_thisyear = $total_thisyear + ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                            <?php $total_lastyear = $total_lastyear + ($row->lastyeardebit-$row->lastyearcredit);?>
                                            <?php $rowdet_thisyeartotal = $rowdet_thisyeartotal + ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit);?>
                                            <?php $rowdet_lastyeartotal = $rowdet_lastyeartotal + ($row->lastyeardebit-$row->lastyearcredit);?>
                                     <?php } ?>
                      <?php   }
                endforeach;?>
                                    <?php } ?>        
                      <tr>
                                  <?php if($rowdet->ID == '39'){?>
                          <td>&nbsp;&nbsp;&nbsp;<strong><?php echo $this->lang->line($rowdet->acctGroupName)?></strong></td>
                                    <?php }else{ ?>
                          <td>&nbsp;&nbsp;&nbsp;<?php echo $this->lang->line('subtotal') ?> <?php echo $this->lang->line($rowdet->acctGroupName)?> </td>
                                    <?php } ?>
                                    <?php if($rowdet->status == 1){?>
                        <td class="tar sep"><?php echo ($rowdet_thisyeartotal <= 0 )?number_format($rowdet_thisyeartotal * -1,2):'('.number_format($rowdet_thisyeartotal,2).')'?></td>
                                        <td>&nbsp;</td>
                        <td class="tar sep"><?php echo ($rowdet_lastyeartotal <= 0 )?number_format($rowdet_lastyeartotal * -1,2):'('.number_format($rowdet_lastyeartotal,2).')'?></td>
                      <?php }else{?>
                          <td class="tar sep"><?php echo ($rowdet_thisyeartotal >= 0 )?number_format($rowdet_thisyeartotal,2):'('.number_format($rowdet_thisyeartotal * -1,2).')'?></td>
                                        <td>&nbsp;</td>
                          <td class="tar sep"><?php echo ($rowdet_lastyeartotal >= 0 )?number_format($rowdet_lastyeartotal,2):'('.number_format($rowdet_lastyeartotal * -1,2).')'?></td>
                      <?php }?>
                        </tr>
                                <tr><td colspan="4">&nbsp;</td></tr>
                <?php   }
              endforeach;?>
                        <?php foreach($accountdetails as $row):
                    if($row->acctGroupID == $datatbl->ID){ ?>
                                <?php     if($row->acctCode == '130000000') { ?>
                                <?php       $thisyear_amount = $currentretained * -1;?>
                                <?php       $lastyear_amount = $lastyearretained * -1;//$row->lastyeardebit-$row->lastyearcredit?>
                                <?php     }else{ ?>
                                <?php       $thisyear_amount = ($row->lastyeardebit-$row->lastyearcredit)+($row->currentyeardebit - $row->currentyearcredit)?>
                                <?php       $lastyear_amount = $row->lastyeardebit-$row->lastyearcredit?>
                                <?php     } 
                                         if(floatval($thisyear_amount) == 0 && floatval($lastyear_amount)==0) continue; 
                                ?>
                            <tr>
                              <td style="display:none" ><?php echo $row->ID.'hello'; ?></td>
                                <td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="<?php echo base_url(); ?>glreports/accountDetailsfc/<?php echo $row->ID; ?>/<?php echo $selyear;?>/<?php echo $selperiod;?>" title="<?php echo $this->lang->line('details');?>" class="btn btn-mini btn-link edit"><?php echo  substr($row->acctCode,0, 4).'-'.substr($row->acctCode,4, 3).'-'.substr($row->acctCode,7, 2).' [ '.$row->acctName.' ]'?></td>
                                    <?php if($datatbl->status == 1){?>
                        <td class="tar"><?php echo ($thisyear_amount <= 0 )?number_format($thisyear_amount * -1,2):'('.number_format($thisyear_amount,2).')'?></td>
                                        <td>&nbsp;</td>
                        <td class="tar"><?php echo ($lastyear_amount <= 0 )?number_format($lastyear_amount * -1,2):'('.number_format($lastyear_amount,2).')'?></td>
                      <?php }else{?>
                          <td class="tar"><?php echo ($thisyear_amount >= 0 )?number_format($thisyear_amount,2):'('.number_format($thisyear_amount * -1,2).')'?></td>
                                        <td>&nbsp;</td>
                          <td class="tar"><?php echo ($lastyear_amount >= 0 )?number_format($lastyear_amount,2):'('.number_format($lastyear_amount * -1,2).')'?></td>
                      <?php }?>
                              </tr>
                                            <?php $total_thisyear = $total_thisyear + $thisyear_amount;?>
                                            <?php $total_lastyear = $total_lastyear + $lastyear_amount;?>
                      <?php   }
                endforeach;?>
                      <tr>
                          <td><h4><?php echo $this->lang->line('total') ?> <?php echo $this->lang->line($datatbl->acctGroupName)?> </h4></td>
                                    <?php if($datatbl->status == 1){?>
                          <td class="tar tots"><?php echo ($total_thisyear <= 0 )?number_format($total_thisyear * -1,2):'('.number_format($total_thisyear,2).')'?></td>
                                        <td>&nbsp;</td>
                          <td class="tar tots"><?php echo ($total_lastyear <= 0 )?number_format($total_lastyear * -1,2):'('.number_format($total_lastyear,2).')'?></td>
                      <?php }else{?>
                          <td class="tar tots"><?php echo ($total_thisyear >= 0 )?number_format($total_thisyear,2):'('.number_format($total_thisyear * -1,2).')'?></td>
                                        <td>&nbsp;</td>
                          <td class="tar tots"><?php echo ($total_lastyear >= 0 )?number_format($total_lastyear,2):'('.number_format($total_lastyear * -1,2).')'?></td>
                      <?php }?>
                        </tr>
                                <tr><td colspan="4">&nbsp;</td></tr>
            <?php endforeach; }?>
                     </tbody>
                     </table>
        </div><!-- content -->
        </div><!-- block -->
      </div><!-- span12 -->
    </div><!-- row-fluid -->  
  </div><!-- wrap -->
</div><!-- content -->
<div class="dialog" id="row_edit" style="display: none;" title="<?php echo $this->lang->line('edit');?> ?">
    <p><?php echo $this->lang->line('message1');?></p>
</div>
</div>
</div>  

