Added menu, model, and view for reports. Nothing in there yet.
authorChuck Scott <cscott@gaslightmedia.com>
Thu, 21 Sep 2017 17:26:53 +0000 (13:26 -0400)
committerChuck Scott <cscott@gaslightmedia.com>
Thu, 21 Sep 2017 17:26:53 +0000 (13:26 -0400)
Have admin reg events levels and rates displaying, adding, editing, saving, and storing
Still some glitches in that page.

16 files changed:
js/adminRegApp.js
js/collections/admin/regRates.js
js/models/admin/regClass.js
js/models/admin/regEvent.js
js/views/admin/regClass.js
js/views/admin/regEvent.js
js/views/admin/regRate.js
models/admin/registrations/accounts.php
models/admin/registrations/events.php
models/admin/registrations/reports.php [new file with mode: 0644]
models/admin/registrations/requests.php
setup/adminMenus.php
setup/validActions.php
views/admin/registrations/eventEditLevels.html
views/admin/registrations/eventsDashboard.html
views/admin/registrations/reports.html [new file with mode: 0644]

index 546b8eb..bad5d8d 100644 (file)
@@ -15,7 +15,11 @@ app.Models.Admin.RegClass = Backbone.Model.extend({
         this.rates = new app.Collections.Admin.RegRates;
     },
 
-    url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses'
+    url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses',
+
+    setRates: function(regRates){
+        this.rates.set(regRates);
+    }
 
 });
 
@@ -42,7 +46,7 @@ app.Models.Admin.RegEvent = Backbone.Model.extend({
     },
 
     setClasses: function( regClasses ){
-        this.classes.reset( regClasses );
+        this.classes.set( regClasses );
     }
 
 });
@@ -87,8 +91,8 @@ app.Collections.Admin.RegClasses = Backbone.Collection.extend({
 app.Collections.Admin.RegRates = Backbone.Collection.extend({
     model: app.Models.Admin.RegRate,
     url: ajaxUrl+'&glm_action=regAdmin&collection=regRates'
-});
-
+}); 
 // js/views/app.js
 Backbone.emulateJSON = true;
 Backbone.emulateHTTP = true;
@@ -124,6 +128,9 @@ app.Views.Admin.RegClass = Backbone.View.extend({
 
     initialize: function(){
         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);
         return this;
     },
 
@@ -190,7 +197,11 @@ app.Views.Admin.RegClass = Backbone.View.extend({
 
     delete: function(){
         console.log('deleteLevel called');
-        
+    
+        if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
+            return false;
+        }
+
         // Remove class here
         var x = this.model.get('id');
         this.model.destroy({data: { 
@@ -259,6 +270,12 @@ app.Views.Admin.RegClass = Backbone.View.extend({
     
     render: function(addFlag){
         this.$el.html( this.template( this.model.toJSON() ) );
+        var rateView = this.model.rates.map(function(item){
+            return (new app.Views.Admin.RegRate({ model: item })).render().el;
+        });
+        var rateContainer = this.$('.class-rate-container');        
+        rateContainer.append(rateView);
+        
         // If addFlag set then we know the call to this is to add a class and not to initialize existing classes
         if (addFlag == true) {
             console.log('New level created');
@@ -297,9 +314,9 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
 
     events: {
         'click #class-add': 'addLevel',
-    },
+    }, 
 
-    addLevel: function(){
+    addLevel: function(){ 
         
         console.log( 'addLevel Called' );
         
@@ -313,7 +330,7 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
         });
         this.$el.append(view.render(true).el);
     },
-
     render: function(){
         this.$el.html( this.template( this.model.toJSON() ) );
         var view = regEvent.classes.map(function(item){
@@ -389,10 +406,9 @@ app.Views.Admin.RegRate = Backbone.View.extend({
            alert('There was a problem communicating with the AJAX server.');
         });
         
+        glmSubmitRequired -= 1; 
         console.log('New ID = '+newID);
         
-        glmSubmitRequired -= 1; 
-
     },
 
     delete: function() {
@@ -419,14 +435,14 @@ app.Views.Admin.RegRate = Backbone.View.extend({
     update: function() {
         console.log('update called');
         var cName  = this.$('.rate-name').val().trim();
-        if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
+        if (!this.model.save({ option: 'update', name: cName})) {
             console.log('Rate Save Error');
         } else {
             console.log('Rate Save Successful');
         }
         this.$('.rate-display-template').show();
         this.$('.rate-edit-template').hide();
-        glmSubmitRequired -= 1;        
+        glmSubmitRequired -= 1;       
 
     },
     
@@ -434,6 +450,7 @@ app.Views.Admin.RegRate = Backbone.View.extend({
         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
         if (addFlag) {
+            // Setup to edit this for the first time
             console.log('New rate created');
             this.$('.rate-display-template').hide();
             this.$('.rate-edit-template').show();
index ff3ac3e..dfdbc75 100644 (file)
@@ -4,4 +4,5 @@
 app.Collections.Admin.RegRates = Backbone.Collection.extend({
     model: app.Models.Admin.RegRate,
     url: ajaxUrl+'&glm_action=regAdmin&collection=regRates'
-});
+}); 
\ No newline at end of file
index de805f9..6102da8 100644 (file)
@@ -15,6 +15,10 @@ app.Models.Admin.RegClass = Backbone.Model.extend({
         this.rates = new app.Collections.Admin.RegRates;
     },
 
-    url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses'
+    url: ajaxUrl+'&glm_action=regAdmin&collection=regClasses',
+
+    setRates: function(regRates){
+        this.rates.set(regRates);
+    }
 
 });
index ae923d6..0d9ebff 100644 (file)
@@ -21,7 +21,7 @@ app.Models.Admin.RegEvent = Backbone.Model.extend({
     },
 
     setClasses: function( regClasses ){
-        this.classes.reset( regClasses );
+        this.classes.set( regClasses );
     }
 
 });
index 8feeab4..99c6ced 100644 (file)
@@ -9,6 +9,9 @@ app.Views.Admin.RegClass = Backbone.View.extend({
 
     initialize: function(){
         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);
         return this;
     },
 
@@ -75,7 +78,11 @@ app.Views.Admin.RegClass = Backbone.View.extend({
 
     delete: function(){
         console.log('deleteLevel called');
-        
+    
+        if (!confirm('Are you sure you want to delete this? ( *** need to check for rates *** )')) {
+            return false;
+        }
+
         // Remove class here
         var x = this.model.get('id');
         this.model.destroy({data: { 
@@ -144,6 +151,12 @@ app.Views.Admin.RegClass = Backbone.View.extend({
     
     render: function(addFlag){
         this.$el.html( this.template( this.model.toJSON() ) );
+        var rateView = this.model.rates.map(function(item){
+            return (new app.Views.Admin.RegRate({ model: item })).render().el;
+        });
+        var rateContainer = this.$('.class-rate-container');        
+        rateContainer.append(rateView);
+        
         // If addFlag set then we know the call to this is to add a class and not to initialize existing classes
         if (addFlag == true) {
             console.log('New level created');
index 0c24fd4..c6d4e0a 100644 (file)
@@ -19,9 +19,9 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
 
     events: {
         'click #class-add': 'addLevel',
-    },
+    }, 
 
-    addLevel: function(){
+    addLevel: function(){ 
         
         console.log( 'addLevel Called' );
         
@@ -35,7 +35,7 @@ app.Views.Admin.RegEvent = Backbone.View.extend({
         });
         this.$el.append(view.render(true).el);
     },
-
     render: function(){
         this.$el.html( this.template( this.model.toJSON() ) );
         var view = regEvent.classes.map(function(item){
index c2635ec..b4b3d14 100644 (file)
@@ -62,10 +62,9 @@ app.Views.Admin.RegRate = Backbone.View.extend({
            alert('There was a problem communicating with the AJAX server.');
         });
         
+        glmSubmitRequired -= 1; 
         console.log('New ID = '+newID);
         
-        glmSubmitRequired -= 1; 
-
     },
 
     delete: function() {
@@ -92,14 +91,14 @@ app.Views.Admin.RegRate = Backbone.View.extend({
     update: function() {
         console.log('update called');
         var cName  = this.$('.rate-name').val().trim();
-        if (!this.model.save({ option: 'update', name: cName, descr: cDescr })) {
+        if (!this.model.save({ option: 'update', name: cName})) {
             console.log('Rate Save Error');
         } else {
             console.log('Rate Save Successful');
         }
         this.$('.rate-display-template').show();
         this.$('.rate-edit-template').hide();
-        glmSubmitRequired -= 1;        
+        glmSubmitRequired -= 1;       
 
     },
     
@@ -107,6 +106,7 @@ app.Views.Admin.RegRate = Backbone.View.extend({
         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
         if (addFlag) {
+            // Setup to edit this for the first time
             console.log('New rate created');
             this.$('.rate-display-template').hide();
             this.$('.rate-edit-template').show();
index d7f4cc0..a479392 100644 (file)
@@ -193,7 +193,7 @@ class GlmMembersAdmin_registrations_accounts extends GlmDataRegistrationsAccount
             
             // Load registration request and registration registrant data classes
             require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
-            $RegRequest = new GlmDataRegistrationsRequest($this->wpdb, $this->config);
+            $RegRequest = new GlmDataRegistrationsRegRequest($this->wpdb, $this->config);
             require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequestRegistrant.php';
             $RegRequestRegistrant = new GlmDataRegistrationsRequestRegistrant($this->wpdb, $this->config);
             
index 9f5b22f..54ccd0f 100644 (file)
@@ -177,6 +177,7 @@ class GlmMembersAdmin_registrations_events extends GlmDataRegistrationsRegEvent
                 // 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']);
diff --git a/models/admin/registrations/reports.php b/models/admin/registrations/reports.php
new file mode 100644 (file)
index 0000000..b912ae9
--- /dev/null
@@ -0,0 +1,106 @@
+<?php
+/**
+ * Gaslight Media Members Database
+ * Admin Registrations Reports
+ *
+ * PHP version 5.5
+ *
+ * @category glmWordPressPlugin
+ * @package  glmMembersDatabase
+ * @author   Chuck Scott <cscott@gaslightmedia.com>
+ * @license  http://www.gaslightmedia.com Gaslightmedia
+ * @release  index.php,v 1.0 2014/10/31 19:31:47 cscott Exp $
+ * @link     http://dev.gaslightmedia.com/
+ */
+
+class GlmMembersAdmin_registrations_reports
+{
+
+    /**
+     * WordPress Database Object
+     *
+     * @var $wpdb
+     * @access public
+     */
+    public $wpdb;
+    /**
+     * Plugin Configuration Data
+     *
+     * @var $config
+     * @access public
+     */
+    public $config;
+    /**
+     * Registrations Event ID
+     *
+     * @var $eventID
+     * @access public
+     */
+    public $accountID = false;
+
+    /**
+     * 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($actionData = false)
+    {
+        $view               = 'reports';
+        $reason             = array();
+        
+        // Compile template data
+        $templateData = array(
+            'reason'             => $reason
+        );
+        
+        // Return status, any suggested view, and any data to controller
+        return array(
+            'status'        => true,
+            'modelRedirect' => false,
+            'view'          => 'admin/registrations/' . $view . '.html',
+            'data'          => $templateData
+        );
+
+    }
+
+
+}
index 9b510a1..3eb7b1c 100644 (file)
@@ -16,7 +16,7 @@
 // Load Registration Requests data abstract
 require_once GLM_MEMBERS_REGISTRATIONS_PLUGIN_CLASS_PATH.'/data/dataRegRequest.php';
 
-class GlmMembersAdmin_registrations_requests extends GlmDataRegistrationsRequest
+class GlmMembersAdmin_registrations_requests extends GlmDataRegistrationsRegRequest
 {
 
     /**
index 94955d1..f79fc0b 100644 (file)
@@ -83,3 +83,11 @@ add_submenu_page(
     'glm-members-admin-menu-registrations-accounts',
     function() {$this->controller('registrations', 'accounts');}
 );
+add_submenu_page(
+    'glm-members-admin-menu-members',
+    'Registration Reports',
+    '&nbsp;&nbsp;&nbsp;&nbsp;Reports',
+    'glm_members_members',
+    'glm-members-admin-menu-registrations-reports',
+    function() {$this->controller('registrations', 'reports');}
+    );
index 86d40d9..37e248e 100644 (file)
@@ -68,7 +68,8 @@ $glmMembersRegistrationsAddOnValidActions = array(
             'index'                     => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
             'events'                    => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
             'requests'                  => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
-            'accounts'                  => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG
+            'accounts'                  => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
+            'reports'                   => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG
         ),
         'management' => array(
             'registrations'             => GLM_MEMBERS_REGISTRATIONS_PLUGIN_SLUG,
index ef54305..05cbd52 100644 (file)
@@ -40,8 +40,8 @@
                 <div class="glm-class-header">
                     <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 button button-secondary glm-button-small">Delete Level</a>
+                        <a class="class-delete button button-secondary glm-button-small">Delete</a>
+                        <a class="class-add-rate button button-secondary glm-button-small">Add Rate</a>
                     </div>
                     <div class="glm-class-label">
                         <h3><%= name %></h3>
@@ -54,8 +54,6 @@
                     <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" 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 %><% } %>">
@@ -74,7 +72,7 @@
                         <a class="rate-edit button button-secondary glm-button-small">Edit</a>
                         <a class="rate-delete button button-secondary glm-button-small">Delete Rate</a>
                     </div>
-                    <div class="glm-rate-label">
+                    <div class="glm-rate-label" style="margin-bottom: .5em;">
                         <h3><%= name %></h3>
                     </div>
                 </div>
@@ -84,7 +82,6 @@
                     <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 Rate</a>
                     </div>
                     <div class="glm-rate-label" style="padding-bottom: .3em;">
                         <b>Rate Name:</b> <input class="rate-name" type="text" name="rate_name_<% if (id) { %><%- id %><% } else { %> new <% } %>" value="<% if (name) { %><%- name %><% } %>">
index 9156b7f..654b62f 100644 (file)
@@ -46,7 +46,7 @@
         <tbody>
 {if $haveRegEvents}
     {assign var="i" value="0"}
-    {foreach $regEvents as $r}z
+    {foreach $regEvents as $r}
         {if $i++ is odd by 1}
             <tr>
         {else}
diff --git a/views/admin/registrations/reports.html b/views/admin/registrations/reports.html
new file mode 100644 (file)
index 0000000..2ac61d1
--- /dev/null
@@ -0,0 +1,7 @@
+
+<h1>Reports</h1>
+
+<p>Move along now, nothing to see here.</p>
+
+{include file='admin/footer.html'}
+