public function renderForm()
 {
     if (Tools::getValue('addfeatures')) {
         $obj_hotel_features = new HotelFeatures();
         $features_list = $obj_hotel_features->HotelAllCommonFeaturesArray();
         $this->context->smarty->assign('features_list', $features_list);
         $this->context->smarty->assign('addfeatures', 1);
     }
     if ($this->display == 'add') {
         $obj_hotel_features = new HotelFeatures();
         $features_list = $obj_hotel_features->HotelAllCommonFeaturesArray();
         $hotel_info_obj = new HotelBranchInformation();
         $unassigned_ftrs_hotels = $hotel_info_obj->getUnassignedFeaturesHotelIds();
         $this->context->smarty->assign('hotels', $unassigned_ftrs_hotels);
         $this->context->smarty->assign('features_list', $features_list);
     } elseif ($this->display == 'edit') {
         $id = Tools::getValue('id');
         $this->context->smarty->assign('edit', 1);
         $obj_hotel_features = new HotelFeatures();
         $hotel_info_obj = new HotelBranchInformation();
         $features_hotel = $hotel_info_obj->getFeaturesOfHotelByHotelId(Tools::getValue('id'));
         $features_list = $obj_hotel_features->HotelBranchSelectedFeaturesArray($features_hotel);
         $hotels = $hotel_info_obj->hotelsNameAndId();
         $this->context->smarty->assign('hotel_id', $id);
         $this->context->smarty->assign('hotels', $hotels);
         $this->context->smarty->assign('features_list', $features_list);
     }
     $this->fields_form = array('submit' => array('title' => $this->l('Save')));
     return parent::renderForm();
 }
 public function hookDisplayLeftColumn()
 {
     if ($this->context->controller->php_self == 'category') {
         if (Tools::isSubmit('filter_search_btn')) {
             $hotel_cat_id = Tools::getValue('hotel_cat_id');
             $check_in = Tools::getValue('check_in_time');
             $check_out = Tools::getValue('check_out_time');
             $error = false;
             if ($hotel_cat_id == '') {
                 $error = 1;
             } elseif ($check_in == '' || !Validate::isDate($check_in)) {
                 $error = 1;
             } elseif ($check_out == '' || !Validate::isDate($check_out)) {
                 $error = 1;
             } elseif ($check_out <= $check_in) {
                 $error = 1;
             }
             if (!$error) {
                 if (Configuration::get('PS_REWRITING_SETTINGS')) {
                     $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '?date_from=' . $check_in . '&date_to=' . $check_out;
                 } else {
                     $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '&date_from=' . $check_in . '&date_to=' . $check_out;
                 }
             } else {
                 if (Configuration::get('PS_REWRITING_SETTINGS')) {
                     $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '?error=' . $error;
                 } else {
                     $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '&error=' . $error;
                 }
             }
             Tools::redirect($redirect_link);
         }
         if (Tools::getValue('error')) {
             $this->context->smarty->assign('error', Tools::getValue('error'));
         }
         $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE');
         $hotel_branch_obj = new HotelBranchInformation();
         $htl_id_category = Tools::getValue('id_category');
         $category = new Category((int) $htl_id_category);
         $parent_dtl = $hotel_branch_obj->getCategoryDataByIdCategory((int) $category->id_parent);
         if (!($date_from = Tools::getValue('date_from'))) {
             $date_from = date('Y-m-d');
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         if (!($date_to = Tools::getValue('date_to'))) {
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         $search_data['parent_data'] = $parent_dtl;
         $search_data['date_from'] = $date_from;
         $search_data['date_to'] = $date_to;
         $search_data['htl_dtl'] = $hotel_branch_obj->hotelBranchInfoById(HotelBranchInformation::getHotelIdByIdCategory($htl_id_category));
         $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo();
         $this->context->smarty->assign(array('search_data' => $search_data, 'all_hotels_info' => $hotel_info, 'location_enable' => $location_enable));
         $this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/wkhotelfiltersearchblock.css');
         return $this->display(__FILE__, 'htlfiltersearchblock.tpl');
     }
 }
 public function hookDisplayHeader()
 {
     $is_hotel_room_search = Tools::getValue('is_hotel_rooms_search');
     if (isset($is_hotel_room_search) && $is_hotel_room_search) {
         $hotel_cat_id = Tools::getValue('hotel_cat_id');
         $check_in = Tools::getValue('check_in_time');
         $check_out = Tools::getValue('check_out_time');
         $error = false;
         if ($hotel_cat_id == '') {
             $error = 1;
         } elseif ($check_in == '' || !Validate::isDate($check_in)) {
             $error = 2;
         } elseif ($check_out == '' || !Validate::isDate($check_out)) {
             $error = 3;
         } elseif ($check_out <= $check_in) {
             $error = 4;
         }
         if (!$error) {
             if (Configuration::get('PS_REWRITING_SETTINGS')) {
                 $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '?date_from=' . $check_in . '&date_to=' . $check_out;
             } else {
                 $redirect_link = $this->context->link->getCategoryLink(new Category($hotel_cat_id, $this->context->language->id), null, $this->context->language->id) . '&date_from=' . $check_in . '&date_to=' . $check_out;
             }
             Tools::redirect($redirect_link);
         } else {
             if (Configuration::get('PS_SSL_ENABLED') && Configuration::get('PS_SSL_ENABLED_EVERYWHERE')) {
                 Tools::redirect($protocol_link . Tools::getShopDomainSsl() . __PS_BASE_URI__ . "index.php?error=" . $error);
             } else {
                 Tools::redirect(_PS_BASE_URL_ . __PS_BASE_URI__ . "index.php?error=" . $error);
             }
         }
     }
     $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE');
     $hotel_branch_obj = new HotelBranchInformation();
     $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo();
     $this->context->smarty->assign('hotel_name', $hotel_info);
     $this->context->smarty->assign('header_block_title', Configuration::get('WK_TITLE_HEADER_BLOCK'));
     $this->context->smarty->assign('header_block_content', Configuration::get('WK_CONTENT_HEADER_BLOCK'));
     $this->context->smarty->assign('location_enable', $location_enable);
     $this->context->controller->addJqueryUI(array('ui.datepicker'));
     $this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/searchblock.css');
     $this->context->controller->addJS(_PS_MODULE_DIR_ . $this->name . '/views/js/wksearchblock.js');
 }
 public function hookDisplayLeftColumn()
 {
     if ($this->context->controller->php_self == 'category') {
         $this->context->controller->addJS(_PS_MODULE_DIR_ . $this->name . '/views/js/wkhotelfilterblock.js');
         $this->context->controller->addCSS(_PS_MODULE_DIR_ . $this->name . '/views/css/wkhotelfilterblock.css');
         $all_feat = FeatureCore::getFeatures($this->context->language->id);
         $htl_id_category = Tools::getValue('id_category');
         $id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category);
         $max_adult = HotelRoomType::getMaxAdults($id_hotel);
         $max_child = HotelRoomType::getMaxChild($id_hotel);
         $category = new Category($htl_id_category);
         if (!($date_from = Tools::getValue('date_from'))) {
             $date_from = date('Y-m-d');
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         if (!($date_to = Tools::getValue('date_to'))) {
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         $obj_rm_type = new HotelRoomType();
         $room_types = $obj_rm_type->getIdProductByHotelId($id_hotel);
         $prod_price = array();
         if ($room_types) {
             foreach ($room_types as $key => $value) {
                 $prod_price[] = Product::getPriceStatic($value['id_product']);
             }
         }
         if (Configuration::get('PS_REWRITING_SETTINGS')) {
             $cat_link = $this->context->link->getCategoryLink($category) . '?date_from=' . $date_from . '&date_to=' . $date_to;
         } else {
             $cat_link = $this->context->link->getCategoryLink($category) . '&date_from=' . $date_from . '&date_to=' . $date_to;
         }
         $currency = $this->context->currency;
         $config = $this->getConfigFieldsValues();
         $obj_booking_detail = new HotelBookingDetail();
         $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
         $ratting_img = _MODULE_DIR_ . $this->name . '/views/img/stars-sprite-image.png';
         $this->context->smarty->assign(array('all_feat' => $all_feat, 'max_adult' => $max_adult, 'max_child' => $max_child, 'cat_link' => $cat_link, 'ratting_img' => $ratting_img, 'currency' => $currency, 'date_from' => $date_from, 'date_to' => $date_to, 'num_days' => $num_days, 'config' => $config, 'min_price' => $prod_price ? min($prod_price) : 0, 'max_price' => $prod_price ? max($prod_price) : 0));
         return $this->display(__FILE__, 'htlfilterblock.tpl');
     }
 }
 /**
  * @param Product $obj
  * @throws Exception
  * @throws PrestaShopException
  * @throws SmartyException
  */
 public function initFormConfiguration($obj)
 {
     $data = $this->createTemplate($this->tpl_form);
     if ($obj->id) {
         if ($this->product_exists_in_shop) {
             $obj_htl_info = new HotelBranchInformation();
             $htl_info = $obj_htl_info->hotelsNameAndId();
             if ($htl_info) {
                 $obj_room_status = new HotelRoomStatus();
                 $rm_status = $obj_room_status->getAllRoomStatus();
                 $obj_room_type = new HotelRoomType();
                 $htl_room_type = $obj_room_type->getRoomTypeInfoByIdProduct($obj->id);
                 if ($htl_room_type) {
                     $data->assign('htl_room_type', $htl_room_type);
                     $htl_full_info = $obj_htl_info->hotelBranchInfoById($htl_room_type['id_hotel']);
                     $data->assign('htl_full_info', $htl_full_info);
                     $obj_room_info = new HotelRoomInformation();
                     $htl_room_info = $obj_room_info->getHotelRoomInfo($obj->id, $htl_room_type['id_hotel']);
                     if ($htl_room_info) {
                         $data->assign('htl_room_info', $htl_room_info);
                     }
                 }
                 $data->assign(array('product' => $obj, 'htl_info' => $htl_info, 'rm_status' => $rm_status));
             } else {
                 $this->displayWarning($this->l('Add Hotel Before configurate this product.'));
             }
         } else {
             $this->displayWarning($this->l('You must save the product in this shop before managing hotel configuration.'));
         }
     } else {
         $this->displayWarning($this->l('You must save this product before managing hotel configuration.'));
     }
     $this->tpl_form_vars['custom_form'] = $data->fetch();
 }
 public function filterResults()
 {
     $this->display_header = false;
     $this->display_footer = false;
     $date_from = Tools::getValue('date_from');
     $date_to = Tools::getValue('date_to');
     $htl_id_category = Tools::getValue('id_category');
     $sort_by = Tools::getValue('sort_by');
     $sort_value = Tools::getValue('sort_value');
     $filter_data = Tools::getValue('filter_data');
     // echo "<pre>";
     // print_r($filter_data);
     // die;
     $adult = 0;
     $child = 0;
     $ratting = 0;
     $amenities = 0;
     $price = 0;
     if (!empty($filter_data)) {
         foreach ($filter_data as $key => $value) {
             if ($key == 'adult') {
                 $adult = min($value);
             } elseif ($key == 'children') {
                 $child = min($value);
             } elseif ($key == 'ratting') {
                 $ratting = min($value);
             } elseif ($key == 'amenities') {
                 $amenities = array();
                 foreach ($value as $a_k => $a_v) {
                     $amenities[] = $a_v;
                 }
             } elseif ($key == 'price') {
                 $price = array();
                 $price['from'] = $value[0];
                 $price['to'] = $value[1];
             }
         }
     }
     if (Module::isInstalled('hotelreservationsystem')) {
         require_once _PS_MODULE_DIR_ . 'hotelreservationsystem/define.php';
         $id_hotel = HotelBranchInformation::getHotelIdByIdCategory($htl_id_category);
         $id_cart = $this->context->cart->id;
         $id_guest = $this->context->cookie->id_guest;
         $obj_booking_dtl = new HotelBookingDetail();
         $booking_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $id_hotel, 0, 0, $adult, $child, $ratting, $amenities, $price, $id_cart, $id_guest);
         if ($sort_by && $sort_value) {
             $indi_arr = array();
             if ($sort_value == 1) {
                 $direction = SORT_ASC;
             } elseif ($sort_value == 2) {
                 $direction = SORT_DESC;
             }
             foreach ($booking_data['rm_data'] as $s_k => $s_v) {
                 if ($sort_by == 1) {
                     $indi_arr[$s_k] = $s_v['ratting'];
                 } elseif ($sort_by == 2) {
                     $indi_arr[$s_k] = $s_v['price'];
                 }
             }
             array_multisort($indi_arr, $direction, $booking_data['rm_data']);
         }
         die(Tools::jsonEncode($booking_data));
     }
 }
 /**
  * Assign template vars related to page content
  * @see FrontController::initContent()
  */
 public function initContent()
 {
     parent::initContent();
     if (!$this->errors) {
         if (Pack::isPack((int) $this->product->id) && !Pack::isInStock((int) $this->product->id)) {
             $this->product->quantity = 0;
         }
         $this->product->description = $this->transformDescriptionWithImg($this->product->description);
         // Assign to the template the id of the virtual product. "0" if the product is not downloadable.
         $this->context->smarty->assign('virtual', ProductDownload::getIdFromIdProduct((int) $this->product->id));
         $this->context->smarty->assign('customizationFormTarget', Tools::safeOutput(urldecode($_SERVER['REQUEST_URI'])));
         if (Tools::isSubmit('submitCustomizedDatas')) {
             // If cart has not been saved, we need to do it so that customization fields can have an id_cart
             // We check that the cookie exists first to avoid ghost carts
             if (!$this->context->cart->id && isset($_COOKIE[$this->context->cookie->getName()])) {
                 $this->context->cart->add();
                 $this->context->cookie->id_cart = (int) $this->context->cart->id;
             }
             $this->pictureUpload();
             $this->textRecord();
             $this->formTargetFormat();
         } elseif (Tools::getIsset('deletePicture') && !$this->context->cart->deleteCustomizationToProduct($this->product->id, Tools::getValue('deletePicture'))) {
             $this->errors[] = Tools::displayError('An error occurred while deleting the selected picture.');
         }
         $pictures = array();
         $text_fields = array();
         if ($this->product->customizable) {
             $files = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_FILE, true);
             foreach ($files as $file) {
                 $pictures['pictures_' . $this->product->id . '_' . $file['index']] = $file['value'];
             }
             $texts = $this->context->cart->getProductCustomization($this->product->id, Product::CUSTOMIZE_TEXTFIELD, true);
             foreach ($texts as $text_field) {
                 $text_fields['textFields_' . $this->product->id . '_' . $text_field['index']] = str_replace('<br />', "\n", $text_field['value']);
             }
         }
         $this->context->smarty->assign(array('pictures' => $pictures, 'textFields' => $text_fields));
         $this->product->customization_required = false;
         $customization_fields = $this->product->customizable ? $this->product->getCustomizationFields($this->context->language->id) : false;
         if (is_array($customization_fields)) {
             foreach ($customization_fields as $customization_field) {
                 if ($this->product->customization_required = $customization_field['required']) {
                     break;
                 }
             }
         }
         // Assign template vars related to the category + execute hooks related to the category
         $this->assignCategory();
         // Assign template vars related to the price and tax
         $this->assignPriceAndTax();
         // Assign template vars related to the images
         $this->assignImages();
         // Assign attribute groups to the template
         $this->assignAttributesGroups();
         // Assign attributes combinations to the template
         $this->assignAttributesCombinations();
         // Pack management
         $pack_items = Pack::isPack($this->product->id) ? Pack::getItemTable($this->product->id, $this->context->language->id, true) : array();
         $this->context->smarty->assign('packItems', $pack_items);
         $this->context->smarty->assign('packs', Pack::getPacksTable($this->product->id, $this->context->language->id, true, 1));
         if (isset($this->category->id) && $this->category->id) {
             $return_link = Tools::safeOutput($this->context->link->getCategoryLink($this->category));
         } else {
             $return_link = 'javascript: history.back();';
         }
         $accessories = $this->product->getAccessories($this->context->language->id);
         if ($this->product->cache_is_pack || count($accessories)) {
             $this->context->controller->addCSS(_THEME_CSS_DIR_ . 'product_list.css');
         }
         if ($this->product->customizable) {
             $customization_datas = $this->context->cart->getProductCustomization($this->product->id, null, true);
         }
         // by webkul
         $htl_features = array();
         $obj_hotel_room_type = new HotelRoomType();
         $room_info_by_product_id = $obj_hotel_room_type->getRoomTypeInfoByIdProduct($this->product->id);
         $hotel_id = $room_info_by_product_id['id_hotel'];
         if (isset($hotel_id) && $hotel_id) {
             $obj_hotel_branch = new HotelBranchInformation();
             $hotel_info_by_id = $obj_hotel_branch->hotelBranchInfoById($hotel_id);
             $hotel_policies = $hotel_info_by_id['policies'];
             $hotel_name = $hotel_info_by_id['hotel_name'];
             $country = Country::getNameById($this->context->language->id, $hotel_info_by_id['country_id']);
             $state = State::getNameById($hotel_info_by_id['state_id']);
             $hotel_location = $hotel_info_by_id['city'] . ', ' . $state . ', ' . $country;
             $obj_hotel_feaures_ids = $obj_hotel_branch->getFeaturesOfHotelByHotelId($hotel_id);
             if (isset($obj_hotel_feaures_ids) && $obj_hotel_feaures_ids) {
                 foreach ($obj_hotel_feaures_ids as $key => $value) {
                     $obj_htl_ftr = new HotelFeatures();
                     $htl_info = $obj_htl_ftr->getFeatureInfoById($value['feature_id']);
                     $htl_features[] = $htl_info['name'];
                 }
             }
         }
         $date_from = Tools::getValue('date_from');
         $date_to = Tools::getValue('date_to');
         if (!($date_from = Tools::getValue('date_from'))) {
             $date_from = date('Y-m-d');
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         if (!($date_to = Tools::getValue('date_to'))) {
             $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         }
         $obj_booking_detail = new HotelBookingDetail();
         $num_days = $obj_booking_detail->getNumberOfDays($date_from, $date_to);
         $priceDisplay = Group::getPriceDisplayMethod(Group::getCurrent()->id);
         if (!$priceDisplay || $priceDisplay == 2) {
             $price_tax = true;
         } elseif ($priceDisplay == 1) {
             $price_tax = false;
         }
         $price_tax_incl = Product::getPriceStatic($this->product->id, $price_tax);
         $total_price = $price_tax_incl * $num_days;
         $obj_booking_dtl = new HotelBookingDetail();
         $hotel_room_data = $obj_booking_dtl->DataForFrontSearch($date_from, $date_to, $hotel_id, $this->product->id, 1);
         $obj_htl_cart_booking_data = new HotelCartBookingData();
         $num_cart_rooms = $obj_htl_cart_booking_data->getCountRoomsByIdCartIdProduct($this->context->cart->id, $this->product->id, $date_from, $date_to);
         if ($hotel_room_data) {
             $total_available_rooms = $hotel_room_data['stats']['num_avail'] - $num_cart_rooms;
         }
         //end
         $location_enable = Configuration::get('WK_HOTEL_LOCATION_ENABLE');
         $hotel_branch_obj = new HotelBranchInformation();
         $hotel_info = $hotel_branch_obj->getActiveHotelBranchesInfo();
         $search_data['date_from'] = $date_from;
         $search_data['date_to'] = $date_to;
         $search_data['htl_dtl'] = $hotel_branch_obj->hotelBranchInfoById($hotel_id);
         if (Tools::getValue('error')) {
             $this->context->smarty->assign('error', Tools::getValue('error'));
         }
         $this->context->smarty->assign(array('stock_management' => Configuration::get('PS_STOCK_MANAGEMENT'), 'customizationFields' => $customization_fields, 'id_customization' => empty($customization_datas) ? null : $customization_datas[0]['id_customization'], 'accessories' => $accessories, 'return_link' => $return_link, 'product' => $this->product, 'product_manufacturer' => new Manufacturer((int) $this->product->id_manufacturer, $this->context->language->id), 'token' => Tools::getToken(false), 'ratting_img_path' => _MODULE_DIR_ . 'hotelreservationsystem/views/img/Slices/icons-sprite.png', 'num_reviews' => ProductComment::getCommentNumber($this->product->id), 'ratting' => ProductComment::getAverageGrade($this->product->id)['grade'], 'total_available_rooms' => $total_available_rooms, 'all_hotels_info' => $hotel_info, 'location_enable' => $location_enable, 'total_price' => $total_price, 'product_controller_url' => $this->context->link->getPageLink('product'), 'num_days' => $num_days, 'date_from' => $date_from, 'date_to' => $date_to, 'hotel_location' => $hotel_location, 'hotel_name' => $hotel_name, 'hotel_policies' => $hotel_policies, 'hotel_features' => $htl_features, 'ftr_img_src' => _PS_IMG_ . 'rf/', 'features' => $this->product->getFrontFeatures($this->context->language->id), 'attachments' => $this->product->cache_has_attachments ? $this->product->getAttachments($this->context->language->id) : array(), 'allow_oosp' => $this->product->isAvailableWhenOutOfStock((int) $this->product->out_of_stock), 'last_qties' => (int) Configuration::get('PS_LAST_QTIES'), 'HOOK_EXTRA_LEFT' => Hook::exec('displayLeftColumnProduct'), 'HOOK_EXTRA_RIGHT' => Hook::exec('displayRightColumnProduct'), 'HOOK_PRODUCT_OOS' => Hook::exec('actionProductOutOfStock', array('product' => $this->product)), 'HOOK_PRODUCT_ACTIONS' => Hook::exec('displayProductButtons', array('product' => $this->product)), 'HOOK_PRODUCT_TAB' => Hook::exec('displayProductTab', array('product' => $this->product)), 'HOOK_PRODUCT_TAB_CONTENT' => Hook::exec('displayProductTabContent', array('product' => $this->product)), 'HOOK_PRODUCT_CONTENT' => Hook::exec('displayProductContent', array('product' => $this->product)), 'display_qties' => (int) Configuration::get('PS_DISPLAY_QTIES'), 'display_ht' => !Tax::excludeTaxeOption(), 'jqZoomEnabled' => Configuration::get('PS_DISPLAY_JQZOOM'), 'ENT_NOQUOTES' => ENT_NOQUOTES, 'outOfStockAllowed' => (int) Configuration::get('PS_ORDER_OUT_OF_STOCK'), 'errors' => $this->errors, 'body_classes' => array($this->php_self . '-' . $this->product->id, $this->php_self . '-' . $this->product->link_rewrite, 'category-' . (isset($this->category) ? $this->category->id : ''), 'category-' . (isset($this->category) ? $this->category->getFieldByLang('link_rewrite') : '')), 'display_discount_price' => Configuration::get('PS_DISPLAY_DISCOUNT_PRICE'), 'search_data' => $search_data));
     }
     $this->setTemplate(_PS_THEME_DIR_ . 'product.tpl');
 }
 public function renderView()
 {
     $check_calender_var = 0;
     $obj_booking_dtl = new HotelBookingDetail();
     $obj_htl_info = new HotelBranchInformation();
     $obj_rm_type = new HotelRoomType();
     $obj_cart_book_data = new HotelCartBookingData();
     $id_cart = $this->context->cart->id;
     $id_guest = $this->context->cookie->id_guest;
     $this->context->smarty->assign(array('id_cart' => $id_cart, 'id_guest' => $id_guest));
     $cart_bdata = $obj_cart_book_data->getCartBookingDetailsByIdCartIdGuest($id_cart, $id_guest);
     if ($cart_bdata) {
         $cart_tamount = $this->context->cart->getOrderTotal();
         $this->context->smarty->assign(array('cart_bdata' => $cart_bdata, 'cart_tamount' => $cart_tamount));
     }
     // No use of adult, child, num_rooms
     $adult = 0;
     $children = 0;
     $num_rooms = 1;
     if (Tools::isSubmit('search_hotel_list')) {
         $date_from = Tools::getValue('from_date');
         $date_to = Tools::getValue('to_date');
         $hotel_id = Tools::getValue('hotel_id');
         $room_type = Tools::getValue('room_type');
         if ($date_from == '') {
             $this->errors[] = Tools::displayError('Date From is required field.');
         }
         if ($date_to == '') {
             $this->errors[] = Tools::displayError('Date To is required field.');
         }
         if ($date_to <= $date_from) {
             $this->errors[] = Tools::displayError('Date To should be greater than Date From.');
         }
         if ($hotel_id == '') {
             $this->errors[] = Tools::displayError('Hotel name is required field.');
         }
         $booking_data = array();
         $booking_calendar_data = array();
         $check_css_condition_var = '';
         if (!count($this->errors)) {
             $booking_data = $obj_booking_dtl->getBookingData($date_from, $date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 0, 1, 1, 1, 1, $id_cart, $id_guest, 1);
             if ($booking_data) {
                 foreach ($booking_data['rm_data'] as $key => $value) {
                     if ($value['data']['partially_available']) {
                         foreach ($value['data']['partially_available'] as $key1 => $value1) {
                             if ($value1['avai_dates']) {
                                 foreach ($value1['avai_dates'] as $key2 => $value2) {
                                     $explode_date = explode(' ', $value2);
                                     $date_start = date('Y-m-d', strtotime($explode_date[0]));
                                     $date_end = date('Y-m-d', strtotime($explode_date[2]));
                                     $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($value1['id_room'], $date_start, $date_end, $id_cart, $id_guest);
                                     if ($result) {
                                         $room_in_cart = true;
                                     } else {
                                         $room_in_cart = false;
                                     }
                                     $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['in_current_cart'] = $room_in_cart;
                                     $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['id_cart'] = $this->context->cart->id;
                                     $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['cart_booking_data_id'] = $result;
                                 }
                             }
                         }
                     }
                 }
                 foreach ($booking_data['rm_data'] as $avil_k => $avail_v) {
                     if ($avail_v['data']['available']) {
                         foreach ($avail_v['data']['available'] as $avil_k1 => $avail_v1) {
                             $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($avail_v1['id_room'], $date_from, $date_to, $id_cart, $id_guest);
                             if ($result) {
                                 $room_in_cart = true;
                             } else {
                                 $room_in_cart = false;
                             }
                             $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['in_current_cart'] = $room_in_cart;
                             $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['id_cart'] = $this->context->cart->id;
                             $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['cart_booking_data_id'] = $result;
                         }
                     }
                 }
                 foreach ($booking_data['rm_data'] as $booked_k => $booked_v) {
                     if ($booked_v['data']['booked']) {
                         foreach ($booked_v['data']['booked'] as $booked_k1 => $booked_v1) {
                             $cust_obj = new Customer($booked_v1['id_customer']);
                             $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_name'] = $cust_obj->firstname . ' ' . $cust_obj->lastname;
                             $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_email'] = $cust_obj->email;
                             $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['avail_rooms_to_swap'] = $obj_booking_dtl->getAvailableRoomsForSwaping($booked_v1['date_from'], $booked_v1['date_to'], $booked_v1['id_product'], $booked_v1['id_hotel']);
                         }
                     }
                 }
             }
             //sumit to show info of every date
             $start_date = $date_from;
             // hard-coded '01' for first day
             $last_day_this_month = $date_to;
             while ($start_date <= $last_day_this_month) {
                 $cal_date_from = $start_date;
                 $cal_date_to = date('Y-m-d', strtotime($cal_date_from) + 86400);
                 $booking_calendar_data[$cal_date_from] = $obj_booking_dtl->getBookingData($cal_date_from, $cal_date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 1, 1, 1, 1, 1, $id_cart, $id_guest, 1);
                 $start_date = date('Y-m-d', strtotime($start_date) + 86400);
             }
             if ($num_rooms <= $booking_data['stats']['num_avail']) {
                 $check_css_condition_var = 'available';
             } else {
                 if ($num_rooms <= $booking_data['stats']['num_part_avai']) {
                     $check_css_condition_var = 'part_available';
                 } else {
                     $check_css_condition_var = 'unavailable';
                 }
             }
         }
     } else {
         $check_calender_var = 1;
         $date_from = date('Y-m-d');
         $date_to = date('Y-m-d', strtotime($date_from) + 86400);
         $hotel_id = 1;
         $room_type = 0;
         $booking_data = $obj_booking_dtl->getBookingData($date_from, $date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 0, 1, 1, 1, 1, $id_cart, $id_guest, 1);
         // ddd($booking_data);
         if ($booking_data) {
             foreach ($booking_data['rm_data'] as $key => $value) {
                 if ($value['data']['partially_available']) {
                     foreach ($value['data']['partially_available'] as $key1 => $value1) {
                         if ($value1['avai_dates']) {
                             foreach ($value1['avai_dates'] as $key2 => $value2) {
                                 $explode_date = explode(' ', $value2);
                                 $date_start = date('Y-m-d', strtotime($explode_date[0]));
                                 $date_end = date('Y-m-d', strtotime($explode_date[2]));
                                 $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($value1['id_room'], $date_start, $date_end, $id_cart, $id_guest);
                                 if ($result) {
                                     $room_in_cart = true;
                                 } else {
                                     $room_in_cart = false;
                                 }
                                 $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['in_current_cart'] = $room_in_cart;
                                 $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['id_cart'] = $this->context->cart->id;
                                 $booking_data['rm_data'][$key]['data']['partially_available'][$key1]['check_cart'][$key2]['cart_booking_data_id'] = $result;
                             }
                         }
                     }
                 }
             }
             foreach ($booking_data['rm_data'] as $avil_k => $avail_v) {
                 if ($avail_v['data']['available']) {
                     foreach ($avail_v['data']['available'] as $avil_k1 => $avail_v1) {
                         $result = $obj_cart_book_data->checkExistanceOfRoomInCurrentCart($avail_v1['id_room'], $date_from, $date_to, $id_cart, $id_guest);
                         if ($result) {
                             $room_in_cart = true;
                         } else {
                             $room_in_cart = false;
                         }
                         $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['in_current_cart'] = $room_in_cart;
                         $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['id_cart'] = $this->context->cart->id;
                         $booking_data['rm_data'][$avil_k]['data']['available'][$avil_k1]['cart_booking_data_id'] = $result;
                     }
                 }
             }
             foreach ($booking_data['rm_data'] as $booked_k => $booked_v) {
                 if ($booked_v['data']['booked']) {
                     foreach ($booked_v['data']['booked'] as $booked_k1 => $booked_v1) {
                         $cust_obj = new Customer($booked_v1['id_customer']);
                         $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_name'] = $cust_obj->firstname . ' ' . $cust_obj->lastname;
                         $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['alloted_cust_email'] = $cust_obj->email;
                         $booking_data['rm_data'][$booked_k]['data']['booked'][$booked_k1]['avail_rooms_to_swap'] = $obj_booking_dtl->getAvailableRoomsForSwaping($booked_v1['date_from'], $booked_v1['date_to'], $booked_v1['id_product'], $booked_v1['id_hotel']);
                     }
                 }
             }
         }
         //sumit to show info of every date
         $start_date = date('Y-m-01');
         // hard-coded '01' for first day
         $last_day_this_month = date('Y-m-t');
         while ($start_date <= $last_day_this_month) {
             $cal_date_from = $start_date;
             $cal_date_to = date('Y-m-d', strtotime($cal_date_from) + 86400);
             $booking_calendar_data[$cal_date_from] = $obj_booking_dtl->getBookingData($cal_date_from, $cal_date_to, $hotel_id, $room_type, $adult, $children, $num_rooms, 1, 1, 1, 1, 1, $id_cart, $id_guest, 1);
             $start_date = date('Y-m-d', strtotime($start_date) + 86400);
         }
         if ($num_rooms <= $booking_data['stats']['num_avail']) {
             $check_css_condition_var = 'default_available';
         } else {
             if ($num_rooms <= $booking_data['stats']['num_part_avai']) {
                 $check_css_condition_var = 'default_part_available';
             } else {
                 $check_css_condition_var = 'default_unavailable';
             }
         }
     }
     $currency = new Currency((int) Configuration::get('PS_CURRENCY_DEFAULT'));
     $hotel_name = $obj_htl_info->hotelsNameAndId();
     $all_room_type = $obj_rm_type->getRoomTypeByHotelId($hotel_id);
     $rms_in_cart = $obj_cart_book_data->getCountRoomsInCart($id_cart, $id_guest);
     $this->tpl_view_vars = array('check_calender_var' => $check_calender_var, 'date_from' => $date_from, 'date_to' => $date_to, 'hotel_id' => $hotel_id, 'room_type' => $room_type, 'adult' => $adult, 'children' => $children, 'num_rooms' => $num_rooms, 'booking_data' => $booking_data, 'booking_calendar_data' => $booking_calendar_data, 'check_css_condition_var' => $check_css_condition_var, 'hotel_name' => $hotel_name, 'all_room_type' => $all_room_type, 'currency' => $currency, 'rms_in_cart' => $rms_in_cart);
     return parent::renderView();
 }
 public function processSave()
 {
     $hotel_id = Tools::getValue('hotel_id');
     $hotel_name = Tools::getValue('hotel_name');
     $phone = Tools::getValue('phone');
     $email = Tools::getValue('email');
     $check_in = Tools::getValue('check_in');
     $check_out = Tools::getValue('check_out');
     $short_description = Tools::getValue('short_description');
     $description = Tools::getValue('description');
     $rating = Tools::getValue('hotel_rating');
     $city = Tools::getValue('hotel_city');
     $state = Tools::getValue('hotel_state');
     $country = Tools::getValue('hotel_country');
     $policies = Tools::getValue('hotel_policies');
     $zipcode = Tools::getValue('hotel_postal_code');
     $address = Tools::getValue('address');
     $active = Tools::getValue('ENABLE_HOTEL');
     if ($hotel_name == '') {
         $this->errors[] = Tools::displayError('Hotel name is required field.');
     } else {
         if (!Validate::isGenericName($hotel_name)) {
             $this->errors[] = Tools::displayError($this->l('Hotel name must not have Invalid characters <>;=#{}'));
         }
     }
     if (!$phone) {
         $this->errors[] = Tools::displayError('Phone number is required field.');
     } else {
         if (!Validate::isPhoneNumber($phone)) {
             $this->errors[] = Tools::displayError('Please enter a valid phone number.');
         }
     }
     if ($email == '') {
         $this->errors[] = Tools::displayError('Email is required field.');
     } else {
         if (!Validate::isEmail($email)) {
             $this->errors[] = Tools::displayError('Please enter a valid email.');
         }
     }
     if ($check_in == '') {
         $this->errors[] = Tools::displayError('Check In time is required field.');
     }
     if ($check_out == '') {
         $this->errors[] = Tools::displayError('Check Out Time is required field.');
     }
     if ($zipcode == '') {
         $this->errors[] = Tools::displayError('Postal Code is required field.');
     } else {
         if (!Validate::isPostCode($zipcode)) {
             $this->errors[] = Tools::displayError('Enter a Valid Postal Code.');
         }
     }
     if (!$rating) {
         $this->errors[] = Tools::displayError('Rating is required field.');
     }
     if ($address == '') {
         $this->errors[] = Tools::displayError('Address is required field.');
     }
     if (!$country) {
         $this->errors[] = Tools::displayError('Country is required field.');
     }
     if (!$state) {
         $this->errors[] = Tools::displayError('State is required field.');
     }
     if ($city == '') {
         $this->errors[] = Tools::displayError('City is required field.');
     } else {
         if (!Validate::isCityName($city)) {
             $this->errors[] = Tools::displayError('Enter a Valid City Name.');
         }
     }
     //validate hotel main image
     if (isset($_FILES['hotel_image']) && $_FILES['hotel_image']['name']) {
         $obj_htl_img = new HotelImage();
         $error = $obj_htl_img->validAddHotelMainImage($_FILES['hotel_image']);
         if ($error) {
             $this->errors[] = Tools::displayError('<strong>' . $_FILES['hotel_image']['name'] . '</strong> : Image format not recognized, allowed formats are: .gif, .jpg, .png', false);
         }
     }
     //validate Hotel's other images
     if (isset($_FILES['images']) && $_FILES['images']) {
         $obj_htl_img = new HotelImage();
         $error = $obj_htl_img->validAddHotelOtherImage($_FILES['images']);
         if ($error) {
             $this->errors[] = Tools::displayError('<strong>' . $_FILES['hotel_image']['name'] . '</strong> : Image format not recognized, allowed formats are: .gif, .jpg, .png', false);
         }
     }
     if (!count($this->errors)) {
         if ($hotel_id) {
             $obj_hotel_info = new HotelBranchInformation($hotel_id);
         } else {
             $obj_hotel_info = new HotelBranchInformation();
         }
         if ($obj_hotel_info) {
             if (!$active) {
                 $obj_htl_rm_info = new HotelRoomType();
                 $ids_product = $obj_htl_rm_info->getIdProductByHotelId($obj_hotel_info->id);
                 if (isset($ids_product) && $ids_product) {
                     foreach ($ids_product as $key_prod => $value_prod) {
                         $obj_product = new Product($value_prod['id_product']);
                         if ($obj_product->active) {
                             $obj_product->toggleStatus();
                         }
                     }
                 }
             }
         }
         $obj_hotel_info->active = $active;
         $obj_hotel_info->hotel_name = $hotel_name;
         $obj_hotel_info->phone = $phone;
         $obj_hotel_info->email = $email;
         $obj_hotel_info->check_in = $check_in;
         $obj_hotel_info->check_out = $check_out;
         $obj_hotel_info->short_description = $short_description;
         $obj_hotel_info->description = $description;
         $obj_hotel_info->rating = $rating;
         $obj_hotel_info->city = $city;
         $obj_hotel_info->state_id = $state;
         $obj_hotel_info->country_id = $country;
         $obj_hotel_info->zipcode = $zipcode;
         $obj_hotel_info->policies = $policies;
         $obj_hotel_info->address = $address;
         $obj_hotel_info->save();
         $new_hotel_id = $obj_hotel_info->id;
         $hotel_img_path = _PS_MODULE_DIR_ . 'hotelreservationsystem/views/img/hotel_img/';
         //upload hotel's image
         if (isset($_FILES['hotel_image']) && $_FILES['hotel_image']) {
             $obj_htl_img = new HotelImage();
             $obj_htl_img->uploadMainImage($_FILES['hotel_image'], $new_hotel_id, $hotel_img_path);
         }
         //upload hotel's other images
         if (isset($_FILES['images']) && $_FILES['images']) {
             $obj_htl_img = new HotelImage();
             $obj_htl_img->uploadOtherImages($_FILES['images'], $new_hotel_id, $hotel_img_path);
         }
         if ($new_hotel_id) {
             $grp_ids = array();
             $obj_grp = new Group();
             $data_grp_ids = $obj_grp->getGroups(1, $id_shop = false);
             foreach ($data_grp_ids as $key => $value) {
                 $grp_ids[] = $value['id_group'];
             }
             $country_name = (new Country())->getNameById(Configuration::get('PS_LANG_DEFAULT'), $country);
             $cat_country = $this->addCategory($country_name, false, $grp_ids);
             if ($cat_country) {
                 $state_name = (new State())->getNameById($state);
                 $cat_state = $this->addCategory($state_name, $cat_country, $grp_ids);
             }
             if ($cat_state) {
                 $cat_city = $this->addCategory($city, $cat_state, $grp_ids);
             }
             if ($cat_city) {
                 $cat_hotel = $this->addCategory($hotel_name, $cat_city, $grp_ids, 1, $new_hotel_id);
             }
             if ($cat_hotel) {
                 $obj_hotel_info = new HotelBranchInformation($new_hotel_id);
                 $obj_hotel_info->id_category = $cat_hotel;
                 $obj_hotel_info->save();
             }
         }
         if (Tools::isSubmit('submitAdd' . $this->table . 'AndStay')) {
             if ($hotel_id) {
                 Tools::redirectAdmin(self::$currentIndex . '&id=' . (int) $new_hotel_id . '&update' . $this->table . '&conf=4&token=' . $this->token);
             } else {
                 Tools::redirectAdmin(self::$currentIndex . '&id=' . (int) $new_hotel_id . '&update' . $this->table . '&conf=3&token=' . $this->token);
             }
         } else {
             if ($hotel_id) {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=4&token=' . $this->token);
             } else {
                 Tools::redirectAdmin(self::$currentIndex . '&conf=3&token=' . $this->token);
             }
         }
     } else {
         if ($hotel_id) {
             $this->display = 'edit';
         } else {
             $this->display = 'add';
         }
     }
 }
 public function createDummyDataForProject()
 {
     //delete privious products of prestashop
     $all_products = Product::getSimpleProducts(Configuration::get('PS_LANG_DEFAULT'));
     foreach ($all_products as $key_pro => $value_pro) {
         $obj_product = new Product($value_pro['id_product']);
         $obj_product->delete();
     }
     // first add a hotel.................
     $def_cont_id = Country::getDefaultCountryId();
     $obj_hotel_info = new HotelBranchInformation();
     $obj_hotel_info->active = 1;
     $obj_hotel_info->hotel_name = "The Hotel Prime";
     $obj_hotel_info->phone = 01234567;
     $obj_hotel_info->email = "prime@htl.com";
     $obj_hotel_info->check_in = '12:00';
     $obj_hotel_info->check_out = '12:00';
     $obj_hotel_info->short_description = $this->l('Nice place to stay');
     $obj_hotel_info->description = $this->l('Nice place to stay');
     $obj_hotel_info->rating = 3;
     $obj_hotel_info->city = 'Nainital';
     $states = State::getStatesByIdCountry($def_cont_id);
     $state_id = $states[0]['id_state'];
     $obj_hotel_info->state_id = $state_id;
     $obj_hotel_info->country_id = $def_cont_id;
     $obj_hotel_info->zipcode = 263001;
     $obj_hotel_info->policies = $this->l('1. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 2. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 3. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred. 4. intelligentsia tattooed pop-up salvia asymmetrical mixtape meggings tousled ramps VHS cred.');
     $obj_hotel_info->address = 'Near post office, Mallital, Nainital';
     $obj_hotel_info->save();
     $htl_id = $obj_hotel_info->id;
     $grp_ids = array();
     $obj_grp = new Group();
     $data_grp_ids = $obj_grp->getGroups(1, $id_shop = false);
     foreach ($data_grp_ids as $key => $value) {
         $grp_ids[] = $value['id_group'];
     }
     $country_name = (new Country())->getNameById(Configuration::get('PS_LANG_DEFAULT'), $def_cont_id);
     $cat_country = $this->addCategory($country_name, false, $grp_ids);
     if ($cat_country) {
         $states = State::getStatesByIdCountry($def_cont_id);
         $state_name = $states[0]['name'];
         $cat_state = $this->addCategory($state_name, $cat_country, $grp_ids);
     }
     if ($cat_state) {
         $cat_city = $this->addCategory('DefCity', $cat_state, $grp_ids);
     }
     if ($cat_city) {
         $cat_hotel = $this->addCategory('The Hotel Prime', $cat_city, $grp_ids, 1, $htl_id);
     }
     if ($cat_hotel) {
         $obj_hotel_info = new HotelBranchInformation($htl_id);
         $obj_hotel_info->id_category = $cat_hotel;
         $obj_hotel_info->save();
     }
     $branch_ftr_ids = array(1, 2, 4, 7, 8, 9, 11, 12, 14, 16, 17, 18, 21);
     foreach ($branch_ftr_ids as $key_ftr => $value_ftr) {
         $htl_ftr_obj = new HotelBranchFeatures();
         $htl_ftr_obj->id_hotel = $htl_id;
         $htl_ftr_obj->feature_id = $value_ftr;
         $htl_ftr_obj->save();
     }
     $prod_arr = array('Delux Rooms', 'Executive Rooms', 'luxury Rooms');
     $img_num = 1;
     foreach ($prod_arr as $key_prod => $value_prod) {
         // Add Product
         $product = new Product();
         $product->name = array();
         $product->description = array();
         $product->description_short = array();
         $product->link_rewrite = array();
         foreach (Language::getLanguages(true) as $lang) {
             $product->name[$lang['id_lang']] = $value_prod;
             $product->description[$lang['id_lang']] = $this->l('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->description_short[$lang['id_lang']] = $this->l('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->id_shop_default = Context::getContext()->shop->id;
         $product->id_category_default = 2;
         $product->price = 1000;
         $product->active = 1;
         $product->quantity = 99999999;
         $product->is_virtual = 1;
         $product->indexed = 1;
         $product->save();
         $product_id = $product->id;
         Search::indexation(Tools::link_rewrite($value_prod), $product_id);
         $product->addToCategories(2);
         StockAvailable::updateQuantity($product_id, null, 99999999);
         //image upload for products
         $count = 0;
         $have_cover = false;
         $old_path = _PS_MODULE_DIR_ . $this->name . '/views/img/prod_imgs/' . $img_num . '.png';
         $image_obj = new Image();
         $image_obj->id_product = $product_id;
         $image_obj->position = Image::getHighestPosition($product_id) + 1;
         if ($count == 0) {
             if (!$have_cover) {
                 $image_obj->cover = 1;
             }
         } else {
             $image_obj->cover = 0;
         }
         $image_obj->add();
         $new_path = $image_obj->getPathForCreation();
         $imagesTypes = ImageType::getImagesTypes('products');
         foreach ($imagesTypes as $image_type) {
             ImageManager::resize($old_path, $new_path . '-' . $image_type['name'] . '.jpg', $image_type['width'], $image_type['height']);
         }
         ImageManager::resize($old_path, $new_path . '.jpg');
         for ($k = 1; $k <= 5; $k++) {
             $htl_room_info_obj = new HotelRoomInformation();
             $htl_room_info_obj->id_product = $product_id;
             $htl_room_info_obj->id_hotel = $htl_id;
             $htl_room_info_obj->room_num = 'A' . $i . '-10' . $k;
             $htl_room_info_obj->id_status = 1;
             $htl_room_info_obj->floor = 'first';
             $htl_room_info_obj->save();
         }
         $htl_rm_type = new HotelRoomType();
         $htl_rm_type->id_product = $product_id;
         $htl_rm_type->id_hotel = $htl_id;
         $htl_rm_type->adult = 2;
         $htl_rm_type->children = 2;
         $htl_rm_type->save();
         $img_num++;
         // Add features to the product
         $ftr_arr = array(0 => 8, 1 => 9, 2 => 10, 3 => 11);
         $ftr_val_arr = array(0 => 34, 1 => 35, 2 => 36, 3 => 37);
         foreach ($ftr_arr as $key_htl_ftr => $val_htl_ftr) {
             $product->addFeaturesToDB($val_htl_ftr, $ftr_val_arr[$key_htl_ftr]);
         }
     }
     return true;
 }