Added country, states in address search results, added constants for the search type

This commit is contained in:
vishalsingh.qlo325
2024-03-14 11:58:02 +05:30
parent 1e9e1180e6
commit 8539c75820
10 changed files with 142 additions and 86 deletions

View File

@@ -39,41 +39,41 @@
</li>
<li class="divider"></li>
<li class="search-book search-option">
<a href="#" data-value="1" data-placeholder="{l s='Product name, SKU, reference...'}" data-icon="icon-book">
<a href="#" data-value="{$QLO_SEARCH_TYPE_CATELOG}" data-placeholder="{l s='Room Types, Service products...'}" data-icon="icon-book">
<i class="icon-book"></i> {l s='Catalog'}
</a>
</li>
<li class="search-modules search-option">
<a href="#" data-value="8" data-placeholder="{l s='Hotel'}" data-icon="icon-AdminHotelReservationSystemManagement">
<a href="#" data-value="{$QLO_SEARCH_TYPE_HOTEL}" data-placeholder="{l s='Hotel'}" data-icon="icon-AdminHotelReservationSystemManagement">
<i class="icon-building"></i> {l s='Hotel'}
</a>
</li>
<li class="search-customers-name search-option">
<a href="#" data-value="2" data-placeholder="{l s='Email, name...'}" data-icon="icon-group">
<a href="#" data-value="{$QLO_SEARCH_TYPE_CUSTOMER_BY_NAME}" data-placeholder="{l s='Email, name...'}" data-icon="icon-group">
<i class="icon-group"></i> {l s='Customers'} {l s='by name'}
</a>
</li>
<li class="search-customers-addresses search-option">
<a href="#" data-value="6" data-placeholder="{l s='123.45.67.89'}" data-icon="icon-desktop">
<a href="#" data-value="{$QLO_SEARCH_TYPE_CUSTOMER_BY_IP}" data-placeholder="{l s='123.45.67.89'}" data-icon="icon-desktop">
<i class="icon-desktop"></i> {l s='Customers'} {l s='by ip address'}</a>
</li>
<li class="search-orders search-option">
<a href="#" data-value="3" data-placeholder="{l s='Order ID'}" data-icon="icon-credit-card">
<a href="#" data-value="{$QLO_SEARCH_TYPE_ORDER}" data-placeholder="{l s='Order ID'}" data-icon="icon-credit-card">
<i class="icon-credit-card"></i> {l s='Orders'}
</a>
</li>
<li class="search-invoices search-option">
<a href="#" data-value="4" data-placeholder="{l s='Invoice Number'}" data-icon="icon-book">
<a href="#" data-value="{$QLO_SEARCH_TYPE_INVOICE}" data-placeholder="{l s='Invoice Number'}" data-icon="icon-book">
<i class="icon-book"></i> {l s='Invoices'}
</a>
</li>
<li class="search-carts search-option">
<a href="#" data-value="5" data-placeholder="{l s='Cart ID'}" data-icon="icon-shopping-cart">
<a href="#" data-value="{$QLO_SEARCH_TYPE_CART}" data-placeholder="{l s='Cart ID'}" data-icon="icon-shopping-cart">
<i class="icon-shopping-cart"></i> {l s='Carts'}
</a>
</li>
<li class="search-modules search-option">
<a href="#" data-value="7" data-placeholder="{l s='Module name'}" data-icon="icon-puzzle-piece">
<a href="#" data-value="{$QLO_SEARCH_TYPE_MODULE}" data-placeholder="{l s='Module name'}" data-icon="icon-puzzle-piece">
<i class="icon-puzzle-piece"></i> {l s='Modules'}
</a>
</li>

View File

@@ -483,17 +483,29 @@ class AddressCore extends ObjectModel
return array();
}
public function getCustomersAddresses($text)
public function searchByName($query, $idLang = false)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
return Db::getInstance()->executeS(
'SELECT * FROM `'._DB_PREFIX_.'address`
'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
(address1 LIKE \'%'.$text.'%\' OR
postcode LIKE \'%'.$text.'%\' OR
city LIKE \'%'.$text.'%\' OR
phone LIKE \'%'.$text.'%\' OR
company LIKE \'%'.$text.'%\' OR
alias LIKE \'%'.$text.'%\'
(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.'%\'
)
');
}

View File

@@ -128,17 +128,17 @@ class CustomerMessageCore extends ObjectModel
);
}
public function searchCustomerMessage($text)
public function searchByName($query)
{
return Db::getInstance()->executeS(
'SELECT cm.*, ct.*, CONCAT(c.firstname, \' \', c.lastname) customer_name
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)
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 \'%'.$text.'%\''
);
ON (IFNULL(ct.`id_customer`, ct.`email`) = IFNULL(c.`id_customer`, c.`email`))
WHERE `message` LIKE \'%'.$query.'%\'
');
}
}

View File

@@ -373,7 +373,7 @@ class GroupCore extends ObjectModel
');
}
public function getRelatedGroups($query)
public function searchGroupByName($query)
{
return Db::getInstance()->executeS('
SELECT g.*, gl.*

View File

@@ -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()
{
@@ -2030,6 +2038,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(),

View File

@@ -30,7 +30,7 @@ class AdminSearchControllerCore extends AdminController
{
$this->bootstrap = true;
parent::__construct();
$this->controllers = array(
$this->controllerAccess = array(
'AdminProducts' => 1,
'AdminCategories' => 1,
'AdminFeatures' => 1,
@@ -64,9 +64,9 @@ class AdminSearchControllerCore extends AdminController
}
/* 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)) {
if ($product->booking_product) {
Tools::redirectAdmin('index.php?tab=AdminProducts&id_product='.(int)($product->id).'&updateproduct&token='.Tools::getAdminTokenLite('AdminProducts'));
@@ -81,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)) {
@@ -94,7 +94,7 @@ class AdminSearchControllerCore extends AdminController
$this->searchCustomer();
}
if ($searchType == 6) {
if ($searchType == self::QLO_SEARCH_TYPE_CUSTOMER_BY_IP) {
$this->searchIP();
}
@@ -104,9 +104,9 @@ class AdminSearchControllerCore extends AdminController
}
/* 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);
@@ -124,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();
@@ -148,7 +148,7 @@ class AdminSearchControllerCore extends AdminController
}
/* 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));
}
@@ -156,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));
}
@@ -166,9 +166,9 @@ 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'));
}
@@ -176,8 +176,8 @@ class AdminSearchControllerCore extends AdminController
$this->searchModule();
}
if (!$searchType || $searchType == 8) {
if ($searchType == 8 && (int)$this->query && Validate::isUnsignedInt((int)$this->query)) {
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)
) {
@@ -203,13 +203,13 @@ class AdminSearchControllerCore extends AdminController
{
$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->controllers)).'")
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->controllers[$tab['class_name']] = $tab['view'];
$this->controllerAccess[$tab['class_name']] = $tab['view'];
}
}
}
@@ -230,8 +230,10 @@ class AdminSearchControllerCore extends AdminController
*/
public function searchCatalog()
{
if (isset($this->controllers['AdminProducts'])
&& $this->controllers['AdminProducts']
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();
@@ -258,13 +260,25 @@ class AdminSearchControllerCore extends AdminController
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->controllers['AdminCategories']) && $this->controllers['AdminCategories']) {
if (isset($this->controllerAccess['AdminCategories']) && $this->controllerAccess['AdminCategories']) {
$this->_list['categories'] = Category::searchByName($this->context->language->id, $this->query);
}
if (isset($this->controllers['AdminFeatures']) && $this->controllers['AdminFeatures']) {
if (isset($this->controllerAccess['AdminFeatures']) && $this->controllerAccess['AdminFeatures']) {
$this->_list['catalog_features'] = Feature::searchByName($this->query, $this->context->language->id);
}
}
@@ -276,22 +290,21 @@ class AdminSearchControllerCore extends AdminController
*/
public function searchCustomer()
{
if (isset($this->controllers['AdminCustomers'])
&& $this->controllers['AdminCustomers']
if (isset($this->controllerAccess['AdminCustomers'])
&& $this->controllerAccess['AdminCustomers']
) {
$this->_list['customers'] = Customer::searchByName($this->query);
}
$objGroup = new Group();
if (isset($this->controllers['AdminGroups']) && $this->controllers['AdminGroups']) {
$this->_list['groups'] = $objGroup->getRelatedGroups($this->query);
if (isset($this->controllerAccess['AdminGroups']) && $this->controllerAccess['AdminGroups']) {
$this->_list['groups'] = $objGroup->searchGroupByName($this->query);
}
}
public function searchModule()
{
if (isset($this->controllers['AdminModules']) && $this->controllers['AdminModules']) {
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) {
@@ -377,9 +390,13 @@ class AdminSearchControllerCore extends AdminController
public function searchHotel()
{
if (class_exists('HotelBranchInformation')) {
if (isset($this->controllers['AdminAddHotel']) && $this->controllers['AdminAddHotel']) {
if (isset($this->controllerAccess['AdminAddHotel']) && $this->controllerAccess['AdminAddHotel']) {
$objHotelBranchInformation = new HotelBranchInformation();
$this->_list['hotels'] = $objHotelBranchInformation->getAccessibleHotelByName($this->query);
$this->_list['hotels'] = $objHotelBranchInformation->searchByName(
$this->query,
$this->context->employee->id_profile,
$this->context->language->id
);
}
}
}
@@ -387,12 +404,14 @@ class AdminSearchControllerCore extends AdminController
public function searchOrderMessages()
{
if (class_exists('CustomerMessage')) {
if (isset($this->controllers['AdminCustomerThreads']) && $this->controllers['AdminCustomerThreads']) {
if (isset($this->controllerAccess['AdminCustomerThreads']) && $this->controllerAccess['AdminCustomerThreads']) {
$objCustomerMessage = new CustomerMessage();
if ($this->_list['order_messages'] = $objCustomerMessage->searchCustomerMessage($this->query)) {
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 ($msg['id_order']) {
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)) {
@@ -407,9 +426,11 @@ class AdminSearchControllerCore extends AdminController
public function searchAddress()
{
if (isset($this->controllers['AdminAddresses']) && $this->controllers['AdminAddresses']) {
if (isset($this->controllerAccess['AdminAddresses'])
&& $this->controllerAccess['AdminAddresses']
) {
$objAddress = new Address();
if ($this->_list['customer_address'] = $objAddress->getCustomersAddresses($this->query)) {
if ($this->_list['customer_address'] = $objAddress->searchByName($this->query)) {
$this->addHotelRestrictionsToSearchedCustomers('customer_address');
}
}
@@ -418,9 +439,9 @@ class AdminSearchControllerCore extends AdminController
public function searchHotelFeatures()
{
if (class_exists('HotelFeatures')) {
if (isset($this->controllers['AdminHotelFeatures']) && $this->controllers['AdminHotelFeatures']) {
if (isset($this->controllerAccess['AdminHotelFeatures']) && $this->controllerAccess['AdminHotelFeatures']) {
$objHotelFeatures = new HotelFeatures();
if ($hotelFeatures = $objHotelFeatures->searchHotelFeatureByName($this->query)) {
if ($hotelFeatures = $objHotelFeatures->searchByName($this->query, $this->context->language->id)) {
$features = array();
foreach ($hotelFeatures as $key => $hotelFeature) {
$features[$hotelFeature['id']]['name'] = $hotelFeature['name'];
@@ -440,9 +461,9 @@ class AdminSearchControllerCore extends AdminController
public function searchAdditionalFacilities()
{
if (class_exists('HotelRoomTypeGlobalDemand')) {
if (isset($this->controllers['AdminRoomTypeGlobalDemand']) && $this->controllers['AdminRoomTypeGlobalDemand']) {
if (isset($this->controllerAccess['AdminRoomTypeGlobalDemand']) && $this->controllerAccess['AdminRoomTypeGlobalDemand']) {
$objHotelRoomTypeGlobalDemands = new HotelRoomTypeGlobalDemand();
if ($globalDemads = $objHotelRoomTypeGlobalDemands->searchRoomTypeDemandsByName($this->query)) {
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'];
@@ -463,9 +484,9 @@ class AdminSearchControllerCore extends AdminController
public function searchRefundRules()
{
if (class_exists('HotelOrderRefundRules')) {
if (isset($this->controllers['AdminOrderRefundRulesController']) && $this->controllers['AdminOrderRefundRulesController']) {
if (isset($this->controllerAccess['AdminOrderRefundRulesController']) && $this->controllerAccess['AdminOrderRefundRulesController']) {
$objRefundRule = new HotelOrderRefundRules();
if ($refundRules = $objRefundRule->searchOrderRefundRulesByName($this->query)) {
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) {
@@ -662,6 +683,8 @@ class AdminSearchControllerCore extends AdminController
'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)
);
}

View File

@@ -1028,19 +1028,21 @@ class HotelBranchInformation extends ObjectModel
return false;
}
public function getAccessibleHotelByName($name)
public function searchByName($query, $idEmployeeProfile, $idLang = false)
{
$context = Context::getContext();
$idLang = $context->language->id;
$sql = ' SELECT a.`id`, a.`active`, hbl.`hotel_name`, aa.`city`, s.`name` as `state_name`, cl.`name` as `country_name`
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($name).'%\'
AND ha.`access`=1 AND ha.`id_profile` = '.(int)$context->employee->id_profile;
WHERE hbl.`hotel_name` LIKE \'%'.pSQL($query).'%\'
AND ha.`access`= 1 AND ha.`id_profile` = '.(int) $idEmployeeProfile;
return Db::getInstance()->executeS($sql);
}

View File

@@ -208,9 +208,8 @@ class HotelFeatures extends ObjectModel
return Db::getInstance()->update('htl_features', $update_params, 'id='.(int) $parent_feature_id);
}
public function searchHotelFeatureByName($name, $idLang = false)
public function searchByName($query, $idLang = false)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
@@ -219,9 +218,8 @@ class HotelFeatures extends ObjectModel
'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($name).'%\'
AND `id_lang`='.(int)$idLang
WHERE hfl.`name` LIKE \'%'.pSQL($query).'%\'
AND hfl.`id_lang`='.(int) $idLang
);
}
}

View File

@@ -268,9 +268,8 @@ class HotelOrderRefundRules extends ObjectModel
}
public function searchOrderRefundRulesByName($name, $idLang = false)
public function searchByName($query, $idLang = false)
{
if (!$idLang) {
$idLang = Context::getContext()->language->id;
}
@@ -279,8 +278,11 @@ class HotelOrderRefundRules extends ObjectModel
'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($name).'%\' OR horrl.`description` LIKE \'%'.pSQL($name).'%\')
AND `id_lang`='.(int)$idLang
WHERE (
horrl.`name` LIKE \'%'.pSQL($query).'%\' OR
horrl.`description` LIKE \'%'.pSQL($query).'%\'
)
AND horrl.`id_lang`='.(int) $idLang
);
}

View File

@@ -154,23 +154,26 @@ class HotelRoomTypeGlobalDemand extends ObjectModel
}
public function searchRoomTypeDemandsByName($name, $idLang = false)
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`
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`
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($name).'%\' OR rtgdaol.`name` LIKE \'%'.pSQL($name).'%\' )
AND rtgdl.`id_lang`='.(int)$idLang
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
);
}