<style type="text/css">
@media print {
    @page {
    margin-top: 1.2cm;
    margin-bottom: 3cm;
  }
       *{

        box-sizing: border-box;

    }
    .table-tree{
        width:100%;
        text-align:left;
        padding-left:10px !important;
        font-size: 12px;
        border-collapse: collapse;
        border-spacing: 0;
    }
    .table-tree th{
        padding-top:5px;
        padding-bottom:5px;
        border-top:1px solid #000;
        border-bottom:1px solid #000;
    }
    .table-tree th, td{
        border-left: 0;
        border-right: 0;
        margin: 0;
        padding: 3px 5px;
    }
    .ze{background: #CCC}
    .box-pad,.box-pad *{
        -moz-box-sizing: border-box;
        -webkit-box-sizing: border-box;
        box-sizing: border-box;
    }
    .tre td{
        border:none;
    }
    .level-1{
        padding-left:5px !important;
    }
    .level-2{
        padding-left: 20px !important;

    }
    .level-3{
        padding-left: 35px !important;
    }
    .level-4{
        padding-left: 55px !important;
    }
    .l1{
        font-size: 12px !important;
    }
    .l2{
        font-size: 11px !important;
        font-style: italic !important;
    }
    .l3{
        font-size: 12px !important;
    }

    .l4{
        font-size: 11px !important;
        font-style: italic;
    }
    .txt-right{
        text-align: right !important;
    }

    .tittle{

        width: 100%;

        margin:10px 0;

        float: left;

        text-align: center;



    }

    .tittle h6{

        border-bottom:2px solid #000;

        width: 120px;

        max-width: 330px;

        font-size: 16px;

        margin: 10px auto;

    }

    .date{
        width: 100%;
        float: left;
        font-size: 11px;
        padding-left: 5px;
        font-weight: 600;
        text-align: left;
        padding-bottom: 3px;
    }

    .date span{

        width: 200px;

        display: inline-block;

    }
    .clear{
        clear: both;
    }
    .cell-left{
      text-align: left !important;
    }
    .cell-right{
      text-align: right !important;
    }
    .br-top{
      border-top: 1px solid #000 !important;
      border-bottom: 3px double #000 !important;
    }
    .space{
      width: 100%;
      float: left;
      clear: both;
      height: 5px;
    }
    .col-6{
      width: 50%;
    }
    .col-9{
      width: 75%
    }
    .col-3{
      width:25%;
    }
    .f-l{
      float: left;
    }
    .f-r{
      float: right;
    }
    .txt-right{
      text-align: right;
    }
    .txt-left{
      text-align: left;
    }
    .x-space{
      box-sizing: border-box;
    }
    .bg-w{
      background: #FFF !important;
    }
    .footer {
      width:100%;
      float:left;
      font-size:11px;
      position:absolute;
      bottom:0px;
      left:0px;
      text-align:center !important;
      line-height:18px;
      border-top: 1px dotted #000;
      padding: 5px;
    }
    .span1{
        width: 80px !important;
        display: inline-block;
        float: left;
    }
    .span2{
        width: 80px !important;
        display: inline-block;
        float: left;
    }
    .span3{
        width: auto !important;
        display: inline-block;
        float: left;
    }
    .span5{
        width: 25%;
        display: inline-block;
        float: right;
    }
  }
</style>


<div id="finance-account-trialbal">
<div class="container">
            <div class="heading tittle">
                    <div><h2><?php echo Yii::app()->user->master_company_name;?></h2></div>
            </div>
	</div>
        <div class="tittle"><h6>Trial Balance</h6></div>
        <div class="container-fluid">
        <div class="col-md-12">
                <div class="col-md-9"></div>
                <div class="col-md-3">
                                <div class="date">
                            <div class="span5">
                                <b>End Date</b>
                            : <?php echo date('d/m/Y',strtotime($date_from)); ?></div><br>
                        </div>
                </div>

        </div>
        </div>
    <table class="table-tree">
<thead>
        <tr>

            <th class="cell-left">Account No.</th><th class="cell-left">Description</th><th class="txt-right">Debit</th><th class="txt-right">Credit</th>

        </tr>
</thead>


                    <?php
$year=date("Y");
Yii::app()->db->createCommand("TRUNCATE TABLE trail_balance_tbl_ex")->execute();                    
Yii::app()->db->createCommand("INSERT INTO  trail_balance_tbl_ex (SELECT accounts.sort_order,accounts.opening_bal,accounts.account_no,accounts.description,sub.account_no as subledger_no,sub.description as subledger_description,accounts.level,accounts.account_type,sum(ledger.debit) AS debit,sum(ledger.credit) AS credit FROM `crm_fin_general_ledger` as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id LEFT JOIN crm_fin_subledger as sub ON ledger.subledger=sub.id WHERE ledger.isAllocated='Y' AND ledger.date<='".$date_from."' AND ( accounts.account_type='A' OR accounts.account_type='L') group by ledger.subledger,ledger.account_id order by accounts.account_no)")->execute();
Yii::app()->db->createCommand("INSERT INTO  trail_balance_tbl_ex (SELECT accounts.sort_order,accounts.opening_bal,accounts.account_no,accounts.description,sub.account_no as subledger_no,sub.description as subledger_description,accounts.level,accounts.account_type,sum(ledger.debit) AS debit,sum(ledger.credit) AS credit FROM `crm_fin_general_ledger` as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id LEFT JOIN crm_fin_subledger as sub ON ledger.subledger=sub.id WHERE ledger.isAllocated='Y' AND ledger.date>='$year-01-01' AND ledger.date<='".$date_from."' AND ( accounts.account_type='I' OR accounts.account_type='E') group by ledger.subledger,ledger.account_id order by accounts.account_no)")->execute();
Yii::app()->db->createCommand("INSERT INTO  trail_balance_tbl_ex (select sort_order,opening_bal,account_no,description,0 as subledger_no,NULL as subledger_description,level,account_type,0 AS debit,0 AS credit FROM crm_fin_accounts)")->execute();
$SQL="select * from  trail_balance_tbl_ex  order by sort_order";
$arr_sum_amount1 	= Yii::app()->db->createCommand($SQL)->queryAll();

$tot_debit=0;
$tot_credit=0;
$tot_bal=0;
$printed = array();
foreach($arr_sum_amount1 as $i => $arr_sum_amount)
{
    			$amount = "0.00";
                        $balance="0.00";
                        $credit="0.00";
                        $debit="0.00";
                        
    			if(isset($arr_sum_amount['credit']) && $arr_sum_amount['credit']!="")
                        {
                            
    				$credit+= $arr_sum_amount['credit'];
                                
                               
                        }
                        if(isset($arr_sum_amount['debit']) && $arr_sum_amount['debit']!="")
                        { 
                                $debit+= $arr_sum_amount['debit'];
                                
                        
                        }
    		

                

                if($arr_sum_amount['account_type']=="A" || $arr_sum_amount['account_type']=="E")
                {
                $debit+=$arr_sum_amount['opening_bal'];
                $balance=$debit-$credit;
                }
                else if($arr_sum_amount['account_type']=="L" || $arr_sum_amount['account_type']=="I")
                {
                    if($arr_sum_amount['account_no']==2124 || $arr_sum_amount['account_no']==2127)
                    {
                    $debit+=$arr_sum_amount['opening_bal'];    
                    }
                    else {
                $credit+=$arr_sum_amount['opening_bal'];
                    }
                $balance=$credit-$debit;
                }
              
                switch($arr_sum_amount['level'])
                {
                   case 1:
                       if(!in_array($arr_sum_amount['account_no'], $printed)){
                           if($arr_sum_amount['subledger_no'] > 0){
                                echo '<tr class="l1"><td class="l1"><b>'.$arr_sum_amount['account_no'].'</b></td><td class="level-1 l1"><b>'.$arr_sum_amount['description'].'</b></td></tr>';
                            }else{
                                echo '<tr class="l1"><td class="l1"><b>'.$arr_sum_amount['account_no'].'</b></td><td class="level-1 l1"><b>'.$arr_sum_amount['description'].'</b></td>';
                            }
                       }
                       if($arr_sum_amount['account_type']=="A" || $arr_sum_amount['account_type']=="E"){
                           
                           if($arr_sum_amount['subledger_no'] > 0){
                                 echo '<tr class="l1"><td class="l1">'.$arr_sum_amount['subledger_no'].'</td><td class="level-1 l1">'.$arr_sum_amount['subledger_description'].'</td>';
                                 echo '<td class="txt-right l1">'.Yii::app()->numberFormatter->formatCurrency($arr_sum_amount['debit'],"").'</b></td><td class="txt-right l1">'.Yii::app()->numberFormatter->formatCurrency($arr_sum_amount['credit'],"").'</td></tr>';
                               
                           }else{
                               echo '<td class="txt-right l1"><b>'.Yii::app()->numberFormatter->formatCurrency($arr_sum_amount['credit'],"").'</b></td><td class="txt-right l1">'.Yii::app()->numberFormatter->formatCurrency($arr_sum_amount['credit'],"").'</b></td></tr>';
                               
                           }
                        }
                        else if($arr_sum_amount['account_type']=="L" || $arr_sum_amount['account_type']=="I")
                        {
                             if($arr_sum_amount['subledger_no'] > 0){
                                  echo '<tr class="l1"><td class="l1">'.$arr_sum_amount['subledger_no'].'</td><td class="level-1 l1">'.$arr_sum_amount['subledger_description'].'</td></tr>';
                                  if($balance<0){
                                    $tot_credit+=abs($balance);
                                    echo '<td class="txt-right l1">0.00</b></td><td class="txt-right l1">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td>';
                                  }else if($balance>0){
                                    $tot_debit+=$balance;
                                    echo '<td class="txt-right l1">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</b></td><td class="txt-right l1">0.00</td>';
                                  }
                             }else{
                                if($balance<0)
                                {
                                    $tot_debit+=abs($balance);
                                    echo '<td class="txt-right l1"><b>'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</b></td><td class="txt-right l1"><b>0.00</b></td>';
                                }
                                    else if($balance>0) {
                                     $tot_credit+=$balance;
                                    echo '<td class="txt-right l1"><b>0.00</b></td><td class="txt-right l1"><b>'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</b></td>';
                                }
                             }
                        }  
                            break;
                    case 2:
                       if(!in_array($arr_sum_amount['account_no'], $printed)){
                          echo '<tr class="l2"><td class="l2"><b>'.$arr_sum_amount['account_no'].'</b></td><td class="level-2 l2"><b>'.$arr_sum_amount['description'].'</b></td></tr>';
                       }
                       if($arr_sum_amount['account_type']=="A" || $arr_sum_amount['account_type']=="E"){
                           
                           if($arr_sum_amount['subledger_no'] > 0){
                                 echo '<tr class="l1"><td class="l2">'.$arr_sum_amount['subledger_no'].'</td><td class="level-2 l2">'.$arr_sum_amount['subledger_description'].'</td></tr>';
                                  if($balance<0){
                                      echo '<td class="txt-right l2">0.00</b></td><td class="txt-right l2">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td>';
                                }
                                 else if($balance>0){
                                     echo '<td class="txt-right l2">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</b></td><td class="txt-right l2">0.00</td>';
                                }
                           }else{
                                if($balance<0){
                                    echo '<td class="txt-right l2"><b>0.00</b></td><td class="txt-right l2">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</b></td>';
                                }
                                 else if($balance>0){
                                     echo '<td class="txt-right l2"><b>'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</b></td><td class="txt-right l2"><b>0.00</b></td>';
                                }
                           }
                        }
                        else if($arr_sum_amount['account_type']=="L" || $arr_sum_amount['account_type']=="I")
                        {
                             if($arr_sum_amount['subledger_no'] > 0){
                                  echo '<tr class="l2"><td class="l2">'.$arr_sum_amount['subledger_no'].'</td><td class="level-2 l2">'.$arr_sum_amount['subledger_description'].'</td></tr>';
                                  if($balance<0){
                                    $tot_credit+=abs($balance);
                                    echo '<td class="txt-right l2">0.00</b></td><td class="txt-right l2">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td>';
                                  }else if($balance>0){
                                    $tot_debit+=$balance;
                                    echo '<td class="txt-right l2">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</b></td><td class="txt-right l2">0.00</td>';
                                  }
                             }else{
                                if($balance<0)
                                {
                                    $tot_debit+=abs($balance);
                                    echo '<td class="txt-right l2"><b>'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</b></td><td class="txt-right l2"><b>0.00</b></td>';
                                }
                                    else if($balance>0) {
                                     $tot_credit+=$balance;
                                    echo '<td class="txt-right l2"><b>0.00</b></td><td class="txt-right l2"><b>'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</b></td>';
                                }
                             }
                        }  
                            break;
                    case 3:
                            			
//                                 }
//    			$balance=$debit-$credit;
        
                            if($arr_sum_amount['account_type']=="A" || $arr_sum_amount['account_type']=="E")
                {
//                                if($balance!=0)
//                                 {
                                    if($balance<0)
                                    {
                                $tot_credit+=abs($balance);
                                echo '<tr class="l3"><td class="l3">'.$arr_sum_amount['account_no'].'</td><td class="level-3 l3">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l3">0.00</td><td class="txt-right l3">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td></tr>';
                                    }
                                    else if($balance>0) {
                                $tot_debit+=$balance;
                                echo '<tr class="l3"><td class="l3">'.$arr_sum_amount['account_no'].'</td><td class="level-3 l3">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l3">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</td><td class="txt-right l3">0.00</td></tr>';
                                    }
//                                 }
                        }
                              else if($arr_sum_amount['account_type']=="L" || $arr_sum_amount['account_type']=="I")
                {
//                                  if($balance!=0)
//                                 {
                                      if($balance<0)
                                      {
                                  $tot_debit+=abs($balance);   
                                  echo '<tr class="l3"><td class="l3">'.$arr_sum_amount['account_no'].'</td><td class="level-3 l3">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l3">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td><td class="txt-right l3">0.00</td></tr>';
                                      }
                                      else if($balance>0) {
                                  $tot_credit+=$balance;
                                  echo '<tr class="l3"><td class="l3">'.$arr_sum_amount['account_no'].'</td><td class="level-3 l3">'.$arr_sum_amount['description'].'</td>';
                            echo '<td class="txt-right l3">0.00</td><td class="txt-right l3">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</td></tr>';
                                 }
//                                 }
                       }
                       break;
                    case 4:
                        
                           			
//                                 }
//    			$balance=$debit-$credit;
                            if($arr_sum_amount['account_type']=="A" || $arr_sum_amount['account_type']=="E")
                {
//                                if($balance!=0)
//                                 {
                                    if($balance<0)
                                    {
                                $tot_credit+=abs($balance); 
                                echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l4">0.00</td><td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td></tr>';
                                    }
                                    else if($balance>0) {
                                        $tot_debit+=$balance;
                                        echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</td><td class="txt-right l4">0.00</td></tr>';
                        }
//                                 }
                }
                              else if($arr_sum_amount['account_type']=="L" || $arr_sum_amount['account_type']=="I")
                {
//                                  if($balance!=0)
//                                 {
                                      if($balance<0)
                                      {
                                    $tot_debit+=abs($balance); 
                                    echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                              echo '<td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td><td class="txt-right l4">0.00</td></tr>';
                                      }
                                      else if($balance>0) {
                                           $tot_credit+=$balance;
                                           echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                               echo '<td class="txt-right l4">0.00</td><td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</td></tr>';
                                      }

//                        }
                }
                break;
                    case 5:
                 
                    			
//                                 }
//    			$balance=$debit-$credit;
                            if($arr_sum_amount['account_type']=="A" || $arr_sum_amount['account_type']=="E")
                {
//                                if($balance!=0)
//                                 {
                                    if($balance<0)
                                    {
                                     $tot_credit+=abs($balance); 
                                     echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l4">0.00</td><td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td></tr>';
                                    }
                                    else if($balance>0) {
                                $tot_debit+=$balance;        
                                echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                           echo '<td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</td><td class="txt-right l4">0.00</td></tr>';
                        }
//                                 }
                }
                              else if($arr_sum_amount['account_type']=="L" || $arr_sum_amount['account_type']=="I")
                {
//                                  if($balance!=0)
//                                 {
                                      if($balance<0)
                                      {
                                      $tot_debit+=abs($balance);   
                                      echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                              echo '<td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency(abs($balance),"").'</td><td class="txt-right l4">0.00</td></tr>';
                                      }
                                      else if($balance>0) {
                                     $tot_credit+=$balance;      
                                     echo '<tr  class="l4"><td class="l4">'.$arr_sum_amount['account_no'].'</td><td class="level-4 l4">'.$arr_sum_amount['description'].'</td>';
                               echo '<td class="txt-right l4">0.00</td><td class="txt-right l4">'.Yii::app()->numberFormatter->formatCurrency($balance,"").'</td></tr>';
                                      }

//                        }
                }
                break;
                } 
//

                $printed[] = $arr_sum_amount['account_no'];
}

//                    echo getChildrenAccount1("A",$date_from);
//
//                    echo getChildrenAccount1("L",$date_from);
//
//                    echo getChildrenAccount1("I",$date_from);
//
//                    echo getChildrenAccount1("E",$date_from);
                    
//                    $com=MasCompany::model()->findByPk(1);$sql_exp="select sum(debit)-sum(credit) as balance from crm_fin_general_ledger as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id where ledger.isAllocated='Y' AND accounts.account_type='I' AND ledger.date between '".$com->financial_start."' AND '".$date_from."'";
//$sql_inc="select sum(debit)-sum(credit) as balance from crm_fin_general_ledger as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id where ledger.isAllocated='Y' AND accounts.account_type='E' AND ledger.date between '".$com->financial_start."' AND '".$date_from."'";
//$arr_sum_exp= Yii::app()->db->createCommand($sql_exp)->queryAll();
//$arr_sum_inc= Yii::app()->db->createCommand($sql_inc)->queryAll();
//$current_year_profit_loss=$arr_sum_inc[0]['balance']-$arr_sum_exp[0]['balance'];

//                    if($current_year_profit_loss>0)
//                    {
//                    $dr=$current_year_profit_loss;
//                    $cr='0.00';
//                    }
//                    else {
//                    $cr=$current_year_profit_loss;
//                    $dr='0.00';
//                    }
//                    echo '<tr class="l2"><td class="l2"><b>999C</b></td><td class="level-2 l2"><b>Current Year Profit or Loss</b></td><td class="txt-right l2"><b>'.$dr.'</b></td><td class="txt-right l2"><b>'.$cr.'</b></td></tr>';
//                     $debit_open="SELECT sum(opening_bal) AS open FROM `crm_fin_accounts` where account_type='A' OR account_type='E'";
//                     $arr_debit_open 	= Yii::app()->db->createCommand($debit_open)->queryAll();
//                     $SQL="SELECT sum(debit-credit) AS debit FROM `crm_fin_general_ledger` as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id WHERE ledger.date<='".$date_from."' AND ledger.isAllocated='Y' AND (accounts.account_type='A')" ;
//                     $date_year=date('Y');
//                     $condition="AND ledger.date>='$date_year-01-01'";
//                     $SQL2="SELECT sum(debit-credit) AS debit FROM `crm_fin_general_ledger` as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id WHERE ledger.date<='".$date_from."' $condition AND ledger.isAllocated='Y' AND (accounts.account_type='E')" ;

                   //         $SQL="SELECT SUM(credit) AS credit,SUM(debit) AS debit FROM `crm_fin_general_ledger` where date<'".$date_from."' AND isAllocated='Y'" ;

//        $arr_sum_amount 	= Yii::app()->db->createCommand($SQL)->queryAll();
//        $arr_sum_amount2 	= Yii::app()->db->createCommand($SQL2)->queryAll();

//    			$debit = "0.00";

//
//                        if(isset($arr_sum_amount[0]['debit']) && $arr_sum_amount[0]['debit']!="")
//                        {
//    				$debit = $arr_sum_amount[0]['debit']+$arr_debit_open[0]['open']+$arr_sum_amount2[0]['debit'];
//                        }
    	
//              $credit_open="SELECT sum(opening_bal) AS open FROM `crm_fin_accounts` where account_type='L' OR account_type='I'";
//              $arr_credit_open 	= Yii::app()->db->createCommand($credit_open)->queryAll();
//              $SQL1="SELECT sum(credit-debit) AS credit FROM `crm_fin_general_ledger` as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id WHERE ledger.date<='".$date_from."' AND ledger.isAllocated='Y' AND (accounts.account_type='L')";
//              $SQL3="SELECT sum(credit-debit) AS credit FROM `crm_fin_general_ledger` as ledger left join `crm_fin_accounts` as accounts on ledger.account_id=accounts.id WHERE ledger.date<='".$date_from."' $condition AND ledger.isAllocated='Y' AND (accounts.account_type='I')";

                   //         $SQL="SELECT SUM(credit) AS credit,SUM(debit) AS debit FROM `crm_fin_general_ledger` where date<'".$date_from."' AND isAllocated='Y'" ;

//        $arr_sum_amount1 	= Yii::app()->db->createCommand($SQL1)->queryAll();
//        $arr_sum_amount3 	= Yii::app()->db->createCommand($SQL3)->queryAll();
//
//                        $credit = "0.00";
//
////                        if(isset($arr_sum_amount1[0]['credit']) && $arr_sum_amount1[0]['credit']!="")
//
//    				$credit = $arr_sum_amount1[0]['credit']+$arr_credit_open[0]['open']+$arr_sum_amount3[0]['credit'];
//$debit+=$dr;
//$credit+=$cr;

                    ?>

    <?php

                    echo '<tr><td></td><td></td><td></td><td></td></tr><tr><td></td><td></td><td></td><td></td></tr>
                        <tr><td></td><td><b>Total</b></td><td class="txt-right br-top"><b>'.Yii::app()->numberFormatter->formatCurrency($tot_debit,"").'</b></td><td class="txt-right br-top"><b>'.Yii::app()->numberFormatter->formatCurrency($tot_credit,"").'</b></td></tr></table>';

                        ?>

    </table>

                    </div>


        <!--mpdf
        <htmlpagefooter name="myfooter">
            <div style="border-top: 1px dotted #000000; font-size: 12px; text-align: center; padding-top: 10px; ">
                <div style="text-align:left;width:50%;float:left">Printed on <?php
                  date_default_timezone_set("Asia/Dubai");
                 echo date('d/m/Y')." ".date("h:i:sa"); ?> </div>
                <div style="text-align:right;width:50%;float:left">Page {PAGENO} of {nb} </div>
            </div>
        </htmlpagefooter>
        <sethtmlpagefooter name="myfooter" page="all" value="on" />
        mpdf-->