Skip to content

Commit

Permalink
Added ServerUse model
Browse files Browse the repository at this point in the history
  • Loading branch information
SilverFire committed Feb 23, 2016
1 parent d088c8e commit 96bfe22
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions src/models/ServerUse.php
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;
}
}

0 comments on commit 96bfe22

Please sign in to comment.