<?php 
include("../config.php");
$vendor_id = $_GET['q'];

// bill table
$vendor           = "SELECT * FROM act_master WHERE id='".$vendor_id."'";
$vendor_res       = mysqli_query($conn,$vendor);
$vendor_row       = mysqli_fetch_array($vendor_res);

$bill             = "SELECT * FROM `trans` WHERE act_code = '".$vendor_row['act_code']."' AND balance > '0' AND company_id = '".$_SESSION['company_id']."' AND branch_id = '".$_SESSION['branch_id']."'";
$bill_res         = mysqli_query($conn,$bill);
$total_records    = mysqli_num_rows($bill_res);

?>
<div class="row">
   <div class="col-xs-12 col-sm-12">
      <div class="box">
         <div class="box-header with-border">
            <h3 class="box-title">VOUCHER DETAILS</h3>
         </div>
         <div class="" id="product-wapper">
            <table class="table table-striped table-bordered table-list" id="">
               <thead>
                  <tr class="hitz-tab capital">
                     <th width="50">#</th>
                     <th width="100">VOUCHER</th>
                     <th width="150">VOU.DATE</th>
                     <th width="250">ACCOUNT NAME</th>
                     <th width="150">AMOUNT</th>
                     <th width="150">DUE</th>
                     <th width="150">ADJUST</th>
                     <th width="150">BALANCE</th>
                  </tr>
               </thead>
               <tbody>
                  <?php
                  $count=$total_records;  if($count>0){
                  $i = 0; 
                  while ($bill_row = mysqli_fetch_array($bill_res)) { 
                  $act = "SELECT * FROM `act_master` WHERE `act_code` = '".$bill_row['act_code']."'";
                  $act_res = mysqli_query($conn,$act);
                  $act_row = mysqli_fetch_array($act_res);

                  ?>
                  <tr>
                     <td><input type="checkbox" required="" id="voucher_no" value="<?php echo $bill_row['voucher_no'];?>" name="product[<?php echo $i; ?>][voucher_no]"></td>
                     <td><?php echo $bill_row['voucher_no'];?></td>
                     <td><?php echo $bill_row['voucher_date'];?></td>
                     <td><?php echo $act_row['ac_name'];?> - <?php echo $bill_row['act_code'];?></td>
                     <td><input type="text" class="form-control hit_net_amt" value="<?php echo $bill_row['amount'];?>" name="product[<?php echo $i; ?>][amount]" readonly="" onkeyup="calculateFinalAmount(this);"></td>

                     <td><input type="text" class="form-control due_amnt" name="product[<?php echo $i; ?>][balance]" onkeyup="calculateFinalAmount(this);" value="<?php echo $bill_row['balance'];?>" readonly=""></td>

                     <td><input type="text" class="form-control adj_amnt" name="product[<?php echo $i; ?>][adjust]" onkeyup="calculateFinalAmount(this);" max="<?php echo $bill_row['balance'];?>"></td>

                     <td><input type="text" class="form-control balance" readonly="" name="product[<?php echo $i; ?>][balance]" value="<?php echo $bill_row['balance'];?>"></td>
                  </tr>
                  
                  <?php $i++;} }else{ ?>
                  <tr>
                    <td colspan="8" align="center"><b><?php echo "No Record Found...!!!!"; ?></b></td>
                  </tr>
                  <?php } ?>
               </tbody>
            </table>
         </div>
      </div>
   </div>
</div>