$this->addAccountToCart($registrant['account']);
// Add time data to reg_times table
- $this->addTimeToCart($registrant['reg_time']);
+// **** $this->addTimeToCart($registrant['reg_time']);
} // Each Registrant
}
$totalDiscounts = 0;
$grandTotal = 0;
- // If we have a cart (request)
- if ($this->cart) {
+ $this->cart['blockCheckout'] = false;
+
+ // If we have a cart and a good request array
+ if ($this->cart && is_array($this->cart['request'])) {
// 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']])) {
// If we don't have events for this cart
if (!is_array($this->cart['events']) || count($this->cart['events']) == 0) {
$this->cart['messages'][] = 'Cart is empty.';
+ $this->cart['blockCheckout'] = true;
} else {
// Loop through all events in the cart
$eventRegistrants = 0;
$eventCharges = 0;
$eventDiscounts = 0;
- $eventTotal = 0;
- // Do event Checks
+ // Assume this event is OK
+ $this->cart['events'][$eventKey]['removed'] = false;
+
+ // Update reg_time entries for current availability and get the event data;
+ $regEvent = $RegEvent->checkEventTimes($event['id']);
// Check if Event exists in Events add-on and is active in registrations or if doing admin (admin_active)
$regEvent = $RegEvent->getEntry($event['reg_event']);
if (!$regEvent) {
$this->cart['messages'][] = 'Event in cart is not currently available for registration.';
+ $this->cart['events'][$eventKey]['removed'] = true;
+ $this->cart['blockCheckout'] = true;
}
- // Check if the event is time-specific and if there's a list of times for this event - If not, should be a default
-
-
-
/*
* Classes (levels) Processing
*/
// If we don't have classes for this event
if (!is_array($event['classes']) || count($event['classes']) == 0 ) {
$this->cart['messages'][] = 'Event '.$event['event_name'].' has no levels.';
+ $this->cart['events'][$eventKey]['removed'] = true;
+ $this->cart['blockCheckout'] = true;
} else {
// Loop through all classes (levels) for this event
$classRegistrants = 0;
$classCharges = 0;
$classDiscounts = 0;
- $classTotal = 0;
-
- // Do class (level) checks
+ $this->cart['events'][$eventKey]['classes'][$classKey]['removed'] = false;
/*
* Rates Processing
// If we don't have rates for this class
if (!is_array($class['rates']) || count($class['rates']) == 0 ) {
$this->cart['messages'][] = 'Class '.$class['class_name'].' has no rates.';
+ $this->cart['events'][$eventKey]['classes'][$classKey]['removed'] = true;
+ $this->cart['blockCheckout'] = true;
} else {
// loop through all rates
foreach ($class['rates'] as $rateKey => $rate) {
- $rateRegistrants = 0;
- $rateCharges = 0;
- $rateDiscounts = 0;
- $rateTotal = 0;
+ $rateRegistrants = 0;
+ $rateBaseCharge = 0;
+ $rateRegistrantCharges = 0;
+ $rateDiscounts = 0;
+
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed'] = false;
- // Do rate Checks
+ // Get rate data
+ $eventRate = $RequestRate->getEntry($rate['id']);
+ if (!$eventRate) {
+ $this->cart['message'][] = 'Event rate '.$rate['rage_name'].' is no longer listed - Removed registrants for this rate.';
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed'] = true;
+ } else {
+ /*
+ * Registrants Processing
+ */
- // Update reg_time entries for current availability
- // Check if listed rate is currently available - If not, add as a problem
+ // If we don't have registrants for this class
+ if (!is_array($rate['registrants']) || count($rate['registrants']) == 0 ) {
+ $this->cart['messages'][] = 'Rate '.$rate['rate_name'].' has no registrants.';
+ $this->cart['blockCheckout'] = true;
+ } else {
- /*
- * Registrants Processing
- */
+ // loop through all Registrants
+ foreach ($rate['registrants'] as $registrantKey => $registrant) {
- // If we don't have registrants for this class
- if (!is_array($rate['registrants']) || count($rate['registrants']) == 0 ) {
- $this->cart['messages'][] = 'Rate '.$rate['rate_name'].' has no registrants.';
- } else {
+ $registrantCharges = 0;
+ $registrantDiscounts = 0;
- // loop through all Registrants
- foreach ($rate['registrants'] as $registrantKey => $registrant) {
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['removed'] = false;
- $registrantCharges = 0;
- $registrantDiscounts = 0;
- $registrantTotal = 0;
+ // Check the if registrant still has a time slot hold
- // Do registrant checks
+ // If this registrant is flagged for removal from cart
+ if ($this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed']) {
+// *** remove registrant from cart in Database
+ // Otherwise add registrant to totals
+ } else {
+ // Add registrant to totals
+ if ($rateRegistrants == 0) {
+ $rateBaseCharge = $rate['base_rate'];
+ }
+ $rateRegistrants++;
+ if ($rateRegistrants > $rate['registrant_credits']) {
+ $registrantCharges = $rate['per_registrant'];
+ }
- // Save totals for this registrant
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['totalCharges'] = $registrantCharges;
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['totalDiscounts'] = $registrantDiscounts;
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['rateTotal'] = $registrantTotal;
+ $rateRegistrantCharges += $registrantCharges;
+ $rateDiscounts += $registrantDiscounts;
+ }
- // Add totals to rate
- $rateRegistrants++;
- $rateCharges += $registrantCharges;
- $rateDiscounts += $registrantDiscounts;
- $rateTotal += $registrantTotal;
+ // Save totals for this registrant
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['registrantRate'] = $registrantCharges;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['registrants'][$registrantKey]['registrantDiscounts'] = $registrantDiscounts;
- } // Each registrant
+ } // Each registrant
- } // Have registrants
+ } // Have registrants
- // Save totals for this rate
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalRegistrants'] = $rateRegistrants;
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalCharges'] = $rateCharges;
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalDiscounts'] = $rateDiscounts;
- $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['rateTotal'] = $rateTotal;
+ // Save totals for this rate
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['rateRegistrants'] = $rateRegistrants;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['rateBaseCharge'] = $rateBaseCharge;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['rateRegistrantCharges'] = $rateRegistrantCharges;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['totalDiscounts'] = $rateDiscounts;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['rateTotal'] = ( $rateBaseCharge + $rateRegistrantCarges );
- // Add totals to class
- $classRegistrants += $rateRegistrants;
- $classCharges += $rateCharges;
- $classDiscounts += $rateDiscounts;
- $classTotal += $rateTotal;
+ // Add totals to class
+ $classRegistrants += $rateRegistrants;
+ $classCharges += ( $rateBaseCharge + $rateRegistrantCharges);
+ $classDiscounts += $rateDiscounts;
+
+ // If rate has been flagged for removal from cart, delete it in the database
+ if ($this->cart['events'][$eventKey]['classes'][$classKey]['rates'][$rateKey]['removed']) {
+// *** remove rate from cart in Database
+ }
+
+
+ } // Have rate
} // Each Rate
} // Have rates
// Save totals for this class (level)
- $this->cart['events'][$eventKey]['classes'][$classKey]['totalRegistrants'] = $classRegistrants;
- $this->cart['events'][$eventKey]['classes'][$classKey]['totalCharges'] = $classCharges;
- $this->cart['events'][$eventKey]['classes'][$classKey]['totalDiscounts'] = $classDiscounts;
- $this->cart['events'][$eventKey]['classes'][$classKey]['classTotal'] = $classTotal;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['classRegistrants'] = $classRegistrants;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['classCharges'] = $classCharges;
+ $this->cart['events'][$eventKey]['classes'][$classKey]['classDiscounts'] = $classDiscounts;
// Add totals to event
$eventRegistrants += $classRegistrants;
$eventCharges += $classCharges;
$eventDiscounts += $classDiscounts;
- $eventTotal += $classTotal;
+ // If class has been flagged for removal from cart, delete it from cart in database
+ if ($this->cart['events'][$eventKey]['classes'][$classKey]['removed']) {
+// *** remove class from cart in Database
+ }
} // Each class
} // Have Classes
// Save totals for this event
- $this->cart['events'][$eventKey]['totalRegistrants'] = $eventRegistrants;
- $this->cart['events'][$eventKey]['totalCharges'] = $eventCharges;
- $this->cart['events'][$eventKey]['totalDiscounts'] = $eventDiscounts;
- $this->cart['events'][$eventKey]['eventTotal'] = $eventTotal;
+ $this->cart['events'][$eventKey]['eventRegistrants'] = $eventRegistrants;
+ $this->cart['events'][$eventKey]['eventCharges'] = $eventCharges;
+ $this->cart['events'][$eventKey]['eventDiscounts'] = $eventDiscounts;
// Add totals to request
- $totalCharges += $eventCharges;
$totalRegistrants += $eventRegistrants;
+ $totalCharges += $eventCharges;
$totalDiscounts += $eventDiscounts;
- $grandTotal += $eventTotal;
+
+ // If event has been flagged for removal from cart, delete it from cart in database
+ if ($this->cart['events'][$eventKey]['removed']) {
+//*** remove event from cart in Database
+ }
} // Each event
} // Have events
+ // Save totals for this request
+ $this->cart['totalRegistrants'] = $totalRegistrants;
+ $this->cart['totalCharges'] = $totalCharges;
+ $this->cart['totalDiscounts'] = $totalDiscounts;
+
// Update request last_update timestamp
+// *** update cart last_update time
} // have request
CREATE TABLE {prefix}reg_request_class (
id INT NOT NULL AUTO_INCREMENT,
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
+-- **** event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data
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
CREATE TABLE {prefix}reg_request_rate (
id INT NOT NULL AUTO_INCREMENT,
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
+-- **** event_name TINYTEXT NULL, -- Name of Event so it will always be in the cart data
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
id INT NOT NULL AUTO_INCREMENT,
account INT NULL, -- Pointer to the account entry for the person being registered - False (0) if account no longer exists or registrant account not needed
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
+-- **** 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