Added missing validations in the back office

This commit is contained in:
vishalsingh.qlo325
2025-06-04 13:34:59 +05:30
parent 5da60bb913
commit 800ec6d645
6 changed files with 50 additions and 8 deletions

View File

@@ -17,7 +17,7 @@
* @license LICENSE.txt
*}
{l s='This room already has a booking for the selected date range.'}
{sprintf({l s='The room "%s" already has a booking for the selected date range.'}, $orderDetails->room_num)}
<div class="row">
<div class="col-xs-12">
<span class="error_message_label">{l s='Order ID'}:</span> <a href="{$link->getAdminLink('AdminOrders')}&id_order={$orderDetails->id_order}&vieworder" target="_blank"><strong>#{$orderDetails->id_order|intval}</strong></a>

View File

@@ -1238,6 +1238,7 @@
};
$('#page-loader').show();
$('[name="submitBulkCreateRooms"]').attr('disabled', 'disable');
$.ajax({
url: prod_link,
type: 'POST',
@@ -1253,6 +1254,7 @@
},
complete: function() {
$('#page-loader').hide();
$('[name="submitBulkCreateRooms"]').attr('disabled', false);
}
});
},

View File

@@ -401,8 +401,20 @@ class AdminLocalizationControllerCore extends AdminController
public function beforeUpdateOptions()
{
$lang = new Language((int)Tools::getValue('PS_LANG_DEFAULT'));
if (!trim(Tools::getValue('PS_WEIGHT_UNIT'))) {
$this->errors[] = sprintf(Tools::displayError('field %s is required.'), $this->l('Weight unit'));
}
if (!trim(Tools::getValue('PS_DISTANCE_UNIT'))) {
$this->errors[] = sprintf(Tools::displayError('field %s is required.'), $this->l('Distance unit'));
}
if (!trim(Tools::getValue('PS_DIMENSION_UNIT'))) {
$this->errors[] = sprintf(Tools::displayError('field %s is required.'), $this->l('Dimension unit'));
}
if (!trim(Tools::getValue('PS_VOLUME_UNIT'))) {
$this->errors[] = sprintf(Tools::displayError('field %s is required.'), $this->l('Volume unit'));
}
$lang = new Language((int)Tools::getValue('PS_LANG_DEFAULT'));
if (!$lang->active) {
$lang->active = 1;
$lang->save();

View File

@@ -5304,6 +5304,7 @@ class AdminProductsControllerCore extends AdminController
if ($idRooms = Tools::getValue('id_rooms')) {
$rowsToHighlight = array();
$room = array();
$bookedRows = array();
if (trim($floor = Tools::getValue('floor'))) {
$room['floor'] = $floor;
if (!Validate::isGenericName($floor)) {
@@ -5371,7 +5372,8 @@ class AdminProductsControllerCore extends AdminController
}
} else if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE && $disableDates) {
foreach ($disableDates as $key => $dateRange) {
if ($objHotelBookingDetail->chechRoomBooked($idRoom, $dateRange['date_from'], $dateRange['date_to'])) {
if ($bookingRow = $objHotelBookingDetail->chechRoomBooked($idRoom, $dateRange['date_from'], $dateRange['date_to'])) {
$bookedRows[$bookingRow['id']] = new HotelBookingDetail($bookingRow['id']);
$rowsToHighlight[] = $key;
}
}
@@ -5382,6 +5384,18 @@ class AdminProductsControllerCore extends AdminController
Hook::exec('actionValidateRoomInformation', array('room_information' => $room));
}
if (count($bookedRows)) {
foreach ($bookedRows as $bookedRow) {
$this->context->smarty->assign(array(
'link' => $this->context->link,
'orderDetails' => $bookedRow,
));
$this->errors[] = $this->context->smarty->fetch('controllers/products/booked_room_date_ranges_list.tpl');
}
}
}
if (empty($this->errors)) {
@@ -5468,7 +5482,7 @@ class AdminProductsControllerCore extends AdminController
if (!($roomQuantity = Tools::getValue('qty'))) {
$this->errors[] = Tools::displayError('Number of rooms is required.');
} else if ($roomQuantity < 1) {
} else if (!Validate::isUnsignedInt($roomQuantity) || $roomQuantity < 1) {
$this->errors[] = Tools::displayError('Invalid value for number of rooms.');
}

View File

@@ -143,12 +143,25 @@ class AdminHotelBedTypesController extends ModuleAdminController
return;
}
if (!trim(Tools::getValue('width'))) {
$this->errors[] = $this->l('Field Width is required');
$defaultLangId = Configuration::get('PS_LANG_DEFAULT');
$objDefaultLanguage = Language::getLanguage((int) $defaultLangId);
$languages = Language::getLanguages(false);
if (!trim(Tools::getValue('name_'.$defaultLangId))) {
$this->errors[] = $this->l('Bed type name is required at least in ').$objDefaultLanguage['name'];
} else {
foreach ($languages as $lang) {
if (trim(Tools::getValue('name_'.$lang['id_lang'])) && !Validate::isGenericName(Tools::getValue('name_'.$lang['id_lang']))) {
$this->errors[] = $this->l('Invalid bed type name in ').$lang['name'];
}
}
}
if (!trim(Tools::getValue('length'))) {
$this->errors[] = $this->l('Field Length is required');
if (!(float) Tools::getValue('width')) {
$this->errors[] = $this->l('The width field is required');
}
if (!(float) Tools::getValue('length')) {
$this->errors[] = $this->l('The length field is required');
}
return parent::processSave();

View File

@@ -510,6 +510,7 @@ class HotelReservationSystem extends Module
'htl_room_type_global_demand_advance_option',
'htl_order_refund_rules',
'htl_settings_link',
'htl_bed_type'
);
//If Admin update new language when we do entry in module all lang tables.
HotelHelper::updateLangTables($newIdLang, $langTables);