index.php
4.41 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
<?php
/**
* @var ActiveDataProvider $dataProvider
* @var OrderSearch $searchModel
* @var View $this
*/
use artweb\artbox\ecommerce\models\Delivery;
use artweb\artbox\ecommerce\models\Label;
use artweb\artbox\ecommerce\models\OrderSearch;
use kartik\daterange\DateRangePicker;
use kartik\select2\Select2;
use yii\data\ActiveDataProvider;
use yii\helpers\Html;
use yii\grid\GridView;
use yii\helpers\Url;
use yii\web\View;
use yii\widgets\ActiveForm;
$this->title = 'Заказы';
$this->params[ 'breadcrumbs' ][] = $this->title;
$js = <<< JS
$('[name="OrderSearch[phone]"]').mask('+38(000)000-00-00', {
placeholder: '+38(___)___-__-__'
});
JS;
$this->registerJs($js, View::POS_READY);
?>
<h1>Заказы</h1>
<p>
<?= Html::a('Add order', [ 'create' ], [ 'class' => 'btn btn-success' ]) ?>
</p>
<?php
$searchForm = ActiveForm::begin(
[
'method' => 'GET',
'action' => Url::to([ 'order/index' ]),
'id' => 'search-form',
]
);
?>
<p>
<?php echo Html::submitButton(
'Search',
[
'class' => 'btn btn-primary',
]
) ?>
</p>
<?php
echo Select2::widget(
[
'model' => $searchModel,
'attribute' => 'label',
'data' => Label::find()
->joinWith('lang')
->select(['CONCAT(order_label.label,order_label_lang.title) AS name', 'id'])
->indexBy('id')
->asArray()
->column(),
'options' => [ 'placeholder' => 'Select a state ...' ],
'pluginOptions' => [
'allowClear' => true,
'multiple' => true,
],
]
);
?>
<br>
<?php
echo Select2::widget(
[
'model' => $searchModel,
'attribute' => 'delivery',
'data' => Delivery::find()
->joinWith('lang')
->select('order_delivery_lang.title, id')
->indexBy('id')
->asArray()
->column(),
'options' => [ 'placeholder' => 'Select a state ...' ],
'pluginOptions' => [
'allowClear' => true,
'multiple' => true,
],
]
);
?>
<p>
<?php
echo GridView::widget(
[
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
'columns' => [
[
'attribute' => 'id',
'filter' => $searchForm->field($searchModel, 'id')
->textInput(),
],
[
'attribute' => 'created_at',
'format' => 'date',
'filter' => $searchForm->field($searchModel, 'date_range')
->widget(
DateRangePicker::className(),
[
'convertFormat' => false,
'pluginOptions' => [
'locale' => [
'format' => 'D-M-Y',
'separator' => ' to ',
],
'opens' => 'left',
],
]
)
->label(false)
->render(),
],
'name',
'phone',
'status',
[
'class' => 'yii\grid\ActionColumn',
],
],
]
);
?>
</p>
<?php
ActiveForm::end();
?>