<? include "top.php"; ?>
<!DOCTYPE html>
<html>
   <head>
      <?php include('include/head.php'); 
         $stdt=$_POST['stdt'];
         $enddt=$_POST['enddt'];
         $customer=$_POST['customer'];
         
         $name=mysqli_real_escape_string($con,$_POST['search']);
            $custid=mysqli_real_escape_string($con,$_POST['search']);
            //echo "SELECT * FROM `adduser` WHERE name='$name' OR custid='$custid' AND is_cable='1'";
            $getcust=f(q("SELECT * FROM `adduser` WHERE name='$name' OR custid='$custid' AND is_cable='1'"));
         ?>
      <title>Customer Bill History Report for <?=$getcust['name']?></title>
     
      <style type="text/css">
         th{
         font-size: 14px !important;
         padding: 5px;
         }
         td{
         font-size: 12px !important;
         }
         table{

            width: 100%;

         }
         tr{

            width: 100%;
         }
         thead > tr > td{
            background-color: #bad5e4;

         }

      </style>
   </head>
   <body style="background-color: white; padding: 3%;">
   
   <br><center><h4>Bill History Report of <?=$getcust['name']?></h4></center><br>
      <table class="stripe">
         <thead>
            <tr style="background-color: #bad5e4;">
               <th class="table-plus datatable-nosort">Sl. No</th>
               <th>Bill No</th>
               <th>Customer Name</th>
               <? if($customer=='1'){ ?>
               <th>VC NO</th>
               <!-- <th>STB NO</th> -->
               <? }else{?>
               <th>IP</th>
               <!-- <th>userid</th> -->
               <? } ?>
               <th>Bill Date</th>
               <th>Period</th>
               <th>Start Date</th>
               <th>End Date</th>
               <th>Cur Amt</th>
               <th>Prev Due/Adv</th>
               <th>Bill Amt</th>
               <th>Status</th>
               <th>Remarks</th>
               <th>Paid(in Rs.)</th>
               <th>Payment Date</th>
               <th>Due(in Rs.)</th>
            </tr>
         </thead>
         <tbody>
            <?
            
            $row=mysqli_query($con,"SELECT * FROM `cbill` WHERE bl_cid=$getcust[id] ORDER BY blid asc");

               while($arrc=mysqli_fetch_array($row)){$c++;
               
               $total=floatval($total)+floatval($arrc['bl_amt']);
               $paid=floatval($paid)+floatval($arrc['bl_payamt']);
               $billamt=floatval($arrc['bl_amt'])+floatval($arrc['bl_prevdue']);
               $duess=floatval($billamt)-floatval($arrc['bl_payamt']);
               
               ?>
            <tr style="border-bottom: 1px solid gray;<? if($arrc['bl_stat']==0){?>background-color: #f1d4c4;<?}?>">
               <td class="table-plus" style="text-align: center;"><?=$c?></td>
               <td><?=$arrc['bl_no']?></td>
               <td><?=$getcust['name']?><br>A/C No: <?=$getcust['custid']?></td>
             
               <td><?=$getcust['vc']?></td>
               <!-- <td><?=$getcust['stb']?></td> -->
               <td><?=$arrc['bl_dt']?></td>
               <td><?=$arrc['bl_month']?>,<?=$arrc['bl_year']?></td>
               <td><?=$arrc['bl_stdt']?></td>
               <td><?=$arrc['bl_expiry']?></td>
               <td><?=$arrc['bl_amt']?></td>
               <td><?=$arrc['bl_prevdue']?></td>
               <td><?=$billamt?></td>
               <td><? if($arrc['bl_stat']==1){?>Paid<?}else{?>Unpaid<? } ?></td>
               <td><?=$arrc['bl_remarks']?></td>
               <td><?=$arrc['bl_payamt']?></td>
               <td><?php if(floatval($arrc['bl_payamt'])>0){ echo $arrc['bl_paydt']; }?></td>
               <td><?=$duess?></td>
            </tr>
            <?}?>	
            <!-- <tfoot>
            <tr>
               <td class="table-plus"></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               <td></td>
               
            </tr>
         </tfoot> -->
         </tbody>
      </table><br>
      <!-- <table>
            <tr>
               <td style="width: 85%;"></td>
               <td><b>Total Bill Amount</b></td>
               <td>&#8377; <?=$total?></td>
              <td></td>
            </tr>
            <tr>
               <td style="width: 85%;"></td>
               <td><b>Total Paid Amount</b></td>
               
               <td>&#8377; <?=$paid?></td>
               <td></td>
            </tr>
            <tr>
               <td style="width: 85%;"></td>
               <td><b>Total Due Amount</b></td>
               <?php 


                  $dues=floatval($total)-floatval($paid);
               
               
               ?>
               <td>&#8377; <?=$dues?></td>
               <td></td>
            </tr>

      </table> -->
      <br><br>


      <?php //include('include/script.php'); ?>
      
   </body>
</html>

