From 62dc82db997b769e756861648bd8f045238ed4c4 Mon Sep 17 00:00:00 2001 From: Steve Sutton Date: Tue, 17 Apr 2018 09:20:17 -0400 Subject: [PATCH] Getting the custom field for reg level working. I have the custom fields being adding and updated within the registrant forms. --- js/frontRegApp.js | 15 +++++++-------- js/views/front/regRequestRegistrant.js | 6 ++++-- js/views/front/regTime.js | 7 ++----- js/views/front/registrantForm.js | 2 +- models/admin/ajax/regFront/registrant.php | 20 ++++++++++++++++++++ views/front/registrations/registration.html | 10 +++------- 6 files changed, 37 insertions(+), 23 deletions(-) diff --git a/js/frontRegApp.js b/js/frontRegApp.js index b6d889e..aac3157 100644 --- a/js/frontRegApp.js +++ b/js/frontRegApp.js @@ -774,6 +774,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // For some reason this is not available after the newRegistrant is added // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-' + this.model.get('id') ).serialize(); + var customFieldLevelData = this.$( 'form.attendee-cf-form-level-' + this.model.get('id') ).serialize(); var modelId = this.model.get( 'id' ); var fname = this.$('.reg_fname').val().trim(); @@ -817,6 +818,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ country: country, reg_time: this.model.get('reg_time'), customFields: customFieldData, + customFieldsLevel: customFieldLevelData, }, {wait: true}); // this.model.save(); if ( this.model.validationError ) { @@ -830,7 +832,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ resetCustomFields: function() { // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); - app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('reg_class'), this.model.id, '.attendee-cf-level-' + this.model.id); this.$('.reg-edit-form').hide(); }, @@ -869,7 +871,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); - app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('reg_class'), this.model.id, '.attendee-cf-level-' + this.model.id); return this; }, @@ -947,7 +949,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ if ( app.timeSpecific ) { this.newRegAccount = new app.Models.Front.RegRequestRegistrant({ reg_time: this.model.get( 'selectedTime' ) }); } else { - // console.log(this.model); this.newRegAccount = new app.Models.Front.RegRequestRegistrant({ reg_event: this.model.get('reg_event'), reg_class: this.model.get('parent') @@ -999,7 +1000,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ } } else { findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); - console.log( findByEmail.length ); if ( findByEmail.length > 0 ) { this.$('#loading-' + this.model.get('id') ).hide(); } @@ -1016,6 +1016,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // For some reason this is not available after the newRegistrant is added // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); + var customFieldLevelData = this.$( 'form.attendee-cf-form-level-new' ).serialize(); var newRegistrant = this.model.registrants.create({ option: 'add', @@ -1034,6 +1035,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ zip: zip, country: country, customFields: customFieldData, + customFieldsLevel: customFieldLevelData, },{ wait: true, error: this.errorCallback }); this.$('.glm-add-new-account').show(); @@ -1062,15 +1064,12 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add a registrant to collection addOne: function( item ){ - // console.log( 'regTime: addOne called' ); - // console.log( item.get('id') ); this.model.set({selectedTime: item.get('reg_time') }) this.render(); }, // delete a registrant in collection deleteOne: function( item ){ - // console.log( 'regTime: deleteOne called' ); // this.render(); }, }); @@ -1104,7 +1103,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ render: function(){ this.$el.html( this.template( this.model.toJSON() ) ); var regClass = this.model.get('reg_class'); - app.setCustomFieldsForLevelForm( this.model.get('reg_event'), regClass.get('id'), this.model.id, '.attendee-cf-level-' + this.model.id); + app.setCustomFieldsForLevelForm( this.model.get('reg_event'), regClass.get('id'), this.model.id, '.attendee-cf-level-new'); return this; }, diff --git a/js/views/front/regRequestRegistrant.js b/js/views/front/regRequestRegistrant.js index 6e4e15b..296cbdf 100644 --- a/js/views/front/regRequestRegistrant.js +++ b/js/views/front/regRequestRegistrant.js @@ -28,6 +28,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // For some reason this is not available after the newRegistrant is added // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-' + this.model.get('id') ).serialize(); + var customFieldLevelData = this.$( 'form.attendee-cf-form-level-' + this.model.get('id') ).serialize(); var modelId = this.model.get( 'id' ); var fname = this.$('.reg_fname').val().trim(); @@ -71,6 +72,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ country: country, reg_time: this.model.get('reg_time'), customFields: customFieldData, + customFieldsLevel: customFieldLevelData, }, {wait: true}); // this.model.save(); if ( this.model.validationError ) { @@ -84,7 +86,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ resetCustomFields: function() { // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); - app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('reg_class'), this.model.id, '.attendee-cf-level-' + this.model.id); this.$('.reg-edit-form').hide(); }, @@ -123,7 +125,7 @@ app.Views.Front.RegRequestRegistrant = Backbone.View.extend({ // Call the custom fields ajax app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id); - app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('class_id'), this.model.id, '.attendee-cf-level-' + this.model.id); + app.setCustomFieldsForLevelForm(this.model.get('reg_event'), this.model.get('reg_class'), this.model.id, '.attendee-cf-level-' + this.model.id); return this; }, diff --git a/js/views/front/regTime.js b/js/views/front/regTime.js index db63325..f99dd87 100644 --- a/js/views/front/regTime.js +++ b/js/views/front/regTime.js @@ -55,7 +55,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ if ( app.timeSpecific ) { this.newRegAccount = new app.Models.Front.RegRequestRegistrant({ reg_time: this.model.get( 'selectedTime' ) }); } else { - // console.log(this.model); this.newRegAccount = new app.Models.Front.RegRequestRegistrant({ reg_event: this.model.get('reg_event'), reg_class: this.model.get('parent') @@ -107,7 +106,6 @@ app.Views.Front.RegTime = Backbone.View.extend({ } } else { findByEmail = this.model.registrants.where({email: email, fname: fname, lname: lname}); - console.log( findByEmail.length ); if ( findByEmail.length > 0 ) { this.$('#loading-' + this.model.get('id') ).hide(); } @@ -124,6 +122,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ // For some reason this is not available after the newRegistrant is added // to the collection. var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize(); + var customFieldLevelData = this.$( 'form.attendee-cf-form-level-new' ).serialize(); var newRegistrant = this.model.registrants.create({ option: 'add', @@ -142,6 +141,7 @@ app.Views.Front.RegTime = Backbone.View.extend({ zip: zip, country: country, customFields: customFieldData, + customFieldsLevel: customFieldLevelData, },{ wait: true, error: this.errorCallback }); this.$('.glm-add-new-account').show(); @@ -170,15 +170,12 @@ app.Views.Front.RegTime = Backbone.View.extend({ // add a registrant to collection addOne: function( item ){ - // console.log( 'regTime: addOne called' ); - // console.log( item.get('id') ); this.model.set({selectedTime: item.get('reg_time') }) this.render(); }, // delete a registrant in collection deleteOne: function( item ){ - // console.log( 'regTime: deleteOne called' ); // this.render(); }, }); diff --git a/js/views/front/registrantForm.js b/js/views/front/registrantForm.js index 15af930..9aa17e6 100644 --- a/js/views/front/registrantForm.js +++ b/js/views/front/registrantForm.js @@ -27,7 +27,7 @@ app.Views.Front.RegistrantForm = Backbone.View.extend({ render: function(){ this.$el.html( this.template( this.model.toJSON() ) ); var regClass = this.model.get('reg_class'); - app.setCustomFieldsForLevelForm( this.model.get('reg_event'), regClass.get('id'), this.model.id, '.attendee-cf-level-' + this.model.id); + app.setCustomFieldsForLevelForm( this.model.get('reg_event'), regClass.get('id'), this.model.id, '.attendee-cf-level-new'); return this; }, diff --git a/models/admin/ajax/regFront/registrant.php b/models/admin/ajax/regFront/registrant.php index 132cb4f..cf20ec7 100644 --- a/models/admin/ajax/regFront/registrant.php +++ b/models/admin/ajax/regFront/registrant.php @@ -150,6 +150,8 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations */ public function addUpdateRegistrantToCart( $modelData, $action ) { + // trigger_error( print_r($modelData, true) ); + $validated = false; if ( $action == 'add' ) { @@ -521,6 +523,24 @@ class GlmMembersAdmin_registrations_ajax_registrant extends GlmDataRegistrations ); $registrant['customFields'] = $modelData['customFields']; + // Parse str for the custom field data + parse_str( $modelData['customFieldsLevel'], $queryParams2 ); + + // Store the custom Level field data + $_REQUEST = $queryParams2; + // trigger_error(print_r($_REQUEST,1)); + // trigger_error(print_r($regRequestRegistrantId,1)); + // trigger_error(print_r($regRequestClassId,1)); + apply_filters( + 'glm-members-customfields-form-submit', + '', + 'glm_reg_customfields_reg_event_' . $modelData['reg_event'] . '_level_' . $modelData['reg_class'], + $regRequestRegistrantId, + true + ); + $registrant['customFieldsLevel'] = $modelData['customFieldsLevel']; + + return $registrant; } diff --git a/views/front/registrations/registration.html b/views/front/registrations/registration.html index db13409..0409c78 100644 --- a/views/front/registrations/registration.html +++ b/views/front/registrations/registration.html @@ -323,8 +323,8 @@ glm_reg_customfields_reg_event_{$regEventId}_level_{literal}<%- reg_class.id %>{ {literal} -
-
+ +
{/literal}{/if}{literal} {/literal}{if $regEvent.time_specific.value} @@ -420,7 +420,7 @@ glm_reg_customfields_reg_event_{$regEventId}_level_{literal}<%- reg_class.id %>{

Additional Info Needed

{/literal}{/if}{literal}
-
+
{/literal}{/if}{literal} {/literal}{if $regEvent.time_specific.value} @@ -494,7 +494,6 @@ var app = { } }, setCustomFieldsForLevelForm: function( reg_event_id, reg_level_id, record_id, target ){ - console.log('record_id: ', record_id); if ( customFieldActive ) { var formData = { 'action': 'glm_members_admin_ajax', @@ -515,7 +514,6 @@ var app = { }) .done( function( formHtml ) { if ( target === 'return' ) { - console.log( formHtml ); return formHtml; } else { jQuery(target).html( formHtml ); @@ -546,7 +544,6 @@ var app = { }) .done( function( formHtml ) { if ( target === 'return' ) { - console.log( formHtml ); return formHtml; } else { jQuery(target).html( formHtml ); @@ -646,7 +643,6 @@ jQuery(function($){ var id = $(this).data('descr'); var descr = $('body').find( $('#' + id) ); var descr_length = descr.text().length; - console.log(descr_length); if( descr.height() < 47 && descr_length > 150 ){ $(descr).animate({ height: '100%', -- 2.17.1