diff --git a/controllers/admin/AdminCustomerPreferencesController.php b/controllers/admin/AdminCustomerPreferencesController.php index 00c2a9e68..a1e3bb67e 100644 --- a/controllers/admin/AdminCustomerPreferencesController.php +++ b/controllers/admin/AdminCustomerPreferencesController.php @@ -99,6 +99,13 @@ class AdminCustomerPreferencesControllerCore extends AdminController 'cast' => 'intval', 'type' => 'bool' ), + 'PS_CUSTOMER_BIRTHDATE' => array( + 'title' => $this->l('Ask for birth date'), + 'hint' => $this->l('Display or not the birth date field.'), + 'validation' => 'isBool', + 'cast' => 'intval', + 'type' => 'bool' + ), 'PS_CUSTOMER_NWSL' => array( 'title' => $this->l('Enable newsletter registration'), 'hint' => $this->l('Display or not the newsletter registration tick box.'), diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 320da13dd..f13822d55 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -102,6 +102,7 @@ class AuthControllerCore extends FrontController $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active); + $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE')); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); @@ -463,9 +464,11 @@ class AuthControllerCore extends FrontController $this->processCustomerNewsletter($customer); $customer->firstname = Tools::ucwords($customer->firstname); - $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); - if (!Validate::isBirthDate($customer->birthday)) { - $this->errors[] = Tools::displayError('Invalid date of birth.'); + if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) { + $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); + if (!Validate::isBirthDate($customer->birthday)) { + $this->errors[] = Tools::displayError('Invalid date of birth.'); + } } // New Guest customer @@ -594,9 +597,11 @@ class AuthControllerCore extends FrontController $this->processCustomerNewsletter($customer); - $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); - if (!Validate::isBirthDate($customer->birthday)) { - $this->errors[] = Tools::displayError('Invalid date of birth'); + if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) { + $customer->birthday = (empty($_POST['years']) ? '' : (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days')); + if (!Validate::isBirthDate($customer->birthday)) { + $this->errors[] = Tools::displayError('Invalid date of birth'); + } } if (!count($this->errors)) { diff --git a/controllers/front/IdentityController.php b/controllers/front/IdentityController.php index ea8c2af16..68789e42a 100644 --- a/controllers/front/IdentityController.php +++ b/controllers/front/IdentityController.php @@ -53,12 +53,14 @@ class IdentityControllerCore extends FrontController $email = trim(Tools::getValue('email')); - if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') { - $this->customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'); - } elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') { - $this->customer->birthday = null; - } else { - $this->errors[] = Tools::displayError('Invalid date of birth.'); + if (Configuration::get('PS_CUSTOMER_BIRTHDATE')) { + if (Tools::getValue('months') != '' && Tools::getValue('days') != '' && Tools::getValue('years') != '') { + $this->customer->birthday = (int)Tools::getValue('years').'-'.(int)Tools::getValue('months').'-'.(int)Tools::getValue('days'); + } elseif (Tools::getValue('months') == '' && Tools::getValue('days') == '' && Tools::getValue('years') == '') { + $this->customer->birthday = null; + } else { + $this->errors[] = Tools::displayError('Invalid date of birth.'); + } } if (Tools::getIsset('old_passwd')) { @@ -152,6 +154,7 @@ class IdentityControllerCore extends FrontController )); $newsletter = Configuration::get('PS_CUSTOMER_NWSL') || (Module::isInstalled('blocknewsletter') && Module::getInstanceByName('blocknewsletter')->active); + $this->context->smarty->assign('birthday', (bool) Configuration::get('PS_CUSTOMER_BIRTHDATE')); $this->context->smarty->assign('newsletter', $newsletter); $this->context->smarty->assign('optin', (bool)Configuration::get('PS_CUSTOMER_OPTIN')); diff --git a/install/data/xml/configuration.xml b/install/data/xml/configuration.xml index 935de20ba..ba0e173c8 100644 --- a/install/data/xml/configuration.xml +++ b/install/data/xml/configuration.xml @@ -878,6 +878,9 @@ 1 + + 1 + 1 diff --git a/themes/hotel-reservation-theme/authentication.tpl b/themes/hotel-reservation-theme/authentication.tpl index 393e1f4c8..555f52585 100644 --- a/themes/hotel-reservation-theme/authentication.tpl +++ b/themes/hotel-reservation-theme/authentication.tpl @@ -464,49 +464,51 @@ {l s='(Five characters minimum)'} -
- -
-
- - {* - {l s='January'} - {l s='February'} - {l s='March'} - {l s='April'} - {l s='May'} - {l s='June'} - {l s='July'} - {l s='August'} - {l s='September'} - {l s='October'} - {l s='November'} - {l s='December'} - *} -
-
- -
-
- + {if isset($birthday) && $birthday} +
+ +
+
+ + {* + {l s='January'} + {l s='February'} + {l s='March'} + {l s='April'} + {l s='May'} + {l s='June'} + {l s='July'} + {l s='August'} + {l s='September'} + {l s='October'} + {l s='November'} + {l s='December'} + *} +
+
+ +
+
+ +
-
+ {/if} {if isset($newsletter) && $newsletter}
diff --git a/themes/hotel-reservation-theme/identity.tpl b/themes/hotel-reservation-theme/identity.tpl index b84a30800..464cbafba 100644 --- a/themes/hotel-reservation-theme/identity.tpl +++ b/themes/hotel-reservation-theme/identity.tpl @@ -84,51 +84,53 @@
-
- -
-
- -
-
- {* - {l s='January'} - {l s='February'} - {l s='March'} - {l s='April'} - {l s='May'} - {l s='June'} - {l s='July'} - {l s='August'} - {l s='September'} - {l s='October'} - {l s='November'} - {l s='December'} - *} - -
-
- + {if isset($birthday) && $birthday} +
+ +
+
+ +
+
+ {* + {l s='January'} + {l s='February'} + {l s='March'} + {l s='April'} + {l s='May'} + {l s='June'} + {l s='July'} + {l s='August'} + {l s='September'} + {l s='October'} + {l s='November'} + {l s='December'} + *} + +
+
+ +
-
+ {/if}