From b735e90a3c1ed50ad54e1d911d6ab97031c3c9bc Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Mon, 23 Oct 2017 14:43:34 -0400 Subject: [PATCH] Now saving the data for reg_request_rate data for base rate and per registrant. --- js/frontRegApp.js | 33 +++++++++++++-------- js/views/front/app.js | 6 ++-- js/views/front/regClass.js | 23 ++++++++------ js/views/front/regEvent.js | 4 +++ models/front/registrations/registration.php | 8 +++-- views/front/registrations/registration.html | 20 ++++++++----- 6 files changed, 59 insertions(+), 35 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 14815fd..6b23c4f 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -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({ diff --git a/js/views/front/app.js b/js/views/front/app.js index f6ad6d6..005dc60 100644 --- a/js/views/front/app.js +++ b/js/views/front/app.js @@ -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; }, diff --git a/js/views/front/regClass.js b/js/views/front/regClass.js index 885ae93..df8e560 100644 --- a/js/views/front/regClass.js +++ b/js/views/front/regClass.js @@ -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!' ); diff --git a/js/views/front/regEvent.js b/js/views/front/regEvent.js index 7d180e6..12e32af 100644 --- a/js/views/front/regEvent.js +++ b/js/views/front/regEvent.js @@ -23,4 +23,8 @@ app.Views.Front.RegEvent = Backbone.View.extend({ return this; }, + getClassCount: function(){ + return this.model.classes.length; + }, + }); diff --git a/models/front/registrations/registration.php b/models/front/registrations/registration.php index caaf630..4c8989e 100644 --- a/models/front/registrations/registration.php +++ b/models/front/registrations/registration.php @@ -188,9 +188,9 @@ // 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']; @@ -199,11 +199,13 @@ $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 '
$regEvent: ' . print_r( $regEvent, true ) . '
'; + echo '
$regEvent: ' . print_r( $regEvent, true ) . '
'; // Build the regClass JSON for the template. $regClassJSON = '[' . implode( ',', $jsonClasses ) . ']'; diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index d3d766c..47b5b72 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -62,15 +62,19 @@

<%= descr %>

- <% if ( !time_specific ) { %> -

Attend any time during event

- <% _.each(reg_time, function(rTime){ %> - <% if ( rTime.attendee_max > 0 ) { %> -

Maximum Registrants: <%= rTime.attendee_max %>
- Currently Available: <%= rTime.attendees_available %>

- <% } %> - <% }); %> + <% if ( this.getClassCount() == 0 ) { %> +

Registrations for this event not currently available at this time.

<% } else { %> + <% if ( !time_specific ) { %> +

Attend any time during event

+ <% _.each(reg_time, function(rTime){ %> + <% if ( rTime.attendee_max > 0 ) { %> +

Maximum Registrants: <%= rTime.attendee_max %>
+ Currently Available: <%= rTime.attendees_available %>

+ <% } %> + <% }); %> + <% } else { %> + <% } %> <% } %>

<%= terms %>

-- 2.17.1