From 30cc304a3668997ce4b7713570b7c2b72b0dc2d9 Mon Sep 17 00:00:00 2001 From: Markus Birth Date: Fri, 27 May 2016 15:29:18 +0200 Subject: [PATCH] Added mail template + parsing. --- index.php | 7 ++++++ prep_mail.php | 46 +++++++++++++++++++++++++++++++++++ templates/mail_hotel.mustache | 3 +++ 3 files changed, 56 insertions(+) create mode 100644 prep_mail.php create mode 100644 templates/mail_hotel.mustache diff --git a/index.php b/index.php index 7003053..c93cec5 100644 --- a/index.php +++ b/index.php @@ -97,6 +97,13 @@ if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token']) switch ($_GET['action']) { case 'send': echo "This would send the mail..."; + $mtpl = $m->loadTemplate('mail_' . $form_type); + $action = $form_type; + require 'prep_mail.php'; + $data['action'] = $action; + $mail_html = $mtpl->render($data); + echo '
'.$mail_html; + break; case 'event': $tpl = $m->loadTemplate('event_html'); diff --git a/prep_mail.php b/prep_mail.php new file mode 100644 index 0000000..a7b8a04 --- /dev/null +++ b/prep_mail.php @@ -0,0 +1,46 @@ +$meta) { + $meta['field_id'] = $key; + + // Assign session value if set, or use default if set + if (isset($_SESSION[$skey][$key])) { + $meta['value'] = $_SESSION[$skey][$key]; + + switch ($meta['type']) { + case 'datetime': + $meta['value_unixtime'] = strtotime($meta['value']); + break; + } + } + + // Field type marker for Mustache + $meta['fieldtype_' . $meta['type']] = true; + + // Add useful default values for some types + if ($meta['type'] == 'datetime') { + $meta['today'] = date('Y-m-d'); + } + + // Add to fieldlist + $fields[$key] = $meta; +} + +if ($debug) { + print_r($fields); +} + +$data = array_merge($data, $fields); diff --git a/templates/mail_hotel.mustache b/templates/mail_hotel.mustache new file mode 100644 index 0000000..0c369e6 --- /dev/null +++ b/templates/mail_hotel.mustache @@ -0,0 +1,3 @@ +This is the Template for the {{action}} Mail! + +{{reservationFor_name.value}}