<?php














 




 include('db_con.php');




 









 $html = '';




 




 //$store_id = $_Get['fitem_no'];




// $store_id = $_Get['titem_no'];




 $dated = date('d-m-Y h:m A');




 $tot_balance = 0;
























  $sql = "select a.acc_no,a.acc_name,sum(d.debit-d.credit) balance from accounts a, jv_detail d, jv m where m.jv_id=d.jv_id and a.acc_no=d.acc_no and a.acc_type='CREDITOR' group by acc_no,acc_name order by acc_no";




   $statement = $connect->prepare($sql);




 $statement->execute();




  




 




 $result = $statement->fetchAll();









 




  ?>




<!DOCTYPE html>




<html>




<head>




  <title>Payable Report</title>




  <style>




@page { size: auto;  margin: 0mm; }




</style>




<link rel="stylesheet" type="text/css" href="css/print_style.css">




</head>




<body>
























<table width="100%" class="table_header">




<tr>




<td>Payable Report</td>




</tr>









</table>




  <table width="100%" id="print_table" class="print_table">









  <tr>




  <th width="7%">No</th>




  <th width="79%">Name</th>




  




  <th width="14%" class="rightside">Balance</th>



















  </tr>









  




  









<?php




foreach($result as $row)




 {




  




  $balance = $row["balance"];




  $tot_balance = $tot_balance + $balance;




echo '




  




  




  




<tr>




  <td width="7%">'.$row["acc_no"].'</td>




<td width="79%">'.$row["acc_name"].'</td>









   <td width="14%" class="rightside">'.number_format($balance, 2).'</td>




  




   




    




   </tr>









  ';




   




  }




  ?>




</table>




 <?php echo '




 <table width="100%" class="print_table"> 




<tr>




  <td width="86%" class="rightside">Total :</td>














   <td width="14%" class="rightside">'.number_format($tot_balance, 2).'</td>




  




   




    




   </tr>









  </table>




  ';?>









  <table width="100%" class="print_table">




    <tr><td>Printed at : <?php echo $dated;?></td></tr>




  </table>














</body>




</html>