From: Chuck Scott Date: Thu, 27 Sep 2018 16:17:21 +0000 (-0400) Subject: Changed display of attendee numbers in dashboard to make more sense. X-Git-Tag: v1.0.22^2~2 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=0907e582455e8326eb450280804a2499d59c1e9c;p=WP-Plugins%2Fglm-member-db-registrations.git Changed display of attendee numbers in dashboard to make more sense. When displaying attendee numbers, now checking for errors and correcting. --- diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index d22ecaf..76448b7 100755 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -465,12 +465,62 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract // Get sum of all attendee counts $countsData = $this->wpdb->get_row($sql, ARRAY_A); + // Calculate Available numbers + $totalAvailCalc = $countsData['total'] - $countsData['registered']; + $curAvailCalc = $countsData['total'] - $countsData['registered'] - $countsData['cartHold']; + + /* + * Note: we have seen a few errors in the total available numbers in the times entries. + * This could be due to other errors that have now been corrected. This will ensure that + * any such errors, new or lingering, are corrected. + */ + + // If calc error, verify and update incorrect attendees_available values in time entries + $curAvailError = false; + $availErrorCorrected = false; + if ($countsData['curAvail'] != $curAvailCalc) { + + $curAvailError = true; + + // Get reg times for this event + require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegTime.php'; + $RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config); + $regEventTimes = $RegTime->getList("reg_event = ".$eventId); + + // If we have times loop through all looking for calc errors + if (is_array($regEventTimes) && count($regEventTimes) > 0) { + foreach ($regEventTimes as $regTime) { + + // If this time entry isn't right + $availCalc = $regTime['attendee_max'] - $regTime['attendee_count'] - $regTime['attendees_pending']; + if ($availCalc != $regTime['attendees_available']) { + + // Set the correct attendees_available + $sql = " + UPDATE ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_time + SET attendees_available = $availCalc + WHERE id = ".$regTime['id']; + $rows = $this->wpdb->query($sql); + if ($rows = 1) { + $availErrorCorrected = true; + } + } + + } + + } + + } + $counts = array( 'total' => $countsData['total'], 'registered' => $countsData['registered'], 'cartHold' => $countsData['cartHold'], 'curAvail' => $countsData['curAvail'], - 'totalAvail' => $countsData['cartHold'] + $countsData['curAvail'] + 'curAvailCalc' => $curAvailCalc, + 'totalAvail' => $totalAvailCalc, + 'curAvailError' => $curAvailError, + 'errorCorrected' => $availErrorCorrected ); return $counts; diff --git a/models/admin/registrations/events_eventDashboard.php b/models/admin/registrations/events_eventDashboard.php old mode 100644 new mode 100755 diff --git a/setup/databaseScripts/create_database_V1.0.1.sql b/setup/databaseScripts/create_database_V1.0.1.sql index 54bc4d0..fe3819a 100755 --- a/setup/databaseScripts/create_database_V1.0.1.sql +++ b/setup/databaseScripts/create_database_V1.0.1.sql @@ -284,7 +284,7 @@ CREATE TABLE {prefix}reg_time ( attendee_max MEDIUMINT NULL, -- Attendee count limit - 0 = unlimited - get from reg_event record attendee_count MEDIUMINT NULL, -- Current attendee count - calculated on the fly and stored here for reference attendees_pending MEDIUMINT NULL, -- Current number of attendees for this time in active pending carts (Not checked out and attendees slots held) - attendees_available MEDIUMINT NULL, -- Currently available attendee count (limit - current - pending) + attendees_available MEDIUMINT NULL, -- Currently available attendee count (limit - registered - pending) total_base_charge DOUBLE NULL, -- Total base charges total_per_attendee DOUBLE NULL, -- Total per-attendee charges total_other DOUBLE NULL, -- Total other charges (meals, extras, fees, ...) diff --git a/views/admin/registrations/eventDashboard.html b/views/admin/registrations/eventDashboard.html old mode 100644 new mode 100755 index 2c729c4..fc86a82 --- a/views/admin/registrations/eventDashboard.html +++ b/views/admin/registrations/eventDashboard.html @@ -11,7 +11,7 @@

{$terms.reg_term_event_cap} Code:

- {$regEvent.event_code} + {$regEvent.event_code} (ID {$regEvent.id})
@@ -55,26 +55,27 @@ {if $haveRegEvent}
-

Cart Hold:

+

{$terms.reg_term_attendee_plur_cap} Available:

- {$regEvent.cartHold} + {$regEvent.totalAvail}
-

Currently Available:

+

On Hold in Pending Requests:

- {$regEvent.curAvail} + {$regEvent.cartHold}
-

Total Available:

+

Available Less Currently Held:

- {$regEvent.totalAvail} + {$regEvent.curAvailCalc} + {if $regEvent.curAvailError}
(discrepancy in stored quantity corrected) {/if}
{/if}