| @@ 7-35 (lines=29) @@ | ||
| 4 | ||
| 5 | use Yii; |
|
| 6 | ||
| 7 | class HddResourceDecorator extends AbstractServerResourceDecorator |
|
| 8 | { |
|
| 9 | public function displayTitle() |
|
| 10 | { |
|
| 11 | return Yii::t('hipanel/server/order', 'SSD'); |
|
| 12 | } |
|
| 13 | ||
| 14 | public function displayPrepaidAmount() |
|
| 15 | { |
|
| 16 | return Yii::t('yii', '{nFormatted} GB', ['nFormatted' => $this->getPrepaidQuantity()]); // Gb |
|
| 17 | } |
|
| 18 | ||
| 19 | public function getOverusePrice() |
|
| 20 | { |
|
| 21 | return 0.2; // TODO: move to config |
|
| 22 | } |
|
| 23 | ||
| 24 | public function getPrepaidQuantity() |
|
| 25 | { |
|
| 26 | $part = $this->resource->part; |
|
| 27 | preg_match('/((\d{1,5}) GB)$/i', $part->partno, $matches); |
|
| 28 | return (int) $matches[2]; |
|
| 29 | } |
|
| 30 | ||
| 31 | public function displayUnit() |
|
| 32 | { |
|
| 33 | return Yii::t('hipanel', 'GB'); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||
| @@ 7-35 (lines=29) @@ | ||
| 4 | ||
| 5 | use Yii; |
|
| 6 | ||
| 7 | class RamResourceDecorator extends AbstractServerResourceDecorator |
|
| 8 | { |
|
| 9 | public function displayTitle() |
|
| 10 | { |
|
| 11 | return Yii::t('hipanel/server/order', 'RAM'); |
|
| 12 | } |
|
| 13 | ||
| 14 | public function getPrepaidQuantity() |
|
| 15 | { |
|
| 16 | $part = $this->resource->part; |
|
| 17 | preg_match('/((\d{1,5}) MB)$/i', $part->partno, $matches); |
|
| 18 | return $matches[2] / 1024; |
|
| 19 | } |
|
| 20 | ||
| 21 | public function getOverusePrice() |
|
| 22 | { |
|
| 23 | return 4; // TODO: move to config |
|
| 24 | } |
|
| 25 | ||
| 26 | public function displayUnit() |
|
| 27 | { |
|
| 28 | return Yii::t('hipanel', 'GB'); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function displayPrepaidAmount() |
|
| 32 | { |
|
| 33 | return Yii::t('yii', '{nFormatted} GB', ['nFormatted' => $this->getPrepaidQuantity()]); |
|
| 34 | } |
|
| 35 | } |
|
| 36 | ||