diff --git a/controllers/admin/AdminNormalProductsController.php b/controllers/admin/AdminNormalProductsController.php index 3634e81c0..6c0dfb269 100644 --- a/controllers/admin/AdminNormalProductsController.php +++ b/controllers/admin/AdminNormalProductsController.php @@ -224,13 +224,14 @@ class AdminNormalProductsControllerCore extends AdminController 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_.'tax_rules_group` ttrg ON (ttrg.`id_tax_rules_group` = sa.`id_tourism_tax_rules_group`) LEFT JOIN `'._DB_PREFIX_.'htl_room_type_service_product` rsp ON (rsp.`id_product` = a.`id_product`) 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, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; $this->_select .= ' COUNT(hrt.`id_product`) as products_associated, '; - $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, '; + $this->_select .= 'shop.`name` AS `shopname`, a.`id_shop_default`, ttrg.`name` AS `tourism_tax_rules_group`, '; $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`'; if ($join_category) { @@ -354,6 +355,21 @@ class AdminNormalProductsControllerCore extends AdminController ); } + $tourismTaxRulesGroups = array(); + foreach (TaxRulesGroup::getTaxRulesGroups(true, true) as $taxRulesGroup) { + $tourismTaxRulesGroups[$taxRulesGroup['id_tax_rules_group']] = $taxRulesGroup['name']; + } + $this->fields_list['tourism_tax_rules_group'] = array( + 'title' => $this->l('Tourism tax rule'), + 'type' => 'select', + 'multiple' => true, + 'operator' => 'or', + 'filter_key' => 'sa!id_tourism_tax_rules_group', + 'list' => $tourismTaxRulesGroups, + 'optional' => true, + 'class' => 'chosen', + ); + $this->fields_list['price'] = array( 'title' => $this->l('Base price'), 'type' => 'price', diff --git a/controllers/admin/AdminProductsController.php b/controllers/admin/AdminProductsController.php index b971d2b27..fd4eecfe0 100644 --- a/controllers/admin/AdminProductsController.php +++ b/controllers/admin/AdminProductsController.php @@ -229,6 +229,9 @@ class AdminProductsControllerCore extends AdminController 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_.'address` aa ON (aa.`id_hotel` = hb.`id`) + LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hptl ON (hptl.`id_htl_property_type` = hb.`id_property_type` AND hptl.`id_lang` = '.(int) $this->context->language->id.') + LEFT JOIN `'._DB_PREFIX_.'room_type_selling_object_lang` rsol ON (rsol.`id_room_type_selling_object` = a.`id_selling_object` AND rsol.`id_lang` = '.(int) $this->context->language->id.') + LEFT JOIN `'._DB_PREFIX_.'tax_rules_group` ttrg ON (ttrg.`id_tax_rules_group` = a.`id_tourism_tax_rules_group`) LEFT JOIN `'._DB_PREFIX_.'feature_product` fp ON (fp.`id_product` = a.`id_product`) LEFT JOIN ( SELECT rsp.*, GROUP_CONCAT(pl.`name`) AS service_products @@ -240,7 +243,7 @@ class AdminProductsControllerCore extends AdminController LEFT JOIN `'._DB_PREFIX_.'htl_advance_payment` hap ON (hap.`id_product` = a.`id_product`)'; $this->_select .= ' a.`show_at_front`, (SELECT COUNT(hri.`id`) FROM `'._DB_PREFIX_.'htl_room_information` hri WHERE hri.`id_product` = a.`id_product`) as num_rooms, '; - $this->_select .= 'hrt.`adults`, hrt.`children`, hrt.`max_guests`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, '; + $this->_select .= 'hrt.`adults`, hrt.`children`, hrt.`max_guests`, hb.`id` as id_hotel, aa.`city`, hbl.`hotel_name`, hptl.`name` AS `property_type`, rsol.`name` AS `selling_object`, ttrg.`name` AS `tourism_tax_rules_group`, '; $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`, a.`id_tourism_tax_rules_group`'; $this->_select .= ', IFNULL(hap.`active`, 0) AS advance_payment'; @@ -300,6 +303,48 @@ class AdminProductsControllerCore extends AdminController 'visible_default' => true, ); } + $propertyTypes = array(); + foreach (HotelPropertyType::getPropertyTypes($this->context->language->id) as $propertyType) { + $propertyTypes[$propertyType['id_property_type']] = $propertyType['name']; + } + $this->fields_list['property_type'] = array( + 'title' => $this->l('Property type'), + 'type' => 'select', + 'multiple' => true, + 'operator' => 'or', + 'filter_key' => 'hb!id_property_type', + 'list' => $propertyTypes, + 'optional' => true, + 'class' => 'chosen', + ); + $sellingObjects = array(); + foreach (RoomTypeSellingObject::getRoomTypeSellingObjects($this->context->language->id) as $sellingObject) { + $sellingObjects[$sellingObject['id_room_type_selling_object']] = $sellingObject['name']; + } + $this->fields_list['selling_object'] = array( + 'title' => $this->l('Selling object'), + 'type' => 'select', + 'multiple' => true, + 'operator' => 'or', + 'filter_key' => 'a!id_selling_object', + 'list' => $sellingObjects, + 'optional' => true, + 'class' => 'chosen', + ); + $tourismTaxRulesGroups = array(); + foreach (TaxRulesGroup::getTaxRulesGroups(true, true) as $taxRulesGroup) { + $tourismTaxRulesGroups[$taxRulesGroup['id_tax_rules_group']] = $taxRulesGroup['name']; + } + $this->fields_list['tourism_tax_rules_group'] = array( + 'title' => $this->l('Tourism tax rule'), + 'type' => 'select', + 'multiple' => true, + 'operator' => 'or', + 'filter_key' => 'a!id_tourism_tax_rules_group', + 'list' => $tourismTaxRulesGroups, + 'optional' => true, + 'class' => 'chosen', + ); $this->fields_list['adults'] = array( 'title' => $this->l('Adults'), 'filter_key' => 'hrt!adults', diff --git a/controllers/admin/AdminTaxRulesGroupController.php b/controllers/admin/AdminTaxRulesGroupController.php index 6dd6566bf..a5baec80d 100644 --- a/controllers/admin/AdminTaxRulesGroupController.php +++ b/controllers/admin/AdminTaxRulesGroupController.php @@ -52,6 +52,19 @@ class AdminTaxRulesGroupControllerCore extends AdminController 'name' => array( 'title' => $this->l('Name') ), + 'is_tourism_tax_rule_group' => array( + 'title' => $this->l('Tourism tax'), + 'callback' => 'tourismTaxAsLabel', + 'badge_success' => true, + 'badge_danger' => true, + 'type' => 'bool', + 'align' => 'center', + 'class' => 'fixed-width-sm', + 'optional' => true, + 'visible_default' => true, + 'filter_key' => 'a!is_tourism_tax_rule_group', + 'orderby' => false, + ), 'active' => array( 'title' => $this->l('Enabled'), 'active' => 'status', @@ -70,10 +83,15 @@ class AdminTaxRulesGroupControllerCore extends AdminController ) ); + $this->_select = 'a.`is_tourism_tax_rule_group` AS `badge_success`, IF(a.`is_tourism_tax_rule_group`, 0, 1) AS `badge_danger`'; $this->_where .= ' AND a.deleted = 0'; parent::__construct(); } + public function tourismTaxAsLabel($value, $row) + { + return $value ? $this->l('Yes') : $this->l('No'); + } public function initPageHeaderToolbar() {