From e02e45b8e253491e06c81df69ea6c90e3563d143 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Fri, 9 Feb 2024 15:01:01 +0530 Subject: [PATCH] Move customer support options --- .../AdminHotelGeneralSettingsController.php | 25 ++++++++++ .../hotelreservationsystem.php | 49 +++---------------- .../views/templates/hook/display-nav.tpl | 4 +- .../hook/external-navigation-hook.tpl | 6 +-- 4 files changed, 36 insertions(+), 48 deletions(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index b1cd6cfb7..30b34ea38 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -149,6 +149,7 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'type' => 'text', 'isCleanHtml' => true, 'class' => 'fixed-width-xxl', + 'required' => true, ), 'WK_HOTEL_GLOBAL_CONTACT_NUMBER' => array( 'title' => $this->l('Main Branch Phone Number'), @@ -156,12 +157,26 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'type' => 'text', 'validation' => 'isPhoneNumber', 'class' => 'fixed-width-xxl', + 'required' => true, ), 'WK_HOTEL_GLOBAL_CONTACT_EMAIL' => array( 'title' => $this->l('Main Branch Email'), 'hint' => $this->l('The email address of the main branch. It will be shown on Contact Us page.'), 'type' => 'text', 'class' => 'fixed-width-xxl', + 'required' => true, + ), + 'WK_CUSTOMER_SUPPORT_PHONE_NUMBER' => array( + 'title' => $this->l('Support Phone Number'), + 'type' => 'text', + 'hint' => $this->l('The phone number used for customer service. It will be shown on navigation bar.'), + 'class' => 'fixed-width-xxl', + ), + 'WK_CUSTOMER_SUPPORT_EMAIL' => array( + 'title' => $this->l('Support Email'), + 'type' => 'text', + 'hint' => $this->l('The email used for customer service. It will be shown on navigation bar.'), + 'class' => 'fixed-width-xxl', ), ), 'submit' => array( @@ -384,6 +399,16 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController } elseif (!Validate::isEmail(Tools::getValue('WK_HOTEL_GLOBAL_CONTACT_EMAIL'))) { $this->errors[] = $this->l('Hotel global contact email field is invalid'); } + if (trim(Tools::getValue('WK_CUSTOMER_SUPPORT_PHONE_NUMBER')) != '') { + if (!Validate::isPhoneNumber(trim(Tools::getValue('WK_CUSTOMER_SUPPORT_PHONE_NUMBER')))) { + $this->errors[] = $this->l('Support Phone Number is invalid.'); + } + } + if (trim(Tools::getValue('WK_CUSTOMER_SUPPORT_EMAIL')) != '') { + if (!Validate::isEmail(trim(Tools::getValue('WK_CUSTOMER_SUPPORT_EMAIL')))) { + $this->errors[] = $this->l('Support Email is invalid.'); + } + } if (!count($this->errors)) { $objHotelInfo = new HotelBranchInformation(); diff --git a/modules/hotelreservationsystem/hotelreservationsystem.php b/modules/hotelreservationsystem/hotelreservationsystem.php index f41c073c8..8975e6faf 100644 --- a/modules/hotelreservationsystem/hotelreservationsystem.php +++ b/modules/hotelreservationsystem/hotelreservationsystem.php @@ -103,7 +103,12 @@ class HotelReservationSystem extends Module public function hookActionFrontControllerSetMedia() { - $this->context->controller->addCSS($this->getPathUri().'views/css/hook/display-nav.css'); + if (Configuration::get('WK_CUSTOMER_SUPPORT_PHONE_NUMBER') != '' + || Configuration::get('WK_CUSTOMER_SUPPORT_EMAIL') != '' + ) { + $this->context->controller->addCSS($this->getPathUri().'views/css/hook/display-nav.css'); + } + } public function hookDisplayNav() @@ -126,46 +131,6 @@ class HotelReservationSystem extends Module return $this->display(__FILE__, 'external-navigation-hook.tpl'); } - public function hookActionAdminHotelGeneralSettingsOptionsModifier($params) - { - $params['options']['contactdetail']['fields'] = array_merge( - $params['options']['contactdetail']['fields'], - array( - 'WK_CUSTOMER_SUPPORT_PHONE_NUMBER' => array( - 'title' => $this->l('Support Phone Number'), - 'type' => 'text', - 'hint' => $this->l('The phone number used for customer service. It will be shown on navigation bar.'), - 'class' => 'fixed-width-xxl', - ), - 'WK_CUSTOMER_SUPPORT_EMAIL' => array( - 'title' => $this->l('Support Email'), - 'type' => 'text', - 'hint' => $this->l('The email used for customer service. It will be shown on navigation bar.'), - 'class' => 'fixed-width-xxl', - ), - ) - ); - } - - public function hookActionAdminHotelGeneralSettingsControllerUpdate_optionsBefore() - { - $phone = Tools::getValue('WK_CUSTOMER_SUPPORT_PHONE_NUMBER'); - $email = Tools::getValue('WK_CUSTOMER_SUPPORT_EMAIL'); - - if ($phone != '' && !Validate::isPhoneNumber($phone)) { - $this->context->controller->errors[] = $this->l('Support Phone Number is invalid.'); - } - - if ($email != '' && !Validate::isEmail($email)) { - $this->context->controller->errors[] = $this->l('Support Email is invalid.'); - } - - if (!count($this->context->controller->errors)) { - Configuration::updateValue('WK_CUSTOMER_SUPPORT_PHONE_NUMBER', $phone); - Configuration::updateValue('WK_CUSTOMER_SUPPORT_EMAIL', $email); - } - } - public function cartBookingDataForMail($order) { $result = array(); @@ -703,8 +668,6 @@ class HotelReservationSystem extends Module 'actionFrontControllerSetMedia', 'displayNav', 'displayExternalNavigationHook', - 'actionAdminHotelGeneralSettingsOptionsModifier', - 'actionAdminHotelGeneralSettingsControllerUpdate_optionsBefore', ) ); } diff --git a/modules/hotelreservationsystem/views/templates/hook/display-nav.tpl b/modules/hotelreservationsystem/views/templates/hook/display-nav.tpl index de3a1a783..a18db23ab 100644 --- a/modules/hotelreservationsystem/views/templates/hook/display-nav.tpl +++ b/modules/hotelreservationsystem/views/templates/hook/display-nav.tpl @@ -17,13 +17,13 @@ * @license LICENSE.txt *} -{if $email} +{if $email != ''}
{$email}
{/if} -{if $phone} +{if $phone != ''}
{$phone} diff --git a/modules/hotelreservationsystem/views/templates/hook/external-navigation-hook.tpl b/modules/hotelreservationsystem/views/templates/hook/external-navigation-hook.tpl index 4c20672cb..d7b3f27be 100644 --- a/modules/hotelreservationsystem/views/templates/hook/external-navigation-hook.tpl +++ b/modules/hotelreservationsystem/views/templates/hook/external-navigation-hook.tpl @@ -17,9 +17,9 @@ * @license LICENSE.txt *} -{if $email || $phone} +{if ($email != '') || ($phone != '')}