/**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     // die('aass');
     $query = HrAttendanceMinMaxLog::find();
     $sort = ['attributes' => ['employee_name' => ['default' => SORT_ASC], 'y_log' => ['default' => SORT_DESC], 'm_log' => ['default' => SORT_ASC], 'd_log' => ['default' => SORT_ASC], 'dept_name'], 'defaultOrder' => ['employee_name' => SORT_ASC, 'y_log' => SORT_DESC, 'm_log' => SORT_DESC, 'd_log' => SORT_ASC]];
     if ($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, 'dept_id' => $this->dept_id, 'employee_id' => $this->employee_id, 'full_date' => $this->full_date, 'y_log' => $this->y_log, 'm_log' => $this->m_log, 'd_log' => $this->d_log, 'dow_log' => $this->dow_log, 'scan_times_a_day' => $this->scan_times_a_day, 'err_code' => $this->err_code]);
         $query->andFilterWhere(['like', 'dept_name', strtoupper($this->dept_name)])->andFilterWhere(['like', 'employee_name', strtoupper($this->employee_name)])->andFilterWhere(['like', 'min_log', $this->min_log])->andFilterWhere(['like', 'hh_min_log', $this->hh_min_log])->andFilterWhere(['like', 'mm_min_log', $this->mm_min_log])->andFilterWhere(['like', 'min_state_log', $this->min_state_log])->andFilterWhere(['like', 'max_log', $this->max_log])->andFilterWhere(['like', 'hh_max_log', $this->hh_max_log])->andFilterWhere(['like', 'mm_max_log', $this->mm_max_log])->andFilterWhere(['like', 'max_state_log', $this->max_state_log])->andFilterWhere(['like', 'attendance_time', $this->attendance_time]);
         $dataProvider = new \yii\data\ArrayDataProvider(['allModels' => $query->asArray()->all(), 'pagination' => ['pageSize' => 2000], 'sort' => $sort]);
     } else {
         // die();
         $dataProvider = new \yii\data\ArrayDataProvider(['allModels' => $query->where('0=1')->asArray()->all(), 'pagination' => ['pageSize' => 2000], 'sort' => $sort]);
     }
     return $dataProvider;
 }
Exemplo n.º 2
0
 /**
  * Finds the HrAttendanceMinMaxLog model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param string $id
  * @return HrAttendanceMinMaxLog the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = HrAttendanceMinMaxLog::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }