<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/invfunctions.php');
include ('../inc/repfunctions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
$_SESSION['cuPages']='rep_accbalshet.php';   
$cuPage='rep_accbalshet.php';    
$aid=$_SESSION['uid'];
$uty=$_SESSION['utype'];    
$brid=$_SESSION['abrid'];  
$access=$_SESSION['access'];   
}else{
header('Location:../index.php');
exit;    
}
$mhead='report';
$menuh='Report';
$phead='report';
$page='Balance Sheet';
$ractive='F';
$print='print';
$today = date("Y-m-d");
$dtnow = date("Y-m-d h:i:s", time());
$oavno='REP'.date("dmy", strtotime($today)).'ABHS';
?>
<?php
$sql="SELECT CAST(apdate AS DATE) AS date,brid FROM (SELECT apdate,brid FROM tbl_traledger1) cfs ORDER BY apdate DESC LIMIT 1";

$bgdate=mysqli_query($con,$sql)or die(mysqli_error($con));
$rowbd=mysqli_fetch_array($bgdate);

if(isset($_POST['ibrid'])){
$ibrid=$_POST['ibrid'];       
}else{
$ibrid=$brid;    
}

if(isset($_POST['tfdate'])){
if ($_POST['tfdate']<=$today){
$stdate=date('Y-m-d', strtotime('-0 days',strtotime($today)));	
$endate=date('Y-m-d', strtotime('-0 days',strtotime($today)));
}else{
$stdate=$today;	
$endate=date('Y-m-d', strtotime('-0 days',strtotime($_POST['tfdate'])));
}	
$fdate=$_POST['tfdate'];	
}else{
$fdate=date('Y-m-d', strtotime('-29 days', time()));	
$stdate=$today;
$endate=date('Y-m-d', strtotime('+29 days',strtotime($stdate)));
}
if(isset($_POST['ttdate'])){
$tdate=$_POST['ttdate'];	
}else{
$tdate=$today;	
}
?>
<?php
include('../layout/head.php');
include('../layout/header.php');
include('../layout/side_nav.php');
?>

<div class="content-wrapper">
<?php include('../layout/page_head.php'); ?>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-md-12">
<div class="col-md-3">    
<div class="box box-solid">

<div class="box-body">
<div class="col-md-12">    
<div class="row">    
<div class="roles-menu">   
<ul class="nav">
<?php 
$query=mysqli_query($con,"SELECT * FROM tbl_userreportrole WHERE access='$access'")or die(mysqli_error($con));
$row=mysqli_fetch_array($query);

?>
<?php if($row['aclst']==1){ ?><li <?php if($ractive=='A'){echo 'class="active"';}?>><a href="rep_accledgerst.php"><?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Ledger Statement';}else{echo ' খতিয়ান  বিবরণ ';}?></a></li><?php } ?>
<?php if($row['accst']==1){ ?><li <?php if($ractive=='C'){echo 'class="active"';}?>><a href="rep_acccashst.php"><?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Cash Statement';}else{echo ' নগদ  বিবরণ';}?></a></li><?php } ?>
<?php if($row['acbst']==1){ ?><li <?php if($ractive=='D'){echo 'class="active"';}?>><a href="rep_accbankst.php"> <?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Bank Statement';}else{echo ' ব্যাংকের বিবরণ ';}?></a></li><?php } ?>
<?php if($row['acmst']==1){ ?><li <?php if($ractive=='I'){echo 'class="active"';}?>><a href="rep_accmobist.php"> <?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Mobile Statement';}else{echo ' ব্যাংকের বিবরণ ';}?></a></li><?php } ?>    
<?php if($row['acjh']==1){ ?><li <?php if($ractive=='B'){echo 'class="active"';}?>><a href="rep_accjourhis.php"><?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Journal History';}else{echo ' জার্নালের  বিবরণ ';}?></a></li><?php } ?>
<?php if($row['actb']==1){ ?><li <?php if($ractive=='G'){echo 'class="active"';}?>><a href="rep_accprolos.php"> <?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Profit &amp; Loss';}else{echo ' লাভ ও ক্ষতি  বিবরণ ';}?></a></li><?php } ?>    
<?php if($row['acbs']==1){ ?><li <?php if($ractive=='E'){echo 'class="active"';}?>><a href="rep_acctrialbal.php"><?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Trial Balance';}else{echo ' ট্রায়াল ব্যালেন্স';}?></a></li><?php } ?>
<?php if($row['acpl']==1){ ?><li <?php if($ractive=='F'){echo 'class="active"';}?>><a href="rep_accbalshet.php"> <?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Balance Sheet';}else{echo ' ব্যালেন্স শীট';}?></a></li><?php } ?> 
<?php if($row['aco']==1){ ?><li <?php if($ractive=='H'){echo 'class="active"';}?>><a href="rep_accovrview.php"> <?php if(get_fild_data('tbl_setting','1','sval')==0){echo ' Overview';}else{echo ' সামগ্রিক অবস্থা (ওভারভিউ) ';}?></a></li><?php } ?>   
</ul>
</div>
</div>
<hr>    
<form action="rep_accbalshet.php" onsubmit="return validate()" enctype="multipart/form-data" method="post" accept-charset="utf-8">
<!--From Data-->
<div class="col-md-12">    
<div class="row">
<?php if($uty=='1'){?>   
<div class="form-group" >
<label>Branch</label>
<div class="input-group">
<span class="input-group-addon">BR</span>
<select class="form-control select2" name="ibrid" id="ibrid">
<option value="A">-All Branch-</option>
<option value="0">-Corporate Branch-</option>    
<?php									
$querymt=mysqli_query($con,"SELECT DISTINCT id,name FROM tbl_branch ORDER BY name ASC")or die(mysqli_error($con));
while ($rowmt=mysqli_fetch_array($querymt)){
?>
<?php if($rowmt['id']==$ibrid){?>
<option selected value="<?php echo $rowmt['id'];?>"><?php echo $rowmt['name'];?></option>
<?php }else{ ?>    
<option value="<?php echo $rowmt['id'];?>"><?php echo $rowmt['name'];?></option>
<?php } ?>    
<?php } ?>
</select>
</div>
</div>    
<?php } ?>    
</div>
</div>
<div class="row"> 
<div class="col-md-6">    
<div class="form-group" >
<label>From</label>
<div class="input-group date datetimepicker">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
<input type="text" maxlength="18" class="form-control" name="tfdate" value="<?php if(isset($_POST['tfdate'])){echo $_POST['tfdate']; }else{echo date('Y-m-d', strtotime('-0 days', time()));} ?>" required autocomplete="off" required>
</div>
</div>
</div>
<div class="col-md-6">    
<div class="form-group" >
<label>To</label>
<div class="input-group date datetimepicker">
<span class="input-group-addon"><span class="fa fa-calendar"></span></span>
<input type="text" maxlength="18" class="form-control" name="ttdate" value="<?php if(isset($_POST['ttdate'])){echo $_POST['ttdate']; }else{echo $today;} ?>" required autocomplete="off" required>
</div>
</div>
</div>    
</div>    
<!--End From Data-->    
<div class="clearfix" ></div>
<div class="col-md-12 nopadding widgets_area"></div>    
<div class="row"style="margin-top: 15px" >
<div class="col-md-4"></div>
<div class="col-md-8 text-right" >
<input type="submit" name="filter_submit" id="submit" class="btn btn-flat bg-purple btn-sm " value="Submit"/> <a href="axe_report.php" class="btn btn-flat bg-gray  ">Close</a>
</div> 
</div>     
</form>    
</div>
</div>
</div>  
</div>
<div class="col-md-9">
<div class="row">    
<div class="side-head"> 
<div class="col-md-12">    
<div class="col-md-4 text-left">
<button class="btn btn-flat bg-teal" id="print"><i class="fa fa-print"></i></button> 
<button class="btn btn-flat bg-blue"><i class="fa fa-envelope-o"></i></button> 
<button class="btn btn-flat bg-gray"><i class="fa fa-file-pdf-o"></i></button>     
</div>
<div class="col-md-7 text-center">
<select name="Page_resolution" id="resolution" onchange="setPrinterConfig()" style="width: 205px;height: 28px;border: 1px solid red;">
<option value="A4" selected="selected">A4 [210mm × 297mm]</option>   
<option value="A5">A5 [148mm × 210mm]</option>
<option value="Letter">US Letter [216mm × 279mm]</option>
<option value="Legal">US Legal [216mm × 356mm]</option>
</select>
<select name="Page_size" id="rotate" onchange="setPrinterConfig()" style="width: 120px;height: 28px;border: 1px solid red;">
<option value="portrait">Portrait</option>
<option value="landscape">Landscape</option>
</select>    
</div>    
<div class="col-md-1 text-right">

</div>
</div>
</div>    
</div>
<div class="row">
<div class="invhold scrol-y" id="invhold">
<div class="printableArea">
    
<style>
	  html, body {
        height: 100%;
      }
      body {
        background: #dfdfdf;
      }
      .fixed-top {
        position: fixed;
        top: 0;
        right: 0;
        left: 0;
        padding: 0 20px;
        background: white;
        margin: 0;
        z-index: 10;
      }
    .font-weight-bold {
    font-weight: 700 !important;
}
</style>
<style>

  body{
    -webkit-print-color-adjust:exact;
    print-color-adjust:exact;
  }
  
@page {
size: 21cm 29.7cm
}
   @page {
    margin: 0;
    padding: 0;
    margin-left: 0px;
    margin-right: 0px;
    margin-top: 0px;
    margin-bottom: 0px;
  }
  
 #wrap_invoice {
    background: white;
    padding: 0.5cm;
    margin: 2mm auto;
    border: 1px #D3D3D3 solid;
    border-radius: 5px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
  }
  
  #wrap_invoice,
  .text-color{
    color: #555;
  }
  #wrap_invoice .page{
    background: white;
    font-family: sans-serif;
    page-break-after: always;
  }
  #wrap_invoice .page:last-child {
    page-break-after: avoid;
  }
  #wrap_invoice h3{
    font-size: 24px;
    font-weight: bold;
    color: #3785B1;
  }
  #wrap_invoice h4{
    font-size: 15px;
    font-weight: bold;
    color: #3785B1;
  }
  #wrap_invoice p{
    font-size: 12px;
  }    
    
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
    float: left;
}
.col-xs-1, .col-xs-2, .col-xs-3, .col-xs-4, .col-xs-5, .col-xs-6, .col-xs-7, .col-xs-8, .col-xs-9, .col-xs-10, .col-xs-11, .col-xs-12 {
    position: relative;
    min-height: 1px;
    padding-left: 0.9375rem;
    padding-right: 0.9375rem;	
}  

.col-xs-pull-0 {
  right: auto; }

.col-xs-pull-1 {
  right: 8.33333%; }

.col-xs-pull-2 {
  right: 16.66667%; }

.col-xs-pull-3 {
  right: 25%; }

.col-xs-pull-4 {
  right: 33.33333%; }

.col-xs-pull-5 {
  right: 41.66667%; }

.col-xs-pull-6 {
  right: 50%; }

.col-xs-pull-7 {
  right: 58.33333%; }

.col-xs-pull-8 {
  right: 66.66667%; }

.col-xs-pull-9 {
  right: 75%; }

.col-xs-pull-10 {
  right: 83.33333%; }

.col-xs-pull-11 {
  right: 91.66667%; }

.col-xs-pull-12 {
  right: 100%; }

.col-xs-push-0 {
  left: auto; }

.col-xs-push-1 {
  left: 8.33333%; }

.col-xs-push-2 {
  left: 16.66667%; }

.col-xs-push-3 {
  left: 25%; }

.col-xs-push-4 {
  left: 33.33333%; }

.col-xs-push-5 {
  left: 41.66667%; }

.col-xs-push-6 {
  left: 50%; }

.col-xs-push-7 {
  left: 58.33333%; }

.col-xs-push-8 {
  left: 66.66667%; }

.col-xs-push-9 {
  left: 75%; }

.col-xs-push-10 {
  left: 83.33333%; }

.col-xs-push-11 {
  left: 91.66667%; }

.col-xs-push-12 {
  left: 100%; }

.col-xs-offset-0 {
  margin-left: 0%; }

.col-xs-offset-1 {
  margin-left: 8.33333%; }

.col-xs-offset-2 {
  margin-left: 16.66667%; }

.col-xs-offset-3 {
  margin-left: 25%; }

.col-xs-offset-4 {
  margin-left: 33.33333%; }

.col-xs-offset-5 {
  margin-left: 41.66667%; }

.col-xs-offset-6 {
  margin-left: 50%; }

.col-xs-offset-7 {
  margin-left: 58.33333%; }

.col-xs-offset-8 {
  margin-left: 66.66667%; }

.col-xs-offset-9 {
  margin-left: 75%; }

.col-xs-offset-10 {
  margin-left: 83.33333%; }

.col-xs-offset-11 {
  margin-left: 91.66667%; }

.col-xs-offset-12 {
  margin-left: 100%; }
  
.row.row-equal [class*="col-"] {
    padding-right: 0.46875rem;
    padding-left: 0.46875rem;
}  
.row.row-equal {
    padding-right: 0.46875rem;
    padding-left: 0.46875rem;
    margin-right: -0.9375rem;
    margin-left: -0.9375rem;
}  
  .invoice_status {
    display: block;
    width: 250px;
    background: gray;
    text-align: center;
    color: white;
    text-transform: uppercase;
    padding: 5px 10px;
    font-weight: bold;
    transform: rotate(45deg);
    -webkit-transform: rotate(45deg);
    -moz-transform: rotate(45deg);
    position: absolute;
    right: -70px;
    top: 40px;
	}
  
  .table_invoice{
    border-radius: 0px;
    font-size: 12px;
    width: 100% !important;
  }
  
  .table_invoice thead th{
    vertical-align: middle;
    text-align:center;
    padding: 5px 0;
  }
  
  .table_invoice th, .table_invoice td {
    padding: 2px 8px;
    border-radius: 0px !important;
    width: inherit !important;
  }
  .table_invoice tfoot{
    display: table-footer-group;
  }
  
  .A5 .table_invoice *{
    font-size: 10px !important;
  }
  
  .A5 .table_invoice th, .A5 .table_invoice td {
    line-height: 14px;
    padding: 3px 0;
  }
  
  .A5 p{
    font-size: 10px !important;
    margin: 0;
  }
  
  #wrap_invoice.A5 .inv{
    font-size: 10px !important;
  }
  .A5 .invoice-logo-center,
  .A5 .invoice-logo{
    height: 80px;
    line-height: 80px;
  }
  #wrap_invoice.A5 .A4_info{
    display: none;
  }
  #wrap_invoice hr{
    display:block;
    border-top-color: #dfdfdf;
    margin:10px 0;
  }
  #wrap_invoice .inv{
    vertical-align: middle;
    font-size: 12px;
  }
  #wrap_invoice .inv.col{
    line-height: 25px;
    margin: 10px 0 0 0;
    font-weight: normal;
  }
  #wrap_invoice .inv.col b{
    color: #363636;
  }
  #wrap_invoice .page-title{
    font-size: 18px;
    font-weight: bold;
    color: #3785B1 !important;
    margin: 10px auto 10px;
    line-height: 24px;
  }
  #wrap_invoice .pagging{
    position: absolute;
    right: 10px;
    bottom: 10px;
    padding: 0 10px;
    font-size: 9px;
    font-weight: bold;
  }

  #wrap_invoice,
  #wrap_invoice.portrait{
    width: 21cm;
    max-width: 21cm;
    min-height: 29.6cm;
  }
  #wrap_invoice.landscape{
    width: 29.7cm;
    max-width: 29.7cm;
    min-height: 20.9cm;
  }
  #wrap_invoice.A5,
  #wrap_invoice.A5.portrait{
    width: 14.85cm;
    max-width: 14.85cm;
    min-height: 20.9cm;
  }
  #wrap_invoice.A5.landscape{
    width: 21cm;
    max-width: 21cm;
    min-height: 14.75cm;
  }
  #wrap_invoice.Letter,
  #wrap_invoice.Letter.portrait{
    width: 21.6cm;
    max-width: 21.6cm;
    min-height: 27.8cm;
  }
  #wrap_invoice.Letter.landscape{
    width: 27.9cm;
    max-width: 27.9cm;
    min-height: 21.5cm;
  }
  #wrap_invoice.Legal,
  #wrap_invoice.Legal.portrait{
    width: 21.6cm;
    max-width: 21.6cm;
    min-height: 35.5cm;
  }
  #wrap_invoice.Legal.landscape{
    width: 35.6cm;
    max-width: 35.6cm;
    min-height: 21.5cm;
  }
 
  #wrap_invoice .text-bold{
    font-weight: bold;
  }
  
  #wrap_invoice .float-none{
    float: none !important;
  }
  
  #wrap_invoice .float-left{
    float: left !important;
  }
  
  #wrap_invoice .float-right{
    float: right !important;
  }
  
  #wrap_invoice .bordered{
    border: 1px solid #E0E0E0;
  }
  
  #wrap_invoice .overflow-hidden{
    overflow: hidden;
  }
  
  #wrap_invoice input.trans {
    width: inherit;
    margin: 0px;
    font-size: inherit;
    border: none;
    background: none;
    text-align: center;
    padding: 2px 8px;
  }
  
  .invoice_header .invoice-logo{
    height: 120px;
    line-height: 120px;
    text-align: center;
  }
  
  .invoice_header .invoice-logo-center{
    height: 90px;
    line-height: 90px;
    text-align: center;
  }
  
  .invoice_header .invoice-logo img{
    margin: auto !important;
  }
  
  .invoice_header .invoice-header-invoice{
    padding:10px;
    font-size:12px;
	text-align:right;
    min-height: 120px;
  }
  
  .invoice_header .model1 .invoice-header-invoice{
    border-left: 3px solid #dfdfdf;
  }
  
  .invoice_header .invoice-header-info{
    padding:10px;
    font-size:12px;
    min-height: 120px;
  }
 
  .invoice_header .model1 .invoice-logo{
    min-width: 120px;
    max-width: 240px;
  }
  
  .invoice_header .model1 .invoice-header-info{
    border-left: 3px solid #dfdfdf;
  }
  
  .invoice_header .model2 .invoice-header-info{
    border-right: 3px solid #dfdfdf;
  }
  
  .invoice_header .model2 .invoice-logo{
    text-align: center;
  }
  
  .invoice_header .model3{
    text-align: center;
  }
  
  .invoice_header .model3 .invoice-header-info{
    height: inherit;
  }
  
  .A5.portrait .invoice-header-info{
   max-width:310px;	
  }
  
  .invoice_header .model3 .invoice-logo{
    height: 60px;
    width: inherit;
    line-height: 60px;
    margin: 10px 0 0 0;
  }
  
  .invoice_header .model4 .invoice-logo,
  .invoice_header .model3 .invoice-logo{
    max-width: inherit;
  }
  
  .invoice_header .model3 .invoice-logo img{
    height: inherit;
  }
  
  .invoice_header .model4{
    text-align: center;
  }
  
  .invoice_header .model4 .invoice-logo{
    height: 60px;
    width: inherit;
    line-height: 60px;
    margin: 30px 0;
  }
  
  .invoice_header .model4 .invoice-logo img{
    height: inherit;
  }
  
  .invoice_header{
    background: white;
    color: black;
  }
  
  .invoice_footer{
    text-align: center;
    font-size: 10px;
    position: absolute;
    left: 0;
    right: 0;
    bottom: 20px;
  }



  table {
    background-color: transparent;
  }
  
  th {
    text-align: left;
  }
  
  .table_invoice {
    width: 100%;
    max-width: 100%;
    margin-bottom: 20px;
  }
  
  .table_invoice > thead > tr > th,
  .table_invoice > tbody > tr > th,
  .table_invoice > tfoot > tr > th,
  .table_invoice > thead > tr > td,
  .table_invoice > tbody > tr > td,
  .table_invoice > tfoot > tr > td {
    padding: 8px;
    line-height: 1.42857143;
    vertical-align: center;
    border-top: 1px solid #dddddd;
  }
  
  .table_invoice > thead > tr > th {
    vertical-align: middle;
    border-bottom: 2px solid #dddddd;
  }
  .table_invoice > tfoot > tr > th,
  .table_invoice > tfoot > tr > td{
    border-top: 2px solid #aaaaaa;
  }
  .table_invoice > caption + thead > tr:first-child > th,
  .table_invoice > colgroup + thead > tr:first-child > th,
  .table_invoice > thead:first-child > tr:first-child > th,
  .table_invoice > caption + thead > tr:first-child > td,
  .table_invoice > colgroup + thead > tr:first-child > td,
  .table_invoice > thead:first-child > tr:first-child > td {
    border-top: 0;
  }
  .table_invoice > tbody + tbody {
    border-top: 2px solid #dddddd;
  }
  .table_invoice .table_invoice {
    background-color: #ffffff;
  }
  .table_invoice-condensed > thead > tr > th,
  .table_invoice-condensed > tbody > tr > th,
  .table_invoice-condensed > tfoot > tr > th,
  .table_invoice-condensed > thead > tr > td,
  .table_invoice-condensed > tbody > tr > td,
  .table_invoice-condensed > tfoot > tr > td {
    padding: 0 5px;
  }
  .table_invoice-bordered {
    border: 1px solid #dddddd;
  }
  .table_invoice-bordered > thead > tr > th,
  .table_invoice-bordered > tbody > tr > th,
  .table_invoice-bordered > tfoot > tr > th,
  .table_invoice-bordered > thead > tr > td,
  .table_invoice-bordered > tbody > tr > td,
  .table_invoice-bordered > tfoot > tr > td {
    border: 1px solid #dddddd;
  }
  .table_invoice-bordered > thead > tr > th,
  .table_invoice-bordered > thead > tr > td {
    border-bottom-width: 2px;
  }
  .table_invoice-striped > tbody > tr:nth-child(odd) > td,
  .table_invoice-striped > tbody > tr:nth-child(odd) > th {
    background-color: #f9f9f9;
  }
  table col[class*="col-"] {
    position: static;
    float: none;
    display: table-column;
  }
  table td[class*="col-"],
  table th[class*="col-"] {
    position: static;
    float: none;
    display: table-cell;
  }
  .table_invoice > thead > tr > td.active,
  .table_invoice > tbody > tr > td.active,
  .table_invoice > tfoot > tr > td.active,
  .table_invoice > thead > tr > th.active,
  .table_invoice > tbody > tr > th.active,
  .table_invoice > tfoot > tr > th.active,
  .table_invoice > thead > tr.active > td,
  .table_invoice > tbody > tr.active > td,
  .table_invoice > tfoot > tr.active > td,
  .table_invoice > thead > tr.active > th,
  .table_invoice > tbody > tr.active > th,
  .table_invoice > tfoot > tr.active > th {
    background-color: #f5f5f5;
  }
  .table_invoice > thead > tr > td.success,
  .table_invoice > tbody > tr > td.success,
  .table_invoice > tfoot > tr > td.success,
  .table_invoice > thead > tr > th.success,
  .table_invoice > tbody > tr > th.success,
  .table_invoice > tfoot > tr > th.success,
  .table_invoice > thead > tr.success > td,
  .table_invoice > tbody > tr.success > td,
  .table_invoice > tfoot > tr.success > td,
  .table_invoice > thead > tr.success > th,
  .table_invoice > tbody > tr.success > th,
  .table_invoice > tfoot > tr.success > th {
    background-color: #dff0d8;
  }
  .table_invoice > thead > tr > td.info,
  .table_invoice > tbody > tr > td.info,
  .table_invoice > tfoot > tr > td.info,
  .table_invoice > thead > tr > th.info,
  .table_invoice > tbody > tr > th.info,
  .table_invoice > tfoot > tr > th.info,
  .table_invoice > thead > tr.info > td,
  .table_invoice > tbody > tr.info > td,
  .table_invoice > tfoot > tr.info > td,
  .table_invoice > thead > tr.info > th,
  .table_invoice > tbody > tr.info > th,
  .table_invoice > tfoot > tr.info > th {
    background-color: #d9edf7;
  }
  .table_invoice > thead > tr > td.warning,
  .table_invoice > tbody > tr > td.warning,
  .table_invoice > tfoot > tr > td.warning,
  .table_invoice > thead > tr > th.warning,
  .table_invoice > tbody > tr > th.warning,
  .table_invoice > tfoot > tr > th.warning,
  .table_invoice > thead > tr.warning > td,
  .table_invoice > tbody > tr.warning > td,
  .table_invoice > tfoot > tr.warning > td,
  .table_invoice > thead > tr.warning > th,
  .table_invoice > tbody > tr.warning > th,
  .table_invoice > tfoot > tr.warning > th {
    background-color: #fcf8e3;
  }
  .table_invoice > thead > tr > td.danger,
  .table_invoice > tbody > tr > td.danger,
  .table_invoice > tfoot > tr > td.danger,
  .table_invoice > thead > tr > th.danger,
  .table_invoice > tbody > tr > th.danger,
  .table_invoice > tfoot > tr > th.danger,
  .table_invoice > thead > tr.danger > td,
  .table_invoice > tbody > tr.danger > td,
  .table_invoice > tfoot > tr.danger > td,
  .table_invoice > thead > tr.danger > th,
  .table_invoice > tbody > tr.danger > th,
  .table_invoice > tfoot > tr.danger > th {
    background-color: #f2dede;
  }
  .text-danger {
    color: #DD0703 !important;
  }
  a.text-danger:hover {
    color: #843534;
  }

  .vertical-middle{
    vertical-align: middle;
  }
  .control-label{
    width: 27%;
    display: inline-block;
    line-height: 20px;
    font-weight: bold;
    vertical-align: top;
  }
  .control-p{
    width: 65%;
    display: inline-block;
    line-height: 20px;
  }
  .col-sm-6 > .control-label{
    width: 42%;
  }
  .col-sm-6 > .control-p{
    width: 50%;
  }
  .column-border {
    border-right: 1px solid #ddd;
  }
  text[text-anchor="end"] {
    display:none;
  }
	
.col-xs-offset-8 {
    margin-left: 66.66667%;
}	
.demo_invoice{
  color: rgba(0,0,0,0.2);
  position: absolute;
  font-size: 9rem;
  top: 25%;
  left: 15%;
  transform: rotate(-45deg);
}

.clearfix::after {
    content: "";
    display: table;
    clear: both;
}

.text-md-center {
    text-align: center !important;
}
.text-md-left {
    text-align: left !important;
}
.text-md-right {
    text-align: right !important;
}
			
@media print {
    @page{
	  size: A4;	
      margin: 0.5cm;
      margin: 0cm;
    }
		
    #wrap_invoice {
      margin: 0;
      padding: 0.5cm;
      border: initial;
      border-radius: initial;
      box-shadow: initial;
      overflow: hidden;
      transform: inherit !important;
      -webkit-transform: inherit !important;
      transform-origin: inherit !important;
      -webkit-transform-origin: inherit !important;
    }
	
    #wrap_invoice {
      page-break-after: always;
    }
	
    #wrap_invoice:last-child {
      page-break-after: avoid;
    }
	
    #not-printed{
      display: none;
    }
  }
</style>
<div id="css_script">    
<style type="text/css" id="pageInit">@page{size: 21cm 29.7cm}</style>
<style type="text/css">
        #wrap_invoice.page {
            font-family: Arial, Helvetica, sans-serif;
            background-color: #ffffff;
            padding: 0.5cm 0.5cm 0.5cm 0.5cm;
            z-index: 1;
        }

        #wrap_invoice::after {
            content: "";
            display: block;
            background-repeat: no-repeat;
            /*background-image: url(http://localhost/sis/storage/logo14.png);*/
            background-position: center center;
            background-size: initial;
            opacity: 0.4;
            top: 0;
            left: 0;
            bottom: 0;
            right: 0;
            position: absolute;
            z-index: -1;
        }

        #wrap_invoice h3 {
            color: #009be1;
        }

        #wrap_invoice h4 {
            color: #009be1;
        }

        .invoice_header .invoice-logo img {
            height: 100% !important;
            width: auto !important;
            max-width: 100%;
        }

		.A5 .invoice-logo img {
            height: auto !important;
			width: 100% !important;
			max-height: 100%;
        }
	
        #wrap_invoice,
        #wrap_invoice p,
        #wrap_invoice .text-color,
        #wrap_invoice .inv.col b,
        #wrap_invoice .table_invoice {
            font-size: 12px;
            color: #2e2e2e;
        }

        #wrap_invoice .table_invoice thead th {
            border: none;
			border-top: 1px solid red;
			border-left: 1px solid #dddddd;
			border-bottom: 1px solid black;
			line-height: 24px;
			height: 24px;
        }

        #wrap_invoice .table_invoice td {
            line-height: 23px;
            height: 23px;
        }

        #wrap_invoice .page-title {
            color: #009be1;
            text-align: center;
        }

        #wrap_invoice .invoice_header {
            background: #ffffff;
            color: #000000 !important;
            margin: -0.5cm -0.5cm 0 -0.5cm;
            padding: 0.5cm 0.5cm 0 0.5cm;
        }

        #wrap_invoice .invoice_header * {
            color: #000000 !important;
            margin: 0;
        }

        #wrap_invoice .invoice_footer,
        #wrap_invoice .invoice_footer p,
        #wrap_invoice .invoice_footer .pagging {
            background: #ffffff;
            color: #2e2e2e;
        }
    </style>
</div> 

<div class="wrapper" style="background: none;">    
<div id="wrap_invoice" class="page A4 portrait">
<div class="invoice_header etat_header">
<div class="row model1">
<div class="col-xs-3 invoice-logo">
<img src="../img/<?php if(empty(get_cominfo('1','logo'))){echo "no_logo.png";}else{echo get_cominfo('1','logo');}?>" alt="<?php echo get_cominfo('1','name');?>" style="vertical-align:middle; width: 100%;">
</div>
<div class="col-xs-5 invoice-header-info" id="adheight">
<h4><?php echo get_cominfo('1','name');?></h4>
<?php echo get_cominfo('1','',$brid);?>
</div>
<div class="col-xs-4 invoice-header-invoice" id="inheight" style="height: 140px;">
<?php echo "<img src = '../inc/barcode.php?text=".$oavno."&codetype=code128&orientation=horizontal&size=30&print=false' style='margin-right: -10px;padding-bottom: 5px;'/>"; ?>
<?php echo "<br><strong>Ref N°:</strong> ".$oavno;?>
<?php echo "<br><strong>Date:</strong> ".date("d M Y", strtotime($today));?>  
</div>
</div>
<hr>
<div class="clearfix"></div>
</div>
<center>
<h3 class="page-title">BALANCE SHEET</h3>
</center>    
<div class="etat_content">
<div class="page_split">
<hr>    
<div class="row row-equal">
<div class="col-xs-4 text-left">
<h3 class="inv col"><b>Start Date: </b><?php echo date("d M Y", strtotime($fdate));?></h3>
</div>
<div class="col-xs-4 text-center">

</div>    
<div class="col-xs-4 text-right">
<h3 class="inv col"><b>End Date: </b><?php echo date("d M Y", strtotime($tdate));?></h3>
</div>
</div>    
<hr>
<br> 
<table class="table table-bordered table-hover treetable" id="itemdata">
<tbody>
<tr>
<td width="50%" class="bg-gray"><b>ASSETS</b></td>
<td width="16.16%" class="bg-gray"><b>Opening</b></td>
<td width="16.16%" class="bg-gray"><b>During Time</b></td>
<td width="16.16%" class="bg-gray"><b>Closing</b></td>    
</tr>
<?php     
$sql="SELECT DISTINCT grid,groups FROM tbl_ledger WHERE clsid='1' ORDER BY grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gopval=(get_ledgervalnew($rowg['grid'],'D','O','G',$fdate)-get_ledgervalnew($rowg['grid'],'C','O','G',$fdate));
$gdebit=get_ledgervalnew($rowg['grid'],'D','D','G',$fdate,$tdate);
$gcredit=get_ledgervalnew($rowg['grid'],'C','D','G',$fdate,$tdate);
$gnet=($gdebit-$gcredit);
$gcval=($gopval+$gnet);    
?>
<?php if(ABS($gcval)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'];?>" class="branch collapsed">
<td><b>&nbsp;&nbsp;<?php echo $rowg['groups'];?></b></td>
<td style="text-align:right;"><?php echo number_format($gopval,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcval,2);?></td>
</tr>
<?php } ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup FROM tbl_ledger WHERE clsid='1' AND grid='".$rowg['grid']."' ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sopval=(get_ledgervalnew($rowsg['sgrid'],'D','O','S',$fdate)-get_ledgervalnew($rowsg['sgrid'],'C','O','S',$fdate));
$sdebit=get_ledgervalnew($rowsg['sgrid'],'D','D','S',$fdate,$tdate);
$scredit=get_ledgervalnew($rowsg['sgrid'],'C','D','S',$fdate,$tdate);
$snet=($sdebit-$scredit);
$scval=($sopval+$snet);  
    
?>
<?php if(ABS($scval)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" >
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sopval,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>
<td style="text-align:right;"><?php echo number_format($scval,2);?></td>  
</tr>
<?php } ?>   
<?php     
$sql="SELECT id,code,ledger FROM tbl_ledger WHERE clsid='1' AND sgrid='".$rowsg['sgrid']."' ORDER BY id ASC";
$resultl=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowl=mysqli_fetch_array($resultl)){
$lopval=(get_ledgervalnew($rowl['id'],'D','O',$fdate)-get_ledgervalnew($rowl['id'],'C','O',$fdate));
$ldebit=get_ledgervalnew($rowl['id'],'D','D',$fdate,$tdate);
$lcredit=get_ledgervalnew($rowl['id'],'C','D',$fdate,$tdate);
$lnet=($ldebit-$lcredit);
$lcval=($lopval+$lnet);    
?>
<?php if(ABS($lcval)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" >
<td style="padding-left:30px;"><?php echo $rowl['code'];?>: <?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($lopval,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>
<td class="text-right"><?php echo number_format($lcval,2);?></td>    
</tr>
<?php } ?>   
<?php }} ?>
<?php if(ABS($gcval)>0){?>     
<tr>
<td style="text-align: right;padding-right:20px;"><strong>Total <?php echo $rowg['groups'];?></strong></td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gopval,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcval,2);?></b>
</td>    
</tr>
<?php } ?>    
<?php } ?>
<?php 
$acopval=(get_ledgervalnew('1','D','O','C',$fdate)-get_ledgervalnew('1','C','O','C',$fdate));
$acdebit=get_ledgervalnew('1','D','D','C',$fdate,$tdate);
$accredit=get_ledgervalnew('1','C','D','C',$fdate,$tdate);
$acnet=($acdebit-$accredit);
$accval=($acopval+$acnet);    
?>
<?php if(ABS($accval)>0){?>    
<tr style="border-bottom:none;border-top:none;">
    <td colspan="4"></td>
</tr>     
<tr>    
<td ><b>&nbsp;Total Assets</b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(ABS($acopval),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(ABS($acnet),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(ABS($accval),2);?></b></td>    
</tr>
<?php } ?>
</tbody>    
</table>
<!--/ASSETS-->
<!--LIABILITIES--> 
<table class="table table-bordered table-hover treetable" id='itemdata1'>
<tbody>
<tr>
<td width="50%" class="bg-gray"><b>LIABILITIES &amp; OWNER'S EQUITY</b></td>
<td width="16.16%" class="bg-gray"><b>Opening</b></td>
<td width="16.16%" class="bg-gray"><b>During Time</b></td>
<td width="16.16%" class="bg-gray"><b>Closing</b></td>    
</tr>
<?php     
$sql="SELECT DISTINCT grid,groups FROM tbl_ledger WHERE clsid='2'  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gopval=(get_ledgervalnew($rowg['grid'],'C','O','G',$fdate)-get_ledgervalnew($rowg['grid'],'D','O','G',$fdate));
$gdebit=get_ledgervalnew($rowg['grid'],'D','D','G',$fdate,$tdate);
$gcredit=get_ledgervalnew($rowg['grid'],'C','D','G',$fdate,$tdate);
$gnet=($gcredit-$gdebit);
$gcval=($gopval+$gnet);    
?>
<?php if(ABS($gcval)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'];?>" class="branch collapsed">
<td><b>&nbsp;&nbsp;<?php echo $rowg['groups'];?></b></td>
<td style="text-align:right;"><?php echo number_format($gopval,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcval,2);?></td>
</tr>
<?php } ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup FROM tbl_ledger WHERE clsid='2' AND grid='".$rowg['grid']."' ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sopval=(get_ledgervalnew($rowsg['sgrid'],'C','O','S',$fdate)-get_ledgervalnew($rowsg['sgrid'],'D','O','S',$fdate));
$sdebit=get_ledgervalnew($rowsg['sgrid'],'D','D','S',$fdate,$tdate);
$scredit=get_ledgervalnew($rowsg['sgrid'],'C','D','S',$fdate,$tdate);
$snet=($scredit-$sdebit);
$scval=($sopval+$snet);     
?>
<?php if(ABS($scval)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" >
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sopval,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>
<td style="text-align:right;"><?php echo number_format($scval,2);?></td>  
</tr>
<?php } ?>   
<?php     
$sql="SELECT id,code,ledger FROM tbl_ledger WHERE clsid='2' AND grid='".$rowg['grid']."' AND sgrid='".$rowsg['sgrid']."' ORDER BY id ASC";
$resultl=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowl=mysqli_fetch_array($resultl)){
$lopval=(get_ledgervalnew($rowl['id'],'C','O',$fdate)-get_ledgervalnew($rowl['id'],'D','O',$fdate));
$ldebit=get_ledgervalnew($rowl['id'],'D','D',$fdate,$tdate);
$lcredit=get_ledgervalnew($rowl['id'],'C','D',$fdate,$tdate);
$lnet=($lcredit-$ldebit);
$lcval=($lopval+$lnet);    
?>
<?php if(ABS($lcval)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" >
<td style="padding-left:30px;"><?php echo $rowl['code'];?>: <?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($lopval,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>
<td class="text-right"><?php echo number_format($lcval,2);?></td>   
</tr>
<?php } ?>   
<?php }} ?>
<?php if(ABS($gcval)>0){?>     
<tr>
<td style="text-align: right;padding-right:20px;"><strong>Total <?php echo $rowg['groups'];?></strong></td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gopval,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcval,2);?></b>
</td>    
</tr>
<?php } ?>    
<?php } ?>

</tbody>    
</table>
<!--/LIABILITIES-->
<!--OWNER'S EQUITY-->   
<table class="table table-bordered table-hover treetable" id="itemdata2">
<tbody> 
<?php     
$sql="SELECT DISTINCT grid,groups FROM tbl_ledger WHERE clsid='3'  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gopval=(get_ledgervalnew($rowg['grid'],'C','O','G',$fdate)-get_ledgervalnew($rowg['grid'],'D','O','G',$fdate));
$gdebit=get_ledgervalnew($rowg['grid'],'D','D','G',$fdate,$tdate);
$gcredit=get_ledgervalnew($rowg['grid'],'C','D','G',$fdate,$tdate);
$gnet=($gcredit-$gdebit);
$gcval=($gopval+$gnet);    
?>
<?php if(ABS($gcval)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'];?>" class="branch collapsed">
<td><b>&nbsp;&nbsp;<?php echo $rowg['groups'];?></b></td>
<td style="text-align:right;"><?php echo number_format($gopval,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcval,2);?></td>
</tr>
<?php } ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup FROM tbl_ledger WHERE clsid='3' AND grid='".$rowg['grid']."' ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sopval=(get_ledgervalnew($rowsg['sgrid'],'C','O','S',$fdate)-get_ledgervalnew($rowsg['sgrid'],'D','O','S',$fdate));
$sdebit=get_ledgervalnew($rowsg['sgrid'],'D','D','S',$fdate,$tdate);
$scredit=get_ledgervalnew($rowsg['sgrid'],'C','D','S',$fdate,$tdate);
$snet=($scredit-$sdebit);
$scval=($sopval+$snet);     
?>
<?php if(ABS($scval)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" >
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sopval,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>
<td style="text-align:right;"><?php echo number_format($scval,2);?></td>  
</tr>
<?php } ?>   
<?php     
$sql="SELECT id,code,ledger FROM tbl_ledger WHERE clsid='3' AND sgrid='".$rowsg['sgrid']."' ORDER BY id ASC";
$resultl=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowl=mysqli_fetch_array($resultl)){
$lopval=(get_ledgervalnew($rowl['id'],'C','O',$fdate)-get_ledgervalnew($rowl['id'],'D','O',$fdate));
$ldebit=get_ledgervalnew($rowl['id'],'D','D',$fdate,$tdate);
$lcredit=get_ledgervalnew($rowl['id'],'C','D',$fdate,$tdate);
$lnet=($lcredit-$ldebit);
$lcval=($lopval+$lnet);    
?>
<?php if(ABS($lcval)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" >
<td style="padding-left:30px;"><?php echo $rowl['code'];?>: <?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($lopval,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>
<td class="text-right"><?php echo number_format($lcval,2);?></td>    
</tr>
<?php } ?>   
<?php }} ?>
<?php if(ABS($gcval)>0){?>     
<tr>
<td style="text-align: right;padding-right:20px;"><strong>Total <?php echo $rowg['groups'];?></strong></td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gopval,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcval,2);?></b>
</td>    
</tr>
<?php } ?>    
<?php } ?>    
<!--/OWNER'S EQUITY-->   
</tbody>    
</table>
<table class="table table-bordered   table-hover">
<tbody> 
<?php 
$rcopval=(get_ledgervalnew('5','C','O','C',$fdate)-get_ledgervalnew('5','D','O','C',$fdate));
$rcdebit=get_ledgervalnew('5','D','D','C',$fdate,$tdate);
$rccredit=get_ledgervalnew('5','C','D','C',$fdate,$tdate);
$rcnet=($rccredit-$rcdebit);
$rccval=($rcopval+$rcnet);    

$ecopval=(get_ledgervalnew('4','D','O','C',$fdate)-get_ledgervalnew('4','C','O','C',$fdate));
$ecdebit=get_ledgervalnew('4','D','D','C',$fdate,$tdate);
$eccredit=get_ledgervalnew('4','C','D','C',$fdate,$tdate);
$ecnet=($ecdebit-$eccredit);
$eccval=($ecopval+$ecnet);

$reopval=($rcopval-$ecopval);
$reduval=($rcnet-$ecnet);
$reclval=($rccval-$eccval);    
?>    
<tr>
<td ><b><i class="fa fa-caret-right" aria-hidden="true"></i>&nbsp;Retained earnings </b></td>
<td class="text-right"><?php echo number_format(($rcopval-$ecopval),2);?></td>
<td class="text-right"><?php echo number_format(($rcnet-$ecnet),2);?></td>
<td class="text-right"><?php echo number_format(($rccval-$eccval),2);?></td>     
</tr> 
    
<?php 
$lcopval=(get_ledgervalnew('2','C','O','C',$fdate)-get_ledgervalnew('2','D','O','C',$fdate));
$lcdebit=get_ledgervalnew('2','D','D','C',$fdate,$tdate);
$lccredit=get_ledgervalnew('2','C','D','C',$fdate,$tdate);
$lcnet=($lccredit-$lcdebit);
$lccval=($lcopval+$lcnet);
    
$wcopval=(get_ledgervalnew('3','C','O','C',$fdate)-get_ledgervalnew('3','D','O','C',$fdate));
$wcdebit=get_ledgervalnew('3','D','D','C',$fdate,$tdate);
$wccredit=get_ledgervalnew('3','C','D','C',$fdate,$tdate);
$wcnet=($wccredit-$wcdebit);
$wccval=($wcopval+$wcnet);    
?>
<?php if(ABS($lccval)>0){?>    
<tr style="border-bottom:none;border-top:none;">
    <td colspan="4"></td>
</tr>     
<tr>    
<td ><b>&nbsp;Total Liabilities and Owner's Equity</b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(($lcopval+$wcopval+$reopval),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(($lcnet+$wcnet+$reduval),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(($lccval+$wccval+$reclval),2);?></b></td>    
</tr>
<?php } ?>
</tbody>    
</table>
<!--/LIABILITIES and OWNER'S EQUITY-->
<table class="table table-bordered   table-hover">
<tbody>
<tr>
<td width="50%" class="bg-gray"><b>Common Financial Ratios</b></td>
<td width="16.16%" class="bg-gray"></td>
<td width="16.16%" class="bg-gray"></td>
<td width="16.16%" class="bg-gray"></td>    
</tr>
<tr>
<td width="50%" style="padding-left:15px;"><b>Debt Ratio</b> (Total Liabilities / Total Assets)</td>
<td width="16.16%" class="text-right"><?php if(ABS($acopval)>0 && ABS($lcopval)>0){echo number_format(ABS($acopval/$lcopval),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($acnet)>0 && ABS($lcnet)>0){echo number_format(ABS($acnet/$lcnet),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($accval)>0 && ABS($lccval)>0){echo number_format(ABS($accval/$lccval),2);}else{echo '0.00';}?></td>    
</tr>
<?php 
$caopval=(get_ledgervalnew('2','D','O','G',$fdate)-get_ledgervalnew('2','C','O','G',$fdate));
$cadebit=get_ledgervalnew('2','D','D','G',$fdate,$tdate);
$cacredit=get_ledgervalnew('2','C','D','G',$fdate,$tdate);
$canet=($cadebit-$cacredit);
$cacval=($caopval+$canet);

$clopval=(get_ledgervalnew('5','C','O','G',$fdate)-get_ledgervalnew('5','D','O','G',$fdate));
$cldebit=get_ledgervalnew('5','D','D','G',$fdate,$tdate);
$clcredit=get_ledgervalnew('5','C','D','G',$fdate,$tdate);
$clnet=($clcredit-$cldebit);
$clcval=($clopval+$clnet);     
?>    
<tr>
<td width="50%" style="padding-left:15px;"><b>Current Ratio</b> (Current Assets / Current Liabilities)</td>
<td width="16.16%" class="text-right"><?php if(ABS($caopval)>0 && ABS($clopval)>0){echo number_format(ABS($caopval/$clopval),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($canet)>0 && ABS($clnet)>0){echo number_format(ABS($canet/$clnet),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($cacval)>0 && ABS($clcval)>0){echo number_format(ABS($cacval/$clcval),2);}else{echo '0.00';}?></td>    
</tr>
<tr>
<td width="50%" style="padding-left:15px;"><b>Working Capital</b> (Current Assets - Current Liabilities)</td>
<td width="16.16%" class="text-right"><?php echo number_format(($caopval-$clopval),2);?></td>
<td width="16.16%" class="text-right"><?php echo number_format(($canet-$clnet),2);?></td>
<td width="16.16%" class="text-right"><?php echo number_format(($cacval-$clcval),2);?></td>    
</tr>
<tr>
<td width="50%" style="padding-left:15px;"><b>Assets-to-Equity Ratio</b> (Total Assets / Owner's Equity)</td>
<td width="16.16%" class="text-right"><?php if(ABS($caopval)>0 && ABS($wcopval)>0){echo number_format(ABS($caopval/$wcopval),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($canet)>0 && ABS($wcnet)>0){echo number_format(ABS($canet/$wcnet),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($cacval)>0 && ABS($wccval)>0){echo number_format(ABS($cacval/$wccval),2);}else{echo '0.00';}?></td>    
</tr>
<tr>
<td width="50%" style="padding-left:15px;"><b>Debt-to-Equity Ratio</b> (Total Liabilities / Owner's Equity)</td>
<td width="16.16%" class="text-right"><?php if(ABS($lcopval)>0 && ABS($wcopval)>0){echo number_format(ABS($lcopval/$wcopval),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($lcnet)>0 && ABS($wcnet)>0){echo number_format(ABS($lcnet/$wcnet),2);}else{echo '0.00';}?></td>
<td width="16.16%" class="text-right"><?php if(ABS($lccval)>0 && ABS($wccval)>0){echo number_format(ABS($lccval/$wccval),2);}else{echo '0.00';}?></td>   
</tr>    
</tbody>    
</table>     
 <div style="clear: both;"></div>   
<div id="not-printed">
<br> 
<br>
<br>    
</div>    
</div>    
</div>
<div style="clear: both;"></div>
<div class="invoice_footer">
<hr>
<p style="margin-top: -5px;"><?php echo get_cominfo('1','name');?>. © <?php echo date('Y');?></p>
</div>
<div style="clear: both;"></div>
</div>
</div>   
</div>    
    
</div>
</div>
</div>
    
</div>    
</div>

<?php include('../layout/quick.php');?>    
</section>
<!-- /.main content -->    
</div>
<?php
include('../layout/footer.php');
?>
<!-- page script -->
<!-- <script type="text/javascript">
$("#itemdata").treetable({expandable: true});
$("#itemdata1").treetable({expandable: true});
$("#itemdata2").treetable({expandable: true});
    
$(document).on('click', '#expand', function(e) {
$("#itemdata").treetable('expandAll');  
});
    
$(document).on('click', '#colaps', function(e) {
$("#itemdata").treetable('collapseAll');  
});    
</script>  -->
<script type="text/javascript">
$(function(){
  $('.invhold').css({ height: $(window).innerHeight()-190 });
  $(window).resize(function(){
    $('.invhold').css({ height: $(window).innerHeight()-190 });
  });
});   
</script>    
<!-- /page script -->
</html>    