1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use hipanel\helpers\Url; |
4
|
|
|
use hipanel\models\Ref; |
5
|
|
|
use hipanel\modules\client\widgets\combo\SellerCombo; |
6
|
|
|
use hipanel\modules\finance\models\Plan; |
7
|
|
|
use hipanel\modules\finance\models\PlanAttribute; |
8
|
|
|
use hipanel\widgets\DynamicFormWidget; |
9
|
|
|
use hipanel\widgets\RefCombo; |
10
|
|
|
use yii\bootstrap\ActiveForm; |
11
|
|
|
use yii\helpers\Html; |
12
|
|
|
use yii\web\View; |
13
|
|
|
|
14
|
|
|
/** |
15
|
|
|
* @var View $this |
16
|
|
|
* @var Plan $model |
17
|
|
|
*/ |
18
|
|
|
|
19
|
|
|
$this->registerCss(' |
20
|
|
|
#plan-form .container-items .form-group { position: relative; } |
21
|
|
|
#plan-form .container-items .help-block-error { position: absolute; top: 46px; } |
22
|
|
|
'); |
23
|
|
|
$this->registerJs(/** @lang ECMAScript 6 */ ' |
24
|
|
|
$(".remove-attribute").click(() => { |
25
|
|
|
if ($(".attribute-item").length === 1) { |
26
|
|
|
$(".container-items :input").val(""); |
27
|
|
|
} |
28
|
|
|
}); |
29
|
|
|
'); |
30
|
|
|
|
31
|
|
|
$customAttributes = empty($model->getPlanAttributes()) ? [new PlanAttribute()] : $model->getPlanAttributes(); |
32
|
|
|
?> |
33
|
|
|
|
34
|
|
|
<?php $form = ActiveForm::begin([ |
35
|
|
|
'id' => 'plan-form', |
36
|
|
|
'validationUrl' => Url::toRoute(['validate-form', 'scenario' => $model->scenario]), |
37
|
|
|
]) ?> |
38
|
|
|
|
39
|
|
|
<div class="row"> |
40
|
|
|
<div class="col-md-4"> |
41
|
|
|
<div class="box box-widget"> |
42
|
|
|
<div class="box-header with-border"> |
43
|
|
|
<h4 class="box-title"> |
44
|
|
|
<?= Yii::t('hipanel:finance', 'Tariff plan') ?> |
45
|
|
|
</h4> |
46
|
|
|
</div> |
47
|
|
|
<div class="box-body"> |
48
|
|
|
<?php if (!$model->isNewRecord) : ?> |
49
|
|
|
<?= Html::activeHiddenInput($model, 'id') ?> |
50
|
|
|
<?php endif ?> |
51
|
|
|
<?= $form->field($model, 'name') ?> |
52
|
|
|
<?= $form->field($model, 'type')->dropDownList($model->typeOptions, ['prompt' => '--']) ?> |
53
|
|
|
<?= $form->field($model, 'client')->widget(SellerCombo::class) ?> |
54
|
|
|
<?= $form->field($model, 'currency')->widget(RefCombo::class, [ |
55
|
|
|
'gtype' => 'type,currency', |
56
|
|
|
'i18nDictionary' => 'hipanel', |
57
|
|
|
'findOptions' => [ |
58
|
|
|
'mapOptions' => ['to' => static fn(Ref $model) => strtoupper($model->name)], |
|
|
|
|
59
|
|
|
], |
60
|
|
|
]) ?> |
61
|
|
|
<?= $form->field($model, 'is_grouping')->checkbox() ?> |
62
|
|
|
<?= $form->field($model, 'note') ?> |
63
|
|
|
</div> |
64
|
|
|
</div> |
65
|
|
|
<?= Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success']) ?> |
66
|
|
|
|
67
|
|
|
<?= Html::button(Yii::t('hipanel', 'Cancel'), ['class' => 'btn btn-default', 'onclick' => 'history.go(-1)']) ?> |
68
|
|
|
</div> |
69
|
|
|
<div class="col-md-6"> |
70
|
|
|
<div class="box box-widget"> |
71
|
|
|
<div class="box-header with-border"> |
72
|
|
|
<h4 class="box-title"> |
73
|
|
|
<?= Yii::t('hipanel:finance', 'Attributes') ?> |
74
|
|
|
</h4> |
75
|
|
|
</div> |
76
|
|
|
<div class="box-body no-padding"> |
77
|
|
|
<?php DynamicFormWidget::begin([ |
78
|
|
|
'widgetContainer' => 'dynamicform_wrapper', |
79
|
|
|
'widgetBody' => '.container-items', |
80
|
|
|
'widgetItem' => '.attribute-item', |
81
|
|
|
'insertButton' => '.add-attribute', |
82
|
|
|
'deleteButton' => '.remove-attribute', |
83
|
|
|
'model' => $customAttributes[0], |
84
|
|
|
'formId' => 'plan-form', |
85
|
|
|
'formFields' => [ |
86
|
|
|
'name', |
87
|
|
|
'value', |
88
|
|
|
], |
89
|
|
|
]) ?> |
90
|
|
|
<table class="table table-striped table-condensed"> |
91
|
|
|
<thead> |
92
|
|
|
<tr> |
93
|
|
|
<th><?= Yii::t('hipanel:finance', 'Name') ?></th> |
94
|
|
|
<th><?= Yii::t('hipanel:finance', 'Value') ?></th> |
95
|
|
|
<th class="text-center" style="width: 90px;"> |
96
|
|
|
<button type="button" class="add-attribute btn bg-olive btn-sm" |
97
|
|
|
title="<?= Yii::t('hipanel', 'Add new') ?>"> |
98
|
|
|
<?= Html::tag('span', null, ['class' => 'fa fa-fw fa-plus']) ?> |
99
|
|
|
</button> |
100
|
|
|
</th> |
101
|
|
|
</tr> |
102
|
|
|
</thead> |
103
|
|
|
<tbody class="container-items"> |
104
|
|
|
<?php foreach ($customAttributes as $idx => $attribute): ?> |
105
|
|
|
<tr class="attribute-item"> |
106
|
|
|
<td class="text-center" style="vertical-align: middle"> |
107
|
|
|
<?= $form->field($attribute, "[{$idx}]name")->label('')->textInput(['maxlength' => true]) ?> |
108
|
|
|
</td> |
109
|
|
|
<td class="text-center" style="vertical-align: middle"> |
110
|
|
|
<?= $form->field($attribute, "[{$idx}]value")->label('')->textInput(['maxlength' => true]) ?> |
111
|
|
|
</td> |
112
|
|
|
<td class="text-center" style="vertical-align: middle"> |
113
|
|
|
<button type="button" class="remove-attribute btn btn-danger btn-sm" |
114
|
|
|
title="<?= Yii::t('hipanel', 'Remove') ?>"> |
115
|
|
|
<?= Html::tag('span', null, ['class' => 'fa fa-fw fa-minus']) ?> |
116
|
|
|
</button> |
117
|
|
|
</td> |
118
|
|
|
</tr> |
119
|
|
|
<?php endforeach ?> |
120
|
|
|
</tbody> |
121
|
|
|
</table> |
122
|
|
|
<?php DynamicFormWidget::end() ?> |
123
|
|
|
</div> |
124
|
|
|
</div> |
125
|
|
|
</div> |
126
|
|
|
</div> |
127
|
|
|
|
128
|
|
|
<?php ActiveForm::end() ?> |
129
|
|
|
|