<?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="container">
<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="row">
<!-- logo -->
<div class="col-xs-6"><img src="<?php echo logo; ?>" width="50px"/></div><div class="col-xs-6">
<h2>City Link Internet Network</h2> 
</div></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="4" class="border-0"><h4> Overdue Report</h4></td>

</tr>
<tr>
<th>Paid Customer</th>
<th>Overdue Customer</th>
<th>Payable Amount</th>
<th>Recieve Amount</th>
<th>Total Amount</th>
</tr>
<?php 
$sqli="SELECT SUM(bill_amount - paid) as `arear1` FROM `c_bill`";
if ($resulti=mysqli_query($con,$sqli)){ while($rowi = $resulti->fetch_assoc()) { $arear = $rowi['arear1'];  }}
$sqli="SELECT SUM(bill_amount) as `arear1` FROM `c_bill`";
if ($resulti=mysqli_query($con,$sqli)){ while($rowi = $resulti->fetch_assoc()) { $bill_amount = $rowi['arear1'];  }}
$sqli="SELECT SUM(paid) as `arear1` FROM `c_bill` ";
if ($resulti=mysqli_query($con,$sqli)){ while($rowi = $resulti->fetch_assoc()) { $paid = $rowi['arear1'];  }}

$sqli="SELECT Count(DISTINCT c_id) as `arear1` FROM `c_bill` Where total_amount = paid";
if ($resulti=mysqli_query($con,$sqli)){ while($rowi = $resulti->fetch_assoc()) { $payment = $rowi['arear1'];  }}
$sqli="SELECT Count(DISTINCT c_id) as `arear1` FROM `c_bill` Where total_amount <> paid";
if ($resulti=mysqli_query($con,$sqli)){ while($rowi = $resulti->fetch_assoc()) { $due = $rowi['arear1'];  }}




echo '<tr><td class="align-right">'.$payment.'</td><td>'.$due.'</td><td>'.$arear.'</td><td>'.$paid.'</td><td>'.$bill_amount.'</td></tr>';





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




