1ac35977
Alexey Boroda
-Staistics started
|
1
|
<?php
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
2
|
use artweb\artbox\ecommerce\models\Label;
|
44747138
Alexey Boroda
-Default statisti...
|
3
|
use artweb\artbox\ecommerce\models\Order;
|
29257441
Alexey Boroda
-Manager filter o...
|
4
5
|
use artweb\artbox\ecommerce\models\ProductVariant;
use common\models\User;
|
c130fad8
Alexey Boroda
-Yml fix
|
6
|
use kartik\daterange\DateRangePicker;
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
7
|
use kartik\grid\GridView;
|
c130fad8
Alexey Boroda
-Yml fix
|
8
|
use kartik\select2\Select2;
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
9
10
|
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
|
c130fad8
Alexey Boroda
-Yml fix
|
11
|
use yii\helpers\Html;
|
44747138
Alexey Boroda
-Default statisti...
|
12
|
use yii\helpers\StringHelper;
|
d7331490
Alexey Boroda
-Export ready
|
13
|
use yii\helpers\Url;
|
1ac35977
Alexey Boroda
-Staistics started
|
14
|
use yii\web\View;
|
44747138
Alexey Boroda
-Default statisti...
|
15
|
use yiier\chartjs\ChartJs;
|
1ac35977
Alexey Boroda
-Staistics started
|
16
17
|
/**
|
44747138
Alexey Boroda
-Default statisti...
|
18
19
|
* @var View $this
* @var Label[] $labels
|
29257441
Alexey Boroda
-Manager filter o...
|
20
|
* @var User[] $managers
|
44747138
Alexey Boroda
-Default statisti...
|
21
22
|
* @var array $labelStatistics
* @var array $rejectionStatistics
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
23
|
* @var ActiveDataProvider $dataProvider
|
cbc8daa9
Alexey Boroda
-Order history ready
|
24
25
26
|
* @var array $labelChartData1
* @var array $labelChartData2
* @var array $labelChartData3
|
29257441
Alexey Boroda
-Manager filter o...
|
27
28
|
* @var array $rejectChartData1
* @var array $rejectChartData2
|
44747138
Alexey Boroda
-Default statisti...
|
29
30
|
* @var string $dateValue
* @var int | boolean $dataLabel
|
29257441
Alexey Boroda
-Manager filter o...
|
31
|
* @var int | boolean $dataManager
|
1ac35977
Alexey Boroda
-Staistics started
|
32
|
*/
|
d7331490
Alexey Boroda
-Export ready
|
33
34
35
36
37
|
$this->registerJsFile('/admin/js/statistics.js', [
'position' => View::POS_END,
'depends' => 'yii\web\JqueryAsset'
]);
|
29257441
Alexey Boroda
-Manager filter o...
|
38
|
|
1ac35977
Alexey Boroda
-Staistics started
|
39
40
41
42
|
?>
<div class="box box-default">
<div class="box-header with-border">
|
cbc8daa9
Alexey Boroda
-Order history ready
|
43
|
<h3 class="box-title">Поиск заказов</h3>
|
1ac35977
Alexey Boroda
-Staistics started
|
44
45
46
47
48
|
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box-tools -->
</div><!-- /.box-header -->
<div class="box-body">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
49
50
51
52
53
|
<?= Html::beginForm(
[ '/ecommerce/statistics' ],
'get'
) ?>
<div class="row">
|
29257441
Alexey Boroda
-Manager filter o...
|
54
|
<div class="col-md-3">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
55
56
57
|
<?= DateRangePicker::widget(
[
'name' => 'date_range',
|
44747138
Alexey Boroda
-Default statisti...
|
58
|
'value' => $dateValue,
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
59
60
61
62
63
64
65
66
67
|
'pluginOptions' => [
'locale' => [
'format' => 'DD-MM-Y',
'separator' => ' : ',
],
],
]
) ?>
</div>
|
29257441
Alexey Boroda
-Manager filter o...
|
68
|
<div class="col-md-4">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
69
70
|
<?= Select2::widget(
[
|
cbc8daa9
Alexey Boroda
-Order history ready
|
71
72
73
|
'name' => 'label',
'value' => $dataLabel,
'data' => ArrayHelper::map(
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
74
75
76
77
78
79
80
81
|
$labels,
function($model) {
return $model->id;
},
function($model) {
return $model->lang->title;
}
),
|
cbc8daa9
Alexey Boroda
-Order history ready
|
82
|
'options' => [
|
29257441
Alexey Boroda
-Manager filter o...
|
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
'placeholder' => 'Все метки',
],
'pluginOptions' => [
'allowClear' => true,
],
]
) ?>
</div>
<div class="col-md-3">
<?= Select2::widget(
[
'name' => 'manager',
'value' => $dataManager,
'data' => ArrayHelper::map(
$managers,
function(User $model) {
return $model->id;
},
function(User $model) {
return $model->username;
}
),
'options' => [
'placeholder' => 'Все менеджеры',
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
107
|
],
|
44747138
Alexey Boroda
-Default statisti...
|
108
|
'pluginOptions' => [
|
cbc8daa9
Alexey Boroda
-Order history ready
|
109
|
'allowClear' => true,
|
44747138
Alexey Boroda
-Default statisti...
|
110
|
],
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
111
112
113
114
115
|
]
) ?>
</div>
<div class="col-md-2">
<?= Html::submitButton(
|
cbc8daa9
Alexey Boroda
-Order history ready
|
116
|
'Поиск',
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
117
118
119
120
121
122
|
[
'class' => 'btn btn-success',
]
) ?>
</div>
</div>
|
c130fad8
Alexey Boroda
-Yml fix
|
123
|
<?= Html::endForm() ?>
|
1ac35977
Alexey Boroda
-Staistics started
|
124
125
|
</div><!-- /.box-body -->
</div><!-- /.box -->
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
126
127
128
|
<div class="box box-default">
<div class="box-header with-border">
|
29257441
Alexey Boroda
-Manager filter o...
|
129
|
<h3 class="box-title">Метки, статистика за <?= empty($dateValue) ? 'всё время' : $dateValue ?></h3>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box-tools -->
</div><!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tr>
<td><b>Метка</b></td>
<td><b>Заказов, шт.</b></td>
<td><b>На сумму, грн.</b></td>
<td><b>Заказано товаров, шт.</b></td>
<td><b>Уникальных товаров, шт.</b></td>
</tr>
<?php
|
d9fd9ce5
Alexey Boroda
-Total for statis...
|
144
145
146
147
|
$total_count = 0;
$total_sum = 0;
$total_products = 0;
$total_unique = 0;
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
148
|
foreach ($labelStatistics as $name => $statistic) {
|
d9fd9ce5
Alexey Boroda
-Total for statis...
|
149
150
151
152
|
$total_count += $statistic[ 'count' ];
$total_sum += $statistic[ 'sum' ];
$total_products += $statistic[ 'products' ];
$total_unique += $statistic[ 'unique' ];
|
44747138
Alexey Boroda
-Default statisti...
|
153
154
155
156
157
158
159
|
echo Html::tag(
'tr',
Html::tag('td', $name) . Html::tag('td', $statistic[ 'count' ]) . Html::tag(
'td',
$statistic[ 'sum' ]
) . Html::tag('td', $statistic[ 'products' ]) . Html::tag('td', $statistic[ 'unique' ])
);
|
d9fd9ce5
Alexey Boroda
-Total for statis...
|
160
161
162
163
164
165
166
167
168
|
}
?>
<tr>
<td><b>Всего</b></td>
<td><b><?=$total_count?></b></td>
<td><b><?=$total_sum?></b></td>
<td><b><?=$total_products?></b></td>
<td><b><?=$total_unique?></b></td>
</tr>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
169
|
</table>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
170
|
</div><!-- /.box-body -->
|
29257441
Alexey Boroda
-Manager filter o...
|
171
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
172
173
174
175
176
|
<div class="box-footer">
<div class="nav-tabs-custom">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
|
29257441
Alexey Boroda
-Manager filter o...
|
177
178
|
<li role="presentation" class="active">
<a href="#home" aria-controls="home" role="tab" data-toggle="tab">Заказы</a></li>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
179
|
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Сумма</a></li>
|
29257441
Alexey Boroda
-Manager filter o...
|
180
181
|
<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Товары</a>
</li>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
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
|
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="home">
<?= ChartJs::widget(
[
'type' => 'bar',
'options' => [
'height' => 200,
'width' => 600,
],
'data' => $labelChartData1,
'clientOptions' => [
'title' => [
'display' => true,
'text' => 'Статистика меток',
],
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
<div role="tabpanel" class="tab-pane" id="profile">
<?= ChartJs::widget(
[
'type' => 'bar',
'options' => [
'height' => 200,
'width' => 600,
],
'data' => $labelChartData2,
'clientOptions' => [
'title' => [
'display' => true,
'text' => 'Статистика меток',
],
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
<div role="tabpanel" class="tab-pane" id="messages">
<?= ChartJs::widget(
[
'type' => 'bar',
'options' => [
'height' => 200,
'width' => 600,
],
'data' => $labelChartData3,
'clientOptions' => [
'title' => [
'display' => true,
'text' => 'Статистика меток',
],
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
</div>
</div>
</div>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
265
266
267
268
|
</div><!-- /.box -->
<div class="box box-default">
<div class="box-header with-border">
|
29257441
Alexey Boroda
-Manager filter o...
|
269
|
<h3 class="box-title">Причины отказа, статистика за <?= empty($dateValue) ? 'всё время' : $dateValue ?></h3>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
270
271
272
273
274
275
276
277
278
279
280
281
282
|
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box-tools -->
</div><!-- /.box-header -->
<div class="box-body table-responsive no-padding">
<table class="table table-hover">
<tr>
<td><b>Причина</b></td>
<td><b>Заказов, шт.</b></td>
<td><b>На сумму, грн.</b></td>
</tr>
<?php
foreach ($rejectionStatistics as $name => $statistic) {
|
44747138
Alexey Boroda
-Default statisti...
|
283
284
285
286
287
288
289
290
291
|
echo Html::tag(
'tr',
Html::tag('td', $name) . Html::tag('td', $statistic[ 'count' ]) . Html::tag(
'td',
$statistic[ 'sum' ]
)
);
}
?>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
292
293
|
</table>
</div><!-- /.box-body -->
|
29257441
Alexey Boroda
-Manager filter o...
|
294
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
295
296
|
<div class="box-footer">
<div class="nav-tabs-custom">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
297
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
298
299
|
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
|
29257441
Alexey Boroda
-Manager filter o...
|
300
301
|
<li role="presentation" class="active">
<a href="#count" aria-controls="count" role="tab" data-toggle="tab">Заказы</a></li>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
|
<li role="presentation"><a href="#sum" aria-controls="sum" role="tab" data-toggle="tab">Сумма</a></li>
</ul>
<!-- Tab panes -->
<div class="tab-content">
<div role="tabpanel" class="tab-pane active" id="count">
<?= ChartJs::widget(
[
'type' => 'bar',
'options' => [
'height' => 200,
'width' => 600,
],
'data' => $rejectChartData1,
'clientOptions' => [
'title' => [
'display' => true,
'text' => 'Статистика отказов',
],
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
<div role="tabpanel" class="tab-pane" id="sum">
<?= ChartJs::widget(
[
'type' => 'bar',
'options' => [
'height' => 200,
'width' => 600,
],
'data' => $rejectChartData2,
'clientOptions' => [
'title' => [
'display' => true,
'text' => 'Статистика отказов',
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
345
|
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
</div>
</div>
</div>
|
29257441
Alexey Boroda
-Manager filter o...
|
361
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
362
363
|
</div><!-- /.box -->
|
d7331490
Alexey Boroda
-Export ready
|
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
|
<p>
<?php
echo Html::button(Html::tag('i', '', [
'class' => 'glyphicon glyphicon-cog',
]) . ' Создать выгрузку', [
'class' => 'btn bg-navy',
'id' => 'generate-button',
'data-link' => Url::to([
'export',
'date_range' => $dateValue,
'label' => $dataLabel,
'manager' => $dataManager,
])
])
?>
</p>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
380
381
382
|
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Заказы</h3>
|
d7331490
Alexey Boroda
-Export ready
|
383
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
384
385
386
387
388
389
390
391
392
393
|
<div class="box-tools pull-right">
<button class="btn btn-box-tool" data-widget="collapse"><i class="fa fa-minus"></i></button>
</div><!-- /.box-tools -->
</div><!-- /.box-header -->
<div class="box-body table-responsive">
<?= GridView::widget(
[
'dataProvider' => $dataProvider,
'columns' => [
'id',
|
ca6a6b40
Alexey Boroda
-Date format for ...
|
394
395
396
397
398
399
400
|
[
'label' => 'Дата добавления',
'content' => function(Order $model) {
return \Yii::$app->formatter->asDate($model->created_at) .
'<br>' . \Yii::$app->formatter->asTime($model->created_at);
},
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
401
|
'name',
|
5c177682
Alexey Boroda
-Order history ready
|
402
|
[
|
29257441
Alexey Boroda
-Manager filter o...
|
403
|
'label' => 'Товары',
|
5c177682
Alexey Boroda
-Order history ready
|
404
|
'content' => function(Order $model) {
|
29257441
Alexey Boroda
-Manager filter o...
|
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
|
if (empty($model->products)) {
return '';
} else {
$content = '';
$i = 0;
foreach ($model->products as $product) {
if(empty($product->productVariant)){
$image = '';
} else {
$image = $product->productVariant->imageUrl;
}
$i++;
$content .= Html::a(
$product->sku,
'#',
[
'onclick' => 'event.preventDefault();',
'data-toggle' => 'popover',
'data-placement' => 'right',
'data-html' => 'true',
'data-content' => Html::img(
$image,
[
'class' => 'img-rounded',
]
) . Html::tag('p', $product->product_name),
]
);
if ($i != count($model->products)) {
$content .= ', ';
}
if ($i % 2 == 0) {
$content .= '<br>';
}
}
return $content;
|
5c177682
Alexey Boroda
-Order history ready
|
441
|
}
|
29257441
Alexey Boroda
-Manager filter o...
|
442
|
},
|
5c177682
Alexey Boroda
-Order history ready
|
443
|
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
|
'city',
[
'attribute' => 'orderLabel.label',
'label' => 'Метка',
],
'total',
[
'attribute' => 'reason',
'content' => function($model) {
/**
* @var Order $model
*/
if (empty($model->reason)) {
return '';
} else {
return Order::REASONS[ $model->reason ];
}
},
],
[
'attribute' => 'manager.username',
'label' => 'Менеджер',
],
[
'attribute' => 'body',
'content' => function($model) {
/**
* @var Order $model
*/
if (empty($model->body)) {
return '';
} else {
return Html::a(
StringHelper::truncate($model->body, 10, '...'),
'#',
[
'data-toggle' => 'tooltip',
'title' => $model->body,
'onclick' => 'event.preventDefault();',
]
);
}
},
],
[
'content' => function($model) {
/**
* @var Order $model
*/
return Html::a(
Html::tag('i', '', [ 'class' => 'glyphicon glyphicon-eye-open' ]),
[
'/ecommerce/order/view',
'id' => $model->id,
],
[
'target' => '_blank',
'data-pjax' => '0',
]
);
},
],
],
]
) ?>
</div><!-- /.box-body -->
</div><!-- /.box -->
|