-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdata.php
More file actions
287 lines (264 loc) · 10.3 KB
/
data.php
File metadata and controls
287 lines (264 loc) · 10.3 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
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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
<?php
require 'config.php';
if (isset($_COOKIE[User::COOKIE_ID]) and isset($_COOKIE[User::COOKIE_TOKEN])) {
$sql = new simpleMySQLi($db, realpath(__DIR__));
$user = new User($sql);
if ($user->auth($_COOKIE[User::COOKIE_ID], $_COOKIE[User::COOKIE_TOKEN])) {
# ok
} else {
header('Location: login.php');
exit;
}
} else {
header('Location: login.php');
exit;
}
$data = new Data($sql);
$place = new Place($sql);
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>report</title>
<link rel="stylesheet" href="bootstrap/bootstrap.min.css">
<link rel="stylesheet" href="bootstrap/jquery.ui.min.css">
<link rel="stylesheet" href="bootstrap/air.datepicker.min.css">
<style>
.run {
display: none;
position: fixed;
z-index: 1000;
top: 0;
left: 0;
height: 100%;
width: 100%;
background: rgba(255, 255, 255, .8) url('bootstrap/run.gif') 50% 50% no-repeat;
}
body.loading { overflow: hidden; }
body.loading .run { display: block; }
</style>
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<input type="hidden" rel="settings" data-key="ADMINISTRATOR" data-value="<?php echo User::ADMINISTRATOR; ?>">
<input type="hidden" rel="settings" data-key="MANAGER" data-value="<?php echo User::MANAGER; ?>">
<input type="hidden" rel="settings" data-key="type" data-value="<?php echo $user->type; ?>">
<nav class="navbar navbar-light bg-light sticky-top">
<div class="container">
<span class="navbar-brand">report</span>
<span class="navbar-text"><?php echo $user->name; ?> (<?php echo $user->type; ?>)</span>
<?php
if (User::ADMINISTRATOR == $user->type) {
$monYears = $data->monYears(0);
$managers = $user->managers();
} else if (User::MANAGER == $user->type) {
$monYears = $data->monYears($user->id);
$places = $place->lista($user->id);
?>
<a class="nav-link" href="javascript:void(popupData(0))">добавить запись в отчёт</a>
<?php
}
$monthes = Data::_monthes();
?>
<a class="nav-link" href="javascript:void(logout())">выход</a>
</div>
</nav>
<div class="container">
<div class="card mb-2 mt-2">
<div class="card-body">
<div class="form-group row mb-2">
<label for="data-period-month-year" class="col-form-label col-form-label-sm col-1">период</label>
<div class="col-3">
<?php
if ($monYears) {
?>
<select id="data-period-month-year" class="custom-select custom-select-sm">
<?php
foreach ($monYears as $value) {
?>
<option data-year="<?php echo $value['year']; ?>" data-month="<?php echo $value['month']; ?>">
<?php echo $monthes[$value['month']]; ?> <?php echo $value['year']; ?>
</option>
<?php
}
?>
</select>
<?php
} else if (false == $monYears) {
?>
<div class="alert alert-danger">Internal Server Error</div>
<?php
} else if (empty($monYears)) {
?>
<div class="alert alert-warning">нет заполненных отчётов</div>
<?php
}
?>
</div>
<?php
if (User::ADMINISTRATOR == $user->type) {
?>
<label for="data-manager" class="col-form-label col-form-label-sm col-1 text-nowrap">менеджер</label>
<div class="col-3">
<?php
if ($managers) {
?>
<select id="data-manager" class="custom-select custom-select-sm">
<option data-id="0">все менеджеры</option>
<?php
foreach ($managers as $id => $name) {
?>
<option data-id="<?php echo $id; ?>"><?php echo $name; ?></option>
<?php
}
?>
</select>
<?php
} else if (false == $managers) {
?>
<div class="alert alert-danger">Internal Server Error</div>
<?php
} else if (empty($managers)) {
?>
<div class="alert alert-warning">нет назначенных менеджеров</div>
<?php
}
?>
</div>
<?php
}
?>
<div class="col-2">
<a class="btn btn-block btn-outline-primary btn-sm" href="javascript:void(showData())">показать</a>
</div>
<?php
if (User::ADMINISTRATOR == $user->type) {
?>
<div class="col-2">
<a class="btn btn-block btn-outline-primary btn-sm" href="javascript:void(showReport())">сводный</a>
</div>
<?php
}
?>
</div>
</div>
</div>
<?php
if (User::ADMINISTRATOR == $user->type) {
?>
<table hidden id="data-table" class="table table-bordered table-hover table-sm table-striped">
<thead>
<tr class="table-primary">
<th>#</th>
<th>дата</th>
<th>менеджер</th>
<th>точка</th>
<th class="text-right">выручка</th>
</tr>
</thead>
<tbody id="data-table-body"></tbody>
<tfoot id="data-table-foot"></tfoot>
</table>
<table hidden id="data-report" class="table table-bordered table-hover table-sm table-striped">
<thead>
<tr class="table-primary">
<th>#</th>
<th>менеджер</th>
<th class="text-right">выручка</th>
</tr>
</thead>
<tbody id="data-report-body"></tbody>
<tfoot id="data-report-foot"></tfoot>
</table>
<?php
} else if (User::MANAGER == $user->type) {
?>
<table id="data-table" class="table table-bordered table-hover table-sm table-striped">
<thead>
<tr class="table-primary">
<th>#</th>
<th>дата</th>
<th>точка</th>
<th class="text-right">выручка</th>
</tr>
</thead>
<tbody id="data-table-body"></tbody>
<tfoot id="data-table-foot"></tfoot>
</table>
<div class="modal fade" id="data-popup" tabindex="-1" role="dialog">
<div class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title">добавить запись в отчёт</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
<div class="modal-body">
<div class="form-group row mb-2">
<label for="data-popup-place" class="col-form-label col-form-label-sm col-2">точка</label>
<div class="col-10">
<?php
if ($places) {
?>
<select id="data-popup-place" class="custom-select custom-select-sm">
<?php
foreach ($places as $value) {
?>
<option value="<?php echo $value['id']; ?>"><?php echo $value['address']; ?></option>
<?php
}
?>
</select>
<?php
} else if (false === $places) {
?>
<div class="alert alert-danger">Internal Server Error</div>
<?php
} else if (empty($places)) {
?>
<div class="alert alert-warning">у вас нет точек</div>
<?php
}
?>
</div>
</div>
<div class="form-group row mb-2">
<label for="data-popup-date" class="col-form-label col-form-label-sm col-2">дата</label>
<div class="col-4">
<input disabled type="text" class="form-control form-control-sm text-center" id="data-popup-date" rel="datepicker" autocomplete="off" value="<?php echo date('d.m.Y'); ?>">
</div>
<label for="data-popup-amount" class="col-form-label col-form-label-sm col-2">сумма</label>
<div class="col-4">
<input type="text" class="form-control form-control-sm text-right" id="data-popup-amount">
</div>
</div>
</div>
<div class="modal-footer">
<a class="btn btn-outline-primary" href="javascript:void(saveData())">сохранить</a>
</div>
</div>
</div>
</div>
<?php
}
$script = 'data.' . $user->type . '.js';
?>
</div>
<div class="modal run"></div>
<script src="bootstrap/jquery.min.js"></script>
<script src="bootstrap/jquery.ui.min.js"></script>
<script src="bootstrap/popper.min.js"></script>
<script src="bootstrap/bootstrap.min.js"></script>
<script src="bootstrap/moment.min.js"></script>
<script src="bootstrap/air.datepicker.min.js"></script>
<script src="report.js?<?php echo fileatime('report.js'); ?>"></script>
<script src="<?php echo $script; ?>?<?php echo fileatime($script); ?>"></script>
</body>
</html>