Updated: google connector code for inactive room type query
Co-authored-by: Name <azharbhat.qlo098@webkul.in>
This commit is contained in:
@@ -154,7 +154,7 @@ class QghcAri
|
||||
// to Google, regardless of what's requested. Changed rows in qghc_ari_updates
|
||||
// are written by hotel-wide events (e.g. booking-offset changes) that don't check QGHC
|
||||
// connection, so only_change=1 must re-filter here too, not just the full-sync path.
|
||||
$connectedProducts = QghcRoomType::getConnectedProductIds($idProperty);
|
||||
$connectedProducts = QghcRoomType::getConnectedProductIds($idProperty, 1);
|
||||
|
||||
if (!empty($params['id_room_type'])) {
|
||||
$requested = array_filter(array_map('intval', explode('|', $params['id_room_type'])));
|
||||
|
||||
@@ -597,6 +597,8 @@ class QghcPropertyService
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'product_lang` pl
|
||||
ON pl.`id_product` = hrt.`id_product`
|
||||
AND pl.`id_lang` = ' . (int)$idLang . '
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'product` p
|
||||
ON p.`id_product` = hrt.`id_product` AND p.`active` = 1 AND p.`show_at_front` = 1
|
||||
WHERE hrt.`id_hotel` = ' . (int)$idHotel . '
|
||||
AND hrt.`is_google_hotel_enabled` = 1'
|
||||
);
|
||||
@@ -682,6 +684,9 @@ class QghcPropertyService
|
||||
ON hrt.`id_hotel` = hbi.`id`
|
||||
AND hrt.`is_google_hotel_enabled` = 1
|
||||
|
||||
INNER JOIN `' . _DB_PREFIX_ . 'product` p
|
||||
ON p.`id_product` = hrt.`id_product` AND p.`active` = 1 AND p.`show_at_front` = 1
|
||||
|
||||
LEFT JOIN `' . _DB_PREFIX_ . 'product_lang` pl
|
||||
ON pl.`id_product` = hrt.`id_product`
|
||||
AND pl.`id_lang` = ' . $idLang . '
|
||||
|
||||
@@ -127,12 +127,17 @@ class QghcRoomType
|
||||
* @param int $idHotel
|
||||
* @return int[]
|
||||
*/
|
||||
public static function getConnectedProductIds($idHotel)
|
||||
public static function getConnectedProductIds($idHotel, $onlySellable = 0)
|
||||
{
|
||||
$rows = Db::getInstance()->executeS(
|
||||
'SELECT `id_product` FROM `' . _DB_PREFIX_ . 'htl_room_type`
|
||||
WHERE `id_hotel` = ' . (int) $idHotel . ' AND `is_google_hotel_enabled` = 1'
|
||||
);
|
||||
$sql = 'SELECT hrt.`id_product` FROM `' . _DB_PREFIX_ . 'htl_room_type` hrt INNER JOIN `' . _DB_PREFIX_ . 'product` p ON (p.`id_product` = hrt.`id_product`';
|
||||
|
||||
if ($onlySellable) {
|
||||
$sql .= ' AND p.`active` = 1 AND p.`show_at_front` = 1';
|
||||
}
|
||||
|
||||
$sql .= ') WHERE hrt.`id_hotel` = ' . (int) $idHotel . ' AND hrt.`is_google_hotel_enabled` = 1';
|
||||
|
||||
$rows = Db::getInstance()->executeS($sql);
|
||||
|
||||
$ids = array();
|
||||
if ($rows) {
|
||||
@@ -151,6 +156,20 @@ class QghcRoomType
|
||||
*/
|
||||
public static function getMappingsForHotel($idHotel)
|
||||
{
|
||||
return self::getConnectedProductIds($idHotel);
|
||||
// Deliberately NOT filtered by product.active (unlike getConnectedProductIds()):
|
||||
// inactive room types stay selectable on the tab, so their ticked state must
|
||||
// reflect the real enrollment flag or saving the hotel would un-enroll them.
|
||||
$rows = Db::getInstance()->executeS(
|
||||
'SELECT `id_product` FROM `' . _DB_PREFIX_ . 'htl_room_type`
|
||||
WHERE `id_hotel` = ' . (int) $idHotel . ' AND `is_google_hotel_enabled` = 1'
|
||||
);
|
||||
|
||||
$ids = array();
|
||||
if ($rows) {
|
||||
foreach ($rows as $row) {
|
||||
$ids[] = (int) $row['id_product'];
|
||||
}
|
||||
}
|
||||
return $ids;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,7 +153,7 @@ class AdminGoogleHotelConfigController extends ModuleAdminController
|
||||
'id_hotel' => (int)$row['id_hotel'],
|
||||
'hotel_name' => $row['hotel_name'],
|
||||
'date_add' => $row['date_add'],
|
||||
'edit_url' => $hotelEditBase . '&id=' . (int)$row['id_hotel'] . '&updatehtl_branch_info',
|
||||
'edit_url' => $hotelEditBase . '&id=' . (int)$row['id_hotel'] . '&updatehtl_branch_info' . QloGoogleHotelConnector::HOTEL_TAB_QUERY,
|
||||
'status_class' => $badge['class'],
|
||||
'status_icon' => $badge['icon'],
|
||||
'status_label' => $badge['label'],
|
||||
|
||||
@@ -33,6 +33,8 @@ class QloGoogleHotelConnector extends Module
|
||||
const CONFIG_WS_KEY = 'QGHC_WS_KEY';
|
||||
/** PS Configuration key that stores the module connection status (0 = off, 1 = connected). */
|
||||
const CONFIG_STATUS = 'QGHC_STATUS';
|
||||
/** Query fragment that opens the Google Hotel tab (id "hotel-tab") on the hotel edit form — read by the core form via htl_active_tab. */
|
||||
const HOTEL_TAB_QUERY = '&htl_active_tab=%23hotel-tab';
|
||||
|
||||
/** Cron task name registered in the Cron Task Manager module. */
|
||||
const CRON_TASK_CLEANUP_LOGS = 'cleanup_api_logs';
|
||||
@@ -459,7 +461,7 @@ class QloGoogleHotelConnector extends Module
|
||||
foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) {
|
||||
$hotels[] = array(
|
||||
'name' => $hotelName,
|
||||
'url' => $hotelEditBase . '&id=' . (int) $idHotel . '&updatehtl_branch_info',
|
||||
'url' => $hotelEditBase . '&id=' . (int) $idHotel . '&updatehtl_branch_info' . QloGoogleHotelConnector::HOTEL_TAB_QUERY,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -482,7 +484,7 @@ class QloGoogleHotelConnector extends Module
|
||||
foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) {
|
||||
$hotels[] = array(
|
||||
'hotel_name' => $hotelName,
|
||||
'edit_url' => $editBaseUrl . '&id=' . (int) $idHotel . '&updatehtl_branch_info',
|
||||
'edit_url' => $editBaseUrl . '&id=' . (int) $idHotel . '&updatehtl_branch_info' . QloGoogleHotelConnector::HOTEL_TAB_QUERY,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -542,7 +544,7 @@ class QloGoogleHotelConnector extends Module
|
||||
foreach (QghcPropertyService::getHotelsWithIssues($idLang) as $idHotel => $hotelName) {
|
||||
$hotelsWithIssues[] = array(
|
||||
'hotel_name' => $hotelName,
|
||||
'edit_url' => $editBaseUrl . '&id=' . $idHotel . '&updatehtl_branch_info',
|
||||
'edit_url' => $editBaseUrl . '&id=' . $idHotel . '&updatehtl_branch_info' . QloGoogleHotelConnector::HOTEL_TAB_QUERY,
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1218,4 +1220,4 @@ class QloGoogleHotelConnector extends Module
|
||||
|
||||
return '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user