reorganise functions into appropriate files
This commit is contained in:
@@ -301,6 +301,7 @@ function booking_manual_email_form($form, &$form_state)
|
||||
$email_options_array['travelcomplete'] = 'Travel Form Complete Email';
|
||||
$preselection_options['---'] = "---";
|
||||
$preselection_options['bookedin'] = 'People who are booked-in';
|
||||
$preselection_options['waitinglist'] = 'People on waiting list';
|
||||
$preselection_options['unpaid'] = 'People booked-in with outstanding balance';
|
||||
$preselection_options['notravelform'] = "People booked-in no travel form received";
|
||||
$preselection_options['notravelforminclwaiting'] = "People booked-in/waiting no travel form received";
|
||||
@@ -555,6 +556,11 @@ function _booking_email_get_default_selection_callback($form, $form_state) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'waitinglist':
|
||||
if ($person->booking_status == 2) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
break;
|
||||
case 'unpaid':
|
||||
if ($person->booking_payment_complete == 'N' && $person->booking_status == 1) {
|
||||
$defaults[] = $person->nid;
|
||||
@@ -572,9 +578,11 @@ function _booking_email_get_default_selection_callback($form, $form_state) {
|
||||
break;
|
||||
case 'leaderhelper':
|
||||
foreach ($person as $key => $value) {
|
||||
if (preg_match('/^session(\d+)_role/', $key, $matches) &&
|
||||
$value > 0) {
|
||||
$defaults[] = $person->nid;
|
||||
if (preg_match('/^session(\d+)_role/', $key, $matches) && $value > 0) {
|
||||
//don't add the person multiple times if they're leading/helping multiple groups
|
||||
if (! in_array($person->nid, $defaults)) {
|
||||
$defaults[] = $person->nid;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@@ -115,8 +115,7 @@ function _booking_process_payment($data) {
|
||||
|
||||
//extract the person node id from the invoice
|
||||
$pos = strpos($data['invoice'], "_");
|
||||
if (($pos === false) || ($pos == 0))
|
||||
{
|
||||
if (($pos === false) || ($pos == 0)) {
|
||||
watchdog('booking', 'Unable to process payment with invalid invoice information: !id', array('!id' => $data['invoice']), WATCHDOG_ERROR);
|
||||
return;
|
||||
}
|
||||
@@ -125,8 +124,7 @@ function _booking_process_payment($data) {
|
||||
//get the data between the first and second underscore
|
||||
$eid = substr($data['invoice'], $pos + 1, strrpos($data['invoice'], "_") - $pos - 1);
|
||||
|
||||
if (substr($eid,0,3) == "bal")
|
||||
{
|
||||
if (substr($eid,0,3) == "bal") {
|
||||
$balance_payment = true;
|
||||
watchdog('booking', 'Balance payment for user with node id: !id', array('!id' => $nid));
|
||||
}
|
||||
@@ -135,10 +133,8 @@ function _booking_process_payment($data) {
|
||||
$duplicate_check = db_query("SELECT payid, booking_person_nid FROM {booking_payment} where booking_ipn_track_id = :ipn_id ",
|
||||
array(':ipn_id' => $data['ipn_track_id']))
|
||||
->fetchObject();
|
||||
|
||||
if ($duplicate_check)
|
||||
{
|
||||
watchdog('booking', 'Detected duplicate paypal notifications for transaction id !id, registration id !nid', array('!id' => $data['ipn_track_id'], '!nid' => $nid), WATCHDOG_ERROR);
|
||||
if ($duplicate_check) {
|
||||
watchdog('booking', 'Detected duplicate paypal notifications for transaction id !id, registration id !nid', array('!id' => $data['ipn_track_id'], '!nid' => $nid), WATCHDOG_ERROR);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -165,43 +161,37 @@ function _booking_process_payment($data) {
|
||||
))
|
||||
->execute();
|
||||
|
||||
//Get the person's info
|
||||
//Get the person's info so we can update their total amount paid and booking status
|
||||
$person = node_load($nid);
|
||||
|
||||
//check if we found a person matching this payment
|
||||
if ($person)
|
||||
{
|
||||
if ($person) {
|
||||
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment', array('!id' => $nid, '!eid' => $eid,
|
||||
'!payment' => $person->booking_amount_paid));
|
||||
//if successful, update their total payment amount
|
||||
$total = $person->booking_amount_paid + $data['mc_gross'];
|
||||
|
||||
//only recalculate their booking status if this is the initial payment, not a payment of the outstanding balance
|
||||
if ($balance_payment == FALSE)
|
||||
{
|
||||
if ($balance_payment == FALSE) {
|
||||
watchdog('booking', 'Processing an initial payment. Booking status is currently ' . $person->booking_status);
|
||||
if ($person->booking_status == 1)
|
||||
{
|
||||
if ($person->booking_status == 1) {
|
||||
watchdog('booking', 'This registration has been manually assigned to the booked-in list.');
|
||||
$status = 1;
|
||||
}
|
||||
elseif (_booking_check_bookings_full() == True || $person->booking_status == 2)
|
||||
{
|
||||
elseif (_booking_check_bookings_full() == True || $person->booking_status == 2) {
|
||||
watchdog('booking', 'This registration belongs on the waiting list.');
|
||||
$status = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
watchdog('booking', 'This registration made it to the booked-in list.');
|
||||
$status = 1;
|
||||
}
|
||||
}
|
||||
else //this is a balance payment
|
||||
{
|
||||
else {
|
||||
//this is a balance payment
|
||||
watchdog('booking', 'Processing a balance payment.');
|
||||
//if this is a payment of outstanding balance, keep the booking_status the same
|
||||
$status = $person->booking_status;
|
||||
//$status = $person->booking_status == 2 ? 2 : 1;
|
||||
}
|
||||
|
||||
//update the database for this person
|
||||
@@ -213,87 +203,55 @@ function _booking_process_payment($data) {
|
||||
->condition('nid', $nid)
|
||||
->execute();
|
||||
|
||||
//replace the code below with a call to the helper function
|
||||
_booking_postpayment_trigger($nid, $person, $balance_payment);
|
||||
|
||||
/*
|
||||
//If there is no outstanding balance, send a payment complete email
|
||||
$amount_owing = _booking_amount_owing($person);
|
||||
//if ($total >= $person->booking_total_pay_reqd)
|
||||
if ($amount_owing == 0)
|
||||
{
|
||||
//set the payment complete flag
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_payment_complete' => 'Y',
|
||||
))
|
||||
->condition('nid', $nid)
|
||||
->execute();
|
||||
|
||||
//this should always be a balance payment type email, since that tells the user that their payment is completed
|
||||
_booking_registration_email($nid, TRUE);
|
||||
|
||||
//if we are combining payments, and this person has a linked spouse
|
||||
if ((variable_get('booking_enable_combined_pricing', 0) == 1) && ($person->booking_partner_id > 0))
|
||||
{
|
||||
//check spouse booking_status and payment info
|
||||
$spouse = db_select('booking_person', 'p')
|
||||
->condition('p.nid', $person->booking_partner_id,'=')
|
||||
->fields('p', array('booking_amount_paid', 'booking_status', 'booking_total_pay_reqd'))
|
||||
->execute()
|
||||
->fetchObject();
|
||||
|
||||
//update the spouse's status from "not paid" if required
|
||||
$spouse_status = $spouse->booking_status == 0 ? 1 : $spouse->booking_status;
|
||||
watchdog('booking', 'Setting status for spouse id !id to !new from !status', array('!id' => $person->booking_partner_id,
|
||||
'!new' => $spouse_status, '!status' => $spouse->booking_status));
|
||||
|
||||
//set the spouse's payment required to be zero or equal to their previous payment total
|
||||
$spouse_new_amount_reqd = $spouse->booking_amount_paid > 0 ? $spouse->booking_amount_paid : 0;
|
||||
watchdog('booking', 'Setting amount owing for spouse id !id to !new from !old.', array('!id' => $person->booking_partner_id,
|
||||
'!new' => $spouse_new_amount_reqd, '!old' => $spouse->booking_total_pay_reqd));
|
||||
|
||||
//update the database for this person
|
||||
db_update('booking_person')
|
||||
->fields(array(
|
||||
'booking_total_pay_reqd' => $spouse_new_amount_reqd,
|
||||
'booking_status' => $spouse_status,
|
||||
'booking_payment_complete' => 'Y',
|
||||
))
|
||||
->condition('nid', $person->booking_partner_id)
|
||||
->execute();
|
||||
|
||||
//send an email to the spouse
|
||||
_booking_registration_email($person->booking_partner_id, TRUE);
|
||||
}
|
||||
}
|
||||
//if this was an initial payment we might need to send a notification
|
||||
elseif ($balance_payment == FALSE)
|
||||
{
|
||||
//send a notification email if we didn't automatically send one earlier
|
||||
if (variable_get('booking_auto_confirm_email', 0) == 0)
|
||||
{
|
||||
_booking_registration_email($nid, FALSE);
|
||||
}
|
||||
}
|
||||
else //this person still has an outstanding balance so just send a confirmation email
|
||||
{
|
||||
watchdog('booking', 'This balance payment of !payment was insufficient for !id to completely pay the total outstanding of !outstanding.',
|
||||
array('!id' => $nid, '!payment' => $data['mc_gross'], '!outstanding' => $amount_owing));
|
||||
//send the person an email thanking them for their partial payment
|
||||
_booking_partialbalance_payment_email($nid);
|
||||
//TODO: create an email specifically for partial-balance payments
|
||||
//_booking_registration_email($nid, $balance_payment);
|
||||
}
|
||||
|
||||
*/
|
||||
//handle workflow emails and spouse payment updates
|
||||
_booking_postpayment_trigger($nid, $person, $balance_payment);
|
||||
}
|
||||
else //couldn't find a matching nid for this invoice
|
||||
{
|
||||
else {
|
||||
//couldn't find a matching nid for this invoice
|
||||
watchdog('booking', "Unable to process payment for user with node id: '!id'", array('!id' => $nid), WATCHDOG_ERROR);
|
||||
//db_query("UPDATE {booking_person} SET booking_tempid='' WHERE nid = %d", $nid);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Landing page after returning from paypal
|
||||
*/
|
||||
function booking_payment_completed_page()
|
||||
{
|
||||
//get some configuration information
|
||||
global $event;
|
||||
$output = "";
|
||||
$return_array = array();
|
||||
/*
|
||||
$parameters = drupal_get_query_parameters();
|
||||
|
||||
//check if we got a transaction token from paypal
|
||||
if (isset($parameters['token'])) {
|
||||
//check to make sure the value is something we're expecting
|
||||
$paypal_token = $parameters['token'];
|
||||
if (! preg_match('/^[0-9A-Fa-f\-]+$/', $paypal_token)) {
|
||||
//parameter from url is not what we were expecting so ignore it and just use the site-wide tokens for this page
|
||||
$tokens = booking_define_tokens();
|
||||
}
|
||||
else {
|
||||
//query the payments table to find the attendee that this paypal token belongs to
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
//set the page title
|
||||
$bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event';
|
||||
drupal_set_title($bookingTitle . ' Registration Completed');
|
||||
$input = variable_get('booking_regn_completed_page');
|
||||
//watchdog('booking_debug', "<pre>Paypal landing page token:\n@info</pre>", array('@info' => print_r($input['value'] , true)));
|
||||
|
||||
|
||||
|
||||
$output = token_replace($input['value'], booking_define_tokens());
|
||||
$return_array[] = array(
|
||||
'paragraph' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $output
|
||||
)
|
||||
);
|
||||
|
||||
return $return_array;
|
||||
}
|
@@ -1288,49 +1288,4 @@ function _booking_form_submit_post_triggers($node)
|
||||
//just send a notification email
|
||||
_booking_regn_notifyonly_email($node, FALSE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Landing page after returning from paypal
|
||||
*/
|
||||
function booking_payment_completed_page()
|
||||
{
|
||||
//get some configuration information
|
||||
global $event;
|
||||
$output = "";
|
||||
$return_array = array();
|
||||
/*
|
||||
$parameters = drupal_get_query_parameters();
|
||||
|
||||
//check if we got a transaction token from paypal
|
||||
if (isset($parameters['token'])) {
|
||||
//check to make sure the value is something we're expecting
|
||||
$paypal_token = $parameters['token'];
|
||||
if (! preg_match('/^[0-9A-Fa-f\-]+$/', $paypal_token)) {
|
||||
//parameter from url is not what we were expecting so ignore it and just use the site-wide tokens for this page
|
||||
$tokens = booking_define_tokens();
|
||||
}
|
||||
else {
|
||||
//query the payments table to find the attendee that this paypal token belongs to
|
||||
|
||||
}
|
||||
}
|
||||
*/
|
||||
//set the page title
|
||||
$bookingTitle = !empty($event->booking_eventname) ? $event->booking_eventname : 'Event';
|
||||
drupal_set_title($bookingTitle . ' Registration Completed');
|
||||
$input = variable_get('booking_regn_completed_page');
|
||||
watchdog('booking_debug', "<pre>Paypal landing page token:\n@info</pre>", array('@info' => print_r($input['value'] , true)));
|
||||
|
||||
$output = token_replace($input['value'], booking_define_tokens());
|
||||
$return_array[] = array(
|
||||
'paragraph' => array(
|
||||
'#type' => 'markup',
|
||||
'#markup' => $output
|
||||
)
|
||||
);
|
||||
|
||||
return $return_array;
|
||||
}
|
Reference in New Issue
Block a user