Have attendees adding with same email.
authorSteve Sutton <steve@gaslightmedia.com>
Tue, 19 Dec 2017 18:06:20 +0000 (13:06 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Tue, 19 Dec 2017 18:07:54 +0000 (13:07 -0500)
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
js/views/front/regRequestRegistrant.js
js/views/front/regTime.js
js/views/front/registrantForm.js
models/admin/ajax/regFront/registrant.php
views/front/registrations/registration.html

index 90130a0..8401f8c 100644 (file)
@@ -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();
index fc3b185..0fc01ec 100644 (file)
@@ -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();
     },
 
index e5a5941..150921a 100644 (file)
@@ -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();
     },
 });
index 361af19..b0a5002 100644 (file)
@@ -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();
index 1086866..c2afa95 100644 (file)
@@ -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']
                     )
                 );
             }
index 42e289f..f5b28c8 100644 (file)
             <div>
                 <h4>{/literal}{$terms.reg_term_attendee_cap} Info{literal}</h4>
                 <div class="row">
-                    <div class="columns large-4 small-12">First Name</div>
-                    <div class="columns large-8 small-12"><input class="add_reg_fname" value="<%- fname %>"></div>
+                    <div class="columns small-12 text-right">
+                        <span style="color:red;">* Required Fields</span>
+                    </div>
                 </div>
                 <div class="row">
-                    <div class="columns large-4 small-12">Last Name</div>
-                    <div class="columns large-8 small-12"><input class="add_reg_lname" value="<%- lname %>"></div>
+                    <div class="columns large-4 small-12 text-right">Email Address</div>
+                    <div class="columns large-8 small-12"><input class="add_reg_email" value="<%- email %>"></div>
                 </div>
                 <div class="row">
-                    <div class="columns large-4 small-12">Email Address</div>
-                    <div class="columns large-8 small-12"><input class="add_reg_email" value="<%- email %>"></div>
+                    <div class="columns large-4 small-12 text-right">First Name *</div>
+                    <div class="columns large-8 small-12"><input class="add_reg_fname" value="<%- fname %>"></div>
+                </div>
+                <div class="row">
+                    <div class="columns large-4 small-12 text-right">Last Name *</div>
+                    <div class="columns large-8 small-12"><input class="add_reg_lname" value="<%- lname %>"></div>
                 </div>
                 <form class="attendee-cf-form-new">
                     <div class="attendee-cf-new">
                     <a class="show-hide-address">Address (show/hide)</a>
                 </div>
                 <div class="row ereg-addr">
-                    <div class="columns large-4 small-12">Address 1</div>
+                    <div class="columns large-4 small-12 text-right">Address 1</div>
                     <div class="columns large-8 small-12"><input class="add_reg_addr1" value="<%- addr1 %>"></div>
                 </div>
                 <div class="row ereg-addr">
-                    <div class="columns large-4 small-12">Address 2</div>
+                    <div class="columns large-4 small-12 text-right">Address 2</div>
                     <div class="columns large-8 small-12"><input class="add_reg_addr2" value="<%- addr2 %>"></div>
                 </div>
                 <div class="row ereg-addr">
-                    <div class="columns large-4 small-12">City</div>
+                    <div class="columns large-4 small-12 text-right">City</div>
                     <div class="columns large-8 small-12"><input class="add_reg_city" value="<%- city %>"></div>
                 </div>
                 <div class="row ereg-addr">
-                    <div class="columns large-4 small-12">State</div>
+                    <div class="columns large-4 small-12 text-right">State</div>
                     <div class="columns large-8 small-12"><input class="add_reg_state" value="<%- state %>"></div>
                 </div>
                 <div class="row ereg-addr">
-                    <div class="columns large-4 small-12">Zip/Postal Code</div>
+                    <div class="columns large-4 small-12 text-right">Zip/Postal Code</div>
                     <div class="columns large-8 small-12"><input class="add_reg_zip" value="<%- zip %>"></div>
                 </div>
                 <div class="row ereg-addr">
-                    <div class="columns large-4 small-12">Country</div>
+                    <div class="columns large-4 small-12 text-right">Country</div>
                     <div class="columns large-8 small-12"><input class="add_reg_country" value="<%- country %>"></div>
                 </div>
                 {/literal}{if $regEvent.time_specific.value}
                 <div class="columns small-12 large-12">
                     <h4>{/literal}{$terms.reg_term_attendee_cap} Info{literal}</h4>
                     <div class="row">
-                        <div class="columns large-4 small-12">First Name</div>
-                        <div class="columns large-8 small-12"><input class="reg_fname" value="<%- fname %>"></div>
+                        <div class="columns small-12 text-right">
+                            <span style="color:red;">* Required Fields</span>
+                        </div>
                     </div>
                     <div class="row">
-                        <div class="columns large-4 small-12">Last Name</div>
-                        <div class="columns large-8 small-12"><input class="reg_lname" value="<%- lname %>"></div>
+                        <div class="columns large-4 small-12 text-right">Email Address</div>
+                        <div class="columns large-8 small-12"><input class="reg_email" value="<%- email %>" disabled></div>
                     </div>
                     <div class="row">
-                        <div class="columns large-4 small-12">Email Address</div>
-                        <div class="columns large-8 small-12"><input class="reg_email" value="<%- email %>" disabled></div>
+                        <div class="columns large-4 small-12 text-right">First Name *</div>
+                        <div class="columns large-8 small-12"><input class="reg_fname" value="<%- fname %>"></div>
+                    </div>
+                    <div class="row">
+                        <div class="columns large-4 small-12 text-right">Last Name *</div>
+                        <div class="columns large-8 small-12"><input class="reg_lname" value="<%- lname %>"></div>
                     </div>
                     <form class="attendee-cf-form-<%= id %>"><div class="attendee-cf-<%= id %>"></div></form>
                     <div>
                         <a class="show-hide-address">Address (show/hide)</a>
                     </div>
                     <div class="row ereg-addr">
-                        <div class="columns large-4 small-12">Address 1</div>
+                        <div class="columns large-4 small-12 text-right">Address 1</div>
                         <div class="columns large-8 small-12"><input class="reg_addr1" value="<%- addr1 %>"></div>
                     </div>
                     <div class="row ereg-addr">
-                        <div class="columns large-4 small-12">Address 2</div>
+                        <div class="columns large-4 small-12 text-right">Address 2</div>
                         <div class="columns large-8 small-12"><input class="reg_addr2" value="<%- addr2 %>"></div>
                     </div>
                     <div class="row ereg-addr">
-                        <div class="columns large-4 small-12">City</div>
+                        <div class="columns large-4 small-12 text-right">City</div>
                         <div class="columns large-8 small-12"><input class="reg_city" value="<%- city %>"></div>
                     </div>
                     <div class="row ereg-addr">
-                        <div class="columns large-4 small-12">State</div>
+                        <div class="columns large-4 small-12 text-right">State</div>
                         <div class="columns large-8 small-12"><input class="reg_state" value="<%- state %>"></div>
                     </div>
                     <div class="row ereg-addr">
-                        <div class="columns large-4 small-12">Zip/Postal Code</div>
+                        <div class="columns large-4 small-12 text-right">Zip/Postal Code</div>
                         <div class="columns large-8 small-12"><input class="reg_zip" value="<%- zip %>"></div>
                     </div>
                     <div class="row ereg-addr">
-                        <div class="columns large-4 small-12">Country</div>
+                        <div class="columns large-4 small-12 text-right">Country</div>
                         <div class="columns large-8 small-12"><input class="reg_country" value="<%- country %>"></div>
                     </div>
                 </div>