Files
booking/booking.confirm.inc

84 lines
3.0 KiB
PHP

<?php
// $Id: booking.confirm.inc,v 0.1 2011/07/12
/**
* Confirmation page for event registration
*/
function booking_confirm_page() {
global $event;
$output = "";
$waiting_list = False;
$already_paid = false;
$paypal_form = "";
//verify that arg(1) is a uuid
if (! preg_match('/^[0-9A-Fa-f\-]+$/', arg(1))) {
//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', arg(1), '=')
->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_event_id . '_' . $node->booking_lastname . '-' . $node->booking_firstname;
$invoiceid = substr($invoiceid, 0, 126);
} else {
drupal_set_message("Unable to find matching session ID " . arg(1), 'error', FALSE);
return "";
}
//check if this registration will be on the waiting list
if (_booking_check_bookings_full() == True || $node->booking_status == 2)
$waiting_list = TRUE;
//populate tokens
$tokens = booking_define_personspecific_tokens($node);
//add in the paypal forms as tokens
$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)));
//$tokens['paypal-total-form'] = drupal_get_form('_booking_paypal_form', arg(1), $person, $invoiceid, $tokens['paypal-total-amount']);
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);
//$paypal_form = drupal_get_form('_booking_paypal_form_builder', $person, $invoiceid, $amount_owing, "Pay Full Amount");
}
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);
}
//put all the bits together
$return_array[] = array('paragraph' => array('#type' => 'markup', '#markup' => $output));
//$return_array[] = array('form' => $paypal_form);
//return the form
return $return_array;
}