コード例 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = DeviceEventCodeTxt::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'id_user' => $this->id_user, 'id_device' => $this->id_device, 'code' => $this->code]);
     $query->andFilterWhere(['like', 'txt', $this->txt]);
     return $dataProvider;
 }
コード例 #2
0
 public function getmyCODE()
 {
     $device = Device::find()->where(['sys_n' => $this->sys_n])->one();
     $id_device = $device->id;
     //
     $ut = DeviceEventCodeTxt::find()->where(['id_user' => Yii::$app->user->identity->id])->andFilterWhere(['id_device' => $id_device])->andFilterWhere(['code' => $this->code])->one();
     if ($ut == null) {
         return '????';
     }
     if (!empty($this->nzone)) {
         if (strcmp($this->tz, "0") == 0) {
             return $ut->txt . ' ' . $this->nzone . ' (норма)';
         }
         if (strcmp($this->tz, "1") == 0) {
             return $ut->txt . ' ' . $this->nzone . ' (КЗ)';
         }
         if (strcmp($this->tz, "2") == 0) {
             return $ut->txt . ' ' . $this->nzone . ' (норма)';
         }
         if (strcmp($this->tz, "3") == 0) {
             return $ut->txt . ' ' . $this->nzone . ' (обрыв)';
         }
         return $ut->txt . ' ' . $this->nzone;
     }
     if (!empty($this->nuser)) {
         return $ut->txt . ' Пользователь  ' . $this->nuser;
     }
     if (!empty($this->balans)) {
         return $ut->txt . ' ' . $this->balans . ' ' . Yii::$app->user->identity->money;
     }
     // потом надо будет заменить номер карточки на ФИО пользователя (школьника)
     if (!empty($this->card)) {
         return $ut->txt . ' Пользователь ' . $this->card . ' [' . $this->cardcode . ']';
     }
     //if( !empty($this->cardcode) ){ return $ut->txt . ' Пользователь ' . $this->card;  }
     if ($this->modemerror > 0) {
         return $ut->txt . ' [' . $this->modemerror . ']';
     }
     if ($this->temperature > 0) {
         return $ut->txt . ' ' . $this->temperature . ' C';
     }
     return $ut->txt;
 }
 /**
  * Finds the DeviceEventCodeTxt model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return DeviceEventCodeTxt the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = DeviceEventCodeTxt::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }