From: Chuck Scott Date: Fri, 7 Apr 2017 20:35:50 +0000 (-0400) Subject: Minor database updates. X-Git-Tag: v1.0.0^2~481 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/index.cgi?a=commitdiff_plain;h=ce1a1919bf7bb3c2d95ae9726569acd94051e027;p=WP-Plugins%2Fglm-member-db-registrations.git Minor database updates. --- diff --git a/classes/data/dataRegEvent.php b/classes/data/dataRegEvent.php index cdf8cbf..b1c523b 100644 --- a/classes/data/dataRegEvent.php +++ b/classes/data/dataRegEvent.php @@ -224,7 +224,6 @@ class GlmDataRegistrationsRegEvent extends GlmDataAbstract 'use' => 'a' ), - // Bitmap of restricted (admin use only) payment methods for this event - see payment_method 'restricted_payment_methods' => array ( 'field' => 'restricted_payment_methods', diff --git a/classes/registrationsSupport.php b/classes/registrationsSupport.php index cc76975..71d0dc3 100644 --- a/classes/registrationsSupport.php +++ b/classes/registrationsSupport.php @@ -16,6 +16,7 @@ // Load required data classes for registration events require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php'; +require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegTime.php'; require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegClass.php'; require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRate.php'; @@ -104,6 +105,14 @@ class GlmRegistrationsSupport public function getRegistrationCart($requestId = false) { + $RegEvent = new GlmDataRegistrationsRegEvent($this->wpdb, $this->config); + $RegTime = new GlmDataRegistrationsRegTime($this-->wpdb, $this->config); + $RegRequest = new GlmDataRegistrationsRequest($this->wpdb, $this->config); + $RequestEvent = new GlmDataRegistrationsRequestEvent($this->wpdb, $this->config); + $RequestClass = new GlmDataRegistrationsRequestClass($this->wpdb, $this->config); + $RequestRate = new GlmDataRegistrationsRegRequestRate($this->wpdb, $this->config); + $RequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config); + // Clear cart data $this->cart = array( 'status' => false, // Return status, default to false, true if valid request returned @@ -111,8 +120,9 @@ class GlmRegistrationsSupport 'notes' => array(), // System generated notes regarding status of request 'accounts' => array(), // Accounts associated with this request - both requesting and attending (might be the same) // Index in this array is the account ID as used in data below + 'times' => array(), // reg_time records associated with this request - Index is the reg_time ID 'request' => false, // Base request record - 'events' => array() // List of events requested + 'events' => array() // List of events requested ); // Validate request ID @@ -121,7 +131,6 @@ class GlmRegistrationsSupport } // Try to get the base registration request data - $RegRequest = new GlmDataRegistrationsRequest($this->wpdb, $this->config); $this->cart['request'] = $RegRequest->getEntry($requestId); if (!$this->cart['request']) { $this->cart['errorMsg'] = 'Unable to retrieve the requested registration request.'; @@ -132,15 +141,16 @@ class GlmRegistrationsSupport $this->addAccountToCart($this->cart['request']['account']); // Get list of events being requested - $RequestEvent = new GlmDataRegistrationsRequestEvent($this->wpdb, $this->config); $this->cart['events'] = $RequestEvent->getList("T.reg_request = $requestId"); // For each event if ($this->cart['events']) { foreach ($this->cart['events'] as $eventKey => $event) { + // Get reg_event record for this event + $this->cart['events'][$eventKey]['reg_event'] = $RegEvent->getEntry($event['reg_event']); + // Get list of event classes requested for this event - $RequestClass = new GlmDataRegistrationsRequestClass($this->wpdb, $this->config); $this->cart['events'][$eventKey]['classes'] = $RequestClass->getList("T.reg_request = $requestId"); // For each class selected for this event @@ -148,7 +158,6 @@ class GlmRegistrationsSupport foreach ($this->cart['events'][$eventKey]['classes'] as $classKey => $class) { // Get list of rates requested for this class - $RequestRate = new GlmDataRegistrationsRegRequestRate($this->wpdb, $this->config); $this->cart['events'][$eventKey]['classes'][$classKey]['rates'] = $RequestRate->getList("T.reg_request = $requestId"); // For each rate selected for this class @@ -156,7 +165,6 @@ class GlmRegistrationsSupport foreach ($this->cart['events'][$eventKey]['classes'][$classKey]['rates'] as $rateKey => $rate) { // Get list of registrants requested for this rate - $RequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config); $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'] = $RequestRegistrant->getList("T.reg_request = $requestId"); // For each rate selected for this class @@ -166,6 +174,9 @@ class GlmRegistrationsSupport // Add registrant account to accounts table $this->addAccountToCart($registrant['account']); + // Add time data to reg_times table + $this->addTimeToCart($registrant['reg_time']); + } // Each Registrant } @@ -201,7 +212,7 @@ class GlmRegistrationsSupport * Updates all totals * Updates request last accessed time * - * @param integer $requestId + * @param integer $requestId If false then check the currently loaded cart * * @return array Array of request and all associated information or false * @access public @@ -209,13 +220,37 @@ class GlmRegistrationsSupport public function checkRegistrationRequest($requestId = false) { - $this->getRegistrationCart($requestId); + $messages[] = ''; + + // If request ID is not false, get the cart first + if ($requestId !== false) { - if (!$this->cart['status']) { - return; + // If we didn't get a cart using this ID or there was some failure getting it, then return false + if (!$this->getRegistrationCart($requestId) || !$this->cart['status']) { + return false; + } } - // **** NEED TO COMPLETE THIS FUNCTION **** + // If a submission account is specified (otherwise it should be a guest user prior to checkout) + if ($this->cart['request']['account'] && !isset($this->cart['accounts'][$this->cart['request']['account']])) { + $messages[] .= 'Account for person submitting the request is missing.'; + } + + // Check if there's no events listed + if (is_array($this->cart['events']) && count($this->cart['events']) > 0) { + $messages[] .= 'Cart is empty.'; + } else { + + // Loop through all events in the cart + foreach ($this->cart['events'] as $event) { + + // Check if Event exists in Events add-on + + } + + } // have events + + // Check if Event Time exists in Events add-on } @@ -239,9 +274,8 @@ class GlmRegistrationsSupport } - -/* - * Add an account to the accounts list if not already there + /* + * Add an account to the accounts list in the temoporary cart array if not already there * * * @param integer $accountId @@ -276,6 +310,42 @@ class GlmRegistrationsSupport } + /* + * Add a reg_time record to the times list in the temoporary cart array if not already there + * + * + * @param integer $timeId + * + * @return boolean Success or fail + * @access public + */ + public function addTimeToCart($timeId) + { + + // Check the supplied reg_time ID + $timeId = ($timeId-0); + if ($timeId == 0) { + return false; + } + + // Try to get the account record for the person who submitted (is submitting) the request + $RegTime = new GlmDataRegistrationsRegTime($this->wpdb, $this->config); + $time = $Account->getEntry($timeId); + + // If time was not found + if (!$time) { + return false; + } + + // If the time doesn't exist in the times array, add it + if (!isset($this->cart['times'][$timeId])) { + $this->cart['times'][$time['id']] = $time; + } + + return true; + + } + /* * Add temporary test data * diff --git a/setup/databaseScripts/create_database_V0.0.7.sql b/setup/databaseScripts/create_database_V0.0.7.sql index e13438e..5bb41af 100644 --- a/setup/databaseScripts/create_database_V0.0.7.sql +++ b/setup/databaseScripts/create_database_V0.0.7.sql @@ -467,9 +467,9 @@ CREATE TABLE {prefix}account ( -- Has one or more reg_detail records associated with it CREATE TABLE {prefix}reg_request ( id INT NOT NULL AUTO_INCREMENT, - account INT NULL, -- Pointer to user account (reg_account) who submitted the registrations + account INT NULL, -- Pointer to user account (reg_account) who submitted the registrations. If false then guest request (prior to checkout) validated BOOLEAN NULL, -- Flag that indicates if request passed last validation with checkRegistrationRequest() - validation_message TEXT NULL, -- Reasons that request did not pass validation with checkRegistrationRequest() + validation_message TEXT NULL, -- Reasons that request did not pass validation with checkRegistrationRequest() - Serialized array bill_fname TINYTEXT NULL, -- Billing information used for this registration submission - Updates account billing address - Kept here for each request bill_lname TINYTEXT NULL, bill_org TINYTEXT NULL, @@ -532,7 +532,6 @@ CREATE TABLE {prefix}reg_request_class ( account INT NULL, -- Pointer to account (person submitting the registration) reg_event INT NULL, -- Pointer to reg_event entry event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data - reg_time INT NULL, -- Pointer reg_time entry event_datetime DATETIME NULL, -- Date and time of event time selected so it will always be in the cart reg_request INT NULL, -- Pointer to the registration request record reg_request_event INT NULL, -- Pointer to reg_request_event table entry @@ -557,8 +556,9 @@ CREATE TABLE {prefix}reg_request_rate ( account INT NULL, -- Pointer to account (person submitting the registration) reg_event INT NULL, -- Pointer to reg_event entry event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data - reg_time INT NULL, -- Pointer reg_time entry - event_datetime DATETIME NULL, -- Date and time of event time selected so it will always be in the cart + event_datetime DATETIME N // Add registrant account to accounts table + $this->addAccountToCart($registrant['account']); +ULL, -- Date and time of event time selected so it will always be in the cart reg_request INT NULL, -- Pointer to the registration request record reg_request_event INT NULL, -- Pointer to reg_request_event table entry reg_request_class INT NULL, -- Pointer to reg_request_class table entry diff --git a/setup/databaseScripts/update_database_V0.0.7.sql b/setup/databaseScripts/update_database_V0.0.7.sql index 131fd5a..fa17062 100644 --- a/setup/databaseScripts/update_database_V0.0.7.sql +++ b/setup/databaseScripts/update_database_V0.0.7.sql @@ -42,11 +42,7 @@ CREATE INDEX reg_event ON {prefix}reg_request_rate (reg_event); ---- -DROP INDEX event_time ON {prefix}reg_request_rate; ----- -ALTER TABLE {prefix}reg_request_rate CHANGE event_time reg_time INT; ----- -CREATE INDEX reg_time ON {prefix}reg_request_rate (reg_time); +ALTER TABLE {prefix}reg_request_rate DROP COLUMN event_time; ---- @@ -58,11 +54,7 @@ CREATE INDEX reg_event ON {prefix}reg_request_class (reg_event); ---- -DROP INDEX event_time ON {prefix}reg_request_class; ----- -ALTER TABLE {prefix}reg_request_class CHANGE event_time reg_time INT; ----- -CREATE INDEX reg_time ON {prefix}reg_request_class (reg_time); +ALTER TABLE {prefix}reg_request_class DROP COLUMN event_time; ---- @@ -74,11 +66,7 @@ CREATE INDEX reg_event ON {prefix}reg_request_event (reg_event); ---- -DROP INDEX event_time ON {prefix}reg_request_event; ----- -ALTER TABLE {prefix}reg_request_event CHANGE event_time reg_time INT; ----- -CREATE INDEX reg_time ON {prefix}reg_request_event (reg_time); +ALTER TABLE {prefix}reg_request_event DROP COLUMN event_time; ----