Files
booking/booking.tokens.inc
2016-07-23 10:16:12 +10:00

672 lines
31 KiB
PHP

<?php
/**
* @file
* Helper functions relating to the administration menu implementation for the booking module
*/
function booking_tokens_admin() {
global $event;
$defaults = array(
'value' => ' ',
'format' => filter_default_format(),
);
$form = array ();
$default_aims_and_rules_text = "<p>During [booking:eventname] we ask that you consider the following so that each of us can be free from distraction whilst we grow in Christ together. Christ is our ultimate example so in all actions, thoughts and words we ask that you demonstrate behaviour that emulates him.</p>\n" .
"<ul><li>Please leave distractions like iPods, MP3 players, etc at home as this will help us all have a more uplifting time</li>\n" .
"<li>No alcohol or illicit drugs are allowed at [booking:eventname]. Not only do these do serious harm to you but can endanger others who attend. Only bring things that better yourself and others</li>\n" .
"<li>With regards to clothing, we ask that you wear modest clothing to all activities. There is a variety of activities during [booking:eventname], we would like you to be comfortable at all times. In light of this, pants may be worn throughout for all attendees - when packing, please keep in mind that modesty and moderate dress will be insisted upon</li>\n" .
"<li>In keeping with the spirit of [booking:eventname], please respect the facilities and equipment. We ask that you also respect the instruction of the Hosts and the Committee. Attendees must not leave the premises without the prior permission of the Secretary or Hosts.</li></ul>";
$default_aims_and_rules_checkbox = "I regularly attend CYC type activities/events, and I agree at all times to be an example of Christ and that my actions and words will be a light to those we meet.";
$default_into_regn_not_opened_text = t("<p><br />Hi. Welcome to the booking page for [booking:eventname], God willing.</p>\n" .
"<p>Bookings are not yet open. Please try again later.</p>" .
"<p>If you have any questions, please use the !contact form.</p>",
array('!contact' => l('contact us', 'contact-us')));
$default_into_regn_closed_text = t("<p><br />Hi. Welcome to the booking page for [booking:eventname], God willing.</p>\n" .
"<p>Bookings for this event are now closed.</p>" .
"<p>If you have any questions, please use the !contact form.</p>",
array('!contact' => l('contact us', 'contact-us')));
$default_intro_text = "<p><br />Hi. Welcome to the booking page for [booking:eventname], God willing.</p>\n" .
"<p>So we can make sure this event is tailored for you, can you please complete ALL of the following details with the correct information.<br />\n" .
"Upon completing the form we will provide the necessary information to pay for [booking:eventname].</p><p>&nbsp;</p>";
$waiting_intro_text = "<p>Hi. Welcome to the booking page for [booking:eventname], God willing.</p>" .
"<p>We have reached the maximum capacity that the venue can hold, so all bookings are now going directly onto the waiting list.</p>" .
"<p>If you would still like to book into the waiting list, please complete ALL of the following details with the correct information and make the necessary payment." .
"Upon completing the form we will provide the necessary information to pay for [booking:eventname].</p><p>&nbsp;</p>";
$booking_whoscoming_pre_text = "<p>The following people are registered to attend [booking:eventname]. Registrations are limited so be sure to get in early!</p>\n<br />\n";
$booking_whoscoming_pre_waitlist_text = "<p>The following people are registered to attend [booking:eventname]. Registrations are limited so be sure to get in early!</p>\n<br />\n" .
"<p>Even though our registrations have reached maximum capacity, you can still <a href=\"/booking\">register</a> to join the waiting list." .
" See how many people are on the waiting list <a href=\"/waitinglist\">here</a>.</p>\n<br />\n";
$booking_whoscoming_pre_noregistrations_text = "<p>Nobody is coming, because nobody has booked in yet!</p>\n";
$booking_whoscoming_post_text = "<p></p>\n";
$booking_waitingpage_pre_text = "<p>The following people are on the waiting list to attend [booking:eventname]. " .
"Even though our registrations have reached maximum capacity, you can still <a href=\"/booking\">register</a> to join the waiting list.</p>\n<br />\n";
$booking_waitingpage_pre_nowaitlist_text = "<p>There's no one on the waiting list yet. If you haven't already done so, go ahead and <a href=\"/booking\">register</a>.</p>\n<br />\n";
$booking_waitingpage_post_text = "<p></p>\n";
$booking_confirmation_text = "<p>Thanks for filling out the registration form.</p>\n" .
"<p>To complete your booking, please make a payment of <strong>$[booking:payment-required]</strong> into the following bank account<br />\n" .
"&nbsp;Account Name: blah<br />\n&nbsp;BSB: blah<br />\n&nbsp;Account Number: blah</p>\n" .
"<p>Use the following as the transaction description:<br /><strong>[booking:payment-transaction-desc]</strong></p>" .
"<p>Alternatively, you can pay by a cheque payable to <strong>blah</strong>. Please post the cheque to<br />Address</p>\n";
$booking_confirmation_waitinglist_text = "<p>Thanks for filling out the registration form.</p>\n" .
"<p>Although you are on the waiting list, you can make a refundable payment of <strong>$[booking:payment-required]</strong> into the following bank account<br />\n" .
"&nbsp;Account Name: blah<br />\n&nbsp;BSB: blah<br />\n&nbsp;Account Number: blah</p>\n" .
"<p>Use the following as the transaction description:<br /><strong>[booking:payment-transaction-desc]</strong></p>" .
"<p>Alternatively, you can pay by a cheque payable to <strong>blah</strong>. Please post the cheque to<br />Address</p>\n";
$booking_regn_confirm_married_text = "<p>In your registration details, you indicated that you were married. Please note that both you and your spouse must book in and pay indivdually.</p>";
$form['tokens'] = array(
'#theme' => 'token_tree',
'#token_types' => array('booking'),
);
$form['registration'] = array(
'#type' => 'fieldset',
'#title' => 'Registration Page Text Definitions',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['registration']['default_into_regn_not_opened_text'] = array(
'#title' => t('Text to use at the start of the registration form if registrations haven\'t opened yet'),
'#description' => t(''),
'#type' => 'textarea',
'#default_value' => variable_get('default_into_regn_not_opened_text', $default_into_regn_not_opened_text),
);
/*
$booking_registration_intro_text = variable_get('booking_registration_intro_text', array('value' => '', 'format' => NULL));
$form['registration']['booking_registration_intro_text'] = array(
'#title' => t('Text to use at the start of the registration form'),
'#type' => 'text_format',
'#format' => isset($edit['format']) ? $edit['format'] : NULL,
'#description' => t(''),
'#default_value' => $booking_registration_intro_text['value'],
);
*/
/*
$booking_registration_intro_text = variable_get('booking_registration_intro_text', $defaults);
*/
$form['registration']['booking_registration_intro_text'] = array(
'#title' => t('Text to use at the start of the registration form'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_registration_intro_text', $default_intro_text),
//'#type' => 'text_format',
//'#format' => 'full_html',
//'#default_value' => $booking_registration_intro_text['value'],
);
$form['registration']['booking_registration_waiting_intro_text'] = array(
'#title' => t('Text to use at the start of the registration form if the venue has reached capacity'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_registration_waiting_intro_text', $waiting_intro_text),
);
$form['registration']['default_into_regn_closed_text'] = array(
'#title' => t('Text to use at the start of the registration form if registrations have closed'),
'#description' => t(''),
'#type' => 'textarea',
'#default_value' => variable_get('default_into_regn_closed_text', $default_into_regn_closed_text),
);
$form['registration']['booking_registration_aims_rules_checkbox'] = array(
'#title' => t('The text next to the aims and rules checkbox'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_registration_aims_rules_checkbox', $default_aims_and_rules_checkbox),
);
$form['registration']['booking_registration_aims_rules_text'] = array(
'#title' => t('The aims and rules attendees must agree to'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_registration_aims_rules_text', $default_aims_and_rules_text),
);
/*Text for the confirmation page*/
$form['confirmation'] = array(
'#type' => 'fieldset',
'#title' => 'Confirmation Page Text Definitions',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['confirmation']['booking_regn_confirm_page'] = array(
'#title' => t('Text to use on the confirmation page if the person has booked in and is not on the waiting list'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_regn_confirm_page', $booking_confirmation_text),
);
$form['confirmation']['booking_regn_confirm_waiting_page'] = array(
'#title' => t('Text to use on the confirmation page if the person is on the waiting list'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_regn_confirm_waiting_page', $booking_confirmation_waitinglist_text),
);
$form['confirmation']['booking_regn_confirm_married_text'] = array(
'#title' => t('Optional text to add to the confirmaton page if the person indicated they were married.'),
'#type' => 'textarea',
'#rows' => 1,
'#description' => t(''),
'#default_value' => variable_get('booking_regn_confirm_married_text', $booking_regn_confirm_married_text),
);
/*Text for the balance payment page*/
$form['balance'] = array(
'#type' => 'fieldset',
'#title' => 'Balance Payment Page Text Definitions',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
//$booking_regn_balance_page_paid = variable_get('booking_regn_balance_page_paid', $defaults);
$form['balance']['booking_regn_balance_page_paid'] = array(
'#title' => t('Text to use on the balance payment page if registration is fully paid.'),
'#type' => 'textarea',
'#default_value' => variable_get('booking_regn_balance_page_paid', ''),
'#description' => t(''),
//'#type' => 'text_format',
//'#format' => 'full_html',
//'#default_value' => $booking_regn_balance_page_paid['value'],
);
//$booking_regn_balance_page = variable_get('booking_regn_balance_page',$defaults);
$form['balance']['booking_regn_balance_page'] = array(
'#title' => t('Text to use on the balance payment page.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_regn_balance_page', ''),
//'#type' => 'text_format',
//'#format' => 'full_html',
//'#default_value' => $booking_regn_balance_page['value'],
);
//$booking_regn_balance_married_text = variable_get('booking_regn_balance_married_text', $defaults);
$form['balance']['booking_regn_balance_married_text'] = array(
'#title' => t('Optional text to add to the balance payment page if the person indicated they were married.'),
'#type' => 'textarea',
'#rows' => 1,
'#description' => t(''),
'#default_value' => variable_get('booking_regn_balance_married_text', ''),
//'#type' => 'text_format',
//'#format' => 'full_html',
//'#default_value' => $booking_regn_balance_married_text['value'],
);
$form['balance']['booking_regn_partial_balance_page'] = array(
'#title' => t('Text to use on the partial balance payment page.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_regn_partial_balance_page', ''),
);
/*People reporting pages*/
$form['people_lists'] = array(
'#type' => 'fieldset',
'#title' => 'Who\'s Coming and Waiting List Page Text Definitions',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
/*Text for the Who's coming page*/
$form['people_lists']['booking_whoscoming_pre_noregistrations_text'] = array(
'#title' => t('Text to use at the start of the Who\'s Coming page if there are no registrations'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_whoscoming_pre_noregistrations_text', $booking_whoscoming_pre_noregistrations_text),
);
$form['people_lists']['booking_whoscoming_pre_text'] = array(
'#title' => t('Text to use at the start of the Who\'s Coming page if there is no waiting list'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_whoscoming_pre_text', $booking_whoscoming_pre_text),
);
$form['people_lists']['booking_whoscoming_pre_waitlist_text'] = array(
'#title' => t('Text to use at the start of the Who\'s Coming page if there is a waiting list'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_whoscoming_pre_waitlist_text', $booking_whoscoming_pre_waitlist_text),
);
$form['people_lists']['booking_whoscoming_post_text'] = array(
'#title' => t('Text to use at the end of the Who\'s Coming page'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_whoscoming_post_text', $booking_whoscoming_post_text),
);
/*Text for the Waiting List page*/
$form['people_lists']['booking_waitingpage_pre_text'] = array(
'#title' => t('Text to use at the start of the Waiting List page'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_waitingpage_pre_text', $booking_waitingpage_pre_text),
);
$form['people_lists']['booking_waitingpage_pre_nowaitlist_text'] = array(
'#title' => t('Text to use at the start of the Waiting List page if there is no-one on the waiting list yet'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_waitingpage_pre_nowaitlist_text', $booking_waitingpage_pre_nowaitlist_text),
);
$form['people_lists']['booking_waitingpage_post_text'] = array(
'#title' => t('Text to use at the end of the Waiting List page'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_waitingpage_post_text', $booking_waitingpage_post_text),
);
/*Text for the Travel Form page*/
$form['travel'] = array(
'#type' => 'fieldset',
'#title' => 'Travel Form Text Definitions',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
$form['travel']['booking_travelform_page'] = array(
'#title' => t('Text to use at the start of the travel form for a non-married person.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => isset(variable_get('booking_travelform_page')['value']) ? variable_get('booking_travelform_page')['value'] : $defaults,
'#type' => 'text_format',
'#format' => 'full_html',
);
$form['travel']['booking_travelform_married_page'] = array(
'#title' => t('Text to use at the start of the travel form for a married couple. Only applies if combined pricing is enabled.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => isset(variable_get('booking_travelform_married_page')['value']) ? variable_get('booking_travelform_married_page')['value'] : $defaults,
'#type' => 'text_format',
'#format' => 'full_html',
);
$form['travel']['booking_travelform_page_post_text'] = array(
'#title' => t('Text to use at the end of the travel form. This is not displayed on the "travel form completed" page defined below.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => isset(variable_get('booking_travelform_page_post_text')['value']) ? variable_get('booking_travelform_page_post_text')['value'] : $defaults,
'#type' => 'text_format',
'#format' => 'full_html',
);
$form['travel']['booking_travelform_completed_page'] = array(
'#title' => t('Text to use on the travel form if the form has already been submitted.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => isset(variable_get('booking_travelform_completed_page')['value']) ? variable_get('booking_travelform_completed_page')['value'] : $defaults,
'#type' => 'text_format',
'#format' => 'full_html',
);
/*
$form['travel']['booking_travelform_page'] = array(
'#title' => t('Text to use at the start of the travel form for a non-married person.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_travelform_page', ''),
);
$form['travel']['booking_travelform_married_page'] = array(
'#title' => t('Text to use at the start of the travel form for a married couple. Only applies if combined pricing is enabled.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_travelform_married_page', ''),
);
$form['travel']['booking_travelform_completed_page'] = array(
'#title' => t('Text to use on the travel form if the form has already been submitted.'),
'#type' => 'textarea',
'#description' => t(''),
'#default_value' => variable_get('booking_travelform_completed_page', ''),
);
*/
//other pages like paypal landing page
$form['otherpages'] = array(
'#type' => 'fieldset',
'#title' => 'Miscellaneous pages',
'#collapsible' => TRUE,
'#collapsed' => TRUE,
);
//$booking_regn_completed_page_default = variable_get('booking_regn_completed_page');
//$booking_regn_completed_page = isset($booking_regn_completed_page_default['value']) ? $booking_regn_completed_page_default['value'] : '';
$form['otherpages']['booking_regn_completed_page'] = array(
'#title' => t('Text to use for landing page on return from paypal website'),
'#type' => 'textarea',
'#description' => t(''),
//'#default_value' => $booking_regn_completed_page,
'#default_value' => isset(variable_get('booking_regn_completed_page')['value']) ? variable_get('booking_regn_completed_page')['value'] : $defaults,
'#type' => 'text_format',
'#format' => 'full_html',
);
//see http://drupal.org/node/820816#comment-3100356
//and http://drupal.org/node/823362
/*
$booking_email_test_text = variable_get('booking_email_test_text', array('value' => '', 'format' => NULL));
$form['booking_email_test_text'] = array(
'#title' => t('Test email text'),
'#type' => 'text_format',
'#format' => isset($edit['format']) ? $edit['format'] : NULL,
'#description' => t(''),
'#default_value' => $booking_email_test_text['value'],
);
*/
return system_settings_form($form, FALSE);
}
function booking_tokens_admin_validate($form, $form_state) {
}
/**
* Provide information about our custom placeholder/token.
*
* @see http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_token_info/7
* @see http://api.lullabot.com/token_example_token_info/7
* @return array
* An associative array of available tokens and token types.
*/
function booking_token_info() {
$info['types']['booking'] = array(
'name' => t('Booking Tokens'),
'description' => t('Tokens related to bookings module.'),
'needs-data' => 'booking',
);
$info['tokens']['booking']['eventname'] = array(
'name' => t('Event Name'),
'description' => t('Name of the current event.')
);
$info['tokens']['booking']['regn-count'] = array(
'name' => t('Registration Count'),
'description' => t('Number of people registered for the current event.')
);
$info['tokens']['booking']['regn-max'] = array(
'name' => t('Registration Limit'),
'description' => t('Maximum allowed number of people for the current event.')
);
$info['tokens']['booking']['contact-email'] = array(
'name' => t('Event Contact Email'),
'description' => t('Contact email address for the current event.')
);
$info['tokens']['booking']['logistics-email'] = array(
'name' => t('Event Logistics Email'),
'description' => t('Logistics email address for the current event.')
);
$info['tokens']['booking']['eventdates'] = array(
'name' => t('Event Dates'),
'description' => t('Dates of the current event.')
);
$info['tokens']['booking']['fname'] = array(
'name' => t('First Name'),
'description' => t('First Name of the attendee.')
);
$info['tokens']['booking']['lname'] = array(
'name' => t('Last Name'),
'description' => t('Last Name of the attendee.')
);
$info['tokens']['booking']['team-colour'] = array(
'name' => t('Team Colour'),
'description' => t('Reading group team of attendee.')
);
$info['tokens']['booking']['dietary'] = array(
'name' => t('Dietary Requirements'),
'description' => t('Specified dietary requirements of the attendee')
);
$info['tokens']['booking']['payment-required'] = array(
'name' => t('Payment Required'),
'description' => t('The total amount required to complete the registration.')
);
$info['tokens']['booking']['refund-due'] = array(
'name' => t('Refund Due'),
'description' => t('The amount due as a refund.')
);
$info['tokens']['booking']['balance-payment-link'] = array(
'name' => t('Balance Payment Link'),
'description' => t('If using paypal, the link to the balance payment page.')
);
$info['tokens']['booking']['confirm-payment-link'] = array(
'name' => t('Confirm Payment Link'),
'description' => t('If using paypal, the link to the booking confirmation page to complete a registration.')
);
$info['tokens']['booking']['paypal-deposit-amount'] = array(
'name' => t('Paypal Deposit Only'),
'description' => t('The deposit amount required to confirm the registration including paypal fees.')
);
$info['tokens']['booking']['paypal-total-amount'] = array(
'name' => t('Paypal Outstanding Balance'),
'description' => t('The total amount required to complete the registration including paypal fees.')
);
$info['tokens']['booking']['paypal-deposit-form'] = array(
'name' => t('Paypal Deposit Form Button'),
'description' => t('The paypal form for the deposit amount.')
);
$info['tokens']['booking']['paypal-total-form'] = array(
'name' => t('Paypal Total Form Button'),
'description' => t('The paypal form for the total amount.')
);
$info['tokens']['booking']['stripe-deposit-amount'] = array(
'name' => t('Stripe Deposit Only'),
'description' => t('The deposit amount required to confirm the registration including stripe fees. These tokens are only used for display purposes, not in the actual calculations.')
);
$info['tokens']['booking']['stripe-total-amount'] = array(
'name' => t('Stripe Outstanding Balance'),
'description' => t('The total amount required to complete the registration including stripe fees.')
);
$info['tokens']['booking']['stripe-total-amount-intl'] = array(
'name' => t('Stripe Outstanding Balance International'),
'description' => t('The total amount required to complete the registration including international or amex stripe fees.')
);
$info['tokens']['booking']['stripe-deposit-form'] = array(
'name' => t('Stripe Deposit Form Button'),
'description' => t('The stripe popup form for the deposit amount.')
);
$info['tokens']['booking']['stripe-total-form'] = array(
'name' => t('Stripe Total Form Button'),
'description' => t('The stripe popup form for the total amount.')
);
$info['tokens']['booking']['booking-id'] = array(
'name' => t('Booking ID'),
'description' => t('ID of the user\'s registration.')
);
$info['tokens']['booking']['waitinglist-position'] = array(
'name' => t('Waiting List Position'),
'description' => t('Position of the registrant on the waiting list.')
);
$info['tokens']['booking']['payment-transaction-desc'] = array(
'name' => t('Transaction Decsription'),
'description' => t('Text description to use for a direct deposit transaction.')
);
$info['tokens']['booking']['regn-summary'] = array(
'name' => t('Registration Summary'),
'description' => t('Summary of details from user registration.')
);
$info['tokens']['booking']['travel-summary'] = array(
'name' => t('Registration Travel Summary'),
'description' => t('Summary of travel details from user registration.')
);
$info['tokens']['booking']['studygroup-summary'] = array(
'name' => t('Registration Study Group Summary'),
'description' => t('Summary of allocated study groups.')
);
$info['tokens']['booking']['leaderhelper-pair'] = array(
'name' => t('Registration Study Group Leader-Helper Pair'),
'description' => t('List out the leader and helper pairs, with intro text.')
);
$info['tokens']['booking']['room-allocation'] = array(
'name' => t('Room Allocation'),
'description' => t('Details of room allocated to attendee.')
);
$info['tokens']['booking']['bed-type'] = array(
'name' => t('Bed Type'),
'description' => t('The bed type allocated to attendee.')
);
$info['tokens']['booking']['travel-link'] = array(
'name' => t('Travel form Link'),
'description' => t('Link to the person\'s travel form.')
);
return $info;
}
/**
* Provide replacement values for placeholder tokens.
*
* @see http://api.drupal.org/api/drupal/modules--system--system.api.php/function/hook_tokens/7
* @see http://api.lullabot.com/token_example_tokens/7
* @param string $type
* The machine-readable name of the type (group) of token being replaced, such
* as 'node', 'user', or another type defined by a hook_token_info()
* implementation.
* @param array $tokens
* An array of tokens to be replaced. The keys are the machine-readable token
* names, and the values are the raw [type:token] strings that appeared in the
* original text.
* @param array $data (optional)
* An associative array of data objects to be used when generating replacement
* values, as supplied in the $data parameter to token_replace().
* @param array $options (optional)
* An associative array of options for token replacement; see token_replace()
* for possible values.
* @return array
* An associative array of replacement values, keyed by the raw [type:token]
* strings from the original text.
*/
function booking_tokens($type, $tokens, array $data = array(), array $options = array()) {
//watchdog('booking', 'Processing token request');
$replacements = array();
$sanitize = !empty($options['sanitize']);
if ($type == 'booking') {
foreach ($tokens as $name => $original) {
if (array_key_exists($name, $data)) {
$replacements[$original] = $data[$name];
}
}
}
return $replacements;
}
/**
* Function to define generic site-wide tokens relating to the bookings module
*
* @param none
* @return associative array containing tokens
*/
function booking_define_tokens()
{
global $event;
$booking_times = db_query("SELECT booking_event_start, booking_event_end FROM {booking_event} where eid = :eid",
array(':eid' => $event->eid))->fetchObject();
$regncount_query = db_query("SELECT count(*) as num_ppl FROM {booking_person} where booking_eventid = :eventid and booking_status = 1",
array(':eventid' => $event->eid))
->fetchObject();
$tokens = array();
$tokens['eventname'] = $event->booking_eventname;
$tokens['eventdates'] = _date_range_to_string(date("Y-m-d", $booking_times->booking_event_start),
date("Y-m-d", $booking_times->booking_event_end));
$tokens['contact-us'] = l('contact us', 'contact-us');
$tokens['contact-email'] = variable_get('booking_contact_email');
$tokens['logistics-email'] = variable_get('booking_logistics_email');
$tokens['regn-count'] = $regncount_query->num_ppl;
$tokens['regn-limit'] = variable_get('booking_regn_limit',0);
return $tokens;
}
/**
* Function to define tokens related to a specific registration from the bookings module
*
* @param $node - object representing the registration
* @return associative array containing tokens for the specified person
*/
function booking_define_personspecific_tokens($node)
{
global $event;
$amount_paid = 0;
$payment_processor_type = variable_get('booking_payment_processor', 0);
//get a count of the total number of people booked in to this event
//but don't include people who haven't paid or have withdrawn their booking
$result = db_query("SELECT count(*) as num_ppl FROM {booking_person} where booking_eventid = :eventid and (booking_status = 1 or booking_status = 2)",
array(':eventid' => $event->eid))
->fetchObject();
//calcalate a new temp id to be configured for this user if required
if ($node->booking_tempid == '')
{
$tempid = _booking_uuidSecure();
//update the user with this tempid
db_update('booking_person')
->fields(array(
'booking_tempid' => $tempid
))
->condition('nid', $node->nid)
->execute();
}
else
$tempid = $node->booking_tempid;
//check how much has been paid by this person
$amount_paid = _booking_amount_paid($node->nid);
//generate the tokens
$tokens = array();
$tokens['eventname'] = $event->booking_eventname;
$tokens['contact-email'] = variable_get('booking_contact_email');
$tokens['logistics-email'] = variable_get('booking_logistics_email');
$tokens['team-colour'] = ucwords($node->booking_readinggroup);
$tokens['fname'] = ucwords(trim($node->booking_firstname));
$tokens['lname'] = ucwords(trim($node->booking_lastname));
$tokens['dietary'] = ucwords(trim($node->booking_dietary));
$tokens['booking-id'] = $node->nid;
$tokens['payment-required'] = _booking_amount_owing($node, $amount_paid, FALSE);
$tokens['refund-due'] = $node->booking_refund_due;
$tokens['waitinglist-position'] = $result->num_ppl - variable_get('booking_regn_limit',350) + 1;
$tokens['payment-transaction-desc'] = $node->nid . ' ' . $node->booking_lastname;
$tokens['balance-payment-link'] = url('balance/' . $tempid, array('absolute' => TRUE));
$tokens['confirm-payment-link'] = url('confirm/' . $tempid, array('absolute' => TRUE));
$tokens['regn-summary'] = _booking_details_email_summary($node);
//if payment processor is set to manual then don't populate these tokens
//if paypal is enabled
if ($payment_processor_type == 0) {
$tokens['paypal-deposit-amount'] = _booking_deposit_amount($node, TRUE);
$tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid);
$tokens['stripe-deposit-amount'] = "";
$tokens['stripe-total-amount'] = "";
$tokens['stripe-total-intl'] = "";
}
//if stripe is enabled
elseif ($payment_processor_type == 1) {
$tokens['paypal-deposit-amount'] = "";
$tokens['paypal-total-amount'] = "";
$tokens['stripe-deposit-amount'] = _booking_deposit_amount($node, TRUE);
$tokens['stripe-total-amount'] = _booking_amount_owing($node, $amount_paid, TRUE, FALSE);
$tokens['stripe-total-intl'] = _booking_amount_owing($node, $amount_paid, TRUE, TRUE);
}
//if travelform is enabled
if (variable_get('booking_enable_travelform', 0) == 1) {
$tokens['travel-link'] = url('travel/' . $tempid, array('absolute' => TRUE));
$tokens['travel-summary'] = _booking_travelform_email_summary($node);
}
else {
$tokens['travel-link'] = "";
$tokens['travel-summary'] = "";
}
//if studygroups are enabled
if (variable_get('booking_enable_studygroups', 0) == 1) {
$tokens['studygroup-summary'] = _booking_studygroup_email_summary($node);
$tokens['leaderhelper-pair'] = _booking_leader_helper_email_summary($node);
}
else {
$tokens['studygroup-summary'] = "";
$tokens['leaderhelper-pair'] = "";
}
//if room allocations are enabled
if (variable_get('booking_enable_roomallocations', 0) == 1) {
$tokens['room-allocation'] = _booking_room_email_summary($node);
$tokens['bed-type'] = _booking_room_bedtype_lookup(empty($node->booking_room_bedtype) ? '0' : $node->booking_room_bedtype);
}
else {
$tokens['room-allocation'] = "";
$tokens['bed-type'] = "";
}
//watchdog('booking_debug', "<pre>Person specific tokens:\n@info</pre>", array('@info' => print_r( $tokens, true)));
return $tokens;
}