<?php 

session_start();
if (!isset($_SESSION['username'])) {
  header("location:login/main_login.php");
}

require_once("setting.php");
	
    require_once(connection);
$id=date('m');
?>
<html lang="en">
<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1">
  <link rel="stylesheet" href="css/bootstrap.min.css">
  <script src="js/jquery.min.js"></script>
  <script src="js/bootstrap.min.js"></script>
</head>
<body>
<div class="d-print-none">
        <br>
        <button style="background-color: floralwhite" onclick="window.print()">Print Bill</button>
        <button style="background-color: floralwhite" onclick="history.go(-1);">Back</button>
        <br>
        <br>
    </div>
<div class="container">
<div class="row">
<!-- logo -->
<div class="col-xs-6"><img src="<?php echo logo;?>" width="55px"/></div>
<h2>City Link Internet Network</h2> 
</div>
<!-- customer detail -->
<!-- services detail -->


<div class="col-md-9">
<table class="table text-center">
<tbody>
<tr><td class="border-0">Date:<?php echo date('d-m-Y');?></td><td colspan="5" class="border-0"><h4> Overdue Report</h4></td>

</tr>
<tr>
<th>Name</th>
<th>Address</th>
<th>Pkg Plan</th>
<th>Arear Amount</th>
<th>Total Bill</th>
<th>Overdue</th>
</tr>
<?php
$sqli="SELECT * FROM c_bill where bill_month=$id";
if ($resulti=mysqli_query($con,$sqli)){
while($rowi = $resulti->fetch_assoc()) { 
$c_inv =$rowi['c_inv'];
$c_id =$rowi['c_id'];
$pkg_id =$rowi['pkg_id'];
$arear =$rowi['arear'];
$bill_amount =$rowi['bill_amount'];
$total_amount =$rowi['total_amount'];
$due_date =$rowi['due_date'];
$bill_month =$rowi['bill_month'];
$paid =$rowi['paid'];
$overdue=$total_amount-$paid ;
  $month = date('F', mktime(0,0,0,$bill_month, 1, date('Y')));

$sql2="SELECT * FROM customer where c_id=$c_id";
if ($result2=mysqli_query($con,$sql2)){
	while($row2 = $result2->fetch_assoc()) { 
$name = $row2['c_name'];
$fname = $row2['c_fname'];
$address = $row2['c_address'];
$pkg = $row2['c_pkg'];
$mobile = $row2['c_phone1'];

$sqle="SELECT * FROM pkg where pkg_id=$pkg";
if ($resulte=mysqli_query($con,$sqle)){
	while($rowe = $resulte->fetch_assoc()) { 
$pkg_name = $rowe['pkg_name'];

	
	}}
}}

if (empty($overdue)){
	
}else{
echo '<tr><td>'.$name.'</td><td>'.$address.'</td><td>'.$pkg_name.'</td><td>'.$arear.'</td><td>'.$total_amount.'</td><td>'.$overdue.'</td></tr>';
}



}}
?>
</tbody>
</table>
</div>
</div >
<!-- bill history -->
</body>
</html>




