[ '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() { $producerModule = $this->getProducerModule(); $producerBuilder = $producerModule->getBuilder(); $request = Yii::$app->request; $model = $this->findModel(GlobalParam::getCurrentProducerId()); $logoFilenameOld = $model->logo; $photoFilenameOld = $model->photo; $documentImageBottomFilenameOld = $model->document_image_bottom; $producerBuilder->initOptionsDatesDisplay($model); if ($model->load(\Yii::$app->request->post())) { $model->logoFile = UploadedFile::getInstance($model, 'logoFile'); $model->photoFile = UploadedFile::getInstance($model, 'photoFile'); $model->document_image_bottomFile = UploadedFile::getInstance($model, 'document_image_bottomFile'); if($model->validate()) { $producerBuilder->initOptionsDatesBeforeSave($model); $producerBuilder->processUploadImage($model, 'logo', $logoFilenameOld, $request->post('delete_logo', 0)); $producerBuilder->processUploadImage($model, 'photo', $photoFilenameOld, $request->post('delete_photo', 0)); $producerBuilder->processUploadImage($model, 'document_image_bottom', $documentImageBottomFilenameOld, $request->post('delete_document_image_bottom', 0)); $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', [ 'paidFeaturesArray' => $this->getFeatureModule()->getRepository()->findPaidFeatures(), '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() { $producerModule = $this->getProducerModule(); $producerModule->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->getProducerModule()->getProducerPageSizer() ->updatePagesize($producerCurrent, $entity, $pageSize); } $referer = strtok(Yii::$app->request->referrer, "?"); return $this->redirect($referer); } }