Appointments made with duplicate emails wipe out existing customer details

254 views
Skip to first unread message

paul...@gmail.com

unread,
Jun 16, 2018, 7:02:21 PM6/16/18
to Easy!Appointments - Support Group
Hi,

It looks like the appointment info is displayed / aggregated based on the email.  I know that when I create a customer/appt fro the backend and use an existing email, I get an error re: "duplicate email."  However, if a customer uses the front end and re-uses an email, all the previous customer info is wiped out.  For example, this happens when a parent is booking for their child and is just using the parent's email address.  In this case, all the appointments then show the name of the last person booking an appointment.

Is this the expected behavior, or is there some way to key off of the customer ID?



Thanks,

Paul

paul...@gmail.com

unread,
Jun 17, 2018, 1:09:30 AM6/17/18
to Easy!Appointments - Support Group
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

paul...@gmail.com

unread,
Jun 17, 2018, 1:53:20 AM6/17/18
to Easy!Appointments - Support Group
If you want to allow blank emails when added customers in the backend, you need to also take out "required" from customers.php (same as book.php)

Histo Sem

unread,
Jun 27, 2018, 9:36:21 AM6/27/18
to Easy!Appointments - Support Group
I don't have a better solution but just wanted to give some feedback. This is a good solution for the problem. Of course, it would be far more elegant if the customer id were produced from a combination of first and last name, in this case one could simply remove the "required" and the asterisk from the book.php, but we will need Alex to implement this solution in a newer version. (Otherwise, if some of us do it on our own, we will most probably get into trouble at the next update.)

As you have correctly pointed out, the method Alex uses with taking the e-mail-address as the costumer id and overwriting old customer data with new ones once the same address is used with other name etc. has its serious limitations in many every day life scenarios, that were not that obvious at the time of app development. I really hope, he will switch to a different method in the future.

For the time being your solution seems to be not that "dirty" but rather very convenient and easily applicable.


Mickey Fox

unread,
Aug 26, 2018, 9:24:00 AM8/26/18
to Easy!Appointments - Support Group
Just agreeing with Histo here. It would be really nice to see a user id/name as a unique database value for both logins and record maintenance - especially as this would help with integrating other applications.

Andreas Hanny

unread,
Mar 11, 2021, 1:59:49 PM3/11/21
to Easy!Appointments - Support Group
Hi Paul,

I've got the same problem, just don't know where to put the code in Customers_model.php, can you please help me? I just need the option 3), I want to add the uniqueID to every new created customer mail.

Thank you very much!!!!!!

Andreas

Andreas Hanny

unread,
Mar 11, 2021, 2:05:30 PM3/11/21
to Easy!Appointments - Support Group
Ok,

found it and I'll publish it, maybe it will help someone:

    public function add($customer)
    {
        // Validate the customer data before doing anything.
        $this->validate($customer);

        // Check if a customer already exists (by email).
        if ($this->exists($customer) && ! isset($customer['id']))
        {
            // Find the customer id from the database.
            $customer['id'] = $this->find_record_id($customer);
        }
        $customer['email'] .= uniqid("appt-",TRUE) . "@dummy_domain.com"; // this is the modification

        // Insert or update the customer record.
        if ( ! isset($customer['id']))
        {
            $customer['id'] = $this->insert($customer);
        }
        else
        {
            $this->update($customer);
        }

        return $customer['id'];
    }
Reply all
Reply to author
Forward
0 new messages