Update _booking_amount_owing to use $person object instead of just a node id
This commit is contained in:
@@ -325,8 +325,8 @@ function booking_manual_email()
|
||||
|
||||
foreach($result as $data)
|
||||
{
|
||||
//$paid = _booking_amount_owing($data);
|
||||
$paid = _booking_amount_owing($data->nid);
|
||||
$paid = _booking_amount_owing($data);
|
||||
//$paid = _booking_amount_owing($data->nid);
|
||||
$options[$data->nid] = array (
|
||||
'booking_nid' => l(t('!id', array('!id' => $data->nid)), t('node/!id', array('!id' => $data->nid))),
|
||||
'booking_name' => $data->booking_firstname . " " . $data->booking_lastname,
|
||||
|
@@ -643,13 +643,13 @@ function _booking_total_due($person)
|
||||
* @param $include_paypal_fees - boolean to indicate whether we want the net amount or the amount owing including paypal fees
|
||||
* @return amount owing as a decimal value
|
||||
*/
|
||||
function _booking_amount_owing($nid, $amount_paid = 0, $include_paypal_fees = TRUE)
|
||||
function _booking_amount_owing($person, $amount_paid = 0, $include_paypal_fees = TRUE)
|
||||
{
|
||||
//$amount_paid = 0;
|
||||
//$total_due = 0;
|
||||
|
||||
//fetch details about the person
|
||||
|
||||
/*
|
||||
$person = db_query("SELECT price.booking_price, price.booking_late_price, person.booking_payment_id, " .
|
||||
"person.booking_total_pay_reqd, person.booking_amount_paid, person.booking_partner_id, person.booking_country, person.booking_welfare_required, person.booking_committee_member " .
|
||||
"FROM {booking_person} person, {booking_price} price " .
|
||||
@@ -659,10 +659,10 @@ function _booking_amount_owing($nid, $amount_paid = 0, $include_paypal_fees = TR
|
||||
->fetchObject();
|
||||
|
||||
//$person = node_load($nid);
|
||||
|
||||
*/
|
||||
//quick sanity check
|
||||
if (! $person) {
|
||||
watchdog('booking', "Unable to find matching person relating to registration id '" . $nid . "' .");
|
||||
if (! $person->nid) {
|
||||
watchdog('booking', "Unable to find matching person relating to registration id. Details were '" . var_export($person, TRUE) . "' .");
|
||||
return 0.00;
|
||||
}
|
||||
|
||||
@@ -671,7 +671,7 @@ function _booking_amount_owing($nid, $amount_paid = 0, $include_paypal_fees = TR
|
||||
//if we didn't get the amount paid as a command line parameter, check it now
|
||||
if ($amount_paid == 0)
|
||||
{
|
||||
$amount_paid = _booking_amount_paid($nid, $person);
|
||||
$amount_paid = _booking_amount_paid($person->nid, $person);
|
||||
}
|
||||
|
||||
//check if there is anything outstanding
|
||||
|
@@ -144,30 +144,34 @@ function _booking_process_payment($data) {
|
||||
->execute();
|
||||
|
||||
//Get the person's info
|
||||
/*
|
||||
$payment = db_select('booking_person', 'p')
|
||||
->condition('p.nid', $nid, '=')
|
||||
->fields('p', array('booking_amount_paid', 'booking_status', 'booking_total_pay_reqd', 'booking_partner_id'))
|
||||
->execute()
|
||||
->fetchObject();
|
||||
|
||||
*/
|
||||
|
||||
$person = node_load($nid);
|
||||
|
||||
//check if we found a person matching this payment
|
||||
if ($payment)
|
||||
if ($person)
|
||||
{
|
||||
watchdog('booking', 'Found matching user with node id: !id; event id: !eid; existing payment !payment', array('!id' => $nid, '!eid' => $eid,
|
||||
'!payment' => $payment->booking_amount_paid));
|
||||
'!payment' => $person->booking_amount_paid));
|
||||
//if successful, update their total payment amount
|
||||
$total = $payment->booking_amount_paid + $data['mc_gross'];
|
||||
$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)
|
||||
{
|
||||
watchdog('booking', 'Processing an initial payment. Booking status is currently ' . $payment->booking_status);
|
||||
if ($payment->booking_status == 1)
|
||||
watchdog('booking', 'Processing an initial payment. Booking status is currently ' . $person->booking_status);
|
||||
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 || $payment->booking_status == 2)
|
||||
elseif (_booking_check_bookings_full() == True || $person->booking_status == 2)
|
||||
{
|
||||
watchdog('booking', 'This registration belongs on the waiting list.');
|
||||
$status = 2;
|
||||
@@ -182,8 +186,8 @@ function _booking_process_payment($data) {
|
||||
{
|
||||
watchdog('booking', 'Processing a balance payment.');
|
||||
//if this is a payment of outstanding balance, keep the booking_status the same
|
||||
$status = $payment->booking_status;
|
||||
//$status = $payment->booking_status == 2 ? 2 : 1;
|
||||
$status = $person->booking_status;
|
||||
//$status = $person->booking_status == 2 ? 2 : 1;
|
||||
}
|
||||
|
||||
//update the database for this person
|
||||
@@ -196,26 +200,26 @@ function _booking_process_payment($data) {
|
||||
->execute();
|
||||
|
||||
//If there is no outstanding balance, send a payment complete email
|
||||
$amount_owing = _booking_amount_owing($nid);
|
||||
//if ($total >= $payment->booking_total_pay_reqd)
|
||||
$amount_owing = _booking_amount_owing($person);
|
||||
//if ($total >= $person->booking_total_pay_reqd)
|
||||
if ($amount_owing == 0)
|
||||
{
|
||||
//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) && ($payment->booking_partner_id > 0))
|
||||
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', $payment->booking_partner_id,'=')
|
||||
->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' => $payment->booking_partner_id,
|
||||
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
|
||||
@@ -229,16 +233,16 @@ function _booking_process_payment($data) {
|
||||
'booking_total_pay_reqd' => $spouse_new_amount_reqd,
|
||||
'booking_status' => $spouse_status,
|
||||
))
|
||||
->condition('nid', $payment->booking_partner_id)
|
||||
->condition('nid', $person->booking_partner_id)
|
||||
->execute();
|
||||
|
||||
//send an email to the spouse
|
||||
_booking_registration_email($payment->booking_partner_id, TRUE);
|
||||
_booking_registration_email($person->booking_partner_id, TRUE);
|
||||
}
|
||||
/*
|
||||
elseif (variable_get('booking_enable_combined_pricing', 0) == 1)
|
||||
{
|
||||
watchdog('booking', 'Combined pricing is enabled, but this person has a partner id of !id.', array('!id' => $payment->booking_partner_id));
|
||||
watchdog('booking', 'Combined pricing is enabled, but this person has a partner id of !id.', array('!id' => $person->booking_partner_id));
|
||||
} //end spouse check
|
||||
*/
|
||||
}
|
||||
|
@@ -1495,7 +1495,8 @@ function booking_view($node, $view_mode) {
|
||||
$travel_rows = array();
|
||||
|
||||
//calculate the price owed by this person
|
||||
if (_booking_is_earlybird() == true || _booking_amount_owing($node->nid) == 0)
|
||||
//if (_booking_is_earlybird() == true || _booking_amount_owing($node->nid) == 0)
|
||||
if (_booking_is_earlybird() == true || _booking_amount_owing($node) == 0 || $node->booking_committee_member == 'Y' || $node->booking_welfare_required == 'Y')
|
||||
{
|
||||
$price = $node->booking_price;
|
||||
}
|
||||
|
@@ -103,7 +103,8 @@ function booking_report_summary() {
|
||||
|
||||
foreach ($result as $person) {
|
||||
|
||||
$amount_owing = _booking_amount_owing($person->nid, 0, FALSE);
|
||||
//$amount_owing = _booking_amount_owing($person->nid, 0, FALSE);
|
||||
$amount_owing = _booking_amount_owing($person, 0, FALSE);
|
||||
|
||||
$rows[] = array(
|
||||
l(t('!id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))),
|
||||
@@ -549,7 +550,7 @@ function booking_csv_report() {
|
||||
{
|
||||
$output[] = $value;
|
||||
//this is really hacky since it does another database query for each person
|
||||
$output[] = _booking_amount_owing($value, 0, FALSE);
|
||||
//$output[] = _booking_amount_owing($value, 0, FALSE);
|
||||
//$output[] = _booking_amount_owing($value);
|
||||
continue;
|
||||
}
|
||||
|
@@ -639,13 +639,15 @@ function booking_define_personspecific_tokens($node)
|
||||
$tokens['dietary'] = ucwords(trim($node->booking_dietary));
|
||||
$tokens['booking-id'] = $node->nid;
|
||||
//$tokens['payment-required'] = $node->booking_total_pay_reqd - $amount_paid;
|
||||
$tokens['payment-required'] = _booking_amount_owing($node->nid, $amount_paid, FALSE);
|
||||
//$tokens['payment-required'] = _booking_amount_owing($node->nid, $amount_paid, FALSE);
|
||||
$tokens['payment-required'] = _booking_amount_owing($node, $amount_paid, FALSE);
|
||||
$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['travel-link'] = url('travel/' . $tempid, array('absolute' => TRUE));
|
||||
$tokens['paypal-total-amount'] = _booking_amount_owing($node->nid, $amount_paid);
|
||||
$tokens['paypal-total-amount'] = _booking_amount_owing($node, $amount_paid);
|
||||
//$tokens['paypal-total-amount'] = _booking_amount_owing($node->nid, $amount_paid);
|
||||
$tokens['paypal-deposit-amount'] = _booking_deposit_amount();
|
||||
$tokens['regn-summary'] = _booking_details_email_summary($node);
|
||||
$tokens['travel-summary'] = _booking_travelform_email_summary($node);
|
||||
|
Reference in New Issue
Block a user