@@ -609,5 +609,18 @@ class Producer extends ActiveRecordCommon | |||
return $this->slug.'@opendistrib.net' ; | |||
} | |||
public function getMainContact() | |||
{ | |||
if($this->contact) { | |||
foreach($this->contact as $contact) { | |||
if($contact->is_main_contact) { | |||
return $contact ; | |||
} | |||
} | |||
} | |||
return false ; | |||
} | |||
} | |||
@@ -412,7 +412,7 @@ class OrderController extends ProducerBaseController | |||
// envoi mail de confirmation | |||
if($isNewOrder && Producer::getConfig('option_email_confirm')) { | |||
$user = User::getCurrent() ; | |||
$successMail = Mailjet::sendMail([ | |||
$paramsEmail = [ | |||
'from_email' => $producer->getEmailOpendistrib(), | |||
'from_name' => $producer->name, | |||
'to_email' => $user->email, | |||
@@ -426,7 +426,15 @@ class OrderController extends ProducerBaseController | |||
'distribution' => $distribution, | |||
'user' => $user | |||
] | |||
]); | |||
] ; | |||
$successMail = Mailjet::sendMail($paramsEmail); | |||
$contactProducer = $producer->getMainContact() ; | |||
if($contactProducer && strlen($contactProducer->email)) { | |||
$paramsEmail['to_email'] = $contactProducer->email ; | |||
$paramsEmail['to_name'] = $contactProducer->name ; | |||
$successMail = Mailjet::sendMail($paramsEmail); | |||
} | |||
} | |||
$order->setTillerSynchronization() ; |
@@ -152,10 +152,9 @@ class SiteController extends ProducerBaseController | |||
$isSent = false ; | |||
if (is_array($producer->contact)) { | |||
$email = '' ; | |||
foreach($producer->contact as $contact) { | |||
if($contact->is_main_contact) { | |||
$email = $contact->email ; | |||
} | |||
$contact = $producer->getMainContact() ; | |||
if($contact) { | |||
$email = $contact->email ; | |||
} | |||
if(strlen($email) && $model->sendEmail($email)) { |
@@ -234,12 +234,16 @@ if (!Yii::$app->user->isGuest) { | |||
</div> | |||
<?php endif; ?> | |||
<div id="infos-producer"> | |||
<?php if(!$producer->hasSpecificDelays()): ?> | |||
<?php if(!$producer->hasSpecificDelays() && $producer->order_deadline && $producer->order_delay): ?> | |||
<span data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande"> | |||
<span class="glyphicon glyphicon-time"></span> Commande avant | |||
<strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>, | |||
<span data-toggle="tooltip" data-placement="bottom" | |||
title="Exemple : commande le lundi pour le <?php if ($producer->order_delay == 1): ?>mardi<?php elseif ($producer->order_delay == 2): ?>mercredi<?php elseif ($producer->order_delay == 3): ?>jeudi<?php elseif ($producer->order_delay == 4): ?>vendredi<?php elseif ($producer->order_delay == 5): ?>samedi<?php elseif ($producer->order_delay == 6): ?>dimanche<?php elseif ($producer->order_delay == 7): ?>lundi d'après<?php endif; ?>"><strong><?= Html::encode($producer->order_delay) ?> jour<?php if ($producer->order_delay > 1): ?>s<?php endif; ?></strong> à l'avance</span> | |||
title="Exemple : commande le lundi pour le | |||
<?php if ($producer->order_delay == 1): ?>mardi<?php elseif ($producer->order_delay == 2): ?>mercredi | |||
<?php elseif ($producer->order_delay == 3): ?>jeudi<?php elseif ($producer->order_delay == 4): ?>vendredi | |||
<?php elseif ($producer->order_delay == 5): ?>samedi<?php elseif ($producer->order_delay == 6): ?>dimanche | |||
<?php elseif ($producer->order_delay == 7): ?>lundi d'après<?php endif; ?>"><strong><?= Html::encode($producer->order_delay) ?> jour<?php if ($producer->order_delay > 1): ?>s<?php endif; ?></strong> à l'avance</span> | |||
<?php endif; ?> | |||
<?php if (!Yii::$app->user->isGuest): ?> |
@@ -143,7 +143,7 @@ $this->setPageTitle(Html::encode($producer->type.' à '.$producer->city)) ; | |||
$html .= ' / '.Html::encode($model->description) ; | |||
} | |||
if(strlen($model->recipe)) { | |||
$html .= '<br />'.Html::encode($model->recipe) ; | |||
$html .= '<br />'.nl2br(Html::encode($model->recipe)) ; | |||
} | |||
return $html ; | |||
} |