forked from laksa19/mikhmonv3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathresumereport.php
172 lines (139 loc) · 4.2 KB
/
resumereport.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?php
/*
* Copyright (C) 2018 Laksamadi Guko.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
session_start();
// hide all error
error_reporting(0);
if (!isset($_SESSION["mikhmon"])) {
header("Location:../admin.php?id=login");
} else {
// load session MikroTik
$session = $_GET['session'];
// load config
include('../include/config.php');
include('../include/readcfg.php');
$idbl = $_GET['idbl'];
$thisM = substr($idbl,0,3);
$thisY = substr($idbl,-4);
$ms = array(1 => "jan", "feb", "mar", "apr", "may", "jun", "jul", "aug", "sep", "oct", "nov", "dec");
$mn = array_search($thisM, $ms);
// https://secure.php.net/manual/en/function.cal-days-in-month.php#38666
function days_in_month($month, $year)
{
// calculate number of days in a month
return $month == 2 ? ($year % 4 ? 28 : ($year % 100 ? 29 : ($year % 400 ? 28 : 29))) : (($month - 1) % 7 % 2 ? 30 : 31);
}
if ($mn == date("n")){
$totD = (date('d') +1);
}else{
$totD = (days_in_month($mn, $thisY)+ 1);
}
function resume_per_day($date){
$evalue = explode($date,$_SESSION['dataresume']);
$x = count($evalue);
for ($i = 0; $i < $x; $i++) {
$result += (int) $evalue[$i];
}
return ($x-1).'/'.$result;
}
$totalvrc = explode("/",$_SESSION['totalresume'])[0];
$totalincome = explode("/",$_SESSION['totalresume'])[1];
if ($currency == in_array($currency, $cekindo['indo'])) {
$totalreport = "Total " . $totalvrc . "vcr : " . $currency . " " . number_format((float)$totalincome, 0, ",", ".");
} else {
$totalreport = "Total " . $totalvrc . "vcr : " . $currency . " " . number_format((float)$totalincome, 2);
}
}
?>
<div class="card">
<div class="card-header"><h3><i class="fa fa-area-chart"></i> Resume Report </h3></div>
<div class="card-body">
<div class="row">
<script src="./js/highcharts/highcharts.js"></script>
<script src="./js/highcharts/themes/hc.<?= $theme; ?>.js"></script>
<div class="col-12" id="container"></div>
<script type="text/javascript">
Highcharts.chart('container', {
chart: {
height: 500,
type: 'area',
},
title: {
text: 'Selling Report <?= ucfirst($thisM)." ".$thisY;?>'
},
subtitle: {
text: '<?= $totalreport;?>'
},
xAxis: {
tickInterval: 1
},
yAxis: {
title: {
text: 'Total Sales'
}
},
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
},
plotOptions: {
series: {
label: {
connectorAllowed: false
},
pointStart: 1
}
},
series: [{
name: 'Report',
data: [
<?php
for ($i = 1; $i < $totD; $i++) {
if (strlen($i) == "1") {
$thisD = "0" . $i;
} else {
$thisD = $i;
}
$idhr = strtolower($thisM . '/' . $thisD . '/' . $thisY);
if(explode("/",resume_per_day($idhr))[1] == ""){$r = 0;}else{$r = explode("/",resume_per_day($idhr))[1];}
echo "['<b>".$thisD." " .ucfirst($thisM)." ".explode("/",resume_per_day($idhr))[0]."vcr</b>',".$r."],";
}
?>
]
}],
tooltip: {
pointFormat: 'Total sales: <b>{point.y}</b>',
},
responsive: {
rules: [{
condition: {
maxWidth: 500
},
chartOptions: {
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom'
}
}
}]
}
});
</script>
</div>
</div>