<?php 

include "top.php";

$logusers=$_POST['logusers'];
$mnth=$_POST['mnth'];
$yrs=$_POST['yrs'];

$q="SELECT * FROM cbill WHERE bl_line='$logusers' AND bl_month='$mnth' AND bl_year='$yrs'  ORDER BY bl_cname";

$getline=f(q("SELECT * FROM tbl_login WHERE l_id='$logusers' AND l_type=2"));


?>
<!DOCTYPE html>
<html>
<head>
        <style>
                                table {
                                border-collapse: collapse;
                                width: 100%;
                                }

                                th, td {
                                padding: 8px;
                                text-align: left;
                                border-bottom: 1px solid #ddd;
                                font-size:12px;
								font-weight:600;
                                }
                                body{

                                    padding:1%;
                                }
        </style>


</head>
<body>

<h2><?php echo $getline['l_name']?> Bill List For <?php echo $mnth?>,<?php echo $yrs;?></h2>


<table>
    <tr>
	<th>#</th>
    <th>Customer Name</th>
	<th>A/C No</th>
    <th>Phone</th>
    <th>Address</th>
    <th>Total Bill</th>
    <th>Paid Amt</th>
    
    </tr>
<?php
	$i=0;
    $res=mysqli_query($con,$q);
    while($arr=mysqli_fetch_array($res)){
		
		$getcust=f(q("SELECT * FROM adduser WHERE id='$arr[bl_cid]'"));
		$acno=$getcust['custid'];
		$i++;
		
		$curdue=floatval($arr['bl_amt'])+floatval($arr['bl_prevdue']);
        ?>

        <tr>
		<td><?php echo $i;?></td>
            <td>
                <?php echo $arr['bl_cname']?>
            </td>
			<td>
				<?php echo $acno;?>
			</td>
            <td>
                <?php echo $arr['bl_phone']?>
            </td>
            <td>
                <?php echo $arr['bl_address']?>
            </td>
            <td>
                <?php echo $curdue?>
            </td>
            <td></td>
            
        </tr>



   <?php }


?>


</table>
<script>
    window.print();
</script>
</body>
</html>