Your IP : 216.73.216.79


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

<?php

namespace app\models;

use Yii;
use app\models\AssetCategory;

/**
 * This is the model class for table "asset_details".
 *
 * @property int $id
 * @property string $uuid
 * @property string $name
 * @property string $descr
 * @property string $cat
 * @property string $asset_value
 * @property string $purchase_dt
 * @property string $img_url
 * @property string $created_dt
 * @property int $created_by
 * @property string $updated_dt
 * @property int $updated_by
 */
class AssetDetails extends \yii\db\ActiveRecord {

    public $file;

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

    /**
     * {@inheritdoc}
     */
    public function rules() {
        return [
            [['name', 'cat', 'purchase_dt'], 'required'],
            [['descr'], 'string'],
            [['purchase_dt', 'created_dt', 'updated_dt', 'uuid'], 'safe'],
            [['created_by', 'updated_by'], 'integer'],
            [['name', 'cat', 'asset_value', 'img_url'], 'string', 'max' => 255],
            [['file'], 'file'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'uuid' => 'Uuid',
            'name' => 'Asset Name',
            'descr' => 'Description',
            'cat' => 'Category',
            'asset_value' => 'Asset Value',
            'purchase_dt' => 'Purchase Date',
            'img_url' => 'Image',
            'created_dt' => 'Created Dt',
            'created_by' => 'Created By',
            'updated_dt' => 'Updated Dt',
            'updated_by' => 'Updated By',
            'file' => 'Image',
        ];
    }

    public function getserialnumber($id) {
        $output = '';
        $AssetCategory = new AssetCategory();
        if (($model = AssetDetails::findOne($id)) !== null) {
            $output = $AssetCategory->getcode($model->cat) . '-' . date("mY", strtotime($model->purchase_dt)) . '-' . sprintf('%07d', $model->id);
        }
        return $output;
    }

}