<?php 

    include "top.php";
    $arid=$_POST['logusers'];
    $cstat=$_POST['paytype'];
    $yrs=$_POST['yrs'];
    $mnth=$_POST['mnth'];

    if($arid==''){

        $title="Customer List for All area, ".$mnth." , ".$yrs;

    }else{

      //  echo "SELECT * FROM `tbl_area` WHERE arid='$arid'";

        $sqlll=f(q("SELECT * FROM `tbl_area` WHERE arid='$arid'"));
        $title="Customer List for ".$sqlll['arname'].", ".$mnth." , ".$yrs;


    }

    $getcom=f(q("SELECT * FROM tbl_company WHERE c_id=5"));

?>
<style>
    table{

        width:100%;
    }
    tr{

        width:100%;
    }
    td{

        border:1px solid gray;
    }

    @media print
{    
    .no-print, .no-print *
    {
        display: none !important;
    }
}
</style>
<div style="width:100%;text-align:right;" class="no-print" id="noprint">


<form action="blankexcel.php" method="post" target="_blank">
<input type="hidden" name="logusers" value="<?php echo $arid?>" />
<input type="hidden" name="paytype" value="<?php echo $cstat?>" />
<input type="hidden" name="yrs" value="<?php echo $yrs?>" />
<input type="hidden" name="mnth" value="<?php echo $mnth?>" />

<button type="submit" style="font-size:bold;background-color:orange;color:black;padding:15px;" href="billgenerate_report_excel.php?stdt=<?php echo $stdt?>&enddt=<?php echo $enddt?>&logusers=<?php echo $logusers?>&dbarea=<?php echo $dbarea?>" class="btn btn-primary" target="_blank">Export To Excel</button></form></div><br><br><br>
<center><h3><?php echo $getcom['c_name']?></h3><h3><?php echo $getcom['c_address']?></h3></center>
<center><h3><?php echo $title?></h3></center>

<table class="stripe hover multiple-select-row data-table-export nowrap">
         <thead>
            <tr>
               <th class="table-plus datatable-nosort">Sl. No</th>
               <th>NAME</th>
               
              
               <th>HNO</th>
               <th>AREA</th>
               <th>DUE</th>
               <th>CDATE</th>
               <th>MONTH</th>
               <th>REMARKS</th>
               
            </tr>
         </thead>
         <tbody>
            <?  
                if($arid==''){

                    $sqll="SELECT * FROM `adduser` WHERE is_cable='1' AND actv='1'";
                    
                   // $sql=mysqli_query($con,"SELECT * FROM `adduser` WHERE is_cable='$customer' AND actv='$paytype'");

                }else{
                    $sqll="SELECT * FROM `adduser` WHERE is_cable='1' AND actv='1' AND area_id='$arid'";
                   
                }
               // echo $sqll;
                $sql=mysqli_query($con,$sqll);

               while($row=mysqli_fetch_array($sql)){$c++;
               
					  
                        $getco=f(q("SELECT * FROM tbl_company WHERE c_id='$row[com_id]'"));
                        $coname=$getc['c_name'];
                        $getbill=f(q("SELECT * FROM cbill WHERE bl_cid='$row[id]' ORDER BY blid DESC LIMIT 1"));
                        $areaname=f(q("SELECT * FROM `tbl_area` WHERE arid='$row[area_id]'"));
                        $stadd=explode(",",ltrim($row['houseno']));
											//print_r($stadd);
											$hnos=$stadd[0];
                                           $uphse=mysqli_query($con,"UPDATE adduser SET houseno='$hnos' WHERE id='$row[id]'");
               ?>
            <tr>
               <td class="table-plus"><?=$c?></td>
               <td><?=$row['name']?></td>
               <td><?=$row['houseno']?></td>
               <td><?=$areaname['arname']?></td>
               <td><?php echo $getbill['bl_amt']?></td>
               <td></td>
               <td></td>
               <td></td>
               
            </tr>
            <?} ?>	
         
         </tbody>
      </table>

      <script>
        function prinwindow(){

            window.print();
        }
        
      </script>