-
Notifications
You must be signed in to change notification settings - Fork 0
/
filegraph.php
76 lines (52 loc) · 1.79 KB
/
filegraph.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
<?php session_start();
require_once("includes/connection.php");
require_once("includes/functions.php");
header("Content-type: image/png");
include("includes/graidlechart/graidle.php");
include_once("includes/phpMyGraph5.0.php");
//include("includes/pChart/class/pData.class.php");
//include("includes/pChart/class/pDraw.class.php");
//include("includes/pChart/class/pImage.class.php");
// SESSION VARIABLES
if (!loggedin()){
$rmessage = "You must be logged in or be Saqalain to come to this page!";
$_SESSION['rmessage'] = $rmessage;
toindex();
}
if(isset($_POST['vsubmit']) && loggedin()){
$_POST = array_map("strip_tags",$_POST);
$_POST = array_map("trim",$_POST);
$year = $_POST['years'];
$graphs = $_POST['graphs'];
$marray = array();
//$salesdata = array();
$msales = array();
$months = array('blank','Jan','Feb','Mar','Apr','May','June','July','Aug','Sept','Oct','Nov','Dec');
$msarray = array();
// Select all months for sales year & put in array
$monthsnh = $connection->query("SELECT DISTINCT `month` FROM `daily_sales` WHERE `year` = {$year}");
while ($month = $monthsnh->fetch_assoc()){
$marray[] = $month['month'];
}
foreach($marray as $number){
$msarray[] = $months[$number];
}
// start logic of gathering monthly sales
foreach($marray as $month){
$mshandle = $connection->query("SELECT SUM(`amount`) AS 'amount' FROM `daily_sales` WHERE `year` = '{$year}' AND `month` = '{$month}'");
while($ms = $mshandle->fetch_assoc()){
$msales[] = $ms['amount'];
}
} // foreach($marray as $month){
$salesdata = array_combine($msarray, $msales);
// Code for generating graph
//Set config directives
$cfg['title'] = "Graph for year {$year}";
$cfg['width'] = 800;
$cfg['height'] = 600;
$data = $salesdata;
$graph = new phpMyGraph();
//Parse
$graph->$graphs($data, $cfg);
} //post is set
?>