diff --git a/admin/themes/default/sass/partials/_nav.sass b/admin/themes/default/sass/partials/_nav.sass
index 44a54f66c..18677bed3 100644
--- a/admin/themes/default/sass/partials/_nav.sass
+++ b/admin/themes/default/sass/partials/_nav.sass
@@ -268,6 +268,11 @@ $min-height: 850px
width: 200px
@include margin-right(5px)
@include float(right)
+ .clear_search
+ position: absolute
+ top: 6px
+ z-index: 10
+ @include right(8px)
li.maintab, li.subtab
height: 28px
padding: 0
diff --git a/admin/themes/default/template/controllers/search/helpers/view/view.tpl b/admin/themes/default/template/controllers/search/helpers/view/view.tpl
index f7577de04..3e3483d15 100644
--- a/admin/themes/default/template/controllers/search/helpers/view/view.tpl
+++ b/admin/themes/default/template/controllers/search/helpers/view/view.tpl
@@ -108,43 +108,160 @@ $(function() {
{/if}
+ {if isset($num_hotels) && $num_hotels}
+
+
+ {if $num_hotels == 1}
+ {l s='1 Hotel'}
+ {else}
+ {l s='%d Hotels' sprintf=$num_hotels}
+ {/if}
+
+ {$hotels}
+
+ {/if}
+
+ {if isset($num_hotel_features) && $num_hotel_features}
+
+
+ {if $num_hotel_features == 1}
+ {l s='1 hotel feature'}
+ {else}
+ {l s='%d hotel features' sprintf=$num_hotel_features}
+ {/if}
+
+ {$hotel_features}
+
+ {/if}
+
{if isset($num_products) && $num_products}
-
-
- {if $num_products == 1}
- {l s='1 product'}
- {else}
- {l s='%d products' sprintf=$num_products}
- {/if}
-
- {$products}
-
+
+
+ {if $num_products == 1}
+ {l s='1 room type'}
+ {else}
+ {l s='%d room types' sprintf=$num_products}
+ {/if}
+
+ {$products}
+
+ {/if}
+
+ {if isset($num_catalog_features) && $num_catalog_features}
+
+
+ {if $num_catalog_features == 1}
+ {l s='1 feature'}
+ {else}
+ {l s='%d features' sprintf=$num_catalog_features}
+ {/if}
+
+ {$catalog_features}
+
+ {/if}
+
+ {if isset($num_service_products) && $num_service_products}
+
+
+ {if $num_service_products == 1}
+ {l s='1 service product'}
+ {else}
+ {l s='%d service products' sprintf=$num_service_products}
+ {/if}
+
+ {$service_products}
+
+ {/if}
+
+ {if isset($num_global_demands) && $num_global_demands}
+
+
+ {if $num_global_demands == 1}
+ {l s='1 global demand'}
+ {else}
+ {l s='%d global demands' sprintf=$num_global_demands}
+ {/if}
+
+ {$global_demands}
+
+ {/if}
+
+ {if isset($num_refund_rules) && $num_refund_rules}
+
+
+ {if $num_refund_rules == 1}
+ {l s='1 refund rule'}
+ {else}
+ {l s='%d refund rules' sprintf=$num_refund_rules}
+ {/if}
+
+ {$refund_rules}
+
{/if}
{if isset($num_customers) && $num_customers}
-
-
- {if $num_customers == 1}
- {l s='1 customer'}
- {else}
- {l s='%d customers' sprintf=$num_customers}
- {/if}
-
- {$customers}
-
+
+
+ {if $num_customers == 1}
+ {l s='1 customer'}
+ {else}
+ {l s='%d customers' sprintf=$num_customers}
+ {/if}
+
+ {$customers}
+
+ {/if}
+
+ {if isset($num_groups) && $num_groups}
+
+
+ {if $num_groups == 1}
+ {l s='1 group'}
+ {else}
+ {l s='%d groups' sprintf=$num_groups}
+ {/if}
+
+ {$groups}
+
+ {/if}
+
+ {if isset($num_customer_address) && $num_customer_address}
+
+
+ {if $num_customer_address == 1}
+ {l s='1 customer address'}
+ {else}
+ {l s='%d customer addresses' sprintf=$num_customer_address}
+ {/if}
+
+ {$customer_address}
+
+ {/if}
+
+ {if isset($num_order_messages) && $num_order_messages}
+
+
+ {if $num_order_messages == 1}
+ {l s='1 customer service message'}
+ {else}
+ {l s='%d customer service messages' sprintf=$num_order_messages}
+ {/if}
+
+ {$order_messages}
+
{/if}
{if isset($num_orders) && $num_orders}
-
-
- {if $num_orders == 1}
- {l s='1 order'}
- {else}
- {l s='%d orders' sprintf=$num_orders}
- {/if}
-
- {$orders}
-
+
+
+ {if $num_orders == 1}
+ {l s='1 order'}
+ {else}
+ {l s='%d orders' sprintf=$num_orders}
+ {/if}
+
+ {$orders}
+
{/if}
{if isset($addons) && $addons}
diff --git a/admin/themes/default/template/search_form.tpl b/admin/themes/default/template/search_form.tpl
index 46054e840..ac11075f7 100644
--- a/admin/themes/default/template/search_form.tpl
+++ b/admin/themes/default/template/search_form.tpl
@@ -39,36 +39,41 @@
-
+
{l s='Catalog'}
+
+
+ {l s='Hotel'}
+
+
-
+
{l s='Customers'} {l s='by name'}
-
+
{l s='Customers'} {l s='by ip address'}
-
+
{l s='Orders'}
-
+
{l s='Invoices'}
-
+
{l s='Carts'}
-
+
{l s='Modules'}
diff --git a/classes/Address.php b/classes/Address.php
index 1bd0e69cb..9d1b583dd 100644
--- a/classes/Address.php
+++ b/classes/Address.php
@@ -482,4 +482,32 @@ class AddressCore extends ObjectModel
}
return array();
}
+
+ public function searchByName($query, $idLang = false)
+ {
+ if (!$idLang) {
+ $idLang = Context::getContext()->language->id;
+ }
+
+ return Db::getInstance()->executeS(
+ 'SELECT a.`id_address`, a.`firstname`, a.`lastname`, a.`address1`, a.`postcode`, a.`city`,
+ cl.`name` AS `country_name`, s.`name` AS `state_name`
+ FROM `'._DB_PREFIX_.'address` a
+ LEFT JOIN `'._DB_PREFIX_.'country_lang` cl
+ ON cl.`id_country` = a.`id_country`
+ LEFT JOIN `'._DB_PREFIX_.'state` s
+ ON s.`id_country` = cl.`id_country`
+ WHERE id_customer > 0 AND
+ (a.`address1` LIKE \'%'.$query.'%\' OR
+ a.`postcode` LIKE \'%'.$query.'%\' OR
+ a.`city` LIKE \'%'.$query.'%\' OR
+ a.`phone` LIKE \'%'.$query.'%\' OR
+ a.`company` LIKE \'%'.$query.'%\' OR
+ a.`alias` LIKE \'%'.$query.'%\' OR
+ s.`name` LIKE \'%'.$query.'%\' OR
+ cl.`name` LIKE \'%'.$query.'%\'
+ )
+ ');
+ }
+
}
diff --git a/classes/CustomerMessage.php b/classes/CustomerMessage.php
index efab7e2f1..33792addf 100644
--- a/classes/CustomerMessage.php
+++ b/classes/CustomerMessage.php
@@ -118,7 +118,7 @@ class CustomerMessageCore extends ObjectModel
}
return parent::delete();
}
-
+
public static function getMessagesByDate($date)
{
return Db::getInstance()->getValue(
@@ -127,4 +127,18 @@ class CustomerMessageCore extends ObjectModel
WHERE cm.`date_add` BETWEEN "'.pSQL($date).' 00:00:00" AND "'.pSQL($date).' 23:59:59"'
);
}
+
+ public function searchByName($query)
+ {
+ return Db::getInstance()->executeS('
+ SELECT cm.*, ct.*, CONCAT(c.`firstname`, \' \', c.`lastname`) `customer_name`
+ FROM `'._DB_PREFIX_.'customer_message` cm
+ LEFT JOIN '._DB_PREFIX_.'customer_thread ct
+ ON (ct.`id_customer_thread` = cm.`id_customer_thread`)
+ LEFT JOIN '._DB_PREFIX_.'customer c
+ ON (IFNULL(ct.`id_customer`, ct.`email`) = IFNULL(c.`id_customer`, c.`email`))
+ WHERE `message` LIKE \'%'.$query.'%\'
+ ');
+ }
+
}
diff --git a/classes/Feature.php b/classes/Feature.php
index badd3cc3a..8d9816263 100644
--- a/classes/Feature.php
+++ b/classes/Feature.php
@@ -361,4 +361,18 @@ class FeatureCore extends ObjectModel
{
return $this->id;
}
+
+ public static function searchByName($name, $idLang = false)
+ {
+ if (!$idLang) {
+ $idLang = Context::getContext()->language->id;
+ }
+
+ return Db::getInstance()->executeS('
+ SELECT *
+ FROM '._DB_PREFIX_.'feature_lang
+ WHERE `name` LIKE \'%'.pSQL($name).'%\'
+ AND `id_lang`='.(int)$idLang
+ );
+ }
}
diff --git a/classes/Group.php b/classes/Group.php
index cf32be978..1ea01a9e1 100644
--- a/classes/Group.php
+++ b/classes/Group.php
@@ -372,4 +372,16 @@ class GroupCore extends ObjectModel
WHERE `name` = \''.pSQL($query).'\'
');
}
+
+ public function searchGroupsByName($query)
+ {
+ return Db::getInstance()->executeS('
+ SELECT g.*, gl.*
+ FROM `'._DB_PREFIX_.'group` g
+ LEFT JOIN `'._DB_PREFIX_.'group_lang` gl
+ ON (g.`id_group` = gl.`id_group`)
+ WHERE `name` LIKE \'%'.pSQL($query).'%\'
+ ');
+ }
+
}
diff --git a/classes/controller/AdminController.php b/classes/controller/AdminController.php
index a4023154d..b4a1d9241 100644
--- a/classes/controller/AdminController.php
+++ b/classes/controller/AdminController.php
@@ -397,6 +397,14 @@ class AdminControllerCore extends Controller
/** @var int level for permissions View/read */
const LEVEL_VIEW = 1;
+ const QLO_SEARCH_TYPE_CATELOG = 1;
+ const QLO_SEARCH_TYPE_CUSTOMER_BY_NAME = 2;
+ const QLO_SEARCH_TYPE_ORDER = 3;
+ const QLO_SEARCH_TYPE_INVOICE = 4;
+ const QLO_SEARCH_TYPE_CART = 5;
+ const QLO_SEARCH_TYPE_CUSTOMER_BY_IP = 6;
+ const QLO_SEARCH_TYPE_MODULE = 7;
+ const QLO_SEARCH_TYPE_HOTEL = 8;
public function __construct()
{
@@ -2049,6 +2057,14 @@ class AdminControllerCore extends Controller
'employee' => $this->context->employee,
'search_type' => Tools::getValue('bo_search_type'),
'bo_query' => Tools::safeOutput(Tools::stripslashes(Tools::getValue('bo_query'))),
+ 'QLO_SEARCH_TYPE_CATELOG' => self::QLO_SEARCH_TYPE_CATELOG,
+ 'QLO_SEARCH_TYPE_CUSTOMER_BY_NAME' => self::QLO_SEARCH_TYPE_CUSTOMER_BY_NAME,
+ 'QLO_SEARCH_TYPE_CUSTOMER_BY_IP' => self::QLO_SEARCH_TYPE_CUSTOMER_BY_IP,
+ 'QLO_SEARCH_TYPE_ORDER' => self::QLO_SEARCH_TYPE_ORDER,
+ 'QLO_SEARCH_TYPE_INVOICE' => self::QLO_SEARCH_TYPE_INVOICE,
+ 'QLO_SEARCH_TYPE_CART' => self::QLO_SEARCH_TYPE_CART,
+ 'QLO_SEARCH_TYPE_MODULE' => self::QLO_SEARCH_TYPE_MODULE,
+ 'QLO_SEARCH_TYPE_HOTEL' => self::QLO_SEARCH_TYPE_HOTEL,
'quick_access' => $quick_access,
'multi_shop' => Shop::isFeatureActive(),
'shop_list' => $helperShop->getRenderedShopList(),
diff --git a/controllers/admin/AdminSearchController.php b/controllers/admin/AdminSearchController.php
index b0a312832..b5f8d5dd9 100644
--- a/controllers/admin/AdminSearchController.php
+++ b/controllers/admin/AdminSearchController.php
@@ -30,6 +30,22 @@ class AdminSearchControllerCore extends AdminController
{
$this->bootstrap = true;
parent::__construct();
+ $this->controllerAccess = array(
+ 'AdminProducts' => 1,
+ 'AdminCategories' => 1,
+ 'AdminFeatures' => 1,
+ 'AdminOrders' => 1,
+ 'AdminOrderRefundRules' => 1,
+ 'AdminRoomTypeGlobalDemand' => 1,
+ 'AdminGroups' => 1,
+ 'AdminHotelFeatures' => 1,
+ 'AdminCustomers' => 1,
+ 'AdminAddHotel' => 1,
+ 'AdminNormalProducts' => 1,
+ 'AdminAddresses' => 1,
+ 'AdminCustomerThreads' => 1,
+ 'AdminModules' => 1
+ );
}
public function postProcess()
@@ -39,16 +55,24 @@ class AdminSearchControllerCore extends AdminController
$searchType = (int)Tools::getValue('bo_search_type');
/* Handle empty search field */
if (!empty($this->query)) {
+ if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
+ $this->setControllerAccesses();
+ }
+
if (!$searchType && strlen($this->query) > 1) {
$this->searchFeatures();
}
/* Product research */
- if (!$searchType || $searchType == 1) {
+ if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_CATELOG) {
/* Handle product ID */
- if ($searchType == 1 && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
+ if ($searchType == self::QLO_SEARCH_TYPE_CATELOG && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
if (($product = new Product($this->query)) && Validate::isLoadedObject($product)) {
- Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&token='.Tools::getAdminTokenLite('AdminProducts'));
+ if ($product->booking_product) {
+ Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&updateproduct&token='.Tools::getAdminTokenLite('AdminProducts'));
+ } else {
+ Tools::redirectAdmin('index.php?tab=AdminNormalProducts&id_product='.(int)($product->id).'&updateproduct&token='.Tools::getAdminTokenLite('AdminNormalProducts'));
+ }
}
}
@@ -57,8 +81,8 @@ class AdminSearchControllerCore extends AdminController
}
/* Customer */
- if (!$searchType || $searchType == 2 || $searchType == 6) {
- if (!$searchType || $searchType == 2) {
+ if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_NAME || $searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_IP) {
+ if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_NAME) {
/* Handle customer ID */
if ($searchType && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
if (($customer = new Customer($this->query)) && Validate::isLoadedObject($customer)) {
@@ -70,15 +94,19 @@ class AdminSearchControllerCore extends AdminController
$this->searchCustomer();
}
- if ($searchType == 6) {
+ if ($searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_IP) {
$this->searchIP();
}
+
+ if (isset($this->_list['customers']) && is_array($this->_list['customers']) && count($this->_list['customers'])) {
+ $this->addHotelRestrictionsToSearchedCustomers('customers');
+ }
}
/* Order */
- if (!$searchType || $searchType == 3) {
+ if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_ORDER) {
if (Validate::isUnsignedInt(trim($this->query)) && (int)$this->query && ($order = new Order((int)$this->query)) && Validate::isLoadedObject($order)) {
- if ($searchType == 3) {
+ if ($searchType == self::QLO_SEARCH_TYPE_ORDER) {
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)$order->id.'&vieworder'.'&token='.Tools::getAdminTokenLite('AdminOrders'));
} else {
$row = get_object_vars($order);
@@ -96,7 +124,7 @@ class AdminSearchControllerCore extends AdminController
} else {
$orders = Order::getByReference($this->query);
$nb_orders = count($orders);
- if ($nb_orders == 1 && $searchType == 3) {
+ if ($nb_orders == 1 && $searchType == self::QLO_SEARCH_TYPE_ORDER) {
Tools::redirectAdmin('index.php?tab=AdminOrders&id_order='.(int)$orders[0]->id.'&vieworder'.'&token='.Tools::getAdminTokenLite('AdminOrders'));
} elseif ($nb_orders) {
$this->_list['orders'] = array();
@@ -113,14 +141,14 @@ class AdminSearchControllerCore extends AdminController
$this->_list['orders'][] = $row;
}
}
- } elseif ($searchType == 3) {
- $this->errors[] = Tools::displayError('No order was found with this ID:').' '.Tools::htmlentitiesUTF8($this->query);
}
}
+
+ $this->searchOrderMessages();
}
/* Invoices */
- if ($searchType == 4) {
+ if ($searchType == self::QLO_SEARCH_TYPE_INVOICE) {
if (Validate::isOrderInvoiceNumber($this->query) && ($invoice = OrderInvoice::getInvoiceByNumber($this->query))) {
Tools::redirectAdmin($this->context->link->getAdminLink('AdminPdf').'&submitAction=generateInvoicePDF&id_order='.(int)($invoice->id_order));
}
@@ -128,7 +156,7 @@ class AdminSearchControllerCore extends AdminController
}
/* Cart */
- if ($searchType == 5) {
+ if ($searchType == self::QLO_SEARCH_TYPE_CART) {
if ((int)$this->query && Validate::isUnsignedInt((int)$this->query) && ($cart = new Cart($this->query)) && Validate::isLoadedObject($cart)) {
Tools::redirectAdmin('index.php?tab=AdminCarts&id_cart='.(int)($cart->id).'&viewcart'.'&token='.Tools::getAdminToken('AdminCarts'.(int)(Tab::getIdFromClassName('AdminCarts')).(int)$this->context->employee->id));
}
@@ -138,19 +166,53 @@ class AdminSearchControllerCore extends AdminController
// 6 - but it is included in the customer block
/* Module search */
- if (!$searchType || $searchType == 7) {
+ if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_MODULE) {
/* Handle module name */
- if ($searchType == 7 && Validate::isModuleName($this->query) and ($module = Module::getInstanceByName($this->query)) && Validate::isLoadedObject($module)) {
+ if ($searchType == self::QLO_SEARCH_TYPE_MODULE && Validate::isModuleName($this->query) and ($module = Module::getInstanceByName($this->query)) && Validate::isLoadedObject($module)) {
Tools::redirectAdmin('index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules'));
}
/* Normal catalog search */
$this->searchModule();
}
+
+ if (!$searchType || $searchType == self::QLO_SEARCH_TYPE_HOTEL) {
+ if ($searchType == self::QLO_SEARCH_TYPE_HOTEL && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
+ if (($objHotelBranchInfo = new HotelBranchInformation((int) $this->query))
+ && Validate::isLoadedObject($objHotelBranchInfo)
+ ) {
+ Tools::redirectAdmin('index.php?tab=AdminAddHotel&id='.$objHotelBranchInfo->id.'&updatehtl_branch_info'.'&token='.Tools::getAdminTokenLite('AdminAddHotel'));
+ }
+ }
+
+ $this->searchHotel();
+ }
+
+ if (!$searchType) {
+ $this->searchAddress();
+ $this->searchHotelFeatures();
+ $this->searchAdditionalFacilities();
+ $this->searchRefundRules();
+ }
}
+
$this->display = 'view';
}
+ public function setControllerAccesses()
+ {
+ $sql = 'SELECT a.`view`, t.`class_name` FROM `'._DB_PREFIX_.'access` a
+ LEFT JOIN `'._DB_PREFIX_.'tab` t ON (t.`id_tab` = a.`id_tab`)
+ WHERE t.`class_name` IN ("'.implode('", "', array_keys($this->controllerAccess)).'")
+ AND a.`id_profile` = '.(int) $this->context->employee->id_profile.'
+ ';
+
+ if ($tabs = Db::getInstance()->executeS($sql)) {
+ foreach ($tabs as $tab) {
+ $this->controllerAccess[$tab['class_name']] = $tab['view'];
+ }
+ }
+ }
public function searchIP()
{
@@ -168,44 +230,57 @@ class AdminSearchControllerCore extends AdminController
*/
public function searchCatalog()
{
- $this->context = Context::getContext();
- if ($this->_list['products'] = Product::searchByName($this->context->language->id, $this->query)) {
+ if (((isset($this->controllerAccess['AdminProducts'])
+ && $this->controllerAccess['AdminProducts'])
+ || (isset($this->controllerAccess['AdminNormalProducts'])
+ && $this->controllerAccess['AdminNormalProducts']))
+ && ($this->_list['products'] = Product::searchByName($this->context->language->id, $this->query))
+ ) {
$objRoomType = new HotelRoomType();
+ $accessableHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
$objRoomTypeServiceProduct = new RoomTypeServiceProduct();
- $accessibleHotels = HotelBranchInformation::getProfileAccessedHotels(
- $this->context->employee->id_profile,
- 1,
- 1
- );
-
foreach ($this->_list['products'] as $key => $product) {
- $toUnset = false;
- if ($product['booking_product']) {
- $roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product']);
- if (!in_array($roomInfo['id_hotel'], $accessibleHotels)) {
- $toUnset = true;
+ if ($roomInfo = $objRoomType->getRoomTypeInfoByIdProduct($product['id_product'])) {
+ if (!in_array($roomInfo['id_hotel'], $accessableHotels)) {
+ unset($this->_list['products'][$key]);
}
- } else {
- $associations = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($product['id_product']);
- // proceed only if access can not be determined from hotels
- if (!count(array_intersect($associations['hotels'], $accessibleHotels))) {
- $toUnset = true;
- foreach ($associations['room_types'] as $idProduct) {
- $roomTypeInfo = $objRoomType->getRoomTypeInfoByIdProduct($idProduct);
- if (in_array($roomTypeInfo['id_hotel'], $accessibleHotels)) {
- $toUnset = false;
- break;
- }
+ } else if ($associatedData = $objRoomTypeServiceProduct->getAssociatedHotelsAndRoomType($product['id_product'])) {
+ $count = 0;
+ foreach ($associatedData['room_types'] as $id_room_type) {
+ $objRoomType = new HotelRoomType($id_room_type);
+ if (in_array($objRoomType->id_hotel, $accessableHotels)) {
+ $count += 1;
}
}
- }
- if ($toUnset) {
+ if ($count) {
+ $this->_list['service_products'][] = $this->_list['products'][$key];
+ }
+
unset($this->_list['products'][$key]);
}
}
+
+ if (isset($this->controllerAccess['AdminProducts'])
+ && $this->controllerAccess['AdminProducts']
+ ) {
+ unset($this->_list['products']);
+ }
+
+ if (isset($this->controllerAccess['AdminNormalProducts'])
+ && $this->controllerAccess['AdminNormalProducts']
+ ) {
+ unset($this->_list['service_products']);
+ }
+ }
+
+ if (isset($this->controllerAccess['AdminCategories']) && $this->controllerAccess['AdminCategories']) {
+ $this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query);
+ }
+
+ if (isset($this->controllerAccess['AdminFeatures']) && $this->controllerAccess['AdminFeatures']) {
+ $this->_list['catalog_features'] = Feature::searchByName($this->query, $this->context->language->id);
}
- $this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query);
}
/**
@@ -215,29 +290,40 @@ class AdminSearchControllerCore extends AdminController
*/
public function searchCustomer()
{
- $this->_list['customers'] = Customer::searchByName($this->query);
+ if (isset($this->controllerAccess['AdminCustomers'])
+ && $this->controllerAccess['AdminCustomers']
+ ) {
+ $this->_list['customers'] = Customer::searchByName($this->query);
+ }
+
+ $objGroup = new Group();
+ if (isset($this->controllerAccess['AdminGroups']) && $this->controllerAccess['AdminGroups']) {
+ $this->_list['groups'] = $objGroup->searchGroupsByName($this->query);
+ }
}
public function searchModule()
{
- $this->_list['modules'] = array();
- $all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
- foreach ($all_modules as $module) {
- if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
- $module->linkto = 'index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules');
- $this->_list['modules'][] = $module;
+ if (isset($this->controllerAccess['AdminModules']) && $this->controllerAccess['AdminModules']) {
+ $this->_list['modules'] = array();
+ $all_modules = Module::getModulesOnDisk(true, true, Context::getContext()->employee->id);
+ foreach ($all_modules as $module) {
+ if (stripos($module->name, $this->query) !== false || stripos($module->displayName, $this->query) !== false || stripos($module->description, $this->query) !== false) {
+ $module->linkto = 'index.php?tab=AdminModules&tab_module='.$module->tab.'&module_name='.$module->name.'&anchor='.ucfirst($module->name).'&token='.Tools::getAdminTokenLite('AdminModules');
+ $this->_list['modules'][] = $module;
+ }
}
- }
- if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
- $iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
- $iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
- if (($json_content = Tools::file_get_contents('https://api-addons.prestashop.com/'._PS_VERSION_.'/search/'.urlencode($this->query).'/'.$iso_country.'/'.$iso_lang.'/')) != false) {
- $results = json_decode($json_content, true);
- if (isset($results['id'])) {
- $this->_list['addons'] = array($results);
- } else {
- $this->_list['addons'] = $results;
+ if (!is_numeric(trim($this->query)) && !Validate::isEmail($this->query)) {
+ $iso_lang = Tools::strtolower(Context::getContext()->language->iso_code);
+ $iso_country = Tools::strtolower(Country::getIsoById(Configuration::get('PS_COUNTRY_DEFAULT')));
+ if (($json_content = Tools::file_get_contents('https://api-addons.prestashop.com/'._PS_VERSION_.'/search/'.urlencode($this->query).'/'.$iso_country.'/'.$iso_lang.'/')) != false) {
+ $results = json_decode($json_content, true);
+ if (isset($results['id'])) {
+ $this->_list['addons'] = array($results);
+ } else {
+ $this->_list['addons'] = $results;
+ }
}
}
}
@@ -301,8 +387,175 @@ class AdminSearchControllerCore extends AdminController
}
}
+ public function searchHotel()
+ {
+ if (class_exists('HotelBranchInformation')) {
+ if (isset($this->controllerAccess['AdminAddHotel']) && $this->controllerAccess['AdminAddHotel']) {
+ $objHotelBranchInformation = new HotelBranchInformation();
+ $this->_list['hotels'] = $objHotelBranchInformation->searchByName(
+ $this->query,
+ $this->context->employee->id_profile,
+ $this->context->language->id
+ );
+ }
+ }
+ }
+
+ public function searchOrderMessages()
+ {
+ if (class_exists('CustomerMessage')) {
+ if (isset($this->controllerAccess['AdminCustomerThreads']) && $this->controllerAccess['AdminCustomerThreads']) {
+ $objCustomerMessage = new CustomerMessage();
+ if ($this->_list['order_messages'] = $objCustomerMessage->searchByName($this->query)) {
+ $accesibleHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
+ foreach ($this->_list['order_messages'] as $key => $msg) {
+ if (isset($msg['id_order'])
+ && $msg['id_order']
+ ) {
+ // To set set restriction on the messages belonging to an order. While the other messages will be show to all
+ $idHotel = HotelBookingDetail::getIdHotelByIdOrder($msg['id_order']);
+ if (!in_array($idHotel, $accesibleHotels)) {
+ unset($this->_list['order_messages'][$key]);
+ }
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public function searchAddress()
+ {
+ if (isset($this->controllerAccess['AdminAddresses'])
+ && $this->controllerAccess['AdminAddresses']
+ ) {
+ $objAddress = new Address();
+ if ($this->_list['customer_address'] = $objAddress->searchByName($this->query)) {
+ $this->addHotelRestrictionsToSearchedCustomers('customer_address');
+ }
+ }
+ }
+
+ public function searchHotelFeatures()
+ {
+ if (class_exists('HotelFeatures')) {
+ if (isset($this->controllerAccess['AdminHotelFeatures']) && $this->controllerAccess['AdminHotelFeatures']) {
+ $objHotelFeatures = new HotelFeatures();
+ if ($hotelFeatures = $objHotelFeatures->searchByName($this->query, $this->context->language->id)) {
+ $features = array();
+ foreach ($hotelFeatures as $key => $hotelFeature) {
+ $features[$hotelFeature['id']]['name'] = $hotelFeature['name'];
+ if ($hotelFeature['parent_feature_id']) {
+ $features[$hotelFeature['id']]['id'] = $hotelFeature['parent_feature_id'];
+ } else {
+ $features[$hotelFeature['id']]['id'] = $hotelFeature['id'];
+ }
+ }
+
+ $this->_list['hotel_features'] = $features;
+ }
+ }
+ }
+ }
+
+ public function searchAdditionalFacilities()
+ {
+ if (class_exists('HotelRoomTypeGlobalDemand')) {
+ if (isset($this->controllerAccess['AdminRoomTypeGlobalDemand']) && $this->controllerAccess['AdminRoomTypeGlobalDemand']) {
+ $objHotelRoomTypeGlobalDemands = new HotelRoomTypeGlobalDemand();
+ if ($globalDemads = $objHotelRoomTypeGlobalDemands->searchByName($this->query, $this->context->language->id)) {
+ foreach ($globalDemads as $key => $demand) {
+ if (!(int) $globalDemads[$key]['price']) {
+ $globalDemads[$key]['price'] = $globalDemads[$key]['option_price'];
+ }
+
+ $globalDemads[$key]['per_day_price_calc'] = $this->l('No');
+ if ($globalDemads[$key]['price_calc_method'] == HotelRoomTypeGlobalDemand::WK_PRICE_CALC_METHOD_EACH_DAY) {
+ $globalDemads[$key]['per_day_price_calc'] = $this->l('Yes');
+ }
+ }
+
+ $this->_list['global_demands'] = $globalDemads;
+ }
+ }
+ }
+ }
+
+ public function searchRefundRules()
+ {
+ if (class_exists('HotelOrderRefundRules')) {
+ if (isset($this->controllerAccess['AdminOrderRefundRulesController']) && $this->controllerAccess['AdminOrderRefundRulesController']) {
+ $objRefundRule = new HotelOrderRefundRules();
+ if ($refundRules = $objRefundRule->searchByName($this->query, $this->context->language->id)) {
+ foreach ($refundRules as $key => $rule) {
+ $refundRules[$key]['deduction_type'] = $this->l('Percentage');
+ if ($rule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_FIXED) {
+ $refundRules[$key]['deduction_type'] = $this->l('Fixed Amount');
+ $refundRules[$key]['deduction_value_full_pay'] = Tools::displayPrice($rule['deduction_value_full_pay']);
+ $refundRules[$key]['deduction_value_adv_pay'] = Tools::displayPrice($rule['deduction_value_adv_pay']);
+ } else if ($rule['payment_type'] == HotelOrderRefundRules::WK_REFUND_RULE_PAYMENT_TYPE_PERCENTAGE) {
+ $refundRules[$key]['deduction_value_full_pay'] = $rule['deduction_value_full_pay'].' %';
+ $refundRules[$key]['deduction_value_adv_pay'] = $rule['deduction_value_adv_pay'].' %';
+ }
+ }
+
+ $this->_list['refund_rules'] = $refundRules;
+ }
+ }
+ }
+ }
+
+ protected function addHotelRestrictionsToSearchedCustomers($index)
+ {
+ $accessibleHotels = HotelBranchInformation::getProfileAccessedHotels($this->context->employee->id_profile, 1, 1);
+ foreach ($this->_list[$index] as $key => $item) {
+ if ($this->context->employee->id_profile != _PS_ADMIN_PROFILE_) {
+ $customerBelongsToHotel = 0;
+ if(isset($item['id_customer'])) {
+ $customerOrders = Order::getCustomerOrders($item['id_customer']);
+ if (count($customerOrders)) {
+ foreach($customerOrders as $order) {
+ $idHotel = HotelBookingDetail::getIdHotelByIdOrder($order['id_order']);
+ if (!in_array($idHotel, $accessibleHotels)) {
+ $customerBelongsToHotel += 1;
+ }
+ }
+ }
+ }
+
+ if (!$customerBelongsToHotel) {
+ unset($this->_list[$index][$key]);
+ }
+ }
+ }
+ }
+
+ protected function initGroupList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['groups'] = array(
+ 'id_group' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
+ 'name' => array('title' => $this->l('Name'), 'align' => 'center', 'width' => 65),
+ 'reduction' => array('title' => $this->l('Discount')),
+ 'show_prices' => array('title' => $this->l('Show prices'), 'callback' => 'printShowPricesIcon'),
+ 'date_add' => array('title' => $this->l('Creation date'), 'width' => 130, 'align' => 'right', 'type' => 'datetime'),
+ );
+ }
+
+ public function printShowPricesIcon($id_group, $tr)
+ {
+ $group = new Group($tr['id_group']);
+ if (!Validate::isLoadedObject($group)) {
+ return;
+ }
+ return '
+ '.($group->show_prices ? '' : '').
+ '';
+ }
+
protected function initOrderList()
{
+ $this->show_toolbar = false;
$this->fields_list['orders'] = array(
'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 65),
'id_order' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
@@ -314,6 +567,43 @@ class AdminSearchControllerCore extends AdminController
);
}
+ protected function initGlobalDemandList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['global_demands'] = array(
+ 'id_global_demand' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
+ 'name' => array('title' => $this->l('Name')),
+ 'option_name' => array('title' => $this->l('Advance Option Name')),
+ 'price' => array('title' => $this->l('Price'), 'type' => 'price', 'currency' => true),
+ 'per_day_price_calc' => array('title' => $this->l('Per day price calculation'))
+ );
+ }
+
+ protected function initRefundRuleList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['refund_rules'] = array(
+ 'id_refund_rule' => array('title' => $this->l('ID'), 'align' => 'center', 'width' => 25),
+ 'name' => array('title' => $this->l('Name')),
+ 'payment_type' => array('title' => $this->l('Payment Type')),
+ 'deduction_value_full_pay' => array('title' => $this->l('Full Payment Deduction Percentage/Amount')),
+ 'deduction_value_adv_pay' => array('title' => $this->l('Full Payment Deduction Percentage/Amount')),
+ 'days' => array('title' => $this->l('Days Before Check-in')),
+ );
+ }
+
+ protected function initOrderMessagesList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['order_messages'] = array(
+ 'id_customer_thread' => array('title' => $this->l('ID '), 'align' => 'center', 'width' => 65),
+ 'customer_name' => array('title' => $this->l('Customer Name'), 'align' => 'center'),
+ 'email' => array('title' => $this->l('Customer email')),
+ 'message' => array('title' => $this->l('Message'), 'width' => 70),
+ 'status' => array('title' => $this->l('Status'), 'width' => 280),
+ );
+ }
+
protected function initCustomerList()
{
$genders_icon = array('default' => 'unknown.gif');
@@ -342,13 +632,71 @@ class AdminSearchControllerCore extends AdminController
$this->fields_list['products'] = array(
'id_product' => array('title' => $this->l('ID'), 'width' => 25),
'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
- 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
+ // 'reference' => array('title' => $this->l('Reference'), 'align' => 'center', 'width' => 150),
'price_tax_excl' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
'price_tax_incl' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
);
}
+ protected function initServiceProdList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['service_products'] = array(
+ 'id_product' => array('title' => $this->l('ID'), 'width' => 25),
+ 'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
+ 'price_tax_excl' => array('title' => $this->l('Price (tax excl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
+ 'price_tax_incl' => array('title' => $this->l('Price (tax incl.)'), 'align' => 'right', 'type' => 'price', 'width' => 60),
+ 'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
+ );
+ }
+
+ protected function initFeatureList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['catalog_features'] = array(
+ 'id_feature' => array('title' => $this->l('ID'), 'width' => 25),
+ 'name' => array('title' => $this->l('Name'), 'width' => 'auto'),
+ 'logo' => array('title' => $this->l('Logo'),'image' => 'rf', 'align' => 'right', 'type' => 'price', 'width' => 60),
+ );
+ }
+
+ protected function initHotelList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['hotels'] = array(
+ 'id' => array('title' => $this->l('ID'), 'width' => 25),
+ 'hotel_name' => array('title' => $this->l('Name'), 'width' => 'auto'),
+ 'city' => array('title' => $this->l('City'), 'align' => 'right'),
+ 'state_name' => array('title' => $this->l('State'), 'align' => 'right'),
+ 'country_name' => array('title' => $this->l('Country'), 'align' => 'right'),
+ 'active' => array('title' => $this->l('Active'), 'width' => 70, 'active' => 'status', 'align' => 'center', 'type' => 'bool')
+ );
+ }
+
+ protected function initAddressList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['customer_address'] = array(
+ 'id_address' => array('title' => $this->l('ID'), 'width' => 25),
+ 'firstname' => array('title' => $this->l('First Name'), 'width' => 'auto'),
+ 'lastname' => array('title' => $this->l('Last Name'), 'align' => 'right'),
+ 'address1' => array('title' => $this->l('Address'), 'align' => 'right'),
+ 'postcode' => array('title' => $this->l('Zip/Postal Code'), 'align' => 'right'),
+ 'country_name' => array('title' => $this->l('Country'), 'align' => 'right'),
+ 'state_name' => array('title' => $this->l('State'), 'align' => 'right'),
+ 'city' => array('title' => $this->l('City'), 'width' => 70)
+ );
+ }
+
+ protected function initHotelFeatureList()
+ {
+ $this->show_toolbar = false;
+ $this->fields_list['hotel_features'] = array(
+ 'name' => array('title' => $this->l('name'), 'width' => 'auto'),
+ );
+ }
+
public function setMedia()
{
parent::setMedia();
@@ -403,7 +751,6 @@ class AdminSearchControllerCore extends AdminController
$helper->show_toolbar = false;
$helper->table = 'product';
$helper->currentIndex = $this->context->link->getAdminLink('AdminProducts', false);
-
$query = trim(Tools::getValue('bo_query'));
$searchType = (int)Tools::getValue('bo_search_type');
@@ -420,6 +767,152 @@ class AdminSearchControllerCore extends AdminController
$this->tpl_view_vars['num_products'] = count($this->_list['products']);
$this->tpl_view_vars['products'] = $view;
}
+ if (isset($this->_list['service_products']) && $this->_list['service_products']&& count($this->_list['service_products'])) {
+ $view = '';
+ $this->initServiceProdList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_product';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'product';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminNormalProducts', false);
+
+ $query = trim(Tools::getValue('bo_query'));
+ $searchType = (int)Tools::getValue('bo_search_type');
+
+ if ($query) {
+ $helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
+ }
+
+ $helper->token = Tools::getAdminTokenLite('AdminNormalProducts');
+
+ if ($this->_list['service_products']) {
+ $view = $helper->generateList($this->_list['service_products'], $this->fields_list['service_products']);
+ }
+
+ $this->tpl_view_vars['num_service_products'] = count($this->_list['service_products']);
+ $this->tpl_view_vars['service_products'] = $view;
+ }
+ if (isset($this->_list['catalog_features']) && $this->_list['catalog_features']&& count($this->_list['catalog_features'])) {
+ $view = '';
+ $this->initFeatureList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_feature';
+ $helper->imageType = 'jpg';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'feature';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminFeatures', false);
+
+ $query = trim(Tools::getValue('bo_query'));
+ $searchType = (int)Tools::getValue('bo_search_type');
+
+ if ($query) {
+ $helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
+ }
+
+ $helper->token = Tools::getAdminTokenLite('AdminFeatures');
+
+ if ($this->_list['catalog_features']) {
+ $view = $helper->generateList($this->_list['catalog_features'], $this->fields_list['catalog_features']);
+ }
+
+ $this->tpl_view_vars['num_catalog_features'] = count($this->_list['catalog_features']);
+ $this->tpl_view_vars['catalog_features'] = $view;
+ }
+ if (isset($this->_list['customer_address']) && $this->_list['customer_address']&& count($this->_list['customer_address'])) {
+ $view = '';
+ $this->initAddressList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_address';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'address';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminAddresses', false);
+
+ $query = trim(Tools::getValue('bo_query'));
+ $searchType = (int)Tools::getValue('bo_search_type');
+
+ if ($query) {
+ $helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
+ }
+
+ $helper->token = Tools::getAdminTokenLite('AdminAddresses');
+
+ if ($this->_list['customer_address']) {
+ $view = $helper->generateList($this->_list['customer_address'], $this->fields_list['customer_address']);
+ }
+
+ $this->tpl_view_vars['num_customer_address'] = count($this->_list['customer_address']);
+ $this->tpl_view_vars['customer_address'] = $view;
+ }
+ if (isset($this->_list['order_messages']) && $this->_list['order_messages']&& count($this->_list['order_messages'])) {
+ $view = '';
+ $this->initOrderMessagesList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_customer_message';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'feature';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminCustomerThreads', false);
+
+ $query = trim(Tools::getValue('bo_query'));
+ $searchType = (int)Tools::getValue('bo_search_type');
+
+ if ($query) {
+ $helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
+ }
+
+ $helper->token = Tools::getAdminTokenLite('AdminCustomerThreads');
+
+ if ($this->_list['order_messages']) {
+ $view = $helper->generateList($this->_list['order_messages'], $this->fields_list['order_messages']);
+ }
+
+ $this->tpl_view_vars['num_order_messages'] = count($this->_list['order_messages']);
+ $this->tpl_view_vars['order_messages'] = $view;
+ }
+ if (isset($this->_list['hotels']) && $this->_list['hotels']&& count($this->_list['hotels'])) {
+ $view = '';
+ $this->initHotelList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'htl_branch_info';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminAddHotel', false);
+
+ $query = trim(Tools::getValue('bo_query'));
+ $searchType = (int)Tools::getValue('bo_search_type');
+
+ if ($query) {
+ $helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
+ }
+
+ $helper->token = Tools::getAdminTokenLite('AdminAddHotel');
+
+ if ($this->_list['hotels']) {
+ $view = $helper->generateList($this->_list['hotels'], $this->fields_list['hotels']);
+ }
+
+ $this->tpl_view_vars['num_hotels'] = count($this->_list['hotels']);
+ $this->tpl_view_vars['hotels'] = $view;
+ }
if (isset($this->_list['customers']) && count($this->_list['customers'])) {
$view = '';
$this->initCustomerList();
@@ -443,6 +936,101 @@ class AdminSearchControllerCore extends AdminController
$this->tpl_view_vars['num_customers'] = count($this->_list['customers']);
$this->tpl_view_vars['customers'] = $view;
}
+
+ if (isset($this->_list['hotel_features']) && count($this->_list['hotel_features'])) {
+ $view = '';
+ $this->initHotelFeatureList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id';
+ $helper->actions = array('edit', 'view');
+ $helper->show_toolbar = false;
+ $helper->table = 'htl_features';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminHotelFeatures', false);
+ $helper->token = Tools::getAdminTokenLite('AdminHotelFeatures');
+
+ if ($this->_list['hotel_features']) {
+ $view = $helper->generateList($this->_list['hotel_features'], $this->fields_list['hotel_features']);
+ }
+
+ $this->tpl_view_vars['num_hotel_features'] = count($this->_list['hotel_features']);
+ $this->tpl_view_vars['hotel_features'] = $view;
+ }
+ if (isset($this->_list['groups']) && count($this->_list['groups'])) {
+ $view = '';
+ $this->initGroupList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_group';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'group';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminGroups', false);
+
+ $query = trim(Tools::getValue('bo_query'));
+ $searchType = (int)Tools::getValue('bo_search_type');
+
+ if ($query) {
+ $helper->currentIndex .= '&bo_query='.$query.'&bo_search_type='.$searchType;
+ }
+
+ $helper->token = Tools::getAdminTokenLite('AdminGroups');
+
+ if ($this->_list['groups']) {
+ $view = $helper->generateList($this->_list['groups'], $this->fields_list['groups']);
+ }
+
+ $this->tpl_view_vars['num_groups'] = count($this->_list['groups']);
+ $this->tpl_view_vars['groups'] = $view;
+ }
+
+ if (isset($this->_list['global_demands']) && count($this->_list['global_demands'])) {
+ $view = '';
+ $this->initGlobalDemandList();
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_global_demand';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'htl_room_type_global_demand';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminRoomTypeGlobalDemand', false);
+ $helper->token = Tools::getAdminTokenLite('AdminRoomTypeGlobalDemand');
+
+ if ($this->_list['global_demands']) {
+ $view = $helper->generateList($this->_list['global_demands'], $this->fields_list['global_demands']);
+ }
+
+ $this->tpl_view_vars['num_global_demands'] = count($this->_list['global_demands']);
+ $this->tpl_view_vars['global_demands'] = $view;
+ }
+
+ if (isset($this->_list['refund_rules']) && count($this->_list['refund_rules'])) {
+ $view = '';
+ $this->initRefundRuleList();
+
+ $helper = new HelperList();
+ $helper->shopLinkType = '';
+ $helper->simple_header = true;
+ $helper->identifier = 'id_refund_rule';
+ $helper->actions = array('edit');
+ $helper->show_toolbar = false;
+ $helper->table = 'htl_order_refund_rules';
+ $helper->currentIndex = $this->context->link->getAdminLink('AdminOrderRefundRules', false);
+ $helper->token = Tools::getAdminTokenLite('AdminOrderRefundRules');
+
+ if ($this->_list['refund_rules']) {
+ $view = $helper->generateList($this->_list['refund_rules'], $this->fields_list['refund_rules']);
+ }
+
+ $this->tpl_view_vars['num_refund_rules'] = count($this->_list['refund_rules']);
+ $this->tpl_view_vars['refund_rules'] = $view;
+ }
+
if (isset($this->_list['orders']) && count($this->_list['orders'])) {
$view = '';
$this->initOrderList();
diff --git a/modules/hotelreservationsystem/classes/HotelBranchInformation.php b/modules/hotelreservationsystem/classes/HotelBranchInformation.php
index 8a59f4c80..5bcbdbf15 100644
--- a/modules/hotelreservationsystem/classes/HotelBranchInformation.php
+++ b/modules/hotelreservationsystem/classes/HotelBranchInformation.php
@@ -1286,4 +1286,24 @@ class HotelBranchInformation extends ObjectModel
return false;
}
+
+ public function searchByName($query, $idEmployeeProfile, $idLang = false)
+ {
+ if (!$idLang) {
+ $idLang = Context::getContext()->language->id;
+ }
+
+ $sql = 'SELECT a.`id`, a.`active`, hbl.`hotel_name`, aa.`city`, s.`name` AS `state_name`, cl.`name` AS `country_name`
+ FROM `'._DB_PREFIX_.'htl_branch_info` a
+ LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON hbl.`id` = a.`id` AND hbl.`id_lang` = '.(int)$idLang.'
+ LEFT JOIN `'._DB_PREFIX_.'address` aa ON aa.`id_hotel` = a.`id`
+ LEFT JOIN `'._DB_PREFIX_.'state` s ON s.`id_state` = aa.`id_state`
+ LEFT JOIN `'._DB_PREFIX_.'country_lang` cl ON cl.`id_country` = aa.`id_country` AND cl.`id_lang` = hbl.`id_lang`
+ LEFT JOIN `'._DB_PREFIX_.'htl_access` ha ON a.`id` = ha.`id_hotel`
+ WHERE hbl.`hotel_name` LIKE \'%'.pSQL($query).'%\'
+ AND ha.`access`= 1 AND ha.`id_profile` = '.(int) $idEmployeeProfile;
+
+ return Db::getInstance()->executeS($sql);
+ }
+
}
diff --git a/modules/hotelreservationsystem/classes/HotelFeatures.php b/modules/hotelreservationsystem/classes/HotelFeatures.php
index 13d53b76a..120eb6b6a 100644
--- a/modules/hotelreservationsystem/classes/HotelFeatures.php
+++ b/modules/hotelreservationsystem/classes/HotelFeatures.php
@@ -207,4 +207,19 @@ class HotelFeatures extends ObjectModel
{
return Db::getInstance()->update('htl_features', $update_params, 'id='.(int) $parent_feature_id);
}
+
+ public function searchByName($query, $idLang = false)
+ {
+ if (!$idLang) {
+ $idLang = Context::getContext()->language->id;
+ }
+
+ return Db::getInstance()->executeS(
+ 'SELECT hf.*, hfl.* FROM `'._DB_PREFIX_.'htl_features` hf
+ LEFT JOIN `'._DB_PREFIX_.'htl_features_lang` hfl
+ ON hfl.`id` = hf.`id`
+ WHERE hfl.`name` LIKE \'%'.pSQL($query).'%\'
+ AND hfl.`id_lang`='.(int) $idLang
+ );
+ }
}
diff --git a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
index 91b472101..32a6ad0e0 100644
--- a/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
+++ b/modules/hotelreservationsystem/classes/HotelOrderRefundRules.php
@@ -267,4 +267,23 @@ class HotelOrderRefundRules extends ObjectModel
return array();
}
+
+ public function searchByName($query, $idLang = false)
+ {
+ if (!$idLang) {
+ $idLang = Context::getContext()->language->id;
+ }
+
+ return Db::getInstance()->executeS(
+ 'SELECT horr.*, horrl.* FROM `'._DB_PREFIX_.'htl_order_refund_rules` horr
+ LEFT JOIN `'._DB_PREFIX_.'htl_order_refund_rules_lang` horrl
+ ON horrl.`id_refund_rule` = horr.`id_refund_rule`
+ WHERE (
+ horrl.`name` LIKE \'%'.pSQL($query).'%\' OR
+ horrl.`description` LIKE \'%'.pSQL($query).'%\'
+ )
+ AND horrl.`id_lang`='.(int) $idLang
+ );
+ }
+
}
diff --git a/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php b/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php
index b5b6bfa17..96f8ab5b1 100644
--- a/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php
+++ b/modules/hotelreservationsystem/classes/HotelRoomTypeGlobalDemand.php
@@ -152,4 +152,29 @@ class HotelRoomTypeGlobalDemand extends ObjectModel
'SELECT `id_option` as `id` FROM `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option` WHERE `id_global_demand` = '.(int)$this->id.' ORDER BY `id` ASC'
);
}
+
+
+ public function searchByName($query, $idLang = false)
+ {
+ if (!$idLang) {
+ $idLang = Context::getContext()->language->id;
+ }
+
+ return Db::getInstance()->executeS('
+ SELECT rtgd.*, rtgdl.*, rtgdao.`price` AS `option_price`, rtgdaol.`name` AS `option_name`
+ FROM `'._DB_PREFIX_.'htl_room_type_global_demand` rtgd
+ LEFT JOIN `'._DB_PREFIX_.'htl_room_type_global_demand_lang` rtgdl
+ ON rtgdl.`id_global_demand` = rtgd.`id_global_demand`
+ LEFT JOIN `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option` rtgdao
+ ON rtgdao.`id_global_demand` = rtgd.`id_global_demand`
+ LEFT JOIN `'._DB_PREFIX_.'htl_room_type_global_demand_advance_option_lang` rtgdaol
+ ON (rtgdaol.`id_option` = rtgdao.`id_option` AND rtgdl.`id_lang` = rtgdaol.`id_lang`)
+ WHERE (
+ rtgdl.`name` LIKE \'%'.pSQL($query).'%\' OR
+ rtgdaol.`name` LIKE \'%'.pSQL($query).'%\'
+ )
+ AND rtgdl.`id_lang`='.(int) $idLang
+ );
+ }
+
}