|
|
@@ -127,8 +127,7 @@ class SiteController extends FrontendController |
|
|
|
public function actionIndex() |
|
|
|
{ |
|
|
|
return $this->render('index', [ |
|
|
|
'producerDemoAccount' => $this->getLogic()->getProducerContainer() |
|
|
|
->getRepository()->getOneDemoAccount(), |
|
|
|
'producerDemoAccount' => $this->getProducerManager()->findOneProducerDemoAccount(), |
|
|
|
'dataProviderPrices' => $this->getDataProviderPrices() |
|
|
|
]); |
|
|
|
} |
|
|
@@ -146,8 +145,7 @@ class SiteController extends FrontendController |
|
|
|
public function getDataProviderPrices() |
|
|
|
{ |
|
|
|
return new ActiveDataProvider([ |
|
|
|
'query' => $this->getLogic()->getProducerPriceRangeContainer() |
|
|
|
->getRepository()->query(), |
|
|
|
'query' => $this->getProducerPriceRangeManager()->queryProducerPriceRanges(), |
|
|
|
'pagination' => [ |
|
|
|
'pageSize' => 100, |
|
|
|
], |
|
|
@@ -160,8 +158,7 @@ class SiteController extends FrontendController |
|
|
|
public function actionProducers() |
|
|
|
{ |
|
|
|
$dataProviderProducers = new ActiveDataProvider([ |
|
|
|
'query' => $this->getLogic()->getProducerContainer() |
|
|
|
->getRepository()->queryActive(), |
|
|
|
'query' => $this->getProducerManager()->queryProducersActive(), |
|
|
|
'pagination' => [ |
|
|
|
'pageSize' => 100, |
|
|
|
], |
|
|
@@ -189,11 +186,7 @@ class SiteController extends FrontendController |
|
|
|
return $this->redirect($returnUrl); |
|
|
|
} |
|
|
|
else { |
|
|
|
$userProducerArray = $this->getLogic() |
|
|
|
->getUserProducerContainer() |
|
|
|
->getRepository() |
|
|
|
->getBy(GlobalParam::getCurrentUser()); |
|
|
|
|
|
|
|
$userProducerArray = $this->getUserProducerManager()->findUserProducersByUser(GlobalParam::getCurrentUser()); |
|
|
|
if ($userProducerArray |
|
|
|
&& is_array($userProducerArray) |
|
|
|
&& count($userProducerArray) == 1) { |
|
|
@@ -257,7 +250,7 @@ class SiteController extends FrontendController |
|
|
|
public function actionSignup() |
|
|
|
{ |
|
|
|
$model = new SignupForm(); |
|
|
|
$producerRepository = \Yii::$app->logic->getProducerContainer()->getRepository(); |
|
|
|
$producerManager = $this->getProducerManager(); |
|
|
|
|
|
|
|
if ($model->load(Yii::$app->request->post())) { |
|
|
|
$user = $model->signup(); |
|
|
@@ -268,9 +261,9 @@ class SiteController extends FrontendController |
|
|
|
$this->redirect(Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index'])); |
|
|
|
} |
|
|
|
else { |
|
|
|
$producer = $producerRepository->getOneById($model->id_producer); |
|
|
|
$producer = $producerManager->findOneProducerById($model->id_producer); |
|
|
|
if ($producer) { |
|
|
|
$this->redirect(Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); |
|
|
|
$this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); |
|
|
|
} |
|
|
|
else { |
|
|
|
$this->redirect(['site/index']); |
|
|
@@ -281,7 +274,7 @@ class SiteController extends FrontendController |
|
|
|
} |
|
|
|
|
|
|
|
// Liste des producteurs disponibles |
|
|
|
$producersArray = $producerRepository->getPopulateDropdown(); |
|
|
|
$producersArray = $producerManager->populateProducerDropdown(); |
|
|
|
$dataProducers = $producersArray['data']; |
|
|
|
$optionsProducers = $producersArray['options']; |
|
|
|
|
|
|
@@ -348,8 +341,8 @@ class SiteController extends FrontendController |
|
|
|
*/ |
|
|
|
public function actionProducerCode(int $id) |
|
|
|
{ |
|
|
|
$producerContainer = $this->getLogic()->getProducerContainer(); |
|
|
|
$producer = $producerContainer->getRepository()->getOneById($id); |
|
|
|
$producerManager = $this->getProducerManager(); |
|
|
|
$producer = $producerManager->findOneProducerById($id); |
|
|
|
|
|
|
|
if (!$producer) { |
|
|
|
throw new \yii\web\HttpException(404, 'Producteur introuvable'); |
|
|
@@ -361,7 +354,7 @@ class SiteController extends FrontendController |
|
|
|
if ($producerCodeForm->load($this->getRequest()->post()) |
|
|
|
&& $producerCodeForm->validate()) { |
|
|
|
|
|
|
|
$producerContainer->getBuilder()->addUser(GlobalParam::getCurrentUser(), $producer); |
|
|
|
$producerManager->addUser(GlobalParam::getCurrentUser(), $producer); |
|
|
|
|
|
|
|
$this->redirect($this->getUrlManagerProducer()->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug])); |
|
|
|
} |
|
|
@@ -380,9 +373,8 @@ class SiteController extends FrontendController |
|
|
|
{ |
|
|
|
$loginForm = new LoginForm(); |
|
|
|
$signupForm = new SignupForm(); |
|
|
|
$producerContainer = $this->getLogic()->getProducerContainer(); |
|
|
|
|
|
|
|
$producer = $producerContainer->getRepository()->getOneById($id); |
|
|
|
$producerManager = $this->getProducerManager(); |
|
|
|
$producer = $producerManager->findOneProducerById($id); |
|
|
|
$loginForm->id_producer = $id; |
|
|
|
$signupForm->id_producer = $id; |
|
|
|
$signupForm->option_user_producer = 'user'; |
|
|
@@ -391,7 +383,7 @@ class SiteController extends FrontendController |
|
|
|
if ($this->getUser()->isGuest) { |
|
|
|
if ($loginForm->load($this->getRequest()->post()) && $loginForm->login()) { |
|
|
|
if (!strlen($producer->code)) { |
|
|
|
$producerContainer->getBuilder()->addUser(GlobalParam::getCurrentUser(), $producer); |
|
|
|
$producerManager->addUser(GlobalParam::getCurrentUser(), $producer); |
|
|
|
} |
|
|
|
|
|
|
|
$this->redirect($returnUrl); |
|
|
@@ -421,8 +413,7 @@ class SiteController extends FrontendController |
|
|
|
public function actionProducerOffline(int $id) |
|
|
|
{ |
|
|
|
return $this->render('producer_offline', [ |
|
|
|
'producer' => $this->getLogic()->getProducerContainer() |
|
|
|
->getRepository()->getOneById($id), |
|
|
|
'producer' => $this->getProducerManager()->findOneProducerById($id), |
|
|
|
]); |
|
|
|
} |
|
|
|
|