[ 'class' => VerbFilter::class, 'actions' => [ 'delete' => ['post'], ], ], 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'roles' => ['@'], 'matchCallback' => function ($rule, $action) { return $this->getUserModule() ->getAuthorizationChecker() ->isGrantedAsProducer($this->getUserCurrent()); } ] ], ], ]; } /** * Modifie un producteur. */ public function actionUpdate() { $producerContainer = $this->getProducerContainer(); $producerBuilder = $producerContainer->getBuilder(); $request = Yii::$app->request; $model = $this->findModel(GlobalParam::getCurrentProducerId()); $logoFilenameOld = $model->logo; $photoFilenameOld = $model->photo; $producerBuilder->initOptionDashboardDatesDisplay($model); if ($model->load(\Yii::$app->request->post())) { $model->logoFile = UploadedFile::getInstance($model, 'logoFile'); $model->photoFile = UploadedFile::getInstance($model, 'photoFile'); if($model->validate()) { $producerBuilder->processUploadImage($model, 'logo', $logoFilenameOld, $request->post('delete_logo', 0)); $producerBuilder->processUploadImage($model, 'photo', $photoFilenameOld, $request->post('delete_photo', 0)); $producerBuilder->initOptionDashboardDatesBeforeSave($model); $producerBuilder->savePrivateKeysStripe($model); $model->save(); $this->setFlash('success', 'Paramètres mis à jour.'); return $this->redirect(['update', 'id' => $model->id, 'edit_ok' => true]); } } if ($model->load(\Yii::$app->request->post())) { $this->setFlash('error', 'Le formulaire comporte des erreurs.'); } return $this->render('update', [ 'model' => $model, ]); } /** * Affiche le formulaire permettant au producteur de définir le montant * de son abonnement. */ public function actionBilling() { $producer = Producer::findOne(GlobalParam::getCurrentProducerId()); if ($producer->load(\Yii::$app->request->post())) { $producer->save(); if (!is_null($producer->free_price)) { $alertFreeprice = true; } } $dataProviderPrices = new ActiveDataProvider([ 'query' => ProducerPriceRange::find() ->orderBy('id ASC'), 'pagination' => [ 'pageSize' => 100, ], ]); return $this->render('billing', [ 'dataProviderPrices' => $dataProviderPrices, 'producer' => $producer, 'alertFreePrice' => (isset($alertFreeprice)) ? true : false ]); } /** * Recherche un établissement via son ID. */ protected function findModel(int $id) { if (($model = Producer::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } } public function actionUpdateOpendistribVersion() { $producerManager = $this->getProducerManager(); $producerManager->updateOpendistribVersion($this->getProducerCurrent()); return $this->redirect(\Yii::$app->request->referrer); } public function actionPagesize() { $producerCurrent = $this->getProducerCurrent(); $request = Yii::$app->request; if($request->isPost) { $entity = $request->post('entity'); $pageSize = $request->post('pagesize'); $this->getProducerContainer()->getProducerPageSizer() ->updatePagesize($producerCurrent, $entity, $pageSize); } $referer = strtok(Yii::$app->request->referrer, "?"); return $this->redirect($referer); } }