From b41730867c2f70d7a09852f24b778f67858b340c Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 27 Dec 2018 17:23:15 +0100 Subject: [PATCH 01/26] [FIX] Popover destroy behaviour --- hotel_calendar/static/src/css/view.css | 2 +- .../calendar/hotel_calendar_controller.js | 20 ++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/hotel_calendar/static/src/css/view.css b/hotel_calendar/static/src/css/view.css index 6bcf10640..4989fcc46 100644 --- a/hotel_calendar/static/src/css/view.css +++ b/hotel_calendar/static/src/css/view.css @@ -173,7 +173,7 @@ input#bookings_search { max-width: 550px; } .popover .container { - max-width: -webkit-fill-available; + max-width: 100%; } .popover .container p { margin-top: 3px; diff --git a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js index 1b3f68524..ae61e03c2 100644 --- a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js +++ b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js @@ -375,6 +375,11 @@ var PMSCalendarController = AbstractController.extend({ self.savePricelist(ev.detail.calendar_obj, ev.detail.pricelist_id, ev.detail.pricelist); }); $('.hcal-reservation noselect').popover(); + var _destroy_and_clear_popover_mark = function(ev){ + $(".marked-as-having-a-popover").popover('destroy'); + $('.hcal-reservation').removeClass("marked-as-having-a-popover"); + }; + this._multi_calendar.on_calendar('hcalOnClickReservation', function(ev){ if (ev.detail.reservationObj) { var tp = self._multi_calendar._reserv_tooltips[ev.detail.reservationObj.id]; @@ -382,18 +387,23 @@ var PMSCalendarController = AbstractController.extend({ $(".marked-as-having-a-popover").popover('destroy'); $(ev.detail.reservationDiv).addClass('marked-as-having-a-popover'); var $reservationPopover = $(ev.detail.reservationDiv).popover({ - trigger: 'click focus', + trigger: 'manual', container: 'body', animation: false, html: true, placement: 'bottom', - /* title: "Come'n popovers!", */ content: QWeb.render('HotelCalendar.TooltipReservation', qdict) }).popover('show'); + /* destroy popover if mouse click is done out the popover */ + $(document).click(function(e){ + if( $(e.target).closest(".popover-content").length == 0 && $(e.target).hasClass("marked-as-having-a-popover") == false ) { + _destroy_and_clear_popover_mark(); + } + }); /* add actions */ $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_folio").on('click', {folio_id: ev.detail.reservationObj._userData.folio_id}, function(ev){ - $(".marked-as-having-a-popover").popover('destroy'); + _destroy_and_clear_popover_mark(); self.do_action({ type: 'ir.actions.act_window', res_model: 'hotel.folio', @@ -403,7 +413,7 @@ var PMSCalendarController = AbstractController.extend({ }); $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_reservation").on('click', {reservation_id: ev.detail.reservationObj.id}, function(ev){ - $(".marked-as-having-a-popover").popover('destroy'); + _destroy_and_clear_popover_mark(); self.do_action({ type: 'ir.actions.act_window', res_model: 'hotel.reservation', @@ -412,7 +422,7 @@ var PMSCalendarController = AbstractController.extend({ }); }); $reservationPopover.data('bs.popover').tip().find(".btn_popover_close").on('click', function(ev){ - $(".marked-as-having-a-popover").popover('destroy'); + _destroy_and_clear_popover_mark(); }); } }); From 99188b2a91f6b0061aac3c4c8be727f1e59a7920 Mon Sep 17 00:00:00 2001 From: Pablo Date: Thu, 27 Dec 2018 17:27:23 +0100 Subject: [PATCH 02/26] [UPD] Increase _lazyModeReservationsSelection time --- hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index cb938b527..118217c6a 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -2060,7 +2060,7 @@ HotelCalendar.prototype = { } $this._lazyModeReservationsSelection = false; - }.bind(this, $this), 100); + }.bind(this, $this), 175); } } } From 862042b87e25c07f5a884f2b52bfe2e17fb83791 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sat, 29 Dec 2018 20:36:46 +0100 Subject: [PATCH 03/26] [FIX] Disable Popover click event on menu button box actions --- .../src/js/views/calendar/hotel_calendar_controller.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js index ae61e03c2..517c3dc0e 100644 --- a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js +++ b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js @@ -374,6 +374,7 @@ var PMSCalendarController = AbstractController.extend({ this._multi_calendar.on_calendar('hcalOnSavePricelist', function(ev){ self.savePricelist(ev.detail.calendar_obj, ev.detail.pricelist_id, ev.detail.pricelist); }); + $('.hcal-reservation noselect').popover(); var _destroy_and_clear_popover_mark = function(ev){ $(".marked-as-having-a-popover").popover('destroy'); @@ -381,6 +382,12 @@ var PMSCalendarController = AbstractController.extend({ }; this._multi_calendar.on_calendar('hcalOnClickReservation', function(ev){ + var active_calendar = self._multi_calendar.get_active_calendar(); + if ( active_calendar.getSelectionMode() !== HotelCalendar.MODE.NONE + || active_calendar.getSwapMode() !== HotelCalendar.MODE.NONE ) + { + return; + } if (ev.detail.reservationObj) { var tp = self._multi_calendar._reserv_tooltips[ev.detail.reservationObj.id]; var qdict = self._generate_reservation_tooltip_dict(tp); From 89576bf508a7189087ac1881808363d26b402be0 Mon Sep 17 00:00:00 2001 From: Pablo Date: Sat, 29 Dec 2018 20:40:33 +0100 Subject: [PATCH 04/26] [FIX] Remove led-green if Swap button is clicked twice (no action) Merry Christmas and Happy New Year :) --- .../static/src/js/views/calendar/hotel_calendar_controller.js | 1 + 1 file changed, 1 insertion(+) diff --git a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js index 517c3dc0e..852170929 100644 --- a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js +++ b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js @@ -278,6 +278,7 @@ var PMSCalendarController = AbstractController.extend({ } else { active_calendar.setSwapMode(HotelCalendar.MODE.NONE); $("#btn_swap span.ntext").html(_t("Start Swap")); + $led.removeClass('led-green'); $led.removeClass('led-blue'); $led.addClass('led-disabled'); } From 30ee50aeae705115193bdebe6760f182ca957b3d Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Thu, 27 Dec 2018 16:22:08 +0100 Subject: [PATCH 05/26] [WIP] Calendar styles --- .../src/lib/hcalendar/css/hcalendar.css | 45 +++++++++++++------ .../static/src/lib/hcalendar/js/hcalendar.js | 9 ++-- 2 files changed, 36 insertions(+), 18 deletions(-) diff --git a/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css b/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css index 941c7da5d..bda9f278a 100644 --- a/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css +++ b/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css @@ -47,13 +47,30 @@ } #pms-menu { - background-color: white; + background-color: #f8f8f8; height: 100%; + padding: 0 2.5em !important; } #hcal_widget { max-height: 100%; - background-color: white; +} + +#multicalendar_panels { + background-color: white; + border-left: 1px solid #ddd; +} + +.nav-tabs > li > a { + border-radius: 0; +} + +.nav-tabs { + padding-top: 4px; +} + +.navbar-default { + border-color: #f8f8f8; } #cal-pag-prev-plus, #cal-pag-prev, #cal-pag-selector, #cal-pag-next, #cal-pag-next-plus { @@ -85,6 +102,7 @@ flex-grow: 2; overflow-y: scroll; overflow-x: hidden; + font-size: 12px; max-height: 20vh; } .table-calcs input, .table-reservations-header input { @@ -96,17 +114,13 @@ text-align: center; } -.hcal-event-day { - background-color: #6ebcff !important; -} - .btn-hcal { } .btn-hcal.hcal-cell-current-day { background-color: #7c7bad66; color: #654a37; } .btn-hcal.hcal-cell-end-week { - background-color: #CBE5F8; + background-color: #EDEDED83; } .btn-hcal-3d { border: 1px solid #eaeaea; @@ -175,7 +189,7 @@ height: 100%; border-collapse: collapse !important; border: 0 dotted #eaeaea; - border-width: 2px 0; + border-width: 1px 0; } /*.hcal-table-day tr:first-child td{ border: 1px solid #727272 !important; @@ -191,21 +205,21 @@ }*/ .hcal-table-day td { padding: 2px; - height: 2.3em; + height: 3em; font-size: 7px; vertical-align: middle; font-weight: bold; - border: 1px solid #eaeaea !important; + border: 0.5px solid #eaeaea !important; } .hcal-table-day td:hover:not(.hcal-cell-highlight):not(.hcal-cell-invalid) { background-color: #FCFEE1 !important; } .hcal-cell-current-day { - background-color: #FAFFD9; + background-color: #7C7BADA5; } .hcal-cell-end-week { - background-color: #ECF3FF; + background-color: #EDEDED83; } .hcal-cell-day-selector { @@ -233,6 +247,7 @@ text-align: center !important; vertical-align: middle; white-space: nowrap; + font-size: 12px; } .hcal-cell-month:nth-child(n+3) { border-left-width: 2px !important; @@ -304,6 +319,8 @@ white-space: nowrap; overflow: hidden; z-index:8; + line-height: 17px !important; + vertical-align: middle !important; } .hcal-reservation:hover { background-color: #4e97bf; @@ -491,6 +508,7 @@ td.hcal-cell-room-type-group-item:last-child { td.hcal-cell-header-day { padding: 0; vertical-align: middle; + font-size: 10px; } td.hcal-cell-month-day-occupied { @@ -522,8 +540,7 @@ td.hcal-cell-month-day-occupied { } .hcal-unused-zone { - border: 1px solid #444; - border-radius: 0px; + border-radius: 0px; } .input-price { diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index 118217c6a..f268d70b0 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -1785,14 +1785,15 @@ HotelCalendar.prototype = { var etableOffset = this.etable.getBoundingClientRect(); reserv._html.style.top = `${boundsInit.top-etableOffset.top}px`; - var divHeight = (boundsEnd.bottom-etableOffset.top)-(boundsInit.top-etableOffset.top); - var fontHeight = divHeight/1.2; - if (fontHeight > 16) { fontHeight = 16; } + var divHeight = (boundsEnd.bottom-etableOffset.top-4)-(boundsInit.top-etableOffset.top); + var fontHeight = divHeight/1.1; + if (fontHeight > 12) { fontHeight = 12; } reserv._html.style.height = `${divHeight}px`; reserv._html.style.lineHeight = `${divHeight+fontHeight/2.0}px`; reserv._html.style.fontSize = `${fontHeight}px`; reserv._html.style.left = `${boundsInit.left-etableOffset.left}px`; - reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-4}px`; + reserv._html.style.margin = `${2}px`; if (reserv._drawModes[0] === 'soft-start') { reserv._html.style.borderLeftWidth = '3px'; reserv._html.style.borderLeftStyle = 'double'; From 328883ca8397a868d692c40b975f76208d280f5f Mon Sep 17 00:00:00 2001 From: Dario Lodeiros Date: Thu, 3 Jan 2019 20:15:56 +0100 Subject: [PATCH 06/26] [WIP] Calendar Styles --- .../src/lib/hcalendar/css/hcalendar.css | 4 +-- .../static/src/lib/hcalendar/js/hcalendar.js | 35 +++++++++++++++---- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css b/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css index bda9f278a..efc66367e 100644 --- a/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css +++ b/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css @@ -319,8 +319,8 @@ white-space: nowrap; overflow: hidden; z-index:8; - line-height: 17px !important; - vertical-align: middle !important; + vertical-align: middle; + display: table-cell; } .hcal-reservation:hover { background-color: #4e97bf; diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index f268d70b0..1f451aeef 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -1784,28 +1784,49 @@ HotelCalendar.prototype = { var etableOffset = this.etable.getBoundingClientRect(); - reserv._html.style.top = `${boundsInit.top-etableOffset.top}px`; + reserv._html.style.top = `${boundsInit.top-etableOffset.top+2}px`; var divHeight = (boundsEnd.bottom-etableOffset.top-4)-(boundsInit.top-etableOffset.top); - var fontHeight = divHeight/1.1; - if (fontHeight > 12) { fontHeight = 12; } + var fontHeight = 12; + var has_changed = false; reserv._html.style.height = `${divHeight}px`; - reserv._html.style.lineHeight = `${divHeight+fontHeight/2.0}px`; + reserv._html.style.lineHeight = `${divHeight}px`; reserv._html.style.fontSize = `${fontHeight}px`; - reserv._html.style.left = `${boundsInit.left-etableOffset.left}px`; - reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-4}px`; - reserv._html.style.margin = `${2}px`; + reserv._html.style.left = `${boundsInit.left-etableOffset.left+2}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-4}px`; if (reserv._drawModes[0] === 'soft-start') { + has_changed = true; reserv._html.style.borderLeftWidth = '3px'; reserv._html.style.borderLeftStyle = 'double'; + reserv._html.style.left = `${boundsInit.left-etableOffset.left}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; + console.log("PASA 11"); } else if (reserv.splitted && reserv.startDate.isSame(reserv.getUserData('realDates')[0], 'day')) { + has_changed = true; reserv._html.style.borderLeftWidth = '0'; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; + console.log("PASA 12"); + } else if (reserv.splitted) { + has_changed = true; + reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; + console.log("PASA 13"); } if (reserv._drawModes[1] === 'soft-end') { reserv._html.style.borderRightWidth = '3px'; reserv._html.style.borderRightStyle = 'double'; + console.log("PASA 14"); + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; } else if (reserv.splitted && reserv.endDate.isSame(reserv.getUserData('realDates')[1], 'day')) { reserv._html.style.borderRightWidth = '0'; + reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-1}px`; + console.log("PASA 15"); + } else if (reserv.splitted && !has_changed) { + reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; + console.log("PASA 16"); } + console.log(reserv.startDate.format('DD/MM/YYYY')) } }, From 9f6f7129762c56acdc03b24470f3ae8910d8b697 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Sat, 5 Jan 2019 21:37:12 +0100 Subject: [PATCH 07/26] [IMP] Calendar Dates & Splitted Calcs --- .../views/calendar/hotel_calendar_renderer.js | 3 ++- .../static/src/lib/hcalendar/js/hcalendar.js | 25 ++++++++----------- 2 files changed, 12 insertions(+), 16 deletions(-) diff --git a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js index 94f7cb35c..065c6ecb5 100644 --- a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js +++ b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js @@ -53,7 +53,8 @@ var HotelCalendarView = AbstractRenderer.extend({ if (days === 'month') { days = date_begin.daysInMonth(); } - var date_end = date_begin.clone().add(days, 'd').set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc(); + var date_end = date_begin.clone().add(days+1, 'd').set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc(); + return [date_begin, date_end]; }, diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index 1f451aeef..0cfece543 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -1792,41 +1792,36 @@ HotelCalendar.prototype = { reserv._html.style.lineHeight = `${divHeight}px`; reserv._html.style.fontSize = `${fontHeight}px`; reserv._html.style.left = `${boundsInit.left-etableOffset.left+2}px`; - reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-4}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-4}px`; if (reserv._drawModes[0] === 'soft-start') { has_changed = true; reserv._html.style.borderLeftWidth = '3px'; reserv._html.style.borderLeftStyle = 'double'; reserv._html.style.left = `${boundsInit.left-etableOffset.left}px`; reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; - console.log("PASA 11"); } else if (reserv.splitted && reserv.startDate.isSame(reserv.getUserData('realDates')[0], 'day')) { has_changed = true; reserv._html.style.borderLeftWidth = '0'; reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; - console.log("PASA 12"); - } else if (reserv.splitted) { - has_changed = true; - reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; - reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; - console.log("PASA 13"); } + if (reserv._drawModes[1] === 'soft-end') { + has_changed = true; reserv._html.style.borderRightWidth = '3px'; reserv._html.style.borderRightStyle = 'double'; - console.log("PASA 14"); reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; } else if (reserv.splitted && reserv.endDate.isSame(reserv.getUserData('realDates')[1], 'day')) { + has_changed = true; reserv._html.style.borderRightWidth = '0'; reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-1}px`; - console.log("PASA 15"); - } else if (reserv.splitted && !has_changed) { - reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; - reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; - console.log("PASA 16"); } - console.log(reserv.startDate.format('DD/MM/YYYY')) + + if (reserv.splitted && !has_changed) { + has_changed = true; + reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; + } } }, From 0fddc7cd4a9b9412c6a0a309e4ee08fe738893fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Sat, 5 Jan 2019 22:40:52 +0100 Subject: [PATCH 08/26] [FIX] Unify --- hotel/models/hotel_reservation.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 222b2030f..3b73f75e0 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -960,8 +960,8 @@ class HotelReservation(models.Model): master_reservation = self.parent_reservation or self splitted_reservs = self.env['hotel.reservation'].search([ - '|', ('splitted', '=', True), + '|', ('id', '=', master_reservation.id), # This here because can create a splitted reserv before set as splitted the parent reservation (master) ('folio_id', '=', self.folio_id.id), '|', @@ -1058,19 +1058,24 @@ class HotelReservation(models.Model): @api.model def unify_books(self, splitted_reservs): - master_reservation = splitted_reservs[0].parent_reservation or splitted_reservs[0] + parent_reservation = splitted_reservs[0].parent_reservation or splitted_reservs[0] room_type_ids = splitted_reservs.mapped('room_type_id.id') if len(room_type_ids) > 1 or \ (len(room_type_ids) == 1 - and master_reservation.room_type_id.id != room_type_ids[0]): + and parent_reservation.room_type_id.id != room_type_ids[0]): raise ValidationError(_("This reservation can't be unified: They \ all need to be in the same room")) # Search checkout last_checkout = splitted_reservs[0].checkout + first_checkin = splitted_reservs[0].checkin + master_reservation = splitted_reservs[0] for reserv in splitted_reservs: if last_checkout < reserv.checkout: last_checkout = reserv.checkout + if first_checkin > reserv.checkin: + first_checkin = reserv.checkin + master_reservation = reserv # Agrupate reservation lines reservation_line_ids = splitted_reservs.mapped('reservation_line_ids') @@ -1084,13 +1089,16 @@ class HotelReservation(models.Model): })) tprice += rline.price + # Real Dates + rdate_begin, rdate_end = master_reservation.get_real_checkin_checkout() + # Unify osplitted_reservs = splitted_reservs - master_reservation osplitted_reservs.sudo().unlink() master_reservation.write({ 'checkout': last_checkout, - 'splitted': master_reservation.get_real_checkin_checkout()[1] != last_checkout, + 'splitted': rdate_begin != first_checkin or rdate_end != last_checkout, 'reservation_line_ids': rlines, 'price_total': tprice, }) From e1dae0d5200837cc8632374a3a116fb18b1c5064 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Sat, 5 Jan 2019 22:43:34 +0100 Subject: [PATCH 09/26] [IMP] Unsed assignament --- hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index 0cfece543..ae1fb0506 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -1804,7 +1804,7 @@ HotelCalendar.prototype = { reserv._html.style.borderLeftWidth = '0'; reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-2}px`; } - + if (reserv._drawModes[1] === 'soft-end') { has_changed = true; reserv._html.style.borderRightWidth = '3px'; @@ -1818,7 +1818,6 @@ HotelCalendar.prototype = { } if (reserv.splitted && !has_changed) { - has_changed = true; reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; } From de545d5b6b6772a8f6274b7ead1705b5c3f493ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Sat, 5 Jan 2019 22:53:47 +0100 Subject: [PATCH 10/26] [FIX] Real Dates --- hotel/models/hotel_reservation.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 3b73f75e0..4287ed8fd 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -960,8 +960,8 @@ class HotelReservation(models.Model): master_reservation = self.parent_reservation or self splitted_reservs = self.env['hotel.reservation'].search([ - ('splitted', '=', True), '|', + ('splitted', '=', True), ('id', '=', master_reservation.id), # This here because can create a splitted reserv before set as splitted the parent reservation (master) ('folio_id', '=', self.folio_id.id), '|', From 8a6f5e2aecb50ae37c63623585fdd5fe0396823d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Thu, 10 Jan 2019 18:55:07 +0100 Subject: [PATCH 11/26] [IMP] Reservation Drawing --- hotel/models/hotel_reservation.py | 3 +- .../models/inherited_hotel_reservation.py | 53 +++++------ .../src/lib/hcalendar/css/hcalendar.css | 20 ++-- .../static/src/lib/hcalendar/js/hcalendar.js | 92 +++++++++++-------- 4 files changed, 90 insertions(+), 78 deletions(-) diff --git a/hotel/models/hotel_reservation.py b/hotel/models/hotel_reservation.py index 4287ed8fd..94bd2764d 100644 --- a/hotel/models/hotel_reservation.py +++ b/hotel/models/hotel_reservation.py @@ -983,8 +983,7 @@ class HotelReservation(models.Model): date_start_dt = fields.Date.from_string(record.checkin) date_end_dt = fields.Date.from_string(record.checkout) date_diff = abs((date_end_dt - date_start_dt).days) - new_start_date_dt = date_start_dt + \ - timedelta(days=date_diff-nights) + new_start_date_dt = date_start_dt + timedelta(days=date_diff-nights) if nights >= date_diff or nights < 1: raise ValidationError(_("Invalid Nights! Max is \ '%d'") % (date_diff-1)) diff --git a/hotel_calendar/models/inherited_hotel_reservation.py b/hotel_calendar/models/inherited_hotel_reservation.py index c68c109fb..44cfd1ab6 100644 --- a/hotel_calendar/models/inherited_hotel_reservation.py +++ b/hotel_calendar/models/inherited_hotel_reservation.py @@ -184,32 +184,29 @@ class HotelReservation(models.Model): return json_events @api.model - def get_hcalendar_reservations_data(self, dfrom, dto, rooms): - date_start = fields.Date.from_string(dfrom) - timedelta(days=1) - date_start_str = date_start.strftime(DEFAULT_SERVER_DATETIME_FORMAT) + def get_hcalendar_reservations_data(self, dfrom_dt, dto_dt, rooms): + rdfrom_dt = dfrom_dt + timedelta(days=1) # Ignore checkout reservations_raw = self.env['hotel.reservation'].search( [('room_id', 'in', rooms.ids)], order="checkin DESC, checkout ASC, adults DESC, children DESC") reservations_ll = self.env['hotel.reservation'].search([ - ('checkin', '<=', dto), - ('checkout', '>=', date_start_str) + ('checkin', '<=', dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)), + ('checkout', '>=', rdfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)) ]) reservations_lr = self.env['hotel.reservation'].search([ - ('checkin', '>=', date_start_str), - ('checkout', '<=', dto) + ('checkin', '>=', dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)), + ('checkout', '<=', dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)) ]) reservations = (reservations_ll | reservations_lr) & reservations_raw return self._hcalendar_reservation_data(reservations) @api.model - def get_hcalendar_pricelist_data(self, dfrom, dto): + def get_hcalendar_pricelist_data(self, dfrom_dt, dto_dt): pricelist_id = self.env['ir.default'].sudo().get( 'res.config.settings', 'default_pricelist_id') if pricelist_id: pricelist_id = int(pricelist_id) - date_start = fields.Date.from_string(dfrom) - timedelta(days=1) - date_end = fields.Date.from_string(dto) - date_diff = abs((date_end - date_start).days) + 1 + date_diff = abs((dfrom_dt - dto_dt).days) + 1 # Get Prices json_rooms_prices = {pricelist_id: []} room_typed_ids = self.env['hotel.room.type'].search( @@ -220,7 +217,7 @@ class HotelReservation(models.Model): for room_type_id in room_typed_ids: days = {} for i in range(0, date_diff): - ndate = date_start + timedelta(days=i) + ndate = dfrom_dt + timedelta(days=i) ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) prod_price_id = room_pr_cached_obj.search([ ('room_id', '=', room_type_id.id), @@ -242,14 +239,12 @@ class HotelReservation(models.Model): return json_rooms_prices @api.model - def get_hcalendar_restrictions_data(self, dfrom, dto): + def get_hcalendar_restrictions_data(self, dfrom_dt, dto_dt): restriction_id = self.env['ir.default'].sudo().get( 'res.config.settings', 'default_restriction_id') if restriction_id: restriction_id = int(restriction_id) - date_start = fields.Date.from_string(dfrom) - timedelta(days=1) - date_end = fields.Date.from_string(dto) - date_diff = abs((date_end - date_start).days) + 1 + date_diff = abs((dto_dt - dfrom_dt).days) + 1 # Get Prices json_rooms_rests = {} room_types = self.env['hotel.room.type'].search( @@ -259,7 +254,7 @@ class HotelReservation(models.Model): for room_type in room_types: days = {} for i in range(0, date_diff): - ndate = date_start + timedelta(days=i) + ndate = dfrom_dt + timedelta(days=i) ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT) rest_id = room_type_rest_obj.search([ ('room_type_id', '=', room_type.id), @@ -284,9 +279,7 @@ class HotelReservation(models.Model): return json_rooms_rests @api.model - def get_hcalendar_events_data(self, dfrom, dto): - date_start = fields.Date.from_string(dfrom) - timedelta(days=1) - date_start_str = date_start.strftime(DEFAULT_SERVER_DATETIME_FORMAT) + def get_hcalendar_events_data(self, dfrom_dt, dto_dt): user_id = self.env['res.users'].browse(self.env.uid) domain = [] if user_id.pms_allowed_events_tags: @@ -296,12 +289,12 @@ class HotelReservation(models.Model): ('categ_ids', 'not in', user_id.pms_denied_events_tags)) events_raw = self.env['calendar.event'].search(domain) events_ll = self.env['calendar.event'].search([ - ('start', '<=', dto), - ('stop', '>=', date_start_str) + ('start', '<=', dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)), + ('stop', '>=', dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)) ]) events_lr = self.env['calendar.event'].search([ - ('start', '>=', date_start_str), - ('stop', '<=', dto) + ('start', '>=', dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)), + ('stop', '<=', dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)) ]) events = (events_ll | events_lr) & events_raw return self._hcalendar_event_data(events) @@ -332,18 +325,22 @@ class HotelReservation(models.Model): if not dfrom or not dto: raise ValidationError(_('Input Error: No dates defined!')) + dfrom_dt = fields.Date.from_string(dfrom) + dto_dt = fields.Date.from_string(dto) + rooms = self.env['hotel.room'].search([], order='hcal_sequence ASC') calendars = self.env['hotel.calendar'].search([]) json_res, json_res_tooltips = self.get_hcalendar_reservations_data( - dfrom, dto, rooms) + dfrom_dt, dto_dt, rooms) vals = { 'rooms': withRooms and self._hcalendar_room_data(rooms) or [], 'reservations': json_res, 'tooltips': json_res_tooltips, - 'pricelist': self.get_hcalendar_pricelist_data(dfrom, dto), - 'restrictions': self.get_hcalendar_restrictions_data(dfrom, dto), - 'events': self.get_hcalendar_events_data(dfrom, dto), + 'pricelist': self.get_hcalendar_pricelist_data(dfrom_dt, dto_dt), + 'restrictions': self.get_hcalendar_restrictions_data(dfrom_dt, + dto_dt), + 'events': self.get_hcalendar_events_data(dfrom_dt, dto_dt), 'calendars': self._hcalendar_calendar_data(calendars) } diff --git a/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css b/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css index efc66367e..86ac21ee9 100644 --- a/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css +++ b/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css @@ -318,9 +318,7 @@ color: white; white-space: nowrap; overflow: hidden; - z-index:8; - vertical-align: middle; - display: table-cell; + z-index: 8; } .hcal-reservation:hover { background-color: #4e97bf; @@ -424,21 +422,25 @@ } .hcal-reservation-divide-l { - background-color: transparent !important; + background-color: transparent; border: 2px dashed black; cursor: copy; pointer-events: none; - border-color: black !important; - border-right-style: solid !important; + border-color: black; + border-right-style: solid; + position: absolute; + z-index: 9; } .hcal-reservation-divide-r { - background-color: transparent !important; + background-color: transparent; border: 2px dashed black; cursor: copy; pointer-events: none; - border-color: black !important; - border-left-style: solid !important; + border-color: black; + border-left-style: solid; + position: absolute; + z-index: 9; } .hcal-row-room-type-group-item { diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index ae1fb0506..9cc202103 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -511,6 +511,13 @@ HotelCalendar.prototype = { } while (notFound && nbed <= reservation.room.capacity); reservation._limits = limits; + + // Update Beds + if (limits.isValid()) { + var numBeds = (+limits.right.dataset.hcalBedNum)-(+limits.left.dataset.hcalBedNum); + reservation._beds = []; + for (var i=0; i<=numBeds; reservation._beds.push(+limits.left.dataset.hcalBedNum+i++)); + } }, //==== CELLS @@ -1756,41 +1763,21 @@ HotelCalendar.prototype = { } if (!noRefresh) { - var numBeds = (+reserv._limits.right.dataset.hcalBedNum)-(+reserv._limits.left.dataset.hcalBedNum); - reserv._beds = []; - for (var i=0; i<=numBeds; reserv._beds.push(+reserv._limits.left.dataset.hcalBedNum+i++)); + //reserv._html.removeAttribute('style'); var boundsInit = reserv._limits.left.getBoundingClientRect(); var boundsEnd = reserv._limits.right.getBoundingClientRect(); - - reserv._html.removeAttribute('style'); - - if (reserv.splitted) { - reserv._html.classList.add('hcal-reservation-splitted'); - // 1. Use reservation ID as seed - // 2. Use sinusiudal function - // 3. Only use positive values (This decrease longitude, increase frequency) - // 4. Use the first 5 decimals to make the integer value - // 5. Get integer value (Bitwise tilde method) - // TODO: Improve pseudo-random number generator - var magicNumber = ~~(Math.abs(Math.sin((reserv.getUserData('parent_reservation') || reserv.id))) * 100000); - var bbColor = this._intToRgb(magicNumber); - reserv._html.style.borderColor = `rgb(${bbColor[0]},${bbColor[1]},${bbColor[2]})`; - } else { - reserv._html.classList.remove('hcal-reservation-splitted'); - } - reserv._html.style.backgroundColor = reserv.color; - reserv._html.style.color = reserv.colorText; - var etableOffset = this.etable.getBoundingClientRect(); - - reserv._html.style.top = `${boundsInit.top-etableOffset.top+2}px`; var divHeight = (boundsEnd.bottom-etableOffset.top-4)-(boundsInit.top-etableOffset.top); var fontHeight = 12; var has_changed = false; + + reserv._html.style.backgroundColor = reserv.color; + reserv._html.style.color = reserv.colorText; reserv._html.style.height = `${divHeight}px`; reserv._html.style.lineHeight = `${divHeight}px`; reserv._html.style.fontSize = `${fontHeight}px`; + reserv._html.style.top = `${boundsInit.top-etableOffset.top+2}px`; reserv._html.style.left = `${boundsInit.left-etableOffset.left+2}px`; reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-4}px`; if (reserv._drawModes[0] === 'soft-start') { @@ -1817,9 +1804,24 @@ HotelCalendar.prototype = { reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width-1}px`; } - if (reserv.splitted && !has_changed) { - reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; - reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; + if (reserv.splitted) { + reserv._html.classList.add('hcal-reservation-splitted'); + // 1. Use reservation ID as seed + // 2. Use sinusiudal function + // 3. Only use positive values (This decrease longitude) + // 4. Use the first 5 decimals to make the integer value + // 5. Get integer value (Bitwise tilde method) + // TODO: Improve pseudo-random number generator + var magicNumber = ~~(Math.abs(Math.sin((reserv.getUserData('parent_reservation') || reserv.id))) * 100000); + var bbColor = this._intToRgb(magicNumber); + reserv._html.style.borderColor = `rgb(${bbColor[0]},${bbColor[1]},${bbColor[2]})`; + + if (!has_changed) { + reserv._html.style.left = `${boundsInit.left-etableOffset.left-1}px`; + reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width+2}px`; + } + } else { + reserv._html.classList.remove('hcal-reservation-splitted'); } } }, @@ -2618,25 +2620,37 @@ HotelCalendar.prototype = { } if (reservs.length) { this._splitReservation = reservs[0]; - this._divideDivs = [$(this._splitReservation._html).clone().text('').appendTo(this.edivr), $(this._splitReservation._html).clone().text('').appendTo(this.edivr)]; + var defStyle = { + top: this._splitReservation._html.style.top, + left: this._splitReservation._html.style.left, + height: this._splitReservation._html.style.height, + }; + this._divideDivs = [ + $('
', {class: 'hcal-reservation-divide-l', css: defStyle}).appendTo(this.edivr), + $('
', {class: 'hcal-reservation-divide-r', css: defStyle}).appendTo(this.edivr) + ]; var diff = this.getDateDiffDays(this._splitReservation.startDate, date_cell); - this._divideDivs[0].addClass('hcal-reservation-divide-l'); - this._divideDivs[1].addClass('hcal-reservation-divide-r'); - var etableOffset = this.etable.getBoundingClientRect(); var boundsCell = ev.target.getBoundingClientRect(); var beginCell = this._splitReservation._limits.left.getBoundingClientRect(); var endCell = this._splitReservation._limits.right.getBoundingClientRect(); - var splitCell = boundsCell; - var splitDate = date_cell.clone(); this._splitDate = date_cell.clone(); if (date_cell.isSame(this._splitReservation.endDate.clone().subtract(1, 'd'), 'day')) { - splitDate.subtract(1, 'd'); - splitCell = this.getCell(this._splitDate, this._splitReservation.room, 0); + this._splitDate.subtract(1, 'd'); + var tcell = this.getCell(this._splitDate, this._splitReservation.room, 0); + if (tcell) { + boundsCell = tcell.getBoundingClientRect(); + } else { + boundsCell = false; + this._splitReservation = false; + this._splitDate = false; + } + } + if (boundsCell) { + this._divideDivs[0][0].style.width = `${(boundsCell.left-beginCell.left)+boundsCell.width}px`; + this._divideDivs[1][0].style.left = `${(boundsCell.left-etableOffset.left)+boundsCell.width}px`; + this._divideDivs[1][0].style.width = `${(endCell.left-boundsCell.left)}px`; } - this._divideDivs[0][0].style.width = `${(splitCell.left-beginCell.left)+splitCell.width}px`; - this._divideDivs[1][0].style.left = `${(splitCell.left-etableOffset.left)+splitCell.width}px`; - this._divideDivs[1][0].style.width = `${(endCell.left-splitCell.left)}px`; } else { this._splitReservation = false; this._splitDate = false; From 62a2f18ad82ff6bd74f005baa24fd5fffed1b1fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Thu, 10 Jan 2019 23:08:57 +0100 Subject: [PATCH 12/26] [FIX] Invisible Elements --- hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js | 1 + 1 file changed, 1 insertion(+) diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index 9cc202103..b645b9966 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -2718,6 +2718,7 @@ HotelCalendar.prototype = { hasInvalidLink = !hasInvalidLink && r._html.classList.contains('hcal-reservation-invalid'); r._html.classList.remove('hcal-reservation-action'); r._html.classList.remove('hcal-reservation-invalid'); + r._html.style.visibility = ''; } } From ff0172f613d9c923555e23176314211716db0486 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexandre=20D=C3=ADaz?= Date: Fri, 11 Jan 2019 01:34:43 +0100 Subject: [PATCH 13/26] [IMP] Collapsable Sections --- hotel_calendar/static/src/css/view.css | 9 ++++- .../calendar/hotel_calendar_controller.js | 6 +++ .../static/src/xml/hotel_calendar_view.xml | 38 ++++++++++--------- 3 files changed, 34 insertions(+), 19 deletions(-) diff --git a/hotel_calendar/static/src/css/view.css b/hotel_calendar/static/src/css/view.css index 4989fcc46..e2d118139 100644 --- a/hotel_calendar/static/src/css/view.css +++ b/hotel_calendar/static/src/css/view.css @@ -90,6 +90,13 @@ input#bookings_search { margin-top: 1em; } +#pms-menu .menu-filter-box h4 { + cursor: pointer; +} +#pms-menu .menu-filter-box h4 i { + transition: all 0.5s ease; +} + #pms-menu .button-box { text-align: left; min-height: 3.5em; @@ -230,4 +237,4 @@ input#bookings_search { display: flex; } -/* TODO: Use Odoo Colours based on http://www.odoo.com/openerp_website/static/src/less/variables.less */ \ No newline at end of file +/* TODO: Use Odoo Colours based on http://www.odoo.com/openerp_website/static/src/less/variables.less */ diff --git a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js index 852170929..7865ebb12 100644 --- a/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js +++ b/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js @@ -363,6 +363,12 @@ var PMSCalendarController = AbstractController.extend({ }); }); + this.renderer.$el.find('#pms-menu .menu-filter-box #filters').on('show.bs.collapse', function(ev){ + self.renderer.$el.find('#pms-menu .menu-filter-box h4 i.fa').css({transform: 'rotate(90deg)'}); + }).on('hide.bs.collapse', function(ev){ + self.renderer.$el.find('#pms-menu .menu-filter-box h4 i.fa').css({transform: 'rotate(0deg)'}); + }); + this._multi_calendar.on('tab_changed', function(ev, active_index){ if (active_index) { self._refresh_view_options(active_index); diff --git a/hotel_calendar/static/src/xml/hotel_calendar_view.xml b/hotel_calendar/static/src/xml/hotel_calendar_view.xml index 78b6d4498..227d916f8 100644 --- a/hotel_calendar/static/src/xml/hotel_calendar_view.xml +++ b/hotel_calendar/static/src/xml/hotel_calendar_view.xml @@ -113,24 +113,26 @@