// 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';
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
'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
}
// 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.';
$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
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
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
// Add registrant account to accounts table
$this->addAccountToCart($registrant['account']);
+ // Add time data to reg_times table
+ $this->addTimeToCart($registrant['reg_time']);
+
} // Each Registrant
}
* 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
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
}
}
-
-/*
- * 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
}
+ /*
+ * 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
*
-- 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,
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
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