diff --git a/booking.emails.inc b/booking.emails.inc index 78cc56e..7bb08dd 100644 --- a/booking.emails.inc +++ b/booking.emails.inc @@ -13,14 +13,13 @@ $language = user_preferred_language($user); //$account = $user; + //flush cache for this node + entity_get_controller('node')->resetCache(array($nid)); + //load the node matching this id - - //TODO: Put this back in after testing $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 = $node->booking_status == 2 ? TRUE : FALSE; diff --git a/booking.register.inc b/booking.register.inc index e7d6615..76d3a79 100644 --- a/booking.register.inc +++ b/booking.register.inc @@ -1183,6 +1183,8 @@ function _booking_update($node) { ->condition('nid', $node->nid) ->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 ($node->booking_partner_id != 0) { @@ -1203,8 +1205,7 @@ function _booking_update($node) { } } - - //now check if someone needs to move from the waiting list to the booked in list + //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) { watchdog('booking', 'Detected person moving from Booked In list to No Longer Coming'); @@ -1228,8 +1229,8 @@ function _booking_update($node) { else watchdog('booking', 'Still no room on the booked in list though.'); } - //if we're not automatically sending emails on registration, then check if - //someone moved from not-paid to booked-in (ie, manual payment process) + //if we're not automatically sending emails on registration + //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) { 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); } } - + //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 ($previous_status->booking_payment_id != $node->booking_payment_id) {