From 0d7667f6366a90ed8e3f0d904c5a4076017b7ab0 Mon Sep 17 00:00:00 2001 From: Pablo Date: Wed, 6 Feb 2019 16:14:10 +0100 Subject: [PATCH] popover improvement (#93) * [FIX] Fix popover placement * [FIX] Fix popover in xs (phones) * [ADD] folio and reservation buttons * [ADD] Folio pending highlights * [FIX] event is not defined in Firefox --- hotel_calendar/models/bus_hotel_calendar.py | 2 + .../models/inherited_hotel_reservation.py | 3 ++ hotel_calendar/static/src/css/view.css | 10 ++++ .../calendar/hotel_calendar_controller.js | 53 +++++++++++++++---- .../static/src/lib/hcalendar/js/hcalendar.js | 4 ++ .../src/xml/hotel_calendar_templates.xml | 35 ++++++------ 6 files changed, 81 insertions(+), 26 deletions(-) diff --git a/hotel_calendar/models/bus_hotel_calendar.py b/hotel_calendar/models/bus_hotel_calendar.py index e81ac1385..d1016ae29 100644 --- a/hotel_calendar/models/bus_hotel_calendar.py +++ b/hotel_calendar/models/bus_hotel_calendar.py @@ -49,6 +49,8 @@ class BusHotelCalendar(models.TransientModel): 'fix_days': vals['fix_days'], 'fix_room': False, 'overbooking': vals['overbooking'], + 'price_room_services_set': vals['price_room_services_set'], + 'amount_total': vals['pending_amount'] + vals['invoices_paid'], 'real_dates': vals['real_dates'], }, 'tooltip': { diff --git a/hotel_calendar/models/inherited_hotel_reservation.py b/hotel_calendar/models/inherited_hotel_reservation.py index 15e0edcbb..12559a790 100644 --- a/hotel_calendar/models/inherited_hotel_reservation.py +++ b/hotel_calendar/models/inherited_hotel_reservation.py @@ -92,6 +92,8 @@ class HotelReservation(models.Model): 'fix_room': False, # Fix Rooms 'overbooking': reserv['overbooking'], 'state': reserv['state'], + 'price_room_services_set': reserv['price_room_services_set'], + 'amount_total': reserv['amount_total'], 'real_dates': [reserv['real_checkin'], reserv['real_checkout']]}) json_reservation_tooltips.update({ reserv['id']: { @@ -192,6 +194,7 @@ class HotelReservation(models.Model): hr.price_room_services_set, hf.id as folio_id, hf.name as folio_name, hf.reservation_type, hf.invoices_paid, hf.pending_amount, + hf.amount_total, rp.mobile, rp.phone, rp.email, rp.name as partner_name, diff --git a/hotel_calendar/static/src/css/view.css b/hotel_calendar/static/src/css/view.css index 46a9fbbc3..534bb5520 100644 --- a/hotel_calendar/static/src/css/view.css +++ b/hotel_calendar/static/src/css/view.css @@ -350,6 +350,12 @@ div.diagonal { left: 40%; bottom: 0; } +div.diagonal_pending_amount { + background-color: #A24689; +} +.diagonal_pending_amount::before { + border-top-color: #A24689; +} div.triangle-right { overflow: hidden; @@ -378,3 +384,7 @@ div.pull-right-custom { color: #777; text-align: right; } + +@keyframes blinker { + 50% { opacity: 0; } +} \ No newline at end of file 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 1c2bf4774..348fd320e 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 @@ -386,6 +386,16 @@ var PMSCalendarController = AbstractController.extend({ $('.hcal-reservation').removeClass("marked-as-having-a-popover"); }; + /* destroy popover if mouse click is done out the popover */ + /* except if you click in the payment button */ + /* TODO: Review because this event is trigger anywhere, even if you click in other buttons! */ + $('html').on('click', function(e) { + if (!$(e.target).hasClass("marked-as-having-a-popover") && + !$(e.target).parents().is('.popover.in') && + (e.target.id !== 'payment_folio')) { + _destroy_and_clear_popover_mark(); + } + }); this._multi_calendar.on_calendar('hcalOnClickReservation', function(ev){ var active_calendar = self._multi_calendar.get_active_calendar(); if ( active_calendar.getSelectionMode() !== HotelCalendar.MODE.NONE @@ -403,15 +413,9 @@ var PMSCalendarController = AbstractController.extend({ container: 'body', animation: false, html: true, - placement: 'bottom', + placement: 'auto bottom', 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){ @@ -433,12 +437,39 @@ var PMSCalendarController = AbstractController.extend({ views: [[false, 'form']] }); }); - $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_payment").on('click', + $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_payment_folio").on('click', + {reservation: ev.detail.reservationObj}, function(ev){ + if (ev.data.reservation.total_folio <= ev.data.reservation.total_reservation || + $('#payment_reservation').hasClass('in')) { + _destroy_and_clear_popover_mark(); + var x = self._rpc({ + model: 'hotel.reservation', + method: 'action_pay_folio', + args: [ev.data.reservation.id], + }).then(function (result){ + return self.do_action({ + name: result.name, + view_type: result.view_type, + view_mode: result.view_mode, + type: result.type, + res_model: result.res_model, + views: [[result.view_id, 'form']], + context: result.context, + target: result.target, + }); + }); + } else { + $('#payment_folio').css('color', '#A24689'); + $('#folio_pending_amount').css('animation', 'blinker 1s linear'); + $('#price_room').css('animation', 'blinker 1s linear'); + } + }); + $reservationPopover.data('bs.popover').tip().find(".btn_popover_open_payment_reservation").on('click', {reservation_id: ev.detail.reservationObj.id}, function(ev){ _destroy_and_clear_popover_mark(); var x = self._rpc({ model: 'hotel.reservation', - method: 'action_pay_folio', + method: 'action_pay_reservation', args: [ev.data.reservation_id], }).then(function (result){ return self.do_action({ @@ -771,7 +802,9 @@ var PMSCalendarController = AbstractController.extend({ 'unusedZone': false, 'linkedId': false, 'overbooking': json_reserv['overbooking'], - 'cancelled': json_reserv['state'] === 'cancelled' + 'cancelled': json_reserv['state'] === 'cancelled', + 'total_reservation': json_reserv['price_room_services_set'], + 'total_folio': json_reserv['amount_total'], }); nreserv.addUserData({ 'folio_id': json_reserv['folio_id'], diff --git a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js index f57934073..42ae0f351 100644 --- a/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js +++ b/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js @@ -2992,6 +2992,8 @@ function HReservation(/*Dictionary*/rValues) { this.overbooking = rValues.overbooking || false; this.cancelled = rValues.cancelled || false; this.room = rValues.room || null; + this.total_reservation = rValues.total_reservation || 0; + this.total_folio = rValues.total_folio || 0; this._drawModes = ['hard-start', 'hard-end']; this._html = false; @@ -3046,6 +3048,8 @@ HReservation.prototype = { 'overbooking': this.overbooking, 'cancelled': this.cancelled, 'room_id': this.room_id, + 'total_reservation': this.total_reservation, + 'total_folio': this.total_folio, }); nreserv._beds = _.clone(this._beds); nreserv._html = this._html; diff --git a/hotel_calendar/static/src/xml/hotel_calendar_templates.xml b/hotel_calendar/static/src/xml/hotel_calendar_templates.xml index 793163e6d..203e4b3aa 100644 --- a/hotel_calendar/static/src/xml/hotel_calendar_templates.xml +++ b/hotel_calendar/static/src/xml/hotel_calendar_templates.xml @@ -96,12 +96,12 @@
-
+
Sales Channel:
-
+
TODO: add call center information @@ -111,19 +111,19 @@
-
+

-
+

- +

Adults:

Children:

@@ -132,7 +132,8 @@
-
+

Folio Pending

@@ -155,7 +156,7 @@
-
+
@@ -168,13 +169,13 @@
-
-
+
+