Skip to content

Commit

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

0 comments on commit 0f40b67

Please sign in to comment.