'orders' => $arrayOrders | 'orders' => $arrayOrders | ||||
] | ] | ||||
) | ) | ||||
->setFrom([Yii::$app->params['adminEmail'] => 'distrib']); | |||||
->setFrom([Yii::$app->parameterBag->get('adminEmail') => 'distrib']); | |||||
if (is_array($arrayOrders) && count($arrayOrders)) { | if (is_array($arrayOrders) && count($arrayOrders)) { | ||||
$subject = '[Opendistrib] Commandes du ' . date('d/m', strtotime($date)); | $subject = '[Opendistrib] Commandes du ' . date('d/m', strtotime($date)); |
<ul class="contacts"> | <ul class="contacts"> | ||||
<li> | <li> | ||||
<span class="glyphicon glyphicon-earphone"></span> | <span class="glyphicon glyphicon-earphone"></span> | ||||
<p><?= Html::a('Prendre rendez-vous', Yii::$app->params['appointmentUrl'], ['class' => '', 'target' => '_blank']); ?></p> | |||||
<p><?= Html::a('Prendre rendez-vous', Yii::$app->parameterBag->get('appointmentUrl'), ['class' => '', 'target' => '_blank']); ?></p> | |||||
</li> | </li> | ||||
<li> | <li> | ||||
<span class="glyphicon glyphicon-envelope"></span> | <span class="glyphicon glyphicon-envelope"></span> |
?> | ?> | ||||
<iframe id="matomoframe" src="<?= Yii::$app->params['matomoWidgetDashbordUrl']; ?>" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="800px"></iframe> | |||||
<iframe id="matomoframe" src="<?= Yii::$app->parameterBag->get('matomoWidgetDashbordUrl'); ?>" frameborder="0" marginheight="0" marginwidth="0" width="100%" height="800px"></iframe> |
<span class="info-box-text">Me contacter directement</span> | <span class="info-box-text">Me contacter directement</span> | ||||
<span class="info-box-text"> | <span class="info-box-text"> | ||||
<br/> | <br/> | ||||
<strong><?= Yii::$app->params['adminPhoneNumber'] ?></strong> | |||||
<strong><?= Yii::$app->parameterBag->get('adminPhoneNumber'); ?></strong> | |||||
</span> | </span> | ||||
</div> | </div> | ||||
</div> | </div> | ||||
<span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span> | <span class="info-box-icon bg-yellow"><i class="fa fa-calendar"></i></span> | ||||
<div class="info-box-content"> | <div class="info-box-content"> | ||||
<span class="info-box-text"><br/> | <span class="info-box-text"><br/> | ||||
<?= Html::a('Prendre rendez-vous', Yii::$app->params['appointmentUrl'], ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?> | |||||
<?= Html::a('Prendre rendez-vous', Yii::$app->parameterBag->get('appointmentUrl'), ['class' => 'btn btn-sm btn-default', 'target' => '_blank']); ?> | |||||
</span> | </span> | ||||
</div> | </div> | ||||
</div> | </div> |
public function sendAdmin(string $subject, string $view, array $params = []) | public function sendAdmin(string $subject, string $view, array $params = []) | ||||
{ | { | ||||
$message = $this->composeBase(\Yii::$app->params['adminEmail'], $view, $params); | |||||
$message = $this->composeBase(\Yii::$app->parameterBag->get('adminEmail'), $view, $params); | |||||
$this->initMessageFromSite($message, $subject); | $this->initMessageFromSite($message, $subject); | ||||
$message->send(); | $message->send(); | ||||
} | } | ||||
private function initMessageFromSite(MessageInterface $message, string $subject) | private function initMessageFromSite(MessageInterface $message, string $subject) | ||||
{ | { | ||||
$message->setFrom([\Yii::$app->params['adminEmail'] => \Yii::$app->params['siteName']]); | |||||
$message->setSubject($this->buildSubject(\Yii::$app->params['siteName'], $subject)); | |||||
$message->setFrom([\Yii::$app->parameterBag->get('adminEmail') => \Yii::$app->parameterBag->get('siteName')]); | |||||
$message->setSubject($this->buildSubject(\Yii::$app->parameterBag->get('siteName'), $subject)); | |||||
return $message; | return $message; | ||||
} | } | ||||
<?php | |||||
namespace common\components; | |||||
use yii\base\ErrorException; | |||||
class ParameterBag | |||||
{ | |||||
protected array $parameters = []; | |||||
public function __construct() | |||||
{ | |||||
$this->parameters = \Yii::$app->params; | |||||
} | |||||
public function get(string $name) | |||||
{ | |||||
if(isset($this->parameters[$name])) { | |||||
return $this->parameters[$name]; | |||||
} | |||||
else { | |||||
throw new ErrorException('Paramètre '.$name.' non défini.'); | |||||
} | |||||
} | |||||
public function has(string $name) | |||||
{ | |||||
return \array_key_exists($name, $this->parameters); | |||||
} | |||||
public function set(string $name, $value) | |||||
{ | |||||
$this->parameters[$name] = $value; | |||||
} | |||||
} |
} | } | ||||
}, | }, | ||||
'components' => [ | 'components' => [ | ||||
'parameterBag' => [ | |||||
'class' => 'common\components\ParameterBag' | |||||
], | |||||
'assetManager' => [ | 'assetManager' => [ | ||||
'linkAssets' => YII_ENV == "dev" ? 'true' : false, | 'linkAssets' => YII_ENV == "dev" ? 'true' : false, | ||||
], | ], |
public static function createProducerEmailRedirection(Producer $producer) | public static function createProducerEmailRedirection(Producer $producer) | ||||
{ | { | ||||
return self::post('mailbox',[ | return self::post('mailbox',[ | ||||
'domain' => \Yii::$app->params['alwaysdataDomainOpendistribId'], | |||||
'domain' => \Yii::$app->parameterBag->get('alwaysdataDomainOpendistribId'), | |||||
'name' => $producer->slug, | 'name' => $producer->slug, | ||||
'password' => Password::generate(13), | 'password' => Password::generate(13), | ||||
'redirect_enabled' => true, | 'redirect_enabled' => true, | ||||
self::checkConfiguration(); | self::checkConfiguration(); | ||||
return new Client([ | return new Client([ | ||||
'base_uri' => \Yii::$app->params['alwaysdataApiUrl'].$resource.'/', | |||||
'auth' => [\Yii::$app->params['alwaysdataApiKey'].' account='.\Yii::$app->params['alwaysdataAccount'], ''], | |||||
'base_uri' => \Yii::$app->parameterBag->get('alwaysdataApiUrl').$resource.'/', | |||||
'auth' => [\Yii::$app->parameterBag->get('alwaysdataApiKey').' account='.\Yii::$app->parameterBag->get('alwaysdataAccount'), ''], | |||||
]); | ]); | ||||
} | } | ||||
private static function checkConfiguration() | private static function checkConfiguration() | ||||
{ | { | ||||
if(!isset(\Yii::$app->params['alwaysdataApiUrl']) | |||||
|| !isset(\Yii::$app->params['alwaysdataAccount']) | |||||
|| !isset(\Yii::$app->params['alwaysdataApiKey']) | |||||
|| !isset(\Yii::$app->params['alwaysdataDomainOpendistribId'])) { | |||||
if(!\Yii::$app->parameterBag->has('alwaysdataApiUrl') | |||||
|| !\Yii::$app->parameterBag->has('alwaysdataAccount') | |||||
|| !\Yii::$app->parameterBag->has('alwaysdataApiKey') | |||||
|| !\Yii::$app->parameterBag->has('alwaysdataDomainOpendistribId')) { | |||||
throw new ErrorException('Configuration API Alwaysdata absente ou incomplète dans params-local.php'); | throw new ErrorException('Configuration API Alwaysdata absente ou incomplète dans params-local.php'); | ||||
} | } |
return self::getCurrentProducer(); | return self::getCurrentProducer(); | ||||
} else { | } else { | ||||
return \Yii::$app->params[$key]; | |||||
return \Yii::$app->parameterBag->get($key); | |||||
} | } | ||||
} | } | ||||
public static function getCurrentProducer() | public static function getCurrentProducer() | ||||
{ | { | ||||
if (\Yii::$app->params['producer'] == false) { | |||||
\Yii::$app->params['producer'] = Producer::searchOne(); | |||||
if(!\Yii::$app->parameterBag->has('producer') || !\Yii::$app->parameterBag->get('producer')) { | |||||
\Yii::$app->parameterBag->set('producer', Producer::searchOne()); | |||||
} | } | ||||
return \Yii::$app->params['producer']; | |||||
return \Yii::$app->parameterBag->get('producer'); | |||||
} | } | ||||
/** | /** |
], [ | ], [ | ||||
'producer' => $producer | 'producer' => $producer | ||||
]) | ]) | ||||
->setTo(\Yii::$app->params['adminEmail']) | |||||
->setFrom([\Yii::$app->params['adminEmail'] => 'distrib']) | |||||
->setTo(\Yii::$app->parameterBag->get('adminEmail')) | |||||
->setFrom([\Yii::$app->parameterBag->get('adminEmail') => 'Opendistrib']) | |||||
->setSubject('[Opendistrib] Nouveau producteur') | ->setSubject('[Opendistrib] Nouveau producteur') | ||||
->send(); | ->send(); | ||||
} | } |
if (empty($token)) { | if (empty($token)) { | ||||
return false; | return false; | ||||
} | } | ||||
$expire = \Yii::$app->params['user.passwordResetTokenExpire']; | |||||
$expire = \Yii::$app->parameterBag->get('user.passwordResetTokenExpire'); | |||||
$parts = explode('_', $token); | $parts = explode('_', $token); | ||||
$timestamp = (int)end($parts); | $timestamp = (int)end($parts); | ||||
return $timestamp + $expire >= time(); | return $timestamp + $expire >= time(); |
<?php if($user->status == User::STATUS_PRODUCER): ?> | <?php if($user->status == User::STATUS_PRODUCER): ?> | ||||
<p>Vous pouvez dès maintenant vous connecter à l'<a href="<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?>">administration</a> pour configurer votre compte producteur.</p> | <p>Vous pouvez dès maintenant vous connecter à l'<a href="<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?>">administration</a> pour configurer votre compte producteur.</p> | ||||
<p>Si vous avez des questions ou si vous avez besoin d'être accompagné lors de cette étape, n'hésitez pas à me contacter en réponse à ce mail ou directement au <strong><?= Yii::$app->params['adminPhoneNumber'] ?></strong>.</p> | |||||
<p>Si vous avez des questions ou si vous avez besoin d'être accompagné lors de cette étape, n'hésitez pas à me contacter en réponse à ce mail ou directement au <strong><?= Yii::$app->parameterBag->get('adminPhoneNumber') ?></strong>.</p> | |||||
<?php else: ?> | <?php else: ?> | ||||
<?php if(!is_null($producer)): ?> | <?php if(!is_null($producer)): ?> | ||||
<p>Vous pouvez maintenant <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]); ?>">passer commande</a> chez votre producteur <strong><?= Html::encode($producer->name); ?></strong>.</p> | <p>Vous pouvez maintenant <a href="<?= Yii::$app->urlManagerProducer->createAbsoluteUrl(['site/index', 'slug_producer' => $producer->slug]); ?>">passer commande</a> chez votre producteur <strong><?= Html::encode($producer->name); ?></strong>.</p> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<p>À bientôt,<br /> | <p>À bientôt,<br /> | ||||
<?= Yii::$app->params['adminFirstname'] ?></p> | |||||
<?= Yii::$app->parameterBag->get('adminFirstname') ?></p> |
Vous pouvez dès maintenant vous connecter à l'administration pour configurer votre compte : | Vous pouvez dès maintenant vous connecter à l'administration pour configurer votre compte : | ||||
<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?> | <?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?> | ||||
Si vous avez des questions ou si vous avez besoin d'être accompagné lors de cette étape, n'hésitez pas à me contacter en réponse à ce mail ou directement au <?= Yii::$app->params['adminPhoneNumber'] ?>. | |||||
Si vous avez des questions ou si vous avez besoin d'être accompagné lors de cette étape, n'hésitez pas à me contacter en réponse à ce mail ou directement au <?= Yii::$app->parameterBag->get('adminPhoneNumber'); ?>. | |||||
<?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?> | <?= Yii::$app->urlManagerBackend->createAbsoluteUrl(['site/index']); ?> | ||||
<?php else: ?> | <?php else: ?> | ||||
<?php if(!is_null($producer)): ?> | <?php if(!is_null($producer)): ?> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
À bientôt, | À bientôt, | ||||
<?= Yii::$app->params['adminFirstname'] ?> | |||||
<?= Yii::$app->parameterBag->get('adminFirstname') ?> |
_paq.push(['trackPageView']); | _paq.push(['trackPageView']); | ||||
_paq.push(['enableLinkTracking']); | _paq.push(['enableLinkTracking']); | ||||
(function() { | (function() { | ||||
var u="//<?= Yii::$app->params['matomoUrl']; ?>/"; | |||||
var u="//<?= Yii::$app->parameterBag->get('matomoUrl'); ?>/"; | |||||
_paq.push(['setTrackerUrl', u+'matomo.php']); | _paq.push(['setTrackerUrl', u+'matomo.php']); | ||||
_paq.push(['setSiteId', '<?= Yii::$app->params['matomoIdSite']; ?>']); | |||||
_paq.push(['setSiteId', '<?= Yii::$app->parameterBag->get('matomoIdSite'); ?>']); | |||||
var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; | var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0]; | ||||
g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); | g.async=true; g.src=u+'matomo.js'; s.parentNode.insertBefore(g,s); | ||||
})(); | })(); |
$countUsersActive = $userManager->countUsersActiveLastThreeMonths(); | $countUsersActive = $userManager->countUsersActiveLastThreeMonths(); | ||||
$averageOrdersPerDay = $orderManager->countGlobalUserOrdersAverageLastSevenDays(); | $averageOrdersPerDay = $orderManager->countGlobalUserOrdersAverageLastSevenDays(); | ||||
$averageTurnover = $orderManager->getAverageTurnoverLastThreeMonths(); | $averageTurnover = $orderManager->getAverageTurnoverLastThreeMonths(); | ||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->params['matomoApiVisitSummaryUrl'])); | |||||
$resultMatomoApiVisitSummary = json_decode(file_get_contents(Yii::$app->parameterBag->get('matomoApiVisitSummaryUrl'))); | |||||
$numberVisitsMonth = $resultMatomoApiVisitSummary->nb_uniq_visitors; | $numberVisitsMonth = $resultMatomoApiVisitSummary->nb_uniq_visitors; | ||||
return $this->renderPartial('_about_few_numbers', [ | return $this->renderPartial('_about_few_numbers', [ | ||||
$model = new ContactForm(); | $model = new ContactForm(); | ||||
if ($model->load(Yii::$app->request->post()) && $model->validate()) { | if ($model->load(Yii::$app->request->post()) && $model->validate()) { | ||||
if ($model->sendEmail(Yii::$app->params['adminEmail'])) { | |||||
if ($model->sendEmail(Yii::$app->parameterBag->get('adminEmail'))) { | |||||
$this->setFlash('success', 'Votre message a bien été envoyé. Nous vous répondrons dès que possible.'); | $this->setFlash('success', 'Votre message a bien été envoyé. Nous vous répondrons dès que possible.'); | ||||
} | } | ||||
else { | else { |
<span class="glyphicon glyphicon-plus-sign"></span> En savoir plus | <span class="glyphicon glyphicon-plus-sign"></span> En savoir plus | ||||
</a> | </a> | ||||
<?php if (Yii::$app->user->isGuest): ?><br /><?php endif; ?> | <?php if (Yii::$app->user->isGuest): ?><br /><?php endif; ?> | ||||
<a class="btn btn-default" href="<?= \Yii::$app->params['appointmentUrl']; ?>" target="_blank"> | |||||
<a class="btn btn-default" href="<?= \Yii::$app->parameterBag->get('appointmentUrl'); ?>" target="_blank"> | |||||
<span class="glyphicon glyphicon-education"></span> Je demande une démo | <span class="glyphicon glyphicon-education"></span> Je demande une démo | ||||
</a> | </a> | ||||
<?php if (Yii::$app->user->isGuest): ?> | <?php if (Yii::$app->user->isGuest): ?> |
href="<?= $this->getUrlManagerFrontend()->createUrl(['site/producer', 'id' => 32]); ?>"> | href="<?= $this->getUrlManagerFrontend()->createUrl(['site/producer', 'id' => 32]); ?>"> | ||||
<span class="glyphicon glyphicon-check"></span> Je teste le logiciel | <span class="glyphicon glyphicon-check"></span> Je teste le logiciel | ||||
</a> | </a> | ||||
<a class="btn btn-default" href="<?= \Yii::$app->params['appointmentUrl']; ?>" | |||||
<a class="btn btn-default" href="<?= \Yii::$app->parameterBag->get('appointmentUrl'); ?>" | |||||
target="_blank"> | target="_blank"> | ||||
<span class="glyphicon glyphicon-education"></span> Je demande une démo | <span class="glyphicon glyphicon-education"></span> Je demande une démo | ||||
</a> | </a> |