diff --git a/modules/hotelreservationsystem/classes/HotelHelper.php b/modules/hotelreservationsystem/classes/HotelHelper.php index d8f9b10d2..db3e44d19 100644 --- a/modules/hotelreservationsystem/classes/HotelHelper.php +++ b/modules/hotelreservationsystem/classes/HotelHelper.php @@ -1312,30 +1312,79 @@ class HotelHelper public function createHotelDefaultPropertyTypes() { $propertyTypes = array( - 'Hotel', - 'Motel', - 'Resort', - 'Hostel', - 'Guest House', - 'Bed & Breakfast', - 'Lodge', - 'Apartment', - 'Vacation Rental', - 'Homestay', - 'Co-Living', - 'Camping', - 'Glamping', - 'Farm Stay', - 'Houseboat', - 'Boat Stay', + array( + 'name' => 'Hotel', + 'plural_name' => 'Hotels', + ), + array( + 'name' => 'Motel', + 'plural_name' => 'Motels', + ), + array( + 'name' => 'Resort', + 'plural_name' => 'Resorts', + ), + array( + 'name' => 'Hostel', + 'plural_name' => 'Hostels', + ), + array( + 'name' => 'Guest House', + 'plural_name' => 'Guest Houses', + ), + array( + 'name' => 'Bed & Breakfast', + 'plural_name' => 'Bed & Breakfasts', + ), + array( + 'name' => 'Lodge', + 'plural_name' => 'Lodges', + ), + array( + 'name' => 'Apartment', + 'plural_name' => 'Apartments', + ), + array( + 'name' => 'Vacation Rental', + 'plural_name' => 'Vacation Rentals', + ), + array( + 'name' => 'Homestay', + 'plural_name' => 'Homestays', + ), + array( + 'name' => 'Co-Living', + 'plural_name' => 'Co-Livings', + ), + array( + 'name' => 'Camping', + 'plural_name' => 'Campings', + ), + array( + 'name' => 'Glamping', + 'plural_name' => 'Glampings', + ), + array( + 'name' => 'Farm Stay', + 'plural_name' => 'Farm Stays', + ), + array( + 'name' => 'Houseboat', + 'plural_name' => 'Houseboats', + ), + array( + 'name' => 'Boat Stay', + 'plural_name' => 'Boat Stays', + ), ); $languages = Language::getLanguages(true); - foreach ($propertyTypes as $typeName) { + foreach ($propertyTypes as $propertyType) { $objType = new HotelPropertyType(); $objType->active = 1; foreach ($languages as $lang) { - $objType->name[$lang['id_lang']] = $typeName; + $objType->name[$lang['id_lang']] = $propertyType['name']; + $objType->plural_name[$lang['id_lang']] = $propertyType['plural_name']; } $objType->save(); } diff --git a/modules/hotelreservationsystem/classes/HotelPropertyType.php b/modules/hotelreservationsystem/classes/HotelPropertyType.php index 14dde5724..c1486e8af 100644 --- a/modules/hotelreservationsystem/classes/HotelPropertyType.php +++ b/modules/hotelreservationsystem/classes/HotelPropertyType.php @@ -27,6 +27,7 @@ class HotelPropertyType extends ObjectModel public $date_add; public $date_upd; public $name; + public $plural_name; public static $definition = array( 'table' => 'htl_property_type', @@ -37,6 +38,7 @@ class HotelPropertyType extends ObjectModel 'date_add' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), 'date_upd' => array('type' => self::TYPE_DATE, 'validate' => 'isDate', 'copy_post' => false), 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), + 'plural_name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 255), ), ); @@ -46,6 +48,7 @@ class HotelPropertyType extends ObjectModel 'objectMethods' => array('update' => 'updateWs', 'delete' => 'deleteWs'), 'fields' => array( 'name' => array('required' => true), + 'plural_name' => array('required' => true), 'active' => array('required' => false), ), ); @@ -121,7 +124,7 @@ class HotelPropertyType extends ObjectModel $cacheKey = 'HotelPropertyType::getPropertyTypes'.$idLang.'_'.(int) $active; if (!Cache::isStored($cacheKey)) { - $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hptl.`name` + $sql = 'SELECT hpt.`id_htl_property_type` AS `id_property_type`, hptl.`name`, hptl.`plural_name` FROM `'._DB_PREFIX_.'htl_property_type` hpt LEFT JOIN `'._DB_PREFIX_.'htl_property_type_lang` hptl ON (hpt.`id_htl_property_type` = hptl.`id_htl_property_type` diff --git a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php index 32542bc30..d2fca3b04 100644 --- a/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php +++ b/modules/hotelreservationsystem/classes/HotelReservationSystemDb.php @@ -142,6 +142,7 @@ class HotelReservationSystemDb `id_htl_property_type` int(10) unsigned NOT NULL, `id_lang` int(10) unsigned NOT NULL, `name` varchar(255) NOT NULL, + `plural_name` varchar(255) NOT NULL, PRIMARY KEY (`id_htl_property_type`, `id_lang`) ) ENGINE="._MYSQL_ENGINE_." DEFAULT CHARSET=utf8;", "CREATE TABLE IF NOT EXISTS `"._DB_PREFIX_."htl_branch_amenity` ( diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php index d3485a680..e59a8e6be 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelPropertyTypesController.php @@ -45,6 +45,10 @@ class AdminHotelPropertyTypesController extends ModuleAdminController 'title' => $this->l('Name'), 'align' => 'left', ), + 'plural_name' => array( + 'title' => $this->l('Plural Name'), + 'align' => 'left', + ), 'active' => array( 'title' => $this->l('Status'), 'align' => 'center', @@ -109,6 +113,14 @@ class AdminHotelPropertyTypesController extends ModuleAdminController 'required' => true, 'hint' => $this->l('Displayed name for this property type.'), ), + array( + 'type' => 'text', + 'label' => $this->l('Plural Name'), + 'name' => 'plural_name', + 'lang' => true, + 'required' => true, + 'hint' => $this->l('Displayed name when referring to more than one property of this type.'), + ), array( 'type' => 'switch', 'label' => $this->l('Enabled'), @@ -166,6 +178,18 @@ class AdminHotelPropertyTypesController extends ModuleAdminController } } + if (!trim(Tools::getValue('plural_name_'.$defaultLangId))) { + $this->errors[] = $this->l('Plural Name is required at least in ').$objDefaultLanguage['name']; + } else { + foreach ($languages as $lang) { + if (trim(Tools::getValue('plural_name_'.$lang['id_lang']))) { + if (!Validate::isGenericName(Tools::getValue('plural_name_'.$lang['id_lang']))) { + $this->errors[] = $this->l('Invalid Plural Name in ').$lang['name']; + } + } + } + } + $this->display = $idPropertyType ? 'edit' : 'add'; if (!$this->errors && !Tools::getValue('active') && $idPropertyType) {