_form.php
4.43 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
<?php
use yii\bootstrap\Html;
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
*/
?>
<div class="order-form">
<?php $form = ActiveForm::begin(); ?>
<?php
if ($model->isNewRecord) {
echo $form->field($model, 'user_id')
->textInput();
}
?>
<?= $form->field($model, 'name')
->textInput([ 'maxlength' => true ]) ?>
<?= $form->field($model, 'phone')
->textInput([ 'maxlength' => true ]) ?>
<?= $form->field($model, 'email')
->textInput([ 'maxlength' => true ]) ?>
<?= $form->field($model, 'city')
->textInput([ 'maxlength' => true ]) ?>
<?= $form->field($model, 'address')
->textInput([ 'maxlength' => true ]) ?>
<?= $form->field($model, 'comment')
->textInput([ 'maxlength' => true ]) ?>
<?= $form->field($model, 'label_id')
->dropDownList($labels) ?>
<?= $form->field($model, 'delivery_id')
->dropDownList($deliveries) ?>
<?= $form->field($model, 'payment_id')
->dropDownList($payments) ?>
<?php
if (!$model->isNewRecord) {
?>
<div class="order-product-container">
<div class="row strong">
<div class="col-md-4">
<?php
echo Html::tag('strong', \Yii::t('order', 'Product'));
?>
</div>
<div class="col-md-4">
<?php
echo Html::tag('strong', \Yii::t('order', 'Price'));
?>
</div>
<div class="col-md-4">
<?php
echo Html::tag('strong', \Yii::t('order', 'Count'));
?>
</div>
</div>
<?php
foreach ($model->orderProducts as $index => $orderProduct) {
?>
<div class="row row-order-product">
<div class="col-md-4">
<?php
echo $form->field($orderProduct, "[$index]variant_id")
->hiddenInput()
->label(false);
echo $orderProduct->variant->product->lang->title . '(' . $orderProduct->variant->sku . ')';
?>
</div>
<div class="col-md-4">
<?php echo $orderProduct->price; ?>
</div>
<div class="col-md-3">
<?php
echo $form->field($orderProduct, "[$index]count")
->textInput()
->label(false);
?>
</div>
<div class="col-md-1">
<?php
echo Html::a(
Html::icon(
'trash-o',
[
'prefix' => 'fa fa-',
]
),
'#',
[
'class' => 'remove-order-product',
]
)
?>
</div>
</div>
<?php
}
?>
<div class="row">
<div class="col-md-8">
</div>
<div class="col-md-4">
</div>
</div>
</div>
<?php
}
?>
<div class="form-group">
<?= Html::submitButton(
$model->isNewRecord ? Yii::t('order', 'Create') : Yii::t('order', 'Update'),
[ 'class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary' ]
) ?>
</div>
<?php ActiveForm::end(); ?>
</div>