Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
<?php
//This page displays a list of all Users Monthly Consumption
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script>
<link href="<?php echo $design; ?>/style.css" rel="stylesheet" title="Style" />
<title>User Bill</title>
</head>
<body>
<div>
<div align="center">
<div class="header" style="width: 100%; margin: auto;margin-top: 10px">
<img width="80%" src="<?php echo $design; ?>/images/logo.png" alt="Espace Membre" />
</div></div>
<div class="contentusers">
<div class="box">
<div class="box_left">
<a href="<?php echo $url_home; ?>">WCSF Index</a> &gt; User Bill
</div>
<div class="box_right">
<a href="profile.php?id=<?php echo $_SESSION['userid']; ?>"><?php echo htmlentities($_SESSION['username'], ENT_QUOTES, 'UTF-8'); ?></a> (<a href="login.php">Logout</a>)
</div>
<div class="clean">
</div>
</div>
<div>
<?php $find = mysqli_query($var,'select users.username,users.user_address,users.monthly_consumption,bill.monthly_bill from users INNER JOIN bill ON users.id = bill.bill_id'); ?>
</div>
<div>
<?php
if(isset($_SESSION['username']) and $_SESSION['username']==$admin)
{?>
<form method="post" action="billing.php">
Billing Due Date <input type="date" name="monthly_date" id="monthly_date"> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
Billing Month <input type="text" name="month" id="month">
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<input type="submit" name="billing" value="Assign" id="billing">
</form>
</div>
<br>
Monthly Users Bill:
<table>
<tr>
<th width="80px">Name</th>
<th width="120px">Address</th>
<th width="80px">Usage</th>
<th width="50px">Bill</th>
<th width="50px">Discount</th>
<!-- <th width="50px">Penalty</th> -->
<th width="80px">Total Bill</th>
<!-- <th width="60px">Payment</th> -->
</tr>
<?php
$req = mysqli_query($var,'select users.id ,users.username,users.email,users.user_address,users.monthly_consumption,bill.monthly_bill,bill.discount,bill.rate,bill.total_bill,bill.penalty,bill.bill_id from users INNER JOIN bill
ON users.id = bill.bill_id');
while($dnn = mysqli_fetch_array($req))
{
$dnn['monthly_bill'] = 0;
$dnn['total_bill'] = 0;
$dnn['discount'] = 0;
// $dnn['penalty'] = 0;
$dnn['rate'] = 0.08;
$bill_id = $dnn['bill_id'];
?>
<tr>
<!-- <td><?php echo $dnn['id']; ?></td>
<td><a href="profile.php?id=<?php echo $dnn['id']; ?>"></a> -->
<td><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></td>
<!-- <td><?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?></td> -->
<td><?php echo htmlentities($dnn['user_address'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($dnn['monthly_consumption'], ENT_QUOTES, 'UTF-8');?></td>
<?php
$monthly_consumption = $dnn['monthly_consumption'];
$monthly_bill = $dnn['rate'] * $dnn['monthly_consumption'];
if ($monthly_bill ==0 ||$monthly_bill <= 200) {
$total_bill = $monthly_bill;
$result = mysqli_query($var, " UPDATE bill SET monthly_bill='$monthly_bill', total_bill='$total_bill' WHERE bill_id = '$bill_id' ");
?>
<td><?php echo htmlentities($dnn['monthly_bill'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($dnn['discount'], ENT_QUOTES, 'UTF-8'); ?></td>
<!-- <td><?php echo htmlentities($dnn['penalty'], ENT_QUOTES, 'UTF-8'); ?></td> -->
<td><?php echo htmlentities($total_bill, ENT_QUOTES, 'UTF-8'); ?></td>
<?php
}
else if ($monthly_bill > 200 && $monthly_bill <= 1500) {
$discount = 100;
// $monthly_bill = $dnn['rate'] * $dnn['monthly_consumption'];
$total_bill = $monthly_bill - $discount;
$result = mysqli_query($var, " UPDATE bill SET discount='$discount', monthly_bill='$monthly_bill', total_bill='$total_bill' WHERE bill_id = '$bill_id' ");
?>
<td><?php echo htmlentities($monthly_bill, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($discount, ENT_QUOTES, 'UTF-8'); ?></td>
<!-- <td><?php echo htmlentities($dnn['penalty'], ENT_QUOTES, 'UTF-8'); ?></td> -->
<td><?php echo htmlentities($total_bill, ENT_QUOTES, 'UTF-8'); ?></td>
<?php }
else if ($monthly_bill > 1500 && $monthly_bill <= 2500){
// $monthly_bill = $dnn['rate'] * $dnn['monthly_consumption'];
$discount = 0;
$total_bill = $monthly_bill;
$qry = mysqli_query($var,"UPDATE bill SET discount='$discount',monthly_bill='$monthly_bill', total_bill ='$total_bill' WHERE bill_id = '$bill_id' ");
?>
<td><?php echo htmlentities($monthly_bill, ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($discount, ENT_QUOTES, 'UTF-8'); ?></td>
<!-- <td><?php echo htmlentities($dnn['penalty'], ENT_QUOTES, 'UTF-8'); ?></td> -->
<td><?php echo htmlentities($total_bill, ENT_QUOTES, 'UTF-8'); ?></td>
<?php }
?>
<!-- <td><a href="bill_payment.php?id=<?php echo $dnn['id'];?>" onclick="valueUpdate()"><span id="clicked" style="color: rgb(0,0,153);"> Update </span></a></td> -->
</tr>
<?php
}}
?>
</table>
<?php
if(isset($_SESSION['username']) and $_SESSION['username']!=$admin)
{?>
Monthly Users Bill:
<table style="margin: auto;">
<tr>
<th>Name</th>
<!-- <th>Email</th> -->
<th>Address</th>
<th>Usage</th>
<th>Bill</th>
<!-- <th>Discount</th>
<th>Penalty</th>
--><th>Total Bill</th>
</tr>
<?php //zubair
$req = mysqli_query($var,'select users.id,users.username,users.email,users.user_address,users.monthly_consumption,bill.bill_id,bill.monthly_bill,bill.discount,bill.penalty,bill.total_bill from users INNER JOIN bill
ON users.id = bill.bill_id');
$user = $_SESSION['username'];
while($dnn = mysqli_fetch_array($req))
{
if($user === $dnn['username']) {
?>
<tr>
<!-- <td><a href="profile.php?id=<?php echo $dnn['id']; ?>"></a> -->
<!-- <td><?php echo htmlentities($dnn['bill_id'], ENT_QUOTES, 'UTF-8'); ?></td> -->
<td><?php echo htmlentities($dnn['username'], ENT_QUOTES, 'UTF-8'); ?></td>
<!-- <td><?php echo htmlentities($dnn['email'], ENT_QUOTES, 'UTF-8'); ?></td> -->
<td><?php echo htmlentities($dnn['user_address'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($dnn['monthly_consumption'], ENT_QUOTES, 'UTF-8');?></td>
<td><?php echo htmlentities($dnn['monthly_bill'], ENT_QUOTES, 'UTF-8'); ?></td>
<!-- <td><?php echo htmlentities($dnn['discount'], ENT_QUOTES, 'UTF-8'); ?></td>
<td><?php echo htmlentities($dnn['penalty'], ENT_QUOTES, 'UTF-8'); ?></td>
--><td><?php echo htmlentities($dnn['total_bill'], ENT_QUOTES, 'UTF-8'); ?></td>
</tr>
</table>
<?php
?>
<br/>
<div class="center">
<b><a href="pdf_bill.php?id=<?php echo $dnn['id'];?>" target="_blank"> <input type="button" value="Generate Bill"> </input></a></b>
</div></div>
<?php }}}?>
</div>
<!-- <div class="foot">
<p><b>Water Control System and Discussion Portal for Farmers</b></p>
</div> -->
</div>
</div>
</body>
</html>