Create default links using queries
This commit is contained in:
@@ -527,80 +527,6 @@ class HotelHelper
|
||||
}
|
||||
}
|
||||
|
||||
public function saveDefaultHotelSettingsLinks()
|
||||
{
|
||||
$settingsLinks = array(
|
||||
array(
|
||||
'name' => 'General Settings',
|
||||
'hint' => 'Configure Your Hotel general Settings using this option.',
|
||||
'icon' => 'icon-cogs',
|
||||
'link' => 'index.php?controller=AdminHotelGeneralSettings',
|
||||
'unremovable' => 1,
|
||||
),
|
||||
array(
|
||||
'name' => 'Order Restrict',
|
||||
'hint' => 'Configure if you want to restrict orders till a specific date for your hotels.',
|
||||
'icon' => 'icon-list-alt',
|
||||
'link' => 'index.php?controller=AdminOrderRestrictSettings',
|
||||
'unremovable' => 1,
|
||||
),
|
||||
array(
|
||||
'name' => 'Advanced Price Rules',
|
||||
'hint' => 'Here set advanced price rules for specific dates.',
|
||||
'icon' => 'icon-cog',
|
||||
'link' => 'index.php?controller=AdminHotelFeaturePricesSettings',
|
||||
'unremovable' => 1,
|
||||
),
|
||||
array(
|
||||
'name' => 'Additional Facilities',
|
||||
'hint' => 'Here create additional facilities and their prices for room types.',
|
||||
'icon' => 'icon-cog',
|
||||
'link' => 'index.php?controller=AdminRoomTypeGlobalDemand',
|
||||
'unremovable' => 1,
|
||||
),
|
||||
array(
|
||||
'name' => 'Hotel Interior Block',
|
||||
'hint' => 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.',
|
||||
'icon' => 'icon-file-text',
|
||||
'link' => 'index.php?controller=AdminAboutHotelBlockSetting',
|
||||
'unremovable' => 0,
|
||||
),
|
||||
array(
|
||||
'name' => 'Hotel Amenities Block',
|
||||
'hint' => 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.',
|
||||
'icon' => 'icon-th-list',
|
||||
'link' => 'index.php?controller=AdminFeaturesModuleSetting',
|
||||
'unremovable' => 0,
|
||||
),
|
||||
);
|
||||
|
||||
$languages = Language::getLanguages();
|
||||
foreach ($settingsLinks as $key => $settingsLink) {
|
||||
$name = array();
|
||||
$hint = array();
|
||||
foreach ($languages as $language) {
|
||||
$name[$language['id_lang']] = $settingsLink['name'];
|
||||
$hint[$language['id_lang']] = $settingsLink['hint'];
|
||||
}
|
||||
|
||||
$objHotelSettingsLink = new HotelSettingsLink();
|
||||
$objHotelSettingsLink->name = $name;
|
||||
$objHotelSettingsLink->hint = $hint;
|
||||
$objHotelSettingsLink->icon = $settingsLink['icon'];
|
||||
$objHotelSettingsLink->link = $settingsLink['link'];
|
||||
$objHotelSettingsLink->new_window = 0;
|
||||
$objHotelSettingsLink->position = (int) $key;
|
||||
$objHotelSettingsLink->unremovable = $settingsLink['unremovable'];
|
||||
$objHotelSettingsLink->active = 1;
|
||||
|
||||
if (!$objHotelSettingsLink->save()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public function saveAdvancedPaymentInfo($id_product)
|
||||
{
|
||||
$obj_adv_pmt = new HotelAdvancedPayment();
|
||||
@@ -647,7 +573,6 @@ class HotelHelper
|
||||
$this->saveDummyHotelImages($htl_id);
|
||||
$this->saveDummyHotelFeatures($htl_id);
|
||||
$this->saveDummyProductsAndRelatedInfo($htl_id);
|
||||
$this->saveDefaultHotelSettingsLinks();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -386,6 +386,14 @@ class HotelReservationSystemDb
|
||||
PRIMARY KEY (`id_settings_link`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8 AUTO_INCREMENT=1;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link` (`id_settings_link`, `icon`, `link`, `new_window`, `position`, `unremovable`, `active`, `date_add`, `date_upd`) VALUES
|
||||
(1, 'icon-cogs', 'index.php?controller=AdminHotelGeneralSettings', 0, 0, 1, 1, NOW(), NOW()),
|
||||
(2, 'icon-list-alt', 'index.php?controller=AdminOrderRestrictSettings', 0, 1, 1, 1, NOW(), NOW()),
|
||||
(3, 'icon-dollar', 'index.php?controller=AdminHotelFeaturePricesSettings', 0, 2, 1, 1, NOW(), NOW()),
|
||||
(4, 'icon-plus-square', 'index.php?controller=AdminRoomTypeGlobalDemand', 0, 3, 1, 1, NOW(), NOW()),
|
||||
(5, 'icon-file-text', 'index.php?controller=AdminAboutHotelBlockSetting', 0, 4, 0, 1, NOW(), NOW()),
|
||||
(6, 'icon-th-list', 'index.php?controller=AdminFeaturesModuleSetting', 0, 5, 0, 1, NOW(), NOW());",
|
||||
|
||||
"CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_settings_link_lang` (
|
||||
`id_settings_link` int(10) unsigned NOT NULL,
|
||||
`id_lang` int(10) unsigned NOT NULL,
|
||||
@@ -393,6 +401,36 @@ class HotelReservationSystemDb
|
||||
`hint` varchar(255) character set utf8 NOT NULL,
|
||||
PRIMARY KEY (`id_settings_link`, `id_lang`)
|
||||
) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
|
||||
SELECT 1, `id_lang`, 'General Settings', 'Configure Your hotel general gettings using this option.'
|
||||
FROM `"._DB_PREFIX_."lang`
|
||||
ORDER BY `id_lang`;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
|
||||
SELECT 2, `id_lang`, 'Order Restrict', 'Configure if you want to restrict orders till a specific date for your hotels.'
|
||||
FROM `"._DB_PREFIX_."lang`
|
||||
ORDER BY `id_lang`;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
|
||||
SELECT 3, `id_lang`, 'Advanced Price Rules', 'Here set Advanced price rules for specific dates.'
|
||||
FROM `"._DB_PREFIX_."lang`
|
||||
ORDER BY `id_lang`;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
|
||||
SELECT 4, `id_lang`, 'Additional Facilities', 'Here create Additional facilities and their prices for room types.'
|
||||
FROM `"._DB_PREFIX_."lang`
|
||||
ORDER BY `id_lang`;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
|
||||
SELECT 5, `id_lang`, 'Hotel Interior Block', 'Configure Hotel Interior block. You can display hotel interior images using this block. This block will be displayed on home page.'
|
||||
FROM `"._DB_PREFIX_."lang`
|
||||
ORDER BY `id_lang`;",
|
||||
|
||||
"INSERT INTO `"._DB_PREFIX_."htl_settings_link_lang` (`id_settings_link`, `id_lang`, `name`, `hint`)
|
||||
SELECT 6, `id_lang`, 'Hotel Amenities Block', 'Configure Hotels Amenities settings. You can display hotel amenities images using this block. This block will be displayed on home page.'
|
||||
FROM `"._DB_PREFIX_."lang`
|
||||
ORDER BY `id_lang`;",
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -50,13 +50,13 @@ class HotelSettingsLink extends ObjectModel
|
||||
),
|
||||
);
|
||||
|
||||
public function getAll($active = true)
|
||||
public function getAllSettingsLinks($active = true)
|
||||
{
|
||||
return Db::getInstance()->executeS(
|
||||
'SELECT * FROM `'._DB_PREFIX_.'htl_settings_link` hsl
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_settings_link_lang` hsll
|
||||
ON hsll.`id_settings_link` = hsl.`id_settings_link` AND hsll.`id_lang` = '.(int) Context::getContext()->language->id.
|
||||
($active ? ' WHERE hsl.`active` = 1' : '').'
|
||||
ON (hsll.`id_settings_link` = hsl.`id_settings_link` AND hsll.`id_lang` = '.(int) Context::getContext()->language->id.')
|
||||
WHERE hsl.`active` = '.(int) $active.'
|
||||
ORDER BY hsl.`position`'
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,6 +19,25 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController
|
||||
$this->addRowAction('edit');
|
||||
$this->addRowAction('delete');
|
||||
|
||||
$this->bulk_actions = array(
|
||||
'enableSelection' => array(
|
||||
'text' => $this->l('Enable selection'),
|
||||
'icon' => 'icon-power-off text-success'
|
||||
),
|
||||
'disableSelection' => array(
|
||||
'text' => $this->l('Disable selection'),
|
||||
'icon' => 'icon-power-off text-danger'
|
||||
),
|
||||
'divider' => array(
|
||||
'text' => 'divider'
|
||||
),
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
'icon' => 'icon-trash'
|
||||
)
|
||||
);
|
||||
|
||||
$this->fields_list = array(
|
||||
'id_settings_link' => array(
|
||||
'title' => $this->l('ID'),
|
||||
@@ -71,25 +90,6 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController
|
||||
'filter_key' => 'a!active',
|
||||
),
|
||||
);
|
||||
|
||||
$this->bulk_actions = array(
|
||||
'enableSelection' => array(
|
||||
'text' => $this->l('Enable selection'),
|
||||
'icon' => 'icon-power-off text-success'
|
||||
),
|
||||
'disableSelection' => array(
|
||||
'text' => $this->l('Disable selection'),
|
||||
'icon' => 'icon-power-off text-danger'
|
||||
),
|
||||
'divider' => array(
|
||||
'text' => 'divider'
|
||||
),
|
||||
'delete' => array(
|
||||
'text' => $this->l('Delete selected'),
|
||||
'confirm' => $this->l('Delete selected items?'),
|
||||
'icon' => 'icon-trash'
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function displayColumnIcon($icon)
|
||||
@@ -205,7 +205,7 @@ class AdminHotelConfigurationSettingController extends ModuleAdminController
|
||||
|
||||
public function renderView()
|
||||
{
|
||||
$settingsLinks = $this->object->getAll();
|
||||
$settingsLinks = $this->object->getAllSettingsLinks();
|
||||
foreach ($settingsLinks as $index => &$settingsLink) {
|
||||
$settingsLink['generated_link'] = $this->object->generateLink($settingsLink['link']);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user