From: Chuck Scott Date: Thu, 14 Jun 2018 18:45:33 +0000 (-0400) Subject: Fixed various customer-reported errors and confusion X-Git-Tag: v1.0.2^2~3 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=a9cc21abe0fc4407367b342d4cf06ce7774ccbee;p=WP-Plugins%2Fglm-member-db-registrations.git Fixed various customer-reported errors and confusion Updated regCartSupport->updateTimeEntryCounts() to better detect count errors and problems. Updated dataRegRequest delete code to better handle attendees, available, pending counts. Fixed confusion with pop date edit dialog box in reg_event Dashboard. Improved messags and display around the Maximum attendees value input in reg_event Dashboard. --- diff --git a/classes/data/dataRegRequest.php b/classes/data/dataRegRequest.php index c5b3a56..e8725e0 100644 --- a/classes/data/dataRegRequest.php +++ b/classes/data/dataRegRequest.php @@ -543,26 +543,25 @@ class GlmDataRegistrationsRegRequest extends GlmDataAbstract if (is_array($registrants) && count($registrants) > 0) { foreach ($registrants as $registrant) { - // Delete holds in reg_time_pending for this registrant - if (false === $this->wpdb->get_results(" - DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_time_pending - WHERE registrant = ".$registrant['id'] - )) { - $err = $this->wpdb->last_error; - $this->wpdb->query('ROLLBACK'); - return $err; + // Delete hold in reg_time_pending for this registrant + $holdRes = $this->wpdb->delete( + GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX.'reg_time_pending', + 'registrant = '.$registrant['id'], + array( '%d' ) + ); + + // Set number of hold deleted (should only be one but might be 0 or false) + $holdDeleted = 0; + if ($holdRes == 1) { + $holdDeleted = 1; } // If request was submitted and inventory updated, restore inventory $submittedStatus = array( 10, 30, 50, 60, 70 ); // See config/plugin.ini in registrations if (in_array($request['status']['value'], $submittedStatus)) { - - $this->wpdb->query(" - UPDATE ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "reg_time - SET attendee_count = attendee_count - 1, - attendees_available = attendees_available + 1 - WHERE id = ".$registrant['reg_time']." - "); + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/regCartSupport.php'; + $RegCartSupport = new GlmRegCartSupport($this->wpdb, $this->config); + $RegCartSupport->updateTimeEntryCounts($registrant['reg_time'], $holdDeleted, -1); } // If registrant's account is not referenced by any other registrants or requests diff --git a/classes/regCartSupport.php b/classes/regCartSupport.php index 939b1db..bfae21a 100644 --- a/classes/regCartSupport.php +++ b/classes/regCartSupport.php @@ -1224,7 +1224,7 @@ class GlmRegCartSupport return true; } - trigger_error('purgeOldRegTimePending() errors: '.$res['error'], E_USER_WARNING); + trigger_error('deleteRegTimePending() errors: '.$res['error'], E_USER_WARNING); return false; } @@ -1239,8 +1239,9 @@ class GlmRegCartSupport * * To return counts (reduce) use a negative number. To consume counts use positive. * - * @param integer $pending Number used to decrement the pending value - * @param integer $count Number used to decrement the attendee_count value (for removing a confirmed registrant) + * @param integer $timeId ID of reg_time entry to adjust + * @param integer $pending Number used to adjust the pending value + * @param integer $count Number used to adjust the attendee_count value (for removing a confirmed registrant) * * @return array('success' boolean, 'error' string) * @access public @@ -1269,17 +1270,36 @@ class GlmRegCartSupport // Adjust balances $time['attendee_count'] += $counts; $time['attendees_pending'] += $pending; - $time['attendees_available'] = $time['attendee_max'] - ($time['attendee_count']+$time['attendees_pending']); - // Do sanity check on results + // If not unlimted, adjust available number + if ($time['attendee_max'] > 0) { + $time['attendees_available'] = $time['attendee_max'] - ($time['attendee_count']+$time['attendees_pending']); + } - if ($time['attendees_pending'] < 0 || $time['attendees_pending'] > ($time['attendee_max']-$time['attendee_count'])) { - $res['success'] = false; - $res['error'] .= 'Result has invalid pending attendees count.'; + // If there's a negative number of attendees pending set to 0 and report error in log + if ($time['attendees_pending'] < 0) { + $time['attendees_pending'] = 0; + trigger_error("regCartSupport->updateTimeEntryCounts(): Problem = negative attendees pending, timeID = $timeId", E_USER_NOTICE); } - if ($time['attendee_count'] < 0 || $time['attendee_count'] > ($time['attendee_max'])) { - $res['success'] = false; - $res['error'] .= 'Result has invalid confirmed attendee count.'; + + // If not unlimited and we have more pending than available attendee slots, adjust this, make sure it's >= 0 and note this in the log + if ($time['attendee_max'] > 0 && $time['attendees_pending'] > ($time['attendee_max']-$time['attendee_count'])) { + $time['attendees_pending'] = $time['attendee_max']-$time['attendee_count']; + if ($time['attendees_pending'] < 0) { + $time['attendees_pending'] = 0; + } + trigger_error("regCartSupport->updateTimeEntryCounts(): Problem = invalid or negative pending count, timeID = $timeId", E_USER_NOTICE); + } + + // If the attendee count is less than 0, set to 0 and report in error log + if ($time['attendee_count'] < 0) { + $time['attendee_count'] = 0; + trigger_error("regCartSupport->updateTimeEntryCounts(): Problem = negative attendee count set to 0, timeID = $timeId", E_USER_NOTICE); + } + + // If not unlimited and attendee count greater than the max attendees, do nothing but note in error log. + if ($time['attendee_max'] > 0 && $time['attendee_count'] > ($time['attendee_max'])) { + trigger_error("regCartSupport->updateTimeEntryCounts(): Problem = attendee count more than max (not adjusted), timeID = $timeId", E_USER_NOTICE); } // If all is well, update time entry @@ -1304,6 +1324,7 @@ class GlmRegCartSupport $res['success'] = false; $res['error'] .= 'Unable to store update.'; } + } return $res; @@ -1353,7 +1374,7 @@ class GlmRegCartSupport * * This method also removes holds associated with this request. * - * The reason inventory update and notify are both in this method is that they both ********************************************************************* FIX WHEN DONE TESTING + * The reason inventory update and notify are both in this method is that they both * happen at the same time and they both require walking through the cart data. * * @param string $summary HTML Summary of checkout for sending to owner and requesting address diff --git a/models/admin/registrations/events_addEdit.php b/models/admin/registrations/events_addEdit.php index 51a6854..fcc5712 100644 --- a/models/admin/registrations/events_addEdit.php +++ b/models/admin/registrations/events_addEdit.php @@ -9,7 +9,7 @@ * @package glmMembersDatabase * @author Chuck Scott * @license http://www.gaslightmedia.com Gaslightmedia - * @release events_delete.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ + * @release events_addEdit.php,v 1.0 2014/10/31 19:31:47 cscott Exp $ * @link http://dev.gaslightmedia.com/ */ diff --git a/models/front/registrations/checkoutProcess.php b/models/front/registrations/checkoutProcess.php index 0f1fff4..7b0703c 100644 --- a/models/front/registrations/checkoutProcess.php +++ b/models/front/registrations/checkoutProcess.php @@ -696,6 +696,7 @@ class GlmMembersFront_registrations_checkoutProcess extends GlmRegCartSupport // Check if not properly stored ..... Send E-Mail to developers if ($updated != 1) { + $reqData['wpdb_error_message'] = $last_error; $reqData['query_result'] = print_r($updated,1); $reqData['user_trace_info'] = unserialize($reqData['user_trace_info']); $reqData['REQUEST'] = $_REQUEST; diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html index dc83cfa..2c729c4 100644 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -208,9 +208,10 @@

Edit {$terms.reg_term_attendee} availability here for this {$terms.reg_term_event}.

{if $rt.attendee_max == 0} Unlimited {$terms.reg_term_registration} - Set maximum {$terms.reg_term_attendee_plur} quantity below to limit {$terms.reg_term_registration_plur}. - {/if} + {else} Limited availability for this {$terms.reg_term_event} - the below numbers are for all days. - Maximum {$terms.reg_term_attendee_plur_cap}: + {/if} + Maximum {$terms.reg_term_attendee_plur_cap} (0 for unlimited):
Update
@@ -249,10 +250,10 @@ Start Time: End Time: {if $regEvent.time_specific.value} - Maximum {$terms.reg_term_attendee_plur_cap}: 0 = Unlimited + Maximum {$terms.reg_term_attendee_plur_cap}: (0 = Unlimited) {$terms.reg_term_registered_cap} {$terms.reg_term_attendee_plur_cap}: Pending in Carts: - Available for {$terms.reg_term_registration_cap}: + Available for {$terms.reg_term_registration_cap}: (0 = Unlimited) {else} Use form above calendar to adjust {$terms.reg_term_attendee} availability. {/if} @@ -382,7 +383,7 @@ dayClick: function(date, allDay, jsEvent, view) { $('#dialogAvailSubmit').off('click'); - $('#availabilityTitle').html('Create New: '+date.format('MM/DD/YYYY')); + $('#availabilityTitle').html(date.format('MM/DD/YYYY')); $('#availabilityEditDialog').dialog('open'); $('#dialogRegActive').prop('checked', false); $('#dialogTimeAllDay').prop('checked', false); @@ -627,10 +628,12 @@ var max = $('#maxAtt').val(); var count = $('#regAtt').html(); var pending = $('#pendAtt').html(); - var available = max - count - pending; + if (max == 0) { + available = 0; + } else { + var available = max - count - pending; + } if (available < 0) { - max = max - available; - $('#maxAtt').val(max); available = 0; } $('#availAtt').html(available);