From 2b405eed03b0c88b3eeedaa6929cfc8d1711fe88 Mon Sep 17 00:00:00 2001 From: Abhishek Kumar Date: Wed, 13 Sep 2023 15:19:15 +0530 Subject: [PATCH] Move Support contact settings to Settings page --- .../default/sass/partials/_commons.sass | 7 +- .../themes/default/sass/vendor/_animate.sass | 26 +++- .../admin/AdminPPreferencesController.php | 9 ++ .../AdminHotelGeneralSettingsController.php | 117 +++++++++--------- modules/qloblockcontact/qloblockcontact.php | 103 ++++++--------- 5 files changed, 140 insertions(+), 122 deletions(-) diff --git a/admin/themes/default/sass/partials/_commons.sass b/admin/themes/default/sass/partials/_commons.sass index 588ef7d53..82fb046af 100644 --- a/admin/themes/default/sass/partials/_commons.sass +++ b/admin/themes/default/sass/partials/_commons.sass @@ -215,4 +215,9 @@ padding: 8px 12px text-transform: none label - font-weight: 400 \ No newline at end of file + font-weight: 400 + +.panel:target, +.panel:target .panel-footer + scroll-margin-top: 180px + animation: flashBgYellow 1.5s \ No newline at end of file diff --git a/admin/themes/default/sass/vendor/_animate.sass b/admin/themes/default/sass/vendor/_animate.sass index 025948818..54798c10d 100644 --- a/admin/themes/default/sass/vendor/_animate.sass +++ b/admin/themes/default/sass/vendor/_animate.sass @@ -434,6 +434,12 @@ 100% -webkit-transform: scale(1) rotate(0) +@-webkit-keyframes flashBgYellow + 0% + background: #fbe986 + 100% + background: #ffffff + @-moz-keyframes fadeIn 0% opacity: 0 @@ -862,6 +868,12 @@ 100% -moz-transform: scale(1) rotate(0) +@-moz-keyframes flashBgYellow + 0% + background: #fbe986 + 100% + background: #ffffff + @-ms-keyframes fadeIn 0% opacity: 0 @@ -1290,6 +1302,12 @@ 100% -ms-transform: scale(1) rotate(0) +@-ms-keyframes flashBgYellow + 0% + background: #fbe986 + 100% + background: #ffffff + @keyframes fadeIn 0% opacity: 0 @@ -1716,4 +1734,10 @@ 90% transform: scale(1.1) rotate(3deg) 100% - transform: scale(1) rotate(0) \ No newline at end of file + transform: scale(1) rotate(0) + +@keyframes flashBgYellow + 0% + background: #fbe986 + 100% + background: #ffffff \ No newline at end of file diff --git a/controllers/admin/AdminPPreferencesController.php b/controllers/admin/AdminPPreferencesController.php index 1ea8b3f50..117b95cfa 100644 --- a/controllers/admin/AdminPPreferencesController.php +++ b/controllers/admin/AdminPPreferencesController.php @@ -194,6 +194,15 @@ class AdminPPreferencesControllerCore extends AdminController 'required' => false, 'type' => 'bool' ), + 'WK_ROOM_LEFT_WARNING_NUMBER' => array( + 'title' => $this->l('Display remaining Number of rooms when the rooms are lower than or equal to'), + 'hint' => $this->l('Mention the minimum quantity of rooms after which alert message of remaining rooms will get displayed to users.'), + 'validation' => 'isInt', + 'cast' => 'intval', + 'type' => 'text', + 'class' => 'fixed-width-xxl', + 'visibility' => Shop::CONTEXT_ALL, + ), ), 'submit' => array('title' => $this->l('Save')) ), diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php index 74e120141..fb90b7d54 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelGeneralSettingsController.php @@ -43,7 +43,7 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController $this->fields_options = array( 'hotelsearchpanel' => array( 'icon' => 'icon-search', - 'title' => $this->l('Hotel Search Setting'), + 'title' => $this->l('Search Panel Setting'), 'fields' => array( 'WK_HOTEL_LOCATION_ENABLE' => array( 'title' => $this->l('Enable Hotel Location'), @@ -86,65 +86,9 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'title' => $this->l('Save'), ), ), - 'occupancypanel' => array( - 'icon' => 'icon-users', - 'title' => $this->l('Occupancy Setting'), - 'fields' => array( - // max age of child - 'WK_GLOBAL_CHILD_MAX_AGE' => array( - 'title' => $this->l('Consider guest as child below age'), - 'type' => 'text', - 'required' => true, - 'validation' => 'isUnsignedInt', - 'hint' => $this->l('Enter the age of the guest, which that guest will be considered as child.'), - ), - 'WK_GLOBAL_MAX_CHILD_IN_ROOM' => array( - 'title' => $this->l('Maximum children allowed in a room'), - 'type' => 'text', - 'required' => true, - 'validation' => 'isUnsignedInt', - 'hint' => $this->l('Enter number of the child allowed in a room.'), - 'desc' => $this->l('Set as 0 if you do not want to limit children in a room.') - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - ), - ), 'generalsetting' => array( - 'title' => $this->l('Configuration'), + 'title' => $this->l('Website Configuration'), 'fields' => array( - 'WK_ROOM_LEFT_WARNING_NUMBER' => array( - 'title' => $this->l('Display remaining Number of rooms when the rooms are lower than or equal to'), - 'hint' => $this->l('Mention the minimum quantity of rooms after which alert message of remaining rooms will get displayed to users.'), - 'validation' => 'isInt', - 'cast' => 'intval', - 'type' => 'text', - 'visibility' => Shop::CONTEXT_ALL, - ), - 'WK_HOTEL_GLOBAL_ADDRESS' => array( - 'title' => $this->l('Global Address'), - 'hint' => $this->l('Hotel global address which you want to show to your customers. It will be - shown at contact us page.'), - 'type' => 'text', - 'isCleanHtml' => true, - ), - 'WK_HOTEL_GLOBAL_CONTACT_EMAIL' => array( - 'title' => $this->l('Global Email'), - 'hint' => $this->l('Email which you want to show a customer to email you.'), - 'type' => 'text', - ), - 'WK_HOTEL_GLOBAL_CONTACT_NUMBER' => array( - 'title' => $this->l('Global Contact Number'), - 'hint' => $this->l('Phone Number which you want to show a customer to contact you.'), - 'type' => 'text', - 'validation' => 'isPhoneNumber', - ), - 'WK_HTL_ESTABLISHMENT_YEAR' => array( - 'title' => $this->l('Website Launch Year'), - 'hint' => $this->l('The year when your hotel site was launched.'), - 'type' => 'text', - ), 'WK_PRIMARY_HOTEL' => array( 'title' => $this->l('Primary hotel'), 'hint' => $this->l('Primary hotel is used to default address for your business. The hotel address will be considered as your registered business address.'), @@ -178,6 +122,11 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController 'validation' => 'isGenericName', 'hint' => $this->l('This will display hotel short description in footer. Note: number of letters must be less than 220.'), ), + 'WK_HTL_ESTABLISHMENT_YEAR' => array( + 'title' => $this->l('Website Launch Year'), + 'hint' => $this->l('The year when your hotel site was launched.'), + 'type' => 'text', + ), 'WK_HTL_HEADER_IMAGE' => array( 'title' => $this->l('Header Background Image'), 'type' => 'file', @@ -189,6 +138,33 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController ), 'submit' => array('title' => $this->l('Save')), ), + 'contactdetail' => array( + 'icon' => 'icon-phone', + 'title' => $this->l('Website Contact Details'), + 'fields' => array( + 'WK_HOTEL_GLOBAL_ADDRESS' => array( + 'title' => $this->l('Global Address'), + 'hint' => $this->l('Hotel global address which you want to show to your customers. It will be + shown at contact us page.'), + 'type' => 'text', + 'isCleanHtml' => true, + ), + 'WK_HOTEL_GLOBAL_CONTACT_EMAIL' => array( + 'title' => $this->l('Global Email'), + 'hint' => $this->l('Email which you want to show a customer to email you.'), + 'type' => 'text', + ), + 'WK_HOTEL_GLOBAL_CONTACT_NUMBER' => array( + 'title' => $this->l('Global Contact Number'), + 'hint' => $this->l('Phone Number which you want to show a customer to contact you.'), + 'type' => 'text', + 'validation' => 'isPhoneNumber', + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + ), + ), 'advancedPayment' => array( 'title' => $this->l('Advance Payment Global Setting'), 'fields' => array( @@ -236,6 +212,31 @@ class AdminHotelGeneralSettingsController extends ModuleAdminController ), 'submit' => array('title' => $this->l('Save')), ), + 'occupancypanel' => array( + 'icon' => 'icon-users', + 'title' => $this->l('Occupancy Settings'), + 'fields' => array( + // max age of child + 'WK_GLOBAL_CHILD_MAX_AGE' => array( + 'title' => $this->l('Consider guest as child below age'), + 'type' => 'text', + 'required' => true, + 'validation' => 'isUnsignedInt', + 'hint' => $this->l('Enter the age of the guest, which that guest will be considered as child.'), + ), + 'WK_GLOBAL_MAX_CHILD_IN_ROOM' => array( + 'title' => $this->l('Maximum children allowed in a room'), + 'type' => 'text', + 'required' => true, + 'validation' => 'isUnsignedInt', + 'hint' => $this->l('Enter number of the child allowed in a room.'), + 'desc' => $this->l('Set as 0 if you do not want to limit children in a room.') + ), + ), + 'submit' => array( + 'title' => $this->l('Save'), + ), + ), 'googleMap' => array( 'title' => $this->l('Google Maps Settings'), 'fields' => array( diff --git a/modules/qloblockcontact/qloblockcontact.php b/modules/qloblockcontact/qloblockcontact.php index a12c23973..e65620a08 100644 --- a/modules/qloblockcontact/qloblockcontact.php +++ b/modules/qloblockcontact/qloblockcontact.php @@ -46,6 +46,8 @@ class QloBlockContact extends Module || !$this->registerHook('actionFrontControllerSetMedia') || !$this->registerHook('displayNav') || !$this->registerHook('displayExternalNavigationHook') + || !$this->registerHook('actionAdminHotelGeneralSettingsOptionsModifier') + || !$this->registerHook('actionAdminHotelGeneralSettingsControllerUpdate_optionsBefore') ) { return false; } @@ -54,14 +56,9 @@ class QloBlockContact extends Module public function getContent() { - if (Tools::isSubmit('submitModuleConfig')) { - Configuration::updateValue('QBC_PHONE', Tools::getValue('QBC_PHONE')); - Configuration::updateValue('QBC_EMAIL', Tools::getValue('QBC_EMAIL')); - Tools::redirectAdmin( - $this->context->link->getAdminLink('AdminModules').'&configure='.$this->name.'&conf=6' - ); - } - return $this->renderForm(); + Tools::redirectAdmin( + $this->context->link->getAdminLink('AdminHotelGeneralSettings').'#configuration_fieldset_contactdetail' + ); } public function hookActionFrontControllerSetMedia() @@ -78,56 +75,6 @@ class QloBlockContact extends Module return $this->display(__FILE__, 'display-nav.tpl'); } - public function renderForm() - { - $fields_form = array( - 'form' => array( - 'legend' => array( - 'title' => $this->l('Configuration'), - 'icon' => 'icon-cogs', - ), - 'input' => array( - array( - 'type' => 'text', - 'label' => $this->l('Phone'), - 'hint' => $this->l('The phone number used for customer service.'), - 'name' => 'QBC_PHONE', - 'class' => 'fixed-width-xxl', - ), - array( - 'type' => 'text', - 'label' => $this->l('Email'), - 'hint' => $this->l('The email used for customer service.'), - 'name' => 'QBC_EMAIL', - 'class' => 'fixed-width-xxl', - ), - ), - 'submit' => array( - 'title' => $this->l('Save'), - ) - ), - ); - - $helper = new HelperForm(); - $helper->show_toolbar = false; - $helper->table = $this->table; - $lang = new Language((int)Configuration::get('PS_LANG_DEFAULT')); - $helper->default_form_language = $lang->id; - $helper->allow_employee_form_lang = Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') ? Configuration::get('PS_BO_ALLOW_EMPLOYEE_FORM_LANG') : 0; - $this->fields_form = array(); - - $helper->identifier = $this->identifier; - $helper->submit_action = 'submitModuleConfig'; - $helper->currentIndex = $this->context->link->getAdminLink('AdminModules', false).'&configure='.$this->name.'&tab_module='.$this->tab.'&module_name='.$this->name; - $helper->token = Tools::getAdminTokenLite('AdminModules'); - $helper->tpl_vars = array( - 'fields_value' => $this->getConfigFieldsValues(), - 'languages' => $this->context->controller->getLanguages(), - 'id_language' => $this->context->language->id - ); - return $helper->generateForm(array($fields_form)); - } - public function hookDisplayExternalNavigationHook() { $this->smarty->assign(array( @@ -137,14 +84,46 @@ class QloBlockContact extends Module return $this->display(__FILE__, 'external-navigation-hook.tpl'); } - public function getConfigFieldsValues() + public function hookActionAdminHotelGeneralSettingsOptionsModifier($params) { - return array( - 'QBC_PHONE' => Tools::getValue('QBC_PHONE', Configuration::get('QBC_PHONE')), - 'QBC_EMAIL' => Tools::getValue('QBC_EMAIL', Configuration::get('QBC_EMAIL')), + $params['options']['contactdetail']['fields'] = array_merge( + $params['options']['contactdetail']['fields'], + array( + 'QBC_PHONE' => array( + 'title' => $this->l('Support Contact Number'), + 'type' => 'text', + 'hint' => $this->l('The phone number used for customer service.'), + 'class' => 'fixed-width-xxl', + ), + 'QBC_EMAIL' => array( + 'title' => $this->l('Support Email'), + 'type' => 'text', + 'hint' => $this->l('The email used for customer service.'), + 'class' => 'fixed-width-xxl', + ), + ) ); } + public function hookActionAdminHotelGeneralSettingsControllerUpdate_optionsBefore() + { + $phone = Tools::getValue('QBC_PHONE'); + $email = Tools::getValue('QBC_EMAIL'); + + if ($phone != '' && !Validate::isPhoneNumber($phone)) { + $this->context->controller->errors[] = $this->l('Support Contact 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('QBC_PHONE', $phone); + Configuration::updateValue('QBC_EMAIL', $email); + } + } + public function uninstall() { if (!parent::uninstall()