1 | <?php |
||
2 | |||
3 | use hipanel\modules\client\widgets\combo\ClientCombo; |
||
4 | use hipanel\modules\finance\widgets\combo\PlanCombo; |
||
5 | use hipanel\modules\server\forms\HubSellForm; |
||
6 | use hipanel\modules\server\models\Server; |
||
7 | use hipanel\modules\server\widgets\HubNameBadge; |
||
8 | use hipanel\modules\server\widgets\ServerNameBadge; |
||
9 | use hipanel\widgets\DateTimePicker; |
||
10 | use yii\bootstrap\ActiveForm; |
||
11 | use yii\helpers\Html; |
||
12 | use yii\web\View; |
||
13 | |||
14 | /** |
||
15 | * @var View |
||
16 | * @var Server|HubSellForm $model |
||
17 | * @var Server[]|HubSellForm[] $models |
||
18 | * @var DateTime $defaultDateTime |
||
19 | * @var string $actionUrl |
||
20 | * @var string $validationUrl |
||
21 | */ |
||
22 | ?> |
||
23 | |||
24 | <div> |
||
25 | <!-- Nav tabs --> |
||
26 | <ul class="nav nav-tabs" role="tablist"> |
||
27 | <li role="presentation" class="active"> |
||
28 | <a href="#bulk" aria-controls="home" role="tab" |
||
29 | data-toggle="tab"><?= Yii::t('hipanel', 'Set for all') ?></a> |
||
30 | </li> |
||
31 | <li role="presentation"> |
||
32 | <a href="#by-one" aria-controls="profile" role="tab" |
||
33 | data-toggle="tab"><?= Yii::t('hipanel', 'Set by one') ?></a> |
||
34 | </li> |
||
35 | </ul> |
||
36 | |||
37 | <!-- Tab panes --> |
||
38 | <div class="row"> |
||
39 | <div class="tab-content"> |
||
40 | <div role="tabpanel" class="tab-pane active" id="bulk"> |
||
41 | <div class="col-md-12" style="margin-top: 15pt;"> |
||
42 | <?php |
||
43 | $form = ActiveForm::begin([ |
||
44 | 'id' => 'bulk-sale', |
||
45 | 'action' => $actionUrl, |
||
46 | 'enableAjaxValidation' => true, |
||
47 | 'validateOnBlur' => true, |
||
48 | 'validationUrl' => $validationUrl, |
||
49 | ]) ?> |
||
50 | |||
51 | <?php foreach ($models as $model) : ?> |
||
52 | <?= Html::activeHiddenInput($model, "[$model->id]id") ?> |
||
53 | <?= Html::activeHiddenInput($model, "[$model->id]name") ?> |
||
54 | <?php endforeach; ?> |
||
55 | |||
56 | <div class="panel panel-default"> |
||
57 | <div class="panel-heading"><?= Yii::t('hipanel:server', 'Affected items') ?></div> |
||
58 | <div class="panel-body"> |
||
59 | <?= \hipanel\widgets\ArraySpoiler::widget([ |
||
60 | 'data' => $models, |
||
61 | 'visibleCount' => count($models), |
||
62 | 'formatter' => function ($model) { |
||
63 | if ($this->context->isServer()) { |
||
0 ignored issues
–
show
Comprehensibility
Best Practice
introduced
by
Loading history...
|
|||
64 | return ServerNameBadge::widget(['model' => $model]); |
||
65 | } else { |
||
66 | return HubNameBadge::widget(['model' => $model]); |
||
67 | } |
||
68 | }, |
||
69 | 'delimiter' => ' ', |
||
70 | ]); ?> |
||
71 | </div> |
||
72 | </div> |
||
73 | |||
74 | <?= $form->field($model, 'client_id')->widget(ClientCombo::class, [ |
||
75 | 'inputOptions' => [ |
||
76 | 'name' => 'client_id', |
||
77 | ], |
||
78 | ])->hint($this->context->isServer() ? Yii::t('hipanel:server', 'Clear this input to unsale the servers') : '') ?> |
||
79 | |||
80 | <?= $form->field($model, 'tariff_id')->widget(PlanCombo::class, [ |
||
81 | /// TODO think: 'tariffType' => 'server' |
||
82 | 'inputOptions' => [ |
||
83 | 'name' => 'tariff_id', |
||
84 | ], |
||
85 | ]) ?> |
||
86 | <?= $form->field($model, 'sale_time')->widget(DateTimePicker::class, [ |
||
87 | 'clientOptions' => [ |
||
88 | 'autoclose' => true, |
||
89 | 'format' => 'yyyy-mm-dd hh:ii:ss', |
||
90 | 'pickerPosition' => 'top-right', |
||
91 | 'todayBtn' => true, |
||
92 | ], |
||
93 | 'options' => [ |
||
94 | 'value' => Yii::$app->formatter->asDatetime($defaultDateTime, 'php:Y-m-d H:i:s'), |
||
95 | 'name' => 'sale_time', |
||
96 | ], |
||
97 | ]) ?> |
||
98 | |||
99 | <?php if ($this->context->isServer()) : ?> |
||
100 | <?= $form->field($model, 'move_accounts')->checkbox(['name' => 'move_accounts']) ?> |
||
101 | <?php endif; ?> |
||
102 | |||
103 | <hr> |
||
104 | <?= Html::submitButton(Yii::t('hipanel:server', 'Sell'), [ |
||
105 | 'class' => 'btn btn-success', 'id' => 'save-button', |
||
106 | ]) ?> |
||
107 | <?php ActiveForm::end() ?> |
||
108 | </div> |
||
109 | </div> |
||
110 | |||
111 | <div role="tabpanel" class="tab-pane" id="by-one"> |
||
112 | <div class="col-md-12" style="margin-top: 15px;"> |
||
113 | <?php $form = ActiveForm::begin([ |
||
114 | 'id' => 'bulk-by-one-sale', |
||
115 | 'action' => $actionUrl, |
||
116 | 'enableAjaxValidation' => true, |
||
117 | 'validateOnBlur' => true, |
||
118 | 'validationUrl' => $validationUrl, |
||
119 | ]); ?> |
||
120 | |||
121 | <div class="row"> |
||
122 | <div class="col-md-12"> |
||
123 | <?= $form->field($model, 'client_id')->widget(ClientCombo::class, [ |
||
124 | 'options' => ['id' => 'bulk-by-one-sale-client'], |
||
125 | 'inputOptions' => [ |
||
126 | 'id' => 'bulk-by-one-sale-client', |
||
127 | 'name' => 'client_id', |
||
128 | ], |
||
129 | 'formElementSelector' => '.form-group', |
||
130 | ])->hint($this->context->isServer() ? Yii::t('hipanel:server', 'Clear this input to unsale the servers') : '') ?> |
||
131 | </div> |
||
132 | |||
133 | <?php foreach ($models as $model) : ?> |
||
134 | <div class="col-md-3 text-right" style="line-height: 34px;"> |
||
135 | <?= Html::activeHiddenInput($model, "[$model->id]id") ?> |
||
136 | <?php if ($this->context->isServer()) : ?> |
||
137 | <?= ServerNameBadge::widget(['model' => $model]) ?> |
||
138 | <?php else : ?> |
||
139 | <?= HubNameBadge::widget(['model' => $model]) ?> |
||
140 | <?php endif; ?> |
||
141 | </div> |
||
142 | <div class="col-md-9"> |
||
143 | <div class="row"> |
||
144 | <div class="col-md-6"> |
||
145 | <?= $form->field($model, "[$model->id]tariff_id") |
||
146 | ->widget(PlanCombo::class, [ |
||
147 | /// TODO think: 'tariffType' => $this->context->isServer() ? 'server' : '', |
||
148 | 'inputOptions' => ['ref' => 'plan-combo'], |
||
149 | ]) |
||
150 | ->label(false) |
||
151 | ?> |
||
152 | </div> |
||
153 | <div class="col-md-6"> |
||
154 | <?= $form->field($model, "[$model->id]sale_time")->widget(DateTimePicker::class, [ |
||
155 | 'clientOptions' => [ |
||
156 | 'autoclose' => true, |
||
157 | 'format' => 'yyyy-mm-dd hh:ii:ss', |
||
158 | 'todayBtn' => true, |
||
159 | ], |
||
160 | 'options' => [ |
||
161 | 'value' => Yii::$app->formatter->asDatetime($defaultDateTime, 'php:Y-m-d H:i:s'), |
||
162 | 'ref' => 'sale-time-combo', |
||
163 | ], |
||
164 | ])->label(false) ?> |
||
165 | </div> |
||
166 | </div> |
||
167 | </div> |
||
168 | <?php endforeach; ?> |
||
169 | |||
170 | </div> |
||
171 | |||
172 | <div class="col-md-12"> |
||
173 | <?php if ($this->context->isServer()) : ?> |
||
174 | <?= $form->field($model, 'move_accounts')->checkbox(['name' => 'move_accounts']) ?> |
||
175 | <?php endif; ?> |
||
176 | |||
177 | <hr> |
||
178 | <?= Html::submitButton(Yii::t('hipanel:server', 'Sell'), [ |
||
179 | 'class' => 'btn btn-success', 'id' => 'save-button', |
||
180 | ]) ?> |
||
181 | <?php ActiveForm::end() ?> |
||
182 | </div> |
||
183 | |||
184 | </div> |
||
185 | |||
186 | </div> |
||
187 | </div> |
||
188 | </div> |
||
189 | </div> |
||
190 | |||
191 | <?= \hipanel\widgets\BulkAssignmentFieldsLinker::widget([ |
||
192 | 'inputSelectors' => ['select[ref=plan-combo]', 'input[ref=sale-time-combo]'], |
||
193 | ]) ?> |
||
194 |