diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index 0cf259e90..a204a2857 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -305,15 +305,16 @@ public function createHotelRoomDefaultFeatures() return true; } - public static function getPsProducts($id_lang, $start = 0, $limit = 0) + public static function getPsProducts($id_lang, $start = 0, $limit = 0, $booking_product = null) { - $sql = 'SELECT p.`id_product`, pl.`name` + $sql = 'SELECT p.`id_product`, pl.`name`, p.`booking_product` FROM `'._DB_PREFIX_.'product` p '.Shop::addSqlAssociation('product', 'p').' LEFT JOIN `'._DB_PREFIX_.'product_lang` pl ON (p.`id_product` = pl.`id_product` '. Shop::addSqlRestrictionOnLang('pl').') WHERE pl.`id_lang` = '.(int)$id_lang. - ' ORDER BY pl.`name`'. + (isset($booking_product) ? ' AND p.`booking_product` = '.(int) $booking_product : '').' + ORDER BY pl.`name`'. ($limit > 0 ? ' LIMIT '.(int)$start.','.(int)$limit : ''); return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql); } @@ -434,7 +435,7 @@ public function saveDummyProductsAndRelatedInfo($id_hotel) $product->description_short[$lang['id_lang']] = 'Fashion axe kogi yuccie, ramps shabby chic direct trade before they sold out distillery bicycle rights. Slow-carb +1 quinoa VHS. +1 brunch trust fund, meggings chartreuse sustainable everyday carry tumblr hoodie tacos tilde ramps post-ironic fixie.'; - $product->link_rewrite[$lang['id_lang']] = Tools::link_rewrite('Super Delux Rooms'); + $product->link_rewrite[$lang['id_lang']] = Tools::link_rewrite($value_prod); } $product->id_shop_default = Context::getContext()->shop->id; $product->id_category_default = 2; @@ -544,6 +545,170 @@ public function saveDummyProductsAndRelatedInfo($id_hotel) } } + public function saveDummyServiceProductsAndRelatedInfo() + { + $idCategoryServices = (int) Configuration::get('PS_SERVICE_CATEGORY'); + $idsGroup = array_column(Group::getGroups(Context::getContext()->language->id), 'id_group'); + + // create service categories + $categories = array( + 'meals' => array( + 'name' => 'Meals', + 'id_category' => 'to_be_set_below', + ), + 'transfers' => array( + 'name' => 'Transfers', + 'id_category' => 'to_be_set_below', + ) + ); + + foreach ($categories as &$category) { + $idCategory = $this->addCategory($category['name'], $idCategoryServices, $idsGroup); + $category['id_category'] = $idCategory; + } + + // create service products + $serviceProducts = array( + array( + 'name' => 'Room Maintenance Fees', + 'id_category_default' => $idCategoryServices, + 'description' => 'Ensure a comfortable stay with our room maintenance service, keeping your accommodation pristine and hassle-free throughout your visit.', + 'price' => '250', + 'auto_add_to_cart' => 1, + 'show_at_front' => 0, + 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, + ), + array( + 'name' => 'Internet Handling Charges', + 'id_category_default' => $idCategoryServices, + 'description' => 'Navigate our website effortlessly with seamless handling, ensuring reliable, high-speed access for an enjoyable browsing experience throughout your online journey.', + 'price' => '250', + 'auto_add_to_cart' => 1, + 'show_at_front' => 0, + 'price_addition_type' => Product::PRICE_ADDITION_TYPE_INDEPENDENT, + ), + array( + 'name' => 'Airport Shuttle', + 'id_category_default' => $categories['transfers']['id_category'], + 'description' => 'Experience convenience from touchdown to check-in with our efficient airport shuttle service, whisking you to your accommodation with ease and comfort.', + 'price' => '50', + 'auto_add_to_cart' => 0, + 'show_at_front' => 1, + 'price_addition_type' => Product::PRICE_ADDITION_TYPE_WITH_ROOM, + ), + array( + 'name' => 'Cab on Demand', + 'id_category_default' => $categories['transfers']['id_category'], + 'description' => 'Explore the city conveniently with our cab-on-demand service, giving you the freedom to travel and discover local attractions at your own pace.', + 'price' => '200', + 'auto_add_to_cart' => 0, + 'show_at_front' => 1, + ), + array( + 'name' => 'Breakfast', + 'id_category_default' => $categories['meals']['id_category'], + 'description' => 'Start your day right with a delicious and hearty breakfast, thoughtfully prepared to fuel your adventures and make your mornings exceptional.', + 'price' => '350', + 'auto_add_to_cart' => 0, + 'show_at_front' => 1, + ), + array( + 'name' => 'Dinner', + 'id_category_default' => $categories['meals']['id_category'], + 'description' => 'Wind down in the evening with a delectable dinner spread, offering a culinary journey that delights your taste buds and completes your day with satisfaction.', + 'price' => '450', + 'auto_add_to_cart' => 0, + 'show_at_front' => 1, + ), + ); + + foreach ($serviceProducts as $serviceProduct) { + $objProduct = new Product(); + $objProduct->name = array(); + $objProduct->description = array(); + $objProduct->description_short = array(); + $objProduct->link_rewrite = array(); + + // copy lang values + foreach (Language::getLanguages(true) as $language) { + $objProduct->name[$language['id_lang']] = $serviceProduct['name']; + $objProduct->description[$language['id_lang']] = $serviceProduct['description']; + $objProduct->description_short[$language['id_lang']] = $serviceProduct['description']; + $objProduct->link_rewrite[$language['id_lang']] = Tools::link_rewrite($serviceProduct['name']); + } + + $objProduct->id_shop_default = Context::getContext()->shop->id; + $objProduct->id_category_default = $serviceProduct['id_category_default']; + $objProduct->price = $serviceProduct['price']; + $objProduct->active = 1; + $objProduct->quantity = 999999999; + $objProduct->booking_product = 0; + $objProduct->service_product_type = Product::SERVICE_PRODUCT_WITH_ROOMTYPE; + $objProduct->auto_add_to_cart = $serviceProduct['auto_add_to_cart']; + $objProduct->show_at_front = $serviceProduct['show_at_front']; + $objProduct->available_for_order = 1; + if ($serviceProduct['auto_add_to_cart']) { + $objProduct->price_addition_type = $serviceProduct['price_addition_type']; + } + $objProduct->is_virtual = 1; + $objProduct->indexed = 1; + $objProduct->save(); + $idProduct = $objProduct->id; + + // add to applicable categories + $objCategory = new Category($serviceProduct['id_category_default']); + if ($categories = $objCategory->getParentsCategories()) { + $idsCategory = array(); + foreach ($categories as $category) { + $idsCategory[] = $category['id_category']; + } + $objProduct->addToCategories($idsCategory); + } + + Search::indexation(Tools::link_rewrite($serviceProduct['name']), $idProduct); + + StockAvailable::updateQuantity($idProduct, null, 999999999); + + // save service product images + $imagesBasePath = _PS_MODULE_DIR_.'hotelreservationsystem/views/img/prod_imgs/'.$idProduct.'/'; + $imagesTypes = ImageType::getImagesTypes('products'); + if (is_dir($imagesBasePath) && $opendir = opendir($imagesBasePath)) { + while (($image = readdir($opendir)) !== false) { + $sourceImagePath = $imagesBasePath.$image; + + if (ImageManager::isRealImage($sourceImagePath) + && ImageManager::isCorrectImageFileExt($sourceImagePath) + ) { + $objImage = new Image(); + $objImage->id_product = $idProduct; + $objImage->position = Image::getHighestPosition($idProduct) + 1; + $objImage->cover = 1; + $objImage->add(); + $destinationPath = $objImage->getPathForCreation(); + foreach ($imagesTypes as $imageType) { + ImageManager::resize( + $sourceImagePath, + $destinationPath.'-'.$imageType['name'].'.jpg', + $imageType['width'], + $imageType['height'] + ); + } + ImageManager::resize($sourceImagePath, $destinationPath.'.jpg'); + } + } + closedir($opendir); + } + + // link to all demo room types + $objRoomTypeServiceProduct = new RoomTypeServiceProduct(); + $objRoomTypeServiceProduct->addRoomProductLink( + $idProduct, + array(1, 2, 3, 4), + RoomTypeServiceProduct::WK_ELEMENT_TYPE_ROOM_TYPE + ); + } + } + public function saveAdvancedPaymentInfo($id_product) { $obj_adv_pmt = new HotelAdvancedPayment(); @@ -584,6 +749,7 @@ public function createDummyDataForProject() $this->saveDummyHotelImages($htl_id); $this->saveDummyHotelFeatures($htl_id); $this->saveDummyProductsAndRelatedInfo($htl_id); + $this->saveDummyServiceProductsAndRelatedInfo(); return true; } diff --git a/modules/hotelreservationsystem/views/img/prod_imgs/10/1.jpg b/modules/hotelreservationsystem/views/img/prod_imgs/10/1.jpg new file mode 100644 index 000000000..6af2e2eac Binary files /dev/null and b/modules/hotelreservationsystem/views/img/prod_imgs/10/1.jpg differ diff --git a/modules/hotelreservationsystem/views/img/prod_imgs/5/1.jpg b/modules/hotelreservationsystem/views/img/prod_imgs/5/1.jpg new file mode 100644 index 000000000..fa9236e73 Binary files /dev/null and b/modules/hotelreservationsystem/views/img/prod_imgs/5/1.jpg differ diff --git a/modules/hotelreservationsystem/views/img/prod_imgs/6/1.jpg b/modules/hotelreservationsystem/views/img/prod_imgs/6/1.jpg new file mode 100644 index 000000000..516d18425 Binary files /dev/null and b/modules/hotelreservationsystem/views/img/prod_imgs/6/1.jpg differ diff --git a/modules/hotelreservationsystem/views/img/prod_imgs/7/1.jpg b/modules/hotelreservationsystem/views/img/prod_imgs/7/1.jpg new file mode 100644 index 000000000..6d70e7a7a Binary files /dev/null and b/modules/hotelreservationsystem/views/img/prod_imgs/7/1.jpg differ diff --git a/modules/hotelreservationsystem/views/img/prod_imgs/8/1.jpg b/modules/hotelreservationsystem/views/img/prod_imgs/8/1.jpg new file mode 100644 index 000000000..9ee9be888 Binary files /dev/null and b/modules/hotelreservationsystem/views/img/prod_imgs/8/1.jpg differ diff --git a/modules/hotelreservationsystem/views/img/prod_imgs/9/1.jpg b/modules/hotelreservationsystem/views/img/prod_imgs/9/1.jpg new file mode 100644 index 000000000..3c08ba9bd Binary files /dev/null and b/modules/hotelreservationsystem/views/img/prod_imgs/9/1.jpg differ diff --git a/modules/wkhotelroom/classes/WkHotelRoomDisplay.php b/modules/wkhotelroom/classes/WkHotelRoomDisplay.php index f324aba82..51406ada8 100644 --- a/modules/wkhotelroom/classes/WkHotelRoomDisplay.php +++ b/modules/wkhotelroom/classes/WkHotelRoomDisplay.php @@ -152,7 +152,7 @@ public function insertModuleDemoData() // update global configuration values in multilang Configuration::updateValue('HOTEL_ROOM_DISPLAY_HEADING', $HOTEL_ROOM_DISPLAY_HEADING); Configuration::updateValue('HOTEL_ROOM_DISPLAY_DESCRIPTION', $HOTEL_ROOM_DISPLAY_DESCRIPTION); - if ($roomTypes = HotelHelper::getPsProducts(Configuration::get('PS_LANG_DEFAULT'), 0, 5)) { + if ($roomTypes = HotelHelper::getPsProducts(Configuration::get('PS_LANG_DEFAULT'), 0, 5, 1)) { foreach ($roomTypes as $product) { if (Validate::isLoadedObject($objProduct = new Product($product['id_product']))) { $objRoomBlock = new WkHotelRoomDisplay();