Added: comments for the disable date jquery, updated the flow, and optimized the code, and fixed some design issues
This commit is contained in:
@@ -9,52 +9,44 @@
|
||||
padding: 4px
|
||||
.highlight-event-day
|
||||
background: #F5F5F5
|
||||
.display_title
|
||||
.event_title_container
|
||||
text-overflow: ellipsis
|
||||
white-space: nowrap
|
||||
max-width: 65%
|
||||
overflow: hidden
|
||||
border-left: 2px solid red
|
||||
padding-left: 10px
|
||||
#disabled_dates_form
|
||||
#disable_dates_form
|
||||
.date_from_container, .date_to_container
|
||||
.ui-datepicker
|
||||
position: absolute
|
||||
top: 62px
|
||||
left: 5px
|
||||
position: relative
|
||||
textarea
|
||||
border-radius: 4px
|
||||
.form-group
|
||||
.control-label
|
||||
margin-bottom: 5px
|
||||
.btn
|
||||
margin-top: 10px
|
||||
margin-left: 5px
|
||||
border-radius: 5px
|
||||
margin: 0
|
||||
padding-right: 0px
|
||||
padding: 10px
|
||||
.modal-title
|
||||
.add_new_dates, .close
|
||||
.add_disable_dates, .close
|
||||
margin-right: 10px
|
||||
.remove_dates_btn
|
||||
.remove_disable_dates
|
||||
margin-right: 20px
|
||||
.close
|
||||
line-height: 2
|
||||
.disabled-dates-modal-title
|
||||
.disabled-dates-modal-room-num
|
||||
.disable_dates_title
|
||||
.disable_dates_room_num
|
||||
color: grey
|
||||
display: inline-block
|
||||
font-weight: 600
|
||||
line-height: 2
|
||||
.form-title-text
|
||||
font-size: 15px
|
||||
.delete_disabled_dates
|
||||
.delete_disable_dates
|
||||
margin-left: 10px
|
||||
.delete_disabled_dates:hover , .edit_disabled_dates:hover
|
||||
.delete_disable_dates:hover , .edit_disable_dates:hover
|
||||
cursor: pointer
|
||||
.date_from_container, .date_to_container
|
||||
.ui-datepicker
|
||||
position: absolute
|
||||
top: 60px
|
||||
left: 5px
|
||||
padding-right: 0
|
||||
position: relative
|
||||
.tooltip_info_block
|
||||
.tooltip_title
|
||||
margin: 10px 5px
|
||||
@@ -70,19 +62,19 @@
|
||||
font-weight: 400
|
||||
color: #888888
|
||||
margin-bottom: 5px
|
||||
.tooltip_content_label
|
||||
.tooltip_event_title
|
||||
border: 1px solid #D9D9D9
|
||||
border-radius: 6px
|
||||
padding: 5px 10px
|
||||
.tooltip_content
|
||||
.tooltip_reason_container, .module_event_id
|
||||
.tooltip_reason_container, .id_event
|
||||
margin-top: 10px
|
||||
&> div
|
||||
display: inline-block
|
||||
.row
|
||||
margin-left: 0
|
||||
margin-right: 0
|
||||
ul.disabled_dates_actions
|
||||
ul.disable_dates_actions
|
||||
.btn
|
||||
text-align: left
|
||||
display: block
|
||||
|
||||
@@ -127,21 +127,21 @@ html
|
||||
|
||||
#deactiveDatesModal
|
||||
.tooltip_container
|
||||
.disabled_dates_actions
|
||||
.disable_dates_actions
|
||||
.btn
|
||||
text-align: right !important
|
||||
padding-inline-start: unset
|
||||
.display_title
|
||||
.event_title_container
|
||||
border-left: unset !important
|
||||
border-right: 2px solid red !important
|
||||
padding-right: 10px !important
|
||||
padding-left: unset !important
|
||||
.fc-event-title-container
|
||||
direction: rtl !important
|
||||
.delete_disabled_dates
|
||||
.delete_disable_dates
|
||||
margin-left: unset !important
|
||||
margin-right: 10px
|
||||
.remove_dates_btn
|
||||
.remove_disable_dates
|
||||
margin-right: 10px !important
|
||||
margin-left: 20px
|
||||
.fc-toolbar > * > :not(:first-child)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -2975,34 +2975,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
$room['booked_dates'] = json_encode($bookedDates);
|
||||
|
||||
if ($room['id_status'] == HotelRoomInformation::STATUS_TEMPORARY_INACTIVE) {
|
||||
if ($disabledDates = $objRoomDisableDates->getRoomDisableDates($room['id'])) {
|
||||
foreach ($disabledDates as $disabledDatesKey => $dates) {
|
||||
// To display the disabled dates events with date_to as inclusive in the full calendar
|
||||
$disabledDates[$disabledDatesKey]['date_to'] = date('Y-m-d', strtotime($dates['date_to']));
|
||||
$disabledDates[$disabledDatesKey]['date_add'] = date('Y-m-d', strtotime($dates['date_add']));
|
||||
if (!isset($dates['id_external_event'])) {
|
||||
$disabledDates[$disabledDatesKey]['id_external_event'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($dates['is_editable'])) {
|
||||
$disabledDates[$disabledDatesKey]['is_editable'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($dates['is_deletable'])) {
|
||||
$disabledDates[$disabledDatesKey]['is_deletable'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($dates['event_title'])) {
|
||||
$disabledDates[$disabledDatesKey]['event_title'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($dates['external_event_url'])) {
|
||||
$disabledDates[$disabledDatesKey]['external_event_url'] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$room['disable_dates_json'] = json_encode($disabledDates);
|
||||
$disableDates = $objRoomDisableDates->getRoomDisableDates($room['id']);
|
||||
$room['disable_dates_json'] = json_encode($disableDates);
|
||||
}
|
||||
}
|
||||
$data->assign('htl_room_info', $hotelRoomInfo);
|
||||
@@ -5018,7 +4992,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
$dateTo = Tools::getValue('date_to');
|
||||
$idProduct = Tools::getValue('id_product');
|
||||
if (!Validate::isDate($dateFrom) || !Validate::isDate($dateTo)) {
|
||||
$this->errors[] = $this->l('Please select the date range during which the room will be disabled.');
|
||||
$this->errors[] = $this->l('Please select valid date range to temporary disable this room');
|
||||
} else if ($idRoom && Validate::isLoadedObject($objHotelRoomInfo = new HotelRoomInformation((int) $idRoom))) {
|
||||
$dateTo = date('Y-m-d', strtotime($dateTo));
|
||||
$objHotelBookingDetail = new HotelBookingDetail();
|
||||
@@ -5031,8 +5005,8 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
$this->errors[] = $this->context->smarty->fetch('controllers/products/booked_room_date_ranges_list.tpl');
|
||||
} else {
|
||||
if (!Tools::getValue('id_disabled_date')
|
||||
|| !Validate::isLoadedObject($objHotelRoomDisableDates = new HotelRoomDisableDates((int) Tools::getValue('id_disabled_date')))
|
||||
if (!Tools::getValue('id_disable_date')
|
||||
|| !Validate::isLoadedObject($objHotelRoomDisableDates = new HotelRoomDisableDates((int) Tools::getValue('id_disable_date')))
|
||||
) {
|
||||
$objHotelRoomDisableDates = new HotelRoomDisableDates();
|
||||
$objHotelRoomDisableDates->id_room_type = $idProduct;
|
||||
@@ -5046,11 +5020,11 @@ class AdminProductsControllerCore extends AdminController
|
||||
if ($objHotelRoomInfo->save()
|
||||
&& $objHotelRoomDisableDates->save()
|
||||
) {
|
||||
$response['id_disabled_date'] = $objHotelRoomDisableDates->id;
|
||||
if (Tools::getValue('id_disabled_date')) {
|
||||
$response['id_disable_date'] = $objHotelRoomDisableDates->id;
|
||||
if (Tools::getValue('id_disable_date')) {
|
||||
$this->confirmations[] = $this->l('Successfully updated.');
|
||||
} else {
|
||||
$this->confirmations[] = $this->l('Room disabled successfully for the specified date range.');
|
||||
$this->confirmations[] = $this->l('Disable date added successfully.');
|
||||
}
|
||||
} else {
|
||||
$this->errors[] = Tools::displayError('An error occurred while trying to save the disable dates.');
|
||||
@@ -5073,14 +5047,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessRemoveSelectedDate()
|
||||
public function ajaxProcessRemoveDisableDatesInDateRange()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
$idRoom = (int) Tools::getValue('id_room');
|
||||
$dateFrom = date('Y-m-d', strtotime(Tools::getValue('date_from')));
|
||||
$dateTo = date('Y-m-d', strtotime(Tools::getValue('date_to')));
|
||||
if (!Tools::getValue('date_from') || !Tools::getValue('date_to')) {
|
||||
$this->errors[] = Tools::displayError('Please select the date range to enable the room.');
|
||||
$this->errors[] = Tools::displayError('Please select valid date range.');
|
||||
} else {
|
||||
$objRoomDisableDates = new HotelRoomDisableDates();
|
||||
$params = array(
|
||||
@@ -5088,18 +5062,18 @@ class AdminProductsControllerCore extends AdminController
|
||||
'date_to' => $dateTo,
|
||||
'id_room' => $idRoom
|
||||
);
|
||||
Hook::exec('actionRoomDisabledDatesRemoveBefore', array('disabled_dates', $params));
|
||||
Hook::exec('actionRoomDisableDatesRemoveBefore', array('disable_dates', $params));
|
||||
if (empty($this->errors)
|
||||
&& ($disabledDates = $objRoomDisableDates->checkIfRoomAlreadyDisabled($params))
|
||||
&& ($disableDates = $objRoomDisableDates->checkIfRoomAlreadyDisabled($params))
|
||||
) {
|
||||
$newDates = array();
|
||||
foreach ($disabledDates as $disabledDatesInfo) {
|
||||
$objRoomDisableDates = new HotelRoomDisableDates($disabledDatesInfo['id']);
|
||||
$newDates[0]['date_from'] = $disabledDatesInfo['date_from'];
|
||||
foreach ($disableDates as $disableDatesInfo) {
|
||||
$objRoomDisableDates = new HotelRoomDisableDates($disableDatesInfo['id']);
|
||||
$newDates[0]['date_from'] = $disableDatesInfo['date_from'];
|
||||
$newDates[0]['date_to'] = $params['date_from'];
|
||||
|
||||
$newDates[1]['date_from'] = $params['date_to'];
|
||||
$newDates[1]['date_to'] = date('Y-m-d', strtotime($disabledDatesInfo['date_to']));
|
||||
$newDates[1]['date_to'] = date('Y-m-d', strtotime($disableDatesInfo['date_to']));
|
||||
|
||||
if (strtotime($newDates[0]['date_from']) >= strtotime($newDates[0]['date_to'])) {
|
||||
unset($newDates[0]);
|
||||
@@ -5110,18 +5084,18 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
|
||||
foreach ($newDates as $newDate) {
|
||||
$objNewDisabledDates = new HotelRoomDisableDates();
|
||||
$objNewDisabledDates->id_room_type = $objRoomDisableDates->id_room_type;
|
||||
$objNewDisabledDates->id_room = $objRoomDisableDates->id_room;
|
||||
$objNewDisabledDates->date_from = $newDate['date_from'];
|
||||
$objNewDisabledDates->date_to = $newDate['date_to'];
|
||||
$objNewDisabledDates->reason = $objRoomDisableDates->reason;
|
||||
$objNewDisabledDates->save();
|
||||
$objNewDisableDates = new HotelRoomDisableDates();
|
||||
$objNewDisableDates->id_room_type = $objRoomDisableDates->id_room_type;
|
||||
$objNewDisableDates->id_room = $objRoomDisableDates->id_room;
|
||||
$objNewDisableDates->date_from = $newDate['date_from'];
|
||||
$objNewDisableDates->date_to = $newDate['date_to'];
|
||||
$objNewDisableDates->reason = $objRoomDisableDates->reason;
|
||||
$objNewDisableDates->save();
|
||||
}
|
||||
|
||||
$objRoomDisableDates->delete();
|
||||
}
|
||||
} else if (!$disabledDates) {
|
||||
} else if (!$disableDates) {
|
||||
$this->errors[] = Tools::displayError('Room is not disabled for the selected date range.');
|
||||
}
|
||||
}
|
||||
@@ -5131,36 +5105,13 @@ class AdminProductsControllerCore extends AdminController
|
||||
} else {
|
||||
$response['status'] = true;
|
||||
$this->confirmations[] = $this->l('Removed successfully.');
|
||||
if ($disabledDates = $objRoomDisableDates->getRoomDisableDates($idRoom)) {
|
||||
foreach ($disabledDates as $disabledDatesKey => $dates) {
|
||||
$disabledDates[$disabledDatesKey]['date_add'] = date('Y-m-d', strtotime($dates['date_add']));
|
||||
if (!isset($dates['id_external_event'])) {
|
||||
$disabledDates[$disabledDatesKey]['id_external_event'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($dates['is_editable'])) {
|
||||
$disabledDates[$disabledDatesKey]['is_editable'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($dates['is_deletable'])) {
|
||||
$disabledDates[$disabledDatesKey]['is_deletable'] = 1;
|
||||
}
|
||||
|
||||
if (!isset($dates['event_title'])) {
|
||||
$disabledDates[$disabledDatesKey]['event_title'] = 0;
|
||||
}
|
||||
|
||||
if (!isset($dates['external_event_url'])) {
|
||||
$disabledDates[$disabledDatesKey]['external_event_url'] = 0;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (!($disableDates = $objRoomDisableDates->getRoomDisableDates($idRoom))) {
|
||||
$objRoomInfo = new HotelRoomInformation($idRoom);
|
||||
$objRoomInfo->id_status = HotelRoomInformation::STATUS_ACTIVE;
|
||||
$objRoomInfo->save();
|
||||
}
|
||||
|
||||
$response['disabled_dates'] = $disabledDates;
|
||||
$response['disable_dates'] = $disableDates;
|
||||
}
|
||||
|
||||
$this->assignAlerts();
|
||||
@@ -5168,14 +5119,29 @@ class AdminProductsControllerCore extends AdminController
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessDeleteDisabledDate()
|
||||
public function ajaxProcessGetDisableDates()
|
||||
{
|
||||
$response['status'] = false;
|
||||
if (($idRoom = Tools::getValue('id_room'))
|
||||
&& Validate::isLoadedObject(new HotelRoomInformation($idRoom))
|
||||
) {
|
||||
$objRoomDisableDates = new HotelRoomDisableDates();
|
||||
$disableDates = $objRoomDisableDates->getRoomDisableDates($idRoom);
|
||||
$response['status'] = true;
|
||||
$response['disable_dates'] = $disableDates;
|
||||
}
|
||||
|
||||
$this->ajaxDie(json_encode($response));
|
||||
}
|
||||
|
||||
public function ajaxProcessDeleteDisableDate()
|
||||
{
|
||||
$response = array('status' => false);
|
||||
$idDisabledDate = Tools::getValue('id_disabled_date');
|
||||
Hook::exec('actionDisabledDateDeleteBefore', array('id_disabled_date', $idDisabledDate));
|
||||
$idDisableDate = Tools::getValue('id_disable_date');
|
||||
Hook::exec('actionDisableDateDeleteBefore', array('id_disable_date', $idDisableDate));
|
||||
if (empty($this->errors)
|
||||
&& (int) $idDisabledDate
|
||||
&& Validate::isLoadedObject($objRoomDisableDates = new HotelRoomDisableDates($idDisabledDate))
|
||||
&& (int) $idDisableDate
|
||||
&& Validate::isLoadedObject($objRoomDisableDates = new HotelRoomDisableDates($idDisableDate))
|
||||
) {
|
||||
$idRoom = $objRoomDisableDates->id_room;
|
||||
if (!$objRoomDisableDates->delete()) {
|
||||
|
||||
@@ -45,10 +45,14 @@ class HotelRoomDisableDates extends ObjectModel
|
||||
|
||||
public function getRoomDisableDates($id_room)
|
||||
{
|
||||
$disabledDates = Db::getInstance()->executeS('SELECT `id`, `date_from`, `date_to`, `reason`, `date_add` FROM `'._DB_PREFIX_.'htl_room_disable_dates` WHERE `id_room`='.(int) $id_room);
|
||||
$disabledDates = Db::getInstance()->executeS('SELECT `id`, `date_from`, `date_to`, `reason`, `date_add`,
|
||||
NULL AS `id_event`, NULL AS `event_url`, NULL AS `event_title`, 1 AS `is_editable`, 1 AS `is_deletable`
|
||||
FROM `'._DB_PREFIX_.'htl_room_disable_dates` WHERE `id_room`='.(int) $id_room
|
||||
);
|
||||
|
||||
Hook::exec('actionRoomDisabledDatesModifier',
|
||||
array(
|
||||
'disabled_dates' => &$disabledDates,
|
||||
'disable_dates' => &$disabledDates,
|
||||
'id_room' => $id_room
|
||||
)
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user