This commit is contained in:
2013-12-09 18:01:21 +11:00
parent b8b9fa4085
commit 3328a9aaa0
2 changed files with 42 additions and 10 deletions

View File

@@ -13,14 +13,13 @@
$language = user_preferred_language($user); $language = user_preferred_language($user);
//$account = $user; //$account = $user;
//flush cache for this node
entity_get_controller('node')->resetCache(array($nid));
//load the node matching this id //load the node matching this id
//TODO: Put this back in after testing
$node = node_load($nid); $node = node_load($nid);
//TODO: remove this after testing
//$node = $nid
watchdog('booking', 'Sending email: @info', array('@info' => var_export($node, TRUE))); watchdog('booking', 'Sending registration email to !first !last', array('!first' => $node->booking_firstname, '!last' => $node->booking_lastname));
//waiting list has already been calculated, stored in node //waiting list has already been calculated, stored in node
$waiting_list = $node->booking_status == 2 ? TRUE : FALSE; $waiting_list = $node->booking_status == 2 ? TRUE : FALSE;

View File

@@ -1183,6 +1183,8 @@ function _booking_update($node) {
->condition('nid', $node->nid) ->condition('nid', $node->nid)
->execute(); ->execute();
//now process some post-update triggers
//if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id //if booking_partner_id is set, make sure the nid it refers to has this node as its booking_partner_id
if ($node->booking_partner_id != 0) if ($node->booking_partner_id != 0)
{ {
@@ -1203,8 +1205,7 @@ function _booking_update($node) {
} }
} }
//check if someone needs to move from the waiting list to the booked in list
//now check if someone needs to move from the waiting list to the booked in list
if ($previous_status->booking_status == 1 && $node->booking_status == 3) if ($previous_status->booking_status == 1 && $node->booking_status == 3)
{ {
watchdog('booking', 'Detected person moving from Booked In list to No Longer Coming'); watchdog('booking', 'Detected person moving from Booked In list to No Longer Coming');
@@ -1228,8 +1229,8 @@ function _booking_update($node) {
else else
watchdog('booking', 'Still no room on the booked in list though.'); watchdog('booking', 'Still no room on the booked in list though.');
} }
//if we're not automatically sending emails on registration, then check if //if we're not automatically sending emails on registration
//someone moved from not-paid to booked-in (ie, manual payment process) //and someone moved from not-paid to booked-in (ie, manual payment process)
elseif (variable_get('booking_auto_confirm_email', 0) == 0 && $previous_status->booking_status == 0 && $node->booking_status == 1) elseif (variable_get('booking_auto_confirm_email', 0) == 0 && $previous_status->booking_status == 0 && $node->booking_status == 1)
{ {
watchdog('booking', 'Detected person moving from Not Paid list to Booked In list'); watchdog('booking', 'Detected person moving from Not Paid list to Booked In list');
@@ -1243,7 +1244,39 @@ function _booking_update($node) {
//_booking_promoted_from_waitinglist_email($node->nid); //_booking_promoted_from_waitinglist_email($node->nid);
} }
} }
//if someone moved from the not-paid list to waiting list by manual update
elseif ($previous_status->booking_status == 0 && $node->booking_status == 2)
{
watchdog('booking', 'Detected person moving from Not Paid list to Waiting List');
//create a manual payment entry of zero dollars
//so things like the waiting list report work
$result = db_insert('booking_payment')
->fields(array(
'booking_person_nid' => $node->nid,
'booking_eventid' => $event->eid,
'booking_mc_gross' => '0.00',
'booking_mc_currency' => 'AUD',
'booking_mc_fee' => '0.00',
'booking_quantity' => 1,
'booking_invoice' => 'ManualPayment',
'booking_payer_id' => '',
'booking_payment_date' => REQUEST_TIME,
'booking_payment_status' => '',
'booking_first_name' => $node->booking_firstname,
'booking_last_name' => $node->booking_lastname,
'booking_buyer_email' => '',
'booking_payer_status' => '',
'booking_item_name' => '',
'booking_ipn_track_id' => '',
))
->execute();
//send them an email
_booking_registration_email($node->nid, FALSE, FALSE);
}
//if the payment ID has changed then update the total pay required //if the payment ID has changed then update the total pay required
if ($previous_status->booking_payment_id != $node->booking_payment_id) if ($previous_status->booking_payment_id != $node->booking_payment_id)
{ {