Result of checRegistrationRequest() is essentially the same array as returned by getRegistrationCart() but will addition information inserted.
Initial comments are in the regCartSupport class on how cart will be validated and some code is in place.
Some additional debugging and fixes to admin reg setup for classes and rates and user interface updates.
/*
* Checks validity of a request (cart) and sets new update time (for holds)
*
- * This function loads the entire cart using the supplied request ID then checks it for any issues.
+ * This function checks the currently loaded cart for any issues and recalculates totals.
*
* Checks links to referenced events and event times records in the Event Add-on tables and notes if either are missing.
* Checks all referenced Accounts for non-guest carts and notes if any are missing.
* Updates all totals
* Updates request last accessed time
*
- * @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)
+ public function checkRegistrationRequest()
{
$messages[] = '';
+ $totalCharges = 0;
+ $totalRegistrants = 0;
+ $totalDiscounts = 0;
+ $grandTotal = 0;
+
// If request ID is not false, get the cart first
if ($requestId !== false) {
// Check if there's no events listed
if (is_array($this->cart['events']) && count($this->cart['events']) > 0) {
- $messages[] .= 'Cart is empty.';
+ $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
+ foreach ($this->cart['events'] as $eventKey => $event) {
+ $this->cart['events'][$eventKey]['charges'] = 0;
+ $this->cart['events'][$eventKey]['credits'] = 0;
+ $this->cart['events'][$eventKey]['discounts'] = 0;
+ $this->cart['events'][$eventKey]['total'] = 0;
+ $this->cart['events'][$eventKey]['numbRegistrants'] = 0;
+
+ // 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) {
+ $messages[] = 'Event in cart is not currently available for registratiosn.';
+ }
+
+ // Check if the event is time-specific and if there's a list of times for this event - If not, should be a default
+
+ // Check if there's a list of classes (levels) for this event - If not, add as a problem
+
+ // Loop though all classes - Might be multiple classes (levels) that are the same but for different reg_times.
+
+ // [this class]['charges'] = 0;
+ // [this class]['credits'] = 0;
+ // [this class]['discounts'] = 0;
+ // [this class]['total'] = 0;
+ // [this class]['numbRegistrants'] = 0;
+
+
+ // Check if there's a list of rates - if not, add as a problem
+
+ // loop through all rates
+
+ // [this rate]['charges'] = 0;
+ // [this rate]['credits'] = 0;
+ // [this rate]['discounts'] = 0;
+ // [this rate]['total'] = 0;
+ // [this rate]['numbRegistrants'] = 0;
+
+ // Check if listed rate is currently available - If not, add as a problem
+
+ // Check if there's a list of registrants for this class (level) - If not, add as a problem
+
+ // Loop through all registrants
+
+ // [this registrant]['charges'] = 0;
+ // [this registrant]['credits'] = 0;
+ // [this registrant]['discounts'] = 0;
+ // [this registrant]['total'] = 0;
+
+ // Check that registrant has an account that's active - If not, add as a problem
+
+ // Check if limited registration
+
+ // Check for a current hold - If expired or not listed
+
+ // If no current hold, try to get new hold - If not, add as a problem
+
+ // If no problems, then calculate charges
+
+ // If there's not already a charge for this class (level) - Add base rate to charges
+
+ // If the number of registrants is less than the registrant credits - Add the per-registrant rate
+
+ // Check if there's a comp or discount code - if so add add discount
+
+ // Calculate net charge for this registrant and put it in registrant data
+
+ // Add charges, credits, discounts, totals to the current rate
+
+ // Add charges, credits, discounts, totals for this rate to the current class (level)
+
+ // Add charges, credits, discounts, totals for class (level) to the current event
+
+ // Add charges, credits, discounts, totals for this event to the grand totals
+
+
}
} // have events
}
- /*
- * Add temporary test data
- *
- * This builds a completed registration request and adds it to the appropriate
- * database tables.
- *
- * This function builds the following data
- *
- * 1 reg_event
- * 1 reg_class
- * 1 reg_rates
- *
- * 1 account - Account also used as registrant
- *
- * 1 reg_request
- * 1 reg_request_event
- * 1 reg_request_class
- * 1 reg_request_rate
- * 1 reg_request_registrant
- *
- */
- public function addTestData()
- {
-
- // Grab the first event from the events database
- $sql = "SELECT id, name FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."events LIMIT 1";
- $event = $this->wpdb->get_results($sql, ARRAY_A);
- $eventId = $event[0]['id'];
- $eventName = $event[0]['name'];
-
- // Grab the first time from this event
- $sql = "SELECT id, start_time FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."times WHERE event = $eventId LIMIT 1";
- $time = $this->wpdb->get_results($sql, ARRAY_A);
- $timeId = $event[0]['id'];
- $eventTime = $time[0]['start_time'];
-
- // Event
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_event
- (
- event,
- event_name,
- event_code,
- active
- )
- VALUES
- (
- $eventId,
- '$eventName',
- 'TEST-EVENT',
- true
- )
- ;";
- $this->wpdb->query($sql);
- $regEventID = $this->wpdb->insert_id;
-
- // Event Registration Class
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_class
- (
- reg_event,
- name,
- descr
- )
- VALUES
- (
- $regEventID,
- 'Admiral Class',
- 'This is our Admiral Class registration level.'
- )
- ;";
- $this->wpdb->query($sql);
- $regClassID = $this->wpdb->insert_id;
-
- // Event Registration Rate
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_rate
- (
- reg_event,
- reg_class,
- name,
- start_days,
- end_days,
- base_rate,
- per_registrant,
- registrant_credits
- )
- VALUES
- (
- $regEventID,
- $regClassID,
- 'Rate Name',
- 100,
- 50,
- 20,
- 10,
- 1
- )
- ;";
- $this->wpdb->query($sql);
- $regRateID = $this->wpdb->insert_id;
-
-
- // Account
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."account
- (
- active,
- fname
- )
- VALUES
- (
- true,
- 'Chuck'
- )
- ;";
- $this->wpdb->query($sql);
- $accountID = $this->wpdb->insert_id;
-
-
- // Registration Request
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request
- (
- account,
- bill_fname,
- bill_lname,
- bill_org,
- bill_title,
- bill_addr1,
- bill_addr2,
- bill_city,
- bill_state,
- bill_zip,
- bill_country,
- date_submitted,
- pay_method,
- payment_code,
- status,
- total,
- cc_type,
- cc_name,
- cc_numb,
- cc_exp,
- cc_cvv,
- cc_conf,
- summary,
- mf_data,
- notes
- )
- VALUES
- (
- ".$accountID.",
- 'Chuck',
- 'Scott',
- 'Gaslight Media',
- 'Vice President',
- '120 E. Lake St.',
- '3rd Floor',
- 'Petoskey',
- 'MI',
- '49770',
- 'US',
- '".date('Y-m-d')."',
- ".$this->config['payment_method_numb']['Not Yet Defined'].",
- 'NULL',
- ".$this->config['submission_status_numb']['CART'].",
- 100,
- 'NULL',
- 'NULL',
- 'NULL',
- 'NULL',
- 'NULL',
- 'NULL',
- '<P>HTML SUMMARY</P>',
- 'NULL',
- 'Notes go here'
- )
- ;";
- $this->wpdb->query($sql);
- $requestID = $this->wpdb->insert_id;
-
- // Registration Request Event
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_event
- (
- account,
- reg_request,
- event,
- event_name,
- event_time,
- event_datetime,
- total_charge,
- mf_data,
- notes
- )
- VALUES
- (
- $accountID,
- $requestID,
- $regEventID,
- '$eventName',
- $timeId,
- '$eventTime',
- 100,
- '',
- ''
- )
- ;";
- $this->wpdb->query($sql);
- $requestEventID = $this->wpdb->insert_id;
-
- // Registration Request class
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_class
- (
- account,
- event,
- event_name,
- event_time,
- event_datetime,
- reg_request,
- reg_request_event,
- class,
- class_name,
- total_class_charge,
- mf_data,
- notes
- )
- VALUES
- (
- $accountID,
- $regEventID,
- '$eventName',
- $timeId,
- '$eventTime',
- $requestID,
- $requestEventID,
- 0,
- 'Class Name',
- 100,
- '',
- ''
- )
- ;";
- $this->wpdb->query($sql);
- $requestClassID = $this->wpdb->insert_id;
-
-
- // Registration Request Rate
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_rate
- (
- account,
- event,
- event_name,
- event_time,
- event_datetime,
- reg_request,
- reg_request_event,
- reg_request_class,
- rate,
- rate_name,
- base_rate,
- per_registrant,
- registrant_credits,
- numb_registrants,
- total_registrant_charges,
- mf_data,
- notes
- )
- VALUES
- (
- $accountID,
- $regEventID,
- '$eventName',
- $timeId,
- '$eventTime',
- $requestID,
- $requestEventID,
- $requestClassID,
- 0,
- 'Rate Name',
- 100,
- 10,
- 1,
- 1,
- 100,
- '',
- ''
- )
- ;";
- $this->wpdb->query($sql);
- $requestRateID = $this->wpdb->insert_id;
-
-
- // Registration Request Registrant
- $sql = "
- INSERT INTO ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_registrant
- (
- account,
- event,
- event_name,
- event_time,
- event_datetime,
- reg_request,
- reg_request_event,
- reg_request_class,
- reg_request_rate,
- reg_request_registrant,
- fname,
- lname,
- mf_data,
- notes
- )
- VALUES
- (
- $accountID,
- $regEventID,
- '$eventName',
- $timeId,
- '$eventTime',
- $requestID,
- $requestEventID,
- $requestClassID,
- $requestRateID,
- $accountID,
- 'First',
- 'Last',
- '',
- ''
- )
- ;";
- $this->wpdb->query($sql);
- $requestRegistrantID = $this->wpdb->insert_id;
-
- return;
-
- }
-
- public function removeRegistrationRequestData()
- {
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_event;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_class;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_rate;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."account;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_event;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_class;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_rate;");
- $this->wpdb->query("DELETE FROM ".GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX."reg_request_registrant;");
-
- }
-
}
this.listenTo( this.model, 'change', this.render );
// Use the reg rates sent as an attribute to the class to create the rates models
- this.model.setRates(this.model.attributes.reg_rate);
+ if (this.model.attributes.reg_rate) {
+ this.model.setRates(this.model.attributes.reg_rate);
+ }
return this;
},
myself.$('.class-edit-template').hide();
myself.$('.class-update').hide();
myself.$('.class-add').hide();
+ myself.$('.class-delete').show();
myself.$('.class-edit').show();
myself.newClass = false;
} else {
delete: function(){
console.log('deleteLevel called');
- if (this.model.attributes.reg_rate) {
- alert('Please remove all rate entries below before deleting this level.');
- return false;
- }
-
+
if (glmSubmitRequired) {
alert('Please complete your other edit first.');
return false;
}
- if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
+ if (!confirm(
+ 'Are you sure you want to delete this? ' +
+ 'Deleting this level will also remove all associated rates!'
+ )) {
return false;
}
this.$('.class-edit-template').show();
this.$('.class-update').show();
this.$('.class-edit').hide();
+ this.$('.class-delete').hide();
this.$('.class-name').focus();
glmSubmitRequired += 1;
},
this.$('.class-edit-template').hide();
this.$('.class-update').hide();
this.$('.class-edit').show();
+ this.$('.class-delete').show();
glmSubmitRequired -= 1;
},
this.$('.class-update').hide();
this.$('.class-edit').show();
this.$('.class-add').show();
+ this.$('.class-delete').hide();
this.$('.class-name').focus();
this.newClass = true;
glmSubmitRequired += 1;
},
getInputData: function() {
+
var input = {
name: this.$('.rate-name').val().trim(),
start_days: this.$('.rate-start-days').val().trim(),
end_days: this.$('.rate-end-days').val().trim(),
- base_rate: this.$('.rate-base-rate').val().trim(),
- per_registrant: this.$('.rate-per-registrant').val().trim(),
- registrant_credits: this.$('.rate-registrant-credits').val().trim()
+ base_rate: this.currency(this.$('.rate-base-rate').val().trim()),
+ per_registrant: this.currency(this.$('.rate-per-registrant').val().trim()),
+ registrant_credits: Number(this.$('.rate-registrant-credits').val().trim())
};
return input;
},
+ currency: function (v) {
+ v = v.trim().replace ( /[^0-9.]/g, '' );
+ if (v == '') {
+ v = 0;
+ }
+ v = '$' + Number(v).toFixed(2);
+ return v;
+ },
+
add: function(){
console.log('add called');
+ // Get parent for id to send to backend for new rate
+ var parentClass = this.model.get( 'parent' );
+
var formData = this.getInputData();
// Check for required data -- NEED TO MOVE THIS TO getInputData function
this.model.set(formData);
- // Get parent for id to send to backend for new rate
- var parentClass = this.model.get( 'parent' );
-
// Try to save the registration rate
var newID = false;
myself = this;
formData.wait = true;
formData.option = 'add';
+ formData.reg_event = parentClass.attributes.reg_event;
this.model.save(
formData
- ).success(function(data){
+ ).success(function(data){
if (data > 0) {
console.log('AJAX Rate Save Successful: ID = '+data);
myself.model.set({id: data});
myself.$('.rate-display-template').show();
myself.$('.rate-edit-template').hide();
myself.$('.rate-update').hide();
+ myself.$('.rate-delete').show();
myself.$('.rate-add').hide();
myself.newRate = false;
} else {
return false;
}
+ if (!confirm('Are you sure you want to delete this?')) {
+ return false;
+ }
+
// Remove rate here
var x = this.model.get('id');
+
this.model.destroy({data: {
id: x,
option: 'delete'
}});
-
+
this.remove();
+
},
edit: function() {
console.log('edit called');
this.$('.rate-display-template').hide();
this.$('.rate-edit-template').show();
+ this.$('.rate-update').show();
+ this.$('.rate-delete').hide();
this.$('.rate-name').focus();
glmSubmitRequired += 1;
}
this.$('.rate-display-template').show();
this.$('.rate-edit-template').hide();
+ this.$('.rate-delete').show();
glmSubmitRequired -= 1;
},
this.$('.rate-edit-template').show();
this.$('.rate-update').hide();
this.$('.rate-add').show();
+ this.$('.rate-delete').hide();
this.$('.rate-name').focus();
this.newRate = true;
glmSubmitRequired += 1;
this.listenTo( this.model, 'change', this.render );
// Use the reg rates sent as an attribute to the class to create the rates models
- this.model.setRates(this.model.attributes.reg_rate);
+ if (this.model.attributes.reg_rate) {
+ this.model.setRates(this.model.attributes.reg_rate);
+ }
return this;
},
myself.$('.class-edit-template').hide();
myself.$('.class-update').hide();
myself.$('.class-add').hide();
+ myself.$('.class-delete').show();
myself.$('.class-edit').show();
myself.newClass = false;
} else {
delete: function(){
console.log('deleteLevel called');
- if (this.model.attributes.reg_rate) {
- alert('Please remove all rate entries below before deleting this level.');
- return false;
- }
-
+
if (glmSubmitRequired) {
alert('Please complete your other edit first.');
return false;
}
- if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
+ if (!confirm(
+ 'Are you sure you want to delete this? ' +
+ 'Deleting this level will also remove all associated rates!'
+ )) {
return false;
}
this.$('.class-edit-template').show();
this.$('.class-update').show();
this.$('.class-edit').hide();
+ this.$('.class-delete').hide();
this.$('.class-name').focus();
glmSubmitRequired += 1;
},
this.$('.class-edit-template').hide();
this.$('.class-update').hide();
this.$('.class-edit').show();
+ this.$('.class-delete').show();
glmSubmitRequired -= 1;
},
this.$('.class-update').hide();
this.$('.class-edit').show();
this.$('.class-add').show();
+ this.$('.class-delete').hide();
this.$('.class-name').focus();
this.newClass = true;
glmSubmitRequired += 1;
},
getInputData: function() {
+
var input = {
name: this.$('.rate-name').val().trim(),
start_days: this.$('.rate-start-days').val().trim(),
end_days: this.$('.rate-end-days').val().trim(),
- base_rate: this.$('.rate-base-rate').val().trim(),
- per_registrant: this.$('.rate-per-registrant').val().trim(),
- registrant_credits: this.$('.rate-registrant-credits').val().trim()
+ base_rate: this.currency(this.$('.rate-base-rate').val().trim()),
+ per_registrant: this.currency(this.$('.rate-per-registrant').val().trim()),
+ registrant_credits: Number(this.$('.rate-registrant-credits').val().trim())
};
return input;
},
+ currency: function (v) {
+ v = v.trim().replace ( /[^0-9.]/g, '' );
+ if (v == '') {
+ v = 0;
+ }
+ v = '$' + Number(v).toFixed(2);
+ return v;
+ },
+
add: function(){
console.log('add called');
+ // Get parent for id to send to backend for new rate
+ var parentClass = this.model.get( 'parent' );
+
var formData = this.getInputData();
// Check for required data -- NEED TO MOVE THIS TO getInputData function
this.model.set(formData);
- // Get parent for id to send to backend for new rate
- var parentClass = this.model.get( 'parent' );
-
// Try to save the registration rate
var newID = false;
myself = this;
formData.wait = true;
formData.option = 'add';
+ formData.reg_event = parentClass.attributes.reg_event;
this.model.save(
formData
- ).success(function(data){
+ ).success(function(data){
if (data > 0) {
console.log('AJAX Rate Save Successful: ID = '+data);
myself.model.set({id: data});
myself.$('.rate-display-template').show();
myself.$('.rate-edit-template').hide();
myself.$('.rate-update').hide();
+ myself.$('.rate-delete').show();
myself.$('.rate-add').hide();
myself.newRate = false;
} else {
return false;
}
+ if (!confirm('Are you sure you want to delete this?')) {
+ return false;
+ }
+
// Remove rate here
var x = this.model.get('id');
+
this.model.destroy({data: {
id: x,
option: 'delete'
}});
-
+
this.remove();
+
},
edit: function() {
console.log('edit called');
this.$('.rate-display-template').hide();
this.$('.rate-edit-template').show();
+ this.$('.rate-update').show();
+ this.$('.rate-delete').hide();
this.$('.rate-name').focus();
glmSubmitRequired += 1;
}
this.$('.rate-display-template').show();
this.$('.rate-edit-template').hide();
+ this.$('.rate-delete').show();
glmSubmitRequired -= 1;
},
this.$('.rate-edit-template').show();
this.$('.rate-update').hide();
this.$('.rate-add').show();
+ this.$('.rate-delete').hide();
this.$('.rate-name').focus();
this.newRate = true;
glmSubmitRequired += 1;
*/
public function modelAction( $actionData = false )
{
-
+
// Get Backbone collection we're talking with
$collection = filter_var( $_REQUEST['collection'], FILTER_SANITIZE_STRING );
trigger_error ( "ERROR: The specified model file doesn't exist. ($modelName)", E_USER_ERROR);
wp_die();
}
-
- ini_set('display_errors', 1);
- error_reporting(E_ALL);
// Load the model file
require_once $modelName;
// Instantiate the model and ask it to perform the work
$model = new $className($this->wpdb, $this->config);
-
+
$results = $model->modelAction($modelData);
case 'add':
// Make sure we got a parent ID with the data
- if (isset($modelData['parent']) || (modelData['parent']-0) > 0) {
+ if (isset($modelData['parent']) || ($modelData['parent']-0) > 0) {
// Try to insert the class (level) data
$res = $this->wpdb->insert(
$classID = ($modelData['id'] - 0);
if ($classID > 0) {
+ $this->wpdb->delete( GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_rate', array( 'reg_class' => $classID ), array( '%d' ) );
$this->wpdb->delete( $this->table, array( 'id' => $classID ), array( '%d' ) );
}
public function modelAction($modelData)
{
+ $ratesFields = array(
+ 'reg_event' => $modelData['reg_event'],
+ 'reg_class' => $modelData['reg_class'],
+ 'name' => $modelData['name'],
+ 'start_days' => $modelData['start_days'],
+ 'end_days' => $modelData['end_days'],
+ 'base_rate' => str_replace('$', '', $modelData['base_rate']),
+ 'per_registrant' => str_replace('$', '', $modelData['per_registrant']),
+ 'registrant_credits' => $modelData['registrant_credits']
+ );
+
+ $ratesFieldTypes = array(
+ '%d',
+ '%d',
+ '%s',
+ '%d',
+ '%d',
+ '%f',
+ '%f',
+ '%d'
+ );
+
// Perform specified action
switch ($modelData['option']) {
-
+
case 'add':
// Make sure we got a parent ID with the data
// Try to insert the rate (level) data
$res = $this->wpdb->insert(
$this->table,
- array(
- 'reg_event' => $modelData['reg_event'],
- 'reg_class' => $modelData['reg_class'],
- 'name' => $modelData['name'],
- 'start_days' => $modelData['start_days'],
- 'end_days' => $modelData['end_days']
- ),
- array(
- '%d',
- '%d',
- '%s',
- '%d',
- '%d'
- )
+ $ratesFields,
+ $ratesFieldTypes
);
if ($res != 1) {
// Try to update the class (level) data
$this->wpdb->update(
$this->table,
- array(
- 'name' => $modelData['name'],
- 'start_days' => $modelData['start_days'],
- 'end_days' => $modelData['end_days']
- ),
+ $ratesFields,
array('id' => $rateID),
- array(
- '%s',
- '%d',
- '%d'
- ),
+ $ratesFieldTypes,
array( '%d' )
);
// Separate Event, Classes, and Times and send those as separate JSONs
$regClassesJSON = json_encode($regEvent['reg_class']);
$regTimesJSON = json_encode($regEvent['reg_time']);
-// echo "<pre>".print_r($regEvent['reg_class'],1)."</pre>";
// Get rid of class and time arrays so we just have the event data
unset($regEvent['reg_class']);
<?php
- require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
+/**
+ * Gaslight Media Members Database
+ * Admin Registrations Cart
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package glmMembersDatabase
+ * @author Chuck Scott <cscott@gaslightmedia.com>
+ * @license http://www.gaslightmedia.com Gaslightmedia
+ * @release cart.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link http://dev.gaslightmedia.com/
+ */
- class GlmMembersFront_registrations_cart extends GlmDataRegistrationsRegEvent {
+// Load Registrations Support
+require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/regCartSupport.php';
+
+class GlmMembersFront_registrations_cart extends GlmRegCartSupport
+{
/**
* WordPress Database Object
*
*
* @return array Array containing status, suggested view, and any data
*/
+ public function __construct ($wpdb, $config)
+ {
+
+ // Save WordPress Database object
+ $this->wpdb = $wpdb;
+
+ // Save plugin configuration object
+ $this->config = $config;
+
+ /*
+ * Run constructor for the REgistrations data class
+ *
+ * Note, the third parameter is a flag that indicates to the Contacts
+ * data class that it should flag a group of fields as 'view_only'.
+ */
+ parent::__construct(false, false, true);
+
+ }
+
public function modelAction($actionData = false)
{
+ $cartID = false;
+ $haveCart = false;
+
+
// Get any provided option
if (isset($_REQUEST['option'])) {
$option = $_REQUEST['option'];
}
}
+ // Get cart ID if supplied
+ if (isset($_REQUEST['cart'])) {
+
+ // Make sure it's numeric
+ $cartID = ($_REQUEST['cart'] - 0);
+
+ if ($cartID <= 0) {
+ $cartID = false;
+ } else {
+ $cart = $this->getRegistrationCart($cartID);
+ if ($cart) {
+ $haveCart = true;
+ }
+ }
+ }
+
+
+
$view = 'cart';
switch ( $option ) {
+
+
+ case 'showCart':
+ default:
+
+
+
+ break;
}
);
}
- }
+}
<?php
require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegEvent.php';
-
+
class GlmMembersFront_registrations_registration extends GlmDataRegistrationsRegEvent {
/**
* WordPress Database Object
switch ( $option ) {
default:
+
// Get the RegEvent entry
$regEvent = $this->getEntry( $eventRegID );
//echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
<th {if $regEvent.fieldRequired.notify_email}class="glm-required-nowrap-left-align"{else}class="glm-nowrap-left-align"{/if}>Notify E-Mail Address</th>
<td {if $regEvent.fieldFail.notify_email}class="glm-form-bad-input" data-tabid="glm-notify_email"{/if}>
<input type="text" name="notify_email" value="{$regEvent.fieldData.notify_email}" class="glm-form-text-input-medium">
+ <br>You may enter up to 5 E-Mail addresses separated by commas. Administrative notifications will go out to all of those addresses.
{if $regEvent.fieldFail.notify_email}<p>{$regEvent.fieldFail.notify_email}</p>{/if}<br>
</td>
</tr>
<tr>
<th {if $regEvent.fieldRequired.descr}class="glm-required-nowrap-left-align"{else}class="glm-nowrap-left-align"{/if}>Description (optional)</th>
<td {if $regEvent.fieldFail.descr}class="glm-form-bad-input" data-tabid="glm-descr"{/if}>
- <textarea name="descr" class="glm-form-textarea">{$regEvent.fieldData.descr}</textarea>
- {if $regEvent.fieldFail.descr}
- <p>{$regEvent.fieldFail.descr}</p>
- {/if}<br>
+ {php}
+ wp_editor('{$regEvent.fieldData.descr|escape:quotes}', 'glm_descr', array(
+ 'media_buttons' => false,
+ // 'quicktags' => false,
+ // 'wpautop' => false, NOTE: Dont use. Problem when numerous spaces before text.
+ 'textarea_name' => 'descr',
+ 'editor_height' => 200, // Height in px, overrides editor_rows
+ // 'textarea_rows' => 8
+ ));
+ {/php}
+ {if $regEvent.fieldFail.descr}<p>{$regEvent.fieldFail.descr}</p>{/if}
</td>
</tr>
<tr>
<th {if $regEvent.fieldRequired.terms}class="glm-required-nowrap-left-align"{else}class="glm-nowrap-left-align"{/if}>Terms and Conditions for Registration</th>
<td {if $regEvent.fieldFail.terms}class="glm-form-bad-input" data-tabid="glm-terms"{/if}>
- <textarea name="terms" class="glm-form-textarea">{$regEvent.fieldData.terms}</textarea>
- {if $regEvent.fieldFail.terms}
- <p>{$regEvent.fieldFail.terms}</p>
- {/if}<br>
+ {php}
+ wp_editor('{$regEvent.fieldData.terms|escape:quotes}', 'glm_terms', array(
+ 'media_buttons' => false,
+ // 'quicktags' => false,
+ // 'wpautop' => false, NOTE: Dont use. Problem when numerous spaces before text.
+ 'textarea_name' => 'terms',
+ 'editor_height' => 200, // Height in px, overrides editor_rows
+ // 'textarea_rows' => 8
+ ));
+ {/php}
+ {if $regEvent.fieldFail.terms}<p>{$regEvent.fieldFail.terms}</p>{/if}
</td>
</tr>
<tr>
</div>
</div>
</div>
- <div class="rate-edit-template" style="display: none;">
+ <div class="rate-edit-template" style="display: none; border: 1px solid black; padding: 1em; margin: 1em;">
<div class="glm-rate-header">
<div class="glm-right">
<a class="rate-update button glm-button-small-highlighted">Update</a>
<a class="rate-add button glm-button-small-highlighted" style="display: none;">Add</a>
<a class="rate-delete button button-secondary glm-button-small">Delete</a>
</div>
+ <h3>Rate Days and Costs</h3>
<div class="glm-rate-label" style="padding-bottom: .3em;">
<table class="glm-admin-table">
<tr>
<tr>
<th style="white-space: nowrap;">Cost:</th>
<td>
- Base <input class="rate-base-rate glm-form-text-input-veryshort" type="text" name="base_rate_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (base_rate) { %><%- base_rate %><% } %>">
- Per-Registrant <input class="rate-per-registrant glm-form-text-input-veryshort" type="text" name="per_registrant_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (per_registrant) { %><%- per_registrant %><% } %>">
- Registrant Credits <input class="rate-registrant-credits glm-form-text-input-veryshort" type="text" name="registrant_credits_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (registrant_credits) { %><%- registrant_credits %><% } %>">
+ <span class="glm-nowrap">Base <input class="rate-base-rate glm-form-text-input-veryshort" type="text" name="base_rate_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (base_rate) { %><%- base_rate %><% } %>"></span>
+ <span class="glm-nowrap">Per-Registrant <input class="rate-per-registrant glm-form-text-input-veryshort" type="text" name="per_registrant_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (per_registrant) { %><%- per_registrant %><% } %>"></span>
+ <span class="glm-nowrap">Registrant Credits <input class="rate-registrant-credits glm-form-text-input-veryshort" type="text" name="registrant_credits_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (registrant_credits) { %><%- registrant_credits %><% } %>"></span>
<br>
</td>
<div class="glm-reg-event-list" id="regApp">
</div>
-
- <div style="border: 1px black solid; padding: .3em; background-color: white; margin-top: 4em;">
- <h3>Things that need to be fixed</h3>
- <ul>
- <li>* Fields do not get focus when adding or editing.</li>
- <li>* Need to complete edit on new entry before it's possible to delete.</li>
- </ul>
- </div>
-
{* Bootstrap the models needed on page load *}
{* Need to have RegEvent model created *}
return true;
}
});
-
+
});
</script>