I also wanted the option of blank emails since many of our customers do not use email. Since it looks like the system keys off of unique emails, I came up with a workaround. It's a bit ugly but seems to be working so far.
1) I modified book.php to no longer require an email (just took out "required")
<input type="text" id=“email” class="form-control"maxlength="250"
2) I modified general_functions.js to validate emails as valid if (email == '')
- I did it this way rather than skipping validation completely as I want validation if there is some text in the email field. I'm just assuming that if the user leave it blank, it's on purpose
if (email == '') {
return true;
} else {
return re.test(email);
}
3) I modified Customers_model.php in 2 places
- I only validate email if it is not blank (identical to new behavior in general_functions.js)
- And before the customer data is inserted or updated into the data, I generate a uniqueID (based off of the timestamp) and append to our "@_____,com" email domain. I then assign this value to the email. This way, each customer with a blank email now has a unique email and the calendars can still render properly.
if (($customer['email'])=='') {
$customer['email'] = uniqid("appt-",TRUE) . "@dummy_domain.com"; }
- I add the "appt-" prefix so I can easily flag dummy emails later if needed.
*** I realize this is a bit of a hack and messing up the elegant code but it was the only way I could figure out how to allow blank emails. Please let me know if anyone has any recommendations on how to improve this.
Thanks,
Paul