Ejemplo n.º 1
0
 public function getFormat()
 {
     $fields = AddressFormat::getOrderedAddressFields($this->country->id, true, true);
     $required = array_flip(AddressFormat::getFieldsRequired());
     $format = ['id_address' => (new FormField())->setName('id_address')->setType('hidden'), 'id_customer' => (new FormField())->setName('id_customer')->setType('hidden'), 'back' => (new FormField())->setName('back')->setType('hidden'), 'token' => (new FormField())->setName('token')->setType('hidden'), 'alias' => (new FormField())->setName('alias')->setLabel($this->getFieldLabel('alias'))];
     foreach ($fields as $field) {
         $formField = new FormField();
         $formField->setName($field);
         $fieldParts = explode(':', $field, 2);
         if (count($fieldParts) === 1) {
             if ($field === 'postcode') {
                 if ($this->country->need_zip_code) {
                     $formField->setRequired(true);
                 }
             }
         } elseif (count($fieldParts) === 2) {
             list($entity, $entityField) = $fieldParts;
             // Fields specified using the Entity:field
             // notation are actually references to other
             // entities, so they should be displayed as a select
             $formField->setType('select');
             // Also, what we really want is the id of the linked entity
             $formField->setName('id_' . strtolower($entity));
             if ($entity === 'Country') {
                 $formField->setType('countrySelect');
                 $formField->setValue($this->country->id);
                 foreach ($this->availableCountries as $country) {
                     $formField->addAvailableValue($country['id_country'], $country[$entityField]);
                 }
             } elseif ($entity === 'State') {
                 if ($this->country->contains_states) {
                     $states = State::getStatesByIdCountry($this->country->id);
                     foreach ($states as $state) {
                         $formField->addAvailableValue($state['id_state'], $state[$entityField]);
                     }
                     $formField->setRequired(true);
                 }
             }
         }
         $formField->setLabel($this->getFieldLabel($field));
         if (!$formField->isRequired()) {
             // Only trust the $required array for fields
             // that are not marked as required.
             // $required doesn't have all the info, and fields
             // may be required for other reasons than what
             // AddressFormat::getFieldsRequired() says.
             $formField->setRequired(array_key_exists($field, $required));
         }
         $format[$formField->getName()] = $formField;
     }
     return $this->addConstraints($this->addMaxLength($format));
 }
Ejemplo n.º 2
0
 private function _displayIntroTpl()
 {
     $this->context->smarty->assign(array('formCredential' => './index.php?tab=AdminModules&configure=merchantware&token=' . Tools::getAdminTokenLite('AdminModules') . '&tab_module=' . $this->tab . '&module_name=merchantware&subscribeMerchantWare', 'states' => State::getStatesByIdCountry(Country::getByIso('US'))));
     return $this->display(__FILE__, 'tpl/intro.tpl');
 }
Ejemplo n.º 3
0
include_once dirname(__FILE__) . '/../../config/config.inc.php';
include_once dirname(__FILE__) . '/../../init.php';
include_once _PS_MODULE_DIR_ . 'gointerpay/gointerpay.php';
$interpay = new GoInterpay();
if ($interpay->active) {
    /* To check if an address is US based on the Front-office */
    if (Tools::getValue('check_address') == 1 && Tools::getValue('id_address') != '') {
        $address = new Address((int) Tools::getValue('id_address'));
        if (Validate::isLoadedObject($address) && $address->id_customer == Context::getContext()->customer->id) {
            if ((int) Configuration::get('PS_COUNTRY_DEFAULT') == $address->id_country) {
                $flag = true;
                echo '1';
            }
            /* Check that the selected ship to country is available with Interpay */
            $ship_to_iso_code = Country::getIsoById((int) $address->id_country);
            $ship_to_supported_by_interpay = Db::getInstance()->getValue('SELECT country_code FROM ' . _DB_PREFIX_ . 'gointerpay_countries WHERE country_code = \'' . pSQL($ship_to_iso_code) . '\'');
            if ($ship_to_supported_by_interpay != $ship_to_iso_code) {
                $flag = true;
                echo '-1';
            }
            if (!isset($flag)) {
                echo '0';
            }
        }
        die;
    } else {
        $id_country = (int) Tools::getValue('id_country');
        $states[(int) $id_country] = State::getStatesByIdCountry((int) $id_country);
        echo count($states[$id_country]) ? Tools::jsonEncode($states) : 0;
    }
}
    public function renderStates($tax_rules, $id_zone, $id_country, $id_lang)
    {
        $states = State::getStatesByIdCountry((int) $id_country);
        $count_states = count($states);
        $i = 1;
        $html = '';
        foreach ($states as $state) {
            $id_tax = 0;
            $selected = PS_PRODUCT_TAX;
            if ($state['id_zone'] != $id_zone) {
                continue;
            }
            if (array_key_exists($id_country, $tax_rules) && array_key_exists($state['id_state'], $tax_rules[$id_country]) && array_key_exists(0, $tax_rules[$id_country][$state['id_state']])) {
                $id_tax = (int) $tax_rules[$id_country][$state['id_state']][0]['id_tax'];
                $selected = (int) $tax_rules[$id_country][$state['id_state']][0]['state_behavior'];
            }
            $disable = PS_PRODUCT_TAX == $selected ? 'disabled' : '';
            $html .= '
			<tr class="states state_' . (int) $id_country . ' alt_row">
				<td>' . (State::hasCounties($state['id_state']) ? '<a class="open_county" id="county_' . (int) $state['id_state'] . '"><img id="county_' . (int) $state['id_state'] . '_button" class="county_state_' . (int) $id_country . '_button" src="../img/admin/more.png" alt="" /></a>' : '') . '</td>
				<td><img src="../img/admin/lv3_' . ($i == $count_states ? 'f' : 'b') . '.png" alt="" style="vertical-align:middle;" /> <label class="t">' . Tools::htmlentitiesUTF8($state['name']) . '</label></td>
				<td>
					' . $this->renderTaxesSelect($id_lang, $id_tax, array('class' => 'tax_' . $id_zone, 'id' => 'tax_' . $id_country . '_' . $state['id_state'], 'name' => 'tax_' . $id_country . '_' . $state['id_state'], 'disabled' => $disable)) . '&nbsp;-&nbsp;
 					<select id="behavior_state_' . $state['id_state'] . '" name="behavior_state_' . $state['id_state'] . '" onchange="disableStateTaxRate(\'' . $id_country . '\',\'' . $state['id_state'] . '\')">
						<option value="' . (int) PS_PRODUCT_TAX . '" ' . ($selected == PS_PRODUCT_TAX ? 'selected="selected"' : '') . '>' . $this->l('Apply country tax only') . '</option>
						<option value="' . (int) PS_STATE_TAX . '" ' . ($selected == PS_STATE_TAX ? 'selected="selected"' : '') . '>' . $this->l('Apply state tax only') . '</option>
						<option value="' . (int) PS_BOTH_TAX . '" ' . ($selected == PS_BOTH_TAX ? 'selected="selected"' : '') . '>' . $this->l('Apply both taxes') . '</option>
					</select>
				</td>
			</tr>
			';
            if (State::hasCounties($state['id_state'])) {
                $html .= $this->renderCounties($tax_rules, $id_zone, $id_country, $state['id_state'], $id_lang);
            }
            $i++;
        }
        return $html;
    }
<?php

defined('DS') ? null : define('DS', DIRECTORY_SEPARATOR);
require_once dirname(__FILE__) . '../../config/config.inc.php';
require_once dirname(__FILE__) . '../../init.php';
$data = array();
$id_country = Country::getIdByName(1, Tools::getValue('country'));
$contain_state = Country::containsStates($id_country);
if ($contain_state) {
    $states = State::getStatesByIdCountry($id_country);
    $data['states'] = $states;
}
$data['id_country'] = $id_country;
$data['contain_state'] = $contain_state;
echo json_encode($data);
 protected function _assignAddress()
 {
     //if guest checkout disabled and flag is_guest  in cookies is actived
     if (Configuration::get('PS_GUEST_CHECKOUT_ENABLED') == 0 and (int) self::$cookie->is_guest != Configuration::get('PS_GUEST_CHECKOUT_ENABLED')) {
         self::$cookie->logout();
         Tools::redirect('');
     } elseif (!Customer::getAddressesTotalById((int) self::$cookie->id_customer)) {
         //Tools::redirect('address.php?back=order.php?step=1');
         //self::$smarty->assign('no_address', 1);
     }
     $customer = new Customer((int) self::$cookie->id_customer);
     if (Validate::isLoadedObject($customer)) {
         /* Getting customer addresses */
         $customerAddresses = $customer->getAddresses((int) self::$cookie->id_lang);
         // Getting a list of formated address fields with associated values
         $formatedAddressFieldsValuesList = array();
         foreach ($customerAddresses as $address) {
             $tmpAddress = new Address($address['id_address']);
             $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields'] = AddressFormat::getOrderedAddressFields($address['id_country']);
             $formatedAddressFieldsValuesList[$address['id_address']]['formated_fields_values'] = AddressFormat::getFormattedAddressFieldsValues($tmpAddress, $formatedAddressFieldsValuesList[$address['id_address']]['ordered_fields']);
             unset($tmpAddress);
         }
         self::$smarty->assign(array('addresses' => $customerAddresses, 'formatedAddressFieldsValuesList' => $formatedAddressFieldsValuesList));
         /* Setting default addresses for cart */
         if ((!isset(self::$cart->id_address_delivery) or empty(self::$cart->id_address_delivery)) and sizeof($customerAddresses)) {
             self::$cart->id_address_delivery = (int) $customerAddresses[0]['id_address'];
             $update = 1;
         }
         if ((!isset(self::$cart->id_address_invoice) or empty(self::$cart->id_address_invoice)) and sizeof($customerAddresses)) {
             self::$cart->id_address_invoice = (int) $customerAddresses[0]['id_address'];
             $update = 1;
         }
         /* Update cart addresses only if needed */
         if (isset($update) and $update) {
             self::$cart->update();
         }
         /* If delivery address is valid in cart, assign it to Smarty */
         if (isset(self::$cart->id_address_delivery)) {
             $deliveryAddress = new Address((int) self::$cart->id_address_delivery);
             if ($deliveryAddress->id_state) {
                 $deliveryAddress->state = State::getNameById($deliveryAddress->id_state);
             }
             if (Validate::isLoadedObject($deliveryAddress) and $deliveryAddress->id_customer == $customer->id) {
                 self::$smarty->assign('delivery', $deliveryAddress);
             }
         }
         /* If invoice address is valid in cart, assign it to Smarty */
         if (isset(self::$cart->id_address_invoice)) {
             $invoiceAddress = new Address((int) self::$cart->id_address_invoice);
             if ($invoiceAddress->id_state) {
                 $invoiceAddress->state = State::getNameById($invoiceAddress->id_state);
             }
             if (Validate::isLoadedObject($invoiceAddress) and $invoiceAddress->id_customer == $customer->id) {
                 self::$smarty->assign('invoice', $invoiceAddress);
             }
         }
         //assign countries
         $countries = Country::getCountries(1);
         $country_names = Country::getActiveCountries();
         self::$smarty->assign('countries', $countries);
         self::$smarty->assign('country_names', $country_names);
         if (isset(self::$cookie->id_country)) {
             $id_current_country = self::$cookie->id_country;
         } else {
             $id_current_country = Tools::getValue('id_country', (int) $customer->id_country);
         }
         self::$smarty->assign('current_country', $id_current_country);
         //default to USA
         if (!$id_current_country) {
             $id_current_country = 21;
         }
         //assign states
         $country = new Country($id_current_country);
         if ($country->contains_states) {
             $stateData = State::getStatesByIdCountry($customer->id_country);
             self::$smarty->assign('states', $stateData);
         }
     }
     if ($oldMessage = Message::getMessageByCartId((int) self::$cart->id)) {
         self::$smarty->assign('oldMessage', $oldMessage['message']);
     }
     //Assign token for new address
     self::$smarty->assign('token', Tools::getToken(false));
     self::$smarty->assign('id_carrier', self::$cart->id_carrier);
 }
Ejemplo n.º 7
0
 public function getStatesByIdCountry($id_country, $id_state = '')
 {
     $states = State::getStatesByIdCountry($id_country);
     return sizeof($states) ? $states : array();
 }
Ejemplo n.º 8
0
 public function createPredefServices($dir = 'templates_predef')
 {
     // create predefined services from templates_predef directory
     $cdir = dirname(__FILE__);
     $sdir = dir($cdir . '/' . $dir);
     while (($item = $sdir->read()) !== false) {
         if (!is_dir($cdir . '/' . $dir . '/' . $item)) {
             $file = $cdir . '/' . $dir . '/' . $item;
             $extension = strrchr($file, '.');
             if ($extension == '.mtpl') {
                 $template = file($file, FILE_SKIP_EMPTY_LINES);
                 $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
                 $defaultCarrier = 0;
                 $defaultCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
                 $defaultState = 0;
                 $defaultCondition = 'new:used:refurbished';
                 $defaultStore = (int) Db::getInstance()->getValue('SELECT `id_store` FROM `' . _DB_PREFIX_ . 'store`');
                 $defaultGroup = (int) Db::getInstance()->getValue('SELECT `id_group` FROM `' . _DB_PREFIX_ . 'group`');
                 $engine = 'ExportCSV';
                 if (Country::containsStates($defaultCountry)) {
                     $states = State::getStatesByIdCountry($defaultCountry);
                     if (sizeof($states)) {
                         $defaultState = (int) $states[0]['id_state'];
                     }
                 }
                 $carriers = Carrier::getCarriers($defaultLanguage, true);
                 if ($carriers && sizeof($carriers)) {
                     $defaultCarrier = (int) $carriers[0]['id_carrier'];
                 }
                 $additionalProperties = array('id_lang' => $defaultLanguage, 'id_country' => $defaultCountry, 'id_state' => $defaultState, 'id_carrier' => $defaultCarrier, 'id_store' => $defaultStore, 'id_group' => $defaultGroup, 'export_engine' => $engine, 'condition' => $defaultCondition);
                 if (sizeof($template) > 0) {
                     $obj = new MoussiqFreeService();
                     foreach ($template as $line) {
                         $line = explode(':', $line);
                         $field = pSQL(base64_decode($line[0]));
                         if ($field == 'template') {
                             $line[1] = base64_decode($line[1]);
                         }
                         $value = base64_decode($line[1]);
                         //print_r(pSQL(base64_decode($line[1])));
                         //print_r($value);
                         if (property_exists($obj, $field)) {
                             $obj->{$field} = $value;
                         }
                         foreach ($additionalProperties as $prop => $val) {
                             if (property_exists($obj, $prop)) {
                                 $obj->{$prop} = $val;
                             }
                         }
                     }
                     if (!$obj->save()) {
                         return false;
                     }
                 }
             }
         }
     }
 }
 protected function createServiceFromTemplate($file)
 {
     if (empty($file['name'])) {
         $this->_errors[] = $this->l('Please select a file from your computer');
         return false;
     }
     $extension = strrchr($file['name'], '.');
     if ($extension == '.gz' && !function_exists('gzopen')) {
         $this->_errors[] = $this->l('Your server does not support gz functions, please unpack the file locally and upload again');
         return false;
     }
     if ($extension == '.mtpl') {
         $template = file($file['tmp_name'], FILE_SKIP_EMPTY_LINES);
     } elseif ($extension == '.gz') {
         $template = gzfile($file['tmp_name']);
     } else {
         $this->_errors[] = $this->l('Unknown file format');
         return false;
     }
     $defaultLanguage = (int) Configuration::get('PS_LANG_DEFAULT');
     $defaultCarrier = 0;
     $defaultCountry = (int) Configuration::get('PS_COUNTRY_DEFAULT');
     $defaultState = 0;
     $defaultCondition = 'new:used:refurbished';
     $defaultStore = (int) Db::getInstance()->getValue('SELECT `id_store` FROM `' . _DB_PREFIX_ . 'store`');
     $defaultGroup = (int) Db::getInstance()->getValue('SELECT `id_group` FROM `' . _DB_PREFIX_ . 'group`');
     $engines = self::getExportEnginesForSetup();
     if (!sizeof($engines)) {
         $this->_errors[] = $this->l('Please add export engines first');
         return false;
     }
     $engine = $engines[0]['engine'];
     if (Country::containsStates($defaultCountry)) {
         $states = State::getStatesByIdCountry($defaultCountry);
         if (sizeof($states)) {
             $defaultState = (int) $states[0]['id_state'];
         }
     }
     $carriers = Carrier::getCarriers($defaultLanguage, true);
     if ($carriers && sizeof($carriers)) {
         $defaultCarrier = (int) $carriers[0]['id_carrier'];
     }
     $additionalProperties = array('id_lang' => $defaultLanguage, 'id_country' => $defaultCountry, 'id_state' => $defaultState, 'id_carrier' => $defaultCarrier, 'id_store' => $defaultStore, 'export_engine' => $engine, 'condition' => $defaultCondition);
     if (sizeof($template) > 0) {
         $obj = new $this->className();
         foreach ($template as $line) {
             $line = explode(':', $line);
             $field = pSQL(base64_decode($line[0]));
             if ($field == 'template') {
                 $line[1] = base64_decode($line[1]);
             }
             $value = base64_decode($line[1]);
             //print_r(pSQL(base64_decode($line[1])));
             //print_r($value);
             if (property_exists($obj, $field)) {
                 $obj->{$field} = $value;
             }
             foreach ($additionalProperties as $prop => $val) {
                 if (property_exists($obj, $prop)) {
                     $obj->{$prop} = $val;
                 }
             }
         }
         if (!$obj->save()) {
             $this->_errors[] = $this->l('A service could not be added, an error occured during an attemt to copy file data into module');
             return false;
         }
     }
 }
 public function ajaxProcessStateByCountryId()
 {
     $country_id = Tools::getValue('id_country');
     $states = array();
     $statesbycountry = State::getStatesByIdCountry($country_id);
     if ($statesbycountry) {
         $states = array();
         foreach ($statesbycountry as $key => $value) {
             $states[$key]['id'] = $value['id_state'];
             $states[$key]['name'] = $value['name'];
         }
         if (isset($states)) {
             die(Tools::jsonEncode($states));
         } else {
             die(Tools::jsonEncode($states));
         }
     } else {
         die(Tools::jsonEncode($states));
     }
 }
Ejemplo n.º 11
0
 public function getStatesByIdCountry($id_country)
 {
     return State::getStatesByIdCountry((int) $id_country);
 }
 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 = "*****@*****.**";
     $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;
 }