1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
use hipanel\modules\finance\widgets\PriceDifferenceWidget; |
4
|
|
|
use hipanel\widgets\Box; |
5
|
|
|
|
6
|
|
|
/** |
7
|
|
|
* @var \yii\web\View |
8
|
|
|
* @var $model \hipanel\modules\finance\forms\ServerTariffForm |
9
|
|
|
* @var $manager \hipanel\modules\finance\logic\AbstractTariffManager |
10
|
|
|
*/ |
11
|
|
|
?> |
12
|
|
|
|
13
|
|
|
<div class="row"> |
14
|
|
|
<div class="col-md-12"> |
15
|
|
|
<?php Box::begin(['title' => Yii::t('hipanel:finance:tariff', 'Tariff')]) ?> |
16
|
|
|
<table class="table table-condensed"> |
17
|
|
|
<thead> |
18
|
|
|
<tr> |
19
|
|
|
<td><?= Yii::t('hipanel:finance:tariff', 'Price') ?></td> |
20
|
|
View Code Duplication |
<?php if (Yii::$app->user->can('manage')) : ?> |
|
|
|
|
21
|
|
|
<td><?= Yii::t('hipanel:finance:tariff', 'Parent tariff price') ?></td> |
22
|
|
|
<td><?= Yii::t('hipanel:finance:tariff', 'Profit') ?></td> |
23
|
|
|
<?php endif; ?> |
24
|
|
|
</tr> |
25
|
|
|
</thead> |
26
|
|
|
<tbody> |
27
|
|
|
<tr> |
28
|
|
|
<?php $price = $model->calculation()->price; ?> |
29
|
|
|
<?php $basePrice = $model->parentCalculation()->price; ?> |
30
|
|
|
<td><?= Yii::$app->formatter->asCurrency($price, $model->calculation()->currency) ?></td> |
31
|
|
View Code Duplication |
<?php if (Yii::$app->user->can('manage')) : ?> |
32
|
|
|
<td><?= Yii::$app->formatter->asCurrency($basePrice, $model->parentCalculation()->currency) ?></td> |
33
|
|
|
<td> |
34
|
|
|
<?= PriceDifferenceWidget::widget([ |
35
|
|
|
'new' => $price, |
36
|
|
|
'old' => $basePrice, |
37
|
|
|
]) ?> |
38
|
|
|
</td> |
39
|
|
|
<?php endif; ?> |
40
|
|
|
</tr> |
41
|
|
|
</tbody> |
42
|
|
|
</table> |
43
|
|
|
<?php Box::end() ?> |
44
|
|
|
</div> |
45
|
|
|
<div class="col-md-12"> |
46
|
|
|
<?php Box::begin(['title' => Yii::t('hipanel:finance:tariff', 'Hardware')]) ?> |
47
|
|
|
<table class="table table-condensed"> |
48
|
|
|
<thead> |
49
|
|
|
<tr> |
50
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Resource') ?></th> |
51
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Model') ?></th> |
52
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Price per period') ?></th> |
53
|
|
|
</tr> |
54
|
|
|
</thead> |
55
|
|
|
<tbody> |
56
|
|
View Code Duplication |
<?php foreach ($model->getHardwareResources() as $resource) : ?> |
57
|
|
|
<?php $baseResource = $model->getParentHardwareResource($resource->object_id); ?> |
58
|
|
|
<tr> |
59
|
|
|
<td><?= $resource->decorator()->displayTitle() ?></td> |
60
|
|
|
<td><?= $resource->decorator()->displayPrepaidAmount() ?></td> |
61
|
|
|
<td> |
62
|
|
|
<?= \hipanel\modules\finance\widgets\ResourcePriceWidget::widget([ |
63
|
|
|
'price' => $resource->fee, |
64
|
|
|
'currency' => $resource->currency, |
65
|
|
|
]) ?> |
66
|
|
|
<?php if (Yii::$app->user->can('manage')) : ?> |
67
|
|
|
<?= PriceDifferenceWidget::widget([ |
68
|
|
|
'new' => $resource->fee, |
69
|
|
|
'old' => $baseResource->fee, |
70
|
|
|
]) ?> |
71
|
|
|
<?php endif; ?> |
72
|
|
|
</td> |
73
|
|
|
</tr> |
74
|
|
|
<?php endforeach ?> |
75
|
|
|
</tbody> |
76
|
|
|
</table> |
77
|
|
|
<?php Box::end() ?> |
78
|
|
|
</div> |
79
|
|
|
</div> |
80
|
|
|
<div class="row"> |
81
|
|
|
<div class="col-md-12"> |
82
|
|
|
<?php Box::begin(['title' => Yii::t('hipanel:finance:tariff', 'Resources')]) ?> |
83
|
|
|
<table class="table table-condensed"> |
84
|
|
|
<thead> |
85
|
|
|
<tr> |
86
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Resource') ?></th> |
87
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Price per period') ?></th> |
88
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Prepaid amount') ?></th> |
89
|
|
|
<th><?= Yii::t('hipanel:finance:tariff', 'Overuse price') ?></th> |
90
|
|
|
</tr> |
91
|
|
|
</thead> |
92
|
|
|
<tbody> |
93
|
|
View Code Duplication |
<?php foreach ($model->getOveruseResources() as $resource) : ?> |
94
|
|
|
<?php $baseResource = $model->getParentOveruseResource($resource->type_id); ?> |
95
|
|
|
<tr> |
96
|
|
|
<td><?= $resource->decorator()->displayTitle() ?></td> |
97
|
|
|
<td> |
98
|
|
|
<?= \hipanel\modules\finance\widgets\ResourcePriceWidget::widget([ |
99
|
|
|
'price' => $resource->fee, |
100
|
|
|
'currency' => $resource->currency, |
101
|
|
|
]) ?> |
102
|
|
|
<?php if (Yii::$app->user->can('manage')) : ?> |
103
|
|
|
<?= PriceDifferenceWidget::widget([ |
104
|
|
|
'new' => $resource->fee, |
105
|
|
|
'old' => $baseResource->fee, |
106
|
|
|
]) ?> |
107
|
|
|
<?php endif; ?> |
108
|
|
|
</td> |
109
|
|
|
<td> |
110
|
|
|
<?= $resource->decorator()->displayPrepaidAmount() ?> |
111
|
|
|
</td> |
112
|
|
|
<td> |
113
|
|
|
<?= \hipanel\modules\finance\widgets\ResourcePriceWidget::widget([ |
114
|
|
|
'price' => $resource->price, |
115
|
|
|
'currency' => $resource->currency, |
116
|
|
|
]) ?> |
117
|
|
|
<?php if (Yii::$app->user->can('manage')) : ?> |
118
|
|
|
<?= PriceDifferenceWidget::widget([ |
119
|
|
|
'new' => $resource->price, |
120
|
|
|
'old' => $baseResource->price, |
121
|
|
|
]) ?> |
122
|
|
|
<?php endif; ?> |
123
|
|
|
</td> |
124
|
|
|
</tr> |
125
|
|
|
<?php endforeach ?> |
126
|
|
|
</tbody> |
127
|
|
|
</table> |
128
|
|
|
<?php Box::end() ?> |
129
|
|
|
</div> |
130
|
|
|
</div> |
131
|
|
|
|
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.