-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraph.php
More file actions
80 lines (53 loc) · 1.63 KB
/
Copy pathgraph.php
File metadata and controls
80 lines (53 loc) · 1.63 KB
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
77
78
79
<?php
class graph {
//starting connection
public function __construct(){
$this->db=new database();
$this->conn=$this->db->conn;
}
public function select($query){
return $this->result=$this->db->select($query);
}
//end dabtabase connection
public function get_last_sms_data($days){
$data=array();
$today=$this->db->date();
for ($i=$days-1; $i>=0; $i--)
{
$date=date('Y-m-d', strtotime($today ." +$i days ago"));
$date1=date('Y-m-d', strtotime($date ." -1 days ago"));
$sql="select SUM(len) as total_sms from sms_list
where (date BETWEEN CAST('$date' AS DATE) AND CAST('$date1' AS DATE))
";
$info=$this->db->get_sql_array($sql);
$data1=array();
$total_data=(int)$info[0]['total_sms'];
$data1['y']=$total_data;
$data1['label']=date('d M Y', strtotime($date));
array_push($data, $data1);
}
$data=json_encode($data);
return $data;
}
public function get_site_activity_data($days){
$data=array();
$today=$this->db->date();
for ($i=$days-1; $i>=0; $i--)
{
$date=date('Y-m-d', strtotime($today ." +$i days ago"));
$date1=date('Y-m-d', strtotime($date ." -1 days ago"));
$sql="select COUNT(*) as total_data from site_activity
where (date BETWEEN CAST('$date' AS DATE) AND CAST('$date1' AS DATE))
";
$info=$this->db->get_sql_array($sql);
$data1=array();
$total_data=(int)$info[0]['total_data'];
$data1['y']=$total_data;
$data1['label']=date('d M Y (l)', strtotime($date));
array_push($data, $data1);
}
$data=json_encode($data);
return $data;
}
}
?>