예제 #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     if (Yii::$app->user->identity->username != 'admin' and Yii::$app->user->identity->username != 'Ceragon') {
         $query = GlobalTest::find()->andWhere(['FACILITY' => Yii::$app->user->identity->username]);
     } else {
         $query = GlobalTest::find();
     }
     // add conditions that should always apply here
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['TESTDATE' => SORT_DESC, 'id' => SORT_DESC]]]);
     $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;
     }
     // grid filtering conditions
     $query->andFilterWhere(['id' => $this->id, 'FACILITY' => $this->FACILITY, 'TESTDATE' => $this->TESTDATE, 'TIMESTART' => $this->TIMESTART, 'TIMESTOP' => $this->TIMESTOP, 'UUTPLACE' => $this->UUTPLACE]);
     $query->andFilterWhere(['like', 'STATIONID', $this->STATIONID])->andFilterWhere(['like', 'FACILITY', $this->FACILITY])->andFilterWhere(['like', 'UUTNAME', $this->UUTNAME])->andFilterWhere(['like', 'PARTNUMBER', $this->PARTNUMBER])->andFilterWhere(['like', 'SERIALNUMBER', $this->SERIALNUMBER])->andFilterWhere(['like', 'TECHNAME', $this->TECHNAME])->andFilterWhere(['like', 'TESTMODE', $this->TESTMODE])->andFilterWhere(['like', 'GLOBALRESULT', $this->GLOBALRESULT])->andFilterWhere(['like', 'VERSIONS', $this->VERSIONS]);
     return $dataProvider;
 }
예제 #2
0
 /**
  * Finds the GlobalTest model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return GlobalTest the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = GlobalTest::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }