feat: ✨ send an order reminder email

This commit is contained in:
Corentin Huet 2026-01-30 11:38:54 +01:00
parent dc49a08128
commit b3d4d6945e
4 changed files with 78 additions and 43 deletions

View file

@ -26,7 +26,7 @@ class Kernel extends ConsoleKernel
protected function schedule(Schedule $schedule)
{
$schedule->job(JobsXmlIncoReader::class)->name('xml-inco-reader')->onOneServer()->dailyAt('15:00');
$schedule->job(SendReminderMail::class)->onOneServer()->dailyAt('7:00');
$schedule->job(SendReminderMail::class)->onOneServer()->dailyAt('10:00');
$schedule->job(GetPublicHolidayForNextYear::class)->onOneServer()->yearlyOn(11, 1, '7:30');
}

View file

@ -27,7 +27,7 @@ class SendReminderMail implements ShouldQueue
public function handle()
{
$orders = Order::whereHas('timeslot', function (Builder $query) {
$query->where('day', now()->format('d/m/Y'));
$query->where('day', now()->format('Y-m-d'));
})->get();
foreach ($orders as $order) {

View file

@ -42,7 +42,7 @@ class OrderTodayReminderMail extends Mailable
$magasin = Magasin::find($order->timeslot->magasin->id);
return $this->subject(
"Votre commande est prête - " . config('theme.site_name')
"Vous avez une commande à retirer aujourd'hui - " . config('theme.site_name')
)->view('emails.order-reminder', compact('order', 'magasin'));
}
}

View file

@ -2,46 +2,49 @@
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office">
<head>
<title>
</title>
<!--[if !mso]><!-- -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
#outlook a {
padding: 0;
}
<title></title>
<!--[if !mso]><!-- -->
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!--<![endif]-->
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<style type="text/css">
#outlook a {
padding: 0;
}
body {
margin: 0;
padding: 0;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
margin: 0;
padding: 0;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
table,
td {
border-collapse: collapse;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
}
table,
td {
border-collapse: collapse;
mso-table-lspace: 0pt;
mso-table-rspace: 0pt;
}
img {
border: 0;
height: auto;
line-height: 100%;
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
}
img {
border: 0;
height: auto;
line-height: 100%;
outline: none;
text-decoration: none;
-ms-interpolation-mode: bicubic;
}
p {
display: block;
margin: 13px 0;
}
</style>
p {
display: block;
margin: 13px 0;
}
.tbl-line {
padding-bottom: 8px;
}
</style>
<!--[if mso]>
<xml>
<o:OfficeDocumentSettings>
@ -122,7 +125,9 @@
</tr>
<tr>
<td align="center" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:25px;font-weight:bold;line-height:1;text-align:center;text-transform:uppercase;color:black;">VOTRE COMMANDE EST PRÊTE !</div>
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:25px;font-weight:bold;line-height:1;text-align:center;text-transform:uppercase;color:black;">
VOTRE COMMANDE EST À RÉCUPÉRER AUJOURD'HUI DANS VOTRE POINT DE RETRAIT !
</div>
</td>
</tr>
</table>
@ -171,16 +176,46 @@
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:20px;line-height:1;text-align:left;color:black;">
Bonjour {{ $order->customer->salarie->prenom }} {{ Str::upper($order->customer->salarie->nom) }},
<br><br>
Votre commande {{ $order->reference }} est disponible
Votre commande {{ $order->reference }} est confirmée
<br><br>
<table style="border-collapse: separate">
<thead>
<th scope="col" style="width: 40%">Produit</th>
<th scope="col">Quantité</th>
<th scope="col">Prix kilo TTC</th>
<th scope="col">Total TTC</th>
</thead>
<tbody>
@foreach ($order->lines as $line)
<tr>
<td class="tbl-line">{{ $line->product->name }}</td>
<td class="tbl-line">{{ $line->quantity }}</td>
<td class="tbl-line">{{ number_format($line->product->priceKgTtc, 2, ',', ' ') }}€</td>
<td class="tbl-line">{{ number_format($line->total_ttc, 2, ',', ' ') }}€</td>
</tr>
@endforeach
</tbody>
</table>
<br>
N'oubliez pas de la récupérer aujourd'hui dans votre point relais :
Total estimé de la commande : {{ number_format($order->total, 2, ',', ' ') }}€ TTC
<br><br>
*Produit vendu au kilo. Le prix sera recalculé en fonction du poids du produit livré lors de la remise de votre commande. Le prix est donc susceptible de varier sur votre facture.
<br><br>
À retirer le {{ $order->timeslot->day->format('d/m/Y') }} à {{ $order->timeslot->time }}, à l'adresse suivante :
</div>
</td>
</tr>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:20px;line-height:1;text-align:left;color:black;">
<b>Point de retrait {{$magasin->name}}, {{$magasin->address}}, {{$magasin->postcode}} {{$magasin->city}}</b>
<b>Mon point de retrait {{$magasin->name}}, {{$magasin->address}}, {{$magasin->postcode}} {{$magasin->city}}</b>
</div>
</td>
</tr>
<tr>
<td align="left" style="font-size:0px;padding:10px 25px;word-break:break-word;">
<div style="font-family:Ubuntu, Helvetica, Arial, sans-serif;font-size:20px;line-height:1;text-align:left;color:black;">
NB: Nous faisons le maximum pour vous livrer l'intégralité de votre commande, malheureusement certains produits peuvent être en rupture. Vous ne serez pas facturé des produits non livrés.
</div>
</td>
</tr>