From 76147d80a2038922a59b819f40d721d86d2cf21c Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 19 Dec 2017 13:06:20 -0500 Subject: [PATCH] Have attendees adding with same email. It will now create a new account if the email and names are different. Names are required fields and now are marked as being required. --- js/frontRegApp.js | 60 +++++++++++---------- js/views/front/regRequestRegistrant.js | 7 ++- js/views/front/regTime.js | 49 +++++++++-------- js/views/front/registrantForm.js | 4 +- models/admin/ajax/regFront/registrant.php | 11 ++-- views/front/registrations/registration.html | 58 +++++++++++--------- 6 files changed, 106 insertions(+), 83 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index 90130a0..8401f8c 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -894,10 +894,12 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // render the view render: function(){ + // Call the custom fields ajax + app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); + this.$el.html( this.template( this.model.toJSON() ) ); this.$emailInput = this.$('.editEmail'); this.$('.reg-edit-form').hide(); - app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); return this; }, @@ -910,6 +912,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ option: 'delete' }, processData: true}); + // Need to release the lock if they want to delete the attendee + app.regEventLock = false; + this.remove(); }, @@ -929,9 +934,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ this.listenTo( this.model.registrants, 'add', this.addOne ); // this.listenTo( this.model.registrants, 'create', this.render ); this.listenTo( this.model.registrants, 'remove', this.deleteOne ); - this.listenTo( this.model, 'change', this.render ); - // this.listenTo( this.model.registrants, 'change', this.render ); + this.listenTo( this.model.registrants, 'change', this.render ); + return this; }, @@ -1010,7 +1015,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ return; } } else { - findByEmail = this.model.registrants.where({email: email}); + findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); } var regRequest = cart.get( 'request' ); var parent = this.model.get('parent'); @@ -1024,27 +1029,26 @@ app.Views.Front.RegTime = Backbone.View.extend({ var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); // return false; - if ( findByEmail.length === 0 ) { - var newRegistrant = this.model.registrants.create({ - option: 'add', - reg_request: regRequest.id, - reg_time: this.model.get( 'id' ), - reg_event: this.model.get( 'reg_event' ), // Todo: use correct reg_event - reg_class: this.model.get( 'parent' ).id, // Todo: use correct reg_class - reg_rate: rateId, - email: email, - fname: fname, - lname: lname, - addr1: addr1, - addr2: addr2, - city: city, - state: state, - zip: zip, - country: country, - customFields: customFieldData, - }); - } + var newRegistrant = this.model.registrants.create({ + option: 'add', + reg_request: regRequest.id, + reg_time: this.model.get( 'id' ), + reg_event: this.model.get( 'reg_event' ), // Todo: use correct reg_event + reg_class: this.model.get( 'parent' ).id, // Todo: use correct reg_class + reg_rate: rateId, + email: email, + fname: fname, + lname: lname, + addr1: addr1, + addr2: addr2, + city: city, + state: state, + zip: zip, + country: country, + customFields: customFieldData, + }); + this.$('.glm-add-new-account').show(); this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; @@ -1060,7 +1064,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add a registrant to collection addOne: function( item ){ - // console.log( 'regTime: addOne called' ); + console.log( 'regTime: addOne called' ); // console.log( item.get('id') ); this.model.set({selectedTime: item.get('reg_time') }) // this.render(); @@ -1068,7 +1072,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // delete a registrant in collection deleteOne: function( item ){ - // console.log( 'regTime: deleteOne called' ); + console.log( 'regTime: deleteOne called' ); // this.render(); }, }); @@ -1088,7 +1092,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // bind events to the view events: { - 'focusout .add_reg_email': 'verifyEmail' + 'blur input.add_reg_email': 'verifyEmail' }, // setup the view @@ -1132,7 +1136,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ this.$('.add_reg_lname').val(account.lname); // lock the form - this.lockForm(); + // this.lockForm(); } else { // They should be able to edit the form this.unLockForm(); diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index fc3b185..0fc01ec 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -96,10 +96,12 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // render the view render: function(){ + // Call the custom fields ajax + app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); + this.$el.html( this.template( this.model.toJSON() ) ); this.$emailInput = this.$('.editEmail'); this.$('.reg-edit-form').hide(); - app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); return this; }, @@ -112,6 +114,9 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ option: 'delete' }, processData: true}); + // Need to release the lock if they want to delete the attendee + app.regEventLock = false; + this.remove(); }, diff --git a/js/views/front/regTime.js b/js/views/front/regTime.js index e5a5941..150921a 100644 --- a/js/views/front/regTime.js +++ b/js/views/front/regTime.js @@ -12,9 +12,9 @@ app.Views.Front.RegTime = Backbone.View.extend({ this.listenTo( this.model.registrants, 'add', this.addOne ); // this.listenTo( this.model.registrants, 'create', this.render ); this.listenTo( this.model.registrants, 'remove', this.deleteOne ); - this.listenTo( this.model, 'change', this.render ); - // this.listenTo( this.model.registrants, 'change', this.render ); + this.listenTo( this.model.registrants, 'change', this.render ); + return this; }, @@ -93,7 +93,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ return; } } else { - findByEmail = this.model.registrants.where({email: email}); + findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); } var regRequest = cart.get( 'request' ); var parent = this.model.get('parent'); @@ -107,27 +107,26 @@ app.Views.Front.RegTime = Backbone.View.extend({ var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); // return false; - if ( findByEmail.length === 0 ) { - var newRegistrant = this.model.registrants.create({ - option: 'add', - reg_request: regRequest.id, - reg_time: this.model.get( 'id' ), - reg_event: this.model.get( 'reg_event' ), // Todo: use correct reg_event - reg_class: this.model.get( 'parent' ).id, // Todo: use correct reg_class - reg_rate: rateId, - email: email, - fname: fname, - lname: lname, - addr1: addr1, - addr2: addr2, - city: city, - state: state, - zip: zip, - country: country, - customFields: customFieldData, - }); - } + var newRegistrant = this.model.registrants.create({ + option: 'add', + reg_request: regRequest.id, + reg_time: this.model.get( 'id' ), + reg_event: this.model.get( 'reg_event' ), // Todo: use correct reg_event + reg_class: this.model.get( 'parent' ).id, // Todo: use correct reg_class + reg_rate: rateId, + email: email, + fname: fname, + lname: lname, + addr1: addr1, + addr2: addr2, + city: city, + state: state, + zip: zip, + country: country, + customFields: customFieldData, + }); + this.$('.glm-add-new-account').show(); this.newRegAccount.destroy(); this.newRegAccountView.remove(); app.regEventLock = false; @@ -143,7 +142,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add a registrant to collection addOne: function( item ){ - // console.log( 'regTime: addOne called' ); + console.log( 'regTime: addOne called' ); // console.log( item.get('id') ); this.model.set({selectedTime: item.get('reg_time') }) // this.render(); @@ -151,7 +150,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // delete a registrant in collection deleteOne: function( item ){ - // console.log( 'regTime: deleteOne called' ); + console.log( 'regTime: deleteOne called' ); // this.render(); }, }); diff --git a/js/views/front/registrantForm.js b/js/views/front/registrantForm.js index 361af19..b0a5002 100644 --- a/js/views/front/registrantForm.js +++ b/js/views/front/registrantForm.js @@ -13,7 +13,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ // bind events to the view events: { - 'focusout .add_reg_email': 'verifyEmail' + 'blur input.add_reg_email': 'verifyEmail' }, // setup the view @@ -57,7 +57,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ this.$('.add_reg_lname').val(account.lname); // lock the form - this.lockForm(); + // this.lockForm(); } else { // They should be able to edit the form this.unLockForm(); diff --git a/models/admin/ajax/regFront/registrant.php b/models/admin/ajax/regFront/registrant.php index 1086866..c2afa95 100644 --- a/models/admin/ajax/regFront/registrant.php +++ b/models/admin/ajax/regFront/registrant.php @@ -320,14 +320,19 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations ); } - // If we have the email address then look up the account for it + // If we have the email address then look up the account for it. + // Need to match the record by email first and last name. if ( isset( $modelData['email'] ) && $email = filter_var( $modelData['email'], FILTER_VALIDATE_EMAIL ) ) { $accountId = $this->wpdb->get_var( $this->wpdb->prepare( "SELECT id FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "account - WHERE email = %s", - $email + WHERE email = %s + AND fname = %s + AND lname = %s", + $email, + $modelData['fname'], + $modelData['lname'] ) ); } diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index 42e289f..f5b28c8 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -166,16 +166,21 @@

{/literal}{$terms.reg_term_attendee_cap} Info{literal}

-
First Name
-
+
+ * Required Fields +
-
Last Name
-
+
Email Address
+
-
Email Address
-
+
First Name *
+
+
+
+
Last Name *
+
@@ -189,27 +194,27 @@ Address (show/hide)
-
Address 1
+
Address 1
-
Address 2
+
Address 2
-
City
+
City
-
State
+
State
-
Zip/Postal Code
+
Zip/Postal Code
-
Country
+
Country
{/literal}{if $regEvent.time_specific.value} @@ -235,43 +240,48 @@

{/literal}{$terms.reg_term_attendee_cap} Info{literal}

-
First Name
-
+
+ * Required Fields +
-
Last Name
-
+
Email Address
+
-
Email Address
-
+
First Name *
+
+
+
+
Last Name *
+
Address (show/hide)
-
Address 1
+
Address 1
-
Address 2
+
Address 2
-
City
+
City
-
State
+
State
-
Zip/Postal Code
+
Zip/Postal Code
-
Country
+
Country
-- 2.17.1