Added mail template + parsing.
This commit is contained in:
parent
c807857e27
commit
30cc304a36
@ -97,6 +97,13 @@ if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token'])
|
|||||||
switch ($_GET['action']) {
|
switch ($_GET['action']) {
|
||||||
case 'send':
|
case 'send':
|
||||||
echo "This would send the mail...";
|
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 '<hr/>'.$mail_html;
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case 'event':
|
case 'event':
|
||||||
$tpl = $m->loadTemplate('event_html');
|
$tpl = $m->loadTemplate('event_html');
|
||||||
|
46
prep_mail.php
Normal file
46
prep_mail.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
// FOR TESTING:
|
||||||
|
if (!isset($action)) {
|
||||||
|
$action = 'hotel';
|
||||||
|
$debug = true;
|
||||||
|
}
|
||||||
|
$skey = 'form_' . $action;
|
||||||
|
|
||||||
|
$field_data_json = file_get_contents('definitions/' . $action . '.json');
|
||||||
|
$field_data = json_decode($field_data_json, true);
|
||||||
|
|
||||||
|
$fields = array();
|
||||||
|
|
||||||
|
// Assign fields to groups, fill in (default) values
|
||||||
|
foreach ($field_data['fields'] as $key=>$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);
|
3
templates/mail_hotel.mustache
Normal file
3
templates/mail_hotel.mustache
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
This is the Template for the {{action}} Mail!
|
||||||
|
|
||||||
|
{{reservationFor_name.value}}
|
Reference in New Issue
Block a user