1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* @var \yii\web\View |
5
|
|
|
* @var $model \hipanel\modules\finance\forms\CertificateTariffForm |
6
|
|
|
*/ |
7
|
|
|
use hipanel\widgets\Box; |
8
|
|
|
use yii\bootstrap\ActiveForm; |
9
|
|
|
use yii\helpers\Html; |
10
|
|
|
|
11
|
|
|
?> |
12
|
|
|
|
13
|
|
|
<?php $form = ActiveForm::begin(array_filter([ |
14
|
|
|
'id' => 'tariff-create-form', |
15
|
|
|
'action' => isset($action) ? $action : null, |
16
|
|
|
])) ?> |
17
|
|
|
|
18
|
|
|
<?php Box::begin() ?> |
19
|
|
|
<div class="row"> |
20
|
|
|
<div class="col-md-12"> |
21
|
|
|
<?= Html::activeHiddenInput($model, 'id') ?> |
22
|
|
|
<?= $form->field($model, 'name') ?> |
23
|
|
|
<?= Html::activeHiddenInput($model, 'parent_id') ?> |
24
|
|
|
</div> |
25
|
|
|
</div> |
26
|
|
|
|
27
|
|
|
<?php if (isset($model->parentTariff)): ?> |
28
|
|
|
<div class="row"> |
29
|
|
|
<div class="col-md-12"> |
30
|
|
|
<table class="table table-condensed"> |
31
|
|
|
<thead> |
32
|
|
|
<tr> |
33
|
|
|
<th></th> |
34
|
|
|
<?php foreach ($model->getResourceTypes() as $type) : ?> |
35
|
|
View Code Duplication |
<?php foreach ($model->getPeriods() as $period => $periodLabel) : ?> |
|
|
|
|
36
|
|
|
<?= Html::tag('th', Yii::t('hipanel:finance:tariff', '{operation} for {duration}', [ |
37
|
|
|
'operation' => $type, |
38
|
|
|
'duration' => $periodLabel, |
39
|
|
|
])); ?> |
40
|
|
|
<?php endforeach; ?> |
41
|
|
|
<?php endforeach; ?> |
42
|
|
|
</tr> |
43
|
|
|
</thead> |
44
|
|
|
<tbody> |
45
|
|
|
<?php |
46
|
|
|
$i = 0; |
47
|
|
|
foreach ($model->getCertificateTypes() as $id => $certificateType) { |
48
|
|
|
?> |
49
|
|
|
<tr> |
50
|
|
|
<td><?= $certificateType ?></td> |
51
|
|
View Code Duplication |
<?php foreach ($model->getTypeResources($certificateType) as $type => $resource) : ?> |
|
|
|
|
52
|
|
|
<?php $baseResources = $model->getTypeParentResources($certificateType); ?> |
53
|
|
|
<?= Html::activeHiddenInput($resource, "[$i]object_id") ?> |
54
|
|
|
<?= Html::activeHiddenInput($resource, "[$i]type") ?> |
55
|
|
|
<?php foreach ($model->getPeriods() as $period => $periodLabel) : ?> |
56
|
|
|
<td> |
57
|
|
|
<?= \hipanel\modules\finance\widgets\ResourcePriceInput::widget([ |
58
|
|
|
'basePrice' => $baseResources[$type]->getPriceForPeriod($period), |
59
|
|
|
'activeField' => $form->field($resource, "[$i]data[sums][$period]"), |
60
|
|
|
]) ?> |
61
|
|
|
</td> |
62
|
|
|
<?php endforeach; ?> |
63
|
|
|
<?php ++$i; ?> |
64
|
|
|
<?php endforeach; ?> |
65
|
|
|
</tr> |
66
|
|
|
<?php |
67
|
|
|
} ?> |
68
|
|
|
</tbody> |
69
|
|
|
</table> |
70
|
|
|
</div> |
71
|
|
|
</div> |
72
|
|
|
<?php endif ?> |
73
|
|
|
<?php Box::end() ?> |
74
|
|
|
|
75
|
|
|
<?php Box::begin(['options' => ['class' => 'box-solid']]) ?> |
76
|
|
|
<div class="row"> |
77
|
|
|
<div class="col-md-12 no"> |
78
|
|
|
<?= Html::submitButton(Yii::t('hipanel', 'Save'), ['class' => 'btn btn-success']) ?> |
79
|
|
|
<?= Html::button(Yii::t('hipanel', 'Cancel'), ['class' => 'btn btn-default', 'onclick' => 'history.go(-1)']) ?> |
80
|
|
|
</div> |
81
|
|
|
</div> |
82
|
|
|
<?php Box::end() ?> |
83
|
|
|
<?php ActiveForm::end(); ?> |
84
|
|
|
|
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.