Your IP : 216.73.216.79


Current Path : /var/www/html/eform/frontend/models/
Upload File :
Current File : /var/www/html/eform/frontend/models/StaffInfo.php

<?php

namespace frontend\models;

use Yii;

/**
 * This is the model class for table "StaffProfiles".
 *
 * @property string|null $StaffId
 * @property string $StaffNo
 * @property string|null $StaffName
 * @property bool|null $IsMale
 * @property string|null $PositionCode
 * @property string|null $CompanyCode
 * @property string|null $ChiefCode
 * @property string|null $SectorCode
 * @property string|null $DivisionCode
 * @property string|null $DepartmentCode
 * @property string|null $UnitCode
 * @property string|null $GradeCode
 * @property string|null $EmployeeType
 * @property string|null $ICNo
 * @property string|null $DirectBossId
 * @property string|null $JoinDate
 * @property string|null $CorrAddress
 * @property string|null $CorrTelNo
 * @property string|null $PermTelNo
 * @property string|null $BirthDate
 * @property bool|null $IsPemangku
 * @property string|null $Email
 * @property string|null $ppc
 * @property string|null $Resigndate
 * @property string|null $Updateddate
 * @property int|null $status
 * @property string|null $CompanyId
 * @property string|null $SalutationCode
 * @property string|null $CostCenter
 * @property string|null $PromotionDate
 * @property string|null $TerminationType
 * @property int|null $TRANSFER
 * @property string|null $TRANSFERDATE
 * @property string|null $CRCODE
 * @property string|null $LEAVE
 * @property int|null $STATUSCODE
 * @property string|null $STATUSDESC
 * @property int|null $PROMOTION
 * @property int|null $DEMOTION
 * @property int|null $RESIGNATION
 * @property int|null $SUSPEND
 * @property int|null $UNSUSPEND
 * @property int|null $OURESTRUCTURING
 * @property int|null $REHIREFLAG
 * @property string|null $SUSPENDDATE
 */
class StaffInfo extends \yii\db\ActiveRecord
{
    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return 'StaffProfiles';
    }

    /**
     * @return \yii\db\Connection the database connection used by this AR class.
     */
    public static function getDb()
    {
        return Yii::$app->get('bkrm');
    }

    /**
     * {@inheritdoc}
     */
    public function rules()
    {
        return [
            [['StaffNo'], 'required'],
            [['IsMale', 'IsPemangku'], 'boolean'],
            [['JoinDate', 'BirthDate', 'Resigndate', 'Updateddate', 'PromotionDate', 'TRANSFERDATE', 'SUSPENDDATE'], 'safe'],
            [['status', 'TRANSFER', 'STATUSCODE', 'PROMOTION', 'DEMOTION', 'RESIGNATION', 'SUSPEND', 'UNSUSPEND', 'OURESTRUCTURING', 'REHIREFLAG'], 'integer'],
            [['StaffId', 'StaffNo', 'Email', 'CRCODE'], 'string', 'max' => 50],
            [['StaffName', 'LEAVE', 'STATUSDESC'], 'string', 'max' => 100],
            [['PositionCode', 'CompanyCode', 'ChiefCode', 'SectorCode', 'DivisionCode', 'DepartmentCode', 'UnitCode', 'EmployeeType', 'DirectBossId', 'ppc'], 'string', 'max' => 10],
            [['GradeCode'], 'string', 'max' => 25],
            [['ICNo'], 'string', 'max' => 30],
            [['CorrAddress'], 'string', 'max' => 500],
            [['CorrTelNo', 'PermTelNo'], 'string', 'max' => 255],
            [['CompanyId', 'SalutationCode', 'CostCenter', 'TerminationType'], 'string', 'max' => 150],
            [['StaffNo'], 'unique'],
        ];
    }

    /**
     * {@inheritdoc}
     */
    public function attributeLabels()
    {
        return [
            'StaffId' => 'Staff ID',
            'StaffNo' => 'Staff No',
            'StaffName' => 'Staff Name',
            'IsMale' => 'Is Male',
            'PositionCode' => 'Position Code',
            'CompanyCode' => 'Company Code',
            'ChiefCode' => 'Chief Code',
            'SectorCode' => 'Sector Code',
            'DivisionCode' => 'Division Code',
            'DepartmentCode' => 'Department Code',
            'UnitCode' => 'Unit Code',
            'GradeCode' => 'Grade Code',
            'EmployeeType' => 'Employee Type',
            'ICNo' => 'Ic No',
            'DirectBossId' => 'Direct Boss ID',
            'JoinDate' => 'Join Date',
            'CorrAddress' => 'Corr Address',
            'CorrTelNo' => 'Corr Tel No',
            'PermTelNo' => 'Perm Tel No',
            'BirthDate' => 'Birth Date',
            'IsPemangku' => 'Is Pemangku',
            'Email' => 'Email',
            'ppc' => 'Ppc',
            'Resigndate' => 'Resigndate',
            'Updateddate' => 'Updateddate',
            'status' => 'Status',
            'CompanyId' => 'Company ID',
            'SalutationCode' => 'Salutation Code',
            'CostCenter' => 'Cost Center',
            'PromotionDate' => 'Promotion Date',
            'TerminationType' => 'Termination Type',
            'TRANSFER' => 'Transfer',
            'TRANSFERDATE' => 'Transferdate',
            'CRCODE' => 'Crcode',
            'LEAVE' => 'Leave',
            'STATUSCODE' => 'Statuscode',
            'STATUSDESC' => 'Statusdesc',
            'PROMOTION' => 'Promotion',
            'DEMOTION' => 'Demotion',
            'RESIGNATION' => 'Resignation',
            'SUSPEND' => 'Suspend',
            'UNSUSPEND' => 'Unsuspend',
            'OURESTRUCTURING' => 'Ourestructuring',
            'REHIREFLAG' => 'Rehireflag',
            'SUSPENDDATE' => 'Suspenddate',
        ];
    }

    public function getDepartment() {
        return $this->hasOne(Department::class, ['Code' => 'DepartmentCode']);
    }

    public function getUnit() {
        return $this->hasOne(Unit::class, ['Code' => 'UnitCode']);
    }

    public function getPositions() {
        return $this->hasOne(Positions::class, ['Code' => 'PositionCode']);
    }

    public static function staffIdMapping() {
        return ['StaffId' => Yii::$app->user->identity->staff_no];
    }
}