示例#1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Notice::find()->where('is_status <> 2');
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['notice_id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['notice_id' => $this->notice_id, 'notice_date' => $this->dbDateSearch($this->notice_date), 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by, 'is_status' => $this->is_status]);
     $query->andFilterWhere(['like', 'notice_title', $this->notice_title])->andFilterWhere(['like', 'notice_description', $this->notice_description])->andFilterWhere(['like', 'notice_user_type', $this->notice_user_type])->andFilterWhere(['like', 'notice_file_path', $this->notice_file_path]);
     unset($_SESSION['exportData']);
     $_SESSION['exportData'] = $dataProvider;
     return $dataProvider;
 }
示例#2
0
 public function actionNoticeFile($nid)
 {
     $path = Yii::getAlias('@webroot') . '/data/notice/';
     $model = Notice::find()->where('notice_id = ' . $nid)->one();
     $nfile = $path . $model->notice_file_path;
     $ext = substr(strrchr($model->notice_file_path, '.'), 1);
     if (!empty($model) && file_exists($nfile)) {
         return Yii::$app->response->sendFile($nfile, date('Y-m-dHis') . "." . $ext);
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }