Пример #1
0
 /**
  * Logs in a user using the provided username and password.
  *
  * @return boolean whether the user is logged in successfully
  */
 public function login()
 {
     if ($this->validate() && Yii::$app->user->login($this->getUser(), $this->rememberMe ? 3600 * 24 * 30 : 0)) {
         $user = Yii::$app->user;
         if ($user->identity->className() == Tech::className() && $user->identity->reload_roles) {
             MenuHelper::invalidate();
             $user->identity->reload_roles = false;
             $user->identity->save(false);
         }
         return true;
     } else {
         return false;
     }
 }
Пример #2
0
 /**
  * @return string
  */
 public function getUserClass()
 {
     if (!$this->_userClass) {
         $this->_userClass = $this->client_id === Client::MASTER_ID ? Tech::className() : User::className();
     }
     return $this->_userClass;
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['contact_id', 'startTime', 'endTime', 'roles'], 'required'], [['contact_id'], 'integer'], [['password'], 'string', 'min' => 6, 'max' => 32], [['confirm_password'], 'compare', 'compareAttribute' => 'password'], [['start_of_day', 'end_of_day'], 'date', 'format' => 'HH:mm'], [['end_of_day'], 'compare', 'operator' => '>', 'compareAttribute' => 'start_of_day'], [['roles'], 'each', 'rule' => ['string']], [['contact_id'], 'exist', 'targetClass' => Contact::className(), 'targetAttribute' => 'id'], [['contact_id'], 'unique', 'targetClass' => Tech::className(), 'message' => 'This user already has an account.'], [['roles'], 'each', 'rule' => ['in', 'range' => ArrayHelper::getColumn(Yii::$app->authManager->getRoles(), 'name')]]];
 }
Пример #4
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['invoice_id', 'tech_id', 'start_time', 'duration', 'ticketIds'], 'required', 'on' => self::SCENARIO_DEFAULT], [['invoice_id', 'start_time', 'duration'], 'required', 'on' => self::SCENARIO_REMOTE], [['invoice_id', 'tech_id'], 'integer'], [['onSite'], 'boolean'], [['start_time'], 'date', 'format' => 'yyyy-MM-dd HH:mm:ss'], [['duration'], 'integer', 'min' => '15'], [['description'], 'string'], [['ticketIds'], 'each', 'rule' => ['integer']], [['invoice_id'], 'exist', 'targetClass' => Location::className(), 'targetAttribute' => 'id'], [['tech_id'], 'exist', 'targetClass' => Tech::className(), 'targetAttribute' => 'contact_id'], [['ticketIds'], 'each', 'rule' => ['exist', 'targetClass' => Ticket::className(), 'targetAttribute' => 'id']]];
 }
Пример #5
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTech()
 {
     return $this->hasOne(Tech::className(), ['contact_id' => 'tech_id']);
 }
Пример #6
0
 /**
  * @inheritdoc
  */
 public function rules()
 {
     return [[['ticket_id', 'item_name', 'item_type_id', 'cost', 'added_by'], 'required'], [['ticket_id', 'item_type_id', 'quantity', 'added_by'], 'integer'], [['cost'], 'number'], [['item_name'], 'string', 'max' => 120], [['item_type_id'], 'in', 'range' => array_keys(self::$ITEM_TYPES)], [['ticket_id'], 'exist', 'targetClass' => Ticket::className(), 'targetAttribute' => 'id'], [['added_by'], 'exist', 'targetClass' => Tech::className(), 'targetAttribute' => 'contact_id']];
 }