implement reservation controller for slot availability and submission logic

This commit is contained in:
Alaguraj0361 2026-03-30 19:35:58 +05:30
parent 3429feece9
commit 2e1b4358b1

View File

@ -271,50 +271,61 @@ class TableReservationController(http.Controller):
# Send Emails
try:
company_email = request.env.company.email or 'info@chennora.ca'
import logging
_logger = logging.getLogger(__name__)
# Use the configured outgoing mail server's FROM address (must match SMTP username)
outgoing_server = request.env['ir.mail_server'].sudo().search([], limit=1)
smtp_from = outgoing_server.smtp_user if outgoing_server else 'alaguraj0361@gmail.com'
# 1. Notify the Company
# 1. Notify the Company (Admin)
admin_mail_values = {
'subject': f"New Table Reservation: {customer_name}",
'body_html': f"""
<p>A new table reservation has been submitted successfully.</p>
<ul>
<li><b>Customer Name:</b> {customer_name}</li>
<li><b>Phone:</b> {phone}</li>
<li><b>Email:</b> {email}</li>
<li><b>Number of Guests:</b> {num_people}</li>
<li><b>Time:</b> {start_time_str}</li>
</ul>
<div style="font-family: Arial, sans-serif; padding: 20px;">
<h2 style="color: #2BB1A5;">New Table Reservation</h2>
<p>A new table reservation has been submitted from the website.</p>
<table style="width:100%; border-collapse: collapse;">
<tr><td style="padding:8px; font-weight:bold;">Customer Name:</td><td style="padding:8px;">{customer_name}</td></tr>
<tr><td style="padding:8px; font-weight:bold;">Phone:</td><td style="padding:8px;">{phone}</td></tr>
<tr><td style="padding:8px; font-weight:bold;">Email:</td><td style="padding:8px;">{email}</td></tr>
<tr><td style="padding:8px; font-weight:bold;">Number of Guests:</td><td style="padding:8px;">{num_people}</td></tr>
<tr><td style="padding:8px; font-weight:bold;">Reservation Time:</td><td style="padding:8px;">{start_time_str}</td></tr>
</table>
</div>
""",
'email_to': 'alaguraj0361@gmail.com',
'email_from': company_email,
'email_from': smtp_from,
'reply_to': email,
}
admin_mail = request.env['mail.mail'].sudo().create(admin_mail_values)
admin_mail.send()
_logger.info("Admin reservation notification sent to alaguraj0361@gmail.com")
# 2. Notify the Customer
customer_mail_values = {
'subject': f"Reservation Confirmation - Chennora",
'subject': "Reservation Confirmation - Chennora",
'body_html': f"""
<p>Dear {customer_name},</p>
<p>Your table reservation has been confirmed successfully!</p>
<p><b>Reservation Details:</b></p>
<ul>
<li><b>Number of Guests:</b> {num_people}</li>
<li><b>Time:</b> {start_time_str}</li>
</ul>
<p>If you have any questions or need to make changes, please reply to this email.</p>
<br>
<p>We look forward to seeing you!</p>
<p>Thank you,<br>Chennora</p>
<div style="font-family: Arial, sans-serif; padding: 20px;">
<h2 style="color: #2BB1A5;">Reservation Confirmed!</h2>
<p>Dear {customer_name},</p>
<p>Your table reservation at <b>Chennora Indian Kitchen Bar</b> has been confirmed successfully!</p>
<table style="width:100%; border-collapse: collapse; margin-top: 15px;">
<tr><td style="padding:8px; font-weight:bold;">Number of Guests:</td><td style="padding:8px;">{num_people}</td></tr>
<tr><td style="padding:8px; font-weight:bold;">Reservation Time:</td><td style="padding:8px;">{start_time_str}</td></tr>
</table>
<p style="margin-top:20px;">If you need to make any changes or have questions, please reply to this email or call us at <b>+1(647)856-2878</b>.</p>
<p>We look forward to seeing you!</p>
<p>Thank you,<br><b>Chennora Indian Kitchen Bar</b></p>
</div>
""",
'email_to': email,
'email_from': company_email,
'reply_to': 'info@chennora.ca',
'email_from': smtp_from,
'reply_to': smtp_from,
}
customer_mail = request.env['mail.mail'].sudo().create(customer_mail_values)
customer_mail.send()
_logger.info("Customer reservation confirmation sent to %s", email)
except Exception as e:
import logging