return $this->slug.'@opendistrib.net' ; | 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 ; | |||||
} | |||||
} | } | ||||
// envoi mail de confirmation | // envoi mail de confirmation | ||||
if($isNewOrder && Producer::getConfig('option_email_confirm')) { | if($isNewOrder && Producer::getConfig('option_email_confirm')) { | ||||
$user = User::getCurrent() ; | $user = User::getCurrent() ; | ||||
$successMail = Mailjet::sendMail([ | |||||
$paramsEmail = [ | |||||
'from_email' => $producer->getEmailOpendistrib(), | 'from_email' => $producer->getEmailOpendistrib(), | ||||
'from_name' => $producer->name, | 'from_name' => $producer->name, | ||||
'to_email' => $user->email, | 'to_email' => $user->email, | ||||
'distribution' => $distribution, | 'distribution' => $distribution, | ||||
'user' => $user | '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() ; | $order->setTillerSynchronization() ; |
$isSent = false ; | $isSent = false ; | ||||
if (is_array($producer->contact)) { | if (is_array($producer->contact)) { | ||||
$email = '' ; | $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)) { | if(strlen($email) && $model->sendEmail($email)) { |
</div> | </div> | ||||
<?php endif; ?> | <?php endif; ?> | ||||
<div id="infos-producer"> | <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 data-toggle="tooltip" data-placement="bottom" title="Heure limite de commande"> | ||||
<span class="glyphicon glyphicon-time"></span> Commande avant | <span class="glyphicon glyphicon-time"></span> Commande avant | ||||
<strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>, | <strong><?php echo Html::encode($producer->order_deadline) ?> h</strong></span>, | ||||
<span data-toggle="tooltip" data-placement="bottom" | <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 endif; ?> | ||||
<?php if (!Yii::$app->user->isGuest): ?> | <?php if (!Yii::$app->user->isGuest): ?> |
$html .= ' / '.Html::encode($model->description) ; | $html .= ' / '.Html::encode($model->description) ; | ||||
} | } | ||||
if(strlen($model->recipe)) { | if(strlen($model->recipe)) { | ||||
$html .= '<br />'.Html::encode($model->recipe) ; | |||||
$html .= '<br />'.nl2br(Html::encode($model->recipe)) ; | |||||
} | } | ||||
return $html ; | return $html ; | ||||
} | } |