Your IP : 216.73.216.79


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

<?php

namespace app\models;

use Yii;
use app\models\Company;
use app\models\ParamList;

/**
 * This is the model class for table "notes".
 *
 * @property int $id
 * @property string $uuid
 * @property string $type
 * @property string $title
 * @property string $notes
 * @property string $created_dt
 * @property int $created_by
 * @property string $updated_dt
 * @property int $updated_by
 */
class Notes extends \yii\db\ActiveRecord {

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

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

    /**
     * {@inheritdoc}
     */
    public function attributeLabels() {
        return [
            'id' => 'ID',
            'uuid' => 'Uuid',
            'type' => 'Type',
            'title' => 'Title',
            'notes' => 'Notes',
            'created_dt' => 'Created Dt',
            'created_by' => 'Created By',
            'updated_dt' => 'Updated Dt',
            'updated_by' => 'Updated By',
        ];
    }

    public function getnotes($type, $com_id) {
        $output = '';
        $ParamList = new ParamList();
        if (($model = static::findOne(['type' => $type])) !== null && ($modelcom = Company::findOne($com_id)) !== null) {
            $output = $model->notes;
            $output = str_replace("#COMPANY_NAME#", $modelcom->name, $output);
            $output = str_replace("#COMPANY_EMAIL#", $modelcom->email, $output);
            $output = str_replace("#COMPANY_BANK_NAME#", $ParamList->getlabel(31, $modelcom->account_bank), $output);
            $output = str_replace("#COMPANY_BANK_ACCNO#", $modelcom->account_number, $output);
            $output = str_replace("#COMPANY_BANK_ACCNAME#", $modelcom->account_name, $output);
        }
        return $output;
    }

}