1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use hipanel\helpers\Url; |
4
|
|
|
use hipanel\modules\finance\widgets\RequisiteTemplatesWidget; |
5
|
|
|
use hipanel\widgets\ArraySpoiler; |
6
|
|
|
use yii\bootstrap\ActiveForm; |
7
|
|
|
use yii\helpers\Html; |
8
|
|
|
use hipanel\widgets\RefCombo; |
9
|
|
|
|
10
|
|
|
?> |
11
|
|
|
|
12
|
|
|
<div> |
13
|
|
|
|
14
|
|
|
<!-- Nav tabs --> |
15
|
|
View Code Duplication |
<?php if (count($models) > 1) : ?> |
16
|
|
|
<ul class="nav nav-tabs" role="tablist"> |
17
|
|
|
<li role="presentation" class="active"><a href="#bulk" aria-controls="home" role="tab" |
18
|
|
|
data-toggle="tab"><?= Yii::t('hipanel', 'Set for all') ?></a></li> |
19
|
|
|
<li role="presentation"><a href="#by-one" aria-controls="profile" role="tab" |
20
|
|
|
data-toggle="tab"><?= Yii::t('hipanel', 'Set by one') ?></a></li> |
21
|
|
|
</ul> |
22
|
|
|
<?php endif ?> |
23
|
|
|
|
24
|
|
|
<!-- Tab panes --> |
25
|
|
|
<div class="tab-content" style="padding-top: 1em"> |
26
|
|
|
<div role="tabpanel" class="tab-pane active" id="bulk"> |
27
|
|
View Code Duplication |
<?php if (!empty($models)) : ?> |
|
|
|
|
28
|
|
|
<div class="panel panel-default"> |
29
|
|
|
<div class="panel-heading"><?= Yii::t('hipanel:finance', 'Affected requisites') ?></div> |
30
|
|
|
<div class="panel-body"> |
31
|
|
|
<?= ArraySpoiler::widget([ |
32
|
|
|
'data' => $models, |
33
|
|
|
'visibleCount' => count($models), |
34
|
|
|
'formatter' => static function ($model) { |
35
|
|
|
return "{$model->email} / {$model->name}"; |
36
|
|
|
}, |
37
|
|
|
'delimiter' => ', ', |
38
|
|
|
]); ?> |
39
|
|
|
</div> |
40
|
|
|
</div> |
41
|
|
|
|
42
|
|
|
<?= RequisiteTemplatesWidget::widget([ |
43
|
|
|
'model' => $models, |
44
|
|
|
'actionUrl' => '@requisite/bulk-set-templates', |
45
|
|
|
]) ?> |
46
|
|
|
<br> |
47
|
|
|
<?php endif ?> |
48
|
|
|
</div> |
49
|
|
|
<div role="tabpanel" class="tab-pane" id="by-one"> |
50
|
|
|
<?php $form = ActiveForm::begin([ |
51
|
|
|
'id' => 'bulk-set-templates', |
52
|
|
|
'action' => Url::toRoute('@requisite/set-templates'), |
53
|
|
|
'enableAjaxValidation' => true, |
54
|
|
|
'validateOnBlur' => true, |
55
|
|
|
'validationUrl' => Url::toRoute(['@requisite/validate-form', 'scenario' => 'set-templates']), |
56
|
|
|
]) ?> |
57
|
|
|
<div class="row"> |
58
|
|
|
<?php foreach ($models as $model) : ?> |
59
|
|
|
<div class="col-md-12" style="line-height: 34px;"> |
60
|
|
|
<b><?= "{$model->name} / {$model->organization}" ?></b> |
61
|
|
|
</div> |
62
|
|
|
<?= Html::activeHiddenInput($model, "[$model->id]id") ?> |
63
|
|
View Code Duplication |
<?php foreach (['invoice', 'acceptance', 'contract', 'probation', 'internal_invoice'] as $template) : ?> |
64
|
|
|
<div class="col-md-6"> |
65
|
|
|
<?= $form->field($model, "[$model->id]{$template}_id")->widget(RefCombo::class, [ |
66
|
|
|
'gtype' => "type,document,{$template}", |
67
|
|
|
]) ?> |
68
|
|
|
</div> |
69
|
|
|
<?php endforeach ?> |
70
|
|
|
<hr> |
71
|
|
|
<?php endforeach ?> |
72
|
|
|
</div> |
73
|
|
|
<hr> |
74
|
|
|
<?= Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success', 'id' => 'save-button']) ?> |
75
|
|
|
<?php ActiveForm::end() ?> |
76
|
|
|
</div> |
77
|
|
|
</div> |
78
|
|
|
|
79
|
|
|
</div> |
80
|
|
|
|
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.