diff --git a/index.php b/index.php index 415cc0c..511f047 100644 --- a/index.php +++ b/index.php @@ -69,6 +69,7 @@ if (!$tpl_done && $sm->hasSessionToken()) { case 'send': echo 'This would send the mail...'; $mo = new MailOutput(dirname(__FILE__) . '/templates'); + $form_type = $_REQUEST['form_type']; $mo->setTemplate('mail_' . $form_type); $skey = 'form_' . $form_type; $fd = new FieldDefinition($form_type); @@ -80,13 +81,15 @@ if (!$tpl_done && $sm->hasSessionToken()) { $data['email_date'] = date('r'); $data = array_merge($data, $fields); $mo->setTemplateVars($data); - $mo->setSubject('[FRS] ' . $data['action_uc'] . ' Reservation'); + $mo->setTemplateVar('form_type', $form_type); + $mo->setTemplateVar('form_type_uc', ucwords($form_type)); + $mo->setSubject('[FRS] ' . ucwords($form_type) . ' Reservation'); $mo->addRecipient($data['user']['email'], $data['user']['name_first'] . ' ' . $data['user']['name_last']); $mail_sent = $mo->send(); if ($mail_sent) { - echo 'Mail sent successfully.'; + $ho->setTemplate('mail_sent_html'); } else { - echo 'Mail sending failed!!'; + $ho->setTemplate('mail_failed_html'); } break; default: diff --git a/templates/mail_failed_html.mustache b/templates/mail_failed_html.mustache new file mode 100644 index 0000000..0d2d286 --- /dev/null +++ b/templates/mail_failed_html.mustache @@ -0,0 +1,17 @@ +{{> html_head}} +{{> mdl_head}} +{{> mdl_content_head}} + +
+ Fake Reservation System > Send Reservation +
+ +

Mail sending FAILED

+ +

+There was an error sending the mail. +

+ +{{> mdl_content_foot}} +{{> mdl_foot}} +{{> html_foot}} diff --git a/templates/mail_flight.mustache b/templates/mail_flight.mustache index 5fc3604..f129383 100644 --- a/templates/mail_flight.mustache +++ b/templates/mail_flight.mustache @@ -1,5 +1,5 @@ From: Fake Reservation System <{{user.email}}> -Subject: [FRS] {{action_uc}} Reservation +Subject: [FRS] {{form_type_uc}} Reservation Date: {{email_date}} X-Mailer: FRS/1.0 MIME-Version: 1.0 diff --git a/templates/mail_hotel.mustache b/templates/mail_hotel.mustache index 5af7fd8..5bb3a51 100644 --- a/templates/mail_hotel.mustache +++ b/templates/mail_hotel.mustache @@ -1,5 +1,5 @@ From: Fake Reservation System <{{user.email}}> -Subject: [FRS] {{action_uc}} Reservation +Subject: [FRS] {{form_type_uc}} Reservation Date: {{email_date}} X-Mailer: FRS/1.0 MIME-Version: 1.0 @@ -19,11 +19,11 @@ Content-Type: text/html; charset=utf-8
Hotel: {{reservationFor_name.value}}
- - - - - + {{reservationFor_address_streetAddress.value}}
+ {{reservationFor_address_addressLocality.value}}
+ {{reservationFor_address_addressRegion.value}}
+ {{reservationFor_address_postalCode.value}} + {{reservationFor_address_addressCountry.value}}
Tel.: {{reservationFor_telephone.value}}

diff --git a/templates/mail_sent_html.mustache b/templates/mail_sent_html.mustache new file mode 100644 index 0000000..d5fea10 --- /dev/null +++ b/templates/mail_sent_html.mustache @@ -0,0 +1,17 @@ +{{> html_head}} +{{> mdl_head}} +{{> mdl_content_head}} + +
+ Fake Reservation System > Send Reservation +
+ +

Mail sent

+ +

+Check your inbox. +

+ +{{> mdl_content_foot}} +{{> mdl_foot}} +{{> html_foot}}