Now have Rates inserting into the database but not showing up when page is reloaded.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 21 Sep 2017 00:21:02 +0000 (20:21 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 21 Sep 2017 00:21:02 +0000 (20:21 -0400)
js/adminRegApp.js
js/models/admin/regRate.js
js/views/admin/regClass.js
js/views/admin/regEvent.js
js/views/admin/regRate.js
models/admin/ajax/regAdmin.php
models/admin/ajax/regAdmin/regClasses.php
models/admin/ajax/regAdmin/regRates.php [new file with mode: 0644]
setup/databaseScripts/create_database_V0.0.12.sql
views/admin/registrations/eventEditLevels.html

index 399e75d..546b8eb 100644 (file)
@@ -57,7 +57,7 @@ app.Models.Admin.RegRate = Backbone.Model.extend({
     defaults: {
         id: null,
         reg_event: 0,
-        reg_class: '',
+        reg_class: 0,
         name: '',
         start_days: 0,
         end_days: 0,
@@ -128,15 +128,16 @@ app.Views.Admin.RegClass = Backbone.View.extend({
     },
 
     events: {
-        'click .class-edit':           'editLevel',
+        'click .class-edit':           'edit',
         'click .class-update':         'update',
         'click .class-add':            'add',
         'click .class-cancel':         'cancel',
-        'click .class-delete-level':   'deleteLevel',
+        'click .class-delete':         'delete',
         'click .class-add-rate':       'addRate'
     },
 
     add: function(){
+        
         console.log('add called');
 
         // Get data from form
@@ -149,24 +150,23 @@ app.Views.Admin.RegClass = Backbone.View.extend({
             return;
         }
         
-        // ???
         this.model.set({ name: cName, descr: cDescr });
 
         // Get parent for id to send to backend for new class
         var parentEvent = this.model.get( 'parent' );
-
+        
         // Try to save the registration class
         var newID = false;
         myself = this;
         this.model.save({ 
             wait: true,
             option: 'add', 
-            parent: parentEvent.id, 
+            event: parentEvent.id, 
             name: cName, 
             descr: cDescr 
         }).success(function(data){
             if (data > 0) {
-                console.log('AJAX Save Successful: ID = '+data);
+                console.log('AJAX Class Save Successful: ID = '+data);
                 myself.model.set({id: data});
                 myself.$('.class-display-template').show();
                 myself.$('.class-edit-template').hide();
@@ -175,24 +175,20 @@ app.Views.Admin.RegClass = Backbone.View.extend({
                 myself.$('.class-edit').show();
                 myself.newClass = false;
             } else {
-                alert('Unable to store data at this time.');
+                alert('Unable to store class ata at this time.');
             }
-        }).error(function(m,e){
+        }).error(function(m, e){
            console.log(e);
            alert('There was a problem communicating with the AJAX server.');
         });
 
         console.log('New ID = '+newID);
-
-        // Add this new model to the collection.
-        var parentEvent = this.model.get( 'parent' );           // ????????
-//        parentEvent.classes.create( this.model );
         
         glmSubmitRequired -= 1; 
 
     },
 
-    deleteLevel: function(){
+    delete: function(){
         console.log('deleteLevel called');
         
         // Remove class here
@@ -210,8 +206,8 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         this.remove();
     },
 
-    editLevel: function(){
-        console.log('editLevel called');
+    edit: function(){
+        console.log('edit called');
         this.$('.class-display-template').hide();
         this.$('.class-edit-template').show();
         this.$('.class-update').show();
@@ -225,9 +221,9 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         var cName  = this.$('.class-name').val().trim();
         var cDescr = this.$('.class-descr').val().trim();
         if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
-            console.log('AJAX Save Error');
+            console.log('Class Save Error');
         } else {
-            console.log('AJAX Save Successful');
+            console.log('Class Save Successful');
         }
         this.$('.class-display-template').show();
         this.$('.class-edit-template').hide();
@@ -236,6 +232,31 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         glmSubmitRequired -= 1;  
     },
 
+    addRate: function(){
+
+        console.log( 'addRate Called');
+
+        var reg_event = this.model.get('reg_event');
+        var reg_class = this.model.get('id');
+
+        var regRate = new app.Models.Admin.RegRate({ 
+            glmAction: 'regRate', 
+            parent: this.model,
+            reg_event: reg_event,
+            reg_class: reg_class
+        });
+        var view = new app.Views.Admin.RegRate({ 
+            model: regRate,
+        });
+        this.$el.append(view.render(true).el);
+
+        // Place rates inside the class-rate-container of the parent class
+        var rateContainer = this.$('.class-rate-container');        
+        rateContainer.append(view.render(true).el);
+        
+
+    },
+    
     render: function(addFlag){
         this.$el.html( this.template( this.model.toJSON() ) );
         // If addFlag set then we know the call to this is to add a class and not to initialize existing classes
@@ -253,29 +274,6 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         return this;
     },
 
-    addOne: function( item ){
-        console.log('addOne called');
-        if ( item.isValid() ) {
-            var view = new app.Views.Admin.RegClasses({ model: item });
-            this.$el.append( view.render().el );
-        }
-    },
-
-    addAll: function(){
-        console.log('addAll called');
-        jQuery('.glm-reg-level').html('');
-    },
-    
-    addRate: function(){
-        console.log( 'addRate Called');
-        var regRate = new app.Models.Admin.RegRate({ parent: this.model });
-        //this.model.classes.add( regClass );
-        var view = new app.Views.Admin.RegRate({ model: regRate });
-        // Place rates inside the class-rate-container of the parent class
-        var rateContainer = this.$('.class-rate-container');        
-        rateContainer.append(view.render(true).el);
-    }
-
 });
 
 // js/views/adminRegEvent.js
@@ -302,12 +300,17 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
     },
 
     addLevel: function(){
+        
         console.log( 'addLevel Called' );
-        // create a new view and model and add it to classes and call render.
-        // Create the model for the view and add it to the collection
-        var regClass = new app.Models.Admin.RegClass({ glmAction: 'regClass', parent: this.model });
-        //this.model.classes.add( regClass );
-        var view = new app.Views.Admin.RegClass({ model: regClass });
+        
+        var regClass = new app.Models.Admin.RegClass({ 
+            glmAction: 'regClass', 
+            parent: this.model 
+        });
+        
+        var view = new app.Views.Admin.RegClass({ 
+            model: regClass 
+        });
         this.$el.append(view.render(true).el);
     },
 
@@ -322,7 +325,7 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
 
 });
 
-// js/views/regClass.js
+// js/views/regRate.js
 
 app.Views.Admin.RegRate = Backbone.View.extend({
     tagName: 'div',
@@ -339,54 +342,92 @@ app.Views.Admin.RegRate = Backbone.View.extend({
     events: {
         'click .rate-edit':       'edit',
         'click .rate-update':     'update',
-        'click .rate-add':     'add',
+        'click .rate-add':        'add',
         'click .rate-cancel':     'cancel',
-        'click .rate-delete':     'deleteRate'
+        'click .rate-delete':     'delete'
+    },
+
+    
+    add: function(){
+        
+        console.log('add called');
+        
+        var cName  = this.$('.rate-name').val().trim();
+
+        // Check for required data
+        if (cName == '') {
+            alert('The Level Name is Required!');
+            return;
+        }
+        
+        this.model.set({ name: cName });
+        
+        // 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;
+        this.model.save({ 
+            wait: true,
+            option: 'add', 
+            name: cName
+        }).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-add').hide();
+                myself.newRate = false;
+            } else {
+                alert('Unable to store rate data at this time.');
+            }
+        }).error(function(m, e){
+           console.log(e);
+           alert('There was a problem communicating with the AJAX server.');
+        });
+        
+        console.log('New ID = '+newID);
+        
+        glmSubmitRequired -= 1; 
+
     },
 
+    delete: function() {
+        console.log('deleteRate called');
+        
+        // Remove rate here
+        var x = this.model.get('id');
+        this.model.destroy({data: { 
+            id: x,
+            option: 'delete'
+        }, processData: true});
+
+        this.remove();
+    },
+    
     edit: function() {
         console.log('edit called');
         this.$('.rate-display-template').hide();
         this.$('.rate-edit-template').show();
         this.$('.rate-name').focus();
-//        glmSubmitRequired++;
+        glmSubmitRequired += 1;
     },
     
     update: function() {
         console.log('update called');
         var cName  = this.$('.rate-name').val().trim();
-//        this.model.save({ name: cName });
-        this.$('.rate-display-template').show();
-        this.$('.rate-edit-template').hide();
-//        glmSubmitRequired--;        
-
-    },
-    
-    cancel: function() {
-        console.log('cancel called');
-        this.remove();
-    },
-    
-    add: function(){
-        console.log('add called');
+        if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
+            console.log('Rate Save Error');
+        } else {
+            console.log('Rate Save Successful');
+        }
         this.$('.rate-display-template').show();
         this.$('.rate-edit-template').hide();
-        this.$('.rate-update').hide();
-        this.$('.rate-add').hide();
-        var cName  = this.$('.rate-name').val().trim();
-        this.model.set({ name: cName });
-        // Add this new model to the collection.
-        var parentRate = this.model.get( 'parent' );           // ????????
-//        parentRate.classes.create( this.model );
-    },
+        glmSubmitRequired -= 1;        
 
-    deleteRate: function() {
-        console.log('deleteRate called');
-        if (this.newRate) {
-console.log('Removing a new rate. May have to avoid doing any ajax call if not updated yet.')
-        }
-        this.remove();
-console.log('Need to check that this is actually removing from database..');
     },
     
     render: function(addFlag){
@@ -400,9 +441,9 @@ console.log('Need to check that this is actually removing from database..');
             this.$('.rate-add').show();
             this.$('.rate-name').focus();
             this.newRate = true;
-//            glmSubmitRequired++;
+            glmSubmitRequired += 1;
         }
         return this;
     }
-
+    
 });
index 2fe44e1..231fcff 100644 (file)
@@ -8,7 +8,7 @@ app.Models.Admin.RegRate = Backbone.Model.extend({
     defaults: {
         id: null,
         reg_event: 0,
-        reg_class: '',
+        reg_class: 0,
         name: '',
         start_days: 0,
         end_days: 0,
index b57e4ad..8feeab4 100644 (file)
@@ -13,15 +13,16 @@ app.Views.Admin.RegClass = Backbone.View.extend({
     },
 
     events: {
-        'click .class-edit':           'editLevel',
+        'click .class-edit':           'edit',
         'click .class-update':         'update',
         'click .class-add':            'add',
         'click .class-cancel':         'cancel',
-        'click .class-delete-level':   'deleteLevel',
+        'click .class-delete':         'delete',
         'click .class-add-rate':       'addRate'
     },
 
     add: function(){
+        
         console.log('add called');
 
         // Get data from form
@@ -34,24 +35,23 @@ app.Views.Admin.RegClass = Backbone.View.extend({
             return;
         }
         
-        // ???
         this.model.set({ name: cName, descr: cDescr });
 
         // Get parent for id to send to backend for new class
         var parentEvent = this.model.get( 'parent' );
-
+        
         // Try to save the registration class
         var newID = false;
         myself = this;
         this.model.save({ 
             wait: true,
             option: 'add', 
-            parent: parentEvent.id, 
+            event: parentEvent.id, 
             name: cName, 
             descr: cDescr 
         }).success(function(data){
             if (data > 0) {
-                console.log('AJAX Save Successful: ID = '+data);
+                console.log('AJAX Class Save Successful: ID = '+data);
                 myself.model.set({id: data});
                 myself.$('.class-display-template').show();
                 myself.$('.class-edit-template').hide();
@@ -60,24 +60,20 @@ app.Views.Admin.RegClass = Backbone.View.extend({
                 myself.$('.class-edit').show();
                 myself.newClass = false;
             } else {
-                alert('Unable to store data at this time.');
+                alert('Unable to store class ata at this time.');
             }
-        }).error(function(m,e){
+        }).error(function(m, e){
            console.log(e);
            alert('There was a problem communicating with the AJAX server.');
         });
 
         console.log('New ID = '+newID);
-
-        // Add this new model to the collection.
-        var parentEvent = this.model.get( 'parent' );           // ????????
-//        parentEvent.classes.create( this.model );
         
         glmSubmitRequired -= 1; 
 
     },
 
-    deleteLevel: function(){
+    delete: function(){
         console.log('deleteLevel called');
         
         // Remove class here
@@ -95,8 +91,8 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         this.remove();
     },
 
-    editLevel: function(){
-        console.log('editLevel called');
+    edit: function(){
+        console.log('edit called');
         this.$('.class-display-template').hide();
         this.$('.class-edit-template').show();
         this.$('.class-update').show();
@@ -110,9 +106,9 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         var cName  = this.$('.class-name').val().trim();
         var cDescr = this.$('.class-descr').val().trim();
         if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
-            console.log('AJAX Save Error');
+            console.log('Class Save Error');
         } else {
-            console.log('AJAX Save Successful');
+            console.log('Class Save Successful');
         }
         this.$('.class-display-template').show();
         this.$('.class-edit-template').hide();
@@ -121,6 +117,31 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         glmSubmitRequired -= 1;  
     },
 
+    addRate: function(){
+
+        console.log( 'addRate Called');
+
+        var reg_event = this.model.get('reg_event');
+        var reg_class = this.model.get('id');
+
+        var regRate = new app.Models.Admin.RegRate({ 
+            glmAction: 'regRate', 
+            parent: this.model,
+            reg_event: reg_event,
+            reg_class: reg_class
+        });
+        var view = new app.Views.Admin.RegRate({ 
+            model: regRate,
+        });
+        this.$el.append(view.render(true).el);
+
+        // Place rates inside the class-rate-container of the parent class
+        var rateContainer = this.$('.class-rate-container');        
+        rateContainer.append(view.render(true).el);
+        
+
+    },
+    
     render: function(addFlag){
         this.$el.html( this.template( this.model.toJSON() ) );
         // If addFlag set then we know the call to this is to add a class and not to initialize existing classes
@@ -138,27 +159,4 @@ app.Views.Admin.RegClass = Backbone.View.extend({
         return this;
     },
 
-    addOne: function( item ){
-        console.log('addOne called');
-        if ( item.isValid() ) {
-            var view = new app.Views.Admin.RegClasses({ model: item });
-            this.$el.append( view.render().el );
-        }
-    },
-
-    addAll: function(){
-        console.log('addAll called');
-        jQuery('.glm-reg-level').html('');
-    },
-    
-    addRate: function(){
-        console.log( 'addRate Called');
-        var regRate = new app.Models.Admin.RegRate({ parent: this.model });
-        //this.model.classes.add( regClass );
-        var view = new app.Views.Admin.RegRate({ model: regRate });
-        // Place rates inside the class-rate-container of the parent class
-        var rateContainer = this.$('.class-rate-container');        
-        rateContainer.append(view.render(true).el);
-    }
-
 });
index 4e9ceee..0c24fd4 100644 (file)
@@ -22,12 +22,17 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
     },
 
     addLevel: function(){
+        
         console.log( 'addLevel Called' );
-        // create a new view and model and add it to classes and call render.
-        // Create the model for the view and add it to the collection
-        var regClass = new app.Models.Admin.RegClass({ glmAction: 'regClass', parent: this.model });
-        //this.model.classes.add( regClass );
-        var view = new app.Views.Admin.RegClass({ model: regClass });
+        
+        var regClass = new app.Models.Admin.RegClass({ 
+            glmAction: 'regClass', 
+            parent: this.model 
+        });
+        
+        var view = new app.Views.Admin.RegClass({ 
+            model: regClass 
+        });
         this.$el.append(view.render(true).el);
     },
 
index 4af9870..c2635ec 100644 (file)
@@ -1,4 +1,4 @@
-// js/views/regClass.js
+// js/views/regRate.js
 
 app.Views.Admin.RegRate = Backbone.View.extend({
     tagName: 'div',
@@ -15,54 +15,92 @@ app.Views.Admin.RegRate = Backbone.View.extend({
     events: {
         'click .rate-edit':       'edit',
         'click .rate-update':     'update',
-        'click .rate-add':     'add',
+        'click .rate-add':        'add',
         'click .rate-cancel':     'cancel',
-        'click .rate-delete':     'deleteRate'
+        'click .rate-delete':     'delete'
     },
 
+    
+    add: function(){
+        
+        console.log('add called');
+        
+        var cName  = this.$('.rate-name').val().trim();
+
+        // Check for required data
+        if (cName == '') {
+            alert('The Level Name is Required!');
+            return;
+        }
+        
+        this.model.set({ name: cName });
+        
+        // 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;
+        this.model.save({ 
+            wait: true,
+            option: 'add', 
+            name: cName
+        }).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-add').hide();
+                myself.newRate = false;
+            } else {
+                alert('Unable to store rate data at this time.');
+            }
+        }).error(function(m, e){
+           console.log(e);
+           alert('There was a problem communicating with the AJAX server.');
+        });
+        
+        console.log('New ID = '+newID);
+        
+        glmSubmitRequired -= 1; 
+
+    },
+
+    delete: function() {
+        console.log('deleteRate called');
+        
+        // Remove rate here
+        var x = this.model.get('id');
+        this.model.destroy({data: { 
+            id: x,
+            option: 'delete'
+        }, processData: true});
+
+        this.remove();
+    },
+    
     edit: function() {
         console.log('edit called');
         this.$('.rate-display-template').hide();
         this.$('.rate-edit-template').show();
         this.$('.rate-name').focus();
-//        glmSubmitRequired++;
+        glmSubmitRequired += 1;
     },
     
     update: function() {
         console.log('update called');
         var cName  = this.$('.rate-name').val().trim();
-//        this.model.save({ name: cName });
-        this.$('.rate-display-template').show();
-        this.$('.rate-edit-template').hide();
-//        glmSubmitRequired--;        
-
-    },
-    
-    cancel: function() {
-        console.log('cancel called');
-        this.remove();
-    },
-    
-    add: function(){
-        console.log('add called');
+        if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
+            console.log('Rate Save Error');
+        } else {
+            console.log('Rate Save Successful');
+        }
         this.$('.rate-display-template').show();
         this.$('.rate-edit-template').hide();
-        this.$('.rate-update').hide();
-        this.$('.rate-add').hide();
-        var cName  = this.$('.rate-name').val().trim();
-        this.model.set({ name: cName });
-        // Add this new model to the collection.
-        var parentRate = this.model.get( 'parent' );           // ????????
-//        parentRate.classes.create( this.model );
-    },
+        glmSubmitRequired -= 1;        
 
-    deleteRate: function() {
-        console.log('deleteRate called');
-        if (this.newRate) {
-console.log('Removing a new rate. May have to avoid doing any ajax call if not updated yet.')
-        }
-        this.remove();
-console.log('Need to check that this is actually removing from database..');
     },
     
     render: function(addFlag){
@@ -76,9 +114,9 @@ console.log('Need to check that this is actually removing from database..');
             this.$('.rate-add').show();
             this.$('.rate-name').focus();
             this.newRate = true;
-//            glmSubmitRequired++;
+            glmSubmitRequired += 1;
         }
         return this;
     }
-
+    
 });
index 460a02f..0a2b06a 100644 (file)
@@ -70,7 +70,7 @@ class GlmMembersAdmin_ajax_regAdmin
      */
     public function modelAction( $actionData = false )
     {
-        
         // Get Backbone collection we're talking with
         $collection = filter_var( $_REQUEST['collection'], FILTER_SANITIZE_STRING );
    
index 90fc203..5a7c43f 100644 (file)
@@ -95,7 +95,7 @@ class GlmMembersAdmin_registrations_ajax_regClasses extends GlmDataRegistrations
                     $res = $this->wpdb->insert(
                         $this->table,
                         array(
-                            'reg_event' => $modelData['parent'],
+                            'reg_event' => $modelData['event'],
                             'name'  => $modelData['name'],
                             'descr' => $modelData['descr']
                         ),
@@ -117,7 +117,7 @@ class GlmMembersAdmin_registrations_ajax_regClasses extends GlmDataRegistrations
                         echo json_encode($classID);
                         wp_die();
                     } else {
-                        echo json_encode(false);
+                        echo json_encode(0);
                         wp_die();
                     }
                     
diff --git a/models/admin/ajax/regAdmin/regRates.php b/models/admin/ajax/regAdmin/regRates.php
new file mode 100644 (file)
index 0000000..9e77aac
--- /dev/null
@@ -0,0 +1,176 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Registrations AJAX processing for Rates
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  regRates.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+// Load Registrations data abstract
+require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRate.php';
+
+class GlmMembersAdmin_registrations_ajax_regRates extends GlmDataRegistrationsRegRate
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+
+    /**
+     * Constructor
+     *
+     * This contructor performs the work for this model. This model returns
+     * an array containing the following.
+     *
+     * 'status'
+     *
+     * True if successfull and false if there was a fatal failure.
+     *
+     * 'view'
+     *
+     * A suggested view name that the contoller should use instead of the
+     * default view for this model or false to indicate that the default view
+     * should be used.
+     *
+     * 'data'
+     *
+     * Data that the model is returning for use in merging with the view to
+     * produce output.
+     *
+     * @wpdb object 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($modelData)
+    {
+
+        // 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 rate (level) data
+                    $res = $this->wpdb->insert(
+                        $this->table,
+                        array(
+                            'reg_event' => $modelData['reg_event'],
+                            'reg_class' => $modelData['reg_class'],
+                            'name'  => $modelData['name']
+                        ),
+                        array(
+                            '%d',
+                            '%d',
+                            '%s'
+                        )
+                    );
+                    
+                    if ($res != 1) {
+                        trigger_error('Registration Rate Insert failed');
+                        return false;
+                    }
+                    
+                    // If there's a new rateID, declare success
+                    $rateID = $this->wpdb->insert_id;
+                    if ($rateID) {
+                        echo json_encode($rateID);
+                        wp_die();
+                    } else {
+                        echo json_encode(0);
+                        wp_die();
+                    }
+                    
+                }
+                
+                break;
+                
+            case 'get':
+                break;
+                
+            case 'update':
+                
+                // We must have a numeric class (level) ID
+                $rateID = ($modelData['id'] - 0);
+                if ($rateID > 0) {
+
+                    // Try to update the class (level) data
+                    $this->wpdb->update(
+                        $this->table,
+                        array(
+                            'name'  => $modelData['name']
+                        ),
+                        array('id' => $rateID),
+                        array(
+                            '%s'
+                        ),
+                        array( '%d' )
+                    );
+                    
+                }
+                
+                break;
+                
+            case 'delete':
+                
+                $rateID = ($modelData['id'] - 0);
+                if ($rateID > 0) {
+                    $this->wpdb->delete( $this->table, array( 'id' => $rateID ), array( '%d' ) );
+                }
+                
+                return;
+                
+                break;
+                
+            default:
+                die();  // should never get here
+                break;
+                
+        }
+        
+        wp_die();
+        
+        
+        
+    }
+
+
+}
index ca19343..7cc969a 100644 (file)
@@ -603,10 +603,10 @@ CREATE TABLE {prefix}reg_request_rate (
 
 ----
 
---  A specific registrant for a selected registration rate
+--  A specific registrant for a selected registration rate - *** Need to remove the reg_request_registrant entry in this table ****
 CREATE TABLE {prefix}reg_request_registrant (
     id INT NOT NULL AUTO_INCREMENT,
-    account INT NULL,                                           -- Pointer to account for person submitting the registration
+    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
     reg_time INT NULL,                                          -- Pointer reg_time entry
@@ -615,7 +615,6 @@ CREATE TABLE {prefix}reg_request_registrant (
     reg_request_event INT NULL,                                 -- Pointer to reg_request_event table entry
     reg_request_class INT NULL,                                 -- Pointer to reg_request_class table entry
     reg_request_rate INT NULL,                                  -- Pointer to reg_request_rate table entry
-    reg_request_registrant INT NULL,                            -- Pointer to account for registrant (person attending) - False (0) if account no longer exists or registrant account not needed
     reg_request_hold BOOLEAN NULL,                              -- Registrant hold active - Registrant slots held certain time since last cart access - After this the slot needs to be updated if available 
     reg_request_hold_not_available BOOLEAN NULL,                -- No registrant slot available for this registrant - Unable to get hold
     fname TINYTEXT NULL,                                        -- First name of registrant at the time of selection
index 1158d35..ef54305 100644 (file)
@@ -41,7 +41,7 @@
                     <div class="glm-right">
                         <a class="class-edit button button-secondary glm-button-small">Edit</a>
                         <a class="class-add-rate button button-secondary glm-button-small">Add Reg Rate</a>
-                        <a class="class-delete-level button button-secondary glm-button-small">Delete Level</a>
+                        <a class="class-delete button button-secondary glm-button-small">Delete Level</a>
                     </div>
                     <div class="glm-class-label">
                         <h3><%= name %></h3>
@@ -54,8 +54,8 @@
                     <div class="glm-right">
                         <a class="class-update button glm-button-small-highlighted">Update</a>
                         <a class="class-add button glm-button-small-highlighted" style="display: none;">Add</a>
-                        <a class="class-add-rate button button-secondary glm-button-small">Add Reg Rate</a>
-                        <a class="class-delete-level button button-secondary glm-button-small">Delete Level</a>
+                        <a class="class-add-rate button button-secondary glm-button-small" style="display: none;">Add Reg Rate</a>
+                        <a class="class-delete button button-secondary glm-button-small">Delete Level</a>
                     </div>
                     <div class="glm-class-label" style="padding-bottom: .3em;">
                         <b>Level Name:</b> <input class="class-name" type="text" name="class_name_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (name) { %><%- name %><% } %>">