Numerous changes. Travel form, CSV report etc
This commit is contained in:
@@ -321,8 +321,8 @@ function _booking_travelform_confirmation_email($nid)
|
|||||||
global $user;
|
global $user;
|
||||||
$language = user_preferred_language($user);
|
$language = user_preferred_language($user);
|
||||||
|
|
||||||
//load the node matching this id
|
//load the node matching this id from the database, ignoring the cache
|
||||||
$node = node_load($nid);
|
$node = node_load($nid, NULL, TRUE);
|
||||||
$tokens = booking_define_personspecific_tokens($node);
|
$tokens = booking_define_personspecific_tokens($node);
|
||||||
|
|
||||||
watchdog('booking', 'Sending travelform confirmation email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
watchdog('booking', 'Sending travelform confirmation email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
|
||||||
|
@@ -552,26 +552,14 @@ function _booking_amount_paid($nid, $person = NULL)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function to calculate the amount outstanding for a person/married couple
|
* Function to calculate the total amount a person is required to pay
|
||||||
*
|
*
|
||||||
* @param $nid - the node id relating to the registration node
|
* @param $person - the populated node object representing this person including related price information
|
||||||
* @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value
|
|
||||||
* @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
|
* @return amount owing as a decimal value
|
||||||
*/
|
*/
|
||||||
function _booking_amount_owing($nid, $amount_paid = 0, $include_paypal_fees = TRUE)
|
function _booking_total_due($person)
|
||||||
{
|
{
|
||||||
//$amount_paid = 0;
|
$total_due = 0.00;
|
||||||
$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 " .
|
|
||||||
"FROM {booking_person} person, {booking_price} price " .
|
|
||||||
"WHERE person.nid = :nid " .
|
|
||||||
"AND person.booking_payment_id = price.pid",
|
|
||||||
array(':nid' => $nid))
|
|
||||||
->fetchObject();
|
|
||||||
|
|
||||||
//determine what rate this person needs to pay
|
//determine what rate this person needs to pay
|
||||||
if ($person->booking_welfare_required == 'Y')
|
if ($person->booking_welfare_required == 'Y')
|
||||||
@@ -587,6 +575,40 @@ function _booking_amount_owing($nid, $amount_paid = 0, $include_paypal_fees = TR
|
|||||||
else
|
else
|
||||||
$total_due = $person->booking_late_price;
|
$total_due = $person->booking_late_price;
|
||||||
|
|
||||||
|
return $total_due;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function to calculate the amount outstanding for a person/married couple
|
||||||
|
*
|
||||||
|
* @param $nid - the node id relating to the registration node
|
||||||
|
* @param $amount_paid - if we have previously calculated the amount paid, this can be passed as a value
|
||||||
|
* @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)
|
||||||
|
{
|
||||||
|
//$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 " .
|
||||||
|
"FROM {booking_person} person, {booking_price} price " .
|
||||||
|
"WHERE person.nid = :nid " .
|
||||||
|
"AND person.booking_payment_id = price.pid",
|
||||||
|
array(':nid' => $nid))
|
||||||
|
->fetchObject();
|
||||||
|
|
||||||
|
//quick sanity check
|
||||||
|
if (! $person) {
|
||||||
|
watchdog('booking', "Unable to find matching person relating to registration id '" . $nid . "' .");
|
||||||
|
return 0.00;
|
||||||
|
}
|
||||||
|
|
||||||
|
$total_due = _booking_total_due($person);
|
||||||
|
|
||||||
//if we didn't get the amount paid as a command line parameter, check it now
|
//if we didn't get the amount paid as a command line parameter, check it now
|
||||||
if ($amount_paid == 0)
|
if ($amount_paid == 0)
|
||||||
{
|
{
|
||||||
|
@@ -869,7 +869,7 @@ function _booking_validate($node, &$form_state) {
|
|||||||
|
|
||||||
//verify that a state has been entered if "Other" was selected
|
//verify that a state has been entered if "Other" was selected
|
||||||
if (($form_state['booking_state'] == 'Other' ) && ($form_state['booking_other_state'] == ''))
|
if (($form_state['booking_state'] == 'Other' ) && ($form_state['booking_other_state'] == ''))
|
||||||
form_set_error('booking_other_state', t('You must enter your State in the address section of the Contact details.'));
|
form_set_error('booking_other_state', t('You must enter your State in the address section of the Contact details. Please put N/A if your country does not have states.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
function booking_form_submit($form, &$form_state) {
|
function booking_form_submit($form, &$form_state) {
|
||||||
@@ -1092,7 +1092,7 @@ function booking_load($nodes) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//watchdog('booking', 'Final loaded node: @info', array('@info' => var_export($nodes, TRUE)));
|
watchdog('booking', 'Final loaded node: @info', array('@info' => var_export($nodes, TRUE)));
|
||||||
// no return necessary since $nodes array members reference objects global to this function
|
// no return necessary since $nodes array members reference objects global to this function
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -36,7 +36,7 @@ function booking_report_summary() {
|
|||||||
array('data' => t('Name'), 'field' => 'booking_lastname'),
|
array('data' => t('Name'), 'field' => 'booking_lastname'),
|
||||||
array('data' => t('Email'), 'field' => 'booking_email'),
|
array('data' => t('Email'), 'field' => 'booking_email'),
|
||||||
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
|
array('data' => t('Payment To Date'), 'field' => 'booking_amount_paid'),
|
||||||
array('data' => t('Total Payment Required'), 'field' => 'booking_total_pay_reqd'),
|
array('data' => t('Total Payment Required')),
|
||||||
array('data' => t('Fully paid?')),
|
array('data' => t('Fully paid?')),
|
||||||
array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
|
array('data' => t('Welfare Required?'), 'field' => 'booking_welfare_required'),
|
||||||
);
|
);
|
||||||
@@ -93,7 +93,7 @@ function booking_report_summary() {
|
|||||||
|
|
||||||
foreach ($result as $person) {
|
foreach ($result as $person) {
|
||||||
|
|
||||||
$amount_owing = _booking_amount_owing($person->nid);
|
$amount_owing = _booking_amount_owing($person->nid, 0, FALSE);
|
||||||
|
|
||||||
$rows[] = array(
|
$rows[] = array(
|
||||||
l(t('!id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))),
|
l(t('!id', array('!id' => $person->nid)), t('node/!id', array('!id' => $person->nid))),
|
||||||
@@ -103,7 +103,7 @@ function booking_report_summary() {
|
|||||||
),
|
),
|
||||||
t('!email', array('!email' => $person->booking_email)),
|
t('!email', array('!email' => $person->booking_email)),
|
||||||
t('!payment', array('!payment' => $person->booking_amount_paid)),
|
t('!payment', array('!payment' => $person->booking_amount_paid)),
|
||||||
t('!payment', array('!payment' => $person->booking_total_pay_reqd)),
|
t('!payment', array('!payment' => $amount_owing == 0 ? $person->booking_total_pay_reqd : _booking_total_due($person))),
|
||||||
t('!fullypaid', array('!fullypaid' => $amount_owing == 0 ? 'Yes' : 'No')),
|
t('!fullypaid', array('!fullypaid' => $amount_owing == 0 ? 'Yes' : 'No')),
|
||||||
t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No'),
|
t($person->booking_welfare_required == 'Y' ? 'Yes' : 'No'),
|
||||||
);
|
);
|
||||||
@@ -509,7 +509,10 @@ function booking_csv_report() {
|
|||||||
if ($key == 'nid')
|
if ($key == 'nid')
|
||||||
{
|
{
|
||||||
$output[] = $value;
|
$output[] = $value;
|
||||||
$output[] = _booking_amount_owing($value);
|
//this is really hacky since it does another massive database query for each person
|
||||||
|
//$person = node_load($value);
|
||||||
|
$output[] = _booking_amount_owing($value, 0, FALSE);
|
||||||
|
//$output[] = _booking_amount_owing($value);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -532,6 +532,10 @@ function booking_token_info() {
|
|||||||
'name' => t('Registration Travel Summary'),
|
'name' => t('Registration Travel Summary'),
|
||||||
'description' => t('Summary of travel details from user registration.')
|
'description' => t('Summary of travel details from user registration.')
|
||||||
);
|
);
|
||||||
|
$info['tokens']['booking']['travel-link'] = array(
|
||||||
|
'name' => t('Travel form Link'),
|
||||||
|
'description' => t('Link to the person\'s travel form.')
|
||||||
|
);
|
||||||
return $info;
|
return $info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -640,6 +644,7 @@ function booking_define_personspecific_tokens($node)
|
|||||||
$tokens['payment-transaction-desc'] = $node->nid . ' ' . $node->booking_lastname;
|
$tokens['payment-transaction-desc'] = $node->nid . ' ' . $node->booking_lastname;
|
||||||
$tokens['balance-payment-link'] = url('balance/' . $tempid, array('absolute' => TRUE));
|
$tokens['balance-payment-link'] = url('balance/' . $tempid, array('absolute' => TRUE));
|
||||||
$tokens['confirm-payment-link'] = url('confirm/' . $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->nid, $amount_paid);
|
||||||
$tokens['paypal-deposit-amount'] = _booking_deposit_amount();
|
$tokens['paypal-deposit-amount'] = _booking_deposit_amount();
|
||||||
$tokens['regn-summary'] = _booking_details_email_summary($node);
|
$tokens['regn-summary'] = _booking_details_email_summary($node);
|
||||||
|
Reference in New Issue
Block a user