[ 'class' => VerbFilter::className(), 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::className(), 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return Yii::$app->user->identity->status == USER::STATUS_ADMIN || Yii::$app->user->identity->status == USER::STATUS_BOULANGER; } ] ], ], ]; } /** * Modifie un établissement. * * @return mixed */ public function actionUpdate() { $request = Yii::$app->request; $model = $this->findModel(Yii::$app->user->identity->id_etablissement); $logo_filename_old = $model->logo; $photo_filename_old = $model->photo; if ($model->load(Yii::$app->request->post()) && $model->save()) { Upload::uploadFile($model, 'logo', $logo_filename_old); Upload::uploadFile($model, 'photo', $photo_filename_old); $delete_logo = $request->post('delete_logo', 0); if ($delete_logo) { $model->logo = ''; $model->save(); } $delete_photo = $request->post('delete_photo', 0); if ($delete_photo) { $model->photo = ''; $model->save(); } return $this->redirect(['update', 'id' => $model->id, 'edit_ok' => true]); } else { return $this->render('update', [ 'model' => $model, ]); } } /** * Affiche le formulaire permettant au producteur de définir le montant * de son abonnement. * * @return mixed */ public function actionFacturation() { $datas_factures = new ActiveDataProvider([ 'query' => Facture::find() ->where(['id_etablissement' => Yii::$app->user->identity->id_etablissement]) ->orderBy('reference DESC'), 'pagination' => [ 'pageSize' => 1000, ], ]); $etablissement = Etablissement::findOne(Yii::$app->user->identity->id_etablissement); if ($etablissement->load(Yii::$app->request->post())) { $etablissement->save(); if (!is_null($etablissement->prix_libre)) $alert_prix_libre = true; } return $this->render('facturation', [ 'datas_factures' => $datas_factures, 'etablissement' => $etablissement, 'alert_prix_libre' => (isset($alert_prix_libre)) ? true : false ]); } /** * Recherche un établissement via son ID. * * @param integer $id * @return Etablissement * @throws NotFoundHttpException */ protected function findModel($id) { if (($model = Etablissement::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } }