added more validation to customer guest, fixed issue after merge

This commit is contained in:
vishalsingh.qlo325
2025-05-16 15:43:57 +05:30
parent 187a913818
commit 2d6bc3ef6e
5 changed files with 15 additions and 37 deletions

View File

@@ -1224,14 +1224,6 @@ class AdminCustomersControllerCore extends AdminController
$this->errors[] = Tools::displayError('Phone number is required.');
}
}
$className = 'CustomerGuestDetail';
$rules = call_user_func(array($className, 'getValidationRules'), $className);
if ($phone && !Validate::isPhoneNumber($phone)) {
$this->errors[] = Tools::displayError('Invaid phone number.');
} elseif ($phone && Tools::strlen($phone) > $rules['size']['phone']) {
$this->errors[] = sprintf(Tools::displayError('Phone number is too long. (%s chars max).'), $rules['size']['phone']);
}
$customer = new Customer();
$this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase());
@@ -1478,6 +1470,18 @@ class AdminCustomersControllerCore extends AdminController
if ($this->tabAccess['edit'] == 1) {
if (Validate::isLoadedObject($objCustomerGuestDetail = new CustomerGuestDetail((int) Tools::getValue('id_customer_guest_detail')))) {
$response['errors'] = $objCustomerGuestDetail->validateController();
if (!Tools::getValue('lastname')) {
$response['errors']['lastname'] = Tools::displayError('lastname is required');
}
if (!Tools::getValue('firstname')) {
$response['errors']['firstname'] = Tools::displayError('firstname is required');
}
if (!Tools::getValue('email')) {
$response['errors']['email'] = Tools::displayError('email is required');
}
if (!Tools::getValue('phone')) {
$response['errors']['phone'] = Tools::displayError('phone is required');
}
if (!$response['errors']) {
$objCustomerGuestDetail->id_gender = Tools::getValue('id_gender');
$objCustomerGuestDetail->firstname = Tools::getValue('firstname');

View File

@@ -422,16 +422,8 @@ class AuthControllerCore extends FrontController
$addresses_types[] = 'address_invoice';
}
$className = 'CustomerGuestDetail';
$rules = call_user_func(array($className, 'getValidationRules'), $className);
if (Configuration::get('PS_ONE_PHONE_AT_LEAST') && !Tools::getValue('phone')) {
$this->errors[] = Tools::displayError('Phone number is required.');
} else {
if (Tools::getValue('phone') && !Validate::isPhoneNumber(Tools::getValue('phone'))) {
$this->errors[] = Tools::displayError('Invald phone number.');
} elseif (Tools::getValue('phone') && Tools::strlen(Tools::getValue('phone')) > $rules['size']['phone']) {
$this->errors[] = sprintf(Tools::displayError('Phone number is too long. (%s chars max).'), $rules['size']['phone']);
}
}
if (!Tools::getValue('is_new_customer', 1)) {

View File

@@ -89,17 +89,8 @@ class IdentityControllerCore extends FrontController
}
}
$className = 'CustomerGuestDetail';
$rules = call_user_func(array($className, 'getValidationRules'), $className);
if ($phone && !Validate::isPhoneNumber($phone)) {
$this->errors[] = Tools::displayError('Invaid phone number.');
} elseif ($phone && Tools::strlen($phone) > $rules['size']['phone']) {
$this->errors[] = sprintf(Tools::displayError('Phone number is too long. (%s chars max).'), $rules['size']['phone']);;
} else {
$this->customer->phone = $phone;
}
if (!count($this->errors)) {
$this->customer->phone = $phone;
$this->customer->id_default_group = (int)$prev_id_default_group;
$this->customer->firstname = Tools::ucwords($this->customer->firstname);

View File

@@ -120,16 +120,7 @@ class OrderOpcControllerCore extends ParentOrderController
$this->errors[] = Tools::displayError('Phone number is a required field.', false);
}
$className = 'CustomerGuestDetail';
$rules = call_user_func(array($className, 'getValidationRules'), $className);
if (!Validate::isPhoneNumber($phone)) {
$this->errors[] = Tools::displayError('Please enter a valid Mobile phone number.', false);
} elseif (Tools::strlen($phone) > $rules['size']['phone']) {
$this->errors[] = sprintf(Tools::displayError('Mobile phone number is too long. (%s chars max).'), $rules['size']['phone']);
} else {
$this->context->customer->phone = $phone;
}
$this->context->customer->phone = $phone;
$_POST['lastname'] = $_POST['customer_lastname'];
$_POST['firstname'] = $_POST['customer_firstname'];
$this->errors = array_merge($this->errors, $this->context->customer->validateController());

View File

@@ -35,7 +35,7 @@
</div>
<div class="row">
<div class="col-sm-12 search_result_info">
{$search_data['htl_dtl']['hotel_name']|escape:'htmlall':'UTF-8'}, {$search_data['htl_dtl']['city']|escape:'htmlall':'UTF-8'} {if !$search_data['order_date_restrict']}<img src="{$module_dir}views/img/icon-arrow-left.svg"> {$search_data['date_from']|escape:'htmlall':'UTF-8'|date_format:"%d %b %Y"} - {$search_data['date_to']|escape:'htmlall':'UTF-8'|date_format:"%d %b %Y"}<span class="faded-txt"> ({1+$search_data['num_days']|escape:'htmlall':'UTF-8'} {l s='Days' mod='wkroomsearchblock'} {$search_data['num_days']|escape:'htmlall':'UTF-8'} {if $search_data['num_days'] > 1}{l s='Nights' mod='wkroomsearchblock'}{else}{l s='Night' mod='wkroomsearchblock'}{/if})</span> {/if}
{$search_data['htl_dtl']['hotel_name']|escape:'htmlall':'UTF-8'}, {$search_data['htl_dtl']['city']|escape:'htmlall':'UTF-8'} {if !$search_data['order_date_restrict']}<img src="{$module_dir}views/img/icon-arrow-left.svg"> {if (isset($search_data['date_from']))}{$search_data['date_from']|escape:'htmlall':'UTF-8'|date_format:"%d %b %Y"}{/if} - {if isset($search_data['date_to'])}{$search_data['date_to']|escape:'htmlall':'UTF-8'|date_format:"%d %b %Y"}{/if}<span class="faded-txt"> ({1+$search_data['num_days']|escape:'htmlall':'UTF-8'} {l s='Days' mod='wkroomsearchblock'} {$search_data['num_days']|escape:'htmlall':'UTF-8'} {if $search_data['num_days'] > 1}{l s='Nights' mod='wkroomsearchblock'}{else}{l s='Night' mod='wkroomsearchblock'}{/if})</span> {/if}
</div>
</div>
</div>