-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d088c8e
commit 96bfe22
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
/** | ||
* @link http://hiqdev.com/hipanel-module-server | ||
* @license http://hiqdev.com/hipanel-module-server/license | ||
* @copyright Copyright (c) 2015 HiQDev | ||
*/ | ||
|
||
namespace hipanel\modules\server\models; | ||
|
||
use hipanel\modules\finance\models\RUse; | ||
use Yii; | ||
use yii\base\InvalidParamException; | ||
|
||
class ServerUse extends RUse | ||
{ | ||
use \hipanel\base\ModelTrait; | ||
|
||
private function getTrafficTypes() | ||
{ | ||
return ['server_traf_in', 'server_traf_max', 'server_traf']; | ||
} | ||
|
||
private function getBandwidthTypes() | ||
{ | ||
return ['server_traf95_in', 'server_traf95_max', 'server_traf95']; | ||
} | ||
|
||
public function getDisplayAmount() | ||
{ | ||
if (in_array($this->type, $this->getBandwidthTypes())) { | ||
return round($this->last / 10**6, 2); | ||
} elseif (in_array($this->type, $this->getTrafficTypes())) { | ||
return round($this->total / 10**9, 2); | ||
} | ||
|
||
return $this->total; | ||
} | ||
} |