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;
|
c130fad8
Alexey Boroda
-Yml fix
|
4
|
use kartik\daterange\DateRangePicker;
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
5
|
use kartik\grid\GridView;
|
c130fad8
Alexey Boroda
-Yml fix
|
6
|
use kartik\select2\Select2;
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
7
8
|
use yii\data\ActiveDataProvider;
use yii\helpers\ArrayHelper;
|
c130fad8
Alexey Boroda
-Yml fix
|
9
|
use yii\helpers\Html;
|
44747138
Alexey Boroda
-Default statisti...
|
10
|
use yii\helpers\StringHelper;
|
1ac35977
Alexey Boroda
-Staistics started
|
11
|
use yii\web\View;
|
44747138
Alexey Boroda
-Default statisti...
|
12
|
use yiier\chartjs\ChartJs;
|
1ac35977
Alexey Boroda
-Staistics started
|
13
14
|
/**
|
44747138
Alexey Boroda
-Default statisti...
|
15
16
17
18
|
* @var View $this
* @var Label[] $labels
* @var array $labelStatistics
* @var array $rejectionStatistics
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
19
|
* @var ActiveDataProvider $dataProvider
|
cbc8daa9
Alexey Boroda
-Order history ready
|
20
21
22
23
24
|
* @var array $labelChartData1
* @var array $labelChartData2
* @var array $labelChartData3
* @var array $rejectChartData1
* @var array $rejectChartData2
|
44747138
Alexey Boroda
-Default statisti...
|
25
26
|
* @var string $dateValue
* @var int | boolean $dataLabel
|
1ac35977
Alexey Boroda
-Staistics started
|
27
28
|
*/
|
5c177682
Alexey Boroda
-Order history ready
|
29
30
31
32
33
|
$js = <<< JS
$('[data-toggle="popover"]').popover();
JS;
$this->registerJs($js, View::POS_READY);
|
1ac35977
Alexey Boroda
-Staistics started
|
34
35
36
37
|
?>
<div class="box box-default">
<div class="box-header with-border">
|
cbc8daa9
Alexey Boroda
-Order history ready
|
38
|
<h3 class="box-title">Поиск заказов</h3>
|
1ac35977
Alexey Boroda
-Staistics started
|
39
40
41
42
43
|
<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 ...
|
44
45
46
47
48
49
50
51
52
|
<?= Html::beginForm(
[ '/ecommerce/statistics' ],
'get'
) ?>
<div class="row">
<div class="col-md-4">
<?= DateRangePicker::widget(
[
'name' => 'date_range',
|
44747138
Alexey Boroda
-Default statisti...
|
53
|
'value' => $dateValue,
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
54
55
56
57
58
59
60
61
62
63
64
65
|
'pluginOptions' => [
'locale' => [
'format' => 'DD-MM-Y',
'separator' => ' : ',
],
],
]
) ?>
</div>
<div class="col-md-6">
<?= Select2::widget(
[
|
cbc8daa9
Alexey Boroda
-Order history ready
|
66
67
68
|
'name' => 'label',
'value' => $dataLabel,
'data' => ArrayHelper::map(
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
69
70
71
72
73
74
75
76
|
$labels,
function($model) {
return $model->id;
},
function($model) {
return $model->lang->title;
}
),
|
cbc8daa9
Alexey Boroda
-Order history ready
|
77
|
'options' => [
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
78
79
|
'placeholder' => 'Все',
],
|
44747138
Alexey Boroda
-Default statisti...
|
80
|
'pluginOptions' => [
|
cbc8daa9
Alexey Boroda
-Order history ready
|
81
|
'allowClear' => true,
|
44747138
Alexey Boroda
-Default statisti...
|
82
|
],
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
83
84
85
86
87
|
]
) ?>
</div>
<div class="col-md-2">
<?= Html::submitButton(
|
cbc8daa9
Alexey Boroda
-Order history ready
|
88
|
'Поиск',
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
89
90
91
92
93
94
|
[
'class' => 'btn btn-success',
]
) ?>
</div>
</div>
|
c130fad8
Alexey Boroda
-Yml fix
|
95
|
<?= Html::endForm() ?>
|
1ac35977
Alexey Boroda
-Staistics started
|
96
97
|
</div><!-- /.box-body -->
</div><!-- /.box -->
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
98
99
100
|
<div class="box box-default">
<div class="box-header with-border">
|
cbc8daa9
Alexey Boroda
-Order history ready
|
101
|
<h3 class="box-title">Метки, статистика за <?=empty($dateValue) ? 'всё время' : $dateValue ?></h3>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
|
<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
foreach ($labelStatistics as $name => $statistic) {
|
44747138
Alexey Boroda
-Default statisti...
|
117
118
119
120
121
122
123
124
|
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' ])
);
} ?>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
125
|
</table>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
126
|
</div><!-- /.box-body -->
|
cbc8daa9
Alexey Boroda
-Order history ready
|
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
|
<div class="box-footer">
<div class="nav-tabs-custom">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#home" aria-controls="home" role="tab" data-toggle="tab">Заказы</a></li>
<li role="presentation"><a href="#profile" aria-controls="profile" role="tab" data-toggle="tab">Сумма</a></li>
<li role="presentation"><a href="#messages" aria-controls="messages" role="tab" data-toggle="tab">Товары</a></li>
</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 ...
|
219
220
221
222
|
</div><!-- /.box -->
<div class="box box-default">
<div class="box-header with-border">
|
cbc8daa9
Alexey Boroda
-Order history ready
|
223
|
<h3 class="box-title">Причины отказа, статистика за <?=empty($dateValue) ? 'всё время' : $dateValue ?></h3>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
224
225
226
227
228
229
230
231
232
233
234
235
236
|
<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...
|
237
238
239
240
241
242
243
244
245
|
echo Html::tag(
'tr',
Html::tag('td', $name) . Html::tag('td', $statistic[ 'count' ]) . Html::tag(
'td',
$statistic[ 'sum' ]
)
);
}
?>
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
246
247
|
</table>
</div><!-- /.box-body -->
|
cbc8daa9
Alexey Boroda
-Order history ready
|
248
249
250
|
<div class="box-footer">
<div class="nav-tabs-custom">
|
ee0e1df5
Alexey Boroda
-Statistics half ...
|
251
|
|
cbc8daa9
Alexey Boroda
-Order history ready
|
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
288
289
290
291
292
293
294
295
296
297
|
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist">
<li role="presentation" class="active"><a href="#count" aria-controls="count" role="tab" data-toggle="tab">Заказы</a></li>
<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 ...
|
298
|
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
299
300
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
|
'scales' => [
'xAxes' => [
[
'display' => false,
],
],
],
],
]
); ?>
</div>
</div>
</div>
</div>
</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',
'created_at:datetime',
'name',
|
5c177682
Alexey Boroda
-Order history ready
|
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
|
[
'label' => 'Товары',
'content' => function(Order $model) {
if (empty($model->products)) {
return '';
} else {
$content = '';
$i = 0;
foreach ($model->products as $product) {
$i ++;
$content .= Html::a(
$product->sku,
'#',
[
'onclick' => 'event.preventDefault();',
'data-toggle' => 'popover',
'data-placement' => 'right',
'data-html' => 'true',
'data-content' => Html::img(
$product->productVariant->imageUrl,
[
'class' => 'img-rounded',
]
) . Html::tag('p', $product->product_name),
]
);
if ($i != count($model->products) ) {
$content .= ', ';
}
if ($i % 2 == 0) {
$content .= '<br>';
}
}
return $content;
}
}
],
|
cbc8daa9
Alexey Boroda
-Order history ready
|
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
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
424
425
426
427
428
429
430
431
432
433
434
435
436
437
|
'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 -->
|