_form.php
8.04 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
<?php
use kartik\select2\Select2;
use yii\bootstrap\Html;
use yii\helpers\Url;
use yii\web\JsExpression;
use yii\widgets\ActiveForm;
/**
* @var \yii\web\View $this
* @var \artbox\order\models\Order $model
* @var array $labels
* @var array $deliveries
* @var array $payments
* @var ActiveForm $form
* @var bool $isCreate
*/
?>
<div class="order-form">
<?php $form = ActiveForm::begin(); ?>
<div class="x_panel">
<?php
// if ($model->isNewRecord) {
// echo $form->field($model, 'user_id')
// ->textInput();
// }
?>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'name')
->textInput([ 'maxlength' => true , 'value' => strip_tags($model->name)]) ?>
</div>
<div class="wrapp-blocks-edit-page">
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'phone')
->textInput([ 'maxlength' => true ]) ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'email')
->textInput([ 'maxlength' => true ]) ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'city')
->textInput([ 'maxlength' => true ]) ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'address')
->textInput([ 'maxlength' => true ]) ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'comment')
->textarea() ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'label_id')
->widget(Select2::className(),[
'options' => [
'placeholder' => \Yii::t('app', 'Выберите вариант метки'),
],
'data' => $labels,
'pluginOptions' => [
'allowClear' => true,
],
]) ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'delivery_id')
->widget(Select2::className(),[
'options' => [
'placeholder' => \Yii::t('app', 'Выберите вариант доставки'),
],
'data' => $deliveries,
'pluginOptions' => [
'allowClear' => true,
],
]) ?>
</div>
<div class="wrapp-blocks-edit-page">
<?= $form->field($model, 'payment_id')
->widget(Select2::className(),[
'options' => [
'placeholder' => \Yii::t('app', 'Выберите вариант оплаты'),
],
'data' => $payments,
'pluginOptions' => [
'allowClear' => true,
],
]) ?>
</div>
</div>
<div class="x_panel">
<div class="order-product-container wrapp-blocks-edit-page">
<div class="row">
<div class="col-xs-12">
<div class="row">
<div class="col-md-9">
<label>Добавить еще товар</label>
<?php
echo Select2::widget(
[
'name' => 'add-to-order',
'options' => [
'placeholder' => \Yii::t('order', 'Select product'),
],
'pluginOptions' => [
'allowClear' => true,
'minimumInputLength' => 3,
'language' => [
'errorLoading' => new JsExpression(
"function() {return '" . \Yii::t('order', 'Waiting for results') . "'; }"
),
],
'ajax' => [
'url' => Url::to([ 'product-list' ]),
'dataType' => 'json',
'data' => new JsExpression('function(params) { return {q:params.term}; }'),
],
'escapeMarkup' => new JsExpression('function (markup) { return markup; }'),
'templateResult' => new JsExpression('function(city) { return city.text; }'),
'templateSelection' => new JsExpression('function (city) { return city.text; }'),
],
'id' => 'add-to-order',
]
);
?>
</div>
<div class="col-md-2">
<?php
$idInput = 'count-to-order';
echo '<label for="'.$idInput.'">КОЛ-ВО</label>';
echo Html::textInput(
'count-to-order',
1,
[
'class' => 'form-control',
'id' => $idInput,
]
);
?>
</div>
<a class="variant-to-order btn btn-success add-goods-order" href="#">
<i class="fa fa-plus"></i>
</a>
</div>
</div>
</div>
<div id="order-product-pjax" class="row">
<div class="col-xs-12 order-goods-th"<?=$isCreate ? ' style="display: none;"' : ''?>>
<div class="row">
<div class="col-md-7">
<?php
echo Html::tag('label', \Yii::t('order', 'Product'));
?>
</div>
<div class="col-md-2">
<?php
echo Html::tag('label', \Yii::t('order', 'Price'));
?>
</div>
<div class="col-md-2">
<?php
echo Html::tag('label', \Yii::t('order', 'Count'));
?>
</div>
</div>
</div>
<div id="product-rows" class="col-xs-12">
<?php
$sum = 0;
if (!$model->isNewRecord) {
foreach ($model->orderProducts as $index => $orderProduct) {
$sum += ( $orderProduct->count * $orderProduct->price );
echo $this->render(
'_order_product',
[
'orderProduct' => $orderProduct,
'price' => $orderProduct->price,
'index' => $index,
'variant' => $orderProduct->variant,
'form' => $form,
]
);
}
}
?>
</div>
<?php
echo( " <div class='sum_all col-xs-12'>Итого: <strong id='total-sum'>" . $sum . "</strong></div>" );
?>
</div>
</div>
</div>
<div class="style buttons-page-wr">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('order', 'Create') : Yii::t('order', 'Update'),
[ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-success' ]
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>