<?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>Trail Balance</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 sale account shown in table
    $sql_tri = "SELECT *,sum(Cr_Amt) as  Cr_Amt FROM tbl_account WHERE sales_type='Sales' and session_login_id = '".$_SESSION['login_id']."'";
    $res_tri = mysql_query($sql_tri);
    $row = mysql_fetch_assoc($res_tri);
    $sales_type1 = $row["sales_type"];
	 $cashsal = $row["Cr_Amt"];
?>
<?php
//here we select sales iteem that are sale//
   /* $sql_sal = "SELECT sum(Cr_Amt) as  Cr_Amt FROM tbl_account where sales_type='Sales'";
    $res_sal = mysql_query($sql_sal);
    $rowsal = mysql_fetch_assoc($res_sal);
    $cashsal = $rowsal["Cr_Amt"];
*/
// here we subtract sale return item from sale
    $sql_sal_r = "SELECT sum(Dr_Amt) as  Dr_Amt FROM tbl_account where sales_type='Sales Return' and session_login_id = '".$_SESSION['login_id']."'";
    $res_sal_r = mysql_query($sql_sal_r);
    $rowsal_r = mysql_fetch_assoc($res_sal_r);
    $cashsal_r = $rowsal_r["Dr_Amt"];

    $sale_ret_tot=$cashsal-$cashsal_r;

?>
                    <tr height="32" class='clickable-row' data-href='sale_trail_summ.php'>
                        <td nowrap="nowrap" width="6%"><?php echo  $sales_type1 ?></td>
                        <td nowrap="nowrap" width="6%"></td>
                        <td nowrap="nowrap" width="6%"><?php echo $cashsal; ?></td>
                    </tr>
                    <tr height="32" class='clickable-row' data-href='sale_r_trail_summ.php'>
                        <td nowrap="nowrap" width="6%">Sales Return</td>
                        <td nowrap="nowrap" width="6%"></td>
                        <td nowrap="nowrap" width="6%"><?php echo $cashsal_r; ?></td>
                    </tr>




</table>
<br><br><br><br>
            <table class="table">
                    <tr height="32">
                        <td nowrap="nowrap" width="6%" style="font-weight: bold">Grand Total</td>
                        <td nowrap="nowrap" width="1%" colspan="2"></td>
                        <td nowrap="nowrap" width="6%"><?php echo  $cashsal_r+$cashsal; ?></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>