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;
|
1ac35977
Alexey Boroda
-Staistics started
|
13
|
use yii\web\View;
|
44747138
Alexey Boroda
-Default statisti...
|
14
|
use yiier\chartjs\ChartJs;
|
1ac35977
Alexey Boroda
-Staistics started
|
15
16
|
/**
|
44747138
Alexey Boroda
-Default statisti...
|
17
18
|
* @var View $this
* @var Label[] $labels
|
29257441
Alexey Boroda
-Manager filter o...
|
19
|
* @var User[] $managers
|
44747138
Alexey Boroda
-Default statisti...
|
20
21
|
* @var array $labelStatistics
* @var array $rejectionStatistics
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
22
|
* @var ActiveDataProvider $dataProvider
|
cbc8daa9
Alexey Boroda
-Order history ready
|
23
24
25
|
* @var array $labelChartData1
* @var array $labelChartData2
* @var array $labelChartData3
|
29257441
Alexey Boroda
-Manager filter o...
|
26
27
|
* @var array $rejectChartData1
* @var array $rejectChartData2
|
44747138
Alexey Boroda
-Default statisti...
|
28
29
|
* @var string $dateValue
* @var int | boolean $dataLabel
|
29257441
Alexey Boroda
-Manager filter o...
|
30
|
* @var int | boolean $dataManager
|
1ac35977
Alexey Boroda
-Staistics started
|
31
|
*/
|
29257441
Alexey Boroda
-Manager filter o...
|
32
|
|
5c177682
Alexey Boroda
-Order history ready
|
33
34
35
|
$js = <<< JS
$('[data-toggle="popover"]').popover();
JS;
|
29257441
Alexey Boroda
-Manager filter o...
|
36
37
|
$this->registerJs($js, View::POS_READY);
|
1ac35977
Alexey Boroda
-Staistics started
|
38
39
40
41
|
?>
<div class="box box-default">
<div class="box-header with-border">
|
cbc8daa9
Alexey Boroda
-Order history ready
|
42
|
<h3 class="box-title">Поиск заказов</h3>
|
1ac35977
Alexey Boroda
-Staistics started
|
43
44
45
46
47
|
<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 ...
|
48
49
50
51
52
|
<?= Html::beginForm(
[ '/ecommerce/statistics' ],
'get'
) ?>
<div class="row">
|
29257441
Alexey Boroda
-Manager filter o...
|
53
|
<div class="col-md-3">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
54
55
56
|
<?= DateRangePicker::widget(
[
'name' => 'date_range',
|
44747138
Alexey Boroda
-Default statisti...
|
57
|
'value' => $dateValue,
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
58
59
60
61
62
63
64
65
66
|
'pluginOptions' => [
'locale' => [
'format' => 'DD-MM-Y',
'separator' => ' : ',
],
],
]
) ?>
</div>
|
29257441
Alexey Boroda
-Manager filter o...
|
67
|
<div class="col-md-4">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
68
69
|
<?= Select2::widget(
[
|
cbc8daa9
Alexey Boroda
-Order history ready
|
70
71
72
|
'name' => 'label',
'value' => $dataLabel,
'data' => ArrayHelper::map(
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
73
74
75
76
77
78
79
80
|
$labels,
function($model) {
return $model->id;
},
function($model) {
return $model->lang->title;
}
),
|
cbc8daa9
Alexey Boroda
-Order history ready
|
81
|
'options' => [
|
29257441
Alexey Boroda
-Manager filter o...
|
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
'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 ...
|
106
|
],
|
44747138
Alexey Boroda
-Default statisti...
|
107
|
'pluginOptions' => [
|
cbc8daa9
Alexey Boroda
-Order history ready
|
108
|
'allowClear' => true,
|
44747138
Alexey Boroda
-Default statisti...
|
109
|
],
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
110
111
112
113
114
|
]
) ?>
</div>
<div class="col-md-2">
<?= Html::submitButton(
|
cbc8daa9
Alexey Boroda
-Order history ready
|
115
|
'Поиск',
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
116
117
118
119
120
121
|
[
'class' => 'btn btn-success',
]
) ?>
</div>
</div>
|
c130fad8
Alexey Boroda
-Yml fix
|
122
|
<?= Html::endForm() ?>
|
1ac35977
Alexey Boroda
-Staistics started
|
123
124
|
</div><!-- /.box-body -->
</div><!-- /.box -->
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
125
126
127
|
<div class="box box-default">
<div class="box-header with-border">
|
29257441
Alexey Boroda
-Manager filter o...
|
128
|
<h3 class="box-title">Метки, статистика за <?= empty($dateValue) ? 'всё время' : $dateValue ?></h3>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
<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...
|
143
144
145
146
|
$total_count = 0;
$total_sum = 0;
$total_products = 0;
$total_unique = 0;
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
147
|
foreach ($labelStatistics as $name => $statistic) {
|
d9fd9ce5
Alexey Boroda
-Total for statis...
|
148
149
150
151
|
$total_count += $statistic[ 'count' ];
$total_sum += $statistic[ 'sum' ];
$total_products += $statistic[ 'products' ];
$total_unique += $statistic[ 'unique' ];
|
44747138
Alexey Boroda
-Default statisti...
|
152
153
154
155
156
157
158
|
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...
|
159
160
161
162
163
164
165
166
167
|
}
?>
<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 ...
|
168
|
</table>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
169
|
</div><!-- /.box-body -->
|
29257441
Alexey Boroda
-Manager filter o...
|
170
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
171
172
173
174
175
|
<div class="box-footer">
<div class="nav-tabs-custom">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
|
29257441
Alexey Boroda
-Manager filter o...
|
176
177
|
<li role="presentation" class="active">
<a href="#home" aria-controls="home" role="tab" data-toggle="tab">Заказы</a></li>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
178
|
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Сумма</a></li>
|
29257441
Alexey Boroda
-Manager filter o...
|
179
180
|
<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Товары</a>
</li>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
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
|
</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 ...
|
264
265
266
267
|
</div><!-- /.box -->
<div class="box box-default">
<div class="box-header with-border">
|
29257441
Alexey Boroda
-Manager filter o...
|
268
|
<h3 class="box-title">Причины отказа, статистика за <?= empty($dateValue) ? 'всё время' : $dateValue ?></h3>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
269
270
271
272
273
274
275
276
277
278
279
280
281
|
<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...
|
282
283
284
285
286
287
288
289
290
|
echo Html::tag(
'tr',
Html::tag('td', $name) . Html::tag('td', $statistic[ 'count' ]) . Html::tag(
'td',
$statistic[ 'sum' ]
)
);
}
?>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
291
292
|
</table>
</div><!-- /.box-body -->
|
29257441
Alexey Boroda
-Manager filter o...
|
293
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
294
295
|
<div class="box-footer">
<div class="nav-tabs-custom">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
296
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
297
298
|
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
|
29257441
Alexey Boroda
-Manager filter o...
|
299
300
|
<li role="presentation" class="active">
<a href="#count" aria-controls="count" role="tab" data-toggle="tab">Заказы</a></li>
|
cbc8daa9
Alexey Boroda
-Order history ready
|
301
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
|
<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 ...
|
344
|
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
|
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
</div>
</div>
</div>
|
29257441
Alexey Boroda
-Manager filter o...
|
360
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
|
</div><!-- /.box -->
<div class="box box-default">
<div class="box-header with-border">
<h3 class="box-title">Заказы</h3>
<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 ...
|
377
378
379
380
381
382
383
|
[
'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
|
384
|
'name',
|
5c177682
Alexey Boroda
-Order history ready
|
385
|
[
|
29257441
Alexey Boroda
-Manager filter o...
|
386
|
'label' => 'Товары',
|
5c177682
Alexey Boroda
-Order history ready
|
387
|
'content' => function(Order $model) {
|
29257441
Alexey Boroda
-Manager filter o...
|
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
|
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
|
424
|
}
|
29257441
Alexey Boroda
-Manager filter o...
|
425
|
},
|
5c177682
Alexey Boroda
-Order history ready
|
426
|
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
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
|
'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 -->
|