setClassRegistrants: function( registrants ){
for ( var i = 0; i < registrants.length; i++ ) {
+ // console.log(registrants[i]);
var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
+ // console.log(foundClass);
if ( foundClass != undefined ) {
- var foundRegTime = _.where(app.Times, { id: registrants[i].reg_time });
+ var foundRegTime = _.findWhere(app.Times, { id: registrants[i].reg_time });
// Now add the time if needed
var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
+ // console.log(hasRegTime);
if ( !hasRegTime ) {
- foundClass.regTimes.create( foundRegTime[0] );
+ foundClass.regTimes.create( foundRegTime );
hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
+ // console.log(hasRegTime);
hasRegTime.set({ parent: foundClass });
}
// Add the registrant
var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
- // console.log( nRegTime );
nRegTime.registrants.create( registrants[i] );
- // var newReg = foundClass.registrants.pop();
- // foundClass.set({selectedTime: newReg.get( 'reg_time' ) });
}
}
},
if ( app.timeSpecific ) {
this.setCalendar();
}
- // console.log('called onRenderComplete');
},
setCalendar: function(){
- console.log( 'setting calendar' );
var times = this.model.get( 'times' );
$('#eventCalendar-' + this.model.get('id')).fullCalendar({
events: function(start, end, timezone, callback) {
// Check to make sure the loginAccount is not empty
if ( loginAccount !== '' ) {
this.$('.glm-add-account').hide();
- // console.log('hiding');
var regRequest = cart.get( 'request' );
var accountEmail = loginAccount.get( 'email' );
var accountId = loginAccount.get( 'id' );
cancelAddNew: function(){
this.$('.glm-add-new-account').show();
- // this.newRegAccount.destroy();
this.newRegAccountView.remove();
- // app.calendar = false;
- // if ( loginAccount != '' && this.model.hasMe() ) {
- // this.$('.glm-add-account').hide();
- // // console.log('hiding');
- // } else if ( loginAccount != '' ) {
- // this.$('.glm-add-account').show();
- // // console.log('showing');
- // }
},
addNewAccount: function(){
// If not found then nothing was found for that email.
alert('Must be a valid email address!');
} else if ( account.id !== undefined && account.email !== undefined ) {
- //console.log( cart.get( 'request' ) );
var regRequest = cart.get( 'request' );
this.model.registrants.create({
option: 'add',
update: function(){
var modelId = this.model.get( 'id' );
- console.log( 'updating model' );
var fname = this.$('.reg_fname').val().trim();
var lname = this.$('.reg_lname').val().trim();
var email = this.$('.reg_email').val().trim();
});
this.model.save();
if ( this.model.validationError ) {
- console.log( this.model.validationError );
+ // console.log( this.model.validationError );
}
this.$('.reg-edit-form').hide();
// Find the class for this registrant
// Use findWhere to get the correct regClass
var regLevel = regEvent.classes.findWhere({ id: this.model.get( 'reg_class' ) });
- // console.log( regLevel );
var times = regLevel.get( 'times' );
$( '#eventCalendar-' + modelId ).fullCalendar({
events: function(start, end, timezone, callback) {
});
},
cancelEdit: function(){
- console.log( 'cancel edit' );
this.$('.reg-edit-form').hide();
},
this.$('.reg-edit-form').show();
if ( app.timeSpecific === true ) {
this.$('#reg-select-time').val( this.model.get( 'reg_time' ) );
- console.log( 'this.setCalendar called' );
this.setCalendar();
}
},
}
var rateId = this.model.get( 'rate_id' );
if ( !rateId ) {
- console.log( 'No rate id!' );
- console.log( sTime );
+ // console.log( 'No rate id!' );
+ // console.log( sTime );
return;
}
if ( fname === '' || lname === '' ) {
}
var regRequest = cart.get( 'request' );
var parent = this.model.get('parent');
- console.log( parent );
+ // console.log( parent );
if ( !parent ) {
- console.log( 'Parent not there!' );
+ // console.log( 'Parent not there!' );
return;
}
if ( findByEmail.length === 0 ) {
this.$('.glm-add-new-account').show();
// this.newRegAccount.destroy();
this.newRegAccountView.remove();
- // app.calendar = false;
- // if ( loginAccount != '' && this.model.hasMe() ) {
- // this.$('.glm-add-account').hide();
- // // console.log('hiding');
- // } else if ( loginAccount != '' ) {
- // this.$('.glm-add-account').show();
- // // console.log('showing');
- // }
},
addOne: function( item ){
if ( email == '' ) {
return;
}
- console.log( 'Verify Email called' );
var isValidEmail = app.isValidEmail( email );
if ( !isValidEmail ) {
alert( 'Email must be valid' );
data: { email: email }
})
.done(function(account){
- console.log(account);
// Check for id and email
if ( account.id ) {
// This account already exists.
// They should not be able to edit the record.
- console.log( 'Record exists not able to edit!' );
this.$('.add_reg_fname').val(account.fname);
this.$('.add_reg_lname').val(account.lname);
setClassRegistrants: function( registrants ){
for ( var i = 0; i < registrants.length; i++ ) {
+ // console.log(registrants[i]);
var foundClass = this.classes.findWhere({ id: registrants[i].class_id });
+ // console.log(foundClass);
if ( foundClass != undefined ) {
- var foundRegTime = _.where(app.Times, { id: registrants[i].reg_time });
+ var foundRegTime = _.findWhere(app.Times, { id: registrants[i].reg_time });
// Now add the time if needed
var hasRegTime = _.findWhere(foundClass, { reg_time: foundRegTime.id });
+ // console.log(hasRegTime);
if ( !hasRegTime ) {
- foundClass.regTimes.create( foundRegTime[0] );
+ foundClass.regTimes.create( foundRegTime );
hasRegTime = foundClass.regTimes.findWhere({ id: foundRegTime.id });
+ // console.log(hasRegTime);
hasRegTime.set({ parent: foundClass });
}
// Add the registrant
var nRegTime = foundClass.regTimes.findWhere({id: hasRegTime.get('id')});
- // console.log( nRegTime );
nRegTime.registrants.create( registrants[i] );
- // var newReg = foundClass.registrants.pop();
- // foundClass.set({selectedTime: newReg.get( 'reg_time' ) });
}
}
},
if ( app.timeSpecific ) {
this.setCalendar();
}
- // console.log('called onRenderComplete');
},
setCalendar: function(){
- console.log( 'setting calendar' );
var times = this.model.get( 'times' );
$('#eventCalendar-' + this.model.get('id')).fullCalendar({
events: function(start, end, timezone, callback) {
// Check to make sure the loginAccount is not empty
if ( loginAccount !== '' ) {
this.$('.glm-add-account').hide();
- // console.log('hiding');
var regRequest = cart.get( 'request' );
var accountEmail = loginAccount.get( 'email' );
var accountId = loginAccount.get( 'id' );
cancelAddNew: function(){
this.$('.glm-add-new-account').show();
- // this.newRegAccount.destroy();
this.newRegAccountView.remove();
- // app.calendar = false;
- // if ( loginAccount != '' && this.model.hasMe() ) {
- // this.$('.glm-add-account').hide();
- // // console.log('hiding');
- // } else if ( loginAccount != '' ) {
- // this.$('.glm-add-account').show();
- // // console.log('showing');
- // }
},
addNewAccount: function(){
// If not found then nothing was found for that email.
alert('Must be a valid email address!');
} else if ( account.id !== undefined && account.email !== undefined ) {
- //console.log( cart.get( 'request' ) );
var regRequest = cart.get( 'request' );
this.model.registrants.create({
option: 'add',
update: function(){
var modelId = this.model.get( 'id' );
- console.log( 'updating model' );
var fname = this.$('.reg_fname').val().trim();
var lname = this.$('.reg_lname').val().trim();
var email = this.$('.reg_email').val().trim();
});
this.model.save();
if ( this.model.validationError ) {
- console.log( this.model.validationError );
+ // console.log( this.model.validationError );
}
this.$('.reg-edit-form').hide();
// Find the class for this registrant
// Use findWhere to get the correct regClass
var regLevel = regEvent.classes.findWhere({ id: this.model.get( 'reg_class' ) });
- // console.log( regLevel );
var times = regLevel.get( 'times' );
$( '#eventCalendar-' + modelId ).fullCalendar({
events: function(start, end, timezone, callback) {
});
},
cancelEdit: function(){
- console.log( 'cancel edit' );
this.$('.reg-edit-form').hide();
},
this.$('.reg-edit-form').show();
if ( app.timeSpecific === true ) {
this.$('#reg-select-time').val( this.model.get( 'reg_time' ) );
- console.log( 'this.setCalendar called' );
this.setCalendar();
}
},
}
var rateId = this.model.get( 'rate_id' );
if ( !rateId ) {
- console.log( 'No rate id!' );
- console.log( sTime );
+ // console.log( 'No rate id!' );
+ // console.log( sTime );
return;
}
if ( fname === '' || lname === '' ) {
}
var regRequest = cart.get( 'request' );
var parent = this.model.get('parent');
- console.log( parent );
+ // console.log( parent );
if ( !parent ) {
- console.log( 'Parent not there!' );
+ // console.log( 'Parent not there!' );
return;
}
if ( findByEmail.length === 0 ) {
this.$('.glm-add-new-account').show();
// this.newRegAccount.destroy();
this.newRegAccountView.remove();
- // app.calendar = false;
- // if ( loginAccount != '' && this.model.hasMe() ) {
- // this.$('.glm-add-account').hide();
- // // console.log('hiding');
- // } else if ( loginAccount != '' ) {
- // this.$('.glm-add-account').show();
- // // console.log('showing');
- // }
},
addOne: function( item ){