Now saving the data for reg_request_rate
authorSteve Sutton <steve@gaslightmedia.com>
Mon, 23 Oct 2017 18:43:34 +0000 (14:43 -0400)
committerSteve Sutton <steve@gaslightmedia.com>
Mon, 23 Oct 2017 18:43:34 +0000 (14:43 -0400)
data for base rate and per registrant.

js/frontRegApp.js
js/views/front/app.js
js/views/front/regClass.js
js/views/front/regEvent.js
models/front/registrations/registration.php
views/front/registrations/registration.html

index 14815fd..6b23c4f 100644 (file)
@@ -379,9 +379,9 @@ app.Views.Front.App = Backbone.View.extend({
 
     render: function(){
         // Check to see if there's a login
-        if ( loginAccount ) {
-            jQuery('#register').hide();
-        }
+        // if ( loginAccount ) {
+        //     jQuery('#register').hide();
+        // }
         this.$el.append( this.event.render().el );
         return this;
     },
@@ -415,6 +415,14 @@ app.Views.Front.RegClass = Backbone.View.extend({
         return this;
     },
 
+    events: {
+        'click .addRegistrant': 'newEntry',
+        'click .glm-add-account': 'addAccount',
+        'click .glm-add-new-account': 'addNewAccount',
+        'click .add-new-registrant': 'addNew',
+        'click .add-new-registrant-cancel': 'cancelAddNew',
+    },
+
     render: function(){
         this.model.set({ reg_count: this.model.registrants.length });
         this.$el.html( this.template( this.model.toJSON() ) );
@@ -465,14 +473,6 @@ app.Views.Front.RegClass = Backbone.View.extend({
         this.render();
     },
 
-    events: {
-        'click .addRegistrant': 'newEntry',
-        'click .glm-add-account': 'addAccount',
-        'click .glm-add-new-account': 'addNewAccount',
-        'click .add-new-registrant': 'addNew',
-        'click .add-new-registrant-cancel': 'cancelAddNew',
-    },
-
     addAccount: function(){
         // Check to make sure the loginAccount is not empty
         if ( loginAccount !== '' ) {
@@ -528,7 +528,12 @@ app.Views.Front.RegClass = Backbone.View.extend({
                 }
             } );
         } else {
-            var rTime = null;
+            var rTime  = null;
+            var times  = this.model.get( 'times' );
+            var rateId = null;
+            _.each( times, function( time ){
+                rateId = time.rate_id;
+            } );
         }
         if ( app.timeSpecific && !rTime ) {
             alert( 'You must select a time!' );
@@ -690,6 +695,10 @@ app.Views.Front.RegEvent = Backbone.View.extend({
         return this;
     },
 
+    getClassCount: function(){
+        return this.model.classes.length;
+    },
+
 });
 
 app.Views.Front.RegRequestRegistrant = Backbone.View.extend({
index f6ad6d6..005dc60 100644 (file)
@@ -16,9 +16,9 @@ app.Views.Front.App = Backbone.View.extend({
 
     render: function(){
         // Check to see if there's a login
-        if ( loginAccount ) {
-            jQuery('#register').hide();
-        }
+        // if ( loginAccount ) {
+        //     jQuery('#register').hide();
+        // }
         this.$el.append( this.event.render().el );
         return this;
     },
index 885ae93..df8e560 100644 (file)
@@ -17,6 +17,14 @@ app.Views.Front.RegClass = Backbone.View.extend({
         return this;
     },
 
+    events: {
+        'click .addRegistrant': 'newEntry',
+        'click .glm-add-account': 'addAccount',
+        'click .glm-add-new-account': 'addNewAccount',
+        'click .add-new-registrant': 'addNew',
+        'click .add-new-registrant-cancel': 'cancelAddNew',
+    },
+
     render: function(){
         this.model.set({ reg_count: this.model.registrants.length });
         this.$el.html( this.template( this.model.toJSON() ) );
@@ -67,14 +75,6 @@ app.Views.Front.RegClass = Backbone.View.extend({
         this.render();
     },
 
-    events: {
-        'click .addRegistrant': 'newEntry',
-        'click .glm-add-account': 'addAccount',
-        'click .glm-add-new-account': 'addNewAccount',
-        'click .add-new-registrant': 'addNew',
-        'click .add-new-registrant-cancel': 'cancelAddNew',
-    },
-
     addAccount: function(){
         // Check to make sure the loginAccount is not empty
         if ( loginAccount !== '' ) {
@@ -130,7 +130,12 @@ app.Views.Front.RegClass = Backbone.View.extend({
                 }
             } );
         } else {
-            var rTime = null;
+            var rTime  = null;
+            var times  = this.model.get( 'times' );
+            var rateId = null;
+            _.each( times, function( time ){
+                rateId = time.rate_id;
+            } );
         }
         if ( app.timeSpecific && !rTime ) {
             alert( 'You must select a time!' );
index 7d180e6..12e32af 100644 (file)
@@ -23,4 +23,8 @@ app.Views.Front.RegEvent = Backbone.View.extend({
         return this;
     },
 
+    getClassCount: function(){
+        return this.model.classes.length;
+    },
+
 });
index caaf630..4c8989e 100644 (file)
             // If the event is Time Specific then the reg_class need to have
             // times array. If it doesn't then there's no current registration
             // allowed for that event.
-            foreach ( $regEvent['reg_class'] as $rClass ) {
+            foreach ( $regEvent['reg_class'] as $key => $rClass ) {
                 // Pull the rate data
-                if ( isset( $rClass['times'] ) && is_array( $rClass['times'] ) ) {
+                if ( isset( $rClass['times'] ) && is_array( $rClass['times'] ) && count( $rClass['times'] ) > 0 ) {
                     foreach ( $rClass['times'] as &$time ) {
                         $rClass['loggedIn']            = ( isset($_SESSION['LoginAccount']) ) ? true : false;
                         $rClass['reg_rate_id']         = $time['id'];
                         $rClass['reg_rate_per_reg']    = $time['per_registrant'];
                     }
                     $jsonClasses[] = json_encode( $rClass, JSON_NUMERIC_CHECK );
+                } else if ( !isset( $rClass['times'] ) || empty( $rClass['times'] ) ) {
+                    unset( $regEvent['reg_class'][$key] );
                 }
             }
         }
 
-        // echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
+        echo '<pre>$regEvent: ' . print_r( $regEvent, true ) . '</pre>';
 
         // Build the regClass JSON for the template.
         $regClassJSON = '[' . implode( ',', $jsonClasses ) . ']';
index d3d766c..47b5b72 100644 (file)
     </div>
     <div>
         <p><%= descr %></p>
-        <% if ( !time_specific ) { %>
-            <p>Attend any time during event</p>
-            <% _.each(reg_time, function(rTime){ %>
-                <% if ( rTime.attendee_max > 0 ) { %>
-            <p> Maximum Registrants: <%= rTime.attendee_max %><br>
-                Currently Available: <%= rTime.attendees_available %> </p>
-                <% } %>
-            <% }); %>
+        <% if ( this.getClassCount() == 0 ) { %>
+            <p> Registrations for this event not currently available at this time. </p>
         <% } else { %>
+            <% if ( !time_specific ) { %>
+                <p>Attend any time during event</p>
+                <% _.each(reg_time, function(rTime){ %>
+                    <% if ( rTime.attendee_max > 0 ) { %>
+                <p> Maximum Registrants: <%= rTime.attendee_max %><br>
+                    Currently Available: <%= rTime.attendees_available %> </p>
+                    <% } %>
+                <% }); %>
+            <% } else { %>
+            <% } %>
         <% } %>
 
         <p><%= terms %></p>