Added: Support for plural names in MP themes

This commit is contained in:
amit sharma
2026-11-02 18:44:10 +05:30
parent 3be9022f8a
commit 793ed6fee2
4 changed files with 96 additions and 19 deletions

View File

@@ -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();
}

View File

@@ -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`

View File

@@ -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` (

View File

@@ -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) {