1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use hipanel\helpers\Url; |
4
|
|
|
use hipanel\modules\finance\widgets\RequisiteSerieWidget; |
5
|
|
|
use yii\bootstrap\ActiveForm; |
6
|
|
|
use yii\helpers\Html; |
7
|
|
|
use hipanel\widgets\RefCombo; |
8
|
|
|
|
9
|
|
|
?> |
10
|
|
|
|
11
|
|
|
<div> |
12
|
|
|
|
13
|
|
|
<!-- Nav tabs --> |
14
|
|
View Code Duplication |
<?php if (count($models) > 1) : ?> |
|
|
|
|
15
|
|
|
<ul class="nav nav-tabs" role="tablist"> |
16
|
|
|
<li role="presentation" class="active"><a href="#bulk" aria-controls="home" role="tab" data-toggle="tab"><?= Yii::t('hipanel', 'Set for all') ?></a></li> |
17
|
|
|
<li role="presentation"><a href="#by-one" aria-controls="profile" role="tab" data-toggle="tab"><?= Yii::t('hipanel', 'Set by one') ?></a></li> |
18
|
|
|
</ul> |
19
|
|
|
<?php endif ?> |
20
|
|
|
|
21
|
|
|
<!-- Tab panes --> |
22
|
|
|
<div class="tab-content"> |
23
|
|
|
<div role="tabpanel" class="tab-pane active" id="bulk"> |
24
|
|
|
<div class="row" style="margin-top: 15pt;"> |
25
|
|
|
<div class="col-md-12"> |
26
|
|
View Code Duplication |
<?php if (!empty($models)) : ?> |
|
|
|
|
27
|
|
|
<div class="panel panel-default"> |
28
|
|
|
<div class="panel-heading"><?= Yii::t('hipanel:finance', 'Affected requisites') ?></div> |
29
|
|
|
<div class="panel-body"> |
30
|
|
|
<?= \hipanel\widgets\ArraySpoiler::widget([ |
31
|
|
|
'data' => $models, |
32
|
|
|
'visibleCount' => count($models), |
33
|
|
|
'formatter' => function ($model) { |
34
|
|
|
return "{$model->email} / {$model->name}"; |
35
|
|
|
}, |
36
|
|
|
'delimiter' => ', ', |
37
|
|
|
]); ?> |
38
|
|
|
</div> |
39
|
|
|
</div> |
40
|
|
|
<?= RequisiteSerieWidget::widget([ |
41
|
|
|
'model' => $models, |
42
|
|
|
'actionUrl' => 'bulk-set-serie', |
43
|
|
|
]) ?> |
44
|
|
|
<?php endif ?> |
45
|
|
|
</div> |
46
|
|
|
</div> |
47
|
|
|
</div> |
48
|
|
|
<div role="tabpanel" class="tab-pane" id="by-one"> |
49
|
|
|
<?php $form = ActiveForm::begin([ |
50
|
|
|
'id' => 'bulk-set-templates', |
51
|
|
|
'action' => Url::toRoute('@requisite/set-serie'), |
52
|
|
|
'enableAjaxValidation' => true, |
53
|
|
|
'validateOnBlur' => true, |
54
|
|
|
'validationUrl' => Url::toRoute(['validate-form', 'scenario' => 'set-serie']), |
55
|
|
|
]) ?> |
56
|
|
|
<div class="row" style="margin-top: 15pt;"> |
57
|
|
|
<?php foreach ($models as $model) : ?> |
58
|
|
|
<div class="col-md-8" style="line-height: 34px;"> |
59
|
|
|
<b><?= "{$model->name} / {$model->organization}" ?></b> |
60
|
|
|
</div> |
61
|
|
|
<?= Html::activeHiddenInput($model, "[$model->id]id") ?> |
62
|
|
|
<div class="col-md-4"> |
63
|
|
|
<?= $form->field($model, "[$model->id]serie") ?> |
64
|
|
|
</div> |
65
|
|
|
<hr> |
66
|
|
|
<?php endforeach ?> |
67
|
|
|
</div> |
68
|
|
|
<hr> |
69
|
|
|
<?= Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success', 'id' => 'save-button']) ?> |
70
|
|
|
<?php ActiveForm::end() ?> |
71
|
|
|
</div> |
72
|
|
|
</div> |
73
|
|
|
|
74
|
|
|
</div> |
75
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.