var zip = this.$('.reg_zip').val().trim();
var country = this.$('.reg_country').val().trim();
var rTime = this.$('#reg-select-time').val().trim();
+ if ( !rTime ) {
+ alert( 'You must select a time!' );
+ return;
+ }
if ( fname === '' || lname === '' ) {
alert( 'First and Last name required!' );
return;
template: _.template( jQuery('#eventReg-registrant-add').html() ),
events: {
+ 'focusout .reg_email': 'verifyEmail'
},
initialize: function(){
return this;
},
+ verifyEmail: function(){
+ var email = this.$('.reg_email').val().trim();
+ if ( email == '' ) {
+ return;
+ }
+ console.log( 'Verify Email called' );
+ var isValidEmail = app.isValidEmail( email );
+ if ( !isValidEmail ) {
+ alert( 'Email must be valid' );
+ } else {
+ // Check to see if this is a valid email.
+ jQuery.ajax({
+ context: this,
+ url: ajaxUrl + '&glm_action=account&option=checkEmail',
+ dataType: 'json',
+ 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.$('.reg_fname').val(account.fname);
+ this.$('.reg_lname').val(account.lname);
+
+ // lock the form
+ this.lockForm();
+ } else {
+ // They should be able to edit the form
+ this.unLockForm();
+ }
+ })
+ .fail(function(msg){
+ console.log('Fail: ' + msg);
+ });
+ }
+ },
+
+ lockForm: function(){
+ this.$('.reg_fname').prop('disabled', true);
+ this.$('.reg_lname').prop('disabled', true);
+ this.$('.reg_addr1').prop('disabled', true);
+ this.$('.reg_addr2').prop('disabled', true);
+ this.$('.reg_city').prop('disabled', true);
+ this.$('.reg_state').prop('disabled', true);
+ this.$('.reg_zip').prop('disabled', true);
+ this.$('.reg_country').prop('disabled', true);
+ },
+
+ unLockForm: function(){
+ this.$('.reg_fname').prop('disabled', false);
+ this.$('.reg_lname').prop('disabled', false);
+ this.$('.reg_addr1').prop('disabled', false);
+ this.$('.reg_addr2').prop('disabled', false);
+ this.$('.reg_city').prop('disabled', false);
+ this.$('.reg_state').prop('disabled', false);
+ this.$('.reg_zip').prop('disabled', false);
+ this.$('.reg_country').prop('disabled', false);
+ },
+
});
var zip = this.$('.reg_zip').val().trim();
var country = this.$('.reg_country').val().trim();
var rTime = this.$('#reg-select-time').val().trim();
+ if ( !rTime ) {
+ alert( 'You must select a time!' );
+ return;
+ }
if ( fname === '' || lname === '' ) {
alert( 'First and Last name required!' );
return;
template: _.template( jQuery('#eventReg-registrant-add').html() ),
events: {
+ 'focusout .reg_email': 'verifyEmail'
},
initialize: function(){
return this;
},
+ verifyEmail: function(){
+ var email = this.$('.reg_email').val().trim();
+ if ( email == '' ) {
+ return;
+ }
+ console.log( 'Verify Email called' );
+ var isValidEmail = app.isValidEmail( email );
+ if ( !isValidEmail ) {
+ alert( 'Email must be valid' );
+ } else {
+ // Check to see if this is a valid email.
+ jQuery.ajax({
+ context: this,
+ url: ajaxUrl + '&glm_action=account&option=checkEmail',
+ dataType: 'json',
+ 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.$('.reg_fname').val(account.fname);
+ this.$('.reg_lname').val(account.lname);
+
+ // lock the form
+ this.lockForm();
+ } else {
+ // They should be able to edit the form
+ this.unLockForm();
+ }
+ })
+ .fail(function(msg){
+ console.log('Fail: ' + msg);
+ });
+ }
+ },
+
+ lockForm: function(){
+ this.$('.reg_fname').prop('disabled', true);
+ this.$('.reg_lname').prop('disabled', true);
+ this.$('.reg_addr1').prop('disabled', true);
+ this.$('.reg_addr2').prop('disabled', true);
+ this.$('.reg_city').prop('disabled', true);
+ this.$('.reg_state').prop('disabled', true);
+ this.$('.reg_zip').prop('disabled', true);
+ this.$('.reg_country').prop('disabled', true);
+ },
+
+ unLockForm: function(){
+ this.$('.reg_fname').prop('disabled', false);
+ this.$('.reg_lname').prop('disabled', false);
+ this.$('.reg_addr1').prop('disabled', false);
+ this.$('.reg_addr2').prop('disabled', false);
+ this.$('.reg_city').prop('disabled', false);
+ this.$('.reg_state').prop('disabled', false);
+ this.$('.reg_zip').prop('disabled', false);
+ this.$('.reg_country').prop('disabled', false);
+ },
+
});
case 'checkEmail':
if ( $email = filter_var( $_REQUEST['email'], FILTER_VALIDATE_EMAIL ) ) {
- $accountId = $this->wpdb->get_var(
+ $accountData = $this->wpdb->get_row(
$this->wpdb->prepare(
- "SELECT id
+ "SELECT id,fname,lname
FROM " . GLM_MEMBERS_REGISTRATIONS_PLUGIN_DB_PREFIX . "account
WHERE email = %s",
$email
- )
+ ),
+ ARRAY_A
);
+ $accountId = $accountData['id'];
+ $fname = $accountData['fname'];
+ $lname = $accountData['lname'];
if ( $accountId ) {
$return = array(
'valid' => true,
'validEmail' => true,
'id' => (int)$accountId,
'email' => $email,
+ 'fname' => $fname,
+ 'lname' => $lname,
);
} else {
$return = array(
Models: { Front: {}, Admin: {} },
Collections: { Front: {}, Admin: {} },
Views: { Front: {}, Admin: {} },
+ isValidEmail: function( email ){
+ var regex = {literal}/^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;{/literal}
+ return regex.test(email);
+ },
initFullCalendar: function(){
if ({$regEvent.time_specific.value}) {
$('#eventCalendar').fullCalendar({