{ | { | ||||
public function beforeAction($event) | public function beforeAction($event) | ||||
{ | { | ||||
$producerCurrent = $this->getProducerCurrent(); | |||||
// Contexte producteur | // Contexte producteur | ||||
$this->getLogic()->setProducerContext($this->getProducerCurrent()); | |||||
if($producerCurrent) { | |||||
$this->getLogic()->setProducerContext($producerCurrent); | |||||
} | |||||
// Pas de producteur défini | |||||
if(!$producerCurrent) { | |||||
$this->redirect(\Yii::$app->urlManagerFrontend->createAbsoluteUrl(['site/index'])); | |||||
return false; | |||||
} | |||||
return parent::beforeAction($event); | return parent::beforeAction($event); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
public function getProducerCurrent(): Producer | |||||
public function getProducerCurrent(): ?Producer | |||||
{ | { | ||||
return Producer::searchOne(); | return Producer::searchOne(); | ||||
} | } |
<section class="content"> | <section class="content"> | ||||
<?php $producer = GlobalParam::getCurrentProducer(); ?> | <?php $producer = GlobalParam::getCurrentProducer(); ?> | ||||
<?php if(!$producerManager->isUpToDateWithOpendistribVersion($producer) && $producer->option_display_message_new_opendistrib_version): ?> | |||||
<?php if($producer && !$producerManager->isUpToDateWithOpendistribVersion($producer) && $producer->option_display_message_new_opendistrib_version): ?> | |||||
<div class="alert alert-warning"> | <div class="alert alert-warning"> | ||||
<p>Opendistrib a été mis à jour vers la version <?= GlobalParam::getOpendistribVersion() ?> ! <a class="alert-link" href="<?= Yii::$app->urlManager->createUrl(['development/index']) ?>">Découvrir les nouveautés</a></p> | <p>Opendistrib a été mis à jour vers la version <?= GlobalParam::getOpendistribVersion() ?> ! <a class="alert-link" href="<?= Yii::$app->urlManager->createUrl(['development/index']) ?>">Découvrir les nouveautés</a></p> | ||||
<a href="<?= Yii::$app->urlManager->createUrl(['producer/update-opendistrib-version']) ?>" class="close"><span aria-hidden="true">×</span></a> | <a href="<?= Yii::$app->urlManager->createUrl(['producer/update-opendistrib-version']) ?>" class="close"><span aria-hidden="true">×</span></a> |
<?php | <?php | ||||
$producer = GlobalParam::getCurrentProducer(); | $producer = GlobalParam::getCurrentProducer(); | ||||
$newVersionOpendistribTemplate = ''; | $newVersionOpendistribTemplate = ''; | ||||
if(!$producerManager->isUpToDateWithOpendistribVersion($producer)) { | |||||
if($producer && !$producerManager->isUpToDateWithOpendistribVersion($producer)) { | |||||
$newVersionOpendistribTemplate = '<span class="pull-right-container"><small class="label pull-right bg-orange"> </small></span>'; | $newVersionOpendistribTemplate = '<span class="pull-right-container"><small class="label pull-right bg-orange"> </small></span>'; | ||||
} | } | ||||
?> | ?> |
$errorPointSale = false; | $errorPointSale = false; | ||||
if (isset($distribution) && $distribution) { | if (isset($distribution) && $distribution) { | ||||
$order->populateDistribution($distribution); | |||||
$pointSale = $pointSaleManager->findOnePointSaleById($posts['Order']['id_point_sale']); | $pointSale = $pointSaleManager->findOnePointSaleById($posts['Order']['id_point_sale']); | ||||
$pointSaleDistribution = $pointSaleDistributionManager->findOnePointSaleDistribution($distribution, $pointSale); | $pointSaleDistribution = $pointSaleDistributionManager->findOnePointSaleDistribution($distribution, $pointSale); | ||||