| @@ 109-124 (lines=16) @@ | ||
| 106 | /** |
|
| 107 | * @return \hipanel\modules\finance\models\ServerResource[] |
|
| 108 | */ |
|
| 109 | public function getOveruseResources() |
|
| 110 | { |
|
| 111 | /** @var ServerResource[] $resources */ |
|
| 112 | $resources = array_filter($this->tariff->resources, function ($model) { |
|
| 113 | /** @var ServerResource $model */ |
|
| 114 | return $model->isTypeCorrect(); |
|
| 115 | }); |
|
| 116 | ||
| 117 | if (empty($resources)) { |
|
| 118 | return []; |
|
| 119 | } |
|
| 120 | ||
| 121 | $order = array_keys(reset($resources)->getTypes()); |
|
| 122 | ||
| 123 | return $this->sortResourcesByDefinedOrder($resources, $order, 'type'); |
|
| 124 | } |
|
| 125 | ||
| 126 | public function getParentOveruseResource($type_id) |
|
| 127 | { |
|
| @@ 45-59 (lines=15) @@ | ||
| 42 | /** |
|
| 43 | * @return \hipanel\modules\finance\models\ServerResource[] |
|
| 44 | */ |
|
| 45 | public function getHardwareResources() |
|
| 46 | { |
|
| 47 | /** @var ServerResource[] $resources */ |
|
| 48 | $resources = array_filter($this->tariff->resources, function ($model) { |
|
| 49 | /** @var ServerResource $model */ |
|
| 50 | return $model->isHardwareTypeCorrect(); |
|
| 51 | }); |
|
| 52 | ||
| 53 | if (empty($result)) { |
|
| 54 | return []; |
|
| 55 | } |
|
| 56 | ||
| 57 | $order = array_keys(reset($resources)->getHardwareTypes()); |
|
| 58 | ||
| 59 | return $this->sortResourcesByDefinedOrder($resources, $order, 'model_type'); |
|
| 60 | } |
|
| 61 | ||
| 62 | /** |
|
| @@ 41-56 (lines=16) @@ | ||
| 38 | /** |
|
| 39 | * @return \hipanel\modules\finance\models\ServerResource[] |
|
| 40 | */ |
|
| 41 | public function getHardwareResources() |
|
| 42 | { |
|
| 43 | /** @var ServerResource[] $resources */ |
|
| 44 | $resources = array_filter($this->tariff->resources, function ($model) { |
|
| 45 | /** @var ServerResource $model */ |
|
| 46 | return $model->isHardwareTypeCorrect(); |
|
| 47 | }); |
|
| 48 | ||
| 49 | if (empty($resources)) { |
|
| 50 | return []; |
|
| 51 | } |
|
| 52 | ||
| 53 | $order = array_keys(reset($resources)->getHardwareTypes()); |
|
| 54 | ||
| 55 | return $this->sortResourcesByDefinedOrder($resources, $order, 'model_type'); |
|
| 56 | } |
|
| 57 | ||
| 58 | /** |
|
| 59 | * @param ServerResource[] $resources |
|
| @@ 81-95 (lines=15) @@ | ||
| 78 | /** |
|
| 79 | * @return \hipanel\modules\finance\models\ServerResource[] |
|
| 80 | */ |
|
| 81 | public function getOveruseResources() |
|
| 82 | { |
|
| 83 | /** @var ServerResource[] $resources */ |
|
| 84 | $resources = array_filter($this->tariff->resources, function ($model) { |
|
| 85 | /** @var ServerResource $model */ |
|
| 86 | return $model->isTypeCorrect(); |
|
| 87 | }); |
|
| 88 | if (empty($resources)) { |
|
| 89 | return []; |
|
| 90 | } |
|
| 91 | ||
| 92 | $order = array_keys(reset($resources)->getTypes()); |
|
| 93 | ||
| 94 | return $this->sortResourcesByDefinedOrder($resources, $order, 'type'); |
|
| 95 | } |
|
| 96 | ||
| 97 | public function getParentOveruseResource($type_id) |
|
| 98 | { |
|