Forums / Bug Reports / [Done v1.3.9] Problem with customer's date of birth in admin

[Done v1.3.9] Problem with customer's date of birth in admin

Locked

Started by sanji on 27 Dec 2007, 2:45 PM · Views: 4,733

Results 1 to 3 of 3
This thread is locked. New replies are disabled.
27 Dec 2007, 2:45 PM
#1
sanji avatar

sanji

Zen Follower

Join Date:
Jan 2005
Posts:
138
Plugin Contributions:
0

[Done v1.3.9] Problem with customer's date of birth in admin

I noticed that if, in Configuration / Minimum Values the Date of Birth parameter is set to 0, then there is an issue when you try to change the date of birth of a customer in the admin part : after you submit your changes, no error message will be displayed by the date will be set to 0001-01-01...

Example (verified on my 1.3.8a cart and on a fresh install) :

Set Configuration / Minimum Values, Date of Birth = 0
Go to admin/customers.php
Select any profile, click on Edit
Change the Date of Birth to anything you want, or even don't change it at all
Submit the changes
Click again on Edit -> the date of birth has disappeared.

I think the problem comes from admin/customers.php file, where:

        if (ACCOUNT_DOB == 'true') {
          if (ENTRY_DOB_MIN_LENGTH >0) {
            if (checkdate(substr(zen_date_raw($customers_dob), 4, 2), substr(zen_date_raw($customers_dob), 6, 2), substr(zen_date_raw($customers_dob), 0, 4))) {
              $entry_date_of_birth_error = false;
            } else {
              $error = true;
              $entry_date_of_birth_error = true;
            }
          } else {
            $customers_dob = '0001-01-01 00:00:00';
          }
        }

If ENTRY_DOB_MIN_LENGTH = 0, the date of birth is automatically set to 0001-01-01 00:00:00

sanji

27 Dec 2007, 5:45 PM
#2
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: [Done v1.3.9] Problem with customer's date of birth in admin

sanji:

    if (ACCOUNT_DOB == 'true') {
      if (ENTRY_DOB_MIN_LENGTH >0) {
        if (checkdate(substr(zen_date_raw($customers_dob), 4, 2), substr(zen_date_raw($customers_dob), 6, 2), substr(zen_date_raw($customers_dob), 0, 4))) {
          $entry_date_of_birth_error = false;
        } else {
          $error = true;
          $entry_date_of_birth_error = true;
        }

[B] } else {
$customers_dob = '0001-01-01 00:00:00';
}
}
[/B]


Yes -- rearrange the highlighted lines, as shown:
    if (ACCOUNT_DOB == 'true') {
      if (ENTRY_DOB_MIN_LENGTH >0) {
        if (checkdate(substr(zen_date_raw($customers_dob), 4, 2), substr(zen_date_raw($customers_dob), 6, 2), substr(zen_date_raw($customers_dob), 0, 4))) {
          $entry_date_of_birth_error = false;
        } else {
          $error = true;
          $entry_date_of_birth_error = true;
        }

[B] }
} else {
$customers_dob = '0001-01-01 00:00:00';
}[/B]

And, then if you want the DOB to be optional, set the Minimum Value for DOB to blank instead of 0 (otherwise the admin will pop up an alert saying it's not filled in).

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

28 Dec 2007, 12:07 AM
#3
sanji avatar

sanji

Zen Follower

Join Date:
Jan 2005
Posts:
138
Plugin Contributions:
0

Re: [Done v1.3.9] Problem with customer's date of birth in admin

Thanks DrByte ;)

sanji