|
|
|
|
|
|
|
|
$production->actif = $actif; |
|
|
$production->actif = $actif; |
|
|
$production->save(); |
|
|
$production->save(); |
|
|
|
|
|
|
|
|
// envoi emails aux personnes qui souhaitent être informées |
|
|
|
|
|
if ($actif) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
$jour = date('N', strtotime($date)); |
|
|
|
|
|
$arr_jour_semaine = [1 => 'lundi', 2 => 'mardi', 3 => 'mercredi', 4 => 'jeudi', 5 => 'vendredi', 6 => 'samedi', 7 => 'dimanche']; |
|
|
|
|
|
|
|
|
|
|
|
$users = User::find()->where('mail_prod_' . $arr_jour_semaine[$jour] . ' = 1')->all(); |
|
|
|
|
|
|
|
|
|
|
|
//$str_date = strtolower(date('l j F', strtotime($date))) ; |
|
|
|
|
|
setlocale(LC_ALL, "fr_FR"); |
|
|
|
|
|
$str_date = strtolower(strftime('%A%e %B', strtotime($date))); |
|
|
|
|
|
$str_date2 = date('d/m', strtotime($date)); |
|
|
|
|
|
|
|
|
|
|
|
foreach ($users as $u) { |
|
|
|
|
|
if (!$u->no_mail) { |
|
|
|
|
|
Yii::$app->mailer->compose() |
|
|
|
|
|
->setTo($u->email) |
|
|
|
|
|
->setFrom(['matthieu@lechatdesnoisettes.com' => 'Le Chat des Noisettes']) |
|
|
|
|
|
->setSubject('[Le Chat des Noisettes] Production de pain du ' . $str_date2) |
|
|
|
|
|
->setTextBody( |
|
|
|
|
|
"Bonjour, |
|
|
|
|
|
|
|
|
|
|
|
Une production de pain est prévue le " . $str_date . ". |
|
|
|
|
|
|
|
|
|
|
|
Cordialement, |
|
|
|
|
|
Matthieu |
|
|
|
|
|
|
|
|
|
|
|
PS : Si vous ne souhaitez plus recevoir ces emails, rendez-vous dans votre compte sur www.lechatdesnoisettes.com. |
|
|
|
|
|
")->send(); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$this->redirect(['index', 'date' => $date]); |
|
|
$this->redirect(['index', 'date' => $date]); |
|
|
} |
|
|
} |
|
|
|
|
|
|