Fixed: Service product associated room types are shown according to hotel permission
This commit is contained in:
@@ -186,19 +186,17 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
|
||||
$id_shop = Shop::isFeatureActive() && Shop::getContext() == Shop::CONTEXT_SHOP? (int)$this->context->shop->id : 'a.id_shop_default';
|
||||
$this->_join .= ' JOIN `'._DB_PREFIX_.'product_shop` sa ON (a.`id_product` = sa.`id_product` AND sa.id_shop = '.$id_shop.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (a.`id_product` = hrt.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info` hb ON (hrt.`id_hotel` = hb.`id`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_branch_info_lang` hbl ON (hb.`id` = hbl.`id` AND b.`id_lang` = hbl.`id_lang`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'category_lang` cl ON ('.$alias.'.`id_category_default` = cl.`id_category` AND b.`id_lang` = cl.`id_lang` AND cl.id_shop = '.$id_shop.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'shop` shop ON (shop.id_shop = '.$id_shop.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image_shop` image_shop ON (image_shop.`id_product` = a.`id_product` AND image_shop.`cover` = 1 AND image_shop.id_shop = '.$id_shop.')
|
||||
LEFT JOIN `'._DB_PREFIX_.'image` i ON (i.`id_image` = image_shop.`id_image`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'product_download` pd ON (pd.`id_product` = a.`id_product` AND pd.`active` = 1)
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` rsp ON (rsp.`id_product` = a.`id_product`)
|
||||
LEFT JOIN `'._DB_PREFIX_.'address` aa ON (aa.`id_hotel` = hb.`id`)';
|
||||
LEFT JOIN `'._DB_PREFIX_.'htl_room_type` hrt ON (rsp.`id_element` = hrt.`id_product` AND rsp.`element_type` = '.(int)RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE.')
|
||||
'.HotelBranchInformation::addHotelRestriction(false, 'hrt');
|
||||
|
||||
$this->_select .= ' IF(a.`auto_add_to_cart`, "'.$this->l('Yes').'", "'.$this->l('No').'") as auto_added, IF(a.`auto_add_to_cart`, 1, 0) as badge_success, IF(a.`show_at_front`, "'.$this->l('Yes').'", "'.$this->l('No').'") as show_at_front_txt, IF(a.`price_calculation_method` = '.(int)Product::PRICE_CALCULATION_METHOD_PER_DAY.', "'.$this->l('Per Day').'", "'.$this->l('Per Booking').'") as price_calculation_method_txt, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, ';
|
||||
$this->_select .= ' COUNT(rsp.`id_product`) as products_associated, hrt.`adults`, hrt.`children`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, ';
|
||||
$this->_select .= ' COUNT(hrt.`id_product`) as products_associated, ';
|
||||
$this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, ';
|
||||
$this->_select .= $alias_image.'.`id_image` AS `id_image`, cl.`name` AS `name_category`, '.$alias.'.`price`, 0 AS `price_final`, a.`is_virtual`, pd.`nb_downloadable`, sav.`quantity` AS `sav_quantity`, '.$alias.'.`active`, IF(sav.`quantity`<=0, 1, 0) AS `badge_danger`';
|
||||
|
||||
@@ -368,15 +366,6 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
return '--';
|
||||
}
|
||||
|
||||
public function getHotelName($hotelName, $row)
|
||||
{
|
||||
if ($hotelName && isset($row['city'])) {
|
||||
return $hotelName.' - '.$row['city'];
|
||||
}
|
||||
|
||||
return '--';
|
||||
}
|
||||
|
||||
public static function getQuantities($hotelName, $tr)
|
||||
{
|
||||
if ((int)$tr['is_virtual'] == 1 && $tr['nb_downloadable'] == 0) {
|
||||
@@ -3531,15 +3520,6 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
));
|
||||
$data->assign($this->tpl_form_vars);
|
||||
|
||||
$objRoomType = new HotelRoomType();
|
||||
$objHotelInfo = new HotelBranchInformation();
|
||||
$data->assign('htl_info', $objHotelInfo->hotelsNameAndId());
|
||||
if ($hotelRoomType = $objRoomType->getRoomTypeInfoByIdProduct($product->id)) {
|
||||
$data->assign('htl_room_type', $hotelRoomType);
|
||||
$hotelFullInfo = $objHotelInfo->hotelBranchInfoById($hotelRoomType['id_hotel']);
|
||||
$data->assign('htl_full_info', $hotelFullInfo);
|
||||
}
|
||||
|
||||
$this->tpl_form_vars['product'] = $product;
|
||||
$this->tpl_form_vars['custom_form'] = $data->fetch();
|
||||
}
|
||||
@@ -4113,19 +4093,6 @@ class AdminNormalProductsControllerCore extends AdminController
|
||||
}
|
||||
}
|
||||
|
||||
public function ajaxProcessGetIdHotelByIdProduct()
|
||||
{
|
||||
$response = array('status' => 'failed');
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
$objHotelRoomType = new HotelRoomType();
|
||||
$roomTypeInfo = $objHotelRoomType->getRoomTypeInfoByIdProduct($idProduct);
|
||||
if ($roomTypeInfo) {
|
||||
$response['status'] = 'success';
|
||||
$response['id_hotel'] = (int)$roomTypeInfo['id_hotel'];
|
||||
}
|
||||
die(json_encode($response));
|
||||
}
|
||||
|
||||
public function processImageLegends()
|
||||
{
|
||||
if (Tools::getValue('key_tab') == 'Images' && Tools::getValue('submitAddproductAndStay') == 'update_legends' && Validate::isLoadedObject($product = new Product((int)Tools::getValue('id_product')))) {
|
||||
|
||||
Reference in New Issue
Block a user