86 lines
3.2 KiB
PHP
86 lines
3.2 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Confirmation page for event registration
|
|
*/
|
|
function booking_confirm_page() {
|
|
global $event;
|
|
$output = "";
|
|
$waiting_list = False;
|
|
$already_paid = false;
|
|
$paypal_form = "";
|
|
$uuid = arg(1);
|
|
$payment_processor_type = variable_get('booking_payment_processor', 0);
|
|
|
|
//verify that arg(1) is a uuid
|
|
if (! preg_match('/^[0-9A-Fa-f\-]+$/', $uuid)) {
|
|
//parameter from url is not what we were expecting
|
|
drupal_set_message("Error: Invalid session ID supplied to the registration confirmation page. Please use the contact us form to let us know.", 'error', FALSE);
|
|
drupal_goto('<front>');
|
|
return "";
|
|
}
|
|
|
|
//@TODO if the person says they're married, query to see if they're listed partner has already registered and paid
|
|
//if they have, then let the new registration person know their partner has already paid, and send them the confirmation email
|
|
|
|
//fetch details about the person
|
|
$query = db_select('booking_person', 'p');
|
|
$query->condition('p.booking_tempid', $uuid, '=')
|
|
->fields('p', array('nid'));
|
|
$person = $query->execute()
|
|
->fetchObject();
|
|
|
|
if ($person) {
|
|
//load all the fields
|
|
$node = node_load($person->nid);
|
|
//maximum length for invoice id is 127 characters
|
|
$invoiceid = $person->nid . '_' . $node->booking_eventid . '_' . $node->booking_lastname . '-' . $node->booking_firstname;
|
|
$invoiceid = substr($invoiceid, 0, 126);
|
|
}
|
|
else {
|
|
drupal_set_message("Unable to find matching session ID " . $uuid, 'error', FALSE);
|
|
drupal_goto('<front>');
|
|
return "";
|
|
}
|
|
|
|
//populate tokens
|
|
$tokens = booking_define_personspecific_tokens($node);
|
|
|
|
//if paypal is enabled then add tokens for it
|
|
if ($payment_processor_type == 0) {
|
|
$tokens['paypal-deposit-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-deposit-amount'], "Pay Deposit");
|
|
$tokens['paypal-total-form'] = _booking_paypal_form($node, $invoiceid, $tokens['paypal-total-amount'], "Pay Full Amount");
|
|
//watchdog('booking', 'Paypal form "@info"', array ('@info' => var_export($tokens['paypal-total-form'], TRUE)));
|
|
}
|
|
//if stripe is enabled
|
|
elseif ($payment_processor_type == 1) {
|
|
//@todo confirm that the deposit amount is correct for a stripe deposit
|
|
$tokens['stripe-deposit-form'] = _booking_stripe_form($node, $invoiceid, $tokens['stripe-deposit-amount'], "Pay Deposit");
|
|
$tokens['stripe-total-form'] = _booking_stripe_form($node, $invoiceid, $tokens['payment-required'], "Pay Balance");
|
|
}
|
|
|
|
//check if this registration will be on the waiting list
|
|
if (_booking_check_bookings_full() == True || $node->booking_status == 2) {
|
|
$waiting_list = TRUE;
|
|
}
|
|
|
|
if ($waiting_list == FALSE) {
|
|
//watchdog('booking', 'Waiting list is false. Un-tokenised text is "@info"', array ('@info' => variable_get('booking_regn_confirm_page')));
|
|
$output = token_replace(variable_get('booking_regn_confirm_page'), $tokens);
|
|
}
|
|
else {
|
|
$output = token_replace(variable_get('booking_regn_confirm_waiting_page'), $tokens);
|
|
}
|
|
|
|
//optional additional text for married people
|
|
if ($node->booking_married == 'Y') {
|
|
$output .= token_replace(variable_get('booking_regn_confirm_married_text'), $tokens);
|
|
}
|
|
|
|
//create the render array
|
|
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
|
|
|
|
//return the form
|
|
return $return_array;
|
|
}
|