-
Notifications
You must be signed in to change notification settings - Fork 6
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
57a347b
commit 0f40b67
Showing
1 changed file
with
62 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,62 @@ | ||
<?php | ||
|
||
/* | ||
* Finance Plugin for HiPanel | ||
* | ||
* @link https://github.com/hiqdev/hipanel-module-finance | ||
* @package hipanel-module-finance | ||
* @license BSD-3-Clause | ||
* @copyright Copyright (c) 2015-2016, HiQDev (http://hiqdev.com/) | ||
*/ | ||
|
||
namespace hipanel\modules\finance\models; | ||
|
||
use Yii; | ||
|
||
/** | ||
* Class RUse. Used to represent Resources Usage | ||
* @package hipanel\modules\finance\models | ||
*/ | ||
class RUse extends \hipanel\base\Model | ||
{ | ||
use \hipanel\base\ModelTrait; | ||
|
||
public function formName() | ||
{ | ||
return 'Use'; | ||
} | ||
|
||
public static function index() | ||
{ | ||
return 'Uses'; | ||
} | ||
|
||
public static function type() | ||
{ | ||
return 'Use'; | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function rules() | ||
{ | ||
return [ | ||
[['id', 'type_id', 'last', 'total'], 'integer'], | ||
[['date', 'type', 'aggregation'], 'safe'], | ||
]; | ||
} | ||
|
||
public function getDisplayDate() | ||
{ | ||
if ($this->aggregation === 'month') { | ||
return Yii::$app->formatter->asDate(strtotime($this->date), 'LLL y'); | ||
} elseif ($this->aggregation === 'week') { | ||
return Yii::$app->formatter->asDate(strtotime($this->date), 'dd LLL y'); | ||
} elseif ($this->aggregation === 'day') { | ||
return Yii::$app->formatter->asDate(strtotime($this->date), 'dd LLL y'); | ||
} | ||
|
||
return Yii::$app->formatter->asDate(strtotime($this->date)); | ||
} | ||
} |