<?php 
session_start();
ob_start(); 
include "header.php";
//$objIms->Semifinisheditem_alter();
?>
<script type="text/javascript">

window.addEventListener("keyup", function(e){ if(e.keyCode == 27) history.back(); }, false);

</script>
<style type="text/css">
    
        tr:hover {background-color:#bcd1cd;}

</style>
      <div class="page-wrapper">
            <!-- Container fluid  -->
            <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body" id="printableArea">
 

<form method="post">
        <div class="panel" >
            <div class="panel-heading" style="font-style: bold"><h3>Current Assets</h3></div>
                <p>&nbsp;</p>
                
                    <table width="100%" class="table table-bordered">
                     <tr height="32" align="left">
                        <th nowrap="nowrap" width="50%" rowspan="2">Particular</th>
                        <th nowrap="nowrap" width="17%" colspan="2" style="text-align: center;">Closing Balance</th>
                    </tr>
                    <tr>
                        
                        <th nowrap="nowrap" width="25%" colspan="1">Debit(Amount)</th>
                        <th nowrap="nowrap" width="50%" colspan="1">Credit(Amount)</th>
                    </tr>
<?php
// here we select all debtors sale in debite side 
    $sql_debtor="SELECT sum(dr_amount) as dr_amount from client_details where session_login_id = '".$_SESSION['login_id']."'";
    $res_debtor=mysql_query($sql_debtor);
    $count=mysql_fetch_assoc($res_debtor);
    $d_amount=$count["dr_amount"];
?>
<?php


//here we select cash in hand from cash to as assets that should be credited
    $sql_cash="SELECT sum(cr_amount) as cr_amount from cash_detail where session_login_id = '".$_SESSION['login_id']."'";
    $res_cash=mysql_query($sql_cash);
    $count=mysql_fetch_assoc($res_cash);
    $cr_amount=$count["cr_amount"];
// after that we subtract those amount from bank
   $sql_cashs="SELECT sum(dr_amount) as dr_amount from cash_detail where session_login_id = '".$_SESSION['login_id']."'";
    $res_cashs=mysql_query($sql_cashs);
    $counts=mysql_fetch_assoc($res_cashs);
    $dr_amounts=$counts["dr_amount"];

    $cassh_tot=$dr_amounts-$cr_amount;
// here we select cash in bank from bank to as assets that should be credited
// here at first sum those amount that are purchased 
    $sql_pur="SELECT sum(credit) as credit, sum(debit) as debit from tbl_bank where session_login_id = '".$_SESSION['login_id']."'";
    $res_pur=mysql_query($sql_pur);
    $coun=mysql_fetch_assoc($res_pur);
    $credit1=$coun["credit"]; 
	$debit_a=$coun["debit"];
	 
// after that we subtract those amount from bank
/*   $sql_bank="SELECT sum(debit) as debit from tbl_bank";
    $res_bank=mysql_query($sql_bank);
    $row=mysql_fetch_assoc($res_bank);
    $debit_a=$coun["debit"];

*/    $cre_amt=$credit1; 
    $tot_amt=$debit_a+$cassh_tot+$cashsal_r1;

    $opening=0;
?>
                    <tr height="32">
                        <td nowrap="nowrap" width="6%">Opening Stocks</td>
                        <td nowrap="nowrap" width="6%"><?php echo $opening; ?></td>
                        <td nowrap="nowrap" width="6%"></td>
                    </tr>
                    <tr height="32">
                        <td nowrap="nowrap" width="6%">Sundary Debtors</td>
                        <td nowrap="nowrap" width="6%"></td>
                        <td nowrap="nowrap" width="6%"></td>
                    </tr>

                    <tr height="32" class='clickable-row' data-href='tri_cuass_c_bank.php'>
                        <td nowrap="nowrap" width="6%">Bank Account</td>
                        <td nowrap="nowrap" width="6%"><?php echo $debit_a; ?></td>
                        <td nowrap="nowrap" width="6%"><?php echo $credit1; ?> </td>
                    </tr>
                    <tr height="32" class='clickable-row' data-href='tri_cur_a_cashdet.php'>
                        <td nowrap="nowrap" width="6%">Cash in hand</td>
                        <td nowrap="nowrap" width="6%"><?php echo $cassh_tot; ?></td>
                        <td nowrap="nowrap" width="6%"></td>
                    </tr>



</table>
<br><br><br><br>
            <table class="table">
                    <tr height="32">
                        <td nowrap="nowrap" width="7.5%" style="font-weight: bold">Grand Total</td>
                        <td nowrap="nowrap" width="1%"><?php echo $tot_amt; ?></td>
                        <td nowrap="nowrap" width="6%"><?php echo   $cre_amt; ?></td>
                    </tr>
                </table
></div>
</form>
                                         </div>
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
            <!-- End Container fluid  -->
      </div>
      
      </div>
 <?php include 'footer.php' ?>
 <script src="../js/lib/datatables/datatables.min.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/dataTables.buttons.min.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/buttons.flash.min.js"></script>
    <script src="../js/lib/datatables/cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script>
    <script src="../js/lib/datatables/cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/pdfmake.min.js"></script>
    <script src="../js/lib/datatables/cdn.rawgit.com/bpampuch/pdfmake/0.1.18/build/vfs_fonts.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/buttons.html5.min.js"></script>
    <script src="../js/lib/datatables/cdn.datatables.net/buttons/1.2.2/js/buttons.print.min.js"></script>
    <script src="../js/lib/datatables/datatables-init.js"></script>
        <script type="text/javascript">
    jQuery(document).ready(function($) {
    $(".clickable-row").click(function() {
        window.location = $(this).data("href");
    });
});
</script>