so far not working using the apply_filters.
var gulp = require('gulp'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
- jshint = require('gulp-jshint'),
+ // jshint = require('gulp-jshint'),
plumber = require('gulp-plumber');
-// notify = require('gulp-notify');
+ // notify = require('gulp-notify');
gulp.task('adminscripts', function(){
gulp.src([
.pipe(plumber())
.pipe(concat('frontRegApp.js'))
//.pipe(uglify())
+ // .pipe(notify('frontscripts:', 'completed'))
.pipe(jshint())
.pipe(gulp.dest('js/'));
});
initialize: function(){
// this.registrants = new app.Collections.Front.RegRequestRegistrants( [] );
- this.regTimes = new app.Collections.Front.RegTimes( [] );
+ this.regTimes = new app.Collections.Front.RegTimes( );
},
});
for ( var i = 0; i < registrants.length; i++ ) {
// Find the class that this registrant belongs to.
var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
- // console.log( foundClass );
if ( foundClass != undefined ) {
+ var foundClassTimes = foundClass.regTimes;
+ // console.log('total times: ' + foundClassTimes.length);
+ var regTimeId = parseInt( registrants[i].reg_time );
// Try looking through the class times
- // console.log( registrants[i].reg_time );
- // console.log( foundClass.get('times') );
// Using the registrants reg_time lookup the regTime
- // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
- var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
- console.log( 'find reg time' );
- console.log( foundRegTime );
+ // class times are in JSON form under class.times
+ var foundRegTime = _.findWhere(foundClass.get('times'), { id: regTimeId });
if ( foundRegTime ) {
// Set the reg_event for this reg_time to the class we found for registrant
foundRegTime.reg_event = foundClass.get('reg_event');
// Now add the time if needed
// First check to see if there's not one added already (regTime).
- var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
+ var hasRegTime = foundClassTimes.findWhere({ id: foundRegTime.id });
if ( !hasRegTime ) {
+ // console.log( 'no time found: creating time');
// Here we have to add the regTime into the class.
foundClass.regTimes.create( foundRegTime );
hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
hasRegTime.set({ parent: foundClass });
}
+ // console.log(hasRegTime);
+ //
+ // console.log('total times: ' + foundClassTimes.length);
// Add the registrant to the regTime.
var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
- console.log( 'nRegTime' );
- console.log(nRegTime);
+ // console.log('total registrants: ' + nRegTime.registrants.length);
nRegTime.registrants.create( registrants[i] );
+ nRegTime.save();
+ // console.log(nRegTime);
+ // console.log('total registrants: ' + nRegTime.registrants.length);
+
}
}
return 1;
}
},
+
});
// js/collections/regTimes.js
// Add times into regTimes collection
var classTimes = this.model.get('times');
- var timeArs = [];
+ //var timeArs = [];
for ( var key in classTimes ) {
var newTime = new app.Models.Front.RegTime( classTimes[key] );
newTime.set({reg_event: this.model.get('reg_event'), parent: this.model});
- timeArs.push( newTime );
- // this.model.regTimes.create( newTime );
+ //timeArs.push( newTime );
+ this.model.regTimes.create( newTime );
}
- this.model.regTimes.reset( timeArs );
+ //this.model.regTimes.reset( timeArs );
// console.log( classTimes );
this.$el.html( this.template( this.model.toJSON() ) );
this.$emailInput = this.$('.editEmail');
this.$('.reg-edit-form').hide();
- app.setCustomFieldsForm(this.model.get('reg_event'), '.attendee-cf-' + this.model.id);
+ app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
return this;
},
// initialize the view
initialize: function(){
this.listenTo( this.model.registrants, 'add', this.addOne );
- this.listenTo( this.model.registrants, 'create', 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 );
return this;
},
// render the view
render: function(){
+ // console.log('render called from Views.Front.RegTime');
this.model.set({ reg_count: this.model.registrants.length });
this.$el.html( this.template( this.model.toJSON() ) );
// Need to see if this has attendees and render them
return;
}
+ var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize();
+
+ // return false;
if ( findByEmail.length === 0 ) {
var newRegistrant = this.model.registrants.create({
option: 'add',
state: state,
zip: zip,
country: country,
+ customFields: customFieldData,
});
- // Now we have a new registrant let's save the custom field data.
- var formData = jQuery( '#attendees-cf-form-new' ).serialize();
- console.log( 'output form data' );
- console.log( formData );
- // app.saveCustomFieldsForm(
- // jQuery('.attendee-cf-form').serialize()
- // );
}
- this.newRegAccount.destroy();
- this.newRegAccountView.remove();
+ // this.newRegAccount.destroy();
+ // this.newRegAccountView.remove();
app.regEventLock = false;
},
// 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();
+ this.render();
},
// delete a registrant in collection
deleteOne: function( item ){
- // this.render();
+ // console.log( 'regTime: deleteOne called' );
+ this.render();
},
});
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
// console.log( this.model.get('reg_event') );
- app.setCustomFieldsForm(this.model.get('reg_event'), '.attendee-cf-new');
+ app.setCustomFieldsForm(this.model.get('reg_event'), '', '.attendee-cf-new');
return this;
},
initialize: function(){
// this.registrants = new app.Collections.Front.RegRequestRegistrants( [] );
- this.regTimes = new app.Collections.Front.RegTimes( [] );
+ this.regTimes = new app.Collections.Front.RegTimes( );
},
});
for ( var i = 0; i < registrants.length; i++ ) {
// Find the class that this registrant belongs to.
var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
- // console.log( foundClass );
if ( foundClass != undefined ) {
+ var foundClassTimes = foundClass.regTimes;
+ // console.log('total times: ' + foundClassTimes.length);
+ var regTimeId = parseInt( registrants[i].reg_time );
// Try looking through the class times
- // console.log( registrants[i].reg_time );
- // console.log( foundClass.get('times') );
// Using the registrants reg_time lookup the regTime
- // var foundRegTime = foundClass.regTimes.findWhere({id: registrants[i].reg_time});
- var foundRegTime = _.findWhere(foundClass.get('times'), { id: registrants[i].reg_time });
- console.log( 'find reg time' );
- console.log( foundRegTime );
+ // class times are in JSON form under class.times
+ var foundRegTime = _.findWhere(foundClass.get('times'), { id: regTimeId });
if ( foundRegTime ) {
// Set the reg_event for this reg_time to the class we found for registrant
foundRegTime.reg_event = foundClass.get('reg_event');
// Now add the time if needed
// First check to see if there's not one added already (regTime).
- var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
+ var hasRegTime = foundClassTimes.findWhere({ id: foundRegTime.id });
if ( !hasRegTime ) {
+ // console.log( 'no time found: creating time');
// Here we have to add the regTime into the class.
foundClass.regTimes.create( foundRegTime );
hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
hasRegTime.set({ parent: foundClass });
}
+ // console.log(hasRegTime);
+ //
+ // console.log('total times: ' + foundClassTimes.length);
// Add the registrant to the regTime.
var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
- console.log( 'nRegTime' );
- console.log(nRegTime);
+ // console.log('total registrants: ' + nRegTime.registrants.length);
nRegTime.registrants.create( registrants[i] );
+ nRegTime.save();
+ // console.log(nRegTime);
+ // console.log('total registrants: ' + nRegTime.registrants.length);
+
}
}
// Add times into regTimes collection
var classTimes = this.model.get('times');
- var timeArs = [];
+ //var timeArs = [];
for ( var key in classTimes ) {
var newTime = new app.Models.Front.RegTime( classTimes[key] );
newTime.set({reg_event: this.model.get('reg_event'), parent: this.model});
- timeArs.push( newTime );
- // this.model.regTimes.create( newTime );
+ //timeArs.push( newTime );
+ this.model.regTimes.create( newTime );
}
- this.model.regTimes.reset( timeArs );
+ //this.model.regTimes.reset( timeArs );
// console.log( classTimes );
this.$el.html( this.template( this.model.toJSON() ) );
this.$emailInput = this.$('.editEmail');
this.$('.reg-edit-form').hide();
- app.setCustomFieldsForm(this.model.get('reg_event'), '.attendee-cf-' + this.model.id);
+ app.setCustomFieldsForm(this.model.get('reg_event'), this.model.id, '.attendee-cf-' + this.model.id);
return this;
},
// initialize the view
initialize: function(){
this.listenTo( this.model.registrants, 'add', this.addOne );
- this.listenTo( this.model.registrants, 'create', 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 );
return this;
},
// render the view
render: function(){
+ // console.log('render called from Views.Front.RegTime');
this.model.set({ reg_count: this.model.registrants.length });
this.$el.html( this.template( this.model.toJSON() ) );
// Need to see if this has attendees and render them
return;
}
+ var customFieldData = this.$( 'form.attendee-cf-form-new' ).serialize();
+
+ // return false;
if ( findByEmail.length === 0 ) {
var newRegistrant = this.model.registrants.create({
option: 'add',
state: state,
zip: zip,
country: country,
+ customFields: customFieldData,
});
- // Now we have a new registrant let's save the custom field data.
- var formData = jQuery( '#attendees-cf-form-new' ).serialize();
- console.log( 'output form data' );
- console.log( formData );
- // app.saveCustomFieldsForm(
- // jQuery('.attendee-cf-form').serialize()
- // );
}
- this.newRegAccount.destroy();
- this.newRegAccountView.remove();
+ // this.newRegAccount.destroy();
+ // this.newRegAccountView.remove();
app.regEventLock = false;
},
// 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();
+ this.render();
},
// delete a registrant in collection
deleteOne: function( item ){
- // this.render();
+ // console.log( 'regTime: deleteOne called' );
+ this.render();
},
});
render: function(){
this.$el.html( this.template( this.model.toJSON() ) );
// console.log( this.model.get('reg_event') );
- app.setCustomFieldsForm(this.model.get('reg_event'), '.attendee-cf-new');
+ app.setCustomFieldsForm(this.model.get('reg_event'), '', '.attendee-cf-new');
return this;
},
{
$validated = false;
- // trigger_error(print_r($modelData,1));
+ trigger_error(print_r($modelData,1));
if ( !isset( $modelData['option'] ) ) {
$option = null;
'%s'
);
$accountId = $this->wpdb->insert_id;
+ $queryParams = parse_url( $modelData['customFields'] );
+
+ // Store the custom field data
+ $_REQUEST = $queryParams;
+ apply_filters( 'glm-members-customfields-form-submit', '', 'glm_reg_customfields_reg_event_attendee_' . $modelData['reg_event'], $accountId, true);
// Here validated would be false.
// Because it is new account.
}
{* Underscore Templates for the Event Registration App *}
{* Template for Logged in Account *}
-<!-- *** TESTING ONLY *** -->
-<div id="test-form-request" class="button map-button">*** TEST FORM REQUEST ***</div>
-<div id="test-form-container">Test Form Container</div>
-<script type="text/javascript">
-jQuery(document).ready(function($) {
-
- // Submit test form request
- $('#test-form-request').click( function() {
-
- // Collect the new field data
- var formData = {
- 'action': 'glm_members_admin_ajax',
- 'glm_action': 'customFieldsFront',
- 'option': 'displayForm',
- 'fid': 'glm_reg_customfields_reg_event_61',
- 'recordId': '123',
- 'parentFormId': 'abc-123',
- 'formData': false
- };
-
- // Submit new field data - expect field new ID back
- $.ajax({
- type: 'POST',
- url: '{$ajaxUrl}',
- data: formData,
- encode: true,
- dataType: 'text'
- })
- .done( function(formHtml) {
- $('#test-form-container').html(formHtml);
- });
-
- });
-
-});
-</script>
-<!-- *** END OF TESTING *** -->
-
-<script src="//maps.googleapis.com/maps/api/js?sensor=true&key={$settings.google_maps_api_key}"></script>
+<script src="//maps.googleapis.com/maps/api/js?key={$settings.google_maps_api_key}"></script>
{literal}
<script type="text/template" id="account-template">
<span>Logged in as <%= fname %><%= lname %></span>
<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>
- <form id="attendee-cf-form-new"><div class="attendee-cf-new"></div></form>
+ <form class="attendee-cf-form-new"><div class="attendee-cf-new"></div></form>
<div>
<a class="show-hide-address">Address (show/hide)</a>
</div>
<div class="columns large-4 small-12">Email Address</div>
<div class="columns large-8 small-12"><input class="reg_email" value="<%- email %>"></div>
</div>
- <form class="attendee-cf-form"><div class="attendee-cf"></div></form>
+ <form class="attendee-cf-form-<%= id %>"><div class="attendee-cf-<%= id %>"></div></form>
<div>
<a class="show-hide-address">Address (show/hide)</a>
</div>
return false;
}
},
- setCustomFieldsForm: function(reg_event_id, target){
+ setCustomFieldsForm: function( reg_event_id, record_id, target ){
var formData = {
'action': 'glm_members_admin_ajax',
'glm_action': 'customFieldsFront',
'option': 'displayForm',
'fid': 'glm_reg_customfields_reg_event_attendee_' + reg_event_id,
- 'recordId': '1',
- 'parentFormId': 'abc-123',
+ 'recordId': record_id,
+ 'parentFormId': '',
'formData': false
};
$.ajax({
$(target).html( formHtml );
});
},
- saveCustomFieldsForm: function( formData, reg_event_id ){
- console.log( 'SAVING FORW DATA' );
- console.log( formData );
- console.log( reg_event_id );
- },
{if $regEvent.time_specific.value}
timeSpecific: true,
{else}