}
+
+
+ /*
+ * Create a new cart
+ *
+ * A new cart consists of only one reg_request record
+ *
+ * @return array Array of request and all associated information or false
+ * @access public
+ */
+ public function createRegistrationCart()
+ {
+
+ $res = $this->wpdb->insert(
+ GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . 'reg_request',
+ array(
+ 'account' => 0,
+ 'validated' => false,
+ 'user_trace_info' => $_SERVER["REMOTE_ADDR"]." - ".date("m/d/Y H:i:s")
+ ),
+ array(
+ '%d',
+ '%d',
+ '%s'
+ )
+ );
+
+ if ($res != 1) {
+ return false;
+ }
+
+ // If there's a new reg request id, declare success
+ $requestID = $this->wpdb->insert_id;
+ if ($requestID) {
+ return $requestID;
+ }
+
+ return false;
+
+ }
+
+
/*
* Retrieve a complete cart
*
add: function(){
console.log('add called');
+ // Get data from form
var cName = this.$('.class-name').val().trim();
var cDescr = this.$('.class-descr').val().trim();
+ // Check for required data
if (cName == '') {
alert('The Level Name is Required!');
return;
}
- this.$('.class-display-template').show();
- this.$('.class-edit-template').hide();
- this.$('.class-update').hide();
- this.$('.class-add').hide();
+ // ???
this.model.set({ name: cName, descr: cDescr });
// Get parent for id to send to backend for new class
var parentEvent = this.model.get( 'parent' );
- if (!this.model.save({ option: 'add', parent: parentEvent.id, name: cName, descr: cDescr })) {
+ // Try to save the registration class
+ $newID = this.model.save({ option: 'add', parent: parentEvent.id, name: cName, descr: cDescr });
+
+ if (!$newID){
console.log('AJAX Save Error');
} else {
console.log('AJAX Save Successful');
}
+
+ this.model.set( 'id', $newID );
+
+ this.$('.class-display-template').show();
+ this.$('.class-edit-template').hide();
+ this.$('.class-update').hide();
+ this.$('.class-add').hide();
+ this.$('.class-edit').show();
+
// Add this new model to the collection.
var parentEvent = this.model.get( 'parent' ); // ????????
// parentEvent.classes.create( this.model );
this.$('.class-display-template').hide();
this.$('.class-edit-template').show();
this.$('.class-name').focus();
+ this.$('.class-update').show();
glmSubmitRequired += 1;
},
add: function(){
console.log('add called');
+ // Get data from form
var cName = this.$('.class-name').val().trim();
var cDescr = this.$('.class-descr').val().trim();
+ // Check for required data
if (cName == '') {
alert('The Level Name is Required!');
return;
}
- this.$('.class-display-template').show();
- this.$('.class-edit-template').hide();
- this.$('.class-update').hide();
- this.$('.class-add').hide();
+ // ???
this.model.set({ name: cName, descr: cDescr });
// Get parent for id to send to backend for new class
var parentEvent = this.model.get( 'parent' );
- if (!this.model.save({ option: 'add', parent: parentEvent.id, name: cName, descr: cDescr })) {
+ // Try to save the registration class
+ $newID = this.model.save({ option: 'add', parent: parentEvent.id, name: cName, descr: cDescr });
+
+ if (!$newID){
console.log('AJAX Save Error');
} else {
console.log('AJAX Save Successful');
}
+
+ this.model.set( 'id', $newID );
+
+ this.$('.class-display-template').show();
+ this.$('.class-edit-template').hide();
+ this.$('.class-update').hide();
+ this.$('.class-add').hide();
+ this.$('.class-edit').show();
+
// Add this new model to the collection.
var parentEvent = this.model.get( 'parent' ); // ????????
// parentEvent.classes.create( this.model );
this.$('.class-display-template').hide();
this.$('.class-edit-template').show();
this.$('.class-name').focus();
+ this.$('.class-update').show();
glmSubmitRequired += 1;
},
// Get Backbone collection we're talking with
$collection = filter_var( $_REQUEST['collection'], FILTER_SANITIZE_STRING );
-
+
// If not a valid collection, die quietly
if (!in_array($collection, array('regClasses', 'regRates'))) {
wp_die();
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);
+trigger_error(print_r($modelData,1));
+
$results = $model->modelAction($modelData);
public function modelAction($modelData)
{
-trigger_error(print_r($modelData,1));
-
// Perform specified action
switch ($modelData['option']) {
case 'add':
+
+ // Make sure we got a parent ID with the data
+ if (isset($modelData['parent']) || (modelData['parent']-0) > 0) {
+
+ // Try to insert the class (level) data
+ $res = $this->wpdb->insert(
+ $this->table,
+ array(
+ 'reg_event' => $modelData['parent'],
+ 'name' => $modelData['name'],
+ 'descr' => $modelData['descr']
+ ),
+ array(
+ '%d',
+ '%s',
+ '%s'
+ )
+ );
+
+ if ($res != 1) {
+ trigger_error('Registration Class Insert failed');
+ return false;
+ }
+
+ // If there's a new classID, declare success
+ $classID = $this->wpdb->insert_id;
+ if ($classID) {
+ return $classID;
+ }
+
+ }
+
break;
case 'get':
case 'update':
- // If we have a numeric class (level) ID
+ // We must have a numeric class (level) ID
$classID = ($modelData['id'] - 0);
if ($classID > 0) {
-- 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. If false then guest request (prior to checkout)
+ account INT NULL, -- Pointer to user account (reg_account) who submitted the registrations. If 0 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() - Serialized array
bill_fname TINYTEXT NULL, -- Billing information used for this registration submission - Updates account billing address - Kept here for each request