Permalink
Cannot retrieve contributors at this time
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?
Watersys/chart.php
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
95 lines (82 sloc)
3.61 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//This page displays a list of all Users Monthly Consumption | |
include('config.php'); | |
// $req = mysqli_query($var,"select username,weekly_consumption from users"); | |
$req = mysqli_query($var,"SELECT users.id, users.username,users.weekly_consumption, valve.water_flow FROM users INNER JOIN valve ON users.id = valve.v_id"); | |
$user = $_SESSION['username']; | |
while($dnn = mysqli_fetch_array($req)) | |
{ | |
if($user === $dnn['username']) { | |
$username = $dnn['username']; | |
$consumption = $dnn['weekly_consumption']; | |
$dailyUsage = $dnn['water_flow']; | |
} | |
} | |
$consumption = $consumption + $dailyUsage; | |
$consumption1= $consumption * 0.95; | |
$consumption2= $consumption * 1.07; | |
// $updateData = mysqli_query($var,"UPDATE users SET weekly_consumption='$consumption' WHERE username ='$user' "); | |
?> | |
<div id="usage" style="display: none;"> | |
<?php echo $consumption ?> | |
</div> | |
<!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>Weekly User Usage Chart</title> | |
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script> | |
<script type="text/javascript"> | |
google.charts.load('current', {'packages':['corechart']}); | |
google.charts.setOnLoadCallback(drawChart); | |
function drawChart() { | |
var div = document.getElementById("usage"); | |
var myData = div.textContent; | |
var data = google.visualization.arrayToDataTable([ | |
['username', 'weekly_consumption'], | |
['Current Week', <?php echo $consumption?>], | |
['Last',<?php echo $consumption1 ?>], | |
['Second Last', <?php echo $consumption2?>], | |
// ['Watch TV', 2], | |
// ['Sleep', 7] | |
]); | |
var options = { | |
title: 'Weekly Usage' | |
}; | |
var chart = new google.visualization.PieChart(document.getElementById('piechart')); | |
chart.draw(data, options); | |
} | |
</script> | |
</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> > Weekly Usage | |
</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> | |
<br> | |
Weekly Usage: | |
<div align="center"> | |
<div id="piechart" style="width: 900px; height: 500px;"></div></div> | |
</div> | |
<!-- <div class="foot"> | |
<p><b>Water Control System and Discussion Portal for Farmers</b></p> | |
</div> --> | |
</div> | |
</div> | |
</body> | |
</html> |