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.
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
return true;
}
- trigger_error('purgeOldRegTimePending() errors: '.$res['error'], E_USER_WARNING);
+ trigger_error('deleteRegTimePending() errors: '.$res['error'], E_USER_WARNING);
return false;
}
*
* 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
// 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
$res['success'] = false;
$res['error'] .= 'Unable to store update.';
}
+
}
return $res;
*
* 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
* @package glmMembersDatabase
* @author Chuck Scott <cscott@gaslightmedia.com>
* @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/
*/
// 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;
<tr><th colpsan="2" style="white-space: nowrap;"><h3>Edit {$terms.reg_term_attendee} availability here for this {$terms.reg_term_event}.</h3></th></tr>
{if $rt.attendee_max == 0}
<tr><th colspan="2">Unlimited {$terms.reg_term_registration} - Set maximum {$terms.reg_term_attendee_plur} quantity below to limit {$terms.reg_term_registration_plur}.</th></tr>
- {/if}
+ {else}
<tr><td colspan="2">Limited availability for this {$terms.reg_term_event} - the below numbers are for all days.</td></tr>
- <tr><th style="text-align: left">Maximum {$terms.reg_term_attendee_plur_cap}:</th><td>
+ {/if}
+ <tr><th style="text-align: left">Maximum {$terms.reg_term_attendee_plur_cap} (0 for unlimited):</th><td>
<input class="glm-form-text-input-veryshort availabilityInput" type="text" id="maxAtt" value="{$rt.attendee_max}">
<div id="availSubmit" class="button-primary" data-timeid="{$rt.id}">Update</div>
<span id="submit-flash" class="glm-notice" style="display: none; margin-left: 1rem;">Submitted</span>
<tr id="dialogStartTimeLine"><th style="text-align: left" class="glm-required">Start Time:</th><td><input id="dialogStartTime" class="glm-form-text-input-short time-input not-all-day" type="text" value=""></td></tr>
<tr id="dialogEndTimeLine"><th style="text-align: left" class="glm-required">End Time:</th><td><input id="dialogEndTime" class="glm-form-text-input-short time-input not-all-day" type="text" value=""></td></tr>
{if $regEvent.time_specific.value}
- <tr><th style="text-align: left" class="glm-required">Maximum {$terms.reg_term_attendee_plur_cap}:</th><td><input class="glm-form-text-input-veryshort availabilityInput" type="text" id="dialogMaxAtt" value=""> 0 = Unlimited</td></tr>
+ <tr><th style="text-align: left" class="glm-required">Maximum {$terms.reg_term_attendee_plur_cap}:</th><td><input class="glm-form-text-input-veryshort availabilityInput" type="text" id="dialogMaxAtt" value=""> (0 = Unlimited)</td></tr>
<tr id="dialogRegLine"><th style="text-align: left">{$terms.reg_term_registered_cap} {$terms.reg_term_attendee_plur_cap}:</th><td id="dialogRegAtt"></td></tr>
<tr id="dialogPendLine"><th style="text-align: left">Pending in Carts:</th><td id="dialogPendAtt"></td></tr>
- <tr id="dialogAvailLine"><th style="text-align: left">Available for {$terms.reg_term_registration_cap}:</th><td id="dialogAvailAtt"></td></tr>
+ <tr id="dialogAvailLine"><th style="text-align: left">Available for {$terms.reg_term_registration_cap}:</th><td><span id="dialogAvailAtt"></span> (0 = Unlimited)</td></tr>
{else}
<tr><th style="text-align: left" colspan="2">Use form above calendar to adjust {$terms.reg_term_attendee} availability.</td></tr>
{/if}
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);
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);