<?php 
session_start();
ob_start(); 
include "header.php";
//$objIms->Semifinisheditem_alter();
?>



<?php

if(isset($_GET["uid"]))
{
$uid=$_GET["uid"];
//$rs=$objIms->getRows("view_purchase_supplier","md5(id)='$uid'");
$sqlrs="select * from view_purchase_supplier where md5(id)='$uid' and session_login_id = '".$_SESSION['login_id']."'";
							//echo $sqlc;
							$res=mysql_query($sqlrs);
							
							$rs=mysql_fetch_array($res);
$pur_id=$rs["id"];
$order_no=$rs["order_no"];
$purchase_date=$objIms->IntToDate($rs["purchase_date"]);
$supplier_name=$rs["supplier_name"];

}


	
?>


		
	
		 <style>
			select.error { background-color:#ffa8a8; border: 1px dotted red;  }
			input.error{ background-color:#ffa8a8;   }
			textarea.error{ background-color:#ffa8a8; border: 1px dotted red;  }
         </style>
		 
        


<style type="text/css">
<!--
.table_bg{ border:#CCCCCC solid 1px; border-radius:5px; height:auto; width:auto; padding:20px; margin-bottom:10px;}


-->
</style>

<script type="text/javascript">
 
function printDiv(divName) {
     var printContents = document.getElementById(divName).innerHTML;
     var originalContents = document.body.innerHTML;

     document.body.innerHTML = printContents;

     window.print();

     document.body.innerHTML = originalContents;
}

</script>
<script type="text/javascript">
$(function(){
    $('button').click(function(){
        var url='data:application/vnd.ms-excel,' + encodeURIComponent($('#tableWrap').html()) 
        location.href=url
        return false
    })
})
</script>
<!-- Page wrapper  -->
        <div class="page-wrapper">
            <!-- Bread crumb -->
            <div class="row page-titles">
                <div class="col-md-5 align-self-center">
                    <h3 class="text-primary"></h3> </div>
                <div class="col-md-7 align-self-center">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="javascript:void(0)">Home</a></li>
                        <li class="breadcrumb-item active">Account Summary List</li>
                    </ol>
                </div>
            </div>
            <!-- End Bread crumb -->
            <!-- Container fluid  -->
            <div class="container-fluid">
                <!-- Start Page Content -->
                <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-body">
							
							<h3>Account Summary</h3>
							<hr />
     

<div id="printableArea">

					<div class="panel">
					<div class="panel-heading"></div>
					<p>&nbsp;</p><form name="form1" id="form1" method="post">
  <table id="example23" class="display nowrap table table-hover table-striped table-bordered" cellspacing="0" width="100%">
    <tr>
     
      <td width="11%"><strong>Select Bank </strong></td>
      <td width="1%"><strong>:</strong></td>
      <td width="12%"><select name="bank" id="bank" class="required form-control" required>
    <option value="">Select</option>
      <?php 
							$sqlc="select * from tbl_bank_detail where session_login_id = '".$_SESSION['login_id']."'";
							//echo $sqlc;
							$c=mysql_query($sqlc);
							if(mysql_num_rows($c)>0){
							while($cs=mysql_fetch_array($c))
							{?>
      <option value="<?=$cs["id"];?>" >
      <?=$cs["bank_name"];?> (AC/NO:  <?=$cs["acc_no"];?>)
      </option>
      <?php }}?>
    </select></td>
      <td width="1%">&nbsp;</td>
      <td width="22%"><input type="submit" name="Search" value="Search" class="btn btn-info" /></td>
      </tr>
  </table>
</form>
<br />
					<form method="post">
                     <table width="100%" class="table table-bordered" id="tab_wrapper">
					
                     <tr height="32" align="left">
            <th nowrap="nowrap" width="6%">SL No</th>
			 <th nowrap="nowrap" width="24%">Bank </th>
            <th nowrap="nowrap" width="35%">Opening Balance</th>
            
            <th nowrap="nowrap" width="18%">Closing Balance</th>
			 <th nowrap="nowrap" width="18%">View</th>
            </tr>
             <?php if(isset($_POST['Search'])){
							 $sqlc1="select *,sum(debit) as debit,  sum(credit) as credit from tbl_bank where bankdet_id ='".$_POST['bank']."' and session_login_id = '".$_SESSION['login_id']."'";
							$i=1;
							$c1=mysql_query($sqlc1);
             $rows=mysql_fetch_assoc($c1);

                $bankdet_id=$rows["bankdet_id"];
                $debit_tot=$rows["debit"];
                $credit_tot=$rows["credit"];
              
            $sql_bank="select * from tbl_bank_detail where id='".$_POST['bank']."' and session_login_id = '".$_SESSION['login_id']."'";
              $res_bank=mysql_query($sql_bank);
              $bank_n=mysql_fetch_assoc($res_bank);
              $bank_name=$bank_n["bank_name"];


              /*$sql_open="select sum(debit) as debit from tbl_bank";
              $res_open=mysql_query($sql_open);
              $res_tot=mysql_fetch_assoc($res_open);
              $debit_tot=$res_tot["debit"];

              $sql_clos="select sum(credit) as credit from tbl_bank";
              $res_clos=mysql_query($sql_clos);
              $res_cre=mysql_fetch_assoc($res_clos);
              $credit_tot=$res_cre["credit"];*/

              $closing_amt=$debit_tot-$credit_tot;

							?>
            <tr height="32">
            <input type="hidden" name="rahul" id="rahul" value="<?='Account_summary '?>" /> 
            <td nowrap="nowrap" width="6%"><?php echo $i++;?></td>
			      <td><?php  echo $bank_name;?></td>
     <!-- <?php echo  $objIms->IntToDate($close_date);?> -->
           <td><?php echo $debit_tot;?></td>


		    <td><?php echo $closing_amt;?></td>
			 
			  <td><a onclick="PopupCenter('account_summary_popup.php?cls_id=<?php echo md5($cls_mtr_id);?>','xtf','1000','700');" style="cursor:pointer; text-decoration:none">View</a></td>
		  
			</tr>
		<?php }?>
			</table>
			
			
           </table>
		 
		   </form>
		   </div>
  
   
<p></p>
		<br />
        

</div>
</div>
<br />

<div align="center"><span class="btn btn-info" onClick="printDiv('printableArea')">Print</span> &nbsp;&nbsp;<button id="btnExport" class="btn btn-success">Export to Excel</button></div></div></div>
                        </div>
                    </div>
                </div>
                <!-- End PAge Content -->
            </div>
            <!-- End Container fluid  -->
<?php include 'footer.php' ?>
<script>
  $(document).ready(function() {
  $("#btnExport").click(function(e) {
    e.preventDefault();

    //getting data from our table
    var data_type = 'data:application/vnd.ms-excel';
    var table_div = document.getElementById('tab_wrapper');
    var table_html = table_div.outerHTML.replace(/ /g, '%20');

    var a = document.createElement('a');
    a.href = data_type + ', ' + table_html;
    a.download = document.getElementById('rahul').value + '.xls';
    a.click();
  });
});
</script>

    <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>