public function searchHistorique($params, $id) { $query = Transferer::find()->where(['codebien' => $id]); $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(['codebien' => $this->codebien]); $query->andFilterWhere(['like', 'dt', $this->dt])->andFilterWhere(['like', 'codebureau', $this->codebureau])->andFilterWhere(['like', 'motif', $this->motif]); return $dataProvider; }
/** * Finds the Transferer model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param string $codebien * @param string $dt * @param string $codebureau * @return Transferer the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($codebien, $dt, $codebureau) { if (($model = Transferer::findOne(['codebien' => $codebien, 'dt' => $dt, 'codebureau' => $codebureau])) !== null) { return $model; } else { throw new NotFoundHttpException('La page demandée n existe pas.'); } }
protected function dernierTransfert($code) { $burDe = ''; $burVer = ''; $models = Transferer::find()->where(['codebien' => $code])->orderBy(['dt' => SORT_ASC])->all(); if ($models) { $cont = Transferer::find()->where(['codebien' => $code])->orderBy('dt')->count(); $i = 0; foreach ($models as $model) { $bureau[$i] = $model->codebureau; $i++; } if ($cont == 1) { $burVer = $bureau[0]; } if ($cont != 1) { for ($i = 0; $i < $cont - 1; $i++) { $burDe = $bureau[$i]; $burVer = $bureau[$i + 1]; } } } return $burVer; }