-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path7day-sales.php
50 lines (32 loc) · 1.29 KB
/
7day-sales.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
<?php
require_once('core.php');
require_once('config.php');
$ts = date('Y-m-d H:i:s', strtotime('-1 week'));
$te = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d'), date('Y')));
$ys = date('Y-m-d H:i:s', strtotime('-1 week',strtotime('-1 week')));
$ye = date('Y-m-d H:i:s', mktime(date('H'), date('i'), date('s'), date('m'), date('d')-7, date('Y')));
// if (isset($_POST) && isset($_SERVER['PHP_AUTH_USER'])) {
// /* Check API key */
// if ($apiKey === $_SERVER['PHP_AUTH_USER']) {
$sales1 = getOrders($ts,$te);
$count1 = getSoldCount($sales1);
$total1 = getSoldValue($sales1);
$sales2 = getOrders($ys,$ye);
$count2 = getSoldCount($sales2);
$total2 = getSoldValue($sales2);
$prefix = '£';
$currentSales = array("text"=>"Sales last 7 days", "value"=>$total1, "prefix"=>$prefix);
$previousSales = array("text"=>"on previous", "value"=>$total2);
$response = array("item"=>array($currentSales,$previousSales));
$json = json_encode($response);
//echo $ts . " to " . $te . "\n" . $ys . " to " . $ye . "\n";
echo $json;
// } else {
// Header("HTTP/1.1 403 Access denied");
// $data = array('error' => 'Nice try, asshole.');
// echo $data;
// }
// } else {
// Header("HTTP/1.1 404 Page not found");
// }
?>