From: Steve Sutton Date: Wed, 16 May 2018 15:18:08 +0000 (-0400) Subject: Updating the front end to use the limit for attendee per reg. X-Git-Tag: v1.0.0^2~9 X-Git-Url: http://cvs2.gaslightmedia.com/gitweb/?a=commitdiff_plain;h=32d8b9c9b8bd6df4dbde9aa86043bf03b790c6c2;p=WP-Plugins%2Fglm-member-db-registrations.git Updating the front end to use the limit for attendee per reg. Using the attendee_max_per_reg. if not 0. --- diff --git a/js/frontRegApp.js b/js/frontRegApp.js index ac1067b..c7bc321 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -185,7 +185,7 @@ app.Models.Front.RegEvent = Backbone.Model.extend({ nRegTime.save(); // console.log(nRegTime); // console.log('total registrants: ' + nRegTime.registrants.length); - + app.attendeeCount++; } } @@ -887,6 +887,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // Need to release the lock if they want to delete the attendee app.regEventLock = false; + // Delete the count + app.attendeeCount--; + this.remove(); }, @@ -940,6 +943,10 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add new account addNewAccount: function(){ + if ( app.checkForMaxAttendees() === true ) { + alert( 'You\'re only allowed to have ' + app.attendeeMaxPerReg + ' ' + app.attendeePlurCapTerm + ' per Registration!' ); + return; + } // check for the lock if ( app.checkForEditLock() === true ) { return; @@ -996,12 +1003,12 @@ app.Views.Front.RegTime = Backbone.View.extend({ return; } if ( email === '' ) { - var confAnsw = confirm( 'You did not supply an Email address! Are you sure you want to add this registrant?' ); - if ( !confAnsw ) { - // Hide the loading graphic - this.$('#loading-' + this.model.get('id') ).hide(); - return; - } + // var confAnsw = confirm( 'You did not supply and Email address! Are you sure you want to add this registrant?' ); + // if ( !confAnsw ) { + // // Hide the loading graphic + // this.$('#loading-' + this.model.get('id') ).hide(); + // return; + // } } else { findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); if ( findByEmail.length > 0 ) { @@ -1046,6 +1053,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; + + // Add the count + app.attendeeCount++; }, successCallback: function( collection, repsonse ){ diff --git a/js/models/front/regEvent.js b/js/models/front/regEvent.js index e6d181d..ed7ec23 100644 --- a/js/models/front/regEvent.js +++ b/js/models/front/regEvent.js @@ -69,7 +69,7 @@ app.Models.Front.RegEvent = Backbone.Model.extend({ nRegTime.save(); // console.log(nRegTime); // console.log('total registrants: ' + nRegTime.registrants.length); - + app.attendeeCount++; } } diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index 296cbdf..bb13ba6 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -141,6 +141,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // Need to release the lock if they want to delete the attendee app.regEventLock = false; + // Delete the count + app.attendeeCount--; + this.remove(); }, diff --git a/js/views/front/regTime.js b/js/views/front/regTime.js index c4e9392..c10f18f 100644 --- a/js/views/front/regTime.js +++ b/js/views/front/regTime.js @@ -46,6 +46,10 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add new account addNewAccount: function(){ + if ( app.checkForMaxAttendees() === true ) { + alert( 'You\'re only allowed to have ' + app.attendeeMaxPerReg + ' ' + app.attendeePlurCapTerm + ' per Registration!' ); + return; + } // check for the lock if ( app.checkForEditLock() === true ) { return; @@ -102,12 +106,12 @@ app.Views.Front.RegTime = Backbone.View.extend({ return; } if ( email === '' ) { - var confAnsw = confirm( 'You did not supply and Email address! Are you sure you want to add this registrant?' ); - if ( !confAnsw ) { - // Hide the loading graphic - this.$('#loading-' + this.model.get('id') ).hide(); - return; - } + // var confAnsw = confirm( 'You did not supply and Email address! Are you sure you want to add this registrant?' ); + // if ( !confAnsw ) { + // // Hide the loading graphic + // this.$('#loading-' + this.model.get('id') ).hide(); + // return; + // } } else { findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); if ( findByEmail.length > 0 ) { @@ -152,6 +156,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; + + // Add the count + app.attendeeCount++; }, successCallback: function( collection, repsonse ){ diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 2cea7db..0c963c8 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -449,7 +449,7 @@ {$reg_bulletin} {/if} - + {if $settings.reg_not_submitted_dialog}

@@ -485,6 +485,21 @@ var app = { return regex.test(email); }, regEventLock: false, + attendeeCount: 0, + attendeeMaxPerReg: parseInt( {$regEvent.attendee_max_per_reg} ), + attendeePlurCapTerm: '{$terms.reg_term_attendee_plur_cap}', + checkForMaxAttendees: function(){ + if ( app.attendeeMaxPerReg ) { + // Here we need to see how many registrants total in each class. + if ( app.attendeeCount >= app.attendeeMaxPerReg ) { + return true; + } else { + return false; + } + } else { + return false; + } + }, checkForEditLock: function(){ if ( app.regEventLock === true ) { alert('Please complete your other edit first.'); @@ -661,7 +676,7 @@ jQuery(function($){ // Registration not submitted Dialog actions - {if $settings.reg_not_submitted_dialog} + {if $settings.reg_not_submitted_dialog} var notSubmittedTimer; notSubmittedDialog = $( "#regNotSubmittedDialog" ).dialog({ @@ -670,7 +685,7 @@ jQuery(function($){ open: function(event,ui) { clearInterval(notSubmittedTimer); }, - close: function(event,ui) { + close: function(event,ui) { resetNotSubmittedTimer(); }, buttons: [ @@ -703,7 +718,7 @@ jQuery(function($){ }); startNotSubmittedTimer(); - {/if} - + {/if} + });