Your IP : 216.73.216.79


Current Path : /var/www/html/crm/models/
Upload File :
Current File : /var/www/html/crm/models/AssetLog.php

<?php

namespace app\models;

use Yii;
use app\models\ParamList;

/**
 * This is the model class for table "asset_log".
 *
 * @property int $id
 * @property int $asset_id
 * @property string $status
 * @property string $location
 * @property string $notes
 * @property string $log_dt
 * @property string $created_dt
 * @property int $created_by
 * @property string $updated_dt
 * @property int $updated_by
 */
class AssetLog extends \yii\db\ActiveRecord {

    /**
     * {@inheritdoc}
     */
    public static function tableName() {
        return 'asset_log';
    }

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['status', 'log_dt'], 'required'],
            [['asset_id', 'created_by', 'updated_by'], 'integer'],
            [['notes'], 'string'],
            [['log_dt', 'created_dt', 'updated_dt'], 'safe'],
            [['status', 'location'], 'string', 'max' => 255],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'asset_id' => 'Asset',
            'status' => 'Status',
            'location' => 'Location',
            'notes' => 'Notes',
            'log_dt' => 'Log Date',
            'created_dt' => 'Created Dt',
            'created_by' => 'Created By',
            'updated_dt' => 'Updated Dt',
            'updated_by' => 'Updated By',
        ];
    }

    public function getstatus($asset_id) {
        $output = '';
        $model = static::find()->where(['asset_id' => $asset_id])->orderby(['log_dt' => SORT_DESC])->one();
        if (!empty($model)) {
            $ParamList = new ParamList();
            $output = $ParamList->getlabel(30, $model->status);
        } else {
            //$output = '<span class="text-muted">(not set)</span>';
        }
        return $output;
    }

    public function getlocation($asset_id) {
        $output = '';
        $model = static::find()->where(['asset_id' => $asset_id])->orderby(['log_dt' => SORT_DESC])->one();
        if (!empty($model)) {
            $output = $model->location;
        } else {
            //$output = '<span class="text-muted">(not set)</span>';
        }
        return $output;
    }

}