Ejemplo n.º 1
0
 /**
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = ReportItem::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['employee' => SORT_ASC]]]);
     if (!$this->load($params) || !$this->validate()) {
         $query->where(['1' => false]);
         return $dataProvider;
     }
     /** @var Report $report */
     $report = Report::findOne(['operatorId' => $this->operatorId, 'period' => $this->_period]);
     $query->andWhere(['reportId' => $report->primaryKey]);
     $query->andWhere(['or', ['number' => ['$in' => $this->_numbers]], ['employee' => ['$in' => $this->_employees]]]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * Finds the Report model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Report the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Report::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('Запрашиваемый отчет не найден.');
     }
 }