Add support for customer booking notifications and phone number updates

- Introduced phone number update functionality in `userSecurityRoute`.
- Enhanced `order_bookings_o` to send booking confirmations to customers via SMS and email.
- Added `sendOrderBookingConfirmationEmail` method in `email` for HTML-based email notifications.
- Updated `notifyNewBooking` to include customer confirmation logic with SMS and email.
- Adjusted `users_o` to make phone and email properties public and added `setPhoneNumber` method.
- Optimized notification logic in `order_bookings_o` with department and customer-specific notifications.
This commit is contained in:
Jeppe Bundgaard
2025-11-11 13:24:32 +01:00
parent 7f838c0961
commit ccb049519c
4 changed files with 175 additions and 36 deletions
+47
View File
@@ -335,5 +335,52 @@ class email implements email_i
);
}
/**
* @throws JsonException
* @throws Exception
*/
public function sendOrderBookingConfirmationEmail(\objects\order_bookings_o $order_booking): void
{
// Validate the booking object
$order_booking->requireSelected();
// Get customer details
$customer = (new users_o())->getUserByCustomerNumber((int)$order_booking->customer_number->value());
$customer->requireSelected();
$recipient_name = $customer->getCustomerName((int)$customer->customer_number->value());
$recipient_email = $customer->email->value();
// Get the department details
$department = (new departments_o())->select((int)$order_booking->department->value());
$department->requireSelected();
// Generate HTML email
$html = self::generateHtmlHeader();
// Add email content
$html .= (new email_template_booking_confirmation(
$order_booking->id,
$recipient_name,
$customer->customer_number->value(),
$customer->email->value(),
$order_booking->reference->value(),
$order_booking->reg_1->value(),
$order_booking->reg_2->value(),
($order_booking->containsWashCertificateItem() ? 'Ja' : 'Nej'),
$customer->email->value(), // Wash certificate email is the customer's email
$order_booking->datetime->value(),
(string)$department->getDepartmentName((int)$department->id),
(string)$department->getBranding()->address->value(),
!!$order_booking->pickup->value() ? 'Ja' : 'Nej',
$order_booking->note->value()
))->generate_html();
// Add email footer
$html .= self::generateHtmlFooter();
// Send email
$this->sendEmailMailerSend(
$recipient_email,
$department->getDepartmentName((int)$department->id),
'Truck Wash Booking ( ID: ' . $order_booking->id . ', REF: ' . $order_booking->reference->value() . ' )',
'',
$html
);
}
}