<?php session_start();
include ('../inc/dbcon.php');
include ('../inc/functions.php');
include ('../inc/repfunctions.php');
if(isset($_SESSION["axeslogin"]) && $_SESSION["axeslogin"] == true){
get_pagesecurity('32','views','R');     
$_SESSION['cuPages']='fin_blasheet.php';   
$cuPage='fin_blasheet.php';    
$aid=$_SESSION['uid'];
$brid=$_SESSION['abrid'];    
}else{
header('Location:../index.php');
exit;    
}
$mhead='financ';
$menuh='Financials';
$phead='finblsh';
$page='Balance Sheet';
$dtnow = date("Y-m-d h:i:s", time());
$today = strftime("%Y-%m-%d", time());


if(isset($_POST['tfdate'])){	
    $fdate=$_POST['tfdate'];	
}else{
 $fdate=date('Y-m-d', strtotime('-29 days', time()));	
}
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-9">
<div class="box box-solid">
<div class="box-header with-border">
<h3 class="box-title">Balance Sheet</h3>
</div>
<div class="box-body">
<?php echo display_msg();?>    
<div class="col-md-12 table-responsive">
<div class="row">    
<center>
<h3 class="page-title">BALANCE SHEET</h3>
</center>
</div>
<div class="row" >  
<div class="col-md-12">

</div>
<div class="clearfix" ></div>
<!-- ASSETS --> 
<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>Debit</b></td>
<td width="16.16%" class="bg-gray"><b>Credit</b></td>
<td width="16.16%" class="bg-gray"><b>Closing</b></td>    
</tr>
<?php      
$agdebit=0;$agcredit=0;$agnet=0;
$sql="SELECT DISTINCT grid,groups,sum(debit)as gdebit,sum(credit) as gcredit, sum(debit-credit) as gbalance FROM tbl_ledgerview WHERE clsid='1' GROUP BY grid  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gdebit=$rowg['gdebit'];
$agdebit +=$gdebit;
$gcredit=$rowg['gcredit'];
$agcredit +=$gcredit;
$gnet=$rowg['gbalance'];
$agnet +=$gnet;
?>
<?php //if(ABS($gnet)>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($gdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
</tr>
<?php //} ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup, sum(debit) as sdebit,SUM(debit-credit) as sbalance FROM tbl_ledgerview WHERE clsid='1' and grid='".$rowg['grid']."' GROUP BY sgrid ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sdebit=$rowsg['sdebit'];
$scredit=$rowsg['scredit'];
$snet=$rowsg['sbalance'];
    
?>
<?php //if(ABS($snet)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($scredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>  
</tr>
<?php //} ?>   
<?php     
$sql="SELECT id,ledger,debit,credit  FROM tbl_ledgerview 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)){
$ldebit=$rowl['debit'];
$lcredit=$rowl['credit'];
$lnet=$rowl['debit']-$rowl['credit'];
?>
<?php //if(ABS($lnet)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left:30px;"><?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($ldebit,2);?></td>
<td class="text-right"><?php echo number_format($lcredit,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>    
</tr>
<?php //} ?>   
<?php }} ?>
<?php //if(ABS($gnet)>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($gdebit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcredit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>     
</tr>
<?php // } ?>    
<?php } ?> 
<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($agdebit),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(ABS($agcredit),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(ABS($agnet),2);?></b></td>    
</tr>   
</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>Debit</b></td>
<td width="16.16%" class="bg-gray"><b>Credit</b></td>
<td width="16.16%" class="bg-gray"><b>Closing</b></td>    
</tr>
<?php    
$lgdebit=0;$lgcredit=0;$lgnet=0;
$sql="SELECT DISTINCT grid,groups,sum(debit)as gdebit,sum(credit) as gcredit, sum(debit-credit) as gbalance FROM tbl_ledgerview WHERE clsid='2' GROUP BY grid  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gdebit=$rowg['gdebit'];
$lgdebit +=$gdebit;
$gcredit=$rowg['gcredit'];
$lgcredit +=$gcredit;
$gnet=$rowg['gbalance']; 
$lgnet +=$gnet;
?>
<?php //if(ABS($gnet)>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($gdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
</tr>
<?php //} ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup, sum(debit) as sdebit,SUM(debit-credit) as sbalance FROM tbl_ledgerview WHERE clsid='2' and grid='".$rowg['grid']."' GROUP BY sgrid ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sdebit=$rowsg['sdebit'];
$scredit=$rowsg['scredit'];
$snet=$rowsg['sbalance'];
    
?>
<?php //if(ABS($snet)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($scredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>  
</tr>
<?php // } ?>   
<?php     
$sql="SELECT id,ledger,debit,credit FROM tbl_ledgerview WHERE clsid='2' AND sgrid='".$rowsg['sgrid']."' ORDER BY id ASC";
$resultl=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowl=mysqli_fetch_array($resultl)){
$ldebit=$rowl['debit'];
$lcredit=$rowl['credit'];
$lnet=$rowl['debit']-$rowl['credit'];
?>
<?php //if(ABS($lnet)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left:30px;"><?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($ldebit,2);?></td>
<td class="text-right"><?php echo number_format($lcredit,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>    
</tr>
<?php //} ?>   
<?php }} ?>
<?php //if(ABS($gnet)>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($gdebit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcredit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>     
</tr>
<?php //} ?>    
<?php } ?>    

</tbody>    
</table>
<!--/LIABILITIES-->
<!--OWNER'S EQUITY-->   
<table class="table table-bordered table-hover treetable" id="itemdata2">
<tbody> 
<?php     
$ogdebit=0;$ogcredit=0;$ognet=0;
$sql="SELECT DISTINCT grid,groups,sum(debit)as gdebit,sum(credit) as gcredit, sum(debit-credit) as gbalance FROM tbl_ledgerview WHERE clsid='3' GROUP BY grid  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gdebit=$rowg['gdebit'];
$ogdebit +=$gdebit;
$gcredit=$rowg['gcredit'];
$ogcredit +=$gcredit;
$gnet=$rowg['gbalance']; 
$ognet +=$gnet;
?>
<?php //if(ABS($gnet)>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($gdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
</tr>
<?php //} ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup, sum(debit) as sdebit,SUM(debit-credit) as sbalance FROM tbl_ledgerview WHERE clsid='3' and grid='".$rowg['grid']."' GROUP BY sgrid ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sdebit=$rowsg['sdebit'];
$scredit=$rowsg['scredit'];
$snet=$rowsg['sbalance'];
    
?>
<?php //if(ABS($snet)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($scredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>  
</tr>
<?php //} ?>   
<?php     
$sql="SELECT id,ledger,debit,credit  FROM tbl_ledgerview 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)){
$ldebit=$rowl['debit'];
$lcredit=$rowl['credit'];
$lnet=$rowl['debit']-$rowl['credit'];
?>
<?php //if(ABS($lnet)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left:30px;"><?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($ldebit,2);?></td>
<td class="text-right"><?php echo number_format($lcredit,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>    
</tr>
<?php //} ?>   
<?php }} ?>
<?php //if(ABS($gnet)>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($gdebit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcredit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>     
</tr>
<?php // } ?>    
<?php } ?>    
<!--/OWNER'S EQUITY-->   
</tbody>    
</table>


<!--REVENUE-->   
<table class="table table-bordered table-hover treetable" id="itemdata2">
<tbody> 
<tr>
<td width="50%" class="bg-gray"><b>Ratain Earning</b></td>
<td width="16.16%" class="bg-gray"><b>Debit</b></td>
<td width="16.16%" class="bg-gray"><b>Credit</b></td>
<td width="16.16%" class="bg-gray"><b>Closing</b></td>    
</tr>
<?php     
$rgdebit=0;$rgcredit=0;$rgnet=0;
$sql="SELECT DISTINCT grid,groups,sum(debit)as gdebit,sum(credit) as gcredit, sum(debit-credit) as gbalance FROM tbl_ledgerview WHERE clsid='4' GROUP BY grid  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gdebit=$rowg['gdebit'];
$rgdebit +=$gdebit;
$gcredit=$rowg['gcredit'];
$rgcredit +=$gcredit;
$gnet=$rowg['gbalance']; 
$rgnet +=$gnet;
?>
<?php //if(ABS($gnet)>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($gdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
</tr>
<?php //} ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup, sum(debit) as sdebit,SUM(debit-credit) as sbalance FROM tbl_ledgerview WHERE clsid='4' and grid='".$rowg['grid']."' GROUP BY sgrid ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sdebit=$rowsg['sdebit'];
$scredit=$rowsg['scredit'];
$snet=$rowsg['sbalance'];
    
?>
<?php //if(ABS($snet)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($scredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>  
</tr>
<?php //} ?>   
<?php     
$sql="SELECT id,ledger,debit,credit FROM tbl_ledgerview WHERE clsid='4' AND sgrid='".$rowsg['sgrid']."' ORDER BY id ASC";
$resultl=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowl=mysqli_fetch_array($resultl)){
$ldebit=$rowl['debit'];
$lcredit=$rowl['credit'];
$lnet=$rowl['debit']-$rowl['credit'];
?>
<?php //if(ABS($lnet)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left:30px;"><?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($ldebit,2);?></td>
<td class="text-right"><?php echo number_format($lcredit,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>    
</tr>
<?php //} ?>   
<?php }} ?>
<?php //if(ABS($gnet)>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($gdebit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcredit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>     
</tr>
<?php // } ?>    
<?php } ?>    
<!--REVENUE-->   
</tbody>    
</table>


<!--EXPENSE-->   
<table class="table table-bordered table-hover treetable" id="itemdata2">
<tbody> 
<?php     
$egdebit=0;$egcredit=0;$egnet=0;
$sql="SELECT DISTINCT grid,groups,sum(debit)as gdebit,sum(credit) as gcredit, sum(debit-credit) as gbalance FROM tbl_ledgerview WHERE clsid='5' GROUP BY grid  ORDER BY clsid,grid ASC";
$result=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowg=mysqli_fetch_array($result)){
$gdebit=$rowg['gdebit'];
$egdebit +=$gdebit;
$gcredit=$rowg['gcredit'];
$egcredit +=$gcredit;
$gnet=$rowg['gbalance']; 
$egnet +=$gnet;
?>
<?php //if(ABS($gnet)>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($gdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gcredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($gnet,2);?></td>
</tr>
<?php //} ?>    
<?php     
$sql="SELECT DISTINCT sgrid,sgroup, sum(debit) as sdebit,SUM(debit-credit) as sbalance FROM tbl_ledgerview WHERE clsid='5' and grid='".$rowg['grid']."' GROUP BY sgrid ORDER BY sgrid ASC";
$results=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowsg=mysqli_fetch_array($results)){
$sdebit=$rowsg['sdebit'];
$scredit=$rowsg['scredit'];
$snet=$rowsg['sbalance'];
    
?>
<?php //if(ABS($snet)>0){?>     
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" data-tt-parent-id="<?php echo $rowg['grid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left: 15px;"><b>&nbsp;<?php echo $rowsg['sgroup'];?></b></td>
<td style="text-align:right;"><?php echo number_format($sdebit,2);?></td>
<td style="text-align:right;"><?php echo number_format($scredit,2);?></td>
<td style="text-align:right;"><?php echo number_format($snet,2);?></td>  
</tr>
<?php //} ?>   
<?php     
$sql="SELECT id,ledger,debit,credit FROM tbl_ledgerview WHERE clsid='5' AND sgrid='".$rowsg['sgrid']."' ORDER BY id ASC";
$resultl=mysqli_query($con,$sql)or die(mysqli_error($con));
while ($rowl=mysqli_fetch_array($resultl)){
$ldebit=$rowl['debit'];
$lcredit=$rowl['credit'];
$lnet=$rowl['debit']-$rowl['credit']; 
?>
<?php //if(ABS($lnet)>0){?>    
<tr data-tt-id="<?php echo $rowg['grid'].$rowsg['sgrid'].$rowl['id'];?>" data-tt-parent-id="<?php echo $rowg['grid'].$rowsg['sgrid'];?>" class="branch collapsed" style="display: none;">
<td style="padding-left:30px;"><?php echo $rowl['ledger'];?></td>
<td class="text-right"><?php echo number_format($ldebit,2);?></td>
<td class="text-right"><?php echo number_format($lcredit,2);?></td>
<td class="text-right"><?php echo number_format($lnet,2);?></td>    
</tr>
<?php //} ?>   
<?php }} ?>
<?php //if(ABS($gnet)>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($gdebit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gcredit,2);?></b>
</td>
<td style="text-align: right; border-top: 1px double #000000;"><b><?php echo number_format($gnet,2);?></b>
</td>     
</tr>
<?php // } ?>    
<?php } ?>    
<!--EXPENSE--> 

<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(($lgdebit+$ogdebit+$rgdebit-$egdebit),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(($lgdebit+$ogcredit+$rgcredit-$egcredit),2);?></b></td>
<td style="text-align: right; border-top: 1px double #000000; border-bottom: 4px double #000000;"><b><?php echo number_format(($lgnet+$ognet+$rgnet-$egnet),2);?></b></td>    
</tr>
</tbody>    
</table>

<!--/LIABILITIES and OWNER'S EQUITY-->
    

</div>    
</div>
</div>    
</div>
</div>
<div class="col-md-3">
    
<div class="row">
<div class="col-md-12">
<div class="box box-solid">
<div class="box-header">
<h3 class="box-title">Filter</h3>
</div>
<!-- /.box-header -->
<div class="box-body" >
<form action="fin_blasheet.php" onsubmit="return validate()" enctype="multipart/form-data" method="post" accept-charset="utf-8">
    <div class="col-md-12 popup_details_div">
        <div class="col-md-1"></div>
            <div class="col-md-10">    
                <div class="form-group" >
                    <label>From:</label>
                    <div class="input-group">
                        <span class="input-group-addon"><span class="fa fa-calendar"></span></span>
                        <input type="text" maxlength="18" class="form-control datetimepicker" name="tfdate"  placeholder="From Date" autocomplete="off" readonly>
                    </div>
                </div>
                <div class="form-group" >
                    <label>To:</label>
                    <div class="input-group">
                        <span class="input-group-addon"><span class="fa fa-calendar"></span></span>
                        <input type="text" maxlength="18" class="form-control datetimepicker" name="ttdate" placeholder="End Date" autocomplete="off" readonly>
                    </div>
                </div>
            </div>    
        <div class="col-md-1"></div>    
    </div>
    <div class="clearfix" ></div>
    <div class="col-md-12 nopadding widgets_area"></div>    
    <div class="row"style="margin-top: 15px" >
        <div class="col-md-6"></div>
        <div class="col-md-6 text-right" >
            <input type="button" id="reset" class="btn btn-flat bg-red btn-sm " value="Reset"/>    
            <input type="submit"  class="btn btn-flat bg-purple btn-sm" value="Submit"/>
        </div> 
    </div>  
</form>  
</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">
ReadData();
// function ReadData(){
// $.ajax({
// url: "fin_blview.php",
// method: "POST",
// data:{ 
// body:1
// },
// success: function(data){
// $('#itemdata').html(data);   
// }
// })
// };
    
// $(document).on('click', '#blview', function(e) {
// var fdate = $('#stdate').val();
// var tdate = $('#endate').val();
// toastr.options = {'positionClass': 'toast-top-center'};
    
// if(fdate.length<=0){
// toastr.info('Please Enter From Date!');
// return;    
// }

// if(tdate.length<=0){
// toastr.info('Please Enter To Date!');
// return;    
// }

// if(Date.parse(tdate) <= Date.parse(fdate)){
// toastr.info('To Date Must Greater or Equel than From Date!');
// return;    
// }    

// $.ajax({
// url: "fin_blasheet.php",
// method: "POST",
// data:{ 
// tfdate:fdate, ttdate:tdate
// },
// success: function(data){    
// $('#itemdata').html(data);   
// }
// })    
    
// });
// 
</script>    
<!-- /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> 
</html>    