mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[WIP][MIG][11.0] Hotel Calendar & Hotel Channel Connector
This commit is contained in:
5
hotel_calendar/__init__.py
Normal file
5
hotel_calendar/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import models
|
||||
from . import controllers
|
||||
from . import wizard
|
||||
45
hotel_calendar/__manifest__.py
Normal file
45
hotel_calendar/__manifest__.py
Normal file
@@ -0,0 +1,45 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
|
||||
{
|
||||
'name': 'Hotel Calendar',
|
||||
'version': '11.0.2.0',
|
||||
'author': "Alexandre Díaz <dev@redneboa.es>",
|
||||
'website': 'https://www.eiqui.com',
|
||||
'category': 'hotel/calendar',
|
||||
'summary': "Hotel Calendar",
|
||||
'description': "Hotel Calendar",
|
||||
'depends': [
|
||||
'bus',
|
||||
'web',
|
||||
'calendar',
|
||||
'hotel',
|
||||
'web_widget_color',
|
||||
],
|
||||
'external_dependencies': {
|
||||
'python': []
|
||||
},
|
||||
'data': [
|
||||
'views/general.xml',
|
||||
'views/actions.xml',
|
||||
'views/res_config_views.xml',
|
||||
'views/inherited_res_users_views.xml',
|
||||
'views/inherited_hotel_virtual_room_views.xml',
|
||||
'views/inherited_hotel_room_views.xml',
|
||||
'views/virtual_room_pricelist_cached_views.xml',
|
||||
'data/views.xml',
|
||||
'data/menus.xml',
|
||||
'data/records.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'wizard/wizard_reservation.xml'
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/*.xml',
|
||||
],
|
||||
'test': [
|
||||
],
|
||||
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'license': 'AGPL-3',
|
||||
}
|
||||
3
hotel_calendar/controllers/__init__.py
Normal file
3
hotel_calendar/controllers/__init__.py
Normal file
@@ -0,0 +1,3 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import bus
|
||||
21
hotel_calendar/controllers/bus.py
Normal file
21
hotel_calendar/controllers/bus.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo.http import request
|
||||
from odoo.addons.bus.controllers.main import BusController
|
||||
|
||||
HOTEL_BUS_CHANNEL_ID = 'hpublic'
|
||||
|
||||
|
||||
# More info...
|
||||
# https://github.com/odoo/odoo/commit/092cf33f93830daf5e704b964724bdf8586da8d9
|
||||
class Controller(BusController):
|
||||
def _poll(self, dbname, channels, last, options):
|
||||
if request.session.uid:
|
||||
# registry, cr, uid, context = request.registry, request.cr, \
|
||||
# request.session.uid, request.context
|
||||
channels = channels + [(
|
||||
request.db,
|
||||
'hotel.reservation',
|
||||
HOTEL_BUS_CHANNEL_ID
|
||||
)]
|
||||
return super(Controller, self)._poll(dbname, channels, last, options)
|
||||
27
hotel_calendar/data/menus.xml
Normal file
27
hotel_calendar/data/menus.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="action_hotel_calendar" model="ir.actions.act_window">
|
||||
<field name="name">Hotel Calendar</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_mode">pms</field>
|
||||
</record>
|
||||
|
||||
<record id="action_hotel_calendar_management" model="ir.actions.act_window">
|
||||
<field name="name">Hotel Calendar Management</field>
|
||||
<field name="res_model">hotel.calendar.management</field>
|
||||
<field name="view_mode">mpms</field>
|
||||
</record>
|
||||
|
||||
<menuitem id="hotel_calendar_menu" name="Hotel Calendar" sequence="10"
|
||||
web_icon="hotel_calendar,static/description/icon_calendar.png"
|
||||
action="action_hotel_calendar" />
|
||||
|
||||
<menuitem id="hotel_calendar_management_menu" name="Hotel Calendar Management" sequence="20"
|
||||
web_icon="hotel_calendar,static/description/icon_calendar_configurator.png"
|
||||
action="action_hotel_calendar_management" groups="hotel.group_hotel_manager" />
|
||||
|
||||
<menuitem id="hotel_virtual_room_pricelist_cached" name="VRoom Pricelist Cached"
|
||||
sequence="1" action="hotel_virtual_room_pricelist_cached_action_form_tree" parent="sale.menu_sale_config"/>
|
||||
|
||||
</odoo>
|
||||
81
hotel_calendar/data/records.xml
Normal file
81
hotel_calendar/data/records.xml
Normal file
@@ -0,0 +1,81 @@
|
||||
<odoo>
|
||||
<data noupdate="1">
|
||||
|
||||
<function id="default_color_pre_reservation"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_pre_reservation', '#A4A4A4')"/>
|
||||
|
||||
<function id="default_color_reservation"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_reservation', '#4E9DC4')"/>
|
||||
|
||||
<function id="default_color_stay"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_stay', '#b40606')"/>
|
||||
|
||||
<function id="default_color_stay_pay"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_stay_pay', '#54d12b')"/>
|
||||
|
||||
<function id="default_color_checkout"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_checkout', '#FF0000')"/>
|
||||
|
||||
<function id="default_color_dontsell"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_dontsell', '#000000')"/>
|
||||
|
||||
<function id="default_color_staff"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_staff', '#FF9933')"/>
|
||||
|
||||
<function id="default_color_to_assign"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_to_assign', '#DFFF00')"/>
|
||||
|
||||
<function id="default_color_payment_pending"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_payment_pending', '#f70f0f')"/>
|
||||
|
||||
<function id="default_color_letter_pre_reservation"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_pre_reservation', '#000000')"/>
|
||||
|
||||
<function id="default_color_letter_reservation"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_reservation', '#000000')"/>
|
||||
|
||||
<function id="default_color_letter_reservation_pay"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_reservation_pay', '#000000')"/>
|
||||
|
||||
<function id="default_color_letter_stay"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_stay', '#FFFFFF')"/>
|
||||
|
||||
<function id="default_color_letter_stay_pay"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_stay_pay', '#000000')"/>
|
||||
|
||||
<function id="default_color_letter_checkout"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_checkout', '#FFFFFF')"/>
|
||||
|
||||
<function id="default_color_letter_dontsell"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_dontsell', '#FFFFFF')"/>
|
||||
|
||||
<function id="default_color_letter_staff"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_staff', '#000000')"/>
|
||||
|
||||
<function id="default_color_letter_to_assign"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_to_assign', '#000000')"/>
|
||||
|
||||
<function id="default_color_letter_payment_pending"
|
||||
model="ir.default" name="set"
|
||||
eval="('res.config.settings', 'color_letter_payment_pending', '#000000')"/>
|
||||
|
||||
</data>
|
||||
</odoo>
|
||||
27
hotel_calendar/data/views.xml
Normal file
27
hotel_calendar/data/views.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- FIXME: This collide with base view... something is wrong here :/
|
||||
idk how define this view for use in pms view without touch base hotel view -->
|
||||
<record id="hotel_calendar_view" model="ir.ui.view">
|
||||
<field name="name">Hotel Calendar</field>
|
||||
<field name="model">hotel.reservation</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_reservation_form" />
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="." position="inside">
|
||||
<div id="hcalendar"> </div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_calendar_management_view" model="ir.ui.view">
|
||||
<field name="name">Hotel Calendar Management</field>
|
||||
<field name="model">hotel.calendar.management</field>
|
||||
<field name="type">form</field>
|
||||
<field name="arch" type="xml">
|
||||
<div id="hcalendar_management"> </div>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
1227
hotel_calendar/i18n/es.po
Normal file
1227
hotel_calendar/i18n/es.po
Normal file
File diff suppressed because it is too large
Load Diff
16
hotel_calendar/models/__init__.py
Normal file
16
hotel_calendar/models/__init__.py
Normal file
@@ -0,0 +1,16 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from . import inherited_hotel_reservation
|
||||
from . import inherited_product_pricelist_item
|
||||
from . import inherited_res_users
|
||||
from . import bus_hotel_calendar
|
||||
from . import virtual_room_pricelist_cached
|
||||
from . import hotel_calendar_management
|
||||
from . import res_config
|
||||
from . import inherited_hotel_virtual_room
|
||||
from . import inherited_hotel_room
|
||||
from . import inherited_hotel_virtual_room_restriction_item
|
||||
from . import inherited_hotel_virtual_room_availability
|
||||
from . import inherited_product_pricelist
|
||||
from . import inherited_hotel_folio
|
||||
from . import inherited_ir_default
|
||||
145
hotel_calendar/models/bus_hotel_calendar.py
Normal file
145
hotel_calendar/models/bus_hotel_calendar.py
Normal file
@@ -0,0 +1,145 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from datetime import datetime
|
||||
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from odoo import models, api
|
||||
from odoo.addons.hotel_calendar.controllers.bus import HOTEL_BUS_CHANNEL_ID
|
||||
|
||||
|
||||
class BusHotelCalendar(models.TransientModel):
|
||||
_name = 'bus.hotel.calendar'
|
||||
|
||||
'''
|
||||
action:
|
||||
- create
|
||||
- write
|
||||
- unlink
|
||||
- cancelled
|
||||
ntype:
|
||||
- notif : Show a normal notification
|
||||
- warn : Show a warning notification
|
||||
- noshow : Don't show any notification
|
||||
'''
|
||||
@api.model
|
||||
def _generate_reservation_notif(self, vals):
|
||||
user_id = self.env['res.users'].browse(self.env.uid)
|
||||
master_reserv = vals['parent_reservation'] or vals['reserv_id']
|
||||
num_split = self.env['hotel.reservation'].search_count([
|
||||
('folio_id', '=', vals['folio_id']),
|
||||
'|', ('parent_reservation', '=', master_reserv),
|
||||
('id', '=', master_reserv),
|
||||
('splitted', '=', True),
|
||||
])
|
||||
|
||||
return {
|
||||
'type': 'reservation',
|
||||
'action': vals['action'],
|
||||
'subtype': vals['type'],
|
||||
'title': vals['title'],
|
||||
'username': user_id.partner_id.name,
|
||||
'userid': user_id.id,
|
||||
'reservation': {
|
||||
'product_id': vals['product_id'],
|
||||
'reserv_id': vals['reserv_id'],
|
||||
'partner_name': vals['partner_name'],
|
||||
'adults': vals['adults'],
|
||||
'childer': vals['children'],
|
||||
'checkin': vals['checkin'],
|
||||
'checkout': vals['checkout'],
|
||||
'folio_id': vals['folio_id'],
|
||||
'reserve_color': vals['reserve_color'],
|
||||
'reserve_color_text': vals['reserve_color_text'],
|
||||
'splitted': vals['splitted'],
|
||||
'parent_reservation': vals['parent_reservation'],
|
||||
'room_name': vals['room_name'],
|
||||
'state': vals['state'],
|
||||
'only_read': False,
|
||||
'fix_days': vals['fix_days'],
|
||||
'fix_rooms': False,
|
||||
'overbooking': vals['overbooking'],
|
||||
},
|
||||
'tooltip': [
|
||||
vals['partner_name'],
|
||||
vals['partner_phone'],
|
||||
vals['checkin'],
|
||||
num_split,
|
||||
vals['price'],
|
||||
]
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _generate_pricelist_notification(self, vals):
|
||||
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
|
||||
return {
|
||||
'type': 'pricelist',
|
||||
'price': {
|
||||
vals['pricelist_id']: [{
|
||||
'days': {
|
||||
date_dt.strftime("%d/%m/%Y"): vals['price'],
|
||||
},
|
||||
'room': vals['virtual_room_id'],
|
||||
'id': vals['id'],
|
||||
}],
|
||||
},
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _generate_restriction_notification(self, vals):
|
||||
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
|
||||
return {
|
||||
'type': 'restriction',
|
||||
'restriction': {
|
||||
vals['virtual_room_id']: {
|
||||
date_dt.strftime("%d/%m/%Y"): [
|
||||
vals['min_stay'],
|
||||
vals['min_stay_arrival'],
|
||||
vals['max_stay'],
|
||||
vals['max_stay_arrival'],
|
||||
vals['closed'],
|
||||
vals['closed_arrival'],
|
||||
vals['closed_departure'],
|
||||
vals['id'],
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _generate_availability_notification(self, vals):
|
||||
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
|
||||
return {
|
||||
'type': 'availability',
|
||||
'availability': {
|
||||
vals['virtual_room_id']: {
|
||||
date_dt.strftime("%d/%m/%Y"): [
|
||||
vals['avail'],
|
||||
vals['no_ota'],
|
||||
vals['id'],
|
||||
],
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@api.model
|
||||
def send_reservation_notification(self, vals):
|
||||
notif = self._generate_reservation_notif(vals)
|
||||
self.env['bus.bus'].sendone((self._cr.dbname, 'hotel.reservation',
|
||||
HOTEL_BUS_CHANNEL_ID), notif)
|
||||
|
||||
@api.model
|
||||
def send_pricelist_notification(self, vals):
|
||||
notif = self._generate_pricelist_notification(vals)
|
||||
self.env['bus.bus'].sendone((self._cr.dbname, 'hotel.reservation',
|
||||
HOTEL_BUS_CHANNEL_ID), notif)
|
||||
|
||||
@api.model
|
||||
def send_restriction_notification(self, vals):
|
||||
notif = self._generate_restriction_notification(vals)
|
||||
self.env['bus.bus'].sendone((self._cr.dbname, 'hotel.reservation',
|
||||
HOTEL_BUS_CHANNEL_ID), notif)
|
||||
|
||||
@api.model
|
||||
def send_availability_notification(self, vals):
|
||||
notif = self._generate_availability_notification(vals)
|
||||
self.env['bus.bus'].sendone((self._cr.dbname, 'hotel.reservation',
|
||||
HOTEL_BUS_CHANNEL_ID), notif)
|
||||
328
hotel_calendar/models/hotel_calendar_management.py
Normal file
328
hotel_calendar/models/hotel_calendar_management.py
Normal file
@@ -0,0 +1,328 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from odoo.tools import (
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from odoo import models, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.addons.hotel import date_utils
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelCalendarManagement(models.TransientModel):
|
||||
_name = 'hotel.calendar.management'
|
||||
|
||||
@api.model
|
||||
def _get_prices_values(self, price):
|
||||
vals = {
|
||||
'fixed_price': price['price'],
|
||||
}
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def _get_restrictions_values(self, restriction):
|
||||
vals = {
|
||||
'min_stay': restriction['min_stay'],
|
||||
'min_stay_arrival': restriction['min_stay_arrival'],
|
||||
'max_stay': restriction['max_stay'],
|
||||
'max_stay_arrival': restriction['max_stay_arrival'],
|
||||
'closed': restriction['closed'],
|
||||
'closed_arrival': restriction['closed_arrival'],
|
||||
'closed_departure': restriction['closed_departure'],
|
||||
}
|
||||
return vals
|
||||
|
||||
@api.model
|
||||
def _get_availability_values(self, avail, vroom):
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
cavail = len(vroom_obj.check_availability_virtual_room(
|
||||
avail['date'], avail['date'], virtual_room_id=vroom.id))
|
||||
ravail = min(cavail, vroom.total_rooms_count, int(avail['avail']))
|
||||
vals = {
|
||||
'no_ota': avail['no_ota'],
|
||||
'avail': ravail,
|
||||
}
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def save_changes(self, pricelist_id, restriction_id, pricelist,
|
||||
restrictions, availability):
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
product_pricelist_item_obj = self.env['product.pricelist.item']
|
||||
vroom_rest_item_obj = self.env['hotel.virtual.room.restriction.item']
|
||||
vroom_avail_obj = self.env['hotel.virtual.room.availability']
|
||||
|
||||
# Save Pricelist
|
||||
for k_price in pricelist.keys():
|
||||
vroom_id = vroom_obj.browse([int(k_price)])
|
||||
vroom_prod_tmpl_id = vroom_id.product_id.product_tmpl_id
|
||||
for price in pricelist[k_price]:
|
||||
price_id = product_pricelist_item_obj.search([
|
||||
('date_start', '>=', price['date']),
|
||||
('date_end', '<=', price['date']),
|
||||
('pricelist_id', '=', int(pricelist_id)),
|
||||
('applied_on', '=', '1_product'),
|
||||
('compute_price', '=', 'fixed'),
|
||||
('product_tmpl_id', '=', vroom_prod_tmpl_id.id),
|
||||
], limit=1)
|
||||
vals = self._get_prices_values(price)
|
||||
if not price_id:
|
||||
vals.update({
|
||||
'date_start': price['date'],
|
||||
'date_end': price['date'],
|
||||
'pricelist_id': int(pricelist_id),
|
||||
'applied_on': '1_product',
|
||||
'compute_price': 'fixed',
|
||||
'product_tmpl_id': vroom_prod_tmpl_id.id,
|
||||
})
|
||||
price_id = product_pricelist_item_obj.create(vals)
|
||||
else:
|
||||
price_id.write(vals)
|
||||
|
||||
# Save Restrictions
|
||||
for k_res in restrictions.keys():
|
||||
for restriction in restrictions[k_res]:
|
||||
res_id = vroom_rest_item_obj.search([
|
||||
('date_start', '>=', restriction['date']),
|
||||
('date_end', '<=', restriction['date']),
|
||||
('restriction_id', '=', int(restriction_id)),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('virtual_room_id', '=', int(k_res)),
|
||||
], limit=1)
|
||||
vals = self._get_restrictions_values(restriction)
|
||||
if not res_id:
|
||||
vals.update({
|
||||
'date_start': restriction['date'],
|
||||
'date_end': restriction['date'],
|
||||
'restriction_id': int(restriction_id),
|
||||
'applied_on': '0_virtual_room',
|
||||
'virtual_room_id': int(k_res),
|
||||
})
|
||||
res_id = vroom_rest_item_obj.create(vals)
|
||||
else:
|
||||
res_id.write(vals)
|
||||
|
||||
# Save Availability
|
||||
for k_avail in availability.keys():
|
||||
vroom_id = vroom_obj.browse(int(k_avail))
|
||||
for avail in availability[k_avail]:
|
||||
vals = self._get_availability_values(avail, vroom_id)
|
||||
avail_id = vroom_avail_obj.search([
|
||||
('date', '=', avail['date']),
|
||||
('virtual_room_id', '=', vroom_id.id),
|
||||
], limit=1)
|
||||
if not avail_id:
|
||||
vals.update({
|
||||
'date': avail['date'],
|
||||
'virtual_room_id': vroom_id.id,
|
||||
})
|
||||
avail_id = vroom_avail_obj.with_context({
|
||||
'mail_create_nosubscribe': True,
|
||||
}).create(vals)
|
||||
else:
|
||||
avail_id.write(vals)
|
||||
|
||||
@api.model
|
||||
def _hcalendar_room_json_data(self, rooms):
|
||||
json_data = []
|
||||
for room in rooms:
|
||||
json_data.append((
|
||||
room.id,
|
||||
room.name,
|
||||
room.get_capacity(),
|
||||
room.list_price,
|
||||
room.max_real_rooms,
|
||||
))
|
||||
return json_data
|
||||
|
||||
@api.model
|
||||
def _hcalendar_pricelist_json_data(self, prices):
|
||||
json_data = {}
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
for rec in prices:
|
||||
virtual_room_id = vroom_obj.search([
|
||||
('product_id.product_tmpl_id', '=', rec.product_tmpl_id.id)
|
||||
], limit=1)
|
||||
if not virtual_room_id:
|
||||
continue
|
||||
|
||||
# TODO: date_end - date_start loop
|
||||
json_data.setdefault(virtual_room_id.id, []).append({
|
||||
'id': rec.id,
|
||||
'price': rec.fixed_price,
|
||||
'date': rec.date_start,
|
||||
})
|
||||
return json_data
|
||||
|
||||
@api.model
|
||||
def _hcalendar_restriction_json_data(self, restrictions):
|
||||
json_data = {}
|
||||
for rec in restrictions:
|
||||
# TODO: date_end - date_start loop
|
||||
json_data.setdefault(rec.virtual_room_id.id, []).append({
|
||||
'id': rec.id,
|
||||
'date': rec.date_start,
|
||||
'min_stay': rec.min_stay,
|
||||
'min_stay_arrival': rec.min_stay_arrival,
|
||||
'max_stay': rec.max_stay,
|
||||
'max_stay_arrival': rec.max_stay_arrival,
|
||||
'closed': rec.closed,
|
||||
'closed_departure': rec.closed_departure,
|
||||
'closed_arrival': rec.closed_arrival,
|
||||
})
|
||||
return json_data
|
||||
|
||||
@api.model
|
||||
def _hcalendar_availability_json_data(self, dfrom, dto):
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False)
|
||||
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
|
||||
vrooms = self.env['hotel.virtual.room'].search([])
|
||||
json_data = {}
|
||||
|
||||
for vroom in vrooms:
|
||||
json_data[vroom.id] = []
|
||||
for i in range(0, date_diff):
|
||||
cur_date = date_start + timedelta(days=i)
|
||||
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
avail = self.env['hotel.virtual.room.availability'].search([
|
||||
('date', '=', cur_date_str),
|
||||
('virtual_room_id', '=', vroom.id)
|
||||
])
|
||||
if avail:
|
||||
json_data[vroom.id].append({
|
||||
'id': avail.id,
|
||||
'date': avail.date,
|
||||
'avail': avail.avail,
|
||||
'no_ota': avail.no_ota,
|
||||
})
|
||||
else:
|
||||
json_data[vroom.id].append({
|
||||
'id': False,
|
||||
'date': cur_date_str,
|
||||
'avail': vroom.max_real_rooms,
|
||||
'no_ota': False,
|
||||
})
|
||||
return json_data
|
||||
|
||||
@api.model
|
||||
def _hcalendar_events_json_data(self, dfrom, dto):
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False) - timedelta(days=1)
|
||||
date_start_str = date_start.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
user_id = self.env['res.users'].browse(self.env.uid)
|
||||
domain = []
|
||||
if user_id.pms_allowed_events_tags:
|
||||
domain.append(('categ_ids', 'in', user_id.pms_allowed_events_tags))
|
||||
if user_id.pms_denied_events_tags:
|
||||
domain.append(
|
||||
('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)
|
||||
])
|
||||
events_lr = self.env['calendar.event'].search([
|
||||
('start', '>=', date_start_str),
|
||||
('stop', '<=', dto)
|
||||
])
|
||||
events = (events_ll | events_lr) & events_raw
|
||||
json_data = []
|
||||
for event in events:
|
||||
json_data.append([
|
||||
event.id,
|
||||
event.name,
|
||||
event.start,
|
||||
event.location,
|
||||
])
|
||||
return json_data
|
||||
|
||||
@api.model
|
||||
def _hcalendar_get_count_reservations_json_data(self, dfrom, dto):
|
||||
vrooms = self.env['hotel.virtual.room'].search([])
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False)
|
||||
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
|
||||
hotel_vroom_obj = self.env['hotel.virtual.room']
|
||||
vrooms = hotel_vroom_obj.search([])
|
||||
json_data = {}
|
||||
|
||||
for vroom in vrooms:
|
||||
for i in range(0, date_diff):
|
||||
cur_date = date_start + timedelta(days=i)
|
||||
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
json_data.setdefault(vroom.id, []).append({
|
||||
'date': cur_date_str,
|
||||
'num': len(
|
||||
hotel_vroom_obj.check_availability_virtual_room(
|
||||
cur_date_str,
|
||||
cur_date_str,
|
||||
virtual_room_id=vroom.id)),
|
||||
})
|
||||
|
||||
return json_data
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_all_data(self, dfrom, dto, pricelist_id, restriction_id,
|
||||
withRooms):
|
||||
if not dfrom or not dto:
|
||||
raise ValidationError(_('Input Error: No dates defined!'))
|
||||
vals = {}
|
||||
if not pricelist_id:
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if not restriction_id:
|
||||
restriction_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_restrictions_id')
|
||||
|
||||
pricelist_id = int(pricelist_id)
|
||||
vals.update({'pricelist_id': pricelist_id})
|
||||
restriction_id = int(restriction_id)
|
||||
vals.update({'restriction_id': restriction_id})
|
||||
|
||||
vroom_rest_it_obj = self.env['hotel.virtual.room.restriction.item']
|
||||
restriction_item_ids = vroom_rest_it_obj.search([
|
||||
('date_start', '>=', dfrom), ('date_end', '<=', dto),
|
||||
('restriction_id', '=', restriction_id),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
])
|
||||
|
||||
pricelist_item_ids = self.env['product.pricelist.item'].search([
|
||||
('date_start', '>=', dfrom), ('date_end', '<=', dto),
|
||||
('pricelist_id', '=', pricelist_id),
|
||||
('applied_on', '=', '1_product'),
|
||||
('compute_price', '=', 'fixed'),
|
||||
])
|
||||
|
||||
json_prices = self._hcalendar_pricelist_json_data(pricelist_item_ids)
|
||||
json_rest = self._hcalendar_restriction_json_data(restriction_item_ids)
|
||||
json_avails = self._hcalendar_availability_json_data(dfrom, dto)
|
||||
json_rc = self._hcalendar_get_count_reservations_json_data(dfrom, dto)
|
||||
json_events = self._hcalendar_events_json_data(dfrom, dto)
|
||||
vals.update({
|
||||
'prices': json_prices or [],
|
||||
'restrictions': json_rest or [],
|
||||
'availability': json_avails or [],
|
||||
'count_reservations': json_rc or [],
|
||||
'events': json_events or [],
|
||||
})
|
||||
|
||||
if withRooms:
|
||||
room_ids = self.env['hotel.virtual.room'].search(
|
||||
[],
|
||||
order='hcal_sequence ASC')
|
||||
json_rooms = self._hcalendar_room_json_data(room_ids)
|
||||
vals.update({'rooms': json_rooms or []})
|
||||
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def get_hcalendar_settings(self):
|
||||
user_id = self.env['res.users'].browse(self.env.uid)
|
||||
return {
|
||||
'eday_week': user_id.npms_end_day_week,
|
||||
'eday_week_offset': user_id.npms_end_day_week_offset,
|
||||
'days': user_id.npms_default_num_days,
|
||||
'show_notifications': user_id.pms_show_notifications,
|
||||
'show_num_rooms': user_id.pms_show_num_rooms,
|
||||
}
|
||||
17
hotel_calendar/models/inherited_hotel_folio.py
Normal file
17
hotel_calendar/models/inherited_hotel_folio.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
from odoo import models, fields, api, _
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelFolio(models.Model):
|
||||
_inherit = 'hotel.folio'
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
ret = super(HotelFolio, self).write(vals)
|
||||
if vals.get('room_lines') or vals.get('service_lines'):
|
||||
for record in self:
|
||||
record.room_lines.send_bus_notification('write', 'noshow')
|
||||
return ret
|
||||
384
hotel_calendar/models/inherited_hotel_reservation.py
Normal file
384
hotel_calendar/models/inherited_hotel_reservation.py
Normal file
@@ -0,0 +1,384 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from odoo import models, fields, api, _
|
||||
from odoo.exceptions import ValidationError
|
||||
from odoo.tools import (
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from odoo.addons.hotel import date_utils
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelReservation(models.Model):
|
||||
_inherit = 'hotel.reservation'
|
||||
|
||||
@api.model
|
||||
def _hcalendar_reservation_data(self, reservations):
|
||||
json_reservations = []
|
||||
json_reservation_tooltips = {}
|
||||
for reserv in reservations:
|
||||
json_reservations.append([
|
||||
reserv.product_id.id,
|
||||
reserv.id,
|
||||
reserv.folio_id.partner_id.name,
|
||||
reserv.adults,
|
||||
reserv.children,
|
||||
reserv.checkin,
|
||||
reserv.checkout,
|
||||
reserv.folio_id.id,
|
||||
reserv.reserve_color,
|
||||
reserv.reserve_color_text,
|
||||
reserv.splitted,
|
||||
reserv.parent_reservation and reserv.parent_reservation.id
|
||||
or False,
|
||||
False, # Read-Only
|
||||
reserv.splitted, # Fix Days
|
||||
False, # Fix Rooms
|
||||
reserv.overbooking])
|
||||
num_split = 0
|
||||
if reserv.splitted:
|
||||
master_reserv = reserv.parent_reservation or reserv
|
||||
num_split = self.search_count([
|
||||
('folio_id', '=', reserv.folio_id.id),
|
||||
'|', ('parent_reservation', '=', master_reserv.id),
|
||||
('id', '=', master_reserv.id),
|
||||
('splitted', '=', True),
|
||||
])
|
||||
json_reservation_tooltips.update({
|
||||
reserv.id: [
|
||||
reserv.folio_id.partner_id.name,
|
||||
reserv.folio_id.partner_id.mobile or
|
||||
reserv.folio_id.partner_id.phone or _('Undefined'),
|
||||
reserv.checkin,
|
||||
num_split,
|
||||
reserv.folio_id.amount_total]
|
||||
})
|
||||
return (json_reservations, json_reservation_tooltips)
|
||||
|
||||
@api.model
|
||||
def _hcalendar_room_data(self, rooms):
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
json_rooms = []
|
||||
room_type_obj = self.env['hotel.room.type']
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
for room in rooms:
|
||||
room_type = room_type_obj.search([
|
||||
('cat_id', '=', room.categ_id.id)
|
||||
], limit=1)
|
||||
vrooms = vroom_obj.search([
|
||||
'|', ('room_ids', 'in', room.id),
|
||||
('room_type_ids.id', '=', room.categ_id.id)],
|
||||
order='hcal_sequence ASC')
|
||||
json_rooms.append((
|
||||
room.product_id.id,
|
||||
room.name,
|
||||
room.capacity,
|
||||
room.categ_id.id,
|
||||
room_type.code_type,
|
||||
room.shared_room,
|
||||
room.sale_price_type == 'vroom'
|
||||
and ['pricelist', room.price_virtual_room.id, pricelist_id,
|
||||
room.price_virtual_room.name]
|
||||
or ['fixed', room.list_price],
|
||||
vrooms.mapped('name'),
|
||||
vrooms.ids,
|
||||
room.floor_id.id,
|
||||
room.room_amenities.ids))
|
||||
return json_rooms
|
||||
|
||||
@api.model
|
||||
def _hcalendar_event_data(self, events):
|
||||
json_events = []
|
||||
for event in events:
|
||||
json_events.append([
|
||||
event.id,
|
||||
event.name,
|
||||
event.start,
|
||||
event.location,
|
||||
])
|
||||
return json_events
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_reservations_data(self, dfrom, dto, rooms):
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False) \
|
||||
- timedelta(days=1)
|
||||
date_start_str = date_start.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
room_product_ids = rooms.mapped('product_id.id')
|
||||
reservations_raw = self.env['hotel.reservation'].search(
|
||||
[
|
||||
('product_id', 'in', room_product_ids),
|
||||
('state', 'in',
|
||||
['draft', 'confirm', 'booking', 'done', False]),
|
||||
],
|
||||
order="checkin DESC, checkout ASC, adults DESC, children DESC")
|
||||
reservations_ll = self.env['hotel.reservation'].search([
|
||||
('checkin', '<=', dto),
|
||||
('checkout', '>=', date_start_str)
|
||||
])
|
||||
reservations_lr = self.env['hotel.reservation'].search([
|
||||
('checkin', '>=', date_start_str),
|
||||
('checkout', '<=', dto)
|
||||
])
|
||||
reservations = (reservations_ll | reservations_lr) & reservations_raw
|
||||
return self._hcalendar_reservation_data(reservations)
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_pricelist_data(self, dfrom, dto):
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False) \
|
||||
- timedelta(days=1)
|
||||
date_diff = date_utils.date_diff(date_start, dto, hours=False) + 1
|
||||
# Get Prices
|
||||
json_rooms_prices = {pricelist_id: []}
|
||||
vrooms = self.env['hotel.virtual.room'].search(
|
||||
[],
|
||||
order='hcal_sequence ASC')
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
|
||||
for vroom in vrooms:
|
||||
days = {}
|
||||
for i in range(0, date_diff):
|
||||
ndate = date_start + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod_price_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
('date', '=', ndate_str)
|
||||
], limit=1)
|
||||
days.update({
|
||||
ndate.strftime("%d/%m/%Y"): prod_price_id and
|
||||
prod_price_id.price or
|
||||
vroom.product_id.with_context(
|
||||
quantity=1,
|
||||
date=ndate_str,
|
||||
pricelist=pricelist_id).price
|
||||
})
|
||||
json_rooms_prices[pricelist_id].append({
|
||||
'room': vroom.id,
|
||||
'days': days,
|
||||
'title': vroom.name,
|
||||
})
|
||||
return json_rooms_prices
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_restrictions_data(self, dfrom, dto):
|
||||
restriction_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_restrictions_id')
|
||||
if restriction_id:
|
||||
restriction_id = int(restriction_id)
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False) \
|
||||
- timedelta(days=1)
|
||||
date_diff = date_utils.date_diff(dfrom, dto, hours=False) + 1
|
||||
# Get Prices
|
||||
json_rooms_rests = {}
|
||||
vrooms = self.env['hotel.virtual.room'].search(
|
||||
[],
|
||||
order='hcal_sequence ASC')
|
||||
vroom_rest_obj = self.env['hotel.virtual.room.restriction.item']
|
||||
for vroom in vrooms:
|
||||
days = {}
|
||||
for i in range(0, date_diff):
|
||||
ndate = date_start + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
rest_id = vroom_rest_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
('date_start', '>=', ndate_str),
|
||||
('date_end', '<=', ndate_str),
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('restriction_id', '=', restriction_id)
|
||||
], limit=1)
|
||||
if rest_id and (rest_id.min_stay or rest_id.min_stay_arrival or
|
||||
rest_id.max_stay or rest_id.max_stay_arrival or
|
||||
rest_id.closed or rest_id.closed_arrival or
|
||||
rest_id.closed_departure):
|
||||
days.update({
|
||||
ndate.strftime("%d/%m/%Y"): (
|
||||
rest_id.min_stay,
|
||||
rest_id.min_stay_arrival,
|
||||
rest_id.max_stay,
|
||||
rest_id.max_stay_arrival,
|
||||
rest_id.closed,
|
||||
rest_id.closed_arrival,
|
||||
rest_id.closed_departure)
|
||||
})
|
||||
json_rooms_rests.update({vroom.id: days})
|
||||
return json_rooms_rests
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_events_data(self, dfrom, dto):
|
||||
date_start = date_utils.get_datetime(dfrom, hours=False) \
|
||||
- timedelta(days=1)
|
||||
date_start_str = date_start.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
user_id = self.env['res.users'].browse(self.env.uid)
|
||||
domain = []
|
||||
if user_id.pms_allowed_events_tags:
|
||||
domain.append(('categ_ids', 'in', user_id.pms_allowed_events_tags))
|
||||
if user_id.pms_denied_events_tags:
|
||||
domain.append(
|
||||
('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)
|
||||
])
|
||||
events_lr = self.env['calendar.event'].search([
|
||||
('start', '>=', date_start_str),
|
||||
('stop', '<=', dto)
|
||||
])
|
||||
events = (events_ll | events_lr) & events_raw
|
||||
return self._hcalendar_event_data(events)
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_settings(self):
|
||||
user_id = self.env['res.users'].browse(self.env.uid)
|
||||
type_move = user_id.pms_type_move
|
||||
return {
|
||||
'divide_rooms_by_capacity': user_id.pms_divide_rooms_by_capacity,
|
||||
'eday_week': user_id.pms_end_day_week,
|
||||
'eday_week_offset': user_id.pms_end_day_week_offset,
|
||||
'days': user_id.pms_default_num_days,
|
||||
'allow_invalid_actions': type_move == 'allow_invalid',
|
||||
'assisted_movement': type_move == 'assisted',
|
||||
'default_arrival_hour': self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_arrival_hour'),
|
||||
'default_departure_hour': self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_departure_hour'),
|
||||
'show_notifications': user_id.pms_show_notifications,
|
||||
'show_pricelist': user_id.pms_show_pricelist,
|
||||
'show_availability': user_id.pms_show_availability,
|
||||
'show_num_rooms': user_id.pms_show_num_rooms,
|
||||
}
|
||||
|
||||
@api.model
|
||||
def get_hcalendar_all_data(self, dfrom, dto, withRooms=True):
|
||||
if not dfrom or not dto:
|
||||
raise ValidationError(_('Input Error: No dates defined!'))
|
||||
|
||||
rooms = self.env['hotel.room'].search([], order='hcal_sequence ASC')
|
||||
json_res, json_res_tooltips = self.get_hcalendar_reservations_data(
|
||||
dfrom, dto, 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),
|
||||
}
|
||||
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def send_bus_notification(self, naction, ntype, ntitle=''):
|
||||
hotel_cal_obj = self.env['bus.hotel.calendar']
|
||||
for record in self:
|
||||
hotel_cal_obj.send_reservation_notification({
|
||||
'action': naction,
|
||||
'type': ntype,
|
||||
'title': ntitle,
|
||||
'product_id': record.product_id.id,
|
||||
'reserv_id': record.id,
|
||||
'partner_name': record.partner_id.name,
|
||||
'adults': record.adults,
|
||||
'children': record.children,
|
||||
'checkin': record.checkin,
|
||||
'checkout': record.checkout,
|
||||
'folio_id': record.folio_id.id,
|
||||
'reserve_color': record.reserve_color,
|
||||
'reserve_color_text': record.reserve_color_text,
|
||||
'splitted': record.splitted,
|
||||
'parent_reservation': record.parent_reservation and
|
||||
record.parent_reservation.id or 0,
|
||||
'room_name': record.product_id.name,
|
||||
'partner_phone': record.partner_id.mobile
|
||||
or record.partner_id.phone or _('Undefined'),
|
||||
'state': record.state,
|
||||
'fix_days': record.splitted,
|
||||
'overbooking': record.overbooking,
|
||||
'price': record.folio_id.amount_total,
|
||||
})
|
||||
|
||||
@api.model
|
||||
def swap_reservations(self, fromReservsIds, toReservsIds):
|
||||
from_reservs = self.env['hotel.reservation'].browse(fromReservsIds)
|
||||
to_reservs = self.env['hotel.reservation'].browse(toReservsIds)
|
||||
|
||||
if not any(from_reservs) or not any(toReservs):
|
||||
raise ValidationError(_("Invalid swap parameters"))
|
||||
|
||||
max_from_persons = max(
|
||||
from_reservs.mapped(lambda x: x.adults + x.children))
|
||||
max_to_persons = max(
|
||||
to_reservs.mapped(lambda x: x.adults + x.children))
|
||||
|
||||
from_room_product = from_reservs[0].product_id
|
||||
to_room_product = to_reservs[0].product_id
|
||||
from_overbooking = from_reservs[0].overbooking
|
||||
to_overbooking = to_reservs[0].overbooking
|
||||
|
||||
hotel_room_obj = self.env['hotel.room']
|
||||
from_room = hotel_room_obj.search([
|
||||
('product_id', '=', from_room_product.id)])
|
||||
to_room = hotel_room_obj.search([
|
||||
('product_id', '=', from_room_product.id)])
|
||||
|
||||
if max_from_persons > to_room.capacity or \
|
||||
max_to_persons > from_room.capacity:
|
||||
raise ValidationError("Invalid swap operation: wrong capacity")
|
||||
|
||||
for record in from_reservs:
|
||||
record.with_context({'ignore_avail_restrictions': True}).write({
|
||||
'product_id': to_room_product.id,
|
||||
'overbooking': to_overbooking,
|
||||
})
|
||||
for record in to_reservs:
|
||||
record.with_context({'ignore_avail_restrictions': True}).write({
|
||||
'product_id': from_room_product.id,
|
||||
'overbooking': from_overbooking,
|
||||
})
|
||||
|
||||
return True
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
reservation_id = super(HotelReservation, self).create(vals)
|
||||
reservation_id.send_bus_notification('create',
|
||||
'notify',
|
||||
_("Reservation Created"))
|
||||
return reservation_id
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
ret = super(HotelReservation, self).write(vals)
|
||||
if 'partner_id' in vals or 'checkin' in vals or \
|
||||
'checkout' in vals or 'product_id' in vals or \
|
||||
'adults' in vals or 'children' in vals or \
|
||||
'state' in vals or 'splitted' in vals or \
|
||||
'reserve_color' in vals or \
|
||||
'reserve_color_text' in vals or 'product_id' in vals or \
|
||||
'parent_reservation' in vals or 'overbooking' in vals:
|
||||
for record in self:
|
||||
record.send_bus_notification(
|
||||
'write',
|
||||
(record.state == 'cancelled') and 'warn' or 'notify',
|
||||
(record.state == 'cancelled') and
|
||||
_("Reservation Cancelled") or _("Reservation Changed")
|
||||
)
|
||||
elif not any(vals) or 'to_read' in vals or 'to_assign' in vals:
|
||||
self.send_bus_notification('write', 'noshow')
|
||||
return ret
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
self.send_bus_notification('unlink',
|
||||
'warn',
|
||||
_("Reservation Deleted"))
|
||||
return super(HotelReservation, self).unlink()
|
||||
9
hotel_calendar/models/inherited_hotel_room.py
Normal file
9
hotel_calendar/models/inherited_hotel_room.py
Normal file
@@ -0,0 +1,9 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class HotelRoom(models.Model):
|
||||
_inherit = 'hotel.room'
|
||||
|
||||
hcal_sequence = fields.Integer('Calendar Sequence', default=0)
|
||||
21
hotel_calendar/models/inherited_hotel_virtual_room.py
Normal file
21
hotel_calendar/models/inherited_hotel_virtual_room.py
Normal file
@@ -0,0 +1,21 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class HotelVirtualRoom(models.Model):
|
||||
_inherit = 'hotel.virtual.room'
|
||||
|
||||
hcal_sequence = fields.Integer('Calendar Sequence', default=0)
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
for record in self:
|
||||
pr_chached = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', record.id)
|
||||
])
|
||||
# Because 'pricelist.cached' is an isolated model,
|
||||
# doesn't trigger 'ondelete'. Need call 'unlink' instead.
|
||||
pr_chached.unlink()
|
||||
return super(HotelVirtualRoom, self).unlink()
|
||||
@@ -0,0 +1,51 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class HotelVirtualRoomAvailability(models.Model):
|
||||
_inherit = 'hotel.virtual.room.availability'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(HotelVirtualRoomAvailability, self).create(vals)
|
||||
self.env['bus.hotel.calendar'].send_availability_notification({
|
||||
'date': res.date,
|
||||
'avail': res.avail,
|
||||
'no_ota': res.no_ota,
|
||||
'virtual_room_id': res.virtual_room_id.id,
|
||||
'id': res.id,
|
||||
})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
ret_vals = super(HotelVirtualRoomAvailability, self).write(vals)
|
||||
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for record in self:
|
||||
bus_hotel_calendar_obj.send_availability_notification({
|
||||
'date': record.date,
|
||||
'avail': record.avail,
|
||||
'no_ota': record.no_ota,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'id': record.id,
|
||||
})
|
||||
return ret_vals
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
# Construct dictionary with relevant info of removed records
|
||||
unlink_vals = []
|
||||
for record in self:
|
||||
unlink_vals.append({
|
||||
'date': record.date,
|
||||
'avail': record.virtual_room_id.max_real_rooms,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'no_ota': False,
|
||||
'id': record.id,
|
||||
})
|
||||
res = super(HotelVirtualRoomAvailability, self).unlink()
|
||||
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for uval in unlink_vals:
|
||||
bus_hotel_calendar_obj.send_availability_notification(uval)
|
||||
return res
|
||||
@@ -0,0 +1,93 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
import logging
|
||||
from odoo import models, fields, api
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelVirtualRoomResrtrictionItem(models.Model):
|
||||
_inherit = 'hotel.virtual.room.restriction.item'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(HotelVirtualRoomResrtrictionItem, self).create(vals)
|
||||
restrictions_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_restrictions_id')
|
||||
if restrictions_parity_id:
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
restriction_id = res.restriction_id.id
|
||||
if restriction_id == restrictions_parity_id and \
|
||||
self.applied_on == '0_virtual_room':
|
||||
self.env['bus.hotel.calendar'].send_restriction_notification({
|
||||
'restriction_id': self.restriction_id.id,
|
||||
'date': self.date_start,
|
||||
'min_stay': self.min_stay,
|
||||
'min_stay_arrival': self.min_stay_arrival,
|
||||
'max_stay': self.max_stay,
|
||||
'max_stay_arrival': self.max_stay_arrival,
|
||||
'closed': self.closed,
|
||||
'closed_departure': self.closed_departure,
|
||||
'closed_arrival': self.closed_arrival,
|
||||
'virtual_room_id': self.virtual_room_id.id,
|
||||
'id': self.id,
|
||||
})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
restrictions_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_restrictions_id')
|
||||
if restrictions_parity_id:
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
ret_vals = super(HotelVirtualRoomResrtrictionItem, self).write(vals)
|
||||
|
||||
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for record in self:
|
||||
if record.restriction_id.id != restrictions_parity_id or \
|
||||
record.applied_on != '0_virtual_room':
|
||||
continue
|
||||
bus_hotel_calendar_obj.send_restriction_notification({
|
||||
'restriction_id': record.restriction_id.id,
|
||||
'date': record.date_start,
|
||||
'min_stay': record.min_stay,
|
||||
'min_stay_arrival': record.min_stay_arrival,
|
||||
'max_stay': record.max_stay,
|
||||
'max_stay_arrival': record.max_stay_arrival,
|
||||
'closed': record.closed,
|
||||
'closed_departure': record.closed_departure,
|
||||
'closed_arrival': record.closed_arrival,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'id': record.id,
|
||||
})
|
||||
return ret_vals
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
restrictions_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_restrictions_id')
|
||||
if restrictions_parity_id:
|
||||
restrictions_parity_id = int(restrictions_parity_id)
|
||||
# Construct dictionary with relevant info of removed records
|
||||
unlink_vals = []
|
||||
for record in self:
|
||||
if record.restriction_id.id != restrictions_parity_id or \
|
||||
record.applied_on != '0_virtual_room':
|
||||
continue
|
||||
unlink_vals.append({
|
||||
'restriction_id': record.restriction_id.id,
|
||||
'date': record.date_start,
|
||||
'min_stay': 0,
|
||||
'min_stay_arrival': 0,
|
||||
'max_stay': 0,
|
||||
'max_stay_arrival': 0,
|
||||
'closed': False,
|
||||
'closed_departure': False,
|
||||
'closed_arrival': False,
|
||||
'virtual_room_id': record.virtual_room_id.id,
|
||||
'id': record.id,
|
||||
})
|
||||
res = super(HotelVirtualRoomResrtrictionItem, self).unlink()
|
||||
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for uval in unlink_vals:
|
||||
bus_hotel_calendar_obj.send_restriction_notification(uval)
|
||||
return res
|
||||
@@ -0,0 +1,8 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields
|
||||
|
||||
class ActWindowView(models.Model):
|
||||
_inherit = 'ir.actions.act_window.view'
|
||||
|
||||
view_mode = fields.Selection(selection_add=[('pms', "PMS")])
|
||||
36
hotel_calendar/models/inherited_ir_default.py
Normal file
36
hotel_calendar/models/inherited_ir_default.py
Normal file
@@ -0,0 +1,36 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
from odoo.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from odoo.addons.hotel import date_utils
|
||||
|
||||
|
||||
class IrDefault(models.Model):
|
||||
_inherit = 'ir.default'
|
||||
|
||||
@api.model
|
||||
def set(self, model_name, field_name, value, user_id=False, company_id=False, condition=False):
|
||||
super(IrDefault, self).set(model_name, field_name, value, user_id, company_id, condition)
|
||||
if model_name == 'res.config.settings' and field_name == 'parity_pricelist_id':
|
||||
pricelist_id = int(value)
|
||||
self.env['virtual.room.pricelist.cached'].search([]).unlink()
|
||||
|
||||
pricelist_items = self.env['product.pricelist.item'].search([
|
||||
('pricelist_id', '=', pricelist_id)
|
||||
])
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
for pitem in pricelist_items:
|
||||
date_start = pitem.date_start
|
||||
product_tmpl_id = pitem.product_tmpl_id.id
|
||||
fixed_price = pitem.fixed_price
|
||||
vroom = vroom_obj.search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id),
|
||||
('date_start', '>=', date_utils.now().strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
], limit=1)
|
||||
vroom_pr_cached_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
'date': date_start,
|
||||
'price': fixed_price,
|
||||
})
|
||||
8
hotel_calendar/models/inherited_ir_ui_view.py
Normal file
8
hotel_calendar/models/inherited_ir_ui_view.py
Normal file
@@ -0,0 +1,8 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields
|
||||
|
||||
class View(models.Model):
|
||||
_inherit = 'ir.ui.view'
|
||||
|
||||
type = fields.Selection(selection_add=[('pms', "PMS")])
|
||||
33
hotel_calendar/models/inherited_product_pricelist.py
Normal file
33
hotel_calendar/models/inherited_product_pricelist.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ProductPricelist(models.Model):
|
||||
_inherit = 'product.pricelist'
|
||||
|
||||
@api.multi
|
||||
def update_price(self, virtual_room_id, date, price):
|
||||
vroom = self.env['hotel.virtual.room'].browse(virtual_room_id)
|
||||
pritem_obj = self.env['product.pricelist.item']
|
||||
for record in self:
|
||||
plitem = pritem_obj.search([
|
||||
('pricelist_id', '=', record.id),
|
||||
('product_tmpl_id', '=', vroom.product_id.product_tmpl_id.id),
|
||||
('date_start', '=', date),
|
||||
('date_end', '=', date),
|
||||
('applied_on', '=', '1_product'),
|
||||
('compute_price', '=', 'fixed')
|
||||
])
|
||||
if plitem:
|
||||
plitem.fixed_price = price
|
||||
else:
|
||||
pritem_obj.create({
|
||||
'pricelist_id': record.id,
|
||||
'product_tmpl_id': vroom.product_id.product_tmpl_id.id,
|
||||
'date_start': date,
|
||||
'date_end': date,
|
||||
'applied_on': '1_product',
|
||||
'compute_price': 'fixed',
|
||||
'fixed_price': price
|
||||
})
|
||||
155
hotel_calendar/models/inherited_product_pricelist_item.py
Normal file
155
hotel_calendar/models/inherited_product_pricelist_item.py
Normal file
@@ -0,0 +1,155 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
|
||||
|
||||
class ProductPricelistItem(models.Model):
|
||||
_inherit = 'product.pricelist.item'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
res = super(ProductPricelistItem, self).create(vals)
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
pricelist_id = res.pricelist_id.id
|
||||
product_tmpl_id = res.product_tmpl_id.id
|
||||
date_start = res.date_start
|
||||
vroom = self.env['hotel.virtual.room'].search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id)
|
||||
], limit=1)
|
||||
if pricelist_id == pricelist_parity_id and vroom:
|
||||
prod = vroom.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
pricelist=pricelist_id)
|
||||
prod_price = prod.price
|
||||
|
||||
self.env['bus.hotel.calendar'].send_pricelist_notification({
|
||||
'pricelist_id': pricelist_id,
|
||||
'date': date_start,
|
||||
'virtual_room_id': vroom.id,
|
||||
'price': prod_price,
|
||||
'id': self.id,
|
||||
})
|
||||
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
vroom_pr_cached_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.write({'price': prod_price})
|
||||
else:
|
||||
vroom_pr_cached_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
'date': date_start,
|
||||
'price': prod_price,
|
||||
})
|
||||
return res
|
||||
|
||||
@api.multi
|
||||
def write(self, vals):
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
ret_vals = super(ProductPricelistItem, self).write(vals)
|
||||
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
bus_calendar_obj = self.env['bus.hotel.calendar']
|
||||
vroom_obj = self.env['hotel.virtual.room']
|
||||
if vals.get('fixed_price'):
|
||||
for record in self:
|
||||
pricelist_id = vals.get('pricelist_id') or \
|
||||
record.pricelist_id.id
|
||||
if pricelist_id != pricelist_parity_id:
|
||||
continue
|
||||
date_start = vals.get('date_start') or record.date_start
|
||||
product_tmpl_id = vals.get('product_tmpl_id') or \
|
||||
record.product_tmpl_id.id
|
||||
vroom = vroom_obj.search([
|
||||
('product_id.product_tmpl_id', '=', product_tmpl_id)
|
||||
], limit=1)
|
||||
|
||||
if vroom and date_start:
|
||||
prod = vroom.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
pricelist=pricelist_id)
|
||||
prod_price = prod.price
|
||||
|
||||
bus_calendar_obj.send_pricelist_notification({
|
||||
'pricelist_id': pricelist_id,
|
||||
'date': date_start,
|
||||
'virtual_room_id': vroom.id,
|
||||
'price': prod_price,
|
||||
'id': record.id,
|
||||
})
|
||||
|
||||
vroom_pr_cached_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.write({'price': prod_price})
|
||||
else:
|
||||
vroom_pr_cached_obj.create({
|
||||
'virtual_room_id': vroom.id,
|
||||
'date': date_start,
|
||||
'price': prod_price,
|
||||
})
|
||||
return ret_vals
|
||||
|
||||
@api.multi
|
||||
def unlink(self):
|
||||
pricelist_parity_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_parity_id:
|
||||
pricelist_parity_id = int(pricelist_parity_id)
|
||||
# Construct dictionary with relevant info of removed records
|
||||
unlink_vals = []
|
||||
for record in self:
|
||||
if record.pricelist_id.id != pricelist_parity_id:
|
||||
continue
|
||||
vroom = self.env['hotel.virtual.room'].search([
|
||||
('product_id.product_tmpl_id', '=', record.product_tmpl_id.id)
|
||||
], limit=1)
|
||||
unlink_vals.append({
|
||||
'pricelist_id': record.pricelist_id.id,
|
||||
'date': record.date_start,
|
||||
'vroom': vroom,
|
||||
'id': record.id,
|
||||
})
|
||||
# Do Normal Stuff
|
||||
res = super(ProductPricelistItem, self).unlink()
|
||||
# Do extra operations
|
||||
vroom_pr_cached_obj = self.env['virtual.room.pricelist.cached']
|
||||
bus_calendar_obj = self.env['bus.hotel.calendar']
|
||||
for vals in unlink_vals:
|
||||
pricelist_id = vals['pricelist_id']
|
||||
date_start = vals['date']
|
||||
vroom = vals['vroom']
|
||||
prod = vroom.product_id.with_context(
|
||||
quantity=1,
|
||||
date=date_start,
|
||||
pricelist=pricelist_id)
|
||||
|
||||
# Send Notification to update calendar pricelist
|
||||
bus_calendar_obj.send_pricelist_notification({
|
||||
'pricelist_id': pricelist_id,
|
||||
'date': date_start,
|
||||
'virtual_room_id': vroom.id,
|
||||
'price': prod.price,
|
||||
'id': vals['id'],
|
||||
})
|
||||
|
||||
# Remove records from cache model
|
||||
vroom_pr_cached_id = vroom_pr_cached_obj.search([
|
||||
('virtual_room_id', '=', vroom.id),
|
||||
('date', '=', date_start),
|
||||
], limit=1)
|
||||
if vroom_pr_cached_id:
|
||||
vroom_pr_cached_id.unlink()
|
||||
return res
|
||||
82
hotel_calendar/models/inherited_res_users.py
Normal file
82
hotel_calendar/models/inherited_res_users.py
Normal file
@@ -0,0 +1,82 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields
|
||||
|
||||
|
||||
class ResUsers(models.Model):
|
||||
_inherit = 'res.users'
|
||||
|
||||
pms_divide_rooms_by_capacity = fields.Boolean('Divide rooms by capacity')
|
||||
pms_end_day_week = fields.Selection([
|
||||
('1', 'Monday'),
|
||||
('2', 'Tuesday'),
|
||||
('3', 'Wednesday'),
|
||||
('4', 'Thursday'),
|
||||
('5', 'Friday'),
|
||||
('6', 'Saturday'),
|
||||
('7', 'Sunday')
|
||||
], string='End day of week', default='6')
|
||||
pms_end_day_week_offset = fields.Selection([
|
||||
('0', '0 Days'),
|
||||
('1', '1 Days'),
|
||||
('2', '2 Days'),
|
||||
('3', '3 Days'),
|
||||
('4', '4 Days'),
|
||||
('5', '5 Days'),
|
||||
('6', '6 Days')
|
||||
], string='Also illuminate the previous', default='0')
|
||||
pms_type_move = fields.Selection([
|
||||
('normal', 'Normal'),
|
||||
('assisted', 'Assisted'),
|
||||
('allow_invalid', 'Allow Invalid')
|
||||
], string='Reservation move mode', default='normal')
|
||||
pms_default_num_days = fields.Selection([
|
||||
('month', '1 Month'),
|
||||
('21', '3 Weeks'),
|
||||
('14', '2 Weeks'),
|
||||
('7', '1 Week')
|
||||
], string='Default number of days', default='month')
|
||||
|
||||
pms_show_notifications = fields.Boolean('Show Notifications', default=True)
|
||||
pms_show_pricelist = fields.Boolean('Show Pricelist', default=True)
|
||||
pms_show_availability = fields.Boolean('Show Availability', default=True)
|
||||
pms_show_num_rooms = fields.Integer('Show Num. Rooms', default=0)
|
||||
|
||||
pms_allowed_events_tags = fields.Many2many(
|
||||
'calendar.event.type',
|
||||
string="Allow Calander Event Tags")
|
||||
pms_denied_events_tags = fields.Many2many(
|
||||
'calendar.event.type',
|
||||
string="Deny Calander Event Tags")
|
||||
|
||||
npms_end_day_week = fields.Selection([
|
||||
('1', 'Monday'),
|
||||
('2', 'Tuesday'),
|
||||
('3', 'Wednesday'),
|
||||
('4', 'Thursday'),
|
||||
('5', 'Friday'),
|
||||
('6', 'Saturday'),
|
||||
('7', 'Sunday')
|
||||
], string='End day of week', default='6')
|
||||
npms_end_day_week_offset = fields.Selection([
|
||||
('0', '0 Days'),
|
||||
('1', '1 Days'),
|
||||
('2', '2 Days'),
|
||||
('3', '3 Days'),
|
||||
('4', '4 Days'),
|
||||
('5', '5 Days'),
|
||||
('6', '6 Days')
|
||||
], string='Also illuminate the previous', default='0')
|
||||
npms_default_num_days = fields.Selection([
|
||||
('month', '1 Month'),
|
||||
('21', '3 Weeks'),
|
||||
('14', '2 Weeks'),
|
||||
('7', '1 Week')
|
||||
], string='Default number of days', default='month')
|
||||
|
||||
npms_allowed_events_tags = fields.Many2many(
|
||||
'calendar.event.type',
|
||||
string="Allow Calander Event Tags")
|
||||
npms_denied_events_tags = fields.Many2many(
|
||||
'calendar.event.type',
|
||||
string="Deny Calander Event Tags")
|
||||
166
hotel_calendar/models/res_config.py
Normal file
166
hotel_calendar/models/res_config.py
Normal file
@@ -0,0 +1,166 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
from odoo.addons.hotel import date_utils
|
||||
|
||||
|
||||
class HotelConfiguration(models.TransientModel):
|
||||
_inherit = 'res.config.settings'
|
||||
|
||||
color_pre_reservation = fields.Char('Pre-reservation')
|
||||
color_reservation = fields.Char('Confirmed Reservation')
|
||||
color_reservation_pay = fields.Char('Paid Reservation')
|
||||
color_stay = fields.Char('Checkin')
|
||||
color_stay_pay = fields.Char('Paid Checkin')
|
||||
color_checkout = fields.Char('Checkout')
|
||||
color_dontsell = fields.Char('Dont Sell')
|
||||
color_staff = fields.Char('Staff')
|
||||
color_to_assign = fields.Char('Ota Reservation to Assign')
|
||||
color_payment_pending = fields.Char('Letter Payment Pending')
|
||||
color_letter_pre_reservation = fields.Char('Letter Pre-reservation')
|
||||
color_letter_reservation = fields.Char('Letter Confirmed Reservation')
|
||||
color_letter_reservation_pay = fields.Char('Letter Paid Reservation')
|
||||
color_letter_stay = fields.Char('Letter Checkin')
|
||||
color_letter_stay_pay = fields.Char('Letter Stay Pay')
|
||||
color_letter_checkout = fields.Char('Letter Checkout')
|
||||
color_letter_dontsell = fields.Char('Letter Dont Sell')
|
||||
color_letter_staff = fields.Char('Letter Staff')
|
||||
color_letter_to_assign = fields.Char('Letter Ota to Assign')
|
||||
color_letter_payment_pending = fields.Char('Letter Payment Pending')
|
||||
|
||||
@api.multi
|
||||
def set_values(self):
|
||||
super(HotelConfiguration, self).set_values()
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_pre_reservation', self.color_pre_reservation)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_reservation', self.color_reservation)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_reservation_pay', self.color_reservation_pay)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_stay', self.color_stay)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_stay_pay', self.color_stay_pay)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_checkout', self.color_checkout)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_dontsell', self.color_dontsell)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_staff', self.color_staff)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_to_assign', self.color_to_assign)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_payment_pending', self.color_payment_pending)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_letter_pre_reservation', self.color_letter_pre_reservation)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_letter_reservation', self.color_letter_reservation)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_letter_reservation_pay', self.color_letter_reservation_pay)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_letter_stay', self.color_letter_stay)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_letter_stay_pay', self.color_letter_stay_pay)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_letter_checkout', self.color_letter_checkout)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_letter_dontsell', self.color_letter_dontsell)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_letter_staff', self.color_letter_staff)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings', 'color_letter_to_assign', self.color_letter_to_assign)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'color_letter_payment_pending', self.color_letter_payment_pending)
|
||||
self.env['ir.default'].sudo().set(
|
||||
'res.config.settings',
|
||||
'default_arrival_hour', self.default_arrival_hour)
|
||||
|
||||
@api.model
|
||||
def get_values(self):
|
||||
res = super(HotelConfiguration, self).get_values()
|
||||
|
||||
# ONLY FOR v11. DO NOT FORWARD-PORT
|
||||
color_pre_reservation = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_pre_reservation', self.color_pre_reservation)
|
||||
color_reservation = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_reservation', self.color_reservation)
|
||||
color_reservation_pay = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_reservation_pay', self.color_reservation_pay)
|
||||
color_stay = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_stay', self.color_stay)
|
||||
color_stay_pay = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_stay_pay', self.color_stay_pay)
|
||||
color_checkout = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_checkout', self.color_checkout)
|
||||
color_dontsell = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_dontsell', self.color_dontsell)
|
||||
color_staff = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_staff', self.color_staff)
|
||||
color_to_assign = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_to_assign', self.color_to_assign)
|
||||
color_payment_pending = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_payment_pending', self.color_payment_pending)
|
||||
color_letter_pre_reservation = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_letter_pre_reservation', self.color_letter_pre_reservation)
|
||||
color_letter_reservation = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_letter_reservation', self.color_letter_reservation)
|
||||
color_letter_reservation_pay = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_letter_reservation_pay', self.color_letter_reservation_pay)
|
||||
color_letter_stay = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_letter_stay', self.color_letter_stay)
|
||||
color_letter_stay_pay = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_letter_stay_pay',
|
||||
self.color_letter_stay_pay)
|
||||
color_letter_checkout = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_letter_checkout',
|
||||
self.color_letter_checkout)
|
||||
color_letter_dontsell = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_letter_dontsell',
|
||||
self.color_letter_dontsell)
|
||||
color_letter_staff = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_letter_staff',
|
||||
self.color_letter_staff)
|
||||
color_letter_to_assign = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings', 'color_letter_to_assign',
|
||||
self.color_letter_to_assign)
|
||||
color_letter_payment_pending = self.env['ir.default'].sudo().get(
|
||||
'res.config.settings',
|
||||
'color_letter_payment_pending', self.color_letter_payment_pending)
|
||||
res.update(
|
||||
color_pre_reservation=color_pre_reservation,
|
||||
color_reservation=color_reservation,
|
||||
color_reservation_pay=color_reservation_pay,
|
||||
color_stay=color_stay,
|
||||
color_stay_pay=color_stay_pay,
|
||||
color_checkout=color_checkout,
|
||||
color_dontsell=color_dontsell,
|
||||
color_staff=color_staff,
|
||||
color_to_assign=color_to_assign,
|
||||
color_payment_pending=color_payment_pending,
|
||||
color_letter_pre_reservation=color_letter_pre_reservation,
|
||||
color_letter_reservation=color_letter_reservation,
|
||||
color_letter_reservation_pay=color_letter_reservation_pay,
|
||||
color_letter_stay=color_letter_stay,
|
||||
color_letter_stay_pay=color_letter_stay_pay,
|
||||
color_letter_checkout=color_letter_checkout,
|
||||
color_letter_dontsell=color_letter_dontsell,
|
||||
color_letter_staff=color_letter_staff,
|
||||
color_letter_to_assign=color_letter_to_assign,
|
||||
color_letter_payment_pending=color_letter_payment_pending,
|
||||
)
|
||||
return res
|
||||
17
hotel_calendar/models/virtual_room_pricelist_cached.py
Normal file
17
hotel_calendar/models/virtual_room_pricelist_cached.py
Normal file
@@ -0,0 +1,17 @@
|
||||
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
from odoo import models, fields, api
|
||||
from odoo.exceptions import ValidationError
|
||||
|
||||
|
||||
class VirtualRoomPricelistCached(models.Model):
|
||||
'''
|
||||
Cached Pricelist. Used only for Calendar Values
|
||||
'''
|
||||
|
||||
_name = 'virtual.room.pricelist.cached'
|
||||
|
||||
virtual_room_id = fields.Many2one('hotel.virtual.room', 'Virtual Room',
|
||||
required=True, track_visibility='always')
|
||||
price = fields.Float('Price', default=0.0)
|
||||
date = fields.Date('Date', required=True, track_visibility='always')
|
||||
1
hotel_calendar/readme/CONTRIBUTORS.rst
Normal file
1
hotel_calendar/readme/CONTRIBUTORS.rst
Normal file
@@ -0,0 +1 @@
|
||||
* Alexandre Díaz <dev@redneboa.es>
|
||||
8
hotel_calendar/readme/DESCRIPTION.rst
Normal file
8
hotel_calendar/readme/DESCRIPTION.rst
Normal file
@@ -0,0 +1,8 @@
|
||||
This module adds new view type "pms"
|
||||
|
||||
Features:
|
||||
|
||||
* Responsive & Interactive PMS
|
||||
* Revenue Management
|
||||
* Long-Polling Communication
|
||||
|
||||
2
hotel_calendar/readme/ROADMAP.rst
Normal file
2
hotel_calendar/readme/ROADMAP.rst
Normal file
@@ -0,0 +1,2 @@
|
||||
* Improve paginator speed
|
||||
* Improve theme
|
||||
5
hotel_calendar/readme/USAGE.rst
Normal file
5
hotel_calendar/readme/USAGE.rst
Normal file
@@ -0,0 +1,5 @@
|
||||
The following keyboard shortcuts are implemented:
|
||||
|
||||
* Toggle Advance Search - ALT Key + X Key
|
||||
* SWAP MODE - CTRL Key + LEFT MOUSE CLICK
|
||||
* ``ESC`` to cancel active action (ex. Swap)
|
||||
5
hotel_calendar/security/ir.model.access.csv
Normal file
5
hotel_calendar/security/ir.model.access.csv
Normal file
@@ -0,0 +1,5 @@
|
||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||
access_virtual_price_cache_user,hotel_calendar.model_virtual_room_pricelist_cached_user,hotel_calendar.model_virtual_room_pricelist_cached,hotel.group_hotel_user,1,1,1,1
|
||||
access_virtual_price_cache_call,hotel_calendar.model_virtual_room_pricelist_cached_call,hotel_calendar.model_virtual_room_pricelist_cached,hotel.group_hotel_call,1,1,1,1
|
||||
access_hotel_product_pricelist_item_call,hotel_calendar.pricelist_item_call,hotel_calendar.model_product_pricelist_item,hotel.group_hotel_call,1,1,1,1
|
||||
access_hotel_product_pricelist_item_user,hotel_calendar.pricelist_item_use,hotel_calendar.model_product_pricelist_item,hotel.group_hotel_user,1,1,1,1
|
||||
|
BIN
hotel_calendar/static/description/eiqui_logo.png
Normal file
BIN
hotel_calendar/static/description/eiqui_logo.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
BIN
hotel_calendar/static/description/icon_calendar.png
Normal file
BIN
hotel_calendar/static/description/icon_calendar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 4.1 KiB |
BIN
hotel_calendar/static/description/icon_calendar_configurator.png
Normal file
BIN
hotel_calendar/static/description/icon_calendar_configurator.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 5.1 KiB |
22
hotel_calendar/static/description/index.html
Normal file
22
hotel_calendar/static/description/index.html
Normal file
@@ -0,0 +1,22 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div>
|
||||
<h1>HOTEL CALENDAR</h1>
|
||||
<h2 class="text-muted">Hotel Calendar</h2>
|
||||
</div>
|
||||
<hr/>
|
||||
<p class="lead">Hotel Calendar</p>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 mb32">
|
||||
<a target="_blank" href="http://www.eiqui.com">
|
||||
<img src="eiqui_logo.png" class="img-responsive center-block" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
96
hotel_calendar/static/src/css/view.css
Normal file
96
hotel_calendar/static/src/css/view.css
Normal file
@@ -0,0 +1,96 @@
|
||||
/*
|
||||
* Hotel Calendar JS v0.0.1a - 2017
|
||||
* GNU Public License
|
||||
* Aloxa Solucions S.L. <info@aloxa.eu>
|
||||
* Alexandre Díaz <alex@aloxa.eu>
|
||||
*/
|
||||
|
||||
|
||||
/* .openerp .oe-view-manager {
|
||||
overflow: initial !important;
|
||||
}
|
||||
*/
|
||||
.nopadding {
|
||||
padding: 0 !important;
|
||||
margin: 0 !important;
|
||||
}
|
||||
|
||||
#pms-menu {
|
||||
padding: 0 0.2em !important;
|
||||
}
|
||||
#pms-menu button {
|
||||
min-height: 45px;
|
||||
margin: 0.2em 0;
|
||||
}
|
||||
|
||||
#pms-search {
|
||||
padding: 0.5em !important;
|
||||
background-color: white;
|
||||
box-shadow: 10px 1px 12px #333;
|
||||
}
|
||||
#pms-search fieldset {
|
||||
display: inline-block;
|
||||
}
|
||||
#pms-search fieldset legend {
|
||||
font-size: initial !important;
|
||||
margin: initial !important;
|
||||
}
|
||||
#pms-search .list {
|
||||
overflow-y: auto;
|
||||
text-align: left;
|
||||
}
|
||||
#pms-search label {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
#pms-search-table > tbody > tr > td {
|
||||
background-color: white;
|
||||
padding: 0.1em;
|
||||
border: 1px solid #efefef;
|
||||
border-width: 0 2px;
|
||||
vertical-align: middle;
|
||||
text-align: center;
|
||||
}
|
||||
#pms-search-table > tbody > tr > td:first-child {
|
||||
border-width: 0 2px 0 0;
|
||||
}
|
||||
#pms-search-table > tbody > tr > td:last-child {
|
||||
border-width: 0 0 0 2px;
|
||||
}
|
||||
|
||||
#pms-search-cal-pag .btn {
|
||||
background-color: transparent;
|
||||
padding: 0.1em;
|
||||
}
|
||||
|
||||
.input-group {
|
||||
padding: 0.1em;
|
||||
}
|
||||
|
||||
/** SELECT 2 **/
|
||||
#pms-search .select2-search-choice {
|
||||
padding-top: 1px !important;
|
||||
padding-bottom: 1px !important;
|
||||
font-size: 10px !important;
|
||||
}
|
||||
#pms-search .select2-search-choice-close {
|
||||
top: 1px !important;
|
||||
}
|
||||
|
||||
/** BOOTSTRAP **/
|
||||
.badge-danger {
|
||||
background-color: #d34f2a !important;
|
||||
}
|
||||
|
||||
/** FONT AWESOME **/
|
||||
.cloud-text {
|
||||
margin-top: .12em;
|
||||
font-size: 26px;
|
||||
font-family: sans-serif;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/** ODOO **/
|
||||
.o_chat_window {
|
||||
z-index: 8 !important;
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.listview_button_open_reservation_wizard', function(require) {
|
||||
'use strict';
|
||||
|
||||
var ListView = require('web.ListView'),
|
||||
Core = require('web.core'),
|
||||
|
||||
_t = Core._t;
|
||||
|
||||
|
||||
ListView.include({
|
||||
render_buttons: function () {
|
||||
var self = this;
|
||||
this._super.apply(this, arguments); // Sets this.$buttons
|
||||
|
||||
if (this.dataset.model == 'hotel.reservation') {
|
||||
this.$buttons.append("<button class='oe_button oe_open_reservation_wizard oe_highlight' type='button'>"+_t('Open Wizard')+"</button>");
|
||||
this.$buttons.find('.oe_open_reservation_wizard').on('click', function(){
|
||||
self.do_action('hotel_calendar.open_wizard_reservations');
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return ListView;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,304 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSCalendarController', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractController = require('web.AbstractController'),
|
||||
Core = require('web.core'),
|
||||
Bus = require('bus.bus').bus,
|
||||
HotelConstants = require('hotel_calendar.Constants'),
|
||||
|
||||
_t = Core._t,
|
||||
QWeb = Core.qweb;
|
||||
|
||||
var PMSCalendarController = AbstractController.extend({
|
||||
custom_events: _.extend({}, AbstractController.prototype.custom_events, {
|
||||
onLoadCalendar: '_onLoadCalendar',
|
||||
onLoadCalendarSettings: '_onLoadCalendarSettings',
|
||||
onLoadViewFilters: '_onLoadViewFilters',
|
||||
onUpdateButtonsCounter: '_onUpdateButtonsCounter',
|
||||
onReloadCalendar: '_onReloadCalendar',
|
||||
}),
|
||||
|
||||
init: function (parent, model, renderer, params) {
|
||||
this._super.apply(this, arguments);
|
||||
this.displayName = params.displayName;
|
||||
this.formViewId = params.formViewId;
|
||||
this.context = params.context;
|
||||
|
||||
Bus.on("notification", this, this._onBusNotification);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
_updateRecord: function (record) {
|
||||
return this.model.updateRecord(record).then(this.reload.bind(this));
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
_onLoadCalendarSettings: function (ev) {
|
||||
var self = this;
|
||||
return this.model.get_hcalendar_settings().then(function(options){
|
||||
self.renderer.load_hcalendar_options(options);
|
||||
});
|
||||
},
|
||||
|
||||
_onLoadCalendar: function (ev) {
|
||||
var self = this;
|
||||
|
||||
/** DO MAGIC **/
|
||||
var hcal_dates = this.renderer.get_view_filter_dates();
|
||||
var oparams = [
|
||||
hcal_dates[0].format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
hcal_dates[1].format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT)
|
||||
];
|
||||
this.model.get_calendar_data(oparams).then(function(results){
|
||||
|
||||
self.renderer._days_tooltips = results['events'];
|
||||
self.renderer._reserv_tooltips = results['tooltips'];
|
||||
var rooms = [];
|
||||
for (var r of results['rooms']) {
|
||||
var nroom = new HRoom(
|
||||
r[0], // Id
|
||||
r[1], // Name
|
||||
r[2], // Capacity
|
||||
r[4], // Category
|
||||
r[5], // Shared Room
|
||||
r[6] // Price
|
||||
);
|
||||
nroom.addUserData({
|
||||
'categ_id': r[3],
|
||||
'price_from': r[6][0] === 'fixed'?`${r[6][1]}${HotelConstants.CURRENCY_SYMBOL} (${_t('Fixed Price')})`:r[6][3],
|
||||
'inside_rooms': r[7],
|
||||
'inside_rooms_ids': r[8],
|
||||
'floor_id': r[9],
|
||||
'amenities': r[10]
|
||||
});
|
||||
rooms.push(nroom);
|
||||
}
|
||||
|
||||
self.renderer.create_calendar('#hcal_widget', rooms, results['pricelist'], results['restrictions']);
|
||||
|
||||
// TODO: Not read this... do the change!!
|
||||
var reservs = [];
|
||||
for (var r of results['reservations']) {
|
||||
var room = self._hcalendar.getRoom(r[0], r[15], r[1]);
|
||||
// need create a overbooking row?
|
||||
if (!room && r[15]) {
|
||||
room = self.renderer._hcalendar.createOBRoom(self._hcalendar.getRoom(r[0]), r[1]);
|
||||
self.renderer._hcalendar.createOBRoomRow(room);
|
||||
}
|
||||
if (!room) {
|
||||
console.warn(`Can't found a room for the reservation '${r[0]}'!`);
|
||||
continue;
|
||||
}
|
||||
|
||||
var nreserv = new HReservation({
|
||||
'id': r[1],
|
||||
'room': room,
|
||||
'title': r[2],
|
||||
'adults': r[3],
|
||||
'childrens': r[4],
|
||||
'startDate': HotelCalendar.toMomentUTC(r[5], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'endDate': HotelCalendar.toMomentUTC(r[6], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'color': r[8],
|
||||
'colorText': r[9],
|
||||
'splitted': r[10],
|
||||
'readOnly': r[12],
|
||||
'fixDays': r[13],
|
||||
'fixRooms': r[14],
|
||||
'unusedZone': false,
|
||||
'linkedId': false,
|
||||
'overbooking': r[15],
|
||||
});
|
||||
nreserv.addUserData({'folio_id': r[7]});
|
||||
nreserv.addUserData({'parent_reservation': r[11]});
|
||||
reservs.push(nreserv);
|
||||
}
|
||||
self.renderer.load_reservations(reservs);
|
||||
});
|
||||
},
|
||||
|
||||
_onReloadCalendar: function (ev) {
|
||||
this.model.get_calendar_data(ev.data.oparams).then(function(results){
|
||||
this.renderer._merge_days_tooltips(results['events']);
|
||||
this.renderer._reserv_tooltips = _.extend(this.renderer._reserv_tooltips, results['tooltips']);
|
||||
var reservs = [];
|
||||
for (var r of results['reservations']) {
|
||||
var room = this.renderer._hcalendar.getRoom(r[0], r[15], r[1]);
|
||||
// need create a overbooking row?
|
||||
if (!room && r[15]) {
|
||||
room = this.renderer._hcalendar.createOBRoom(this.renderer._hcalendar.getRoom(r[0]), r[1]);
|
||||
this.renderer._hcalendar.createOBRoomRow(room);
|
||||
}
|
||||
if (!room) {
|
||||
console.warn(`Can't found a room for the reservation '${r[0]}'!`);
|
||||
continue;
|
||||
}
|
||||
var nreserv = new HReservation({
|
||||
'id': r[1],
|
||||
'room': room,
|
||||
'title': r[2],
|
||||
'adults': r[3],
|
||||
'childrens': r[4],
|
||||
'startDate': HotelCalendar.toMomentUTC(r[5], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'endDate': HotelCalendar.toMomentUTC(r[6], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'color': r[8],
|
||||
'colorText': r[9],
|
||||
'splitted': r[10],
|
||||
'readOnly': r[12] || false,
|
||||
'fixDays': r[13] || false,
|
||||
'fixRooms': r[14] || false,
|
||||
'unusedZone': false,
|
||||
'linkedId': false,
|
||||
'overbooking': r[15],
|
||||
});
|
||||
nreserv.addUserData({'folio_id': r[7]});
|
||||
nreserv.addUserData({'parent_reservation': r[11]});
|
||||
reservs.push(nreserv);
|
||||
}
|
||||
|
||||
this.renderer._hcalendar.addPricelist(results['pricelist']);
|
||||
this.renderer._hcalendar.addRestrictions(results['restrictions']);
|
||||
if (ev.data.clearReservations) {
|
||||
this.renderer._hcalendar.setReservations(reservs);
|
||||
} else {
|
||||
this.renderer._hcalendar.addReservations(reservs);
|
||||
}
|
||||
|
||||
this.renderer._assign_extra_info();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_onUpdateButtonsCounter: function (ev) {
|
||||
var self = this;
|
||||
var domain_checkouts = [['is_checkout', '=', true]];
|
||||
var domain_checkins = [['is_checkin', '=', true]];
|
||||
var domain_overbookings = [['overbooking', '=', true], ['state', 'not in', ['cancelled']]];
|
||||
$.when(
|
||||
this.model.search_count(domain_checkouts),
|
||||
this.model.search_count(domain_checkins),
|
||||
this.model.search_count(domain_overbookings),
|
||||
).then(function(a1, a2, a3){
|
||||
self.renderer.update_buttons_counter(a1, a2, a3);
|
||||
});
|
||||
},
|
||||
|
||||
_onLoadViewFilters: function (ev) {
|
||||
var self = this;
|
||||
$.when(
|
||||
this.model.get_room_types(),
|
||||
this.model.get_floors(),
|
||||
this.model.get_amenities(),
|
||||
this.model.get_vrooms()
|
||||
).then(function(a1, a2, a3, a4){
|
||||
self.renderer.loadViewFilters(a1, a2, a3, a4);
|
||||
});
|
||||
},
|
||||
|
||||
_onBusNotification: function(notifications) {
|
||||
if (!this.renderer._hcalendar) {
|
||||
return;
|
||||
}
|
||||
var need_reload_pricelists = false;
|
||||
var need_update_counters = false;
|
||||
var nreservs = []
|
||||
for (var notif of notifications) {
|
||||
if (notif[0][1] === 'hotel.reservation') {
|
||||
switch (notif[1]['type']) {
|
||||
case 'reservation':
|
||||
var reserv = notif[1]['reservation'];
|
||||
// Only show notifications of other users
|
||||
// if (notif[1]['subtype'] !== 'noshow' && this._view_options['show_notifications'] && notif[1]['userid'] != this.dataset.context.uid) {
|
||||
// var qdict = _.clone(reserv);
|
||||
// qdict = _.extend(qdict, {
|
||||
// 'checkin': HotelCalendar.toMomentUTC(qdict['checkin'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT).clone().local().format(HotelConstants.L10N_DATETIME_MOMENT_FORMAT), // UTC -> Local
|
||||
// 'checkout': HotelCalendar.toMomentUTC(qdict['checkout'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT).clone().local().format(HotelConstants.L10N_DATETIME_MOMENT_FORMAT), // UTC -> Local
|
||||
// 'username': notif[1]['username'],
|
||||
// 'userid': notif[1]['userid']
|
||||
// });
|
||||
// var msg = QWeb.render('HotelCalendar.Notification', qdict);
|
||||
// if (notif[1]['subtype'] === "notify") {
|
||||
// this.do_notify(notif[1]['title'], msg, true);
|
||||
// } else if (notif[1]['subtype'] === "warn") {
|
||||
// this.do_warn(notif[1]['title'], msg, true);
|
||||
// }
|
||||
// }
|
||||
|
||||
// Create/Update/Delete reservation
|
||||
if (notif[1]['action'] === 'unlink' || reserv['state'] === 'cancelled') {
|
||||
this.renderer._hcalendar.removeReservation(reserv['reserv_id'], true);
|
||||
this.renderer._reserv_tooltips = _.pick(this.renderer._reserv_tooltips, function(value, key, obj){ return key != reserv['reserv_id']; });
|
||||
nreservs = _.reject(nreservs, function(item){ return item.id == reserv['reserv_id']; });
|
||||
} else {
|
||||
nreservs = _.reject(nreservs, {'id': reserv['reserv_id']}); // Only like last changes
|
||||
var room = this.renderer._hcalendar.getRoom(reserv['product_id'], reserv['overbooking'], reserv['reserv_id']);
|
||||
// need create a overbooking row?
|
||||
if (!room && reserv['overbooking']) {
|
||||
room = this.renderer._hcalendar.createOBRoom(this.renderer._hcalendar.getRoom(reserv['product_id']), reserv['reserv_id']);
|
||||
this.renderer._hcalendar.createOBRoomRow(room);
|
||||
}
|
||||
if (!room) {
|
||||
console.warn(`Can't found a room for the reservation '${reserv['reserv_id']}'!`);
|
||||
continue;
|
||||
}
|
||||
if (room) {
|
||||
var nreserv = new HReservation({
|
||||
'id': reserv['reserv_id'],
|
||||
'room': room,
|
||||
'title': reserv['partner_name'],
|
||||
'adults': reserv['adults'],
|
||||
'childrens': reserv['children'],
|
||||
'startDate': HotelCalendar.toMomentUTC(reserv['checkin'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'endDate': HotelCalendar.toMomentUTC(reserv['checkout'], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'color': reserv['reserve_color'],
|
||||
'colorText': reserv['reserve_color_text'],
|
||||
'splitted': reserv['splitted'],
|
||||
'readOnly': reserv['read_only'],
|
||||
'fixDays': reserv['fix_days'],
|
||||
'fixRooms': reserv['fix_rooms'],
|
||||
'unusedZone': false,
|
||||
'linkedId': false,
|
||||
'overbooking': reserv['overbooking'],
|
||||
});
|
||||
nreserv.addUserData({'folio_id': reserv['folio_id']});
|
||||
nreserv.addUserData({'parent_reservation': reserv['parent_reservation']});
|
||||
this.renderer._reserv_tooltips[reserv['reserv_id']] = notif[1]['tooltip'];
|
||||
nreservs.push(nreserv);
|
||||
}
|
||||
}
|
||||
need_update_counters = true;
|
||||
break;
|
||||
case 'pricelist':
|
||||
this.renderer._hcalendar.addPricelist(notif[1]['price']);
|
||||
break;
|
||||
case 'restriction':
|
||||
this.renderer._hcalendar.addRestrictions(notif[1]['restriction']);
|
||||
break;
|
||||
default:
|
||||
// Do Nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nreservs.length > 0) {
|
||||
this.renderer._hcalendar.addReservations(nreservs);
|
||||
}
|
||||
if (need_update_counters) {
|
||||
this._onUpdateButtonsCounter();
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
return PMSCalendarController;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSCalendarModel', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractModel = require('web.AbstractModel'),
|
||||
Context = require('web.Context'),
|
||||
Core = require('web.core'),
|
||||
FieldUtils = require('web.field_utils'),
|
||||
Session = require('web.session');
|
||||
|
||||
|
||||
return AbstractModel.extend({
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.end_date = null;
|
||||
},
|
||||
|
||||
load: function (params) {
|
||||
this.modelName = params.modelName;
|
||||
this.modelManagementName = 'hotel.calendar.management'
|
||||
},
|
||||
|
||||
save_pricelist: function(params) {
|
||||
return this._rpc({
|
||||
model: this.modelManagementName,
|
||||
method: 'save_changes',
|
||||
args: params,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
swap_reservations: function(fromIds, toIds) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'swap_reservations',
|
||||
args: [fromIds, toIds],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_calendar_data: function(oparams) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_all_data',
|
||||
args: oparams,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_hcalendar_settings: function() {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_settings',
|
||||
args: [false],
|
||||
});
|
||||
},
|
||||
|
||||
get_room_types: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type',
|
||||
method: 'search_read',
|
||||
args: [false, ['cat_id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_floors: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.floor',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_amenities: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.amenities',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_vrooms: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.virtual.room',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
search_count: function(domain) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'search_count',
|
||||
args: [domain],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
update_records: function(ids, vals) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'write',
|
||||
args: [ids, write_values],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
folio_search_count: function(domain) {
|
||||
return this._rpc({
|
||||
model: 'hotel.folio',
|
||||
method: 'search_count',
|
||||
args: [domain],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,840 @@
|
||||
/* global $, odoo, _, HotelCalendar, moment */
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSCalendarRenderer', function (require) {
|
||||
"use strict";
|
||||
|
||||
var Core = require('web.core'),
|
||||
ViewDialogs = require('web.view_dialogs'),
|
||||
Dialog = require('web.Dialog'),
|
||||
Session = require('web.session'),
|
||||
AbstractRenderer = require('web.AbstractRenderer'),
|
||||
HotelConstants = require('hotel_calendar.Constants'),
|
||||
//Formats = require('web.formats'),
|
||||
|
||||
_t = Core._t,
|
||||
_lt = Core._lt,
|
||||
QWeb = Core.qweb;
|
||||
|
||||
var HotelCalendarView = AbstractRenderer.extend({
|
||||
/** VIEW OPTIONS **/
|
||||
template: "hotel_calendar.HotelCalendarView",
|
||||
display_name: _lt('Hotel Calendar'),
|
||||
icon: 'fa fa-map-marker',
|
||||
searchable: false,
|
||||
searchview_hidden: true,
|
||||
|
||||
// Custom Options
|
||||
_view_options: {},
|
||||
_hcalendar: null,
|
||||
_reserv_tooltips: {},
|
||||
_days_tooltips: [],
|
||||
_last_dates: [false, false],
|
||||
|
||||
|
||||
/** VIEW METHODS **/
|
||||
init: function(parent, state, params) {
|
||||
this._super.apply(this, arguments);
|
||||
this.model = params.model;
|
||||
},
|
||||
|
||||
start: function () {
|
||||
return this._super().then(function() {
|
||||
this.init_calendar_view();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
on_attach_callback: function() {
|
||||
this._super();
|
||||
|
||||
if (this._hcalendar && !this._is_visible) {
|
||||
// FIXME: Workaround for restore "lost" reservations (Drawn when the view is hidden)
|
||||
setTimeout(function(){
|
||||
for (var reserv of this._hcalendar._reservations) {
|
||||
var style = window.getComputedStyle(reserv._html, null);
|
||||
if (parseInt(style.width, 10) < 15 || parseInt(style.height, 10) < 15 || parseInt(style.top, 10) === 0) {
|
||||
this._hcalendar._updateReservation(reserv);
|
||||
}
|
||||
}
|
||||
}.bind(this), 300);
|
||||
}
|
||||
},
|
||||
|
||||
/** CUSTOM METHODS **/
|
||||
_generate_reservation_tooltip_dict: function(tp) {
|
||||
return {
|
||||
'name': tp[0],
|
||||
'phone': tp[1],
|
||||
'arrival_hour': HotelCalendar.toMomentUTC(tp[2], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT).local().format('HH:mm'),
|
||||
'num_split': tp[3],
|
||||
'amount_total': Number(tp[4]).toLocaleString()
|
||||
};
|
||||
},
|
||||
|
||||
load_reservations: function(reservs) {
|
||||
this._hcalendar.setReservations(reservs);
|
||||
this._assign_extra_info();
|
||||
},
|
||||
|
||||
get_view_filter_dates: function () {
|
||||
var $dateTimePickerBegin = this.$el.find('#pms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#pms-search #date_end');
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone().utc();
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc();
|
||||
|
||||
return [date_begin, date_end];
|
||||
},
|
||||
|
||||
load_hcalendar_options: function(options) {
|
||||
// View Options
|
||||
this._view_options = options;
|
||||
var date_begin = moment().startOf('day');
|
||||
if (['xs', 'md'].indexOf(this._find_bootstrap_environment()) >= 0) {
|
||||
this._view_options['days'] = 7;
|
||||
} else {
|
||||
this._view_options['days'] = (this._view_options['days'] !== 'month')?parseInt(this._view_options['days']):date_begin.daysInMonth();
|
||||
}
|
||||
var date_end = date_begin.clone().add(this._view_options['days'], 'd').endOf('day');
|
||||
var $dateTimePickerBegin = this.$el.find('#pms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#pms-search #date_end');
|
||||
//$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
//$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
this._last_dates = this.get_view_filter_dates();
|
||||
},
|
||||
|
||||
destroy_calendar: function() {
|
||||
if (this._hcalendar) {
|
||||
this._hcalendar.$base.empty();
|
||||
delete this._hcalendar;
|
||||
}
|
||||
},
|
||||
|
||||
create_calendar: function(containerSelector, rooms, pricelist, restrictions) {
|
||||
this.destroy_calendar();
|
||||
|
||||
var options = {
|
||||
startDate: HotelCalendar.toMomentUTC(this._last_dates[0], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
days: this._view_options['days'] + 1,
|
||||
rooms: rooms,
|
||||
endOfWeek: parseInt(this._view_options['eday_week']) || 6,
|
||||
divideRoomsByCapacity: this._view_options['divide_rooms_by_capacity'] || false,
|
||||
allowInvalidActions: this._view_options['allow_invalid_actions'] || false,
|
||||
assistedMovement: this._view_options['assisted_movement'] || false,
|
||||
showPricelist: this._view_options['show_pricelist'] || false,
|
||||
showAvailability: this._view_options['show_availability'] || false,
|
||||
showNumRooms: this._view_options['show_num_rooms'] || 0,
|
||||
endOfWeekOffset: this._view_options['eday_week_offset'] || 0
|
||||
};
|
||||
|
||||
this._hcalendar = new HotelCalendar(containerSelector, options, pricelist, restrictions, this.$el[0]);
|
||||
this._assign_hcalendar_events();
|
||||
},
|
||||
|
||||
_assign_hcalendar_events: function() {
|
||||
var self = this;
|
||||
this._hcalendar.addEventListener('hcalOnSavePricelist', function(ev){
|
||||
var pricelist = self._hcalendar.getPricelist();
|
||||
var oparams = [false, self._hcalendar._pricelist_id, false, pricelist, {}, {}];
|
||||
self._rpc({
|
||||
model: 'hotel.calendar.management',
|
||||
method: 'save_changes',
|
||||
args: oparams,
|
||||
context: Session.user_context,
|
||||
}).then(function(results){
|
||||
$(self._hcalendar.btnSaveChanges).removeClass('need-save');
|
||||
$('.hcal-input-changed').removeClass('hcal-input-changed');
|
||||
});
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnMouseEnterReservation', function(ev){
|
||||
if (ev.detail.reservationObj) {
|
||||
var tp = self._reserv_tooltips[ev.detail.reservationObj.id];
|
||||
var qdict = self._generate_reservation_tooltip_dict(tp);
|
||||
$(ev.detail.reservationDiv).tooltip('destroy').tooltip({
|
||||
animation: false,
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
title: QWeb.render('HotelCalendar.TooltipReservation', qdict)
|
||||
}).tooltip('show');
|
||||
}
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnClickReservation', function(ev){
|
||||
//var res_id = ev.detail.reservationObj.getUserData('folio_id');
|
||||
$(ev.detail.reservationDiv).tooltip('hide');
|
||||
self.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
res_model: 'hotel.reservation',
|
||||
res_id: ev.detail.reservationObj.id,
|
||||
views: [[false, 'form']]
|
||||
});
|
||||
// self._model.call('get_formview_id', [res_id, Session.user_context]).then(function(view_id){
|
||||
// var pop = new ViewDialogs.FormViewDialog(self, {
|
||||
// res_model: 'hotel.folio',
|
||||
// res_id: res_id,
|
||||
// title: _t("Open: ") + ev.detail.reservationObj.title,
|
||||
// view_id: view_id
|
||||
// //readonly: false
|
||||
// }).open();
|
||||
// pop.on('write_completed', self, function(){
|
||||
// self.trigger('changed_value');
|
||||
// });
|
||||
// });
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnSwapReservations', function(ev){
|
||||
var qdict = {};
|
||||
var dialog = new Dialog(self, {
|
||||
title: _t("Confirm Reservation Swap"),
|
||||
buttons: [
|
||||
{
|
||||
text: _t("Yes, swap it"),
|
||||
classes: 'btn-primary',
|
||||
close: true,
|
||||
click: function () {
|
||||
if (self._hcalendar.swapReservations(ev.detail.inReservs, ev.detail.outReservs)) {
|
||||
var fromIds = _.pluck(ev.detail.inReservs, 'id');
|
||||
var toIds = _.pluck(ev.detail.outReservs, 'id');
|
||||
var refFromReservDiv = ev.detail.inReservs[0]._html;
|
||||
var refToReservDiv = ev.detail.outReservs[0]._html;
|
||||
|
||||
// Animate Movement
|
||||
for (var nreserv of ev.detail.inReservs) {
|
||||
$(nreserv._html).animate({'top': refToReservDiv.style.top});
|
||||
}
|
||||
for (var nreserv of ev.detail.outReservs) {
|
||||
$(nreserv._html).animate({'top': refFromReservDiv.style.top});
|
||||
}
|
||||
self.model.swapReservations(fromIds, toIds).then(function(results){
|
||||
var allReservs = ev.detail.inReservs.concat(ev.detail.outReservs);
|
||||
for (nreserv of allReservs) {
|
||||
$(nreserv._html).stop(true);
|
||||
}
|
||||
}).fail(function(err, errev){
|
||||
for (var nreserv of ev.detail.inReservs) {
|
||||
$(nreserv._html).animate({'top': refFromReservDiv.style.top}, 'fast');
|
||||
}
|
||||
for (var nreserv of ev.detail.outReservs) {
|
||||
$(nreserv._html).animate({'top': refToReservDiv.style.top}, 'fast');
|
||||
}
|
||||
|
||||
self._hcalendar.swapReservations(ev.detail.outReservs, ev.detail.inReservs);
|
||||
});
|
||||
} else {
|
||||
var qdict = {};
|
||||
var dialog = new Dialog(self, {
|
||||
title: _t("Invalid Reservation Swap"),
|
||||
buttons: [
|
||||
{
|
||||
text: _t("Oops, Ok!"),
|
||||
classes: 'btn-primary',
|
||||
close: true
|
||||
}
|
||||
],
|
||||
$content: QWeb.render('HotelCalendar.InvalidSwapOperation', qdict)
|
||||
}).open();
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
text: _t("No"),
|
||||
close: true
|
||||
}
|
||||
],
|
||||
$content: QWeb.render('HotelCalendar.ConfirmSwapOperation', qdict)
|
||||
}).open();
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnCancelSwapReservations', function(ev){
|
||||
$("#btn_swap span.ntext").html(_t("START SWAP"));
|
||||
$("#btn_swap").css({
|
||||
'backgroundColor': '',
|
||||
'fontWeight': 'normal'
|
||||
});
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnChangeReservation', function(ev){
|
||||
var newReservation = ev.detail.newReserv;
|
||||
var oldReservation = ev.detail.oldReserv;
|
||||
var oldPrice = ev.detail.oldPrice;
|
||||
var newPrice = ev.detail.newPrice;
|
||||
var folio_id = newReservation.getUserData('folio_id');
|
||||
|
||||
var linkedReservs = _.find(self._hcalendar._reservations, function(item){
|
||||
return item.id !== newReservation.id && !item.unusedZone && item.getUserData('folio_id') === folio_id;
|
||||
});
|
||||
|
||||
var hasChanged = false;
|
||||
|
||||
var qdict = {
|
||||
ncheckin: newReservation.startDate.clone().local().format(HotelConstants.L10N_DATETIME_MOMENT_FORMAT),
|
||||
ncheckout: newReservation.endDate.clone().local().format(HotelConstants.L10N_DATETIME_MOMENT_FORMAT),
|
||||
nroom: newReservation.room.number,
|
||||
nprice: newPrice,
|
||||
ocheckin: oldReservation.startDate.clone().local().format(HotelConstants.L10N_DATETIME_MOMENT_FORMAT),
|
||||
ocheckout: oldReservation.endDate.clone().local().format(HotelConstants.L10N_DATETIME_MOMENT_FORMAT),
|
||||
oroom: oldReservation.room.number,
|
||||
oprice: oldPrice,
|
||||
hasReservsLinked: (linkedReservs && linkedReservs.length !== 0)?true:false
|
||||
};
|
||||
var dialog = new Dialog(self, {
|
||||
title: _t("Confirm Reservation Changes"),
|
||||
buttons: [
|
||||
{
|
||||
text: _t("Yes, change it"),
|
||||
classes: 'btn-primary',
|
||||
close: true,
|
||||
disabled: !newReservation.id,
|
||||
click: function () {
|
||||
var roomId = newReservation.room.id;
|
||||
if (newReservation.room.overbooking) {
|
||||
roomId = +newReservation.room.id.substr(newReservation.room.id.indexOf('@')+1);
|
||||
}
|
||||
var write_values = {
|
||||
'checkin': newReservation.startDate.format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'checkout': newReservation.endDate.format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'product_id': roomId,
|
||||
'overbooking': newReservation.room.overbooking
|
||||
};
|
||||
self.model.update_records([newReservation.id], write_values).then(function(result){
|
||||
// Remove OB Room Row?
|
||||
if (oldReservation.room.overbooking) {
|
||||
self._hcalendar.removeOBRoomRow(oldReservation);
|
||||
}
|
||||
}).fail(function(err, errev){
|
||||
self._hcalendar.replaceReservation(newReservation, oldReservation);
|
||||
});
|
||||
// Workarround for dispatch room lines regeneration
|
||||
// new Model('hotel.reservation').call('on_change_checkin_checkout_product_id', [[newReservation.id], false]);
|
||||
hasChanged = true;
|
||||
}
|
||||
},
|
||||
{
|
||||
text: _t("No"),
|
||||
close: true,
|
||||
}
|
||||
],
|
||||
$content: QWeb.render('HotelCalendar.ConfirmReservationChanges', qdict)
|
||||
}).open();
|
||||
dialog.$modal.on('hide.bs.modal', function(e){
|
||||
if (!hasChanged) {
|
||||
self._hcalendar.replaceReservation(newReservation, oldReservation);
|
||||
}
|
||||
});
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnUpdateSelection', function(ev){
|
||||
for (var td of ev.detail.old_cells) {
|
||||
$(td).tooltip('destroy');
|
||||
}
|
||||
if (ev.detail.cells.length > 1) {
|
||||
var last_cell = ev.detail.cells[ev.detail.cells.length-1];
|
||||
var date_cell_start = HotelCalendar.toMoment(self._hcalendar.etable.querySelector(`#${ev.detail.cells[0].dataset.hcalParentCell}`).dataset.hcalDate);
|
||||
var date_cell_end = HotelCalendar.toMoment(self._hcalendar.etable.querySelector(`#${last_cell.dataset.hcalParentCell}`).dataset.hcalDate);
|
||||
var parentRow = document.querySelector(`#${ev.detail.cells[0].dataset.hcalParentRow}`);
|
||||
var room = self._hcalendar.getRoom(parentRow.dataset.hcalRoomObjId);
|
||||
if (room.overbooking) {
|
||||
return;
|
||||
}
|
||||
var nights = date_cell_end.diff(date_cell_start, 'days');
|
||||
var qdict = {
|
||||
'total_price': Number(ev.detail.totalPrice).toLocaleString(),
|
||||
'nights': nights
|
||||
};
|
||||
$(last_cell).tooltip({
|
||||
animation: false,
|
||||
html: true,
|
||||
placement: 'top',
|
||||
title: QWeb.render('HotelCalendar.TooltipSelection', qdict)
|
||||
}).tooltip('show');
|
||||
}
|
||||
});
|
||||
this._hcalendar.addEventListener('hcalOnChangeSelection', function(ev){
|
||||
var parentRow = document.querySelector(`#${ev.detail.cellStart.dataset.hcalParentRow}`);
|
||||
var parentCellStart = document.querySelector(`#${ev.detail.cellStart.dataset.hcalParentCell}`);
|
||||
var parentCellEnd = document.querySelector(`#${ev.detail.cellEnd.dataset.hcalParentCell}`);
|
||||
var startDate = HotelCalendar.toMoment(parentCellStart.dataset.hcalDate);
|
||||
var endDate = HotelCalendar.toMoment(parentCellEnd.dataset.hcalDate);
|
||||
var room = self._hcalendar.getRoom(parentRow.dataset.hcalRoomObjId);
|
||||
if (room.overbooking) {
|
||||
return;
|
||||
}
|
||||
var numBeds = (room.shared || self._hcalendar.getOptions('divideRoomsByCapacity'))?(ev.detail.cellEnd.dataset.hcalBedNum - ev.detail.cellStart.dataset.hcalBedNum)+1:room.capacity;
|
||||
if (numBeds <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Normalize Dates
|
||||
if (startDate.isAfter(endDate)) {
|
||||
var tt = endDate;
|
||||
endDate = startDate;
|
||||
startDate = tt;
|
||||
}
|
||||
|
||||
var def_arrival_hour = self._view_options['default_arrival_hour'].split(':');
|
||||
var def_departure_hour = self._view_options['default_departure_hour'].split(':');
|
||||
startDate.set({'hour': def_arrival_hour[0], 'minute': def_arrival_hour[1], 'second': 0});
|
||||
endDate.set({'hour': def_departure_hour[0], 'minute': def_departure_hour[1], 'second': 0});
|
||||
|
||||
var popCreate = new ViewDialogs.FormViewDialog(self, {
|
||||
res_model: 'hotel.reservation',
|
||||
context: {
|
||||
'default_checkin': startDate.utc().format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'default_checkout': endDate.utc().format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
'default_adults': numBeds,
|
||||
'default_children': 0,
|
||||
'default_product_id': room.id,
|
||||
},
|
||||
title: _t("Create: ") + _t("Reservation"),
|
||||
initial_view: "form",
|
||||
disable_multiple_selection: true,
|
||||
}).open();
|
||||
});
|
||||
|
||||
this._hcalendar.addEventListener('hcalOnDateChanged', function(ev){
|
||||
var $dateTimePickerBegin = this.$el.find('#pms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#pms-search #date_end');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").minDate(false);
|
||||
$dateTimePickerEnd.data("DateTimePicker").maxDate(false);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(ev.detail.date_begin.local().add(1, 'd'));
|
||||
$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(ev.detail.date_end.local());
|
||||
this.reload_hcalendar_reservations(false);
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
_assign_extra_info: function() {
|
||||
var self = this;
|
||||
$(this._hcalendar.etable).find('.hcal-cell-room-type-group-item.btn-hcal-3d').on("mouseenter", function(){
|
||||
var $this = $(this);
|
||||
var room = self._hcalendar.getRoom($this.parent().data("hcalRoomObjId"));
|
||||
if (room.overbooking) {
|
||||
$this.tooltip({
|
||||
animation: true,
|
||||
html: true,
|
||||
placement: 'right',
|
||||
title: QWeb.render('HotelCalendar.TooltipRoomOverbooking', {'name': room.number})
|
||||
}).tooltip('show');
|
||||
return;
|
||||
} else {
|
||||
var qdict = {
|
||||
'price_from': room.getUserData('price_from'),
|
||||
'inside_rooms': room.getUserData('inside_rooms'),
|
||||
'num_inside_rooms': room.getUserData('inside_rooms').length,
|
||||
'name': room.number
|
||||
};
|
||||
$this.tooltip({
|
||||
animation: true,
|
||||
html: true,
|
||||
placement: 'right',
|
||||
title: QWeb.render('HotelCalendar.TooltipRoom', qdict)
|
||||
}).tooltip('show');
|
||||
}
|
||||
});
|
||||
|
||||
$(this._hcalendar.etableHeader).find('.hcal-cell-header-day').each(function(index, elm){
|
||||
var $elm = $(elm);
|
||||
var cdate = HotelCalendar.toMoment($elm.data('hcalDate'), HotelConstants.L10N_DATE_MOMENT_FORMAT);
|
||||
var data = _.filter(self._days_tooltips, function(item) {
|
||||
var ndate = HotelCalendar.toMoment(item[2], HotelConstants.ODOO_DATE_MOMENT_FORMAT);
|
||||
return ndate.isSame(cdate, 'd');
|
||||
});
|
||||
if (data.length > 0) {
|
||||
$elm.addClass('hcal-event-day');
|
||||
$elm.prepend("<i class='fa fa-bell' style='margin-right: 0.1em'></i>");
|
||||
$elm.on("mouseenter", function(data){
|
||||
var $this = $(this);
|
||||
if (data.length > 0) {
|
||||
var qdict = {
|
||||
'date': $this.data('hcalDate'),
|
||||
'events': _.map(data, function(item){
|
||||
return {
|
||||
'name': item[1],
|
||||
'date': item[2],
|
||||
'location': item[3]
|
||||
};
|
||||
})
|
||||
};
|
||||
$this.attr('title', '');
|
||||
$this.tooltip({
|
||||
animation: true,
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
title: QWeb.render('HotelCalendar.TooltipEvent', qdict)
|
||||
}).tooltip('show');
|
||||
}
|
||||
}.bind(elm, data));
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
update_buttons_counter: function(ncheckouts, ncheckins, noverbookings) {
|
||||
var self = this;
|
||||
// Checkouts Button
|
||||
var $ninfo = self.$el.find('#pms-menu #btn_action_checkout div.ninfo');
|
||||
var $badge_checkout = $ninfo.find('.badge');
|
||||
if (ncheckouts > 0) {
|
||||
$badge_checkout.text(ncheckouts);
|
||||
$badge_checkout.parent().show();
|
||||
$ninfo.show();
|
||||
} else {
|
||||
$ninfo.hide();
|
||||
}
|
||||
|
||||
// Checkins Button
|
||||
$ninfo = self.$el.find('#pms-menu #btn_action_checkin div.ninfo');
|
||||
var $badge_checkin = $ninfo.find('.badge');
|
||||
if (ncheckins > 0) {
|
||||
$badge_checkin.text(ncheckins);
|
||||
$badge_checkin.parent().show();
|
||||
$ninfo.show();
|
||||
} else {
|
||||
$ninfo.hide();
|
||||
}
|
||||
|
||||
// OverBookings
|
||||
$ninfo = self.$el.find('#pms-menu #btn_swap div.ninfo');
|
||||
var $badge_swap = $ninfo.find('.badge');
|
||||
if (noverbookings > 0) {
|
||||
$badge_swap.text(noverbookings);
|
||||
$badge_swap.parent().show();
|
||||
$ninfo.show();
|
||||
} else {
|
||||
$ninfo.hide();
|
||||
}
|
||||
},
|
||||
|
||||
init_calendar_view: function(){
|
||||
var self = this;
|
||||
|
||||
/** VIEW CONTROLS INITIALIZATION **/
|
||||
// DATE TIME PICKERS
|
||||
var DTPickerOptions = {
|
||||
viewMode: 'months',
|
||||
icons : {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down'
|
||||
},
|
||||
//language : moment.locale(),
|
||||
locale : moment.locale(),
|
||||
format : HotelConstants.L10N_DATE_MOMENT_FORMAT,
|
||||
};
|
||||
var $dateTimePickerBegin = this.$el.find('#pms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#pms-search #date_end');
|
||||
$dateTimePickerBegin.datetimepicker(DTPickerOptions);
|
||||
$dateTimePickerEnd.datetimepicker($.extend({}, DTPickerOptions, { 'useCurrent': false }));
|
||||
$dateTimePickerBegin.on("dp.change", function (e) {
|
||||
$dateTimePickerEnd.data("DateTimePicker").minDate(e.date.clone().add(3,'d'));
|
||||
$dateTimePickerEnd.data("DateTimePicker").maxDate(e.date.clone().add(2,'M'));
|
||||
$dateTimePickerBegin.data("DateTimePicker").hide();
|
||||
self.on_change_filter_date(true);
|
||||
});
|
||||
$dateTimePickerEnd.on("dp.change", function (e) {
|
||||
$dateTimePickerEnd.data("DateTimePicker").hide();
|
||||
self.on_change_filter_date(false);
|
||||
});
|
||||
|
||||
var date_begin = moment().startOf('day');
|
||||
var days = date_begin.daysInMonth();
|
||||
var date_end = date_begin.clone().add(days, 'd').endOf('day');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
this._last_dates = this.get_view_filter_dates();
|
||||
|
||||
// Initial State
|
||||
var $pms_search = this.$el.find('#pms-search');
|
||||
$pms_search.css({
|
||||
'top': `-100%`,
|
||||
'opacity': 0.0,
|
||||
});
|
||||
// Show search (Alt+S)
|
||||
$(document).keydown(function(ev){
|
||||
if (ev.altKey){
|
||||
if (ev.key == 'x' || ev.key == 'X'){
|
||||
self.toggle_pms_search();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* TOUCH EVENTS */
|
||||
this.$el.on('touchstart', function(ev){
|
||||
var orgEvent = ev.originalEvent;
|
||||
this._mouseEventStartPos = [orgEvent.touches[0].screenX, orgEvent.touches[0].screenY];
|
||||
});
|
||||
this.$el.on('touchend', function(ev){
|
||||
var orgEvent = ev.originalEvent;
|
||||
if (orgEvent.changedTouches.length > 2) {
|
||||
var mousePos = [orgEvent.changedTouches[0].screenX, orgEvent.changedTouches[0].screenY];
|
||||
var mouseDiffX = mousePos[0] - this._mouseEventStartPos[0];
|
||||
var moveLength = 40;
|
||||
var date_begin = false;
|
||||
var days = orgEvent.changedTouches.length == 3 && 7 || 1;
|
||||
if (mouseDiffX < -moveLength) {
|
||||
date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone().add(days, 'd');
|
||||
}
|
||||
else if (mouseDiffX > moveLength) {
|
||||
date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone().subtract(days, 'd');
|
||||
}
|
||||
if (date_begin) {
|
||||
var date_end = date_begin.clone().add(self._view_options['days'], 'd').endOf('day');
|
||||
$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
/* BUTTONS */
|
||||
var $button = this.$el.find('#pms-menu #btn_action_bookings');
|
||||
$button.on('click', function(ev){ self._open_bookings_tree(); });
|
||||
var $btnInput = this.$el.find('#pms-menu #bookings_search');
|
||||
$btnInput.on('keypress', function(ev){
|
||||
if (ev.keyCode === 13) {
|
||||
self._open_bookings_tree();
|
||||
}
|
||||
});
|
||||
|
||||
this.$el.find("button[data-action]").on('click', function(ev){
|
||||
self.do_action(this.dataset.action);
|
||||
});
|
||||
|
||||
this.$el.find("#btn_swap").on('click', function(ev){
|
||||
var hcalSwapMode = self._hcalendar.getSwapMode();
|
||||
if (hcalSwapMode === HotelCalendar.MODE.NONE) {
|
||||
self._hcalendar.setSwapMode(HotelCalendar.MODE.SWAP_FROM);
|
||||
$("#btn_swap span.ntext").html(_t("CONTINUE"));
|
||||
$("#btn_swap").css({
|
||||
'backgroundColor': 'rgb(145, 255, 0)',
|
||||
'fontWeight': 'bold'
|
||||
});
|
||||
} else if (self._hcalendar.getReservationAction().inReservations.length > 0 && hcalSwapMode === HotelCalendar.MODE.SWAP_FROM) {
|
||||
self._hcalendar.setSwapMode(HotelCalendar.MODE.SWAP_TO);
|
||||
$("#btn_swap span.ntext").html(_t("END"));
|
||||
$("#btn_swap").css({
|
||||
'backgroundColor': 'orange',
|
||||
'fontWeight': 'bold'
|
||||
});
|
||||
} else {
|
||||
self._hcalendar.setSwapMode(HotelCalendar.MODE.NONE);
|
||||
$("#btn_swap span.ntext").html(_t("START SWAP"));
|
||||
$("#btn_swap").css({
|
||||
'backgroundColor': '',
|
||||
'fontWeight': ''
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
return $.when(
|
||||
this.trigger_up('onLoadCalendarSettings'),
|
||||
this.trigger_up('onUpdateButtonsCounter'),
|
||||
this.trigger_up('onLoadCalendar'),
|
||||
this.trigger_up('onLoadViewFilters'),
|
||||
);
|
||||
},
|
||||
|
||||
loadViewFilters: function(resultsHotelRoomType, resultsHotelFloor, resultsHotelRoomAmenities, resultsHotelVirtualRooms) {
|
||||
var $list = this.$el.find('#pms-search #type_list');
|
||||
$list.html('');
|
||||
resultsHotelRoomType.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.cat_id[0]}">${item.name}</option>`);
|
||||
});
|
||||
$list.select2({
|
||||
theme: "classic"
|
||||
});
|
||||
$list.on('change', function(ev){
|
||||
this._apply_filters();
|
||||
}.bind(this));
|
||||
|
||||
// Get Floors
|
||||
$list = this.$el.find('#pms-search #floor_list');
|
||||
$list.html('');
|
||||
resultsHotelFloor.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}">${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
this._apply_filters();
|
||||
}.bind(this));
|
||||
|
||||
// Get Amenities
|
||||
$list = this.$el.find('#pms-search #amenities_list');
|
||||
$list.html('');
|
||||
resultsHotelRoomAmenities.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}">${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
this._apply_filters();
|
||||
}.bind(this));
|
||||
|
||||
// Get Virtual Rooms
|
||||
$list = this.$el.find('#pms-search #virtual_list');
|
||||
$list.html('');
|
||||
resultsHotelVirtualRooms.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}">${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
this._apply_filters();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
toggle_pms_search: function() {
|
||||
var $pms_search = this.$el.find('#pms-search');
|
||||
if ($pms_search.position().top < 0)
|
||||
{
|
||||
var $navbar = $('.navbar');
|
||||
var toPos = $navbar.height() + parseInt($navbar.css('border-top-width'), 10) + parseInt($navbar.css('border-bottom-width'), 10);
|
||||
$pms_search.animate({
|
||||
'top': `${toPos}px`,
|
||||
'opacity': 1.0,
|
||||
}, 'fast');
|
||||
} else {
|
||||
$pms_search.animate({
|
||||
'top': `-${$pms_search.height()}px`,
|
||||
'opacity': 0.0,
|
||||
}, 'slow');
|
||||
}
|
||||
},
|
||||
|
||||
_generate_bookings_domain: function(tsearch) {
|
||||
var domain = [];
|
||||
domain.push('|', '|', '|', '|',
|
||||
['partner_id.name', 'ilike', tsearch],
|
||||
['partner_id.mobile', 'ilike', tsearch],
|
||||
['partner_id.vat', 'ilike', tsearch],
|
||||
['partner_id.email', 'ilike', tsearch],
|
||||
['partner_id.phone', 'ilike', tsearch]);
|
||||
return domain;
|
||||
},
|
||||
|
||||
_open_bookings_tree: function() {
|
||||
var $elm = this.$el.find('#pms-menu #bookings_search');
|
||||
var searchQuery = $elm.val();
|
||||
var domain = false;
|
||||
if (searchQuery) {
|
||||
domain = this._generate_bookings_domain(searchQuery);
|
||||
}
|
||||
|
||||
this.do_action({
|
||||
type: 'ir.actions.act_window',
|
||||
view_mode: 'form',
|
||||
view_type: 'tree,form',
|
||||
res_model: 'hotel.reservation',
|
||||
views: [[false, 'list'], [false, 'form']],
|
||||
domain: domain,
|
||||
name: searchQuery?'Reservations for ' + searchQuery:'All Reservations'
|
||||
});
|
||||
|
||||
$elm.val('');
|
||||
},
|
||||
|
||||
on_change_filter_date: function(isStartDate) {
|
||||
isStartDate = isStartDate || false;
|
||||
var $dateTimePickerBegin = this.$el.find('#pms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#pms-search #date_end');
|
||||
|
||||
// FIXME: Hackish onchange ignore (Used when change dates from code)
|
||||
if ($dateTimePickerBegin.data("ignore_onchange") || $dateTimePickerEnd.data("ignore_onchange")) {
|
||||
$dateTimePickerBegin.data("ignore_onchange", false);
|
||||
$dateTimePickerEnd.data("ignore_onchange", false)
|
||||
return true;
|
||||
}
|
||||
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone().utc();
|
||||
|
||||
if (this._hcalendar && date_begin) {
|
||||
if (isStartDate) {
|
||||
var ndate_end = date_begin.clone().add(this._view_options['days'], 'd');
|
||||
$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(ndate_end.local());
|
||||
}
|
||||
|
||||
if (!date_begin.isSame(this._last_dates[0].clone().utc(), 'd') || !date_end.isSame(this._last_dates[1].clone().utc(), 'd')) {
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc();
|
||||
this._hcalendar.setStartDate(date_begin, this._hcalendar.getDateDiffDays(date_begin, date_end), false, function(){
|
||||
this.reload_hcalendar_reservations(false);
|
||||
}.bind(this));
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reload_hcalendar_reservations: function(clearReservations) {
|
||||
var filterDates = this.get_view_filter_dates();
|
||||
// Clip dates
|
||||
var dfrom = filterDates[0].clone(),
|
||||
dto = filterDates[1].clone();
|
||||
if (filterDates[0].isBetween(this._last_dates[0], this._last_dates[1], 'days') && filterDates[1].isAfter(this._last_dates[1], 'day')) {
|
||||
dfrom = this._last_dates[1].clone().local().startOf('day').utc();
|
||||
} else if (this._last_dates[0].isBetween(filterDates[0], filterDates[1], 'days') && this._last_dates[1].isAfter(filterDates[0], 'day')) {
|
||||
dto = this._last_dates[0].clone().local().endOf('day').utc();
|
||||
} else {
|
||||
clearReservations = true;
|
||||
}
|
||||
|
||||
return $.when(this.trigger_up('onReloadCalendar', {
|
||||
oparams: [
|
||||
dfrom.format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
dto.format(HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
false,
|
||||
],
|
||||
clearReservations: clearReservations,
|
||||
})).then(function(){
|
||||
this._last_dates = filterDates;
|
||||
});
|
||||
},
|
||||
|
||||
_apply_filters: function() {
|
||||
var category = _.map(this.$el.find('#pms-search #type_list').val(), function(item){ return +item; });
|
||||
var floor = _.map(this.$el.find('#pms-search #floor_list').val(), function(item){ return +item; });
|
||||
var amenities = _.map(this.$el.find('#pms-search #amenities_list').val(), function(item){ return +item; });
|
||||
var virtual = _.map(this.$el.find('#pms-search #virtual_list').val(), function(item){ return +item; });
|
||||
var domain = [];
|
||||
if (category && category.length > 0) {
|
||||
domain.push(['categ_id', 'in', category]);
|
||||
}
|
||||
if (floor && floor.length > 0) {
|
||||
domain.push(['floor_id', 'in', floor]);
|
||||
}
|
||||
if (amenities && amenities.length > 0) {
|
||||
domain.push(['amenities', 'in', amenities]);
|
||||
}
|
||||
if (virtual && virtual.length > 0) {
|
||||
domain.push(['inside_rooms_ids', 'some', virtual]);
|
||||
}
|
||||
|
||||
this._hcalendar.setDomain(HotelCalendar.DOMAIN.ROOMS, domain);
|
||||
},
|
||||
|
||||
_merge_days_tooltips: function(new_tooltips) {
|
||||
for (var nt of new_tooltips) {
|
||||
var fnt = _.find(this._days_tooltips, function(item) { return item[0] === nt[0]});
|
||||
if (fnt) {
|
||||
fnt = nt;
|
||||
} else {
|
||||
this._days_tooltips.push(nt);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_find_bootstrap_environment: function() {
|
||||
var envs = ['xs', 'sm', 'md', 'lg'];
|
||||
|
||||
var $el = $('<div>');
|
||||
$el.appendTo($('body'));
|
||||
|
||||
for (var i = envs.length - 1; i >= 0; i--) {
|
||||
var env = envs[i];
|
||||
|
||||
$el.addClass('hidden-'+env);
|
||||
if ($el.is(':hidden')) {
|
||||
$el.remove();
|
||||
return env;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return HotelCalendarView;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,211 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSCalendarView', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractView = require('web.AbstractView'),
|
||||
PMSCalendarModel = require('hotel_calendar.PMSCalendarModel'),
|
||||
PMSCalendarController = require('hotel_calendar.PMSCalendarController'),
|
||||
PMSCalendarRenderer = require('hotel_calendar.PMSCalendarRenderer'),
|
||||
ViewRegistry = require('web.view_registry'),
|
||||
SystrayMenu = require('web.SystrayMenu'),
|
||||
ControlPanel = require('web.ControlPanel'),
|
||||
Widget = require('web.Widget'),
|
||||
Session = require('web.session'),
|
||||
Core = require('web.core'),
|
||||
|
||||
_lt = Core._lt,
|
||||
QWeb = Core.qweb;
|
||||
|
||||
/* HIDE CONTROL PANEL */
|
||||
/* FIXME: Look's like a hackish solution */
|
||||
ControlPanel.include({
|
||||
update: function(status, options) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
if (typeof options.toHide === 'undefined')
|
||||
options.toHide = false;
|
||||
var action_stack = this.getParent().action_stack;
|
||||
if (action_stack && action_stack.length) {
|
||||
var active_action = action_stack[action_stack.length-1];
|
||||
if (active_action.widget && active_action.widget.active_view &&
|
||||
active_action.widget.active_view.type === 'pms'){
|
||||
options.toHide = true;
|
||||
}
|
||||
}
|
||||
this._super(status, options);
|
||||
this._toggle_visibility(!options.toHide);
|
||||
}
|
||||
});
|
||||
|
||||
/** SYSTRAY **/
|
||||
var CalendarMenu = Widget.extend({
|
||||
template: 'HotelCalendar.SettingsMenu',
|
||||
events: {
|
||||
"click a[data-action]": "perform_callback",
|
||||
},
|
||||
|
||||
start: function(){
|
||||
this.$dropdown = this.$(".o_calendar_settings_dropdown");
|
||||
return $.when(
|
||||
this._rpc({
|
||||
model: 'res.users',
|
||||
method: 'read',
|
||||
args: [[Session.uid], ["pms_show_notifications", "pms_show_pricelist", "pms_show_availability", "pms_divide_rooms_by_capacity"]],
|
||||
context: Session.user_context,
|
||||
})
|
||||
).then(function(result) {
|
||||
this._show_notifications = result[0]['pms_show_notifications'];
|
||||
this._show_pricelist = result[0]['pms_show_pricelist'];
|
||||
this._show_availability = result[0]['pms_show_availability'];
|
||||
this._show_divide_rooms_by_capacity = result[0]['pms_divide_rooms_by_capacity'];
|
||||
return this.update();
|
||||
}.bind(this));
|
||||
},
|
||||
|
||||
perform_callback: function (evt) {
|
||||
evt.preventDefault();
|
||||
var params = $(evt.target).data();
|
||||
var callback = params.action;
|
||||
|
||||
if (callback && this[callback]) {
|
||||
this[callback](params, evt);
|
||||
} else {
|
||||
console.warn("No handler for ", callback);
|
||||
}
|
||||
},
|
||||
|
||||
update: function() {
|
||||
// var view_type = this.getParent().getParent()._current_state.view_type;
|
||||
// if (view_type === 'pms') {
|
||||
// this.do_show();
|
||||
this.$dropdown
|
||||
.empty()
|
||||
.append(QWeb.render('HotelCalendar.SettingsMenu.Global', {
|
||||
manager: this,
|
||||
}));
|
||||
// }
|
||||
// else {
|
||||
// this.do_hide();
|
||||
// }
|
||||
return $.when();
|
||||
},
|
||||
|
||||
toggle_show_adv_controls: function() {
|
||||
var $pms_search = $(document).find('#pms-search');
|
||||
if ($pms_search.position().top < 0)
|
||||
{
|
||||
var $navbar = $('.navbar');
|
||||
var toPos = $navbar.height() + parseInt($navbar.css('border-top-width'), 10) + parseInt($navbar.css('border-bottom-width'), 10);
|
||||
$pms_search.animate({
|
||||
'top': `${toPos}px`,
|
||||
'opacity': 1.0,
|
||||
}, 'fast');
|
||||
} else {
|
||||
$pms_search.animate({
|
||||
'top': `-${$pms_search.height()}px`,
|
||||
'opacity': 0.0,
|
||||
}, 'slow');
|
||||
}
|
||||
},
|
||||
|
||||
toggle_show_notification: function() {
|
||||
this._show_notifications = !this._show_notifications;
|
||||
this._rpc({
|
||||
model: 'res.users',
|
||||
method: 'write',
|
||||
args: [[Session.uid], {pms_show_notifications: this._show_notifications}],
|
||||
context: Session.user_context,
|
||||
}).then(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
|
||||
toggle_show_pricelist: function() {
|
||||
this._show_pricelist = !this._show_pricelist;
|
||||
this._rpc({
|
||||
model: 'res.users',
|
||||
method: 'write',
|
||||
args: [[Session.uid], {pms_show_pricelist: this._show_pricelist}],
|
||||
context: Session.user_context,
|
||||
}).then(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
|
||||
toggle_show_availability: function() {
|
||||
this._show_availability = !this._show_availability;
|
||||
this._rpc({
|
||||
model: 'res.users',
|
||||
method: 'write',
|
||||
args: [[Session.uid], {pms_show_availability: this._show_availability}],
|
||||
context: Session.user_context,
|
||||
}).then(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
},
|
||||
|
||||
toggle_show_divide_rooms_by_capacity: function() {
|
||||
this._show_divide_rooms_by_capacity = !this._show_divide_rooms_by_capacity;
|
||||
this._rpc({
|
||||
model: 'res.users',
|
||||
method: 'write',
|
||||
args: [[Session.uid], {pms_divide_rooms_by_capacity: this._show_divide_rooms_by_capacity}],
|
||||
context: Session.user_context,
|
||||
}).then(function () {
|
||||
window.location.reload();
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
var PMSCalendarView = AbstractView.extend({
|
||||
display_name: _lt('Calendar PMS'),
|
||||
icon: 'fa-calendar',
|
||||
jsLibs: ['/hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js'],
|
||||
cssLibs: ['/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css'],
|
||||
config: {
|
||||
Model: PMSCalendarModel,
|
||||
Controller: PMSCalendarController,
|
||||
Renderer: PMSCalendarRenderer,
|
||||
},
|
||||
|
||||
init: function (viewInfo, params) {
|
||||
this._super.apply(this, arguments);
|
||||
var arch = viewInfo.arch;
|
||||
var fields = viewInfo.fields;
|
||||
var attrs = arch.attrs;
|
||||
|
||||
// If form_view_id is set, then the calendar view will open a form view
|
||||
// with this id, when it needs to edit or create an event.
|
||||
this.controllerParams.formViewId =
|
||||
attrs.form_view_id ? parseInt(attrs.form_view_id, 10) : false;
|
||||
if (!this.controllerParams.formViewId && params.action) {
|
||||
var formViewDescr = _.find(params.action.views, function (v) {
|
||||
return v[1] === 'form';
|
||||
});
|
||||
if (formViewDescr) {
|
||||
this.controllerParams.formViewId = formViewDescr[0];
|
||||
}
|
||||
}
|
||||
|
||||
this.controllerParams.readonlyFormViewId = !attrs.readonly_form_view_id || !utils.toBoolElse(attrs.readonly_form_view_id, true) ? false : attrs.readonly_form_view_id;
|
||||
this.controllerParams.context = params.context || {};
|
||||
this.controllerParams.displayName = params.action && params.action.name;
|
||||
|
||||
this.rendererParams.model = viewInfo.model;
|
||||
|
||||
this.loadParams.fields = fields;
|
||||
this.loadParams.fieldsInfo = viewInfo.fieldsInfo;
|
||||
this.loadParams.creatable = false;
|
||||
|
||||
this.loadParams.mode = attrs.mode;
|
||||
},
|
||||
});
|
||||
|
||||
SystrayMenu.Items.push(CalendarMenu);
|
||||
ViewRegistry.add('pms', PMSCalendarView);
|
||||
|
||||
return PMSCalendarView;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,174 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.MPMSCalendarController', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractController = require('web.AbstractController'),
|
||||
Core = require('web.core'),
|
||||
Bus = require('bus.bus').bus,
|
||||
HotelConstants = require('hotel_calendar.Constants'),
|
||||
|
||||
_t = Core._t,
|
||||
QWeb = Core.qweb;
|
||||
|
||||
var MPMSCalendarController = AbstractController.extend({
|
||||
custom_events: _.extend({}, AbstractController.prototype.custom_events, {
|
||||
viewUpdated: '_onViewUpdated',
|
||||
onSaveChanges: '_onSaveChanges',
|
||||
onLoadCalendar: '_onLoadCalendar',
|
||||
onLoadCalendarSettings: '_onLoadCalendarSettings',
|
||||
}),
|
||||
/**
|
||||
* @override
|
||||
* @param {Widget} parent
|
||||
* @param {AbstractModel} model
|
||||
* @param {AbstractRenderer} renderer
|
||||
* @param {Object} params
|
||||
*/
|
||||
init: function (parent, model, renderer, params) {
|
||||
this._super.apply(this, arguments);
|
||||
this.displayName = params.displayName;
|
||||
this.formViewId = params.formViewId;
|
||||
this.context = params.context;
|
||||
|
||||
Bus.on("notification", this, this._onBusNotification);
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* @param {Object} record
|
||||
* @param {integer} record.id
|
||||
* @returns {Deferred}
|
||||
*/
|
||||
_updateRecord: function (record) {
|
||||
return this.model.updateRecord(record).then(this.reload.bind(this));
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
_onSaveChanges: function (ev) {
|
||||
this.model.save_changes(ev.data).then(function(results){
|
||||
this.renderer.resetSaveState();
|
||||
});
|
||||
},
|
||||
|
||||
_onLoadCalendar: function (ev) {
|
||||
var self = this;
|
||||
|
||||
/** DO MAGIC **/
|
||||
var params = this.renderer.generate_params();
|
||||
var oparams = [params['dates'][0], params['dates'][1], false, false, true];
|
||||
this.model.get_hcalendar_data(oparams).then(function(results){
|
||||
self.renderer._days_tooltips = results['events'];
|
||||
var rooms = [];
|
||||
for (var r of results['rooms']) {
|
||||
var nroom = new HVRoom(
|
||||
r[0], // Id
|
||||
r[1], // Name
|
||||
r[2], // Capacity
|
||||
r[3], // Price
|
||||
);
|
||||
rooms.push(nroom);
|
||||
}
|
||||
|
||||
// Get Pricelists
|
||||
self.renderer._pricelist_id = results['pricelist_id'];
|
||||
self.renderer._restriction_id = results['restriction_id'];
|
||||
$.when(
|
||||
self.model.get_pricelists(),
|
||||
self.model.get_restrictions(),
|
||||
).then(function(a1, a2){
|
||||
self.renderer.loadViewFilters(a1, a2);
|
||||
})
|
||||
|
||||
self.renderer.create_calendar(rooms);
|
||||
console.log(results);
|
||||
self.renderer.setCalendarData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']);
|
||||
});
|
||||
},
|
||||
|
||||
_onLoadCalendarSettings: function (ev) {
|
||||
var self = this;
|
||||
this.model.get_hcalendar_settings().then(function(results){
|
||||
self.renderer.setHCalendarSettings(results);
|
||||
});
|
||||
},
|
||||
|
||||
_onBusNotification: function () {
|
||||
if (!this.renderer._hcalendar) {
|
||||
return;
|
||||
}
|
||||
for (var notif of notifications) {
|
||||
if (notif[0][1] === 'hotel.reservation') {
|
||||
switch (notif[1]['type']) {
|
||||
case 'availability':
|
||||
var avail = notif[1]['availability'];
|
||||
var vroom = Object.keys(avail)[0];
|
||||
var day = Object.keys(avail[vroom])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var availability = {};
|
||||
availability[vroom] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'avail': avail[vroom][day][0],
|
||||
'no_ota': avail[vroom][day][1],
|
||||
'id': avail[vroom][day][2]
|
||||
}];
|
||||
this.renderer._hcalendar.addAvailability(availability);
|
||||
break;
|
||||
case 'pricelist':
|
||||
var prices = notif[1]['price'];
|
||||
var pricelist_id = Object.keys(prices)[0];
|
||||
var pr = {};
|
||||
for (var price of prices[pricelist_id]) {
|
||||
pr[price['room']] = [];
|
||||
var days = Object.keys(price['days']);
|
||||
for (var day of days) {
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
pr[price['room']].push({
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'price': price['days'][day],
|
||||
'id': price['id']
|
||||
});
|
||||
}
|
||||
}
|
||||
this.renderer._hcalendar.addPricelist(pr);
|
||||
break;
|
||||
case 'restriction':
|
||||
// FIXME: Expected one day and one vroom
|
||||
var restriction = notif[1]['restriction'];
|
||||
var vroom = Object.keys(restriction)[0];
|
||||
var day = Object.keys(restriction[vroom])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var rest = {};
|
||||
rest[vroom] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'min_stay': restriction[vroom][day][0],
|
||||
'min_stay_arrival': restriction[vroom][day][1],
|
||||
'max_stay': restriction[vroom][day][2],
|
||||
'max_stay_arrival': restriction[vroom][day][3],
|
||||
'closed': restriction[vroom][day][4],
|
||||
'closed_arrival': restriction[vroom][day][5],
|
||||
'closed_departure': restriction[vroom][day][6],
|
||||
'id': restriction[vroom][day][7]
|
||||
}];
|
||||
this.renderer._hcalendar.addRestrictions(rest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
return MPMSCalendarController;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,68 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.MPMSCalendarModel', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractModel = require('web.AbstractModel'),
|
||||
Context = require('web.Context'),
|
||||
Core = require('web.core'),
|
||||
FieldUtils = require('web.field_utils'),
|
||||
Session = require('web.session');
|
||||
|
||||
|
||||
return AbstractModel.extend({
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.end_date = null;
|
||||
},
|
||||
|
||||
load: function (params) {
|
||||
this.modelName = params.modelName;
|
||||
},
|
||||
|
||||
save_changes: function (params) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'save_changes',
|
||||
args: params,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_hcalendar_data: function (params) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_all_data',
|
||||
args: params,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_pricelists: function () {
|
||||
return this._rpc({
|
||||
model: 'product.pricelist',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_restrictions: function () {
|
||||
return this._rpc({
|
||||
model: 'hotel.virtual.room.restriction',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_hcalendar_settings: function () {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'search_read',
|
||||
args: [false],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,526 @@
|
||||
/* global $, odoo, _, HotelCalendar, moment */
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.MPMSCalendarRenderer', function (require) {
|
||||
"use strict";
|
||||
|
||||
var Core = require('web.core'),
|
||||
ViewDialogs = require('web.view_dialogs'),
|
||||
Dialog = require('web.Dialog'),
|
||||
Session = require('web.session'),
|
||||
AbstractRenderer = require('web.AbstractRenderer'),
|
||||
HotelConstants = require('hotel_calendar.Constants'),
|
||||
//Formats = require('web.formats'),
|
||||
|
||||
_t = Core._t,
|
||||
_lt = Core._lt,
|
||||
QWeb = Core.qweb;
|
||||
|
||||
var HotelCalendarManagementView = AbstractRenderer.extend({
|
||||
/** VIEW OPTIONS **/
|
||||
template: "hotel_calendar.HotelCalendarManagementView",
|
||||
display_name: _lt('Hotel Calendar Management'),
|
||||
icon: 'fa fa-map-marker',
|
||||
searchable: false,
|
||||
searchview_hidden: true,
|
||||
|
||||
// Custom Options
|
||||
_view_options: {},
|
||||
_hcalendar: null,
|
||||
_last_dates: [false, false],
|
||||
_pricelist_id: null,
|
||||
_restriction_id: null,
|
||||
_days_tooltips: [],
|
||||
|
||||
|
||||
/** VIEW METHODS **/
|
||||
init: function(parent, state, params) {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this.model = params.model;
|
||||
},
|
||||
|
||||
start: function () {
|
||||
var self = this;
|
||||
return this._super().then(function() {
|
||||
self.init_calendar_view();
|
||||
$(window).trigger('resize');
|
||||
});
|
||||
},
|
||||
|
||||
do_show: function() {
|
||||
if (this.$ehcal) {
|
||||
this.$ehcal.show();
|
||||
$('.o_content').css('overflow', 'hidden');
|
||||
}
|
||||
this.do_push_state({});
|
||||
return this._super();
|
||||
},
|
||||
do_hide: function () {
|
||||
if (this.$ehcal) {
|
||||
this.$ehcal.hide();
|
||||
$('.o_content').css('overflow', '');
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** CUSTOM METHODS **/
|
||||
save_changes: function() {
|
||||
var self = this;
|
||||
var btn_save = this.$el.find('#btn_save_changes');
|
||||
if (!btn_save.hasClass('need-save')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pricelist = this._hcalendar.getPricelist(true);
|
||||
var restrictions = this._hcalendar.getRestrictions(true);
|
||||
var availability = this._hcalendar.getAvailability(true);
|
||||
|
||||
var params = this.generate_params();
|
||||
var oparams = [false, params['prices'], params['restrictions'], pricelist, restrictions, availability];
|
||||
this.trigger_up('onSaveChanges', oparams);
|
||||
},
|
||||
|
||||
resetSaveState: function() {
|
||||
this.$el.find('#btn_save_changes').removeClass('need-save');
|
||||
$('.hcal-management-record-changed').removeClass('hcal-management-record-changed');
|
||||
$('.hcal-management-input-changed').removeClass('hcal-management-input-changed');
|
||||
},
|
||||
|
||||
create_calendar: function(rooms) {
|
||||
var self = this;
|
||||
// CALENDAR
|
||||
if (this._hcalendar) {
|
||||
delete this._hcalendar;
|
||||
}
|
||||
this.$ehcal.empty();
|
||||
|
||||
var options = {
|
||||
rooms: rooms,
|
||||
days: self._view_options['days'],
|
||||
endOfWeek: parseInt(self._view_options['eday_week']) || 6,
|
||||
endOfWeekOffset: self._view_options['eday_week_offset'] || 0,
|
||||
dateFormatLong: HotelConstants.ODOO_DATETIME_MOMENT_FORMAT,
|
||||
dateFormatShort: HotelConstants.ODOO_DATE_MOMENT_FORMAT,
|
||||
translations: {
|
||||
'Open': _t('Open'),
|
||||
'Closed': _t('Closed'),
|
||||
'C. Departure': _t('C. Departure'),
|
||||
'C. Arrival': _t('C. Arrival'),
|
||||
'Price': _t('Price'),
|
||||
'Availability': _t('Availability'),
|
||||
'Min. Stay': _t('Min. Stay'),
|
||||
'Max. Stay': _t('Max. Stay'),
|
||||
'Min. Stay Arrival': _t('Min. Stay Arrival'),
|
||||
'Max. Stay Arrival': _t('Max. Stay Arrival'),
|
||||
'Clousure': _t('Clousure'),
|
||||
'Free Rooms': _t('Free Rooms'),
|
||||
'No OTA': _t('No OTA'),
|
||||
'Options': _t('Options'),
|
||||
'Reset': _t('Reset'),
|
||||
'Copy': _t('Copy'),
|
||||
'Paste': _t('Paste'),
|
||||
'Clone': _t('Clone'),
|
||||
'Cancel': _t('Cancel')
|
||||
}
|
||||
};
|
||||
|
||||
this._hcalendar = new HotelCalendarManagement('#hcal_management_widget', options, this.$el[0]);
|
||||
this._assignHCalendarEvents();
|
||||
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
|
||||
// Sticky Header Days
|
||||
this.$ehcal.scroll(this._on_scroll.bind(this));
|
||||
},
|
||||
|
||||
setCalendarData: function (prices, restrictions, availability, count_reservations) {
|
||||
this._hcalendar.setData(prices, restrictions, availability, count_reservations);
|
||||
this._assign_extra_info();
|
||||
},
|
||||
|
||||
_assignHCalendarEvents: function () {
|
||||
var self = this;
|
||||
this._hcalendar.addEventListener('hcOnChangeDate', function(ev){
|
||||
var date_begin = moment(ev.detail.newDate);
|
||||
var days = self._hcalendar.getOptions('days')-1;
|
||||
var date_end = date_begin.clone().add(days, 'd');
|
||||
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
this._hcalendar.addEventListener('hcmOnInputChanged', function(ev){
|
||||
var btn_save = self.$el.find('#btn_save_changes');
|
||||
if (self._hcalendar.hasChangesToSave()) {
|
||||
btn_save.addClass('need-save');
|
||||
} else {
|
||||
btn_save.removeClass('need-save');
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_on_scroll: function() {
|
||||
var curScrollPos = this.$ehcal.scrollTop();
|
||||
if (curScrollPos > 0) {
|
||||
this.$CalendarHeaderDays.css({
|
||||
top: `${curScrollPos}px`,
|
||||
position: 'sticky'
|
||||
});
|
||||
} else {
|
||||
this.$CalendarHeaderDays.css({
|
||||
top: '0px',
|
||||
position: 'initial'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
loadViewFilters: function (resultsPricelist, resultsRestrictions) {
|
||||
var self = this;
|
||||
|
||||
var $list = self.$el.find('#mpms-search #price_list');
|
||||
$list.html('');
|
||||
resultsPricelist.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}" ${item.id==self._pricelist_id?'selected':''}>${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
self._check_unsaved_changes(function(){
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
});
|
||||
|
||||
$list = self.$el.find('#mpms-search #restriction_list');
|
||||
$list.html('');
|
||||
resultsRestrictions.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}" ${item.id==self._restriction_id?'selected':''}>${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
self._check_unsaved_changes(function(){
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
});
|
||||
|
||||
$list = self.$el.find('#mpms-search #mode_list');
|
||||
$list.select2({
|
||||
minimumResultsForSearch: -1
|
||||
});
|
||||
$list.on('change', function(ev){
|
||||
var mode = HotelCalendarManagement.MODE.ALL;
|
||||
if (this.value === 'low') {
|
||||
mode = HotelCalendarManagement.MODE.LOW;
|
||||
} else if (this.value === 'medium') {
|
||||
mode = HotelCalendarManagement.MODE.MEDIUM;
|
||||
}
|
||||
self._hcalendar.setMode(mode);
|
||||
});
|
||||
},
|
||||
|
||||
call_action: function(action) {
|
||||
this.do_action(action);
|
||||
},
|
||||
|
||||
init_calendar_view: function(){
|
||||
var self = this;
|
||||
|
||||
this.$ehcal = this.$el.find("div#hcal_management_widget");
|
||||
|
||||
/** VIEW CONTROLS INITIALIZATION **/
|
||||
// DATE TIME PICKERS
|
||||
var l10nn = _t.database.parameters
|
||||
var DTPickerOptions = {
|
||||
viewMode: 'months',
|
||||
icons : {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down'
|
||||
},
|
||||
format : HotelConstants.L10N_DATE_MOMENT_FORMAT,
|
||||
disabledHours: [0, 1, 2, 3, 4, 5, 6, 7, 8, 18, 19, 20, 21, 22, 23]
|
||||
};
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
$dateTimePickerBegin.datetimepicker(DTPickerOptions);
|
||||
$dateTimePickerEnd.datetimepicker($.extend({}, DTPickerOptions, { 'useCurrent': false }));
|
||||
$dateTimePickerBegin.on("dp.change", function (e) {
|
||||
$dateTimePickerEnd.data("DateTimePicker").minDate(e.date.clone().add(3,'d'));
|
||||
$dateTimePickerEnd.data("DateTimePicker").maxDate(e.date.clone().add(2,'M'));
|
||||
$dateTimePickerBegin.data("DateTimePicker").hide(); // TODO: Odoo uses old datetimepicker version
|
||||
self.on_change_filter_date(e, true);
|
||||
});
|
||||
$dateTimePickerEnd.on("dp.change", function (e) {
|
||||
self.on_change_filter_date(e, false);
|
||||
$dateTimePickerEnd.data("DateTimePicker").hide(); // TODO: Odoo uses old datetimepicker version
|
||||
});
|
||||
|
||||
// var date_begin = moment().startOf('day');
|
||||
// var date_end = date_begin.clone().add(this._view_options['days'], 'd').endOf('day');
|
||||
// $dateTimePickerBegin.data("ignore_onchange", true);
|
||||
// $dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
// $dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
// this._last_dates = this.generate_params()['dates'];
|
||||
|
||||
// View Events
|
||||
this.$el.find("#mpms-search #cal-pag-prev-plus").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
//var days = moment($dateTimePickerBegin.data("DateTimePicker").date()).clone().local().daysInMonth();
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().subtract(14, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().subtract(14, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-prev").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().subtract(7, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().subtract(7, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-next-plus").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
//var days = moment($dateTimePickerBegin.data("DateTimePicker").date()).clone().local().daysInMonth();
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().add(14, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().add(14, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-next").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().add(7, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().add(7, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-selector").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
var date_begin = moment().startOf('day');
|
||||
var date_end = date_begin.clone().add(self._view_options['days'], 'd').endOf('day');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
// Save Button
|
||||
this.$el.find("#btn_save_changes").on('click', function(ev){
|
||||
self.save_changes();
|
||||
});
|
||||
|
||||
// Launch Massive Changes
|
||||
this.$el.find("#btn_massive_changes").on('click', function(ev){
|
||||
self.call_action("hotel.action_hotel_massive_change");
|
||||
});
|
||||
|
||||
/** RENDER CALENDAR **/
|
||||
this.trigger_up('onLoadCalendarSettings');
|
||||
},
|
||||
|
||||
setHCalendarSettings: function (results) {
|
||||
this._view_options = results;
|
||||
var date_begin = moment().startOf('day');
|
||||
if (['xs', 'md'].indexOf(this._findBootstrapEnvironment()) >= 0) {
|
||||
this._view_options['days'] = 7;
|
||||
} else {
|
||||
this._view_options['days'] = (this._view_options['days'] !== 'month')?parseInt(this._view_options['days']):date_begin.daysInMonth();
|
||||
}
|
||||
var date_end = date_begin.clone().add(this._view_options['days'], 'd').endOf('day');
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
//$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
//$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(date_end);
|
||||
this._last_dates = this.generate_params()['dates'];
|
||||
|
||||
this.trigger_up('onLoadCalendar');
|
||||
},
|
||||
|
||||
on_change_filter_date: function(ev, isStartDate) {
|
||||
var self = this;
|
||||
isStartDate = isStartDate || false;
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
|
||||
// FIXME: Hackish onchange ignore (Used when change dates from code)
|
||||
if ($dateTimePickerBegin.data("ignore_onchange") || $dateTimePickerEnd.data("ignore_onchange")) {
|
||||
$dateTimePickerBegin.data("ignore_onchange", false);
|
||||
$dateTimePickerEnd.data("ignore_onchange", false)
|
||||
return true;
|
||||
}
|
||||
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone();
|
||||
|
||||
if (this._hcalendar && date_begin) {
|
||||
if (isStartDate) {
|
||||
var ndate_end = date_begin.clone().add(this._view_options['days'], 'd');
|
||||
$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").date(ndate_end.local());
|
||||
}
|
||||
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().set({'hour': 23, 'minute': 59, 'second': 59}).clone();
|
||||
|
||||
this._check_unsaved_changes(function(){
|
||||
self._hcalendar.setStartDate(date_begin, self._hcalendar.getDateDiffDays(date_begin, date_end));
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
reload_hcalendar_management: function() {
|
||||
var self = this;
|
||||
var params = this.generate_params();
|
||||
var oparams = [params['dates'][0], params['dates'][1], params['prices'], params['restrictions'], false];
|
||||
this._model.call('get_hcalendar_all_data', oparams).then(function(results){
|
||||
self._days_tooltips = results['events'];
|
||||
self._hcalendar.setData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']);
|
||||
self._assign_extra_info();
|
||||
});
|
||||
this._last_dates = params['dates'];
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
this._on_scroll(); // FIXME: Workaround for update sticky header
|
||||
},
|
||||
|
||||
generate_params: function() {
|
||||
var fullDomain = [];
|
||||
var prices = this.$el.find('#mpms-search #price_list').val();
|
||||
var restrictions = this.$el.find('#mpms-search #restriction_list').val();
|
||||
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone().utc().format(HotelConstants.ODOO_DATE_MOMENT_FORMAT);
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").date().set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc().format(HotelConstants.ODOO_DATE_MOMENT_FORMAT);
|
||||
|
||||
return {
|
||||
'dates': [date_begin, date_end],
|
||||
'prices': prices,
|
||||
'restrictions': restrictions
|
||||
};
|
||||
},
|
||||
|
||||
_check_unsaved_changes: function(fnCallback) {
|
||||
var self = this;
|
||||
var btn_save = this.$el.find("#btn_save_changes");
|
||||
if (!btn_save.hasClass('need-save')) {
|
||||
btn_save.removeClass('need-save');
|
||||
fnCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
new Dialog(self, {
|
||||
title: _t("Unsaved Changes!"),
|
||||
buttons: [
|
||||
{
|
||||
text: _t("Yes, save it"),
|
||||
classes: 'btn-primary',
|
||||
close: true,
|
||||
click: function() {
|
||||
self.save_changes();
|
||||
fnCallback();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: _t("No"),
|
||||
close: true,
|
||||
click: function() {
|
||||
btn_save.removeClass('need-save');
|
||||
fnCallback();
|
||||
}
|
||||
}
|
||||
],
|
||||
$content: QWeb.render('HotelCalendarManagement.UnsavedChanges', {})
|
||||
}).open();
|
||||
},
|
||||
|
||||
_findBootstrapEnvironment: function() {
|
||||
var envs = ['xs', 'sm', 'md', 'lg'];
|
||||
|
||||
var $el = $('<div>');
|
||||
$el.appendTo($('body'));
|
||||
|
||||
for (var i = envs.length - 1; i >= 0; i--) {
|
||||
var env = envs[i];
|
||||
|
||||
$el.addClass('hidden-'+env);
|
||||
if ($el.is(':hidden')) {
|
||||
$el.remove();
|
||||
return env;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_assign_extra_info: function() {
|
||||
var self = this;
|
||||
|
||||
$(this._hcalendar.etableHeader).find('.hcal-cell-header-day').each(function(index, elm){
|
||||
var $elm = $(elm);
|
||||
var cdate = HotelCalendarManagement.toMoment($elm.data('hcalDate'), HotelConstants.L10N_DATE_MOMENT_FORMAT);
|
||||
var data = _.filter(self._days_tooltips, function(item) {
|
||||
var ndate = HotelCalendarManagement.toMoment(item[2], HotelConstants.ODOO_DATE_MOMENT_FORMAT);
|
||||
return ndate.isSame(cdate, 'd');
|
||||
});
|
||||
if (data.length > 0) {
|
||||
$elm.addClass('hcal-event-day');
|
||||
$elm.on("mouseenter", function(data){
|
||||
var $this = $(this);
|
||||
if (data.length > 0) {
|
||||
var qdict = {
|
||||
'date': $this.data('hcalDate'),
|
||||
'events': _.map(data, function(item){
|
||||
return {
|
||||
'name': item[1],
|
||||
'date': item[2],
|
||||
'location': item[3]
|
||||
};
|
||||
})
|
||||
};
|
||||
$this.attr('title', '');
|
||||
$this.tooltip({
|
||||
animation: true,
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
title: QWeb.render('HotelCalendar.TooltipEvent', qdict)
|
||||
}).tooltip('show');
|
||||
}
|
||||
}.bind(elm, data));
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
return HotelCalendarManagementView;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,661 @@
|
||||
/* global $, odoo, _, HotelCalendarManagement, moment */
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.HotelCalendarManagementView', function (require) {
|
||||
"use strict";
|
||||
|
||||
var Core = require('web.core'),
|
||||
Bus = require('bus.bus').bus,
|
||||
//Data = require('web.data'),
|
||||
Time = require('web.time'),
|
||||
Model = require('web.DataModel'),
|
||||
View = require('web.View'),
|
||||
Widgets = require('web_calendar.widgets'),
|
||||
//Common = require('web.form_common'),
|
||||
//Pyeval = require('web.pyeval'),
|
||||
ActionManager = require('web.ActionManager'),
|
||||
Utils = require('web.utils'),
|
||||
Dialog = require('web.Dialog'),
|
||||
//Ajax = require('web.ajax'),
|
||||
ControlPanel = require('web.ControlPanel'),
|
||||
//Session = require('web.session'),
|
||||
formats = require('web.formats'),
|
||||
|
||||
_t = Core._t,
|
||||
_lt = Core._lt,
|
||||
QWeb = Core.qweb,
|
||||
l10n = _t.database.parameters,
|
||||
|
||||
ODOO_DATETIME_MOMENT_FORMAT = "YYYY-MM-DD HH:mm:ss",
|
||||
ODOO_DATE_MOMENT_FORMAT = "YYYY-MM-DD",
|
||||
L10N_DATE_MOMENT_FORMAT = "DD/MM/YYYY", //FIXME: Time.strftime_to_moment_format(l10n.date_format);
|
||||
L10N_DATETIME_MOMENT_FORMAT = L10N_DATE_MOMENT_FORMAT + ' ' + Time.strftime_to_moment_format(l10n.time_format);
|
||||
|
||||
|
||||
/* HIDE CONTROL PANEL */
|
||||
/* FIXME: Look's like a hackish solution */
|
||||
ControlPanel.include({
|
||||
update: function(status, options) {
|
||||
if (typeof options.toHide === 'undefined')
|
||||
options.toHide = false;
|
||||
var action_stack = this.getParent().action_stack;
|
||||
if (action_stack && action_stack.length) {
|
||||
var active_action = action_stack[action_stack.length-1];
|
||||
if (active_action.widget && active_action.widget.active_view &&
|
||||
active_action.widget.active_view.type === 'mpms'){
|
||||
options.toHide = true;
|
||||
}
|
||||
}
|
||||
this._super(status, options);
|
||||
this._toggle_visibility(!options.toHide);
|
||||
}
|
||||
});
|
||||
|
||||
var HotelCalendarManagementView = View.extend({
|
||||
/** VIEW OPTIONS **/
|
||||
template: "hotel_calendar.HotelCalendarManagementView",
|
||||
display_name: _lt('Hotel Calendar Management'),
|
||||
icon: 'fa fa-map-marker',
|
||||
//view_type: "mpms",
|
||||
searchable: false,
|
||||
searchview_hidden: true,
|
||||
quick_create_instance: Widgets.QuickCreate,
|
||||
defaults: _.extend({}, View.prototype.defaults, {
|
||||
confirm_on_delete: true,
|
||||
}),
|
||||
|
||||
// Custom Options
|
||||
_model: null,
|
||||
_hcalendar: null,
|
||||
_action_manager: null,
|
||||
_last_dates: [false, false],
|
||||
_pricelist_id: null,
|
||||
_restriction_id: null,
|
||||
_days_tooltips: [],
|
||||
|
||||
/** VIEW METHODS **/
|
||||
init: function(parent, dataset, fields_view, options) {
|
||||
this._super.apply(this, arguments);
|
||||
this.shown = $.Deferred();
|
||||
this.dataset = dataset;
|
||||
this.model = dataset.model;
|
||||
this.view_type = 'mpms';
|
||||
this.selected_filters = [];
|
||||
this.mutex = new Utils.Mutex();
|
||||
this._model = new Model(this.dataset.model);
|
||||
this._action_manager = this.findAncestor(function(ancestor){ return ancestor instanceof ActionManager; });
|
||||
|
||||
Bus.on("notification", this, this._on_bus_signal);
|
||||
},
|
||||
|
||||
start: function () {
|
||||
this.shown.done(this._do_show_init.bind(this));
|
||||
return this._super();
|
||||
},
|
||||
|
||||
_do_show_init: function () {
|
||||
this.init_calendar_view().then(function() {
|
||||
$(window).trigger('resize');
|
||||
});
|
||||
},
|
||||
|
||||
do_show: function() {
|
||||
if (this.$ehcal) {
|
||||
this.$ehcal.show();
|
||||
$('.o_content').css('overflow', 'hidden');
|
||||
}
|
||||
this.do_push_state({});
|
||||
this.shown.resolve();
|
||||
return this._super();
|
||||
},
|
||||
do_hide: function () {
|
||||
if (this.$ehcal) {
|
||||
this.$ehcal.hide();
|
||||
$('.o_content').css('overflow', '');
|
||||
}
|
||||
return this._super();
|
||||
},
|
||||
|
||||
destroy: function () {
|
||||
return this._super.apply(this, arguments);
|
||||
},
|
||||
|
||||
/** CUSTOM METHODS **/
|
||||
save_changes: function() {
|
||||
var self = this;
|
||||
var btn_save = this.$el.find('#btn_save_changes');
|
||||
if (!btn_save.hasClass('need-save')) {
|
||||
return;
|
||||
}
|
||||
|
||||
var pricelist = this._hcalendar.getPricelist(true);
|
||||
var restrictions = this._hcalendar.getRestrictions(true);
|
||||
var availability = this._hcalendar.getAvailability(true);
|
||||
|
||||
var params = this.generate_params();
|
||||
var oparams = [false, params['prices'], params['restrictions'], pricelist, restrictions, availability];
|
||||
this._model.call('save_changes', oparams).then(function(results){
|
||||
btn_save.removeClass('need-save');
|
||||
$('.hcal-management-record-changed').removeClass('hcal-management-record-changed');
|
||||
$('.hcal-management-input-changed').removeClass('hcal-management-input-changed');
|
||||
});
|
||||
},
|
||||
|
||||
create_calendar: function(options) {
|
||||
var self = this;
|
||||
// CALENDAR
|
||||
if (this._hcalendar) {
|
||||
delete this._hcalendar;
|
||||
}
|
||||
|
||||
this.$ehcal.empty();
|
||||
|
||||
this._hcalendar = new HotelCalendarManagement('#hcal_management_widget', options, this.$el[0]);
|
||||
this._hcalendar.addEventListener('hcOnChangeDate', function(ev){
|
||||
var date_begin = moment(ev.detail.newDate);
|
||||
var days = self._hcalendar.getOptions('days')-1;
|
||||
var date_end = date_begin.clone().add(days, 'd');
|
||||
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
this._hcalendar.addEventListener('hcmOnInputChanged', function(ev){
|
||||
var btn_save = self.$el.find('#btn_save_changes');
|
||||
if (self._hcalendar.hasChangesToSave()) {
|
||||
btn_save.addClass('need-save');
|
||||
} else {
|
||||
btn_save.removeClass('need-save');
|
||||
}
|
||||
});
|
||||
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
|
||||
// Sticky Header Days
|
||||
this.$ehcal.scroll(this._on_scroll.bind(this));
|
||||
},
|
||||
|
||||
_on_scroll: function() {
|
||||
var curScrollPos = this.$ehcal.scrollTop();
|
||||
if (curScrollPos > 0) {
|
||||
this.$CalendarHeaderDays.css({
|
||||
top: `${curScrollPos}px`,
|
||||
position: 'sticky'
|
||||
});
|
||||
} else {
|
||||
this.$CalendarHeaderDays.css({
|
||||
top: '0px',
|
||||
position: 'initial'
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
generate_hotel_calendar: function(){
|
||||
var self = this;
|
||||
|
||||
/** DO MAGIC **/
|
||||
var params = this.generate_params();
|
||||
var oparams = [params['dates'][0], params['dates'][1], false, false, true];
|
||||
this._model.call('get_hcalendar_all_data', oparams).then(function(results){
|
||||
self._days_tooltips = results['events'];
|
||||
var rooms = [];
|
||||
for (var r of results['rooms']) {
|
||||
var nroom = new HVRoom(
|
||||
r[0], // Id
|
||||
r[1], // Name
|
||||
r[2], // Capacity
|
||||
r[3], // Price
|
||||
);
|
||||
rooms.push(nroom);
|
||||
}
|
||||
|
||||
// Get Pricelists
|
||||
self._pricelist_id = results['pricelist_id'];
|
||||
new Model('product.pricelist').query(['id','name']).all().then(function(resultsPricelist){
|
||||
var $list = self.$el.find('#mpms-search #price_list');
|
||||
$list.html('');
|
||||
resultsPricelist.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}" ${item.id==self._pricelist_id?'selected':''}>${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
self._check_unsaved_changes(function(){
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Get Restrictions
|
||||
self._restriction_id = results['restriction_id'];
|
||||
new Model('hotel.virtual.room.restriction').query(['id','name']).all().then(function(resultsRestrictions){
|
||||
var $list = self.$el.find('#mpms-search #restriction_list');
|
||||
$list.html('');
|
||||
resultsRestrictions.forEach(function(item, index){
|
||||
$list.append(`<option value="${item.id}" ${item.id==self._restriction_id?'selected':''}>${item.name}</option>`);
|
||||
});
|
||||
$list.select2();
|
||||
$list.on('change', function(ev){
|
||||
self._check_unsaved_changes(function(){
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
// Calendar Mode
|
||||
var $list = self.$el.find('#mpms-search #mode_list');
|
||||
$list.select2({
|
||||
minimumResultsForSearch: -1
|
||||
});
|
||||
$list.on('change', function(ev){
|
||||
var mode = HotelCalendarManagement.MODE.ALL;
|
||||
if (this.value === 'low') {
|
||||
mode = HotelCalendarManagement.MODE.LOW;
|
||||
} else if (this.value === 'medium') {
|
||||
mode = HotelCalendarManagement.MODE.MEDIUM;
|
||||
}
|
||||
self._hcalendar.setMode(mode);
|
||||
});
|
||||
|
||||
self.create_calendar({
|
||||
rooms: rooms,
|
||||
days: self._view_options['days'],
|
||||
endOfWeek: parseInt(self._view_options['eday_week']) || 6,
|
||||
endOfWeekOffset: self._view_options['eday_week_offset'] || 0,
|
||||
dateFormatLong: ODOO_DATETIME_MOMENT_FORMAT,
|
||||
dateFormatShort: ODOO_DATE_MOMENT_FORMAT,
|
||||
translations: {
|
||||
'Open': _t('Open'),
|
||||
'Closed': _t('Closed'),
|
||||
'C. Departure': _t('C. Departure'),
|
||||
'C. Arrival': _t('C. Arrival'),
|
||||
'Price': _t('Price'),
|
||||
'Availability': _t('Availability'),
|
||||
'Min. Stay': _t('Min. Stay'),
|
||||
'Max. Stay': _t('Max. Stay'),
|
||||
'Min. Stay Arrival': _t('Min. Stay Arrival'),
|
||||
'Max. Stay Arrival': _t('Max. Stay Arrival'),
|
||||
'Clousure': _t('Clousure'),
|
||||
'Free Rooms': _t('Free Rooms'),
|
||||
'No OTA': _t('No OTA'),
|
||||
'Options': _t('Options'),
|
||||
'Reset': _t('Reset'),
|
||||
'Copy': _t('Copy'),
|
||||
'Paste': _t('Paste'),
|
||||
'Clone': _t('Clone'),
|
||||
'Cancel': _t('Cancel')
|
||||
}
|
||||
});
|
||||
self._hcalendar.setData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']);
|
||||
self._assign_extra_info();
|
||||
});
|
||||
},
|
||||
|
||||
call_action: function(action) {
|
||||
this._action_manager.do_action(action);
|
||||
},
|
||||
|
||||
init_calendar_view: function(){
|
||||
var self = this;
|
||||
|
||||
this.$ehcal = this.$el.find("div#hcal_management_widget");
|
||||
|
||||
/** VIEW CONTROLS INITIALIZATION **/
|
||||
// DATE TIME PICKERS
|
||||
var l10nn = _t.database.parameters
|
||||
var DTPickerOptions = {
|
||||
viewMode: 'months',
|
||||
icons : {
|
||||
time: 'fa fa-clock-o',
|
||||
date: 'fa fa-calendar',
|
||||
up: 'fa fa-chevron-up',
|
||||
down: 'fa fa-chevron-down'
|
||||
},
|
||||
language : moment.locale(),
|
||||
format : L10N_DATE_MOMENT_FORMAT,
|
||||
disabledHours: true // TODO: Odoo uses old datetimepicker version
|
||||
};
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
$dateTimePickerBegin.datetimepicker(DTPickerOptions);
|
||||
$dateTimePickerEnd.datetimepicker($.extend({}, DTPickerOptions, { 'useCurrent': false }));
|
||||
$dateTimePickerBegin.on("dp.change", function (e) {
|
||||
$dateTimePickerEnd.data("DateTimePicker").setMinDate(e.date.add(3,'d'));
|
||||
$dateTimePickerEnd.data("DateTimePicker").setMaxDate(e.date.add(2,'M'));
|
||||
$dateTimePickerBegin.data("DateTimePicker").hide(); // TODO: Odoo uses old datetimepicker version
|
||||
self.on_change_filter_date(e, true);
|
||||
});
|
||||
$dateTimePickerEnd.on("dp.change", function (e) {
|
||||
self.on_change_filter_date(e, false);
|
||||
$dateTimePickerEnd.data("DateTimePicker").hide(); // TODO: Odoo uses old datetimepicker version
|
||||
});
|
||||
|
||||
// var date_begin = moment().startOf('day');
|
||||
// var date_end = date_begin.clone().add(this._view_options['days'], 'd').endOf('day');
|
||||
// $dateTimePickerBegin.data("ignore_onchange", true);
|
||||
// $dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
// $dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
// this._last_dates = this.generate_params()['dates'];
|
||||
|
||||
// View Events
|
||||
this.$el.find("#mpms-search #cal-pag-prev-plus").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
//var days = moment($dateTimePickerBegin.data("DateTimePicker").getDate()).clone().local().daysInMonth();
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").getDate().subtract(14, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").getDate().subtract(14, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-prev").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").getDate().subtract(7, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").getDate().subtract(7, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-next-plus").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
//var days = moment($dateTimePickerBegin.data("DateTimePicker").getDate()).clone().local().daysInMonth();
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").getDate().add(14, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").getDate().add(14, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-next").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").getDate().add(7, 'd');
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").getDate().add(7, 'd');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
this.$el.find("#mpms-search #cal-pag-selector").on('click', function(ev){
|
||||
// FIXME: Ugly repeated code. Change place.
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
var date_begin = moment().startOf('day');
|
||||
var date_end = date_begin.clone().add(self._view_options['days'], 'd').endOf('day');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
|
||||
ev.preventDefault();
|
||||
});
|
||||
|
||||
// Save Button
|
||||
this.$el.find("#btn_save_changes").on('click', function(ev){
|
||||
self.save_changes();
|
||||
});
|
||||
|
||||
// Launch Massive Changes
|
||||
this.$el.find("#btn_massive_changes").on('click', function(ev){
|
||||
self.call_action("hotel.action_hotel_massive_change");
|
||||
});
|
||||
|
||||
/** RENDER CALENDAR **/
|
||||
this._model.call('get_hcalendar_settings', [false]).then(function(results){
|
||||
self._view_options = results;
|
||||
var date_begin = moment().startOf('day');
|
||||
if (['xs', 'md'].indexOf(self._findBootstrapEnvironment()) >= 0) {
|
||||
self._view_options['days'] = 7;
|
||||
} else {
|
||||
self._view_options['days'] = (self._view_options['days'] !== 'month')?parseInt(self._view_options['days']):date_begin.daysInMonth();
|
||||
}
|
||||
var date_end = date_begin.clone().add(self._view_options['days'], 'd').endOf('day');
|
||||
var $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = self.$el.find('#mpms-search #date_end');
|
||||
//$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").setDate(date_begin);
|
||||
//$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(date_end);
|
||||
self._last_dates = self.generate_params()['dates'];
|
||||
|
||||
self.generate_hotel_calendar();
|
||||
});
|
||||
|
||||
return $.when();
|
||||
},
|
||||
|
||||
on_change_filter_date: function(ev, isStartDate) {
|
||||
var self = this;
|
||||
isStartDate = isStartDate || false;
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
|
||||
// FIXME: Hackish onchange ignore (Used when change dates from code)
|
||||
if ($dateTimePickerBegin.data("ignore_onchange") || $dateTimePickerEnd.data("ignore_onchange")) {
|
||||
$dateTimePickerBegin.data("ignore_onchange", false);
|
||||
$dateTimePickerEnd.data("ignore_onchange", false)
|
||||
return true;
|
||||
}
|
||||
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").getDate().set({'hour': 0, 'minute': 0, 'second': 0}).clone();
|
||||
|
||||
if (this._hcalendar && date_begin) {
|
||||
if (isStartDate) {
|
||||
var ndate_end = date_begin.clone().add(this._view_options['days'], 'd');
|
||||
$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateTimePickerEnd.data("DateTimePicker").setDate(ndate_end.local());
|
||||
}
|
||||
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").getDate().set({'hour': 23, 'minute': 59, 'second': 59}).clone();
|
||||
|
||||
this._check_unsaved_changes(function(){
|
||||
self._hcalendar.setStartDate(date_begin, self._hcalendar.getDateDiffDays(date_begin, date_end));
|
||||
self.reload_hcalendar_management();
|
||||
});
|
||||
}
|
||||
},
|
||||
|
||||
_on_bus_signal: function(notifications) {
|
||||
if (!this._hcalendar) {
|
||||
return;
|
||||
}
|
||||
for (var notif of notifications) {
|
||||
if (notif[0][1] === 'hotel.reservation') {
|
||||
switch (notif[1]['type']) {
|
||||
case 'availability':
|
||||
var avail = notif[1]['availability'];
|
||||
var vroom = Object.keys(avail)[0];
|
||||
var day = Object.keys(avail[vroom])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var availability = {};
|
||||
availability[vroom] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'avail': avail[vroom][day][0],
|
||||
'no_ota': avail[vroom][day][1],
|
||||
'id': avail[vroom][day][2]
|
||||
}];
|
||||
this._hcalendar.addAvailability(availability);
|
||||
break;
|
||||
case 'pricelist':
|
||||
var prices = notif[1]['price'];
|
||||
var pricelist_id = Object.keys(prices)[0];
|
||||
var pr = {};
|
||||
for (var price of prices[pricelist_id]) {
|
||||
pr[price['room']] = [];
|
||||
var days = Object.keys(price['days']);
|
||||
for (var day of days) {
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
pr[price['room']].push({
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'price': price['days'][day],
|
||||
'id': price['id']
|
||||
});
|
||||
}
|
||||
}
|
||||
this._hcalendar.addPricelist(pr);
|
||||
break;
|
||||
case 'restriction':
|
||||
// FIXME: Expected one day and one vroom
|
||||
var restriction = notif[1]['restriction'];
|
||||
var vroom = Object.keys(restriction)[0];
|
||||
var day = Object.keys(restriction[vroom])[0];
|
||||
var dt = HotelCalendarManagement.toMoment(day);
|
||||
var rest = {};
|
||||
rest[vroom] = [{
|
||||
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
|
||||
'min_stay': restriction[vroom][day][0],
|
||||
'min_stay_arrival': restriction[vroom][day][1],
|
||||
'max_stay': restriction[vroom][day][2],
|
||||
'max_stay_arrival': restriction[vroom][day][3],
|
||||
'closed': restriction[vroom][day][4],
|
||||
'closed_arrival': restriction[vroom][day][5],
|
||||
'closed_departure': restriction[vroom][day][6],
|
||||
'id': restriction[vroom][day][7]
|
||||
}];
|
||||
this._hcalendar.addRestrictions(rest);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
reload_hcalendar_management: function() {
|
||||
var self = this;
|
||||
var params = this.generate_params();
|
||||
var oparams = [params['dates'][0], params['dates'][1], params['prices'], params['restrictions'], false];
|
||||
this._model.call('get_hcalendar_all_data', oparams).then(function(results){
|
||||
self._days_tooltips = results['events'];
|
||||
self._hcalendar.setData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']);
|
||||
self._assign_extra_info();
|
||||
});
|
||||
this._last_dates = params['dates'];
|
||||
this.$CalendarHeaderDays = this.$el.find("div.table-vroom-data-header");
|
||||
this._on_scroll(); // FIXME: Workaround for update sticky header
|
||||
},
|
||||
|
||||
generate_params: function() {
|
||||
var fullDomain = [];
|
||||
var prices = this.$el.find('#mpms-search #price_list').val();
|
||||
var restrictions = this.$el.find('#mpms-search #restriction_list').val();
|
||||
|
||||
var $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
|
||||
var $dateTimePickerEnd = this.$el.find('#mpms-search #date_end');
|
||||
|
||||
var date_begin = $dateTimePickerBegin.data("DateTimePicker").getDate().set({'hour': 0, 'minute': 0, 'second': 0}).clone().utc().format(ODOO_DATE_MOMENT_FORMAT);
|
||||
var date_end = $dateTimePickerEnd.data("DateTimePicker").getDate().set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc().format(ODOO_DATE_MOMENT_FORMAT);
|
||||
|
||||
return {
|
||||
'dates': [date_begin, date_end],
|
||||
'prices': prices,
|
||||
'restrictions': restrictions
|
||||
};
|
||||
},
|
||||
|
||||
_check_unsaved_changes: function(fnCallback) {
|
||||
var self = this;
|
||||
var btn_save = this.$el.find("#btn_save_changes");
|
||||
if (!btn_save.hasClass('need-save')) {
|
||||
btn_save.removeClass('need-save');
|
||||
fnCallback();
|
||||
return;
|
||||
}
|
||||
|
||||
new Dialog(self, {
|
||||
title: _t("Unsaved Changes!"),
|
||||
buttons: [
|
||||
{
|
||||
text: _t("Yes, save it"),
|
||||
classes: 'btn-primary',
|
||||
close: true,
|
||||
click: function() {
|
||||
self.save_changes();
|
||||
fnCallback();
|
||||
}
|
||||
},
|
||||
{
|
||||
text: _t("No"),
|
||||
close: true,
|
||||
click: function() {
|
||||
btn_save.removeClass('need-save');
|
||||
fnCallback();
|
||||
}
|
||||
}
|
||||
],
|
||||
$content: QWeb.render('HotelCalendarManagement.UnsavedChanges', {})
|
||||
}).open();
|
||||
},
|
||||
|
||||
_findBootstrapEnvironment: function() {
|
||||
var envs = ['xs', 'sm', 'md', 'lg'];
|
||||
|
||||
var $el = $('<div>');
|
||||
$el.appendTo($('body'));
|
||||
|
||||
for (var i = envs.length - 1; i >= 0; i--) {
|
||||
var env = envs[i];
|
||||
|
||||
$el.addClass('hidden-'+env);
|
||||
if ($el.is(':hidden')) {
|
||||
$el.remove();
|
||||
return env;
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
_assign_extra_info: function() {
|
||||
var self = this;
|
||||
|
||||
$(this._hcalendar.etableHeader).find('.hcal-cell-header-day').each(function(index, elm){
|
||||
var $elm = $(elm);
|
||||
var cdate = HotelCalendar.toMoment($elm.data('hcalDate'), L10N_DATE_MOMENT_FORMAT);
|
||||
var data = _.filter(self._days_tooltips, function(item) {
|
||||
var ndate = HotelCalendar.toMoment(item[2], ODOO_DATE_MOMENT_FORMAT);
|
||||
return ndate.isSame(cdate, 'd');
|
||||
});
|
||||
if (data.length > 0) {
|
||||
$elm.addClass('hcal-event-day');
|
||||
$elm.on("mouseenter", function(data){
|
||||
var $this = $(this);
|
||||
if (data.length > 0) {
|
||||
var qdict = {
|
||||
'date': $this.data('hcalDate'),
|
||||
'events': _.map(data, function(item){
|
||||
return {
|
||||
'name': item[1],
|
||||
'date': item[2],
|
||||
'location': item[3]
|
||||
};
|
||||
})
|
||||
};
|
||||
$this.attr('title', '');
|
||||
$this.tooltip({
|
||||
animation: true,
|
||||
html: true,
|
||||
placement: 'bottom',
|
||||
title: QWeb.render('HotelCalendar.TooltipEvent', qdict)
|
||||
}).tooltip('show');
|
||||
}
|
||||
}.bind(elm, data));
|
||||
}
|
||||
});
|
||||
},
|
||||
});
|
||||
|
||||
Core.view_registry.add('mpms', HotelCalendarManagementView);
|
||||
return HotelCalendarManagementView;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,93 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.MPMSCalendarView', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractView = require('web.AbstractView'),
|
||||
MPMSCalendarModel = require('hotel_calendar.MPMSCalendarModel'),
|
||||
MPMSCalendarController = require('hotel_calendar.MPMSCalendarController'),
|
||||
MPMSCalendarRenderer = require('hotel_calendar.MPMSCalendarRenderer'),
|
||||
ViewRegistry = require('web.view_registry'),
|
||||
SystrayMenu = require('web.SystrayMenu'),
|
||||
ControlPanel = require('web.ControlPanel'),
|
||||
Widget = require('web.Widget'),
|
||||
Session = require('web.session'),
|
||||
Core = require('web.core'),
|
||||
|
||||
_lt = Core._lt,
|
||||
QWeb = Core.qweb;
|
||||
|
||||
/* HIDE CONTROL PANEL */
|
||||
/* FIXME: Look's like a hackish solution */
|
||||
ControlPanel.include({
|
||||
update: function(status, options) {
|
||||
if (typeof options === 'undefined') {
|
||||
options = {};
|
||||
}
|
||||
if (typeof options.toHide === 'undefined')
|
||||
options.toHide = false;
|
||||
var action_stack = this.getParent().action_stack;
|
||||
if (action_stack && action_stack.length) {
|
||||
var active_action = action_stack[action_stack.length-1];
|
||||
if (active_action.widget && active_action.widget.active_view &&
|
||||
active_action.widget.active_view.type === 'mpms'){
|
||||
options.toHide = true;
|
||||
}
|
||||
}
|
||||
this._super(status, options);
|
||||
this._toggle_visibility(!options.toHide);
|
||||
}
|
||||
});
|
||||
|
||||
var MPMSCalendarView = AbstractView.extend({
|
||||
display_name: _lt('Calendar MPMS'),
|
||||
icon: 'fa-calendar',
|
||||
jsLibs: ['/hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js'],
|
||||
cssLibs: [
|
||||
'/hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css',
|
||||
'/hotel_calendar/static/src/lib/hcalendar/css/hcalendar_management.css'
|
||||
],
|
||||
config: {
|
||||
Model: MPMSCalendarModel,
|
||||
Controller: MPMSCalendarController,
|
||||
Renderer: MPMSCalendarRenderer,
|
||||
},
|
||||
|
||||
init: function (viewInfo, params) {
|
||||
this._super.apply(this, arguments);
|
||||
var arch = viewInfo.arch;
|
||||
var fields = viewInfo.fields;
|
||||
var attrs = arch.attrs;
|
||||
|
||||
// If form_view_id is set, then the calendar view will open a form view
|
||||
// with this id, when it needs to edit or create an event.
|
||||
this.controllerParams.formViewId =
|
||||
attrs.form_view_id ? parseInt(attrs.form_view_id, 10) : false;
|
||||
if (!this.controllerParams.formViewId && params.action) {
|
||||
var formViewDescr = _.find(params.action.views, function (v) {
|
||||
return v[1] === 'form';
|
||||
});
|
||||
if (formViewDescr) {
|
||||
this.controllerParams.formViewId = formViewDescr[0];
|
||||
}
|
||||
}
|
||||
|
||||
this.controllerParams.readonlyFormViewId = !attrs.readonly_form_view_id || !utils.toBoolElse(attrs.readonly_form_view_id, true) ? false : attrs.readonly_form_view_id;
|
||||
this.controllerParams.context = params.context || {};
|
||||
this.controllerParams.displayName = params.action && params.action.name;
|
||||
|
||||
this.rendererParams.model = viewInfo.model;
|
||||
|
||||
this.loadParams.fields = fields;
|
||||
this.loadParams.fieldsInfo = viewInfo.fieldsInfo;
|
||||
this.loadParams.creatable = false;
|
||||
|
||||
this.loadParams.mode = attrs.mode;
|
||||
},
|
||||
});
|
||||
|
||||
ViewRegistry.add('mpms', MPMSCalendarView);
|
||||
|
||||
return MPMSCalendarView;
|
||||
|
||||
});
|
||||
20
hotel_calendar/static/src/js/views/constants.js
Normal file
20
hotel_calendar/static/src/js/views/constants.js
Normal file
@@ -0,0 +1,20 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.Constants', function (require) {
|
||||
"use strict";
|
||||
|
||||
var Core = require('web.core'),
|
||||
Time = require('web.time'),
|
||||
|
||||
l10n = Core._t.database.parameters;
|
||||
|
||||
return {
|
||||
ODOO_DATE_MOMENT_FORMAT: 'YYYY-MM-DD',
|
||||
ODOO_DATETIME_MOMENT_FORMAT: 'YYYY-MM-DD HH:mm:ss',
|
||||
L10N_DATE_MOMENT_FORMAT: "DD/MM/YYYY", //FIXME: Time.strftime_to_moment_format(l10n.date_format),
|
||||
L10N_DATETIME_MOMENT_FORMAT: 'DD/MM/YYYY ' + Time.strftime_to_moment_format(l10n.time_format),
|
||||
|
||||
CURRENCY_SYMBOL: "€",
|
||||
};
|
||||
|
||||
});
|
||||
985
hotel_calendar/static/src/lib/bootbox.js
vendored
Normal file
985
hotel_calendar/static/src/lib/bootbox.js
vendored
Normal file
@@ -0,0 +1,985 @@
|
||||
/**
|
||||
* bootbox.js [v4.4.0]
|
||||
*
|
||||
* http://bootboxjs.com/license.txt
|
||||
*/
|
||||
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/180
|
||||
// @see https://github.com/makeusabrew/bootbox/issues/186
|
||||
(function (root, factory) {
|
||||
|
||||
"use strict";
|
||||
if (typeof define === "function" && define.amd) {
|
||||
// AMD. Register as an anonymous module.
|
||||
define(["jquery"], factory);
|
||||
} else if (typeof exports === "object") {
|
||||
// Node. Does not work with strict CommonJS, but
|
||||
// only CommonJS-like environments that support module.exports,
|
||||
// like Node.
|
||||
module.exports = factory(require("jquery"));
|
||||
} else {
|
||||
// Browser globals (root is window)
|
||||
root.bootbox = factory(root.jQuery);
|
||||
}
|
||||
|
||||
}(this, function init($, undefined) {
|
||||
|
||||
"use strict";
|
||||
|
||||
// the base DOM structure needed to create a modal
|
||||
var templates = {
|
||||
dialog:
|
||||
"<div class='bootbox modal' tabindex='-1' role='dialog'>" +
|
||||
"<div class='modal-dialog'>" +
|
||||
"<div class='modal-content'>" +
|
||||
"<div class='modal-body'><div class='bootbox-body'></div></div>" +
|
||||
"</div>" +
|
||||
"</div>" +
|
||||
"</div>",
|
||||
header:
|
||||
"<div class='modal-header'>" +
|
||||
"<h4 class='modal-title'></h4>" +
|
||||
"</div>",
|
||||
footer:
|
||||
"<div class='modal-footer'></div>",
|
||||
closeButton:
|
||||
"<button type='button' class='bootbox-close-button close' data-dismiss='modal' aria-hidden='true'>×</button>",
|
||||
form:
|
||||
"<form class='bootbox-form'></form>",
|
||||
inputs: {
|
||||
text:
|
||||
"<input class='bootbox-input bootbox-input-text form-control' autocomplete=off type=text />",
|
||||
textarea:
|
||||
"<textarea class='bootbox-input bootbox-input-textarea form-control'></textarea>",
|
||||
email:
|
||||
"<input class='bootbox-input bootbox-input-email form-control' autocomplete='off' type='email' />",
|
||||
select:
|
||||
"<select class='bootbox-input bootbox-input-select form-control'></select>",
|
||||
checkbox:
|
||||
"<div class='checkbox'><label><input class='bootbox-input bootbox-input-checkbox' type='checkbox' /></label></div>",
|
||||
date:
|
||||
"<input class='bootbox-input bootbox-input-date form-control' autocomplete=off type='date' />",
|
||||
time:
|
||||
"<input class='bootbox-input bootbox-input-time form-control' autocomplete=off type='time' />",
|
||||
number:
|
||||
"<input class='bootbox-input bootbox-input-number form-control' autocomplete=off type='number' />",
|
||||
password:
|
||||
"<input class='bootbox-input bootbox-input-password form-control' autocomplete='off' type='password' />"
|
||||
}
|
||||
};
|
||||
|
||||
var defaults = {
|
||||
// default language
|
||||
locale: "en",
|
||||
// show backdrop or not. Default to static so user has to interact with dialog
|
||||
backdrop: "static",
|
||||
// animate the modal in/out
|
||||
animate: true,
|
||||
// additional class string applied to the top level dialog
|
||||
className: null,
|
||||
// whether or not to include a close button
|
||||
closeButton: true,
|
||||
// show the dialog immediately by default
|
||||
show: true,
|
||||
// dialog container
|
||||
container: "body"
|
||||
};
|
||||
|
||||
// our public object; augmented after our private API
|
||||
var exports = {};
|
||||
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
function _t(key) {
|
||||
var locale = locales[defaults.locale];
|
||||
return locale ? locale[key] : locales.en[key];
|
||||
}
|
||||
|
||||
function processCallback(e, dialog, callback) {
|
||||
e.stopPropagation();
|
||||
e.preventDefault();
|
||||
|
||||
// by default we assume a callback will get rid of the dialog,
|
||||
// although it is given the opportunity to override this
|
||||
|
||||
// so, if the callback can be invoked and it *explicitly returns false*
|
||||
// then we'll set a flag to keep the dialog active...
|
||||
var preserveDialog = $.isFunction(callback) && callback.call(dialog, e) === false;
|
||||
|
||||
// ... otherwise we'll bin it
|
||||
if (!preserveDialog) {
|
||||
dialog.modal("hide");
|
||||
}
|
||||
}
|
||||
|
||||
function getKeyLength(obj) {
|
||||
// @TODO defer to Object.keys(x).length if available?
|
||||
var k, t = 0;
|
||||
for (k in obj) {
|
||||
t ++;
|
||||
}
|
||||
return t;
|
||||
}
|
||||
|
||||
function each(collection, iterator) {
|
||||
var index = 0;
|
||||
$.each(collection, function(key, value) {
|
||||
iterator(key, value, index++);
|
||||
});
|
||||
}
|
||||
|
||||
function sanitize(options) {
|
||||
var buttons;
|
||||
var total;
|
||||
|
||||
if (typeof options !== "object") {
|
||||
throw new Error("Please supply an object of options");
|
||||
}
|
||||
|
||||
if (!options.message) {
|
||||
throw new Error("Please specify a message");
|
||||
}
|
||||
|
||||
// make sure any supplied options take precedence over defaults
|
||||
options = $.extend({}, defaults, options);
|
||||
|
||||
if (!options.buttons) {
|
||||
options.buttons = {};
|
||||
}
|
||||
|
||||
buttons = options.buttons;
|
||||
|
||||
total = getKeyLength(buttons);
|
||||
|
||||
each(buttons, function(key, button, index) {
|
||||
|
||||
if ($.isFunction(button)) {
|
||||
// short form, assume value is our callback. Since button
|
||||
// isn't an object it isn't a reference either so re-assign it
|
||||
button = buttons[key] = {
|
||||
callback: button
|
||||
};
|
||||
}
|
||||
|
||||
// before any further checks make sure by now button is the correct type
|
||||
if ($.type(button) !== "object") {
|
||||
throw new Error("button with key " + key + " must be an object");
|
||||
}
|
||||
|
||||
if (!button.label) {
|
||||
// the lack of an explicit label means we'll assume the key is good enough
|
||||
button.label = key;
|
||||
}
|
||||
|
||||
if (!button.className) {
|
||||
if (total <= 2 && index === total-1) {
|
||||
// always add a primary to the main option in a two-button dialog
|
||||
button.className = "btn-primary";
|
||||
} else {
|
||||
button.className = "btn-default";
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* map a flexible set of arguments into a single returned object
|
||||
* if args.length is already one just return it, otherwise
|
||||
* use the properties argument to map the unnamed args to
|
||||
* object properties
|
||||
* so in the latter case:
|
||||
* mapArguments(["foo", $.noop], ["message", "callback"])
|
||||
* -> { message: "foo", callback: $.noop }
|
||||
*/
|
||||
function mapArguments(args, properties) {
|
||||
var argn = args.length;
|
||||
var options = {};
|
||||
|
||||
if (argn < 1 || argn > 2) {
|
||||
throw new Error("Invalid argument length");
|
||||
}
|
||||
|
||||
if (argn === 2 || typeof args[0] === "string") {
|
||||
options[properties[0]] = args[0];
|
||||
options[properties[1]] = args[1];
|
||||
} else {
|
||||
options = args[0];
|
||||
}
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
/**
|
||||
* merge a set of default dialog options with user supplied arguments
|
||||
*/
|
||||
function mergeArguments(defaults, args, properties) {
|
||||
return $.extend(
|
||||
// deep merge
|
||||
true,
|
||||
// ensure the target is an empty, unreferenced object
|
||||
{},
|
||||
// the base options object for this type of dialog (often just buttons)
|
||||
defaults,
|
||||
// args could be an object or array; if it's an array properties will
|
||||
// map it to a proper options object
|
||||
mapArguments(
|
||||
args,
|
||||
properties
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* this entry-level method makes heavy use of composition to take a simple
|
||||
* range of inputs and return valid options suitable for passing to bootbox.dialog
|
||||
*/
|
||||
function mergeDialogOptions(className, labels, properties, args) {
|
||||
// build up a base set of dialog properties
|
||||
var baseOptions = {
|
||||
className: "bootbox-" + className,
|
||||
buttons: createLabels.apply(null, labels)
|
||||
};
|
||||
|
||||
// ensure the buttons properties generated, *after* merging
|
||||
// with user args are still valid against the supplied labels
|
||||
return validateButtons(
|
||||
// merge the generated base properties with user supplied arguments
|
||||
mergeArguments(
|
||||
baseOptions,
|
||||
args,
|
||||
// if args.length > 1, properties specify how each arg maps to an object key
|
||||
properties
|
||||
),
|
||||
labels
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* from a given list of arguments return a suitable object of button labels
|
||||
* all this does is normalise the given labels and translate them where possible
|
||||
* e.g. "ok", "confirm" -> { ok: "OK, cancel: "Annuleren" }
|
||||
*/
|
||||
function createLabels() {
|
||||
var buttons = {};
|
||||
|
||||
for (var i = 0, j = arguments.length; i < j; i++) {
|
||||
var argument = arguments[i];
|
||||
var key = argument.toLowerCase();
|
||||
var value = argument.toUpperCase();
|
||||
|
||||
buttons[key] = {
|
||||
label: _t(value)
|
||||
};
|
||||
}
|
||||
|
||||
return buttons;
|
||||
}
|
||||
|
||||
function validateButtons(options, buttons) {
|
||||
var allowedButtons = {};
|
||||
each(buttons, function(key, value) {
|
||||
allowedButtons[value] = true;
|
||||
});
|
||||
|
||||
each(options.buttons, function(key) {
|
||||
if (allowedButtons[key] === undefined) {
|
||||
throw new Error("button key " + key + " is not allowed (options are " + buttons.join("\n") + ")");
|
||||
}
|
||||
});
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
exports.alert = function() {
|
||||
var options;
|
||||
|
||||
options = mergeDialogOptions("alert", ["ok"], ["message", "callback"], arguments);
|
||||
|
||||
if (options.callback && !$.isFunction(options.callback)) {
|
||||
throw new Error("alert requires callback property to be a function when provided");
|
||||
}
|
||||
|
||||
/**
|
||||
* overrides
|
||||
*/
|
||||
options.buttons.ok.callback = options.onEscape = function() {
|
||||
if ($.isFunction(options.callback)) {
|
||||
return options.callback.call(this);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
return exports.dialog(options);
|
||||
};
|
||||
|
||||
exports.confirm = function() {
|
||||
var options;
|
||||
|
||||
options = mergeDialogOptions("confirm", ["cancel", "confirm"], ["message", "callback"], arguments);
|
||||
|
||||
/**
|
||||
* overrides; undo anything the user tried to set they shouldn't have
|
||||
*/
|
||||
options.buttons.cancel.callback = options.onEscape = function() {
|
||||
return options.callback.call(this, false);
|
||||
};
|
||||
|
||||
options.buttons.confirm.callback = function() {
|
||||
return options.callback.call(this, true);
|
||||
};
|
||||
|
||||
// confirm specific validation
|
||||
if (!$.isFunction(options.callback)) {
|
||||
throw new Error("confirm requires a callback");
|
||||
}
|
||||
|
||||
return exports.dialog(options);
|
||||
};
|
||||
|
||||
exports.prompt = function() {
|
||||
var options;
|
||||
var defaults;
|
||||
var dialog;
|
||||
var form;
|
||||
var input;
|
||||
var shouldShow;
|
||||
var inputOptions;
|
||||
|
||||
// we have to create our form first otherwise
|
||||
// its value is undefined when gearing up our options
|
||||
// @TODO this could be solved by allowing message to
|
||||
// be a function instead...
|
||||
form = $(templates.form);
|
||||
|
||||
// prompt defaults are more complex than others in that
|
||||
// users can override more defaults
|
||||
// @TODO I don't like that prompt has to do a lot of heavy
|
||||
// lifting which mergeDialogOptions can *almost* support already
|
||||
// just because of 'value' and 'inputType' - can we refactor?
|
||||
defaults = {
|
||||
className: "bootbox-prompt",
|
||||
buttons: createLabels("cancel", "confirm"),
|
||||
value: "",
|
||||
inputType: "text"
|
||||
};
|
||||
|
||||
options = validateButtons(
|
||||
mergeArguments(defaults, arguments, ["title", "callback"]),
|
||||
["cancel", "confirm"]
|
||||
);
|
||||
|
||||
// capture the user's show value; we always set this to false before
|
||||
// spawning the dialog to give us a chance to attach some handlers to
|
||||
// it, but we need to make sure we respect a preference not to show it
|
||||
shouldShow = (options.show === undefined) ? true : options.show;
|
||||
|
||||
/**
|
||||
* overrides; undo anything the user tried to set they shouldn't have
|
||||
*/
|
||||
options.message = form;
|
||||
|
||||
options.buttons.cancel.callback = options.onEscape = function() {
|
||||
return options.callback.call(this, null);
|
||||
};
|
||||
|
||||
options.buttons.confirm.callback = function() {
|
||||
var value;
|
||||
|
||||
switch (options.inputType) {
|
||||
case "text":
|
||||
case "textarea":
|
||||
case "email":
|
||||
case "select":
|
||||
case "date":
|
||||
case "time":
|
||||
case "number":
|
||||
case "password":
|
||||
value = input.val();
|
||||
break;
|
||||
|
||||
case "checkbox":
|
||||
var checkedItems = input.find("input:checked");
|
||||
|
||||
// we assume that checkboxes are always multiple,
|
||||
// hence we default to an empty array
|
||||
value = [];
|
||||
|
||||
each(checkedItems, function(_, item) {
|
||||
value.push($(item).val());
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
return options.callback.call(this, value);
|
||||
};
|
||||
|
||||
options.show = false;
|
||||
|
||||
// prompt specific validation
|
||||
if (!options.title) {
|
||||
throw new Error("prompt requires a title");
|
||||
}
|
||||
|
||||
if (!$.isFunction(options.callback)) {
|
||||
throw new Error("prompt requires a callback");
|
||||
}
|
||||
|
||||
if (!templates.inputs[options.inputType]) {
|
||||
throw new Error("invalid prompt type");
|
||||
}
|
||||
|
||||
// create the input based on the supplied type
|
||||
input = $(templates.inputs[options.inputType]);
|
||||
|
||||
switch (options.inputType) {
|
||||
case "text":
|
||||
case "textarea":
|
||||
case "email":
|
||||
case "date":
|
||||
case "time":
|
||||
case "number":
|
||||
case "password":
|
||||
input.val(options.value);
|
||||
break;
|
||||
|
||||
case "select":
|
||||
var groups = {};
|
||||
inputOptions = options.inputOptions || [];
|
||||
|
||||
if (!$.isArray(inputOptions)) {
|
||||
throw new Error("Please pass an array of input options");
|
||||
}
|
||||
|
||||
if (!inputOptions.length) {
|
||||
throw new Error("prompt with select requires options");
|
||||
}
|
||||
|
||||
each(inputOptions, function(_, option) {
|
||||
|
||||
// assume the element to attach to is the input...
|
||||
var elem = input;
|
||||
|
||||
if (option.value === undefined || option.text === undefined) {
|
||||
throw new Error("given options in wrong format");
|
||||
}
|
||||
|
||||
// ... but override that element if this option sits in a group
|
||||
|
||||
if (option.group) {
|
||||
// initialise group if necessary
|
||||
if (!groups[option.group]) {
|
||||
groups[option.group] = $("<optgroup/>").attr("label", option.group);
|
||||
}
|
||||
|
||||
elem = groups[option.group];
|
||||
}
|
||||
|
||||
elem.append("<option value='" + option.value + "'>" + option.text + "</option>");
|
||||
});
|
||||
|
||||
each(groups, function(_, group) {
|
||||
input.append(group);
|
||||
});
|
||||
|
||||
// safe to set a select's value as per a normal input
|
||||
input.val(options.value);
|
||||
break;
|
||||
|
||||
case "checkbox":
|
||||
var values = $.isArray(options.value) ? options.value : [options.value];
|
||||
inputOptions = options.inputOptions || [];
|
||||
|
||||
if (!inputOptions.length) {
|
||||
throw new Error("prompt with checkbox requires options");
|
||||
}
|
||||
|
||||
if (!inputOptions[0].value || !inputOptions[0].text) {
|
||||
throw new Error("given options in wrong format");
|
||||
}
|
||||
|
||||
// checkboxes have to nest within a containing element, so
|
||||
// they break the rules a bit and we end up re-assigning
|
||||
// our 'input' element to this container instead
|
||||
input = $("<div/>");
|
||||
|
||||
each(inputOptions, function(_, option) {
|
||||
var checkbox = $(templates.inputs[options.inputType]);
|
||||
|
||||
checkbox.find("input").attr("value", option.value);
|
||||
checkbox.find("label").append(option.text);
|
||||
|
||||
// we've ensured values is an array so we can always iterate over it
|
||||
each(values, function(_, value) {
|
||||
if (value === option.value) {
|
||||
checkbox.find("input").prop("checked", true);
|
||||
}
|
||||
});
|
||||
|
||||
input.append(checkbox);
|
||||
});
|
||||
break;
|
||||
}
|
||||
|
||||
// @TODO provide an attributes option instead
|
||||
// and simply map that as keys: vals
|
||||
if (options.placeholder) {
|
||||
input.attr("placeholder", options.placeholder);
|
||||
}
|
||||
|
||||
if (options.pattern) {
|
||||
input.attr("pattern", options.pattern);
|
||||
}
|
||||
|
||||
if (options.maxlength) {
|
||||
input.attr("maxlength", options.maxlength);
|
||||
}
|
||||
|
||||
// now place it in our form
|
||||
form.append(input);
|
||||
|
||||
form.on("submit", function(e) {
|
||||
e.preventDefault();
|
||||
// Fix for SammyJS (or similar JS routing library) hijacking the form post.
|
||||
e.stopPropagation();
|
||||
// @TODO can we actually click *the* button object instead?
|
||||
// e.g. buttons.confirm.click() or similar
|
||||
dialog.find(".btn-primary").click();
|
||||
});
|
||||
|
||||
dialog = exports.dialog(options);
|
||||
|
||||
// clear the existing handler focusing the submit button...
|
||||
dialog.off("shown.bs.modal");
|
||||
|
||||
// ...and replace it with one focusing our input, if possible
|
||||
dialog.on("shown.bs.modal", function() {
|
||||
// need the closure here since input isn't
|
||||
// an object otherwise
|
||||
input.focus();
|
||||
});
|
||||
|
||||
if (shouldShow === true) {
|
||||
dialog.modal("show");
|
||||
}
|
||||
|
||||
return dialog;
|
||||
};
|
||||
|
||||
exports.dialog = function(options) {
|
||||
options = sanitize(options);
|
||||
|
||||
var dialog = $(templates.dialog);
|
||||
var innerDialog = dialog.find(".modal-dialog");
|
||||
var body = dialog.find(".modal-body");
|
||||
var buttons = options.buttons;
|
||||
var buttonStr = "";
|
||||
var callbacks = {
|
||||
onEscape: options.onEscape
|
||||
};
|
||||
|
||||
if ($.fn.modal === undefined) {
|
||||
throw new Error(
|
||||
"$.fn.modal is not defined; please double check you have included " +
|
||||
"the Bootstrap JavaScript library. See http://getbootstrap.com/javascript/ " +
|
||||
"for more details."
|
||||
);
|
||||
}
|
||||
|
||||
each(buttons, function(key, button) {
|
||||
|
||||
// @TODO I don't like this string appending to itself; bit dirty. Needs reworking
|
||||
// can we just build up button elements instead? slower but neater. Then button
|
||||
// can just become a template too
|
||||
buttonStr += "<button data-bb-handler='" + key + "' type='button' class='btn " + button.className + "'>" + button.label + "</button>";
|
||||
callbacks[key] = button.callback;
|
||||
});
|
||||
|
||||
body.find(".bootbox-body").html(options.message);
|
||||
|
||||
if (options.animate === true) {
|
||||
dialog.addClass("fade");
|
||||
}
|
||||
|
||||
if (options.className) {
|
||||
dialog.addClass(options.className);
|
||||
}
|
||||
|
||||
if (options.size === "large") {
|
||||
innerDialog.addClass("modal-lg");
|
||||
} else if (options.size === "small") {
|
||||
innerDialog.addClass("modal-sm");
|
||||
}
|
||||
|
||||
if (options.title) {
|
||||
body.before(templates.header);
|
||||
}
|
||||
|
||||
if (options.closeButton) {
|
||||
var closeButton = $(templates.closeButton);
|
||||
|
||||
if (options.title) {
|
||||
dialog.find(".modal-header").prepend(closeButton);
|
||||
} else {
|
||||
closeButton.css("margin-top", "-10px").prependTo(body);
|
||||
}
|
||||
}
|
||||
|
||||
if (options.title) {
|
||||
dialog.find(".modal-title").html(options.title);
|
||||
}
|
||||
|
||||
if (buttonStr.length) {
|
||||
body.after(templates.footer);
|
||||
dialog.find(".modal-footer").html(buttonStr);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Bootstrap event listeners; used handle extra
|
||||
* setup & teardown required after the underlying
|
||||
* modal has performed certain actions
|
||||
*/
|
||||
|
||||
dialog.on("hidden.bs.modal", function(e) {
|
||||
// ensure we don't accidentally intercept hidden events triggered
|
||||
// by children of the current dialog. We shouldn't anymore now BS
|
||||
// namespaces its events; but still worth doing
|
||||
if (e.target === this) {
|
||||
dialog.remove();
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
dialog.on("show.bs.modal", function() {
|
||||
// sadly this doesn't work; show is called *just* before
|
||||
// the backdrop is added so we'd need a setTimeout hack or
|
||||
// otherwise... leaving in as would be nice
|
||||
if (options.backdrop) {
|
||||
dialog.next(".modal-backdrop").addClass("bootbox-backdrop");
|
||||
}
|
||||
});
|
||||
*/
|
||||
|
||||
dialog.on("shown.bs.modal", function() {
|
||||
dialog.find(".btn-primary:first").focus();
|
||||
});
|
||||
|
||||
/**
|
||||
* Bootbox event listeners; experimental and may not last
|
||||
* just an attempt to decouple some behaviours from their
|
||||
* respective triggers
|
||||
*/
|
||||
|
||||
if (options.backdrop !== "static") {
|
||||
// A boolean true/false according to the Bootstrap docs
|
||||
// should show a dialog the user can dismiss by clicking on
|
||||
// the background.
|
||||
// We always only ever pass static/false to the actual
|
||||
// $.modal function because with `true` we can't trap
|
||||
// this event (the .modal-backdrop swallows it)
|
||||
// However, we still want to sort of respect true
|
||||
// and invoke the escape mechanism instead
|
||||
dialog.on("click.dismiss.bs.modal", function(e) {
|
||||
// @NOTE: the target varies in >= 3.3.x releases since the modal backdrop
|
||||
// moved *inside* the outer dialog rather than *alongside* it
|
||||
if (dialog.children(".modal-backdrop").length) {
|
||||
e.currentTarget = dialog.children(".modal-backdrop").get(0);
|
||||
}
|
||||
|
||||
if (e.target !== e.currentTarget) {
|
||||
return;
|
||||
}
|
||||
|
||||
dialog.trigger("escape.close.bb");
|
||||
});
|
||||
}
|
||||
|
||||
dialog.on("escape.close.bb", function(e) {
|
||||
if (callbacks.onEscape) {
|
||||
processCallback(e, dialog, callbacks.onEscape);
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Standard jQuery event listeners; used to handle user
|
||||
* interaction with our dialog
|
||||
*/
|
||||
|
||||
dialog.on("click", ".modal-footer button", function(e) {
|
||||
var callbackKey = $(this).data("bb-handler");
|
||||
|
||||
processCallback(e, dialog, callbacks[callbackKey]);
|
||||
});
|
||||
|
||||
dialog.on("click", ".bootbox-close-button", function(e) {
|
||||
// onEscape might be falsy but that's fine; the fact is
|
||||
// if the user has managed to click the close button we
|
||||
// have to close the dialog, callback or not
|
||||
processCallback(e, dialog, callbacks.onEscape);
|
||||
});
|
||||
|
||||
dialog.on("keyup", function(e) {
|
||||
if (e.which === 27) {
|
||||
dialog.trigger("escape.close.bb");
|
||||
}
|
||||
});
|
||||
|
||||
// the remainder of this method simply deals with adding our
|
||||
// dialogent to the DOM, augmenting it with Bootstrap's modal
|
||||
// functionality and then giving the resulting object back
|
||||
// to our caller
|
||||
|
||||
$(options.container).append(dialog);
|
||||
|
||||
dialog.modal({
|
||||
backdrop: options.backdrop ? "static": false,
|
||||
keyboard: false,
|
||||
show: false
|
||||
});
|
||||
|
||||
if (options.show) {
|
||||
dialog.modal("show");
|
||||
}
|
||||
|
||||
// @TODO should we return the raw element here or should
|
||||
// we wrap it in an object on which we can expose some neater
|
||||
// methods, e.g. var d = bootbox.alert(); d.hide(); instead
|
||||
// of d.modal("hide");
|
||||
|
||||
/*
|
||||
function BBDialog(elem) {
|
||||
this.elem = elem;
|
||||
}
|
||||
|
||||
BBDialog.prototype = {
|
||||
hide: function() {
|
||||
return this.elem.modal("hide");
|
||||
},
|
||||
show: function() {
|
||||
return this.elem.modal("show");
|
||||
}
|
||||
};
|
||||
*/
|
||||
|
||||
return dialog;
|
||||
|
||||
};
|
||||
|
||||
exports.setDefaults = function() {
|
||||
var values = {};
|
||||
|
||||
if (arguments.length === 2) {
|
||||
// allow passing of single key/value...
|
||||
values[arguments[0]] = arguments[1];
|
||||
} else {
|
||||
// ... and as an object too
|
||||
values = arguments[0];
|
||||
}
|
||||
|
||||
$.extend(defaults, values);
|
||||
};
|
||||
|
||||
exports.hideAll = function() {
|
||||
$(".bootbox").modal("hide");
|
||||
|
||||
return exports;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* standard locales. Please add more according to ISO 639-1 standard. Multiple language variants are
|
||||
* unlikely to be required. If this gets too large it can be split out into separate JS files.
|
||||
*/
|
||||
var locales = {
|
||||
bg_BG : {
|
||||
OK : "Ок",
|
||||
CANCEL : "Отказ",
|
||||
CONFIRM : "Потвърждавам"
|
||||
},
|
||||
br : {
|
||||
OK : "OK",
|
||||
CANCEL : "Cancelar",
|
||||
CONFIRM : "Sim"
|
||||
},
|
||||
cs : {
|
||||
OK : "OK",
|
||||
CANCEL : "Zrušit",
|
||||
CONFIRM : "Potvrdit"
|
||||
},
|
||||
da : {
|
||||
OK : "OK",
|
||||
CANCEL : "Annuller",
|
||||
CONFIRM : "Accepter"
|
||||
},
|
||||
de : {
|
||||
OK : "OK",
|
||||
CANCEL : "Abbrechen",
|
||||
CONFIRM : "Akzeptieren"
|
||||
},
|
||||
el : {
|
||||
OK : "Εντάξει",
|
||||
CANCEL : "Ακύρωση",
|
||||
CONFIRM : "Επιβεβαίωση"
|
||||
},
|
||||
en : {
|
||||
OK : "OK",
|
||||
CANCEL : "Cancel",
|
||||
CONFIRM : "OK"
|
||||
},
|
||||
es : {
|
||||
OK : "OK",
|
||||
CANCEL : "Cancelar",
|
||||
CONFIRM : "Aceptar"
|
||||
},
|
||||
et : {
|
||||
OK : "OK",
|
||||
CANCEL : "Katkesta",
|
||||
CONFIRM : "OK"
|
||||
},
|
||||
fa : {
|
||||
OK : "قبول",
|
||||
CANCEL : "لغو",
|
||||
CONFIRM : "تایید"
|
||||
},
|
||||
fi : {
|
||||
OK : "OK",
|
||||
CANCEL : "Peruuta",
|
||||
CONFIRM : "OK"
|
||||
},
|
||||
fr : {
|
||||
OK : "OK",
|
||||
CANCEL : "Annuler",
|
||||
CONFIRM : "D'accord"
|
||||
},
|
||||
he : {
|
||||
OK : "אישור",
|
||||
CANCEL : "ביטול",
|
||||
CONFIRM : "אישור"
|
||||
},
|
||||
hu : {
|
||||
OK : "OK",
|
||||
CANCEL : "Mégsem",
|
||||
CONFIRM : "Megerősít"
|
||||
},
|
||||
hr : {
|
||||
OK : "OK",
|
||||
CANCEL : "Odustani",
|
||||
CONFIRM : "Potvrdi"
|
||||
},
|
||||
id : {
|
||||
OK : "OK",
|
||||
CANCEL : "Batal",
|
||||
CONFIRM : "OK"
|
||||
},
|
||||
it : {
|
||||
OK : "OK",
|
||||
CANCEL : "Annulla",
|
||||
CONFIRM : "Conferma"
|
||||
},
|
||||
ja : {
|
||||
OK : "OK",
|
||||
CANCEL : "キャンセル",
|
||||
CONFIRM : "確認"
|
||||
},
|
||||
lt : {
|
||||
OK : "Gerai",
|
||||
CANCEL : "Atšaukti",
|
||||
CONFIRM : "Patvirtinti"
|
||||
},
|
||||
lv : {
|
||||
OK : "Labi",
|
||||
CANCEL : "Atcelt",
|
||||
CONFIRM : "Apstiprināt"
|
||||
},
|
||||
nl : {
|
||||
OK : "OK",
|
||||
CANCEL : "Annuleren",
|
||||
CONFIRM : "Accepteren"
|
||||
},
|
||||
no : {
|
||||
OK : "OK",
|
||||
CANCEL : "Avbryt",
|
||||
CONFIRM : "OK"
|
||||
},
|
||||
pl : {
|
||||
OK : "OK",
|
||||
CANCEL : "Anuluj",
|
||||
CONFIRM : "Potwierdź"
|
||||
},
|
||||
pt : {
|
||||
OK : "OK",
|
||||
CANCEL : "Cancelar",
|
||||
CONFIRM : "Confirmar"
|
||||
},
|
||||
ru : {
|
||||
OK : "OK",
|
||||
CANCEL : "Отмена",
|
||||
CONFIRM : "Применить"
|
||||
},
|
||||
sq : {
|
||||
OK : "OK",
|
||||
CANCEL : "Anulo",
|
||||
CONFIRM : "Prano"
|
||||
},
|
||||
sv : {
|
||||
OK : "OK",
|
||||
CANCEL : "Avbryt",
|
||||
CONFIRM : "OK"
|
||||
},
|
||||
th : {
|
||||
OK : "ตกลง",
|
||||
CANCEL : "ยกเลิก",
|
||||
CONFIRM : "ยืนยัน"
|
||||
},
|
||||
tr : {
|
||||
OK : "Tamam",
|
||||
CANCEL : "İptal",
|
||||
CONFIRM : "Onayla"
|
||||
},
|
||||
zh_CN : {
|
||||
OK : "OK",
|
||||
CANCEL : "取消",
|
||||
CONFIRM : "确认"
|
||||
},
|
||||
zh_TW : {
|
||||
OK : "OK",
|
||||
CANCEL : "取消",
|
||||
CONFIRM : "確認"
|
||||
}
|
||||
};
|
||||
|
||||
exports.addLocale = function(name, values) {
|
||||
$.each(["OK", "CANCEL", "CONFIRM"], function(_, v) {
|
||||
if (!values[v]) {
|
||||
throw new Error("Please supply a translation for '" + v + "'");
|
||||
}
|
||||
});
|
||||
|
||||
locales[name] = {
|
||||
OK: values.OK,
|
||||
CANCEL: values.CANCEL,
|
||||
CONFIRM: values.CONFIRM
|
||||
};
|
||||
|
||||
return exports;
|
||||
};
|
||||
|
||||
exports.removeLocale = function(name) {
|
||||
delete locales[name];
|
||||
|
||||
return exports;
|
||||
};
|
||||
|
||||
exports.setLocale = function(name) {
|
||||
return exports.setDefaults("locale", name);
|
||||
};
|
||||
|
||||
exports.init = function(_$) {
|
||||
return init(_$ || $);
|
||||
};
|
||||
|
||||
return exports;
|
||||
}));
|
||||
499
hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css
Normal file
499
hotel_calendar/static/src/lib/hcalendar/css/hcalendar.css
Normal file
@@ -0,0 +1,499 @@
|
||||
/*
|
||||
* Hotel Calendar JS v0.0.1a - 2017-2018
|
||||
* GNU Public License
|
||||
* Aloxa Solucions S.L. <info@aloxa.eu>
|
||||
* Alexandre Díaz <alex@aloxa.eu>
|
||||
*/
|
||||
|
||||
|
||||
/** ANIMATIONS **/
|
||||
@keyframes cell-invalid {
|
||||
0% {
|
||||
background: #ff0000;
|
||||
background: repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 40%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
background: -webkit-repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 40%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
background: -moz-repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 40%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
}
|
||||
50% {
|
||||
background: #ff0000;
|
||||
background: repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 40%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
background: -webkit-repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 35%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
background: -moz-repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 40%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
}
|
||||
100% {
|
||||
background: #ff0000;
|
||||
background: repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 30%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
background: -webkit-repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 30%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
background: -moz-repeating-linear-gradient(141deg,#ff0000 10%, #ff0000 30%, rgba(255,0,0,0.51) 30%, rgba(255,0,0,0.51) 50%);
|
||||
}
|
||||
}
|
||||
|
||||
#hcal_load {
|
||||
width: 100%;
|
||||
height: 90vh;
|
||||
text-align: center;
|
||||
line-height: 90vh;
|
||||
color: darkgray;
|
||||
}
|
||||
#hcal_load > span {
|
||||
line-height: 24px;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
#pms-search {
|
||||
position: fixed;
|
||||
z-index: 9;
|
||||
}
|
||||
|
||||
#pms-menu {
|
||||
background-color: white;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
#hcal_widget {
|
||||
max-height: 100%;
|
||||
}
|
||||
|
||||
#cal-pag-prev-plus, #cal-pag-prev, #cal-pag-selector, #cal-pag-next, #cal-pag-next-plus {
|
||||
min-height: 0px;
|
||||
}
|
||||
|
||||
.table-reservations-header {
|
||||
order: 1;
|
||||
flex-grow: 1;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.table-reservations {
|
||||
order: 2;
|
||||
flex-grow: 2;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
position: relative;
|
||||
max-height: 57vh;
|
||||
}
|
||||
.table-calcs-header {
|
||||
order: 3;
|
||||
flex-grow: 1;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
.table-calcs {
|
||||
order: 4;
|
||||
flex-grow: 2;
|
||||
overflow-y: scroll;
|
||||
overflow-x: hidden;
|
||||
max-height: 20vh;
|
||||
}
|
||||
.table-calcs input, .table-reservations-header input {
|
||||
border-radius: 0;
|
||||
border: 1px solid lightgray;
|
||||
width: 100%;
|
||||
}
|
||||
.table-calcs input {
|
||||
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: #0D5A8F;
|
||||
}
|
||||
.btn-hcal-3d {
|
||||
color: white;
|
||||
background-color: #7c7bad;
|
||||
border: 1px solid #cfcfdd;
|
||||
/*border-color: white black black white !important;*/
|
||||
}
|
||||
.btn-hcal-flat {
|
||||
background-color: #cfcfdd;
|
||||
border: 1px solid #cfcfdd;
|
||||
}
|
||||
|
||||
.hcal-warn-ob-indicator {
|
||||
position: absolute;
|
||||
background-color: red;
|
||||
color: yellow;
|
||||
border: 1px solid black;
|
||||
z-index: 9;
|
||||
width: 25px;
|
||||
height: 20px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.table-calcs-header .hcal-table, .table-reservations-header .hcal-table {
|
||||
height: 46px;
|
||||
}
|
||||
|
||||
.hcal-table, .hcal-table-day {
|
||||
border-collapse: initial !important;
|
||||
width: 100%;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.hcal-table > tbody {
|
||||
max-height: 50vh;
|
||||
overflow: scroll;
|
||||
}
|
||||
.hcal-table td {
|
||||
text-align: center;
|
||||
min-width: 100px;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
}
|
||||
.hcal-table a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.hcal-table tr:hover td:not(.hcal-unused-zone):not(.hcal-cell-highlight):not(.hcal-cell-current-day):not(.hcal-cell-end-week):not(.btn-hcal):not(.hcal-cell-invalid) {
|
||||
/*background-color: #F6F6F6;
|
||||
border: 5px solid red;*/
|
||||
}
|
||||
|
||||
.hcal-table tr:hover td.hcal-cell-room-type-group-item {
|
||||
background-color: #7c7bad80;
|
||||
color: white;
|
||||
}
|
||||
|
||||
.hcal-restriction-room-day {
|
||||
background-color: #b3218366 !important;
|
||||
}
|
||||
|
||||
.hcal-table-day {
|
||||
height: 100%;
|
||||
border-collapse: collapse !important;
|
||||
border: 0 dotted #cfcfcf;
|
||||
border-width: 2px 0;
|
||||
}
|
||||
/*.hcal-table-day tr:first-child td{
|
||||
border: 1px solid #727272 !important;
|
||||
border-width: 0 1px 0 0 !important;
|
||||
}
|
||||
.hcal-table tr:not(:last-child) .hcal-table-day tr:last-child td {
|
||||
border-style: solid;
|
||||
border-color: #727272 !important;
|
||||
border-bottom-width: 1px !important;
|
||||
}
|
||||
.hcal-table-day tr:not(:last-child):not(:first-child) td {
|
||||
border-width: 0;
|
||||
}*/
|
||||
.hcal-table-day td {
|
||||
padding: 2px;
|
||||
height: 2.3em;
|
||||
font-size: 7px;
|
||||
vertical-align: middle;
|
||||
font-weight: bold;
|
||||
border: 1px solid #cecece !important;
|
||||
}
|
||||
.hcal-table-day td:hover:not(.hcal-cell-highlight):not(.hcal-cell-invalid) {
|
||||
background-color: #FCFEE1 !important;
|
||||
}
|
||||
|
||||
.hcal-cell-current-day {
|
||||
background-color: #E0F8B0;
|
||||
}
|
||||
.hcal-cell-end-week {
|
||||
background-color: #E2EAF9;
|
||||
}
|
||||
|
||||
.hcal-cell-day-selector {
|
||||
text-align: center;
|
||||
vertical-align: center;
|
||||
max-width: 140px;
|
||||
}
|
||||
.hcal-cell-day-selector a {
|
||||
font-size: 22px;
|
||||
padding: 0 0.5em;
|
||||
}
|
||||
.hcal-cell-day-selector span {
|
||||
cursor: pointer;
|
||||
}
|
||||
.hcal-cell-day-selector input {
|
||||
border: 1px solid lightgray;
|
||||
width: 120px;
|
||||
font-size: large;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hcal-cell-month {
|
||||
overflow: hidden;
|
||||
max-width: 0;
|
||||
text-align: center !important;
|
||||
vertical-align: middle;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.hcal-cell-month:nth-child(n+3) {
|
||||
border-left-width: 2px !important;
|
||||
}
|
||||
|
||||
.hcal-cell-start-month {
|
||||
border-left-width: 2px !important;
|
||||
}
|
||||
|
||||
.hcal-room-type:hover {
|
||||
cursor:pointer;
|
||||
}
|
||||
|
||||
.hcal-cell-highlight {
|
||||
background-color: #F8FD9C;
|
||||
}
|
||||
|
||||
.hcal-cell-invalid {
|
||||
background-color: #e58e92;
|
||||
}
|
||||
|
||||
|
||||
.hcal-cell-room-type-group-item-day {
|
||||
padding: 0 !important;
|
||||
height: 100%;
|
||||
}
|
||||
|
||||
.hcal-input-changed {
|
||||
background-color: rgb(237,110,110);
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.hcal-cell-room-type-group-item-day-occupied {
|
||||
/*background-color: #227eaf;*/
|
||||
}
|
||||
.hcal-cell-room-type-group-item-day-occupied[data-hcal-reservation-cell-type=soft-start] {
|
||||
background-color: #729fcf;
|
||||
/*border: 2px solid #3465a4;*/
|
||||
}
|
||||
|
||||
.hcal-cell-pagination button {
|
||||
padding: 0.1em;
|
||||
border-radius: 0;
|
||||
background-color: initial;
|
||||
}
|
||||
|
||||
#btn_save_changes.need-save {
|
||||
color: yellow;
|
||||
background: orange;
|
||||
}
|
||||
|
||||
.hcal-hidden {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.hcal-reservation-unselect {
|
||||
opacity: 0.3;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.hcal-reservation {
|
||||
position: absolute;
|
||||
text-align: center;
|
||||
/*background-color: #729fcf;*/
|
||||
/*transform: skewX(-25deg);*/
|
||||
border-radius: 5px;
|
||||
border: 1px solid #3465a4;
|
||||
color: white;
|
||||
white-space: nowrap;
|
||||
overflow: hidden;
|
||||
z-index:8;
|
||||
}
|
||||
.hcal-reservation:hover {
|
||||
background-color: #4e97bf;
|
||||
}
|
||||
.hcal-reservation span {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.hcal-reservation-splitted {
|
||||
border-width: 1px 6px;
|
||||
}
|
||||
|
||||
.hcal-reservation-invalid {
|
||||
background-color: #c8543b !important;
|
||||
border-color: #6c3624 !important;
|
||||
}
|
||||
.hcal-reservation-invalid:hover {
|
||||
background-color: #f5b595 !important;
|
||||
border-color: #c8543b !important;
|
||||
}
|
||||
|
||||
.hcal-reservation-foreground {
|
||||
pointer-events: none;
|
||||
opacity: 0.9;
|
||||
color: transparent !important;
|
||||
background: repeating-linear-gradient(
|
||||
45deg,
|
||||
#606dbc,
|
||||
#606dbc 10px,
|
||||
#465298 10px,
|
||||
#465298 20px
|
||||
);
|
||||
}
|
||||
|
||||
.hcal-reservation-invalid-swap {
|
||||
pointer-events: none;
|
||||
opacity: 0.9;
|
||||
color: transparent !important;
|
||||
background: repeating-linear-gradient(
|
||||
45deg,
|
||||
#BA6359,
|
||||
#BA6359 10px,
|
||||
#dfe066 10px,
|
||||
#dfe066 20px
|
||||
);
|
||||
}
|
||||
|
||||
.hcal-reservation-action {
|
||||
border: 2px dashed #3465a4;
|
||||
opacity: 0.9;
|
||||
pointer-events: none;
|
||||
z-index:10;
|
||||
}
|
||||
|
||||
.hcal-reservation-readonly:not(.hcal-unused-zone) {
|
||||
border: 2px solid #99995b;
|
||||
color: white !important;
|
||||
font-weight: bold;
|
||||
background: #ffee00;
|
||||
background: repeating-radial-gradient(circle farthest-corner at right center, #ffee00 0%, #2c2c2c 5%, #ffff00 10%, #2c2c2c 20%, #2c2c2c 100%);
|
||||
background: -webkit-repeating-radial-gradient(circle farthest-corner at right center, #ffee00 0%, #2c2c2c 5%, #ffff00 10%, #2c2c2c 20%, #2c2c2c 100%);
|
||||
background: -moz-repeating-radial-gradient(circle farthest-corner at right center, #ffee00 0%, #2c2c2c 5%, #ffff00 10%, #2c2c2c 20%, #2c2c2c 100%);
|
||||
}
|
||||
|
||||
.hcal-reservation-swap-in-selected {
|
||||
background-color: #005B96 !important;
|
||||
border-color: #99bdd5 !important;
|
||||
}
|
||||
|
||||
.hcal-reservation-swap-out-selected {
|
||||
border-color: #005B96 !important;
|
||||
background-color: #99bdd5 !important;
|
||||
}
|
||||
|
||||
.hcal-row-room-type-group-item {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
tr.hcal-row-room-type-group-overbooking-item td {
|
||||
background-color: #c78585;
|
||||
}
|
||||
|
||||
.hcal-cell-month-day {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
.hcal-cell-room-type-group-day {
|
||||
text-align: center !important;
|
||||
}
|
||||
|
||||
.hcal-table-type-group-day {
|
||||
border-collapse: collapse;
|
||||
width:100%;
|
||||
}
|
||||
.hcal-table-type-group-day td {
|
||||
border-width: 0;
|
||||
}
|
||||
.hcal-table-type-group-day tr:not(:last-child) td {
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
|
||||
.hcal-cell-room-type {
|
||||
cursor: pointer;
|
||||
}
|
||||
td.hcal-cell-room-type {
|
||||
border-right-width: 2px;
|
||||
}
|
||||
|
||||
td.hcal-cell-room-type-group-day, td.hcal-cell-room-type {
|
||||
border-top-width: 2px;
|
||||
}
|
||||
td.hcal-cell-room-type-group-day {
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
td.hcal-cell-room-type-group-item {
|
||||
text-align: center !important;
|
||||
vertical-align: middle;
|
||||
font-size: x-small;
|
||||
white-space: nowrap;
|
||||
}
|
||||
td.hcal-cell-room-type-group-item:last-child {
|
||||
border-right-width: 2px;
|
||||
}
|
||||
|
||||
.hcal-cell-type-group-day-free {
|
||||
text-align: center;
|
||||
font-weight: bold;
|
||||
padding: 0 !important;
|
||||
}
|
||||
.hcal-cell-type-group-day-price {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
td.hcal-cell-header-day {
|
||||
padding: 0;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
td.hcal-cell-month-day-occupied {
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.hcal-cell-detail-room-free-type-group-item-day,
|
||||
.hcal-cell-detail-room-free-total-group-item-day,
|
||||
.hcal-cell-detail-room-perc-occup-group-item-day,
|
||||
.hcal-cell-detail-room-price-type-group-item-day,
|
||||
.hcal-cell-detail-room-min-stay-group-item-day {
|
||||
border: 1px solid lightgray;
|
||||
}
|
||||
.hcal-cell-detail-room-min-stay-group-item-day {
|
||||
border-color: #307CB0 lightgray lightgray lightgray;
|
||||
border-width: 2px 1px 1px 1px;
|
||||
}
|
||||
|
||||
.hcal-cell-detail-room-group-item {
|
||||
white-space: nowrap;
|
||||
text-align: right !important;
|
||||
text-overflow: '...';
|
||||
}
|
||||
|
||||
/* FIXME: Workaround for work with other currencies */
|
||||
.hcal-cell-detail-room-group-item[data-currency-symbol='€'] {
|
||||
text-overflow: '... €';
|
||||
}
|
||||
|
||||
.hcal-unused-zone {
|
||||
border: 1px solid #444;
|
||||
border-radius: 0px;
|
||||
}
|
||||
|
||||
.input-price {
|
||||
width: 100%;
|
||||
border-style: none !important;
|
||||
border-radius: 0 !important;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
button#btn_action_bookings {
|
||||
margin-bottom: -1px !important;
|
||||
border-bottom-left-radius: 0;
|
||||
border-bottom-right-radius: 0;
|
||||
}
|
||||
input#bookings_search {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
margin-bottom: 0.2em;
|
||||
}
|
||||
|
||||
.noselect {
|
||||
-webkit-touch-callout: none; /* iOS Safari */
|
||||
-webkit-user-select: none; /* Safari */
|
||||
-khtml-user-select: none; /* Konqueror HTML */
|
||||
-moz-user-select: none; /* Firefox */
|
||||
-ms-user-select: none; /* Internet Explorer/Edge */
|
||||
user-select: none; /* Non-prefixed version, currently
|
||||
supported by Chrome and Opera */
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
/*
|
||||
* Hotel Calendar Management JS v0.0.1a - 2017
|
||||
* GNU Public License
|
||||
* Aloxa Solucions S.L. <info@aloxa.eu>
|
||||
* Alexandre Díaz <alex@aloxa.eu>
|
||||
*/
|
||||
|
||||
.hcal-management-table, .hcal-management-table-day {
|
||||
border-collapse: collapse !important;
|
||||
table-layout: fixed;
|
||||
}
|
||||
.hcal-management-table > tbody {
|
||||
max-height: 50vh;
|
||||
overflow: scroll;
|
||||
}
|
||||
.hcal-management-table > thead > tr > td {
|
||||
/*text-align: center !important;*/
|
||||
width: 110px !important;
|
||||
vertical-align: center;
|
||||
min-width: 110px;
|
||||
height: 1.5em;
|
||||
min-height: 1.5em;
|
||||
white-space: nowrap;
|
||||
/*overflow: hidden;*/
|
||||
border: 1px solid black !important;
|
||||
}
|
||||
.hcal-management-table > tbody > tr > td {
|
||||
/*text-align: center !important;*/
|
||||
width: 110px !important;
|
||||
vertical-align: center;
|
||||
min-width: 110px;
|
||||
height: 115px;
|
||||
min-height: 100px;
|
||||
white-space: nowrap;
|
||||
/*overflow: hidden;*/
|
||||
padding: 5px !important;
|
||||
border: 1px solid black;
|
||||
}
|
||||
.hcal-management-table thead td {
|
||||
text-align: center !important;
|
||||
}
|
||||
.hcal-management-table a {
|
||||
text-decoration: none;
|
||||
}
|
||||
.hcal-management-table tr:hover td:not(.hcal-cell-highlight):not(.hcal-cell-current-day):not(.hcal-cell-end-week):not(.btn-hcal):not(.hcal-cell-invalid) {
|
||||
background-color: #F6F6F6;
|
||||
}
|
||||
|
||||
.hcal-management-table tr:hover td.hcal-cell-room-type-group-item {
|
||||
background-color: #9bcd9b;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.hcal-management-table input[type='edit'] {
|
||||
width: 100%;
|
||||
font-size: 10px;
|
||||
text-align: center;
|
||||
}
|
||||
.hcal-management-table select {
|
||||
font-size: 9px;
|
||||
}
|
||||
|
||||
.hcal-management-table-day {
|
||||
height: 100%;
|
||||
border-collapse: collapse !important;
|
||||
}
|
||||
.hcal-management-table-day td {
|
||||
padding: 2px;
|
||||
height: 2.3em;
|
||||
font-size: 7px;
|
||||
vertical-align: middle;
|
||||
font-weight: bold;
|
||||
border: 0;
|
||||
}
|
||||
.hcal-management-table-day td:hover:not(.hcal-cell-highlight):not(.hcal-cell-invalid) {
|
||||
background-color: #FCFEE1 !important;
|
||||
}
|
||||
|
||||
.hcal-management-low > tbody > tr > td, .hcal-management-low > table > tbody > tr > td {
|
||||
height: 35px !important;
|
||||
}
|
||||
|
||||
.hcal-management-medium > tbody > tr > td, .hcal-management-medium > table > tbody > tr > td {
|
||||
height: 60px !important;
|
||||
}
|
||||
|
||||
.hcal-management-medium tr[name='rest_b'], .hcal-management-medium tr[name='rest_c'],
|
||||
.hcal-management-low tr[name='rest_a'], .hcal-management-low tr[name='rest_b'], .hcal-management-low tr[name='rest_c'] {
|
||||
display: none;
|
||||
visibility: hidden;
|
||||
}
|
||||
|
||||
.table-vrooms {
|
||||
float: left;
|
||||
margin-top: 1.6em;
|
||||
}
|
||||
|
||||
#hcal_management_widget {
|
||||
overflow: auto;
|
||||
height: 84vh;
|
||||
}
|
||||
|
||||
#hcal-management-container-dd {
|
||||
overflow: auto;
|
||||
position: relative;
|
||||
}
|
||||
|
||||
#btn_save_changes, #btn_massive_changes {
|
||||
height: 56px;
|
||||
}
|
||||
#btn_save_changes i, #btn_massive_changes i {
|
||||
top: 22%;
|
||||
}
|
||||
|
||||
.hcal-management-input-changed {
|
||||
background-color: rgb(237,110,110);
|
||||
border: 1px solid gray;
|
||||
}
|
||||
|
||||
.hcal-management-record-changed {
|
||||
background-color: #FFFF66 !important;
|
||||
}
|
||||
|
||||
table.hcal-management-table input {
|
||||
border: 1px solid lightgray;
|
||||
}
|
||||
|
||||
.hcal-border-radius-right {
|
||||
border-top-right-radius: 25px;
|
||||
border-bottom-right-radius: 25px;
|
||||
}
|
||||
|
||||
.hcal-border-radius-left {
|
||||
border-top-left-radius: 25px;
|
||||
border-bottom-left-radius: 25px;
|
||||
}
|
||||
|
||||
.hcal-management-record-options {
|
||||
padding: 0.5em;
|
||||
}
|
||||
|
||||
button.hcal-management-input {
|
||||
font-size: 9px;
|
||||
border: 1px solid gray;
|
||||
padding: 0.5em 2em 0.2em 2em;
|
||||
border-radius: 3px;
|
||||
margin: 0.2em;
|
||||
|
||||
background: rgba(255,255,255,1);
|
||||
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(227,227,227,1) 47%, rgba(194,194,194,1) 100%);
|
||||
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(227,227,227,1)), color-stop(100%, rgba(194,194,194,1)));
|
||||
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(227,227,227,1) 47%, rgba(194,194,194,1) 100%);
|
||||
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(227,227,227,1) 47%, rgba(194,194,194,1) 100%);
|
||||
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(227,227,227,1) 47%, rgba(194,194,194,1) 100%);
|
||||
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(227,227,227,1) 47%, rgba(194,194,194,1) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#c2c2c2', GradientType=0 );
|
||||
}
|
||||
button.hcal-management-input:hover {
|
||||
background: rgba(255,255,255,1);
|
||||
background: -moz-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
|
||||
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(255,255,255,1)), color-stop(47%, rgba(246,246,246,1)), color-stop(100%, rgba(237,237,237,1)));
|
||||
background: -webkit-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
|
||||
background: -o-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
|
||||
background: -ms-linear-gradient(top, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
|
||||
background: linear-gradient(to bottom, rgba(255,255,255,1) 0%, rgba(246,246,246,1) 47%, rgba(237,237,237,1) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#ededed', GradientType=0 );
|
||||
}
|
||||
button.hcal-management-input-active {
|
||||
background: rgba(245,215,93,1) !important;
|
||||
background: -moz-linear-gradient(top, rgba(245,215,93,1) 0%, rgba(245,165,44,1) 47%, rgba(255,153,0,1) 100%) !important;
|
||||
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(245,215,93,1)), color-stop(47%, rgba(245,165,44,1)), color-stop(100%, rgba(255,153,0,1))) !important;
|
||||
background: -webkit-linear-gradient(top, rgba(245,215,93,1) 0%, rgba(245,165,44,1) 47%, rgba(255,153,0,1) 100%) !important;
|
||||
background: -o-linear-gradient(top, rgba(245,215,93,1) 0%, rgba(245,165,44,1) 47%, rgba(255,153,0,1) 100%) !important;
|
||||
background: -ms-linear-gradient(top, rgba(245,215,93,1) 0%, rgba(245,165,44,1) 47%, rgba(255,153,0,1) 100%) !important;
|
||||
background: linear-gradient(to bottom, rgba(245,215,93,1) 0%, rgba(245,165,44,1) 47%, rgba(255,153,0,1) 100%) !important;
|
||||
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#f5d75d', endColorstr='#ff9900', GradientType=0 ) !important;
|
||||
}
|
||||
2844
hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js
Normal file
2844
hotel_calendar/static/src/lib/hcalendar/js/hcalendar.js
Normal file
File diff suppressed because it is too large
Load Diff
1088
hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js
Normal file
1088
hotel_calendar/static/src/lib/hcalendar/js/hcalendar_management.js
Normal file
File diff suppressed because it is too large
Load Diff
551
hotel_calendar/static/src/lib/moment.js
Normal file
551
hotel_calendar/static/src/lib/moment.js
Normal file
@@ -0,0 +1,551 @@
|
||||
//! moment.js
|
||||
//! version : 2.17.1
|
||||
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
|
||||
//! license : MIT
|
||||
//! momentjs.com
|
||||
!function(a,b){"object"==typeof exports&&"undefined"!=typeof module?module.exports=b():"function"==typeof define&&define.amd?define(b):a.moment=b()}(this,function(){"use strict";function a(){return od.apply(null,arguments)}
|
||||
// This is done to register the method called with moment()
|
||||
// without creating circular dependencies.
|
||||
function b(a){od=a}function c(a){return a instanceof Array||"[object Array]"===Object.prototype.toString.call(a)}function d(a){
|
||||
// IE8 will treat undefined and null as object if it wasn't for
|
||||
// input != null
|
||||
return null!=a&&"[object Object]"===Object.prototype.toString.call(a)}function e(a){var b;for(b in a)
|
||||
// even if its not own property I'd still call it non-empty
|
||||
return!1;return!0}function f(a){return"number"==typeof a||"[object Number]"===Object.prototype.toString.call(a)}function g(a){return a instanceof Date||"[object Date]"===Object.prototype.toString.call(a)}function h(a,b){var c,d=[];for(c=0;c<a.length;++c)d.push(b(a[c],c));return d}function i(a,b){return Object.prototype.hasOwnProperty.call(a,b)}function j(a,b){for(var c in b)i(b,c)&&(a[c]=b[c]);return i(b,"toString")&&(a.toString=b.toString),i(b,"valueOf")&&(a.valueOf=b.valueOf),a}function k(a,b,c,d){return rb(a,b,c,d,!0).utc()}function l(){
|
||||
// We need to deep clone this object.
|
||||
return{empty:!1,unusedTokens:[],unusedInput:[],overflow:-2,charsLeftOver:0,nullInput:!1,invalidMonth:null,invalidFormat:!1,userInvalidated:!1,iso:!1,parsedDateParts:[],meridiem:null}}function m(a){return null==a._pf&&(a._pf=l()),a._pf}function n(a){if(null==a._isValid){var b=m(a),c=qd.call(b.parsedDateParts,function(a){return null!=a}),d=!isNaN(a._d.getTime())&&b.overflow<0&&!b.empty&&!b.invalidMonth&&!b.invalidWeekday&&!b.nullInput&&!b.invalidFormat&&!b.userInvalidated&&(!b.meridiem||b.meridiem&&c);if(a._strict&&(d=d&&0===b.charsLeftOver&&0===b.unusedTokens.length&&void 0===b.bigHour),null!=Object.isFrozen&&Object.isFrozen(a))return d;a._isValid=d}return a._isValid}function o(a){var b=k(NaN);return null!=a?j(m(b),a):m(b).userInvalidated=!0,b}function p(a){return void 0===a}function q(a,b){var c,d,e;if(p(b._isAMomentObject)||(a._isAMomentObject=b._isAMomentObject),p(b._i)||(a._i=b._i),p(b._f)||(a._f=b._f),p(b._l)||(a._l=b._l),p(b._strict)||(a._strict=b._strict),p(b._tzm)||(a._tzm=b._tzm),p(b._isUTC)||(a._isUTC=b._isUTC),p(b._offset)||(a._offset=b._offset),p(b._pf)||(a._pf=m(b)),p(b._locale)||(a._locale=b._locale),rd.length>0)for(c in rd)d=rd[c],e=b[d],p(e)||(a[d]=e);return a}
|
||||
// Moment prototype object
|
||||
function r(b){q(this,b),this._d=new Date(null!=b._d?b._d.getTime():NaN),this.isValid()||(this._d=new Date(NaN)),
|
||||
// Prevent infinite loop in case updateOffset creates new moment
|
||||
// objects.
|
||||
sd===!1&&(sd=!0,a.updateOffset(this),sd=!1)}function s(a){return a instanceof r||null!=a&&null!=a._isAMomentObject}function t(a){return a<0?Math.ceil(a)||0:Math.floor(a)}function u(a){var b=+a,c=0;return 0!==b&&isFinite(b)&&(c=t(b)),c}
|
||||
// compare two arrays, return the number of differences
|
||||
function v(a,b,c){var d,e=Math.min(a.length,b.length),f=Math.abs(a.length-b.length),g=0;for(d=0;d<e;d++)(c&&a[d]!==b[d]||!c&&u(a[d])!==u(b[d]))&&g++;return g+f}function w(b){a.suppressDeprecationWarnings===!1&&"undefined"!=typeof console&&console.warn&&console.warn("Deprecation warning: "+b)}function x(b,c){var d=!0;return j(function(){if(null!=a.deprecationHandler&&a.deprecationHandler(null,b),d){for(var e,f=[],g=0;g<arguments.length;g++){if(e="","object"==typeof arguments[g]){e+="\n["+g+"] ";for(var h in arguments[0])e+=h+": "+arguments[0][h]+", ";e=e.slice(0,-2)}else e=arguments[g];f.push(e)}w(b+"\nArguments: "+Array.prototype.slice.call(f).join("")+"\n"+(new Error).stack),d=!1}return c.apply(this,arguments)},c)}function y(b,c){null!=a.deprecationHandler&&a.deprecationHandler(b,c),td[b]||(w(c),td[b]=!0)}function z(a){return a instanceof Function||"[object Function]"===Object.prototype.toString.call(a)}function A(a){var b,c;for(c in a)b=a[c],z(b)?this[c]=b:this["_"+c]=b;this._config=a,
|
||||
// Lenient ordinal parsing accepts just a number in addition to
|
||||
// number + (possibly) stuff coming from _ordinalParseLenient.
|
||||
this._ordinalParseLenient=new RegExp(this._ordinalParse.source+"|"+/\d{1,2}/.source)}function B(a,b){var c,e=j({},a);for(c in b)i(b,c)&&(d(a[c])&&d(b[c])?(e[c]={},j(e[c],a[c]),j(e[c],b[c])):null!=b[c]?e[c]=b[c]:delete e[c]);for(c in a)i(a,c)&&!i(b,c)&&d(a[c])&&(
|
||||
// make sure changes to properties don't modify parent config
|
||||
e[c]=j({},e[c]));return e}function C(a){null!=a&&this.set(a)}function D(a,b,c){var d=this._calendar[a]||this._calendar.sameElse;return z(d)?d.call(b,c):d}function E(a){var b=this._longDateFormat[a],c=this._longDateFormat[a.toUpperCase()];return b||!c?b:(this._longDateFormat[a]=c.replace(/MMMM|MM|DD|dddd/g,function(a){return a.slice(1)}),this._longDateFormat[a])}function F(){return this._invalidDate}function G(a){return this._ordinal.replace("%d",a)}function H(a,b,c,d){var e=this._relativeTime[c];return z(e)?e(a,b,c,d):e.replace(/%d/i,a)}function I(a,b){var c=this._relativeTime[a>0?"future":"past"];return z(c)?c(b):c.replace(/%s/i,b)}function J(a,b){var c=a.toLowerCase();Dd[c]=Dd[c+"s"]=Dd[b]=a}function K(a){return"string"==typeof a?Dd[a]||Dd[a.toLowerCase()]:void 0}function L(a){var b,c,d={};for(c in a)i(a,c)&&(b=K(c),b&&(d[b]=a[c]));return d}function M(a,b){Ed[a]=b}function N(a){var b=[];for(var c in a)b.push({unit:c,priority:Ed[c]});return b.sort(function(a,b){return a.priority-b.priority}),b}function O(b,c){return function(d){return null!=d?(Q(this,b,d),a.updateOffset(this,c),this):P(this,b)}}function P(a,b){return a.isValid()?a._d["get"+(a._isUTC?"UTC":"")+b]():NaN}function Q(a,b,c){a.isValid()&&a._d["set"+(a._isUTC?"UTC":"")+b](c)}
|
||||
// MOMENTS
|
||||
function R(a){return a=K(a),z(this[a])?this[a]():this}function S(a,b){if("object"==typeof a){a=L(a);for(var c=N(a),d=0;d<c.length;d++)this[c[d].unit](a[c[d].unit])}else if(a=K(a),z(this[a]))return this[a](b);return this}function T(a,b,c){var d=""+Math.abs(a),e=b-d.length,f=a>=0;return(f?c?"+":"":"-")+Math.pow(10,Math.max(0,e)).toString().substr(1)+d}
|
||||
// token: 'M'
|
||||
// padded: ['MM', 2]
|
||||
// ordinal: 'Mo'
|
||||
// callback: function () { this.month() + 1 }
|
||||
function U(a,b,c,d){var e=d;"string"==typeof d&&(e=function(){return this[d]()}),a&&(Id[a]=e),b&&(Id[b[0]]=function(){return T(e.apply(this,arguments),b[1],b[2])}),c&&(Id[c]=function(){return this.localeData().ordinal(e.apply(this,arguments),a)})}function V(a){return a.match(/\[[\s\S]/)?a.replace(/^\[|\]$/g,""):a.replace(/\\/g,"")}function W(a){var b,c,d=a.match(Fd);for(b=0,c=d.length;b<c;b++)Id[d[b]]?d[b]=Id[d[b]]:d[b]=V(d[b]);return function(b){var e,f="";for(e=0;e<c;e++)f+=d[e]instanceof Function?d[e].call(b,a):d[e];return f}}
|
||||
// format date using native date object
|
||||
function X(a,b){return a.isValid()?(b=Y(b,a.localeData()),Hd[b]=Hd[b]||W(b),Hd[b](a)):a.localeData().invalidDate()}function Y(a,b){function c(a){return b.longDateFormat(a)||a}var d=5;for(Gd.lastIndex=0;d>=0&&Gd.test(a);)a=a.replace(Gd,c),Gd.lastIndex=0,d-=1;return a}function Z(a,b,c){$d[a]=z(b)?b:function(a,d){return a&&c?c:b}}function $(a,b){return i($d,a)?$d[a](b._strict,b._locale):new RegExp(_(a))}
|
||||
// Code from http://stackoverflow.com/questions/3561493/is-there-a-regexp-escape-function-in-javascript
|
||||
function _(a){return aa(a.replace("\\","").replace(/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,function(a,b,c,d,e){return b||c||d||e}))}function aa(a){return a.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")}function ba(a,b){var c,d=b;for("string"==typeof a&&(a=[a]),f(b)&&(d=function(a,c){c[b]=u(a)}),c=0;c<a.length;c++)_d[a[c]]=d}function ca(a,b){ba(a,function(a,c,d,e){d._w=d._w||{},b(a,d._w,d,e)})}function da(a,b,c){null!=b&&i(_d,a)&&_d[a](b,c._a,c,a)}function ea(a,b){return new Date(Date.UTC(a,b+1,0)).getUTCDate()}function fa(a,b){return a?c(this._months)?this._months[a.month()]:this._months[(this._months.isFormat||ke).test(b)?"format":"standalone"][a.month()]:this._months}function ga(a,b){return a?c(this._monthsShort)?this._monthsShort[a.month()]:this._monthsShort[ke.test(b)?"format":"standalone"][a.month()]:this._monthsShort}function ha(a,b,c){var d,e,f,g=a.toLocaleLowerCase();if(!this._monthsParse)for(
|
||||
// this is not used
|
||||
this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[],d=0;d<12;++d)f=k([2e3,d]),this._shortMonthsParse[d]=this.monthsShort(f,"").toLocaleLowerCase(),this._longMonthsParse[d]=this.months(f,"").toLocaleLowerCase();return c?"MMM"===b?(e=je.call(this._shortMonthsParse,g),e!==-1?e:null):(e=je.call(this._longMonthsParse,g),e!==-1?e:null):"MMM"===b?(e=je.call(this._shortMonthsParse,g),e!==-1?e:(e=je.call(this._longMonthsParse,g),e!==-1?e:null)):(e=je.call(this._longMonthsParse,g),e!==-1?e:(e=je.call(this._shortMonthsParse,g),e!==-1?e:null))}function ia(a,b,c){var d,e,f;if(this._monthsParseExact)return ha.call(this,a,b,c);
|
||||
// TODO: add sorting
|
||||
// Sorting makes sure if one month (or abbr) is a prefix of another
|
||||
// see sorting in computeMonthsParse
|
||||
for(this._monthsParse||(this._monthsParse=[],this._longMonthsParse=[],this._shortMonthsParse=[]),d=0;d<12;d++){
|
||||
// test the regex
|
||||
if(
|
||||
// make the regex if we don't have it already
|
||||
e=k([2e3,d]),c&&!this._longMonthsParse[d]&&(this._longMonthsParse[d]=new RegExp("^"+this.months(e,"").replace(".","")+"$","i"),this._shortMonthsParse[d]=new RegExp("^"+this.monthsShort(e,"").replace(".","")+"$","i")),c||this._monthsParse[d]||(f="^"+this.months(e,"")+"|^"+this.monthsShort(e,""),this._monthsParse[d]=new RegExp(f.replace(".",""),"i")),c&&"MMMM"===b&&this._longMonthsParse[d].test(a))return d;if(c&&"MMM"===b&&this._shortMonthsParse[d].test(a))return d;if(!c&&this._monthsParse[d].test(a))return d}}
|
||||
// MOMENTS
|
||||
function ja(a,b){var c;if(!a.isValid())
|
||||
// No op
|
||||
return a;if("string"==typeof b)if(/^\d+$/.test(b))b=u(b);else
|
||||
// TODO: Another silent failure?
|
||||
if(b=a.localeData().monthsParse(b),!f(b))return a;return c=Math.min(a.date(),ea(a.year(),b)),a._d["set"+(a._isUTC?"UTC":"")+"Month"](b,c),a}function ka(b){return null!=b?(ja(this,b),a.updateOffset(this,!0),this):P(this,"Month")}function la(){return ea(this.year(),this.month())}function ma(a){return this._monthsParseExact?(i(this,"_monthsRegex")||oa.call(this),a?this._monthsShortStrictRegex:this._monthsShortRegex):(i(this,"_monthsShortRegex")||(this._monthsShortRegex=ne),this._monthsShortStrictRegex&&a?this._monthsShortStrictRegex:this._monthsShortRegex)}function na(a){return this._monthsParseExact?(i(this,"_monthsRegex")||oa.call(this),a?this._monthsStrictRegex:this._monthsRegex):(i(this,"_monthsRegex")||(this._monthsRegex=oe),this._monthsStrictRegex&&a?this._monthsStrictRegex:this._monthsRegex)}function oa(){function a(a,b){return b.length-a.length}var b,c,d=[],e=[],f=[];for(b=0;b<12;b++)
|
||||
// make the regex if we don't have it already
|
||||
c=k([2e3,b]),d.push(this.monthsShort(c,"")),e.push(this.months(c,"")),f.push(this.months(c,"")),f.push(this.monthsShort(c,""));for(
|
||||
// Sorting makes sure if one month (or abbr) is a prefix of another it
|
||||
// will match the longer piece.
|
||||
d.sort(a),e.sort(a),f.sort(a),b=0;b<12;b++)d[b]=aa(d[b]),e[b]=aa(e[b]);for(b=0;b<24;b++)f[b]=aa(f[b]);this._monthsRegex=new RegExp("^("+f.join("|")+")","i"),this._monthsShortRegex=this._monthsRegex,this._monthsStrictRegex=new RegExp("^("+e.join("|")+")","i"),this._monthsShortStrictRegex=new RegExp("^("+d.join("|")+")","i")}
|
||||
// HELPERS
|
||||
function pa(a){return qa(a)?366:365}function qa(a){return a%4===0&&a%100!==0||a%400===0}function ra(){return qa(this.year())}function sa(a,b,c,d,e,f,g){
|
||||
//can't just apply() to create a date:
|
||||
//http://stackoverflow.com/questions/181348/instantiating-a-javascript-object-by-calling-prototype-constructor-apply
|
||||
var h=new Date(a,b,c,d,e,f,g);
|
||||
//the date constructor remaps years 0-99 to 1900-1999
|
||||
return a<100&&a>=0&&isFinite(h.getFullYear())&&h.setFullYear(a),h}function ta(a){var b=new Date(Date.UTC.apply(null,arguments));
|
||||
//the Date.UTC function remaps years 0-99 to 1900-1999
|
||||
return a<100&&a>=0&&isFinite(b.getUTCFullYear())&&b.setUTCFullYear(a),b}
|
||||
// start-of-first-week - start-of-year
|
||||
function ua(a,b,c){var// first-week day -- which january is always in the first week (4 for iso, 1 for other)
|
||||
d=7+b-c,
|
||||
// first-week day local weekday -- which local weekday is fwd
|
||||
e=(7+ta(a,0,d).getUTCDay()-b)%7;return-e+d-1}
|
||||
//http://en.wikipedia.org/wiki/ISO_week_date#Calculating_a_date_given_the_year.2C_week_number_and_weekday
|
||||
function va(a,b,c,d,e){var f,g,h=(7+c-d)%7,i=ua(a,d,e),j=1+7*(b-1)+h+i;return j<=0?(f=a-1,g=pa(f)+j):j>pa(a)?(f=a+1,g=j-pa(a)):(f=a,g=j),{year:f,dayOfYear:g}}function wa(a,b,c){var d,e,f=ua(a.year(),b,c),g=Math.floor((a.dayOfYear()-f-1)/7)+1;return g<1?(e=a.year()-1,d=g+xa(e,b,c)):g>xa(a.year(),b,c)?(d=g-xa(a.year(),b,c),e=a.year()+1):(e=a.year(),d=g),{week:d,year:e}}function xa(a,b,c){var d=ua(a,b,c),e=ua(a+1,b,c);return(pa(a)-d+e)/7}
|
||||
// HELPERS
|
||||
// LOCALES
|
||||
function ya(a){return wa(a,this._week.dow,this._week.doy).week}function za(){return this._week.dow}function Aa(){return this._week.doy}
|
||||
// MOMENTS
|
||||
function Ba(a){var b=this.localeData().week(this);return null==a?b:this.add(7*(a-b),"d")}function Ca(a){var b=wa(this,1,4).week;return null==a?b:this.add(7*(a-b),"d")}
|
||||
// HELPERS
|
||||
function Da(a,b){return"string"!=typeof a?a:isNaN(a)?(a=b.weekdaysParse(a),"number"==typeof a?a:null):parseInt(a,10)}function Ea(a,b){return"string"==typeof a?b.weekdaysParse(a)%7||7:isNaN(a)?null:a}function Fa(a,b){return a?c(this._weekdays)?this._weekdays[a.day()]:this._weekdays[this._weekdays.isFormat.test(b)?"format":"standalone"][a.day()]:this._weekdays}function Ga(a){return a?this._weekdaysShort[a.day()]:this._weekdaysShort}function Ha(a){return a?this._weekdaysMin[a.day()]:this._weekdaysMin}function Ia(a,b,c){var d,e,f,g=a.toLocaleLowerCase();if(!this._weekdaysParse)for(this._weekdaysParse=[],this._shortWeekdaysParse=[],this._minWeekdaysParse=[],d=0;d<7;++d)f=k([2e3,1]).day(d),this._minWeekdaysParse[d]=this.weekdaysMin(f,"").toLocaleLowerCase(),this._shortWeekdaysParse[d]=this.weekdaysShort(f,"").toLocaleLowerCase(),this._weekdaysParse[d]=this.weekdays(f,"").toLocaleLowerCase();return c?"dddd"===b?(e=je.call(this._weekdaysParse,g),e!==-1?e:null):"ddd"===b?(e=je.call(this._shortWeekdaysParse,g),e!==-1?e:null):(e=je.call(this._minWeekdaysParse,g),e!==-1?e:null):"dddd"===b?(e=je.call(this._weekdaysParse,g),e!==-1?e:(e=je.call(this._shortWeekdaysParse,g),e!==-1?e:(e=je.call(this._minWeekdaysParse,g),e!==-1?e:null))):"ddd"===b?(e=je.call(this._shortWeekdaysParse,g),e!==-1?e:(e=je.call(this._weekdaysParse,g),e!==-1?e:(e=je.call(this._minWeekdaysParse,g),e!==-1?e:null))):(e=je.call(this._minWeekdaysParse,g),e!==-1?e:(e=je.call(this._weekdaysParse,g),e!==-1?e:(e=je.call(this._shortWeekdaysParse,g),e!==-1?e:null)))}function Ja(a,b,c){var d,e,f;if(this._weekdaysParseExact)return Ia.call(this,a,b,c);for(this._weekdaysParse||(this._weekdaysParse=[],this._minWeekdaysParse=[],this._shortWeekdaysParse=[],this._fullWeekdaysParse=[]),d=0;d<7;d++){
|
||||
// test the regex
|
||||
if(
|
||||
// make the regex if we don't have it already
|
||||
e=k([2e3,1]).day(d),c&&!this._fullWeekdaysParse[d]&&(this._fullWeekdaysParse[d]=new RegExp("^"+this.weekdays(e,"").replace(".",".?")+"$","i"),this._shortWeekdaysParse[d]=new RegExp("^"+this.weekdaysShort(e,"").replace(".",".?")+"$","i"),this._minWeekdaysParse[d]=new RegExp("^"+this.weekdaysMin(e,"").replace(".",".?")+"$","i")),this._weekdaysParse[d]||(f="^"+this.weekdays(e,"")+"|^"+this.weekdaysShort(e,"")+"|^"+this.weekdaysMin(e,""),this._weekdaysParse[d]=new RegExp(f.replace(".",""),"i")),c&&"dddd"===b&&this._fullWeekdaysParse[d].test(a))return d;if(c&&"ddd"===b&&this._shortWeekdaysParse[d].test(a))return d;if(c&&"dd"===b&&this._minWeekdaysParse[d].test(a))return d;if(!c&&this._weekdaysParse[d].test(a))return d}}
|
||||
// MOMENTS
|
||||
function Ka(a){if(!this.isValid())return null!=a?this:NaN;var b=this._isUTC?this._d.getUTCDay():this._d.getDay();return null!=a?(a=Da(a,this.localeData()),this.add(a-b,"d")):b}function La(a){if(!this.isValid())return null!=a?this:NaN;var b=(this.day()+7-this.localeData()._week.dow)%7;return null==a?b:this.add(a-b,"d")}function Ma(a){if(!this.isValid())return null!=a?this:NaN;
|
||||
// behaves the same as moment#day except
|
||||
// as a getter, returns 7 instead of 0 (1-7 range instead of 0-6)
|
||||
// as a setter, sunday should belong to the previous week.
|
||||
if(null!=a){var b=Ea(a,this.localeData());return this.day(this.day()%7?b:b-7)}return this.day()||7}function Na(a){return this._weekdaysParseExact?(i(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysStrictRegex:this._weekdaysRegex):(i(this,"_weekdaysRegex")||(this._weekdaysRegex=ue),this._weekdaysStrictRegex&&a?this._weekdaysStrictRegex:this._weekdaysRegex)}function Oa(a){return this._weekdaysParseExact?(i(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysShortStrictRegex:this._weekdaysShortRegex):(i(this,"_weekdaysShortRegex")||(this._weekdaysShortRegex=ve),this._weekdaysShortStrictRegex&&a?this._weekdaysShortStrictRegex:this._weekdaysShortRegex)}function Pa(a){return this._weekdaysParseExact?(i(this,"_weekdaysRegex")||Qa.call(this),a?this._weekdaysMinStrictRegex:this._weekdaysMinRegex):(i(this,"_weekdaysMinRegex")||(this._weekdaysMinRegex=we),this._weekdaysMinStrictRegex&&a?this._weekdaysMinStrictRegex:this._weekdaysMinRegex)}function Qa(){function a(a,b){return b.length-a.length}var b,c,d,e,f,g=[],h=[],i=[],j=[];for(b=0;b<7;b++)
|
||||
// make the regex if we don't have it already
|
||||
c=k([2e3,1]).day(b),d=this.weekdaysMin(c,""),e=this.weekdaysShort(c,""),f=this.weekdays(c,""),g.push(d),h.push(e),i.push(f),j.push(d),j.push(e),j.push(f);for(
|
||||
// Sorting makes sure if one weekday (or abbr) is a prefix of another it
|
||||
// will match the longer piece.
|
||||
g.sort(a),h.sort(a),i.sort(a),j.sort(a),b=0;b<7;b++)h[b]=aa(h[b]),i[b]=aa(i[b]),j[b]=aa(j[b]);this._weekdaysRegex=new RegExp("^("+j.join("|")+")","i"),this._weekdaysShortRegex=this._weekdaysRegex,this._weekdaysMinRegex=this._weekdaysRegex,this._weekdaysStrictRegex=new RegExp("^("+i.join("|")+")","i"),this._weekdaysShortStrictRegex=new RegExp("^("+h.join("|")+")","i"),this._weekdaysMinStrictRegex=new RegExp("^("+g.join("|")+")","i")}
|
||||
// FORMATTING
|
||||
function Ra(){return this.hours()%12||12}function Sa(){return this.hours()||24}function Ta(a,b){U(a,0,0,function(){return this.localeData().meridiem(this.hours(),this.minutes(),b)})}
|
||||
// PARSING
|
||||
function Ua(a,b){return b._meridiemParse}
|
||||
// LOCALES
|
||||
function Va(a){
|
||||
// IE8 Quirks Mode & IE7 Standards Mode do not allow accessing strings like arrays
|
||||
// Using charAt should be more compatible.
|
||||
return"p"===(a+"").toLowerCase().charAt(0)}function Wa(a,b,c){return a>11?c?"pm":"PM":c?"am":"AM"}function Xa(a){return a?a.toLowerCase().replace("_","-"):a}
|
||||
// pick the locale from the array
|
||||
// try ['en-au', 'en-gb'] as 'en-au', 'en-gb', 'en', as in move through the list trying each
|
||||
// substring from most specific to least, but move to the next array item if it's a more specific variant than the current root
|
||||
function Ya(a){for(var b,c,d,e,f=0;f<a.length;){for(e=Xa(a[f]).split("-"),b=e.length,c=Xa(a[f+1]),c=c?c.split("-"):null;b>0;){if(d=Za(e.slice(0,b).join("-")))return d;if(c&&c.length>=b&&v(e,c,!0)>=b-1)
|
||||
//the next array item is better than a shallower substring of this one
|
||||
break;b--}f++}return null}function Za(a){var b=null;
|
||||
// TODO: Find a better way to register and load all the locales in Node
|
||||
if(!Be[a]&&"undefined"!=typeof module&&module&&module.exports)try{b=xe._abbr,require("./locale/"+a),
|
||||
// because defineLocale currently also sets the global locale, we
|
||||
// want to undo that for lazy loaded locales
|
||||
$a(b)}catch(a){}return Be[a]}
|
||||
// This function will load locale and then set the global locale. If
|
||||
// no arguments are passed in, it will simply return the current global
|
||||
// locale key.
|
||||
function $a(a,b){var c;
|
||||
// moment.duration._locale = moment._locale = data;
|
||||
return a&&(c=p(b)?bb(a):_a(a,b),c&&(xe=c)),xe._abbr}function _a(a,b){if(null!==b){var c=Ae;if(b.abbr=a,null!=Be[a])y("defineLocaleOverride","use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."),c=Be[a]._config;else if(null!=b.parentLocale){if(null==Be[b.parentLocale])return Ce[b.parentLocale]||(Ce[b.parentLocale]=[]),Ce[b.parentLocale].push({name:a,config:b}),null;c=Be[b.parentLocale]._config}
|
||||
// backwards compat for now: also set the locale
|
||||
// make sure we set the locale AFTER all child locales have been
|
||||
// created, so we won't end up with the child locale set.
|
||||
return Be[a]=new C(B(c,b)),Ce[a]&&Ce[a].forEach(function(a){_a(a.name,a.config)}),$a(a),Be[a]}
|
||||
// useful for testing
|
||||
return delete Be[a],null}function ab(a,b){if(null!=b){var c,d=Ae;
|
||||
// MERGE
|
||||
null!=Be[a]&&(d=Be[a]._config),b=B(d,b),c=new C(b),c.parentLocale=Be[a],Be[a]=c,
|
||||
// backwards compat for now: also set the locale
|
||||
$a(a)}else
|
||||
// pass null for config to unupdate, useful for tests
|
||||
null!=Be[a]&&(null!=Be[a].parentLocale?Be[a]=Be[a].parentLocale:null!=Be[a]&&delete Be[a]);return Be[a]}
|
||||
// returns locale data
|
||||
function bb(a){var b;if(a&&a._locale&&a._locale._abbr&&(a=a._locale._abbr),!a)return xe;if(!c(a)){if(
|
||||
//short-circuit everything else
|
||||
b=Za(a))return b;a=[a]}return Ya(a)}function cb(){return wd(Be)}function db(a){var b,c=a._a;return c&&m(a).overflow===-2&&(b=c[be]<0||c[be]>11?be:c[ce]<1||c[ce]>ea(c[ae],c[be])?ce:c[de]<0||c[de]>24||24===c[de]&&(0!==c[ee]||0!==c[fe]||0!==c[ge])?de:c[ee]<0||c[ee]>59?ee:c[fe]<0||c[fe]>59?fe:c[ge]<0||c[ge]>999?ge:-1,m(a)._overflowDayOfYear&&(b<ae||b>ce)&&(b=ce),m(a)._overflowWeeks&&b===-1&&(b=he),m(a)._overflowWeekday&&b===-1&&(b=ie),m(a).overflow=b),a}
|
||||
// date from iso format
|
||||
function eb(a){var b,c,d,e,f,g,h=a._i,i=De.exec(h)||Ee.exec(h);if(i){for(m(a).iso=!0,b=0,c=Ge.length;b<c;b++)if(Ge[b][1].exec(i[1])){e=Ge[b][0],d=Ge[b][2]!==!1;break}if(null==e)return void(a._isValid=!1);if(i[3]){for(b=0,c=He.length;b<c;b++)if(He[b][1].exec(i[3])){
|
||||
// match[2] should be 'T' or space
|
||||
f=(i[2]||" ")+He[b][0];break}if(null==f)return void(a._isValid=!1)}if(!d&&null!=f)return void(a._isValid=!1);if(i[4]){if(!Fe.exec(i[4]))return void(a._isValid=!1);g="Z"}a._f=e+(f||"")+(g||""),kb(a)}else a._isValid=!1}
|
||||
// date from iso format or fallback
|
||||
function fb(b){var c=Ie.exec(b._i);return null!==c?void(b._d=new Date(+c[1])):(eb(b),void(b._isValid===!1&&(delete b._isValid,a.createFromInputFallback(b))))}
|
||||
// Pick the first defined of two or three arguments.
|
||||
function gb(a,b,c){return null!=a?a:null!=b?b:c}function hb(b){
|
||||
// hooks is actually the exported moment object
|
||||
var c=new Date(a.now());return b._useUTC?[c.getUTCFullYear(),c.getUTCMonth(),c.getUTCDate()]:[c.getFullYear(),c.getMonth(),c.getDate()]}
|
||||
// convert an array to a date.
|
||||
// the array should mirror the parameters below
|
||||
// note: all values past the year are optional and will default to the lowest possible value.
|
||||
// [year, month, day , hour, minute, second, millisecond]
|
||||
function ib(a){var b,c,d,e,f=[];if(!a._d){
|
||||
// Default to current date.
|
||||
// * if no year, month, day of month are given, default to today
|
||||
// * if day of month is given, default month and year
|
||||
// * if month is given, default only year
|
||||
// * if year is given, don't default anything
|
||||
for(d=hb(a),
|
||||
//compute day of the year from weeks and weekdays
|
||||
a._w&&null==a._a[ce]&&null==a._a[be]&&jb(a),
|
||||
//if the day of the year is set, figure out what it is
|
||||
a._dayOfYear&&(e=gb(a._a[ae],d[ae]),a._dayOfYear>pa(e)&&(m(a)._overflowDayOfYear=!0),c=ta(e,0,a._dayOfYear),a._a[be]=c.getUTCMonth(),a._a[ce]=c.getUTCDate()),b=0;b<3&&null==a._a[b];++b)a._a[b]=f[b]=d[b];
|
||||
// Zero out whatever was not defaulted, including time
|
||||
for(;b<7;b++)a._a[b]=f[b]=null==a._a[b]?2===b?1:0:a._a[b];
|
||||
// Check for 24:00:00.000
|
||||
24===a._a[de]&&0===a._a[ee]&&0===a._a[fe]&&0===a._a[ge]&&(a._nextDay=!0,a._a[de]=0),a._d=(a._useUTC?ta:sa).apply(null,f),
|
||||
// Apply timezone offset from input. The actual utcOffset can be changed
|
||||
// with parseZone.
|
||||
null!=a._tzm&&a._d.setUTCMinutes(a._d.getUTCMinutes()-a._tzm),a._nextDay&&(a._a[de]=24)}}function jb(a){var b,c,d,e,f,g,h,i;if(b=a._w,null!=b.GG||null!=b.W||null!=b.E)f=1,g=4,
|
||||
// TODO: We need to take the current isoWeekYear, but that depends on
|
||||
// how we interpret now (local, utc, fixed offset). So create
|
||||
// a now version of current config (take local/utc/offset flags, and
|
||||
// create now).
|
||||
c=gb(b.GG,a._a[ae],wa(sb(),1,4).year),d=gb(b.W,1),e=gb(b.E,1),(e<1||e>7)&&(i=!0);else{f=a._locale._week.dow,g=a._locale._week.doy;var j=wa(sb(),f,g);c=gb(b.gg,a._a[ae],j.year),
|
||||
// Default to current week.
|
||||
d=gb(b.w,j.week),null!=b.d?(
|
||||
// weekday -- low day numbers are considered next week
|
||||
e=b.d,(e<0||e>6)&&(i=!0)):null!=b.e?(
|
||||
// local weekday -- counting starts from begining of week
|
||||
e=b.e+f,(b.e<0||b.e>6)&&(i=!0)):
|
||||
// default to begining of week
|
||||
e=f}d<1||d>xa(c,f,g)?m(a)._overflowWeeks=!0:null!=i?m(a)._overflowWeekday=!0:(h=va(c,d,e,f,g),a._a[ae]=h.year,a._dayOfYear=h.dayOfYear)}
|
||||
// date from string and format string
|
||||
function kb(b){
|
||||
// TODO: Move this to another part of the creation flow to prevent circular deps
|
||||
if(b._f===a.ISO_8601)return void eb(b);b._a=[],m(b).empty=!0;
|
||||
// This array is used to make a Date, either with `new Date` or `Date.UTC`
|
||||
var c,d,e,f,g,h=""+b._i,i=h.length,j=0;for(e=Y(b._f,b._locale).match(Fd)||[],c=0;c<e.length;c++)f=e[c],d=(h.match($(f,b))||[])[0],
|
||||
// console.log('token', token, 'parsedInput', parsedInput,
|
||||
// 'regex', getParseRegexForToken(token, config));
|
||||
d&&(g=h.substr(0,h.indexOf(d)),g.length>0&&m(b).unusedInput.push(g),h=h.slice(h.indexOf(d)+d.length),j+=d.length),
|
||||
// don't parse if it's not a known token
|
||||
Id[f]?(d?m(b).empty=!1:m(b).unusedTokens.push(f),da(f,d,b)):b._strict&&!d&&m(b).unusedTokens.push(f);
|
||||
// add remaining unparsed input length to the string
|
||||
m(b).charsLeftOver=i-j,h.length>0&&m(b).unusedInput.push(h),
|
||||
// clear _12h flag if hour is <= 12
|
||||
b._a[de]<=12&&m(b).bigHour===!0&&b._a[de]>0&&(m(b).bigHour=void 0),m(b).parsedDateParts=b._a.slice(0),m(b).meridiem=b._meridiem,
|
||||
// handle meridiem
|
||||
b._a[de]=lb(b._locale,b._a[de],b._meridiem),ib(b),db(b)}function lb(a,b,c){var d;
|
||||
// Fallback
|
||||
return null==c?b:null!=a.meridiemHour?a.meridiemHour(b,c):null!=a.isPM?(d=a.isPM(c),d&&b<12&&(b+=12),d||12!==b||(b=0),b):b}
|
||||
// date from string and array of format strings
|
||||
function mb(a){var b,c,d,e,f;if(0===a._f.length)return m(a).invalidFormat=!0,void(a._d=new Date(NaN));for(e=0;e<a._f.length;e++)f=0,b=q({},a),null!=a._useUTC&&(b._useUTC=a._useUTC),b._f=a._f[e],kb(b),n(b)&&(
|
||||
// if there is any input that was not parsed add a penalty for that format
|
||||
f+=m(b).charsLeftOver,
|
||||
//or tokens
|
||||
f+=10*m(b).unusedTokens.length,m(b).score=f,(null==d||f<d)&&(d=f,c=b));j(a,c||b)}function nb(a){if(!a._d){var b=L(a._i);a._a=h([b.year,b.month,b.day||b.date,b.hour,b.minute,b.second,b.millisecond],function(a){return a&&parseInt(a,10)}),ib(a)}}function ob(a){var b=new r(db(pb(a)));
|
||||
// Adding is smart enough around DST
|
||||
return b._nextDay&&(b.add(1,"d"),b._nextDay=void 0),b}function pb(a){var b=a._i,d=a._f;return a._locale=a._locale||bb(a._l),null===b||void 0===d&&""===b?o({nullInput:!0}):("string"==typeof b&&(a._i=b=a._locale.preparse(b)),s(b)?new r(db(b)):(g(b)?a._d=b:c(d)?mb(a):d?kb(a):qb(a),n(a)||(a._d=null),a))}function qb(b){var d=b._i;void 0===d?b._d=new Date(a.now()):g(d)?b._d=new Date(d.valueOf()):"string"==typeof d?fb(b):c(d)?(b._a=h(d.slice(0),function(a){return parseInt(a,10)}),ib(b)):"object"==typeof d?nb(b):f(d)?
|
||||
// from milliseconds
|
||||
b._d=new Date(d):a.createFromInputFallback(b)}function rb(a,b,f,g,h){var i={};
|
||||
// object construction must be done this way.
|
||||
// https://github.com/moment/moment/issues/1423
|
||||
return f!==!0&&f!==!1||(g=f,f=void 0),(d(a)&&e(a)||c(a)&&0===a.length)&&(a=void 0),i._isAMomentObject=!0,i._useUTC=i._isUTC=h,i._l=f,i._i=a,i._f=b,i._strict=g,ob(i)}function sb(a,b,c,d){return rb(a,b,c,d,!1)}
|
||||
// Pick a moment m from moments so that m[fn](other) is true for all
|
||||
// other. This relies on the function fn to be transitive.
|
||||
//
|
||||
// moments should either be an array of moment objects or an array, whose
|
||||
// first element is an array of moment objects.
|
||||
function tb(a,b){var d,e;if(1===b.length&&c(b[0])&&(b=b[0]),!b.length)return sb();for(d=b[0],e=1;e<b.length;++e)b[e].isValid()&&!b[e][a](d)||(d=b[e]);return d}
|
||||
// TODO: Use [].sort instead?
|
||||
function ub(){var a=[].slice.call(arguments,0);return tb("isBefore",a)}function vb(){var a=[].slice.call(arguments,0);return tb("isAfter",a)}function wb(a){var b=L(a),c=b.year||0,d=b.quarter||0,e=b.month||0,f=b.week||0,g=b.day||0,h=b.hour||0,i=b.minute||0,j=b.second||0,k=b.millisecond||0;
|
||||
// representation for dateAddRemove
|
||||
this._milliseconds=+k+1e3*j+// 1000
|
||||
6e4*i+// 1000 * 60
|
||||
1e3*h*60*60,//using 1000 * 60 * 60 instead of 36e5 to avoid floating point rounding errors https://github.com/moment/moment/issues/2978
|
||||
// Because of dateAddRemove treats 24 hours as different from a
|
||||
// day when working around DST, we need to store them separately
|
||||
this._days=+g+7*f,
|
||||
// It is impossible translate months into days without knowing
|
||||
// which months you are are talking about, so we have to store
|
||||
// it separately.
|
||||
this._months=+e+3*d+12*c,this._data={},this._locale=bb(),this._bubble()}function xb(a){return a instanceof wb}function yb(a){return a<0?Math.round(-1*a)*-1:Math.round(a)}
|
||||
// FORMATTING
|
||||
function zb(a,b){U(a,0,0,function(){var a=this.utcOffset(),c="+";return a<0&&(a=-a,c="-"),c+T(~~(a/60),2)+b+T(~~a%60,2)})}function Ab(a,b){var c=(b||"").match(a);if(null===c)return null;var d=c[c.length-1]||[],e=(d+"").match(Me)||["-",0,0],f=+(60*e[1])+u(e[2]);return 0===f?0:"+"===e[0]?f:-f}
|
||||
// Return a moment from input, that is local/utc/zone equivalent to model.
|
||||
function Bb(b,c){var d,e;
|
||||
// Use low-level api, because this fn is low-level api.
|
||||
return c._isUTC?(d=c.clone(),e=(s(b)||g(b)?b.valueOf():sb(b).valueOf())-d.valueOf(),d._d.setTime(d._d.valueOf()+e),a.updateOffset(d,!1),d):sb(b).local()}function Cb(a){
|
||||
// On Firefox.24 Date#getTimezoneOffset returns a floating point.
|
||||
// https://github.com/moment/moment/pull/1871
|
||||
return 15*-Math.round(a._d.getTimezoneOffset()/15)}
|
||||
// MOMENTS
|
||||
// keepLocalTime = true means only change the timezone, without
|
||||
// affecting the local hour. So 5:31:26 +0300 --[utcOffset(2, true)]-->
|
||||
// 5:31:26 +0200 It is possible that 5:31:26 doesn't exist with offset
|
||||
// +0200, so we adjust the time as needed, to be valid.
|
||||
//
|
||||
// Keeping the time actually adds/subtracts (one hour)
|
||||
// from the actual represented time. That is why we call updateOffset
|
||||
// a second time. In case it wants us to change the offset again
|
||||
// _changeInProgress == true case, then we have to adjust, because
|
||||
// there is no such time in the given timezone.
|
||||
function Db(b,c){var d,e=this._offset||0;if(!this.isValid())return null!=b?this:NaN;if(null!=b){if("string"==typeof b){if(b=Ab(Xd,b),null===b)return this}else Math.abs(b)<16&&(b=60*b);return!this._isUTC&&c&&(d=Cb(this)),this._offset=b,this._isUTC=!0,null!=d&&this.add(d,"m"),e!==b&&(!c||this._changeInProgress?Tb(this,Ob(b-e,"m"),1,!1):this._changeInProgress||(this._changeInProgress=!0,a.updateOffset(this,!0),this._changeInProgress=null)),this}return this._isUTC?e:Cb(this)}function Eb(a,b){return null!=a?("string"!=typeof a&&(a=-a),this.utcOffset(a,b),this):-this.utcOffset()}function Fb(a){return this.utcOffset(0,a)}function Gb(a){return this._isUTC&&(this.utcOffset(0,a),this._isUTC=!1,a&&this.subtract(Cb(this),"m")),this}function Hb(){if(null!=this._tzm)this.utcOffset(this._tzm);else if("string"==typeof this._i){var a=Ab(Wd,this._i);null!=a?this.utcOffset(a):this.utcOffset(0,!0)}return this}function Ib(a){return!!this.isValid()&&(a=a?sb(a).utcOffset():0,(this.utcOffset()-a)%60===0)}function Jb(){return this.utcOffset()>this.clone().month(0).utcOffset()||this.utcOffset()>this.clone().month(5).utcOffset()}function Kb(){if(!p(this._isDSTShifted))return this._isDSTShifted;var a={};if(q(a,this),a=pb(a),a._a){var b=a._isUTC?k(a._a):sb(a._a);this._isDSTShifted=this.isValid()&&v(a._a,b.toArray())>0}else this._isDSTShifted=!1;return this._isDSTShifted}function Lb(){return!!this.isValid()&&!this._isUTC}function Mb(){return!!this.isValid()&&this._isUTC}function Nb(){return!!this.isValid()&&(this._isUTC&&0===this._offset)}function Ob(a,b){var c,d,e,g=a,
|
||||
// matching against regexp is expensive, do it on demand
|
||||
h=null;// checks for null or undefined
|
||||
return xb(a)?g={ms:a._milliseconds,d:a._days,M:a._months}:f(a)?(g={},b?g[b]=a:g.milliseconds=a):(h=Ne.exec(a))?(c="-"===h[1]?-1:1,g={y:0,d:u(h[ce])*c,h:u(h[de])*c,m:u(h[ee])*c,s:u(h[fe])*c,ms:u(yb(1e3*h[ge]))*c}):(h=Oe.exec(a))?(c="-"===h[1]?-1:1,g={y:Pb(h[2],c),M:Pb(h[3],c),w:Pb(h[4],c),d:Pb(h[5],c),h:Pb(h[6],c),m:Pb(h[7],c),s:Pb(h[8],c)}):null==g?g={}:"object"==typeof g&&("from"in g||"to"in g)&&(e=Rb(sb(g.from),sb(g.to)),g={},g.ms=e.milliseconds,g.M=e.months),d=new wb(g),xb(a)&&i(a,"_locale")&&(d._locale=a._locale),d}function Pb(a,b){
|
||||
// We'd normally use ~~inp for this, but unfortunately it also
|
||||
// converts floats to ints.
|
||||
// inp may be undefined, so careful calling replace on it.
|
||||
var c=a&&parseFloat(a.replace(",","."));
|
||||
// apply sign while we're at it
|
||||
return(isNaN(c)?0:c)*b}function Qb(a,b){var c={milliseconds:0,months:0};return c.months=b.month()-a.month()+12*(b.year()-a.year()),a.clone().add(c.months,"M").isAfter(b)&&--c.months,c.milliseconds=+b-+a.clone().add(c.months,"M"),c}function Rb(a,b){var c;return a.isValid()&&b.isValid()?(b=Bb(b,a),a.isBefore(b)?c=Qb(a,b):(c=Qb(b,a),c.milliseconds=-c.milliseconds,c.months=-c.months),c):{milliseconds:0,months:0}}
|
||||
// TODO: remove 'name' arg after deprecation is removed
|
||||
function Sb(a,b){return function(c,d){var e,f;
|
||||
//invert the arguments, but complain about it
|
||||
return null===d||isNaN(+d)||(y(b,"moment()."+b+"(period, number) is deprecated. Please use moment()."+b+"(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."),f=c,c=d,d=f),c="string"==typeof c?+c:c,e=Ob(c,d),Tb(this,e,a),this}}function Tb(b,c,d,e){var f=c._milliseconds,g=yb(c._days),h=yb(c._months);b.isValid()&&(e=null==e||e,f&&b._d.setTime(b._d.valueOf()+f*d),g&&Q(b,"Date",P(b,"Date")+g*d),h&&ja(b,P(b,"Month")+h*d),e&&a.updateOffset(b,g||h))}function Ub(a,b){var c=a.diff(b,"days",!0);return c<-6?"sameElse":c<-1?"lastWeek":c<0?"lastDay":c<1?"sameDay":c<2?"nextDay":c<7?"nextWeek":"sameElse"}function Vb(b,c){
|
||||
// We want to compare the start of today, vs this.
|
||||
// Getting start-of-today depends on whether we're local/utc/offset or not.
|
||||
var d=b||sb(),e=Bb(d,this).startOf("day"),f=a.calendarFormat(this,e)||"sameElse",g=c&&(z(c[f])?c[f].call(this,d):c[f]);return this.format(g||this.localeData().calendar(f,this,sb(d)))}function Wb(){return new r(this)}function Xb(a,b){var c=s(a)?a:sb(a);return!(!this.isValid()||!c.isValid())&&(b=K(p(b)?"millisecond":b),"millisecond"===b?this.valueOf()>c.valueOf():c.valueOf()<this.clone().startOf(b).valueOf())}function Yb(a,b){var c=s(a)?a:sb(a);return!(!this.isValid()||!c.isValid())&&(b=K(p(b)?"millisecond":b),"millisecond"===b?this.valueOf()<c.valueOf():this.clone().endOf(b).valueOf()<c.valueOf())}function Zb(a,b,c,d){return d=d||"()",("("===d[0]?this.isAfter(a,c):!this.isBefore(a,c))&&(")"===d[1]?this.isBefore(b,c):!this.isAfter(b,c))}function $b(a,b){var c,d=s(a)?a:sb(a);return!(!this.isValid()||!d.isValid())&&(b=K(b||"millisecond"),"millisecond"===b?this.valueOf()===d.valueOf():(c=d.valueOf(),this.clone().startOf(b).valueOf()<=c&&c<=this.clone().endOf(b).valueOf()))}function _b(a,b){return this.isSame(a,b)||this.isAfter(a,b)}function ac(a,b){return this.isSame(a,b)||this.isBefore(a,b)}function bc(a,b,c){var d,e,f,g;// 1000
|
||||
// 1000 * 60
|
||||
// 1000 * 60 * 60
|
||||
// 1000 * 60 * 60 * 24, negate dst
|
||||
// 1000 * 60 * 60 * 24 * 7, negate dst
|
||||
return this.isValid()?(d=Bb(a,this),d.isValid()?(e=6e4*(d.utcOffset()-this.utcOffset()),b=K(b),"year"===b||"month"===b||"quarter"===b?(g=cc(this,d),"quarter"===b?g/=3:"year"===b&&(g/=12)):(f=this-d,g="second"===b?f/1e3:"minute"===b?f/6e4:"hour"===b?f/36e5:"day"===b?(f-e)/864e5:"week"===b?(f-e)/6048e5:f),c?g:t(g)):NaN):NaN}function cc(a,b){
|
||||
// difference in months
|
||||
var c,d,e=12*(b.year()-a.year())+(b.month()-a.month()),
|
||||
// b is in (anchor - 1 month, anchor + 1 month)
|
||||
f=a.clone().add(e,"months");
|
||||
//check for negative zero, return zero if negative zero
|
||||
// linear across the month
|
||||
// linear across the month
|
||||
return b-f<0?(c=a.clone().add(e-1,"months"),d=(b-f)/(f-c)):(c=a.clone().add(e+1,"months"),d=(b-f)/(c-f)),-(e+d)||0}function dc(){return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ")}function ec(){var a=this.clone().utc();return 0<a.year()&&a.year()<=9999?z(Date.prototype.toISOString)?this.toDate().toISOString():X(a,"YYYY-MM-DD[T]HH:mm:ss.SSS[Z]"):X(a,"YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]")}/**
|
||||
* Return a human readable representation of a moment that can
|
||||
* also be evaluated to get a new moment which is the same
|
||||
*
|
||||
* @link https://nodejs.org/dist/latest/docs/api/util.html#util_custom_inspect_function_on_objects
|
||||
*/
|
||||
function fc(){if(!this.isValid())return"moment.invalid(/* "+this._i+" */)";var a="moment",b="";this.isLocal()||(a=0===this.utcOffset()?"moment.utc":"moment.parseZone",b="Z");var c="["+a+'("]',d=0<this.year()&&this.year()<=9999?"YYYY":"YYYYYY",e="-MM-DD[T]HH:mm:ss.SSS",f=b+'[")]';return this.format(c+d+e+f)}function gc(b){b||(b=this.isUtc()?a.defaultFormatUtc:a.defaultFormat);var c=X(this,b);return this.localeData().postformat(c)}function hc(a,b){return this.isValid()&&(s(a)&&a.isValid()||sb(a).isValid())?Ob({to:this,from:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function ic(a){return this.from(sb(),a)}function jc(a,b){return this.isValid()&&(s(a)&&a.isValid()||sb(a).isValid())?Ob({from:this,to:a}).locale(this.locale()).humanize(!b):this.localeData().invalidDate()}function kc(a){return this.to(sb(),a)}
|
||||
// If passed a locale key, it will set the locale for this
|
||||
// instance. Otherwise, it will return the locale configuration
|
||||
// variables for this instance.
|
||||
function lc(a){var b;return void 0===a?this._locale._abbr:(b=bb(a),null!=b&&(this._locale=b),this)}function mc(){return this._locale}function nc(a){
|
||||
// the following switch intentionally omits break keywords
|
||||
// to utilize falling through the cases.
|
||||
switch(a=K(a)){case"year":this.month(0);/* falls through */
|
||||
case"quarter":case"month":this.date(1);/* falls through */
|
||||
case"week":case"isoWeek":case"day":case"date":this.hours(0);/* falls through */
|
||||
case"hour":this.minutes(0);/* falls through */
|
||||
case"minute":this.seconds(0);/* falls through */
|
||||
case"second":this.milliseconds(0)}
|
||||
// weeks are a special case
|
||||
// quarters are also special
|
||||
return"week"===a&&this.weekday(0),"isoWeek"===a&&this.isoWeekday(1),"quarter"===a&&this.month(3*Math.floor(this.month()/3)),this}function oc(a){
|
||||
// 'date' is an alias for 'day', so it should be considered as such.
|
||||
return a=K(a),void 0===a||"millisecond"===a?this:("date"===a&&(a="day"),this.startOf(a).add(1,"isoWeek"===a?"week":a).subtract(1,"ms"))}function pc(){return this._d.valueOf()-6e4*(this._offset||0)}function qc(){return Math.floor(this.valueOf()/1e3)}function rc(){return new Date(this.valueOf())}function sc(){var a=this;return[a.year(),a.month(),a.date(),a.hour(),a.minute(),a.second(),a.millisecond()]}function tc(){var a=this;return{years:a.year(),months:a.month(),date:a.date(),hours:a.hours(),minutes:a.minutes(),seconds:a.seconds(),milliseconds:a.milliseconds()}}function uc(){
|
||||
// new Date(NaN).toJSON() === null
|
||||
return this.isValid()?this.toISOString():null}function vc(){return n(this)}function wc(){return j({},m(this))}function xc(){return m(this).overflow}function yc(){return{input:this._i,format:this._f,locale:this._locale,isUTC:this._isUTC,strict:this._strict}}function zc(a,b){U(0,[a,a.length],0,b)}
|
||||
// MOMENTS
|
||||
function Ac(a){return Ec.call(this,a,this.week(),this.weekday(),this.localeData()._week.dow,this.localeData()._week.doy)}function Bc(a){return Ec.call(this,a,this.isoWeek(),this.isoWeekday(),1,4)}function Cc(){return xa(this.year(),1,4)}function Dc(){var a=this.localeData()._week;return xa(this.year(),a.dow,a.doy)}function Ec(a,b,c,d,e){var f;return null==a?wa(this,d,e).year:(f=xa(a,d,e),b>f&&(b=f),Fc.call(this,a,b,c,d,e))}function Fc(a,b,c,d,e){var f=va(a,b,c,d,e),g=ta(f.year,0,f.dayOfYear);return this.year(g.getUTCFullYear()),this.month(g.getUTCMonth()),this.date(g.getUTCDate()),this}
|
||||
// MOMENTS
|
||||
function Gc(a){return null==a?Math.ceil((this.month()+1)/3):this.month(3*(a-1)+this.month()%3)}
|
||||
// HELPERS
|
||||
// MOMENTS
|
||||
function Hc(a){var b=Math.round((this.clone().startOf("day")-this.clone().startOf("year"))/864e5)+1;return null==a?b:this.add(a-b,"d")}function Ic(a,b){b[ge]=u(1e3*("0."+a))}
|
||||
// MOMENTS
|
||||
function Jc(){return this._isUTC?"UTC":""}function Kc(){return this._isUTC?"Coordinated Universal Time":""}function Lc(a){return sb(1e3*a)}function Mc(){return sb.apply(null,arguments).parseZone()}function Nc(a){return a}function Oc(a,b,c,d){var e=bb(),f=k().set(d,b);return e[c](f,a)}function Pc(a,b,c){if(f(a)&&(b=a,a=void 0),a=a||"",null!=b)return Oc(a,b,c,"month");var d,e=[];for(d=0;d<12;d++)e[d]=Oc(a,d,c,"month");return e}
|
||||
// ()
|
||||
// (5)
|
||||
// (fmt, 5)
|
||||
// (fmt)
|
||||
// (true)
|
||||
// (true, 5)
|
||||
// (true, fmt, 5)
|
||||
// (true, fmt)
|
||||
function Qc(a,b,c,d){"boolean"==typeof a?(f(b)&&(c=b,b=void 0),b=b||""):(b=a,c=b,a=!1,f(b)&&(c=b,b=void 0),b=b||"");var e=bb(),g=a?e._week.dow:0;if(null!=c)return Oc(b,(c+g)%7,d,"day");var h,i=[];for(h=0;h<7;h++)i[h]=Oc(b,(h+g)%7,d,"day");return i}function Rc(a,b){return Pc(a,b,"months")}function Sc(a,b){return Pc(a,b,"monthsShort")}function Tc(a,b,c){return Qc(a,b,c,"weekdays")}function Uc(a,b,c){return Qc(a,b,c,"weekdaysShort")}function Vc(a,b,c){return Qc(a,b,c,"weekdaysMin")}function Wc(){var a=this._data;return this._milliseconds=Ze(this._milliseconds),this._days=Ze(this._days),this._months=Ze(this._months),a.milliseconds=Ze(a.milliseconds),a.seconds=Ze(a.seconds),a.minutes=Ze(a.minutes),a.hours=Ze(a.hours),a.months=Ze(a.months),a.years=Ze(a.years),this}function Xc(a,b,c,d){var e=Ob(b,c);return a._milliseconds+=d*e._milliseconds,a._days+=d*e._days,a._months+=d*e._months,a._bubble()}
|
||||
// supports only 2.0-style add(1, 's') or add(duration)
|
||||
function Yc(a,b){return Xc(this,a,b,1)}
|
||||
// supports only 2.0-style subtract(1, 's') or subtract(duration)
|
||||
function Zc(a,b){return Xc(this,a,b,-1)}function $c(a){return a<0?Math.floor(a):Math.ceil(a)}function _c(){var a,b,c,d,e,f=this._milliseconds,g=this._days,h=this._months,i=this._data;
|
||||
// if we have a mix of positive and negative values, bubble down first
|
||||
// check: https://github.com/moment/moment/issues/2166
|
||||
// The following code bubbles up values, see the tests for
|
||||
// examples of what that means.
|
||||
// convert days to months
|
||||
// 12 months -> 1 year
|
||||
return f>=0&&g>=0&&h>=0||f<=0&&g<=0&&h<=0||(f+=864e5*$c(bd(h)+g),g=0,h=0),i.milliseconds=f%1e3,a=t(f/1e3),i.seconds=a%60,b=t(a/60),i.minutes=b%60,c=t(b/60),i.hours=c%24,g+=t(c/24),e=t(ad(g)),h+=e,g-=$c(bd(e)),d=t(h/12),h%=12,i.days=g,i.months=h,i.years=d,this}function ad(a){
|
||||
// 400 years have 146097 days (taking into account leap year rules)
|
||||
// 400 years have 12 months === 4800
|
||||
return 4800*a/146097}function bd(a){
|
||||
// the reverse of daysToMonths
|
||||
return 146097*a/4800}function cd(a){var b,c,d=this._milliseconds;if(a=K(a),"month"===a||"year"===a)return b=this._days+d/864e5,c=this._months+ad(b),"month"===a?c:c/12;switch(
|
||||
// handle milliseconds separately because of floating point math errors (issue #1867)
|
||||
b=this._days+Math.round(bd(this._months)),a){case"week":return b/7+d/6048e5;case"day":return b+d/864e5;case"hour":return 24*b+d/36e5;case"minute":return 1440*b+d/6e4;case"second":return 86400*b+d/1e3;
|
||||
// Math.floor prevents floating point math errors here
|
||||
case"millisecond":return Math.floor(864e5*b)+d;default:throw new Error("Unknown unit "+a)}}
|
||||
// TODO: Use this.as('ms')?
|
||||
function dd(){return this._milliseconds+864e5*this._days+this._months%12*2592e6+31536e6*u(this._months/12)}function ed(a){return function(){return this.as(a)}}function fd(a){return a=K(a),this[a+"s"]()}function gd(a){return function(){return this._data[a]}}function hd(){return t(this.days()/7)}
|
||||
// helper function for moment.fn.from, moment.fn.fromNow, and moment.duration.fn.humanize
|
||||
function id(a,b,c,d,e){return e.relativeTime(b||1,!!c,a,d)}function jd(a,b,c){var d=Ob(a).abs(),e=of(d.as("s")),f=of(d.as("m")),g=of(d.as("h")),h=of(d.as("d")),i=of(d.as("M")),j=of(d.as("y")),k=e<pf.s&&["s",e]||f<=1&&["m"]||f<pf.m&&["mm",f]||g<=1&&["h"]||g<pf.h&&["hh",g]||h<=1&&["d"]||h<pf.d&&["dd",h]||i<=1&&["M"]||i<pf.M&&["MM",i]||j<=1&&["y"]||["yy",j];return k[2]=b,k[3]=+a>0,k[4]=c,id.apply(null,k)}
|
||||
// This function allows you to set the rounding function for relative time strings
|
||||
function kd(a){return void 0===a?of:"function"==typeof a&&(of=a,!0)}
|
||||
// This function allows you to set a threshold for relative time strings
|
||||
function ld(a,b){return void 0!==pf[a]&&(void 0===b?pf[a]:(pf[a]=b,!0))}function md(a){var b=this.localeData(),c=jd(this,!a,b);return a&&(c=b.pastFuture(+this,c)),b.postformat(c)}function nd(){
|
||||
// for ISO strings we do not use the normal bubbling rules:
|
||||
// * milliseconds bubble up until they become hours
|
||||
// * days do not bubble at all
|
||||
// * months bubble up until they become years
|
||||
// This is because there is no context-free conversion between hours and days
|
||||
// (think of clock changes)
|
||||
// and also not between days and months (28-31 days per month)
|
||||
var a,b,c,d=qf(this._milliseconds)/1e3,e=qf(this._days),f=qf(this._months);
|
||||
// 3600 seconds -> 60 minutes -> 1 hour
|
||||
a=t(d/60),b=t(a/60),d%=60,a%=60,
|
||||
// 12 months -> 1 year
|
||||
c=t(f/12),f%=12;
|
||||
// inspired by https://github.com/dordille/moment-isoduration/blob/master/moment.isoduration.js
|
||||
var g=c,h=f,i=e,j=b,k=a,l=d,m=this.asSeconds();return m?(m<0?"-":"")+"P"+(g?g+"Y":"")+(h?h+"M":"")+(i?i+"D":"")+(j||k||l?"T":"")+(j?j+"H":"")+(k?k+"M":"")+(l?l+"S":""):"P0D"}var od,pd;pd=Array.prototype.some?Array.prototype.some:function(a){for(var b=Object(this),c=b.length>>>0,d=0;d<c;d++)if(d in b&&a.call(this,b[d],d,b))return!0;return!1};var qd=pd,rd=a.momentProperties=[],sd=!1,td={};a.suppressDeprecationWarnings=!1,a.deprecationHandler=null;var ud;ud=Object.keys?Object.keys:function(a){var b,c=[];for(b in a)i(a,b)&&c.push(b);return c};var vd,wd=ud,xd={sameDay:"[Today at] LT",nextDay:"[Tomorrow at] LT",nextWeek:"dddd [at] LT",lastDay:"[Yesterday at] LT",lastWeek:"[Last] dddd [at] LT",sameElse:"L"},yd={LTS:"h:mm:ss A",LT:"h:mm A",L:"MM/DD/YYYY",LL:"MMMM D, YYYY",LLL:"MMMM D, YYYY h:mm A",LLLL:"dddd, MMMM D, YYYY h:mm A"},zd="Invalid date",Ad="%d",Bd=/\d{1,2}/,Cd={future:"in %s",past:"%s ago",s:"a few seconds",m:"a minute",mm:"%d minutes",h:"an hour",hh:"%d hours",d:"a day",dd:"%d days",M:"a month",MM:"%d months",y:"a year",yy:"%d years"},Dd={},Ed={},Fd=/(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|YYYYYY|YYYYY|YYYY|YY|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g,Gd=/(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g,Hd={},Id={},Jd=/\d/,Kd=/\d\d/,Ld=/\d{3}/,Md=/\d{4}/,Nd=/[+-]?\d{6}/,Od=/\d\d?/,Pd=/\d\d\d\d?/,Qd=/\d\d\d\d\d\d?/,Rd=/\d{1,3}/,Sd=/\d{1,4}/,Td=/[+-]?\d{1,6}/,Ud=/\d+/,Vd=/[+-]?\d+/,Wd=/Z|[+-]\d\d:?\d\d/gi,Xd=/Z|[+-]\d\d(?::?\d\d)?/gi,Yd=/[+-]?\d+(\.\d{1,3})?/,Zd=/[0-9]*['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]+|[\u0600-\u06FF\/]+(\s*?[\u0600-\u06FF]+){1,2}/i,$d={},_d={},ae=0,be=1,ce=2,de=3,ee=4,fe=5,ge=6,he=7,ie=8;vd=Array.prototype.indexOf?Array.prototype.indexOf:function(a){
|
||||
// I know
|
||||
var b;for(b=0;b<this.length;++b)if(this[b]===a)return b;return-1};var je=vd;
|
||||
// FORMATTING
|
||||
U("M",["MM",2],"Mo",function(){return this.month()+1}),U("MMM",0,0,function(a){return this.localeData().monthsShort(this,a)}),U("MMMM",0,0,function(a){return this.localeData().months(this,a)}),
|
||||
// ALIASES
|
||||
J("month","M"),
|
||||
// PRIORITY
|
||||
M("month",8),
|
||||
// PARSING
|
||||
Z("M",Od),Z("MM",Od,Kd),Z("MMM",function(a,b){return b.monthsShortRegex(a)}),Z("MMMM",function(a,b){return b.monthsRegex(a)}),ba(["M","MM"],function(a,b){b[be]=u(a)-1}),ba(["MMM","MMMM"],function(a,b,c,d){var e=c._locale.monthsParse(a,d,c._strict);
|
||||
// if we didn't find a month name, mark the date as invalid.
|
||||
null!=e?b[be]=e:m(c).invalidMonth=a});
|
||||
// LOCALES
|
||||
var ke=/D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/,le="January_February_March_April_May_June_July_August_September_October_November_December".split("_"),me="Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"),ne=Zd,oe=Zd;
|
||||
// FORMATTING
|
||||
U("Y",0,0,function(){var a=this.year();return a<=9999?""+a:"+"+a}),U(0,["YY",2],0,function(){return this.year()%100}),U(0,["YYYY",4],0,"year"),U(0,["YYYYY",5],0,"year"),U(0,["YYYYYY",6,!0],0,"year"),
|
||||
// ALIASES
|
||||
J("year","y"),
|
||||
// PRIORITIES
|
||||
M("year",1),
|
||||
// PARSING
|
||||
Z("Y",Vd),Z("YY",Od,Kd),Z("YYYY",Sd,Md),Z("YYYYY",Td,Nd),Z("YYYYYY",Td,Nd),ba(["YYYYY","YYYYYY"],ae),ba("YYYY",function(b,c){c[ae]=2===b.length?a.parseTwoDigitYear(b):u(b)}),ba("YY",function(b,c){c[ae]=a.parseTwoDigitYear(b)}),ba("Y",function(a,b){b[ae]=parseInt(a,10)}),
|
||||
// HOOKS
|
||||
a.parseTwoDigitYear=function(a){return u(a)+(u(a)>68?1900:2e3)};
|
||||
// MOMENTS
|
||||
var pe=O("FullYear",!0);
|
||||
// FORMATTING
|
||||
U("w",["ww",2],"wo","week"),U("W",["WW",2],"Wo","isoWeek"),
|
||||
// ALIASES
|
||||
J("week","w"),J("isoWeek","W"),
|
||||
// PRIORITIES
|
||||
M("week",5),M("isoWeek",5),
|
||||
// PARSING
|
||||
Z("w",Od),Z("ww",Od,Kd),Z("W",Od),Z("WW",Od,Kd),ca(["w","ww","W","WW"],function(a,b,c,d){b[d.substr(0,1)]=u(a)});var qe={dow:0,// Sunday is the first day of the week.
|
||||
doy:6};
|
||||
// FORMATTING
|
||||
U("d",0,"do","day"),U("dd",0,0,function(a){return this.localeData().weekdaysMin(this,a)}),U("ddd",0,0,function(a){return this.localeData().weekdaysShort(this,a)}),U("dddd",0,0,function(a){return this.localeData().weekdays(this,a)}),U("e",0,0,"weekday"),U("E",0,0,"isoWeekday"),
|
||||
// ALIASES
|
||||
J("day","d"),J("weekday","e"),J("isoWeekday","E"),
|
||||
// PRIORITY
|
||||
M("day",11),M("weekday",11),M("isoWeekday",11),
|
||||
// PARSING
|
||||
Z("d",Od),Z("e",Od),Z("E",Od),Z("dd",function(a,b){return b.weekdaysMinRegex(a)}),Z("ddd",function(a,b){return b.weekdaysShortRegex(a)}),Z("dddd",function(a,b){return b.weekdaysRegex(a)}),ca(["dd","ddd","dddd"],function(a,b,c,d){var e=c._locale.weekdaysParse(a,d,c._strict);
|
||||
// if we didn't get a weekday name, mark the date as invalid
|
||||
null!=e?b.d=e:m(c).invalidWeekday=a}),ca(["d","e","E"],function(a,b,c,d){b[d]=u(a)});
|
||||
// LOCALES
|
||||
var re="Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),se="Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"),te="Su_Mo_Tu_We_Th_Fr_Sa".split("_"),ue=Zd,ve=Zd,we=Zd;U("H",["HH",2],0,"hour"),U("h",["hh",2],0,Ra),U("k",["kk",2],0,Sa),U("hmm",0,0,function(){return""+Ra.apply(this)+T(this.minutes(),2)}),U("hmmss",0,0,function(){return""+Ra.apply(this)+T(this.minutes(),2)+T(this.seconds(),2)}),U("Hmm",0,0,function(){return""+this.hours()+T(this.minutes(),2)}),U("Hmmss",0,0,function(){return""+this.hours()+T(this.minutes(),2)+T(this.seconds(),2)}),Ta("a",!0),Ta("A",!1),
|
||||
// ALIASES
|
||||
J("hour","h"),
|
||||
// PRIORITY
|
||||
M("hour",13),Z("a",Ua),Z("A",Ua),Z("H",Od),Z("h",Od),Z("HH",Od,Kd),Z("hh",Od,Kd),Z("hmm",Pd),Z("hmmss",Qd),Z("Hmm",Pd),Z("Hmmss",Qd),ba(["H","HH"],de),ba(["a","A"],function(a,b,c){c._isPm=c._locale.isPM(a),c._meridiem=a}),ba(["h","hh"],function(a,b,c){b[de]=u(a),m(c).bigHour=!0}),ba("hmm",function(a,b,c){var d=a.length-2;b[de]=u(a.substr(0,d)),b[ee]=u(a.substr(d)),m(c).bigHour=!0}),ba("hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[de]=u(a.substr(0,d)),b[ee]=u(a.substr(d,2)),b[fe]=u(a.substr(e)),m(c).bigHour=!0}),ba("Hmm",function(a,b,c){var d=a.length-2;b[de]=u(a.substr(0,d)),b[ee]=u(a.substr(d))}),ba("Hmmss",function(a,b,c){var d=a.length-4,e=a.length-2;b[de]=u(a.substr(0,d)),b[ee]=u(a.substr(d,2)),b[fe]=u(a.substr(e))});var xe,ye=/[ap]\.?m?\.?/i,ze=O("Hours",!0),Ae={calendar:xd,longDateFormat:yd,invalidDate:zd,ordinal:Ad,ordinalParse:Bd,relativeTime:Cd,months:le,monthsShort:me,week:qe,weekdays:re,weekdaysMin:te,weekdaysShort:se,meridiemParse:ye},Be={},Ce={},De=/^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Ee=/^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([\+\-]\d\d(?::?\d\d)?|\s*Z)?)?$/,Fe=/Z|[+-]\d\d(?::?\d\d)?/,Ge=[["YYYYYY-MM-DD",/[+-]\d{6}-\d\d-\d\d/],["YYYY-MM-DD",/\d{4}-\d\d-\d\d/],["GGGG-[W]WW-E",/\d{4}-W\d\d-\d/],["GGGG-[W]WW",/\d{4}-W\d\d/,!1],["YYYY-DDD",/\d{4}-\d{3}/],["YYYY-MM",/\d{4}-\d\d/,!1],["YYYYYYMMDD",/[+-]\d{10}/],["YYYYMMDD",/\d{8}/],
|
||||
// YYYYMM is NOT allowed by the standard
|
||||
["GGGG[W]WWE",/\d{4}W\d{3}/],["GGGG[W]WW",/\d{4}W\d{2}/,!1],["YYYYDDD",/\d{7}/]],He=[["HH:mm:ss.SSSS",/\d\d:\d\d:\d\d\.\d+/],["HH:mm:ss,SSSS",/\d\d:\d\d:\d\d,\d+/],["HH:mm:ss",/\d\d:\d\d:\d\d/],["HH:mm",/\d\d:\d\d/],["HHmmss.SSSS",/\d\d\d\d\d\d\.\d+/],["HHmmss,SSSS",/\d\d\d\d\d\d,\d+/],["HHmmss",/\d\d\d\d\d\d/],["HHmm",/\d\d\d\d/],["HH",/\d\d/]],Ie=/^\/?Date\((\-?\d+)/i;a.createFromInputFallback=x("value provided is not in a recognized ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non ISO date formats are discouraged and will be removed in an upcoming major release. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",function(a){a._d=new Date(a._i+(a._useUTC?" UTC":""))}),
|
||||
// constant that refers to the ISO standard
|
||||
a.ISO_8601=function(){};var Je=x("moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var a=sb.apply(null,arguments);return this.isValid()&&a.isValid()?a<this?this:a:o()}),Ke=x("moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",function(){var a=sb.apply(null,arguments);return this.isValid()&&a.isValid()?a>this?this:a:o()}),Le=function(){return Date.now?Date.now():+new Date};zb("Z",":"),zb("ZZ",""),
|
||||
// PARSING
|
||||
Z("Z",Xd),Z("ZZ",Xd),ba(["Z","ZZ"],function(a,b,c){c._useUTC=!0,c._tzm=Ab(Xd,a)});
|
||||
// HELPERS
|
||||
// timezone chunker
|
||||
// '+10:00' > ['10', '00']
|
||||
// '-1530' > ['-15', '30']
|
||||
var Me=/([\+\-]|\d\d)/gi;
|
||||
// HOOKS
|
||||
// This function will be called whenever a moment is mutated.
|
||||
// It is intended to keep the offset in sync with the timezone.
|
||||
a.updateOffset=function(){};
|
||||
// ASP.NET json date format regex
|
||||
var Ne=/^(\-)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/,Oe=/^(-)?P(?:(-?[0-9,.]*)Y)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)W)?(?:(-?[0-9,.]*)D)?(?:T(?:(-?[0-9,.]*)H)?(?:(-?[0-9,.]*)M)?(?:(-?[0-9,.]*)S)?)?$/;Ob.fn=wb.prototype;var Pe=Sb(1,"add"),Qe=Sb(-1,"subtract");a.defaultFormat="YYYY-MM-DDTHH:mm:ssZ",a.defaultFormatUtc="YYYY-MM-DDTHH:mm:ss[Z]";var Re=x("moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",function(a){return void 0===a?this.localeData():this.locale(a)});
|
||||
// FORMATTING
|
||||
U(0,["gg",2],0,function(){return this.weekYear()%100}),U(0,["GG",2],0,function(){return this.isoWeekYear()%100}),zc("gggg","weekYear"),zc("ggggg","weekYear"),zc("GGGG","isoWeekYear"),zc("GGGGG","isoWeekYear"),
|
||||
// ALIASES
|
||||
J("weekYear","gg"),J("isoWeekYear","GG"),
|
||||
// PRIORITY
|
||||
M("weekYear",1),M("isoWeekYear",1),
|
||||
// PARSING
|
||||
Z("G",Vd),Z("g",Vd),Z("GG",Od,Kd),Z("gg",Od,Kd),Z("GGGG",Sd,Md),Z("gggg",Sd,Md),Z("GGGGG",Td,Nd),Z("ggggg",Td,Nd),ca(["gggg","ggggg","GGGG","GGGGG"],function(a,b,c,d){b[d.substr(0,2)]=u(a)}),ca(["gg","GG"],function(b,c,d,e){c[e]=a.parseTwoDigitYear(b)}),
|
||||
// FORMATTING
|
||||
U("Q",0,"Qo","quarter"),
|
||||
// ALIASES
|
||||
J("quarter","Q"),
|
||||
// PRIORITY
|
||||
M("quarter",7),
|
||||
// PARSING
|
||||
Z("Q",Jd),ba("Q",function(a,b){b[be]=3*(u(a)-1)}),
|
||||
// FORMATTING
|
||||
U("D",["DD",2],"Do","date"),
|
||||
// ALIASES
|
||||
J("date","D"),
|
||||
// PRIOROITY
|
||||
M("date",9),
|
||||
// PARSING
|
||||
Z("D",Od),Z("DD",Od,Kd),Z("Do",function(a,b){return a?b._ordinalParse:b._ordinalParseLenient}),ba(["D","DD"],ce),ba("Do",function(a,b){b[ce]=u(a.match(Od)[0],10)});
|
||||
// MOMENTS
|
||||
var Se=O("Date",!0);
|
||||
// FORMATTING
|
||||
U("DDD",["DDDD",3],"DDDo","dayOfYear"),
|
||||
// ALIASES
|
||||
J("dayOfYear","DDD"),
|
||||
// PRIORITY
|
||||
M("dayOfYear",4),
|
||||
// PARSING
|
||||
Z("DDD",Rd),Z("DDDD",Ld),ba(["DDD","DDDD"],function(a,b,c){c._dayOfYear=u(a)}),
|
||||
// FORMATTING
|
||||
U("m",["mm",2],0,"minute"),
|
||||
// ALIASES
|
||||
J("minute","m"),
|
||||
// PRIORITY
|
||||
M("minute",14),
|
||||
// PARSING
|
||||
Z("m",Od),Z("mm",Od,Kd),ba(["m","mm"],ee);
|
||||
// MOMENTS
|
||||
var Te=O("Minutes",!1);
|
||||
// FORMATTING
|
||||
U("s",["ss",2],0,"second"),
|
||||
// ALIASES
|
||||
J("second","s"),
|
||||
// PRIORITY
|
||||
M("second",15),
|
||||
// PARSING
|
||||
Z("s",Od),Z("ss",Od,Kd),ba(["s","ss"],fe);
|
||||
// MOMENTS
|
||||
var Ue=O("Seconds",!1);
|
||||
// FORMATTING
|
||||
U("S",0,0,function(){return~~(this.millisecond()/100)}),U(0,["SS",2],0,function(){return~~(this.millisecond()/10)}),U(0,["SSS",3],0,"millisecond"),U(0,["SSSS",4],0,function(){return 10*this.millisecond()}),U(0,["SSSSS",5],0,function(){return 100*this.millisecond()}),U(0,["SSSSSS",6],0,function(){return 1e3*this.millisecond()}),U(0,["SSSSSSS",7],0,function(){return 1e4*this.millisecond()}),U(0,["SSSSSSSS",8],0,function(){return 1e5*this.millisecond()}),U(0,["SSSSSSSSS",9],0,function(){return 1e6*this.millisecond()}),
|
||||
// ALIASES
|
||||
J("millisecond","ms"),
|
||||
// PRIORITY
|
||||
M("millisecond",16),
|
||||
// PARSING
|
||||
Z("S",Rd,Jd),Z("SS",Rd,Kd),Z("SSS",Rd,Ld);var Ve;for(Ve="SSSS";Ve.length<=9;Ve+="S")Z(Ve,Ud);for(Ve="S";Ve.length<=9;Ve+="S")ba(Ve,Ic);
|
||||
// MOMENTS
|
||||
var We=O("Milliseconds",!1);
|
||||
// FORMATTING
|
||||
U("z",0,0,"zoneAbbr"),U("zz",0,0,"zoneName");var Xe=r.prototype;Xe.add=Pe,Xe.calendar=Vb,Xe.clone=Wb,Xe.diff=bc,Xe.endOf=oc,Xe.format=gc,Xe.from=hc,Xe.fromNow=ic,Xe.to=jc,Xe.toNow=kc,Xe.get=R,Xe.invalidAt=xc,Xe.isAfter=Xb,Xe.isBefore=Yb,Xe.isBetween=Zb,Xe.isSame=$b,Xe.isSameOrAfter=_b,Xe.isSameOrBefore=ac,Xe.isValid=vc,Xe.lang=Re,Xe.locale=lc,Xe.localeData=mc,Xe.max=Ke,Xe.min=Je,Xe.parsingFlags=wc,Xe.set=S,Xe.startOf=nc,Xe.subtract=Qe,Xe.toArray=sc,Xe.toObject=tc,Xe.toDate=rc,Xe.toISOString=ec,Xe.inspect=fc,Xe.toJSON=uc,Xe.toString=dc,Xe.unix=qc,Xe.valueOf=pc,Xe.creationData=yc,
|
||||
// Year
|
||||
Xe.year=pe,Xe.isLeapYear=ra,
|
||||
// Week Year
|
||||
Xe.weekYear=Ac,Xe.isoWeekYear=Bc,
|
||||
// Quarter
|
||||
Xe.quarter=Xe.quarters=Gc,
|
||||
// Month
|
||||
Xe.month=ka,Xe.daysInMonth=la,
|
||||
// Week
|
||||
Xe.week=Xe.weeks=Ba,Xe.isoWeek=Xe.isoWeeks=Ca,Xe.weeksInYear=Dc,Xe.isoWeeksInYear=Cc,
|
||||
// Day
|
||||
Xe.date=Se,Xe.day=Xe.days=Ka,Xe.weekday=La,Xe.isoWeekday=Ma,Xe.dayOfYear=Hc,
|
||||
// Hour
|
||||
Xe.hour=Xe.hours=ze,
|
||||
// Minute
|
||||
Xe.minute=Xe.minutes=Te,
|
||||
// Second
|
||||
Xe.second=Xe.seconds=Ue,
|
||||
// Millisecond
|
||||
Xe.millisecond=Xe.milliseconds=We,
|
||||
// Offset
|
||||
Xe.utcOffset=Db,Xe.utc=Fb,Xe.local=Gb,Xe.parseZone=Hb,Xe.hasAlignedHourOffset=Ib,Xe.isDST=Jb,Xe.isLocal=Lb,Xe.isUtcOffset=Mb,Xe.isUtc=Nb,Xe.isUTC=Nb,
|
||||
// Timezone
|
||||
Xe.zoneAbbr=Jc,Xe.zoneName=Kc,
|
||||
// Deprecations
|
||||
Xe.dates=x("dates accessor is deprecated. Use date instead.",Se),Xe.months=x("months accessor is deprecated. Use month instead",ka),Xe.years=x("years accessor is deprecated. Use year instead",pe),Xe.zone=x("moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",Eb),Xe.isDSTShifted=x("isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",Kb);var Ye=C.prototype;Ye.calendar=D,Ye.longDateFormat=E,Ye.invalidDate=F,Ye.ordinal=G,Ye.preparse=Nc,Ye.postformat=Nc,Ye.relativeTime=H,Ye.pastFuture=I,Ye.set=A,
|
||||
// Month
|
||||
Ye.months=fa,Ye.monthsShort=ga,Ye.monthsParse=ia,Ye.monthsRegex=na,Ye.monthsShortRegex=ma,
|
||||
// Week
|
||||
Ye.week=ya,Ye.firstDayOfYear=Aa,Ye.firstDayOfWeek=za,
|
||||
// Day of Week
|
||||
Ye.weekdays=Fa,Ye.weekdaysMin=Ha,Ye.weekdaysShort=Ga,Ye.weekdaysParse=Ja,Ye.weekdaysRegex=Na,Ye.weekdaysShortRegex=Oa,Ye.weekdaysMinRegex=Pa,
|
||||
// Hours
|
||||
Ye.isPM=Va,Ye.meridiem=Wa,$a("en",{ordinalParse:/\d{1,2}(th|st|nd|rd)/,ordinal:function(a){var b=a%10,c=1===u(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th";return a+c}}),
|
||||
// Side effect imports
|
||||
a.lang=x("moment.lang is deprecated. Use moment.locale instead.",$a),a.langData=x("moment.langData is deprecated. Use moment.localeData instead.",bb);var Ze=Math.abs,$e=ed("ms"),_e=ed("s"),af=ed("m"),bf=ed("h"),cf=ed("d"),df=ed("w"),ef=ed("M"),ff=ed("y"),gf=gd("milliseconds"),hf=gd("seconds"),jf=gd("minutes"),kf=gd("hours"),lf=gd("days"),mf=gd("months"),nf=gd("years"),of=Math.round,pf={s:45,// seconds to minute
|
||||
m:45,// minutes to hour
|
||||
h:22,// hours to day
|
||||
d:26,// days to month
|
||||
M:11},qf=Math.abs,rf=wb.prototype;
|
||||
// Deprecations
|
||||
// Side effect imports
|
||||
// FORMATTING
|
||||
// PARSING
|
||||
// Side effect imports
|
||||
return rf.abs=Wc,rf.add=Yc,rf.subtract=Zc,rf.as=cd,rf.asMilliseconds=$e,rf.asSeconds=_e,rf.asMinutes=af,rf.asHours=bf,rf.asDays=cf,rf.asWeeks=df,rf.asMonths=ef,rf.asYears=ff,rf.valueOf=dd,rf._bubble=_c,rf.get=fd,rf.milliseconds=gf,rf.seconds=hf,rf.minutes=jf,rf.hours=kf,rf.days=lf,rf.weeks=hd,rf.months=mf,rf.years=nf,rf.humanize=md,rf.toISOString=nd,rf.toString=nd,rf.toJSON=nd,rf.locale=lc,rf.localeData=mc,rf.toIsoString=x("toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",nd),rf.lang=Re,U("X",0,0,"unix"),U("x",0,0,"valueOf"),Z("x",Vd),Z("X",Yd),ba("X",function(a,b,c){c._d=new Date(1e3*parseFloat(a,10))}),ba("x",function(a,b,c){c._d=new Date(u(a))}),a.version="2.17.1",b(sb),a.fn=Xe,a.min=ub,a.max=vb,a.now=Le,a.utc=k,a.unix=Lc,a.months=Rc,a.isDate=g,a.locale=$a,a.invalid=o,a.duration=Ob,a.isMoment=s,a.weekdays=Tc,a.parseZone=Mc,a.localeData=bb,a.isDuration=xb,a.monthsShort=Sc,a.weekdaysMin=Vc,a.defineLocale=_a,a.updateLocale=ab,a.locales=cb,a.weekdaysShort=Uc,a.normalizeUnits=K,a.relativeTimeRounding=kd,a.relativeTimeThreshold=ld,a.calendarFormat=Ub,a.prototype=Xe,a});
|
||||
@@ -0,0 +1,94 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="hotel_calendar.HotelCalendarManagementView">
|
||||
<div class="col-xs-12 col-lg-12 nopadding">
|
||||
<div class="col-xs-12 col-lg-12 nopadding">
|
||||
<div class="col-xs-12 col-lg-12 nopadding" id="mpms-search">
|
||||
<table class="col-xs-12 col-lg-12 nopadding" id="pms-search-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-xs-1 col-lg-1">
|
||||
<button class="btn col-xs-12 col-lg-12" id="btn_save_changes" title="Save Changes">
|
||||
<i class="fa fa-save fa-stack-2x"> </i> &nbsp;
|
||||
</button>
|
||||
</td>
|
||||
<td class="col-xs-4 col-lg-3">
|
||||
<div class="col-xs-12 col-lg-12 nopadding">
|
||||
<div class="col-xs-3 col-lg-3 nopadding text-right filter-title">
|
||||
<strong style="line-height:2em">PRICELIST:</strong>
|
||||
</div>
|
||||
<div class="col-xs-9 col-lg-9">
|
||||
<select class="list form-control" id="price_list"/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xs-12 col-lg-12 nopadding">
|
||||
<div class="col-xs-3 col-lg-3 nopadding text-right filter-title">
|
||||
<strong style="line-height:2em">RESTRICTIONS:</strong>
|
||||
</div>
|
||||
<div class="col-xs-9 col-lg-9">
|
||||
<select class="list form-control" id="restriction_list"/>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-xs-4 col-lg-4">
|
||||
<div class="col-xs-12 col-lg-12">
|
||||
<table style="margin: 0 auto">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
FROM<br/>
|
||||
<div class="input-group date" id="date_begin">
|
||||
<input type="text" class="form-control" name="date_begin" required="required" readonly="1"/>
|
||||
<span class="input-group-addon">
|
||||
<span class="fa fa-calendar"></span>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
TO<br/>
|
||||
<div class="input-group date" id="date_end">
|
||||
<input type="text" class="form-control" name="date_end" required="required" readonly="1"/>
|
||||
<span class="input-group-addon">
|
||||
<span class="fa fa-calendar"></span>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-xs-1 col-lg-1">
|
||||
<strong style="line-height:2em">View Mode:</strong>
|
||||
<select class="list form-control" id="mode_list">
|
||||
<option value="all">All</option>
|
||||
<option value="medium">Medium</option>
|
||||
<option value="low">Low</option>
|
||||
</select>
|
||||
</td>
|
||||
<td class="col-xs-2 col-lg-2">
|
||||
<div class="col-xs-12 col-lg-12" id="pms-search-cal-pag">
|
||||
<button id="cal-pag-prev-plus" class="btn"><i class="fa fa-3x fa-angle-double-left"></i></button>
|
||||
<button id="cal-pag-prev" class="btn"><i class="fa fa-3x fa-angle-left"></i></button>
|
||||
<button id="cal-pag-selector" class="btn"><i class="fa fa-3x fa-calendar"></i></button>
|
||||
<button id="cal-pag-next" class="btn"><i class="fa fa-3x fa-angle-right"></i></button>
|
||||
<button id="cal-pag-next-plus" class="btn"><i class="fa fa-3x fa-angle-double-right"></i></button>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-xs-1 col-lg-1">
|
||||
<button class="btn btn-default col-xs-12 col-lg-12" id="btn_massive_changes" title="Launch Massive Changes">
|
||||
<i class="fa fa-bolt fa-stack-2x"> </i> &nbsp;
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="hcal_management_widget" class="col-xs-12 col-lg-12 nopadding"></div>
|
||||
<div style="clear:both;" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
168
hotel_calendar/static/src/xml/hotel_calendar_templates.xml
Normal file
168
hotel_calendar/static/src/xml/hotel_calendar_templates.xml
Normal file
@@ -0,0 +1,168 @@
|
||||
<template>
|
||||
|
||||
<t t-name="HotelCalendar.ConfirmReservationChanges">
|
||||
<div class="content">
|
||||
<p>The following changes will be made...</p>
|
||||
<p t-if="hasReservsLinked" style="color:red">This reservation belongs to a folio with more reservations!</p>
|
||||
<div class="row">
|
||||
<div class="col-xl-6 col-lg-6">
|
||||
<strong>Reserve unchanged:</strong>
|
||||
<div class="well well-small">
|
||||
<t t-if="ocheckin != ncheckin">
|
||||
<strong>Checkin:</strong> <t t-esc="ocheckin"/><br/>
|
||||
</t>
|
||||
<t t-if="ocheckout != ncheckout">
|
||||
<strong>Checkout:</strong> <t t-esc="ocheckout"/><br/>
|
||||
</t>
|
||||
<t t-if="oroom != nroom">
|
||||
<strong>Room:</strong> <t t-esc="oroom"/><br/>
|
||||
</t>
|
||||
<!--
|
||||
<t t-if="oprice != nprice">
|
||||
<strong>Price:</strong> <t t-esc="oprice" widget="monetary"/><br/>
|
||||
</t>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-xl-6 col-lg-6">
|
||||
<strong>Reserve changed:</strong>
|
||||
<div class="well well-small">
|
||||
<t t-if="ocheckin != ncheckin">
|
||||
<strong>Checkin:</strong> <t t-esc="ncheckin"/><br/>
|
||||
</t>
|
||||
<t t-if="ocheckout != ncheckout">
|
||||
<strong>Checkout:</strong> <t t-esc="ncheckout"/><br/>
|
||||
</t>
|
||||
<t t-if="oroom != nroom">
|
||||
<strong>Room:</strong> <t t-esc="nroom"/><br/>
|
||||
</t>
|
||||
<!--
|
||||
<t t-if="oprice != nprice">
|
||||
<strong>Price:</strong> <t t-esc="nprice" widget="monetary"/><br/>
|
||||
</t>
|
||||
-->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<p>Are you sure you want to make this changes?</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.ConfirmPriceChange">
|
||||
<div class="content">
|
||||
<p>Are you sure you want to change these prices?</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.ConfirmSwapOperation">
|
||||
<div class="content">
|
||||
<p>The following changes will be made...</p>
|
||||
<span><strong>Swap Reservations</strong></span><br/>
|
||||
<p>Are you sure you want to make this changes?</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.InvalidSwapOperation">
|
||||
<div class="content">
|
||||
<p>Invalid Swap Operation, can't make this movement :/</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.TooltipReservation">
|
||||
<div class="oe_tooltip_string"><t t-esc="name"/></div>
|
||||
<ul class="oe_tooltip_technical">
|
||||
<li><b>Phone:</b> <t t-esc="phone"/></li>
|
||||
<li><b>Arrival Hour:</b> <t t-esc="arrival_hour"/></li>
|
||||
<t t-if="num_split > 1">
|
||||
<li><b>Splitted:</b> <t t-esc="num_split"/></li>
|
||||
</t>
|
||||
<!-- FIXME: HARD CURRENCY -->
|
||||
<li><b>Total Amount:</b> <t t-esc="amount_total" t-widget="monetary"/>€</li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.TooltipRoom">
|
||||
<div class="oe_tooltip_string"><t t-esc="name"/></div>
|
||||
<p><b>Price From:</b> <t t-esc="price_from"/></p>
|
||||
<t t-if="num_inside_rooms > 0">
|
||||
<b>Belongs to the Virtual Rooms:</b>
|
||||
<ul>
|
||||
<li t-foreach="inside_rooms" t-as="room_name">
|
||||
<t t-esc="room_name"/>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.TooltipEvent">
|
||||
<div class="oe_tooltip_string"><t t-esc="date"/></div>
|
||||
<ul>
|
||||
<li t-foreach="events" t-as="event">
|
||||
<t t-esc="event.name"/>
|
||||
</li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.TooltipRoomOverbooking">
|
||||
<div class="oe_tooltip_string"><t t-esc="name"/></div>
|
||||
<p><b>Overbooking Management</b></p>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.TooltipSelection">
|
||||
<!-- FIXME: HARD CURRENCY -->
|
||||
<span><b t-esc="nights"/> Nights: <b t-esc="total_price" t-widget="monetary"/>€</span>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.TooltipRestriction">
|
||||
<ul class="oe_tooltip_technical">
|
||||
<li><b>Min. Stay:</b> <t t-esc="min_stay"/></li>
|
||||
<li><b>Max. Stay:</b> <t t-esc="max_stay"/></li>
|
||||
<li><b>Max. Stay Arrival:</b> <t t-esc="max_stay_arrival"/></li>
|
||||
<li><b>Closed:</b> <t t-esc="closed"/></li>
|
||||
<li><b>Closed Arrival:</b> <t t-esc="closed_arrival"/></li>
|
||||
<li><b>Closed Departure:</b> <t t-esc="closed_departure"/></li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.ConfirmFolio">
|
||||
<div class="content">
|
||||
<p>Do you want to confirm this folio?</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.Notification">
|
||||
<ul>
|
||||
<li><b>Name:</b> <t t-esc="partner_name"/></li>
|
||||
<li><b>Room:</b> <t t-esc="room_name"/></li>
|
||||
<li><b>Check-In:</b> <t t-esc="checkin"/></li>
|
||||
<li><b>Check-Out:</b> <t t-esc="checkout"/></li>
|
||||
<li><b>Made by:</b> <t t-esc="username"/></li>
|
||||
</ul>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendarManagement.UnsavedChanges">
|
||||
<div class="content">
|
||||
<p>Have unsaved changes!</p>
|
||||
<p>Do you want to save these changes?</p>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.SettingsMenu">
|
||||
<li class="o_calendar_settings">
|
||||
<a href="#" title="Calendar Settings" class="dropdown-toggle" data-toggle="dropdown">
|
||||
<span class="fa fa-calendar"/>
|
||||
</a>
|
||||
<ul class="dropdown-menu o_calendar_settings_dropdown" role="menu"/>
|
||||
</li>
|
||||
</t>
|
||||
|
||||
<t t-name="HotelCalendar.SettingsMenu.Global">
|
||||
<li><a href="#" data-action="toggle_show_adv_controls">Toggle Advance Controls</a></li>
|
||||
<li class="divider"/>
|
||||
<li><a href="#" data-action="toggle_show_notification"><span t-if="manager._show_notifications" class="fa fa-check"/> Show Notifications</a></li>
|
||||
<li><a href="#" data-action="toggle_show_pricelist"><span t-if="manager._show_pricelist" class="fa fa-check"/> Show Pricelist</a></li>
|
||||
<li><a href="#" data-action="toggle_show_availability"><span t-if="manager._show_availability" class="fa fa-check"/> Show Availability</a></li>
|
||||
<li><a href="#" data-action="toggle_show_divide_rooms_by_capacity"><span t-if="manager._show_divide_rooms_by_capacity" class="fa fa-check"/> Divide Rooms by Capacity</a></li>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
101
hotel_calendar/static/src/xml/hotel_calendar_view.xml
Normal file
101
hotel_calendar/static/src/xml/hotel_calendar_view.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-name="hotel_calendar.HotelCalendarView">
|
||||
<div class="col-xs-12 col-md-12 nopadding">
|
||||
<div class="col-lg-1 hidden-xs hidden-sm nopadding" id="pms-menu">
|
||||
<button class="btn btn-default col-xs-12 col-md-12" id="btn_action_checkout" data-action="hotel_calendar.hotel_reservation_action_checkout">
|
||||
<div class="ninfo"><span class="badge badge-danger">0</span></div>
|
||||
CHECK-OUT
|
||||
</button>
|
||||
<button class="btn btn-default col-xs-12 col-md-12" id="btn_action_checkin" data-action="hotel_calendar.hotel_reservation_action_checkin">
|
||||
<div class="ninfo"><span class="badge badge-danger">0</span></div>
|
||||
CHECK-IN
|
||||
</button>
|
||||
<button class="btn btn-default col-xs-12 col-md-12" id="btn_action_bookings">
|
||||
<!--div class="ninfo"><span class="badge badge-danger">0</span></div-->
|
||||
BOOKS<br/>
|
||||
</button>
|
||||
<input type="edit" id="bookings_search" placeholder="Search..." style="width:100%; border:1px solid lightgray;" />
|
||||
<button class="btn btn-default col-xs-12 col-md-12" id="btn_action_control" data-action="hotel_calendar.open_wizard_reservations">
|
||||
WIZARD
|
||||
</button>
|
||||
<button class="btn btn-default col-xs-12 col-md-12" id="btn_swap">
|
||||
<div class="ninfo"><span class="badge badge-danger">0</span></div>
|
||||
<span class="ntext">START SWAP</span>
|
||||
</button>
|
||||
<!--button class="btn btn-default col-xs-12 col-md-12" id="btn_action_refresh">
|
||||
<i class="fa fa-4x fa-refresh"> </i>
|
||||
</button-->
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-11 nopadding">
|
||||
<div class="col-xs-11 col-md-11 nopadding" id="pms-search">
|
||||
<table class="col-xs-12 col-md-12 nopadding" id="pms-search-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td class="col-xs-3 col-md-4">
|
||||
<div class="col-xs-12 col-md-12 text-left">
|
||||
<label for="type_list">SEGMENTATION:</label>
|
||||
<select class="form-control" id="type_list" multiple="multiple"/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-12 text-left">
|
||||
<label for="floor_list">LOCATION:</label>
|
||||
<select class="list form-control" id="floor_list" multiple="multiple"/>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-xs-3 col-md-4">
|
||||
<div class="col-xs-12 col-md-12 text-left">
|
||||
<label for="amenities_list">AMENITIES:</label>
|
||||
<select class="list form-control" id="amenities_list" multiple="multiple"/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-12 text-left">
|
||||
<label for="virtual_list">VIRTUAL:</label>
|
||||
<select class="list form-control" id="virtual_list" multiple="multiple"/>
|
||||
</div>
|
||||
</td>
|
||||
<td class="col-xs-6 col-md-4">
|
||||
<div class="col-xs-12 col-md-12">
|
||||
<table style="margin: 0 auto">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>
|
||||
<label for="date_begin">FROM</label>
|
||||
<div class="input-group date" id="date_begin">
|
||||
<input type="text" class="o_datepicker_input form-control" name="date_begin" required="required"/>
|
||||
<span class="input-group-addon">
|
||||
<span class="fa fa-calendar"></span>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
<td>
|
||||
<label for="date_end">TO</label>
|
||||
<div class="input-group date" id="date_end">
|
||||
<input type="text" class="o_datepicker_input form-control" name="date_end" required="required"/>
|
||||
<span class="input-group-addon">
|
||||
<span class="fa fa-calendar"></span>
|
||||
</span>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div id="hcal_widget" class="col-xs-12 col-md-12 nopadding">
|
||||
<div id="hcal_load">
|
||||
<span>
|
||||
<i class="fa fa-refresh fa-spin fa-5x fa-fw"></i><br/>
|
||||
<h1>Loading Calendar...</h1>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div style="clear:both;" />
|
||||
</div>
|
||||
</div>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
5
hotel_calendar/tests/__init__.py
Normal file
5
hotel_calendar/tests/__init__.py
Normal file
@@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from . import test_reservations_calendar
|
||||
from . import test_management_calendar
|
||||
from . import test_product_pricelist
|
||||
41
hotel_calendar/tests/common.py
Normal file
41
hotel_calendar/tests/common.py
Normal file
@@ -0,0 +1,41 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from odoo.addons.hotel.tests.common import TestHotel
|
||||
|
||||
|
||||
class TestHotelCalendar(TestHotel):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
super(TestHotelCalendar, cls).setUpClass()
|
||||
|
||||
# Minimal Hotel Calendar Configuration
|
||||
cls.tz_hotel = 'Europe/Madrid'
|
||||
cls.parity_pricelist_id = cls.pricelist_1.id
|
||||
cls.parity_restrictions_id = cls.restriction_1.id
|
||||
cls.env['ir.default'].sudo().set_default('res.config.settings',
|
||||
'default_arrival_hour',
|
||||
'14:00')
|
||||
cls.env['ir.default'].sudo().set_default('res.config.settings',
|
||||
'default_departure_hour',
|
||||
'12:00')
|
||||
425
hotel_calendar/tests/test_management_calendar.py
Normal file
425
hotel_calendar/tests/test_management_calendar.py
Normal file
@@ -0,0 +1,425 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import timedelta
|
||||
from openerp.tools import (
|
||||
DEFAULT_SERVER_DATETIME_FORMAT,
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
from openerp.exceptions import ValidationError
|
||||
from .common import TestHotelCalendar
|
||||
from odoo.addons.hotel import date_utils
|
||||
import logging
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class TestManagementCalendar(TestHotelCalendar):
|
||||
|
||||
def test_calendar_prices(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
|
||||
vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['prices'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
if k_info >= len(self.prices_tmp[vroom.id]):
|
||||
break
|
||||
self.assertEqual(v_info['price'],
|
||||
self.prices_tmp[vroom.id][k_info],
|
||||
"Hotel Calendar Management Prices \
|
||||
doesn't match!")
|
||||
|
||||
# REMOVE PRICES
|
||||
prices_obj = self.env['product.pricelist.item'].sudo(
|
||||
self.user_hotel_manager)
|
||||
prod_tmpl_ids = (
|
||||
self.hotel_vroom_budget.product_id.product_tmpl_id.id,
|
||||
self.hotel_vroom_special.product_id.product_tmpl_id.id
|
||||
)
|
||||
pr_ids = prices_obj.search([
|
||||
('pricelist_id', '=', self.parity_pricelist_id),
|
||||
('product_tmpl_id', 'in', prod_tmpl_ids),
|
||||
])
|
||||
pr_ids.sudo(self.user_hotel_manager).unlink()
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
self.assertFalse(any(hcal_data['prices']), "Hotel Calendar Management \
|
||||
Prices doesn't match after remove!")
|
||||
|
||||
def test_calendar_restrictions(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['restrictions'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
rest_items = self.restrictions_min_stay_tmp[vroom.id]
|
||||
if k_info >= len(rest_items):
|
||||
break
|
||||
self.assertEqual(
|
||||
v_info['min_stay'],
|
||||
self.restrictions_min_stay_tmp[vroom.id][k_info],
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
|
||||
# REMOVE RESTRICTIONS
|
||||
rest_it_obj = self.env['hotel.virtual.room.restriction.item'].sudo(
|
||||
self.user_hotel_manager)
|
||||
rest_ids = rest_it_obj.search([
|
||||
('applied_on', '=', '0_virtual_room'),
|
||||
('restriction_id', '=', self.parity_restrictions_id),
|
||||
('virtual_room_id', 'in', (self.hotel_vroom_budget.id,
|
||||
self.hotel_vroom_special.id)),
|
||||
])
|
||||
rest_ids.sudo(self.user_hotel_manager).unlink()
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
self.assertFalse(
|
||||
any(hcal_data['restrictions']),
|
||||
"Hotel Calendar Management Restrictions doesn't match \
|
||||
after remove!")
|
||||
|
||||
def test_calendar_availability(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=6)
|
||||
vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
vroom_avail_obj = self.env['hotel.virtual.room.availability'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['availability'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
if k_info >= len(self.avails_tmp[vroom.id]):
|
||||
break
|
||||
self.assertEqual(
|
||||
v_info['avail'],
|
||||
self.avails_tmp[vroom.id][k_info],
|
||||
"Hotel Calendar Management Availability \
|
||||
doesn't match!")
|
||||
|
||||
# CHANGE AVAIL
|
||||
avail_ids = vroom_avail_obj.search([
|
||||
('virtual_room_id', 'in', (self.hotel_vroom_budget.id,
|
||||
self.hotel_vroom_special.id)),
|
||||
])
|
||||
for avail_id in avail_ids:
|
||||
avail_id.sudo(self.user_hotel_manager).write({'avail': 1})
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['availability'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(
|
||||
v_info['avail'],
|
||||
1,
|
||||
"Hotel Calendar Management Availability \
|
||||
doesn't match!")
|
||||
|
||||
# REMOVE AVAIL
|
||||
avail_ids = vroom_avail_obj.search([
|
||||
('virtual_room_id', 'in', (self.hotel_vroom_budget.id,
|
||||
self.hotel_vroom_special.id)),
|
||||
])
|
||||
avail_ids.sudo(self.user_hotel_manager).unlink()
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['availability'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(
|
||||
v_info['avail'],
|
||||
vroom.max_real_rooms,
|
||||
"Hotel Calendar Management Availability \
|
||||
doesn't match!")
|
||||
|
||||
def test_save_changes(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
vrooms = (self.hotel_vroom_budget,)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
# Generate new prices
|
||||
prices = (144.0, 170.0, 30.0, 50.0)
|
||||
cprices = {}
|
||||
for k_item, v_item in enumerate(prices):
|
||||
ndate_utc_dt = now_utc_dt + timedelta(days=k_item)
|
||||
cprices.setdefault(self.hotel_vroom_budget.id, []).append({
|
||||
'date': ndate_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'price': v_item
|
||||
})
|
||||
|
||||
# Generate new restrictions
|
||||
restrictions = {
|
||||
'min_stay': (3, 2, 4, 1),
|
||||
'max_stay': (5, 8, 9, 3),
|
||||
'min_stay_arrival': (2, 3, 6, 2),
|
||||
'max_stay_arrival': (4, 7, 7, 4),
|
||||
'closed_departure': (False, True, False, True),
|
||||
'closed_arrival': (True, False, False, False),
|
||||
'closed': (False, False, True, True),
|
||||
}
|
||||
crestrictions = {}
|
||||
for i in range(0, 4):
|
||||
ndate_utc_dt = now_utc_dt + timedelta(days=i)
|
||||
crestrictions.setdefault(self.hotel_vroom_budget.id, []).append({
|
||||
'date': ndate_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
'closed_arrival': restrictions['closed_arrival'][i],
|
||||
'max_stay': restrictions['max_stay'][i],
|
||||
'min_stay': restrictions['min_stay'][i],
|
||||
'closed_departure': restrictions['closed_departure'][i],
|
||||
'closed': restrictions['closed'][i],
|
||||
'min_stay_arrival': restrictions['min_stay_arrival'][i],
|
||||
'max_stay_arrival': restrictions['max_stay_arrival'][i],
|
||||
})
|
||||
|
||||
# Generate new availability
|
||||
avails = (1, 2, 2, 1)
|
||||
cavails = {}
|
||||
for k_item, v_item in enumerate(avails):
|
||||
ndate_utc_dt = now_utc_dt + timedelta(days=k_item)
|
||||
ndate_dt = date_utils.dt_as_timezone(ndate_utc_dt, self.tz_hotel)
|
||||
cavails.setdefault(self.hotel_vroom_budget.id, []).append({
|
||||
'date': ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
'avail': v_item,
|
||||
'no_ota': False,
|
||||
})
|
||||
|
||||
# Save new values
|
||||
hotel_cal_mngt_obj.save_changes(
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
cprices,
|
||||
crestrictions,
|
||||
cavails)
|
||||
|
||||
# Check data integrity
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['availability'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(v_info['avail'],
|
||||
avails[k_info],
|
||||
"Hotel Calendar Management \
|
||||
Availability doesn't match!")
|
||||
for k_pr, v_pr in hcal_data['restrictions'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(v_info['min_stay'],
|
||||
restrictions['min_stay'][k_info],
|
||||
"Hotel Calendar Management \
|
||||
Restrictions doesn't match!")
|
||||
self.assertEqual(v_info['max_stay'],
|
||||
restrictions['max_stay'][k_info],
|
||||
"Hotel Calendar Management \
|
||||
Restrictions doesn't match!")
|
||||
self.assertEqual(
|
||||
v_info['min_stay_arrival'],
|
||||
restrictions['min_stay_arrival'][k_info],
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
self.assertEqual(
|
||||
v_info['max_stay_arrival'],
|
||||
restrictions['max_stay_arrival'][k_info],
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
self.assertEqual(
|
||||
v_info['closed_departure'],
|
||||
restrictions['closed_departure'][k_info],
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
self.assertEqual(
|
||||
v_info['closed_arrival'],
|
||||
restrictions['closed_arrival'][k_info],
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
self.assertEqual(
|
||||
v_info['closed'],
|
||||
restrictions['closed'][k_info],
|
||||
"Hotel Calendar Management Restrictions \
|
||||
doesn't match!")
|
||||
for k_pr, v_pr in hcal_data['prices'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
self.assertEqual(v_info['price'],
|
||||
prices[k_info], "Hotel Calendar \
|
||||
Management Prices doesn't match!")
|
||||
|
||||
def test_calendar_reservations(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
vrooms = (self.hotel_vroom_budget,)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
reserv_start_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
reserv_end_utc_dt = reserv_start_utc_dt + timedelta(days=3)
|
||||
folio = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
reservation = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio,
|
||||
reserv_start_utc_dt,
|
||||
reserv_end_utc_dt,
|
||||
self.hotel_room_simple_100,
|
||||
"Reservation Test #1")
|
||||
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
|
||||
avail_end_utc_dt = reserv_end_utc_dt - timedelta(days=1)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['count_reservations'].iteritems():
|
||||
if k_pr == vroom.id: # Only Check Test Cases
|
||||
for k_info, v_info in enumerate(v_pr):
|
||||
ndate = date_utils.get_datetime(v_info['date'])
|
||||
if date_utils.date_in(ndate,
|
||||
reserv_start_utc_dt,
|
||||
avail_end_utc_dt) == 0:
|
||||
self.assertEqual(v_info['num'],
|
||||
1,
|
||||
"Hotel Calendar Management \
|
||||
Availability doesn't match!")
|
||||
|
||||
def test_invalid_input_calendar_data(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
False,
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
with self.assertRaises(ValidationError):
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
False,
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
with self.assertRaises(ValidationError):
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
False,
|
||||
False,
|
||||
self.parity_pricelist_id,
|
||||
self.parity_restrictions_id,
|
||||
True)
|
||||
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
False,
|
||||
False,
|
||||
True)
|
||||
self.assertTrue(any(hcal_data), "Hotel Calendar invalid default \
|
||||
management parity models!")
|
||||
|
||||
def test_calendar_settings(self):
|
||||
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
|
||||
self.user_hotel_manager)
|
||||
settings = hotel_cal_mngt_obj.get_hcalendar_settings()
|
||||
self.assertTrue(settings, "Hotel Calendar invalid settings")
|
||||
|
||||
self.assertEqual(settings['eday_week'],
|
||||
self.user_hotel_manager.npms_end_day_week,
|
||||
"Hotel Calendar invalid settings")
|
||||
self.assertEqual(settings['eday_week_offset'],
|
||||
self.user_hotel_manager.npms_end_day_week_offset,
|
||||
"Hotel Calendar invalid settings")
|
||||
self.assertEqual(settings['days'],
|
||||
self.user_hotel_manager.npms_default_num_days,
|
||||
"Hotel Calendar invalid settings")
|
||||
self.assertEqual(settings['show_notifications'],
|
||||
self.user_hotel_manager.pms_show_notifications,
|
||||
"Hotel Calendar invalid settings")
|
||||
self.assertEqual(settings['show_num_rooms'],
|
||||
self.user_hotel_manager.pms_show_num_rooms,
|
||||
"Hotel Calendar invalid settings")
|
||||
66
hotel_calendar/tests/test_product_pricelist.py
Normal file
66
hotel_calendar/tests/test_product_pricelist.py
Normal file
@@ -0,0 +1,66 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from .common import TestHotelCalendar
|
||||
from odoo.addons.hotel import date_utils
|
||||
|
||||
|
||||
class TestProductPricelist(TestHotelCalendar):
|
||||
|
||||
def test_update_price(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
now_utc_str = now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
|
||||
vroom_tmpl_id = self.hotel_vroom_special.product_id.product_tmpl_id
|
||||
|
||||
pritem_obj = self.env['product.pricelist.item']
|
||||
plitem = pritem_obj.search([
|
||||
('pricelist_id', '=', self.parity_pricelist_id),
|
||||
('product_tmpl_id', '=', vroom_tmpl_id.id),
|
||||
('date_start', '=', now_utc_str),
|
||||
('date_end', '=', now_utc_str),
|
||||
('applied_on', '=', '1_product'),
|
||||
('compute_price', '=', 'fixed')
|
||||
])
|
||||
old_price = plitem.fixed_price
|
||||
|
||||
self.pricelist_1.update_price(
|
||||
self.hotel_vroom_special.id,
|
||||
now_utc_str,
|
||||
999.9)
|
||||
|
||||
plitem = pritem_obj.search([
|
||||
('pricelist_id', '=', self.parity_pricelist_id),
|
||||
('product_tmpl_id', '=', vroom_tmpl_id.id),
|
||||
('date_start', '=', now_utc_str),
|
||||
('date_end', '=', now_utc_str),
|
||||
('applied_on', '=', '1_product'),
|
||||
('compute_price', '=', 'fixed')
|
||||
])
|
||||
new_price = plitem.fixed_price
|
||||
|
||||
self.assertNotEqual(old_price,
|
||||
new_price,
|
||||
"Hotel Calendar can't change price")
|
||||
self.assertEqual(new_price,
|
||||
999.9,
|
||||
"Hotel Calendar can't change price")
|
||||
289
hotel_calendar/tests/test_reservations_calendar.py
Normal file
289
hotel_calendar/tests/test_reservations_calendar.py
Normal file
@@ -0,0 +1,289 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import datetime
|
||||
from datetime import timedelta
|
||||
from odoo import fields
|
||||
from openerp.tools import DEFAULT_SERVER_DATETIME_FORMAT
|
||||
from openerp.exceptions import ValidationError
|
||||
from .common import TestHotelCalendar
|
||||
from odoo.addons.hotel import date_utils
|
||||
import pytz
|
||||
|
||||
|
||||
class TestReservationsCalendar(TestHotelCalendar):
|
||||
|
||||
def test_calendar_pricelist(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
real_start_utc_dt = (now_utc_dt - timedelta(days=1))
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
|
||||
hotel_reserv_obj = self.env['hotel.reservation'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
hcal_data = hotel_reserv_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
|
||||
# Check Pricelist Integrity
|
||||
for k_pr, v_pr in hcal_data['pricelist'].iteritems():
|
||||
for vroom_pr in v_pr:
|
||||
# Only Check Test Cases
|
||||
if vroom_pr['room'] in self.prices_tmp.keys():
|
||||
sorted_dates = sorted(
|
||||
vroom_pr['days'].keys(),
|
||||
key=lambda x: datetime.datetime.strptime(x, '%d/%m/%Y')
|
||||
)
|
||||
init_date_dt = datetime.datetime.strptime(
|
||||
sorted_dates[0],
|
||||
'%d/%m/%Y').replace(tzinfo=pytz.utc)
|
||||
end_date_dt = datetime.datetime.strptime(
|
||||
sorted_dates[-1],
|
||||
'%d/%m/%Y').replace(tzinfo=pytz.utc)
|
||||
|
||||
self.assertEqual(real_start_utc_dt, init_date_dt,
|
||||
"Hotel Calendar don't start in \
|
||||
the correct date!")
|
||||
self.assertEqual(adv_utc_dt, end_date_dt,
|
||||
"Hotel Calendar don't end in \
|
||||
the correct date!")
|
||||
|
||||
vroom_prices = self.prices_tmp[vroom_pr['room']]
|
||||
for k_price, v_price in enumerate(vroom_prices):
|
||||
self.assertEqual(
|
||||
v_price,
|
||||
vroom_pr['days'][sorted_dates[k_price+1]],
|
||||
"Hotel Calendar Pricelist doesn't match!")
|
||||
|
||||
# Check Pricelist Integrity after unlink
|
||||
pricelist_item_obj = self.env['product.pricelist.item'].sudo(
|
||||
self.user_hotel_manager)
|
||||
pr_ids = pricelist_item_obj.search([
|
||||
('pricelist_id', '=', self.parity_pricelist_id),
|
||||
('product_tmpl_id', 'in', (
|
||||
self.hotel_vroom_budget.product_id.product_tmpl_id.id,
|
||||
self.hotel_vroom_special.product_id.product_tmpl_id.id)),
|
||||
])
|
||||
pr_ids.sudo(self.user_hotel_manager).unlink()
|
||||
reserv_obj = self.env['hotel.reservation'].sudo(
|
||||
self.user_hotel_manager)
|
||||
hcal_data = reserv_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
vrooms = (self.hotel_vroom_budget, self.hotel_vroom_special)
|
||||
for vroom in vrooms:
|
||||
for k_pr, v_pr in hcal_data['pricelist'].iteritems():
|
||||
for vroom_pr in v_pr:
|
||||
if vroom_pr['room'] == vroom.id: # Only Check Test Cases
|
||||
self.assertEqual(
|
||||
vroom.list_price,
|
||||
vroom_pr['days'][sorted_dates[k_price+1]],
|
||||
"Hotel Calendar Pricelist doesn't \
|
||||
match after remove!")
|
||||
|
||||
def test_calendar_reservations(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
|
||||
hotel_reserv_obj = self.env['hotel.reservation'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
def is_reservation_listed(reservation_id):
|
||||
hcal_data = hotel_reserv_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
# TODO: Perhaps not the best way to do this test... :/
|
||||
hasReservationTest = False
|
||||
for reserv in hcal_data['reservations']:
|
||||
if reserv[1] == reservation_id:
|
||||
hasReservationTest = True
|
||||
break
|
||||
return hasReservationTest
|
||||
|
||||
# CREATE COMPLETE RESERVATION (3 Nigths)
|
||||
reserv_start_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
reserv_end_utc_dt = reserv_start_utc_dt + timedelta(days=3)
|
||||
folio = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
reservation = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio,
|
||||
reserv_start_utc_dt,
|
||||
reserv_end_utc_dt,
|
||||
self.hotel_room_double_200,
|
||||
"Reservation Test #1")
|
||||
|
||||
# CHECK SUCCESSFULL CREATION
|
||||
self.assertTrue(is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar can't found test reservation!")
|
||||
|
||||
# CONFIRM FOLIO
|
||||
folio.sudo(self.user_hotel_manager).action_confirm()
|
||||
self.assertTrue(is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar can't found test reservation!")
|
||||
|
||||
# CALENDAR LIMITS
|
||||
now_utc_dt_tmp = now_utc_dt
|
||||
adv_utc_dt_tmp = adv_utc_dt
|
||||
# Start after reservation end
|
||||
now_utc_dt = reserv_end_utc_dt + timedelta(days=2)
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
self.assertFalse(
|
||||
is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar found test reservation but expected not found it!")
|
||||
|
||||
# Ends before reservation start
|
||||
adv_utc_dt = reserv_start_utc_dt - timedelta(days=1)
|
||||
now_utc_dt = adv_utc_dt - timedelta(days=15)
|
||||
self.assertFalse(
|
||||
is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar found test reservation but expected not found it!")
|
||||
now_utc_dt = now_utc_dt_tmp
|
||||
adv_utc_dt = adv_utc_dt_tmp
|
||||
|
||||
# Start in the middle of the reservation days
|
||||
now_utc_dt = reserv_end_utc_dt - timedelta(days=1)
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
self.assertTrue(
|
||||
is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar can't found test reservation!")
|
||||
now_utc_dt = now_utc_dt_tmp
|
||||
adv_utc_dt = adv_utc_dt_tmp
|
||||
|
||||
# CANCEL FOLIO
|
||||
folio.sudo(self.user_hotel_manager).action_cancel()
|
||||
self.assertFalse(
|
||||
is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar can't found test reservation!")
|
||||
|
||||
# REMOVE FOLIO
|
||||
folio.sudo().unlink() # FIXME: Can't use: self.user_hotel_manager
|
||||
self.assertFalse(
|
||||
is_reservation_listed(reservation.id),
|
||||
"Hotel Calendar can't found test reservation!")
|
||||
|
||||
def test_invalid_input_calendar_data(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
adv_utc_dt = now_utc_dt + timedelta(days=15)
|
||||
|
||||
hotel_reserv_obj = self.env['hotel.reservation'].sudo(
|
||||
self.user_hotel_manager)
|
||||
|
||||
with self.assertRaises(ValidationError):
|
||||
hcal_data = hotel_reserv_obj.get_hcalendar_all_data(
|
||||
False,
|
||||
adv_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT))
|
||||
with self.assertRaises(ValidationError):
|
||||
hcal_data = hotel_reserv_obj.get_hcalendar_all_data(
|
||||
now_utc_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT),
|
||||
False)
|
||||
with self.assertRaises(ValidationError):
|
||||
hcal_data = hotel_reserv_obj.get_hcalendar_all_data(
|
||||
False,
|
||||
False)
|
||||
|
||||
def test_calendar_settings(self):
|
||||
hcal_options = self.env['hotel.reservation'].sudo(
|
||||
self.user_hotel_manager).get_hcalendar_settings()
|
||||
|
||||
self.assertEqual(hcal_options['divide_rooms_by_capacity'],
|
||||
self.user_hotel_manager.pms_divide_rooms_by_capacity,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(hcal_options['eday_week'],
|
||||
self.user_hotel_manager.pms_end_day_week,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(hcal_options['days'],
|
||||
self.user_hotel_manager.pms_default_num_days,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(
|
||||
hcal_options['allow_invalid_actions'],
|
||||
self.user_hotel_manager.pms_type_move == 'allow_invalid',
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(
|
||||
hcal_options['assisted_movement'],
|
||||
self.user_hotel_manager.pms_type_move == 'assisted',
|
||||
"Hotel Calendar Invalid Options!")
|
||||
default_arrival_hour = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_arrival_hour')
|
||||
self.assertEqual(hcal_options['default_arrival_hour'],
|
||||
default_arrival_hour,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
default_departure_hour = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_departure_hour')
|
||||
self.assertEqual(hcal_options['default_departure_hour'],
|
||||
default_departure_hour,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(hcal_options['show_notifications'],
|
||||
self.user_hotel_manager.pms_show_notifications,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(hcal_options['show_num_rooms'],
|
||||
self.user_hotel_manager.pms_show_num_rooms,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(hcal_options['show_pricelist'],
|
||||
self.user_hotel_manager.pms_show_pricelist,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
self.assertEqual(hcal_options['show_availability'],
|
||||
self.user_hotel_manager.pms_show_availability,
|
||||
"Hotel Calendar Invalid Options!")
|
||||
|
||||
def test_swap_reservation(self):
|
||||
hcal_reserv_obj = self.env['hotel.reservation'].sudo(
|
||||
self.user_hotel_manager)
|
||||
now_utc_dt = date_utils.now()
|
||||
|
||||
# CREATE RESERVATIONS
|
||||
reserv_start_utc_dt = now_utc_dt + timedelta(days=3)
|
||||
reserv_end_utc_dt = reserv_start_utc_dt + timedelta(days=3)
|
||||
folio_a = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
reservation_a = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio_a,
|
||||
reserv_start_utc_dt,
|
||||
reserv_end_utc_dt,
|
||||
self.hotel_room_double_200,
|
||||
"Reservation Test #1")
|
||||
self.assertTrue(reservation_a,
|
||||
"Hotel Calendar create test reservation!")
|
||||
folio_a.sudo(self.user_hotel_manager).action_confirm()
|
||||
|
||||
folio_b = self.create_folio(self.user_hotel_manager, self.partner_2)
|
||||
reservation_b = self.create_reservation(
|
||||
self.user_hotel_manager,
|
||||
folio_b,
|
||||
reserv_start_utc_dt,
|
||||
reserv_end_utc_dt,
|
||||
self.hotel_room_simple_101,
|
||||
"Reservation Test #2")
|
||||
self.assertTrue(reservation_b,
|
||||
"Hotel Calendar can't create test reservation!")
|
||||
folio_b.sudo(self.user_hotel_manager).action_confirm()
|
||||
|
||||
self.assertTrue(
|
||||
hcal_reserv_obj.swap_reservations(reservation_a.ids,
|
||||
reservation_b.ids),
|
||||
"Hotel Calendar invalid swap operation"
|
||||
)
|
||||
self.assertEqual(reservation_a.product_id.id,
|
||||
self.hotel_room_simple_101.product_id.id,
|
||||
"Hotel Calendar wrong swap operation")
|
||||
self.assertEqual(reservation_b.product_id.id,
|
||||
self.hotel_room_double_200.product_id.id,
|
||||
"Hotel Calendar wrong swap operation")
|
||||
27
hotel_calendar/views/actions.xml
Normal file
27
hotel_calendar/views/actions.xml
Normal file
@@ -0,0 +1,27 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.actions.act_window" id="hotel_reservation_action_checkin">
|
||||
<field name="name">Hotel folio checkin</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('is_checkin','=', True)]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="hotel_reservation_action_checkout">
|
||||
<field name="name">Hotel folio checkout</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('is_checkout','=', True)]</field>
|
||||
</record>
|
||||
|
||||
<record model="ir.actions.act_window" id="hotel_virtual_room_pricelist_cached_action_form_tree">
|
||||
<field name="name">Virtual Room Pricelist Cached</field>
|
||||
<field name="res_model">virtual.room.pricelist.cached</field>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
32
hotel_calendar/views/general.xml
Normal file
32
hotel_calendar/views/general.xml
Normal file
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Use an updated momentJS library -->
|
||||
<template id="assets_common" inherit_id="web.assets_common">
|
||||
<xpath expr="//script[@src='/web/static/lib/moment/moment.js']" position="attributes">
|
||||
<attribute name="src">/hotel_calendar/static/src/lib/moment.js</attribute>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
<!-- Backend stuff -->
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/lib/bootbox.js"></script>
|
||||
|
||||
<!-- Hotel Calendar (Internal) -->
|
||||
<link rel="stylesheet" href="/hotel_calendar/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/constants.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_model.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_renderer.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar/hotel_calendar_view.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_controller.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_model.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_renderer.js"></script>
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/views/calendar_management/hotel_calendar_management_view.js"></script>
|
||||
|
||||
<script type="text/javascript" src="/hotel_calendar/static/src/js/open_reservation_wizard_listview_button.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
14
hotel_calendar/views/inherited_hotel_room_views.xml
Normal file
14
hotel_calendar/views/inherited_hotel_room_views.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="room_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.room</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_room_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='to_be_cleaned']" position="after">
|
||||
<field name="hcal_sequence" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
14
hotel_calendar/views/inherited_hotel_virtual_room_views.xml
Normal file
14
hotel_calendar/views/inherited_hotel_virtual_room_views.xml
Normal file
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0"?>
|
||||
<odoo>
|
||||
|
||||
<record id="virtual_room_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.virtual.room</field>
|
||||
<field name="inherit_id" ref="hotel.virtual_room_view_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//field[@name='name']" position="after">
|
||||
<field name="hcal_sequence" />
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
43
hotel_calendar/views/inherited_res_users_views.xml
Normal file
43
hotel_calendar/views/inherited_res_users_views.xml
Normal file
@@ -0,0 +1,43 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<record id="view_users_form" model="ir.ui.view">
|
||||
<field name="model">res.users</field>
|
||||
<field name="inherit_id" ref="base.view_users_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//page/group/group[@name='preferences']" position="before">
|
||||
<group string="Calendar (PMS)" name="calendar">
|
||||
<group colspan="4">
|
||||
<field name="pms_show_notifications" />
|
||||
<field name="pms_show_pricelist" />
|
||||
<field name="pms_show_availability" />
|
||||
<field name="pms_show_num_rooms" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="pms_divide_rooms_by_capacity" />
|
||||
<field name="pms_end_day_week" required="True" />
|
||||
<field name="pms_end_day_week_offset" required="True" />
|
||||
<field name="pms_type_move" required="True" />
|
||||
<field name="pms_default_num_days" required="True" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="pms_allowed_events_tags" widget="many2many_tags" />
|
||||
<field name="pms_denied_events_tags" widget="many2many_tags" />
|
||||
</group>
|
||||
</group>
|
||||
<group string="Calendar Management (Revenue PMS)" name="calendar">
|
||||
<group colspan="4">
|
||||
<field name="npms_end_day_week" required="True" />
|
||||
<field name="npms_end_day_week_offset" required="True" />
|
||||
<field name="npms_default_num_days" required="True" />
|
||||
</group>
|
||||
<group colspan="4">
|
||||
<field name="npms_allowed_events_tags" widget="many2many_tags" />
|
||||
<field name="npms_denied_events_tags" widget="many2many_tags" />
|
||||
</group>
|
||||
</group>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
35
hotel_calendar/views/res_config_views.xml
Normal file
35
hotel_calendar/views/res_config_views.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Calendar Settings -->
|
||||
<record id="view_hotel_config_settings" model="ir.ui.view">
|
||||
<field name="name">res.config.settings.view.form.inherit.hotel</field>
|
||||
<field name="model">res.config.settings</field>
|
||||
<field name="priority" eval="80"/>
|
||||
<field name="inherit_id" ref="base.res_config_settings_view_form"/>
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//div[hasclass('settings')]" position="inside">
|
||||
<div class="app_settings_block o_not_app" data-string="Hotel" string="Hotel" data-key="hotel" groups="hotel.group_hotel_manager">
|
||||
<h2>Calendar colors</h2>
|
||||
<div class="row mt16 o_settings_container">
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
<field name="color_pre_reservation" required="True" widget="color"/><field name="color_letter_pre_reservation" required="True" widget="color" />
|
||||
<field name="color_reservation" required="True" widget="color"/><field name="color_letter_reservation" required="True" widget="color" />
|
||||
<field name="color_reservation_pay" required="True" widget="color"/><field name="color_letter_reservation_pay" required="True" widget="color" />
|
||||
<field name="color_stay" required="True" widget="color"/><field name="color_letter_stay" required="True" widget="color" />
|
||||
<field name="color_stay_pay" required="True" widget="color"/><field name="color_letter_stay_pay" required="True" widget="color" />
|
||||
</div>
|
||||
<div class="col-xs-12 col-md-6 o_setting_box">
|
||||
<field name="color_checkout" required="True" widget="color"/><field name="color_letter_checkout" required="True" widget="color" />
|
||||
<field name="color_dontsell" required="True" widget="color"/><field name="color_letter_dontsell" required="True" widget="color" />
|
||||
<field name="color_staff" required="True" widget="color"/><field name="color_letter_staff" required="True" widget="color" />
|
||||
<field name="color_to_assign" required="True" widget="color"/><field name="color_letter_to_assign" required="True" widget="color" />
|
||||
<field name="color_payment_pending" required="True" widget="color"/><field name="color_letter_payment_pending" required="True" widget="color" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
35
hotel_calendar/views/virtual_room_pricelist_cached_views.xml
Normal file
35
hotel_calendar/views/virtual_room_pricelist_cached_views.xml
Normal file
@@ -0,0 +1,35 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<odoo>
|
||||
|
||||
<!--======= Room Type ======= -->
|
||||
<!-- Form view of hotel room type -->
|
||||
<record model="ir.ui.view" id="view_hotel_virtual_room_pricelist_cached_form">
|
||||
<field name="name">hotel.virtual.room.pricelist.cached.form</field>
|
||||
<field name="model">virtual.room.pricelist.cached</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string=" Virtual Room Pricelist Cached">
|
||||
<sheet>
|
||||
<group>
|
||||
<field name="virtual_room_id" />
|
||||
<field name="date" />
|
||||
<field name="price" />
|
||||
</group>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<!-- Tree view of hotel room type -->
|
||||
<record model="ir.ui.view" id="view_hotel_virtual_room_pricelist_cached_tree">
|
||||
<field name="name">hotel.virtual.room.pricelist.cached.tree</field>
|
||||
<field name="model">virtual.room.pricelist.cached</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string=" Virtual Room Pricelist Cached">
|
||||
<field name="virtual_room_id" />
|
||||
<field name="date" />
|
||||
<field name="price" />
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
1
hotel_calendar/wizard/__init__.py
Normal file
1
hotel_calendar/wizard/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from . import wizard_reservation
|
||||
584
hotel_calendar/wizard/wizard_reservation.py
Normal file
584
hotel_calendar/wizard/wizard_reservation.py
Normal file
@@ -0,0 +1,584 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import pytz
|
||||
import time
|
||||
import logging
|
||||
from decimal import Decimal
|
||||
from dateutil.relativedelta import relativedelta
|
||||
from datetime import datetime, timedelta, date
|
||||
from openerp.exceptions import except_orm, UserError, ValidationError
|
||||
from openerp.tools import (
|
||||
misc,
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
from openerp import models, fields, api, _
|
||||
from odoo.addons.hotel import date_utils
|
||||
import odoo.addons.decimal_precision as dp
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class FolioWizard(models.TransientModel):
|
||||
_name = 'hotel.folio.wizard'
|
||||
|
||||
@api.model
|
||||
def _get_default_center_user(self):
|
||||
user = self.env['res.users'].browse(self.env.uid)
|
||||
return user.has_group('hotel.group_hotel_call')
|
||||
|
||||
@api.model
|
||||
def _get_default_checkin(self):
|
||||
folio = False
|
||||
default_arrival_hour = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_arrival_hour')
|
||||
if 'folio_id' in self._context:
|
||||
folio = self.env['hotel.folio'].search([
|
||||
('id', '=', self._context['folio_id'])
|
||||
])
|
||||
if folio and folio.room_lines:
|
||||
return folio.room_lines[0].checkin
|
||||
else:
|
||||
tz_hotel = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'tz_hotel')
|
||||
now_utc_dt = date_utils.now()
|
||||
ndate = "%s %s:00" % \
|
||||
(now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
default_arrival_hour)
|
||||
ndate_dt = date_utils.get_datetime(ndate, stz=tz_hotel)
|
||||
ndate_dt = date_utils.dt_as_timezone(ndate_dt, 'UTC')
|
||||
return ndate_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
@api.model
|
||||
def _get_default_checkout(self):
|
||||
folio = False
|
||||
default_departure_hour = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_departure_hour')
|
||||
if 'folio_id' in self._context:
|
||||
folio = self.env['hotel.folio'].search([
|
||||
('id', '=', self._context['folio_id'])
|
||||
])
|
||||
if folio and folio.room_lines:
|
||||
return folio.room_lines[0].checkout
|
||||
else:
|
||||
tz_hotel = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'tz_hotel')
|
||||
now_utc_dt = date_utils.now() + timedelta(days=1)
|
||||
ndate = "%s %s:00" % \
|
||||
(now_utc_dt.strftime(DEFAULT_SERVER_DATE_FORMAT),
|
||||
default_departure_hour)
|
||||
ndate_dt = date_utils.get_datetime(ndate, stz=tz_hotel)
|
||||
ndate_dt = date_utils.dt_as_timezone(ndate_dt, 'UTC')
|
||||
return ndate_dt.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
@api.model
|
||||
def _get_default_channel_type(self):
|
||||
user = self.env['res.users'].browse(self.env.uid)
|
||||
if user.has_group('hotel.group_hotel_call'):
|
||||
return 'phone'
|
||||
|
||||
partner_id = fields.Many2one('res.partner',string="Customer")
|
||||
checkin = fields.Datetime('Check In', required=True,
|
||||
default=_get_default_checkin)
|
||||
checkout = fields.Datetime('Check Out', required=True,
|
||||
default=_get_default_checkout)
|
||||
reservation_wizard_ids = fields.One2many('hotel.reservation.wizard',
|
||||
'folio_wizard_id',
|
||||
string="Resevations")
|
||||
service_wizard_ids = fields.One2many('hotel.service.wizard',
|
||||
'folio_wizard_id',
|
||||
string='Services')
|
||||
total = fields.Float('Total', compute='_computed_total')
|
||||
confirm = fields.Boolean('Confirm Reservations', default="1")
|
||||
autoassign = fields.Boolean('Autoassign', default="1")
|
||||
channel_type = fields.Selection([
|
||||
('door', 'Door'),
|
||||
('mail', 'Mail'),
|
||||
('phone', 'Phone')
|
||||
], string='Sales Channel', default=_get_default_channel_type)
|
||||
virtual_room_wizard_ids = fields.Many2many('hotel.virtual.room.wizard',
|
||||
string="Virtual Rooms")
|
||||
call_center = fields.Boolean(default=_get_default_center_user)
|
||||
|
||||
def assign_rooms(self):
|
||||
self.assign=True
|
||||
|
||||
@api.onchange('autoassign')
|
||||
def create_reservations(self):
|
||||
self.ensure_one()
|
||||
total = 0
|
||||
cmds = []
|
||||
for line in self.virtual_room_wizard_ids:
|
||||
if line.rooms_num == 0:
|
||||
continue
|
||||
if line.rooms_num > line.max_rooms:
|
||||
raise ValidationError(_("Too many rooms!"))
|
||||
elif line.virtual_room_id:
|
||||
checkout_dt = date_utils.get_datetime(line.checkout)
|
||||
occupied = self.env['hotel.reservation'].occupied(
|
||||
line.checkin,
|
||||
checkout_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
rooms_occupied = occupied.mapped('product_id.id')
|
||||
free_rooms = self.env['hotel.room'].search([
|
||||
('product_id.id', 'not in', rooms_occupied),
|
||||
('price_virtual_room.id', '=', line.virtual_room_id.id)],
|
||||
order='sequence', limit=line.rooms_num)
|
||||
room_ids = free_rooms.mapped('product_id.id')
|
||||
product_list = self.env['product.product'].search([
|
||||
('id', 'in', room_ids)
|
||||
])
|
||||
nights = days_diff = date_utils.date_diff(line.checkin,
|
||||
line.checkout,
|
||||
hours=False)
|
||||
hotel_tz = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings',
|
||||
'hotel_tz')
|
||||
start_date_utc_dt = date_utils.get_datetime(self.checkin)
|
||||
start_date_dt = date_utils.dt_as_timezone(start_date_utc_dt,
|
||||
hotel_tz)
|
||||
for room in product_list:
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
res_price = 0
|
||||
res_partner = self.partner_id or self.env['res.partner'].browse('1')
|
||||
for i in range(0, nights):
|
||||
ndate = start_date_dt + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod = line.virtual_room_id.product_id.with_context(
|
||||
lang=self.partner_id.lang,
|
||||
partner=self.partner_id.id,
|
||||
quantity=1,
|
||||
date=ndate_str,
|
||||
pricelist=pricelist_id,
|
||||
uom=room.uom_id.id)
|
||||
res_price += prod.price
|
||||
adults = self.env['hotel.room'].search([
|
||||
('product_id.id', '=', room.id)
|
||||
]).capacity
|
||||
res_price = res_price - (res_price * line.discount)/100
|
||||
total += res_price
|
||||
cmds.append((0, False, {
|
||||
'checkin': line.checkin,
|
||||
'checkout': line.checkout,
|
||||
'discount': line.discount,
|
||||
'product_id': room.id,
|
||||
'nights': nights,
|
||||
'adults': adults,
|
||||
'children': 0,
|
||||
'virtual_room_id': line.virtual_room_id,
|
||||
'price': res_price,
|
||||
'amount_reservation': res_price
|
||||
}))
|
||||
self.reservation_wizard_ids = cmds
|
||||
self.total = total
|
||||
|
||||
@api.multi
|
||||
@api.onchange('checkin', 'checkout')
|
||||
def onchange_checks(self):
|
||||
'''
|
||||
When you change checkin or checkout it will checked it
|
||||
and update the qty of hotel folio line
|
||||
-----------------------------------------------------------------
|
||||
@param self: object pointer
|
||||
'''
|
||||
self.ensure_one()
|
||||
now_utc_dt = date_utils.now()
|
||||
if not self.checkin:
|
||||
self.checkin = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
if not self.checkout:
|
||||
self.checkout = time.strftime(DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
|
||||
# UTC -> Hotel tz
|
||||
tz = self.env['ir.default'].sudo().get('hotel.config.settings',
|
||||
'tz_hotel')
|
||||
chkin_utc_dt = date_utils.get_datetime(self.checkin)
|
||||
chkout_utc_dt = date_utils.get_datetime(self.checkout)
|
||||
|
||||
if chkin_utc_dt >= chkout_utc_dt:
|
||||
dpt_hour = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_departure_hour')
|
||||
checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
checkout_str = "%s %s:00" % (checkout_str, dpt_hour)
|
||||
checkout_dt = date_utils.get_datetime(checkout_str, stz=tz)
|
||||
checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC')
|
||||
self.checkout = checkout_utc_dt.strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
checkout_dt = date_utils.get_datetime(self.checkout, stz=tz)
|
||||
# Reservation end day count as free day. Not check it
|
||||
checkout_dt -= timedelta(days=1)
|
||||
virtual_room_ids = self.env['hotel.virtual.room'].search([])
|
||||
virtual_rooms = []
|
||||
|
||||
for virtual in virtual_room_ids:
|
||||
virtual_rooms.append((0, False, {
|
||||
'virtual_room_id': virtual.id,
|
||||
'checkin': self.checkin,
|
||||
'checkout': self.checkout,
|
||||
'folio_wizard_id': self.id,
|
||||
}))
|
||||
self.virtual_room_wizard_ids = virtual_rooms
|
||||
for virtual in self.virtual_room_wizard_ids:
|
||||
virtual.update_price()
|
||||
|
||||
@api.depends('virtual_room_wizard_ids','reservation_wizard_ids','service_wizard_ids')
|
||||
def _computed_total(self):
|
||||
total = 0
|
||||
for line in self.service_wizard_ids:
|
||||
total += line.price_total
|
||||
if not self.reservation_wizard_ids:
|
||||
for line in self.virtual_room_wizard_ids:
|
||||
total += line.total_price
|
||||
self.total = total
|
||||
else:
|
||||
for line in self.reservation_wizard_ids:
|
||||
total += line.price
|
||||
self.total = total
|
||||
|
||||
@api.multi
|
||||
def create_folio(self):
|
||||
self.ensure_one()
|
||||
if not self.partner_id:
|
||||
raise ValidationError(_("We need know the customer!"))
|
||||
reservations = [(5, False, False)]
|
||||
services = [(5, False, False)]
|
||||
if self.autoassign == True:
|
||||
self.create_reservations()
|
||||
for line in self.reservation_wizard_ids:
|
||||
reservations.append((0, False, {
|
||||
'product_id': line.product_id.id,
|
||||
'adults': line.adults,
|
||||
'children': line.children,
|
||||
'checkin': line.checkin,
|
||||
'checkout': line.checkout,
|
||||
'discount': line.discount,
|
||||
'virtual_room_id': line.virtual_room_id.id,
|
||||
'to_read': line.to_read, #REFACT: wubook module
|
||||
'to_assign': line.to_assign,
|
||||
}))
|
||||
for line in self.service_wizard_ids:
|
||||
services.append((0, False, {
|
||||
'product_id': line.product_id.id,
|
||||
'discount': line.discount,
|
||||
'price_unit': line.price_unit,
|
||||
'product_uom_qty': line.product_uom_qty,
|
||||
}))
|
||||
vals = {
|
||||
'partner_id': self.partner_id.id,
|
||||
'channel_type': self.channel_type,
|
||||
'room_lines': reservations,
|
||||
'service_lines': services,
|
||||
}
|
||||
newfol = self.env['hotel.folio'].create(vals)
|
||||
for room in newfol.room_lines:
|
||||
room.on_change_checkin_checkout_product_id()
|
||||
newfol.compute_invoices_amount()
|
||||
if self.confirm:
|
||||
newfol.room_lines.confirm()
|
||||
action = self.env.ref('hotel.open_hotel_folio1_form_tree_all').read()[0]
|
||||
if newfol:
|
||||
action['views'] = [(self.env.ref('hotel.view_hotel_folio1_form').id, 'form')]
|
||||
action['res_id'] = newfol.id
|
||||
else:
|
||||
action = {'type': 'ir.actions.act_window_close'}
|
||||
return action
|
||||
|
||||
class VirtualRoomWizars(models.TransientModel):
|
||||
_name = 'hotel.virtual.room.wizard'
|
||||
|
||||
@api.multi
|
||||
def _get_default_checkin(self):
|
||||
return self.folio_wizard_id.checkin
|
||||
|
||||
@api.model
|
||||
def _get_default_checkout(self):
|
||||
return self.folio_wizard_id.checkout
|
||||
|
||||
virtual_room_id = fields.Many2one('hotel.virtual.room',
|
||||
string="Virtual Rooms")
|
||||
rooms_num = fields.Integer('Number of Rooms')
|
||||
max_rooms = fields.Integer('Max', compute="_compute_max")
|
||||
price = fields.Float(string='Price by Room')
|
||||
total_price = fields.Float(string='Total Price')
|
||||
folio_wizard_id = fields.Many2one('hotel.folio.wizard')
|
||||
amount_reservation = fields.Float(string='Total', readonly=True)
|
||||
discount = fields.Float('discount')
|
||||
min_stay = fields.Integer('Min. Days', compute="_compute_max")
|
||||
checkin = fields.Datetime('Check In', required=True,
|
||||
default=_get_default_checkin)
|
||||
checkout = fields.Datetime('Check Out', required=True,
|
||||
default=_get_default_checkout)
|
||||
can_confirm = fields.Boolean(compute="_can_confirm")
|
||||
|
||||
def _can_confirm(self):
|
||||
for vroom in self:
|
||||
date_start = date_utils.get_datetime(vroom.checkin)
|
||||
date_end = date_utils.get_datetime(vroom.checkout)
|
||||
date_diff = date_utils.date_diff(date_start, date_end, hours=False)
|
||||
if vroom.max_rooms > 0 and vroom.min_stay <= date_diff:
|
||||
vroom.can_confirm = True
|
||||
else:
|
||||
vroom.can_confirm = False
|
||||
|
||||
def _compute_max(self):
|
||||
for res in self:
|
||||
user = self.env['res.users'].browse(self.env.uid)
|
||||
date_start = date_utils.get_datetime(res.checkin)
|
||||
date_end = date_utils.get_datetime(res.checkout)
|
||||
date_diff = date_utils.date_diff(date_start, date_end, hours=False)
|
||||
minstay_restrictions = self.env['hotel.virtual.room.restriction.item'].search([
|
||||
('virtual_room_id','=',res.virtual_room_id.id),
|
||||
])
|
||||
avail_restrictions = self.env['hotel.virtual.room.availability'].search([
|
||||
('virtual_room_id','=',res.virtual_room_id.id)
|
||||
])
|
||||
real_max = len(res.virtual_room_id.check_availability_virtual_room(
|
||||
res.checkin,
|
||||
res.checkout,
|
||||
res.virtual_room_id.id))
|
||||
avail = 100000
|
||||
min_stay = 0
|
||||
dates = []
|
||||
for i in range(0, date_diff):
|
||||
ndate_dt = date_start + timedelta(days=i)
|
||||
ndate_str = ndate_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
dates.append(ndate_str)
|
||||
if minstay_restrictions:
|
||||
date_min_days = minstay_restrictions.filtered(
|
||||
lambda r: r.date_start <= ndate_str and \
|
||||
r.date_end >= ndate_str).min_stay
|
||||
if date_min_days > min_stay:
|
||||
min_stay = date_min_days
|
||||
if user.has_group('hotel.group_hotel_call'):
|
||||
if avail_restrictions:
|
||||
max_avail = avail_restrictions.filtered(
|
||||
lambda r: r.date == ndate_str).wmax_avail
|
||||
if max_avail < avail:
|
||||
avail = min(max_avail, real_max)
|
||||
else:
|
||||
avail = real_max
|
||||
|
||||
|
||||
if avail < 100000 and avail > 0:
|
||||
res.max_rooms = avail
|
||||
else:
|
||||
res.max_rooms = 0
|
||||
if min_stay > 0:
|
||||
res.min_stay = min_stay
|
||||
|
||||
@api.onchange('rooms_num', 'discount', 'price','virtual_room_id',
|
||||
'checkin','checkout')
|
||||
def update_price(self):
|
||||
for line in self:
|
||||
now_utc_dt = date_utils.now()
|
||||
if not self.checkin:
|
||||
self.checkin = self.folio_wizard_id.checkin
|
||||
if not self.checkout:
|
||||
self.checkout = self.folio_wizard_id.checkout
|
||||
if self.rooms_num > self.max_rooms:
|
||||
raise ValidationError(_("There are not enough rooms!"))
|
||||
# UTC -> Hotel tz
|
||||
tz = self.env['ir.default'].sudo().get('hotel.config.settings',
|
||||
'tz_hotel')
|
||||
chkin_utc_dt = date_utils.get_datetime(self.checkin)
|
||||
chkout_utc_dt = date_utils.get_datetime(self.checkout)
|
||||
|
||||
if chkin_utc_dt >= chkout_utc_dt:
|
||||
dpt_hour = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'default_departure_hour')
|
||||
checkout_str = (chkin_utc_dt + timedelta(days=1)).strftime(
|
||||
DEFAULT_SERVER_DATE_FORMAT)
|
||||
checkout_str = "%s %s:00" % (checkout_str, dpt_hour)
|
||||
checkout_dt = date_utils.get_datetime(checkout_str, stz=tz)
|
||||
checkout_utc_dt = date_utils.dt_as_timezone(checkout_dt, 'UTC')
|
||||
self.checkout = checkout_utc_dt.strftime(
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
checkout_dt = date_utils.get_datetime(self.checkout, stz=tz)
|
||||
# Reservation end day count as free day. Not check it
|
||||
checkout_dt -= timedelta(days=1)
|
||||
nights = days_diff = date_utils.date_diff(self.checkin,
|
||||
self.checkout,
|
||||
hours=False)
|
||||
start_date_dt = date_utils.dt_as_timezone(chkin_utc_dt,
|
||||
tz)
|
||||
# Reservation end day count as free day. Not check it
|
||||
checkout_dt -= timedelta(days=1)
|
||||
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
|
||||
res_price = 0
|
||||
for i in range(0, nights):
|
||||
ndate = start_date_dt + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod = self.virtual_room_id.product_id.with_context(
|
||||
lang=self.folio_wizard_id.partner_id.lang,
|
||||
partner=self.folio_wizard_id.partner_id.id,
|
||||
quantity=1,
|
||||
date=ndate_str,
|
||||
pricelist=pricelist_id,
|
||||
uom=self.virtual_room_id.product_id.uom_id.id)
|
||||
res_price += prod.price
|
||||
self.price = res_price - (res_price * self.discount)/100
|
||||
self.total_price = self.rooms_num * self.price
|
||||
self.amount_reservation = self.total_price
|
||||
|
||||
|
||||
class ReservationWizard(models.TransientModel):
|
||||
_name = 'hotel.reservation.wizard'
|
||||
|
||||
product_id = fields.Many2one('product.product',
|
||||
string="Virtual Rooms")
|
||||
|
||||
folio_wizard_id = fields.Many2one('hotel.folio.wizard')
|
||||
|
||||
adults = fields.Integer('Adults',
|
||||
help='List of adults there in guest list. ')
|
||||
children = fields.Integer('Children',
|
||||
help='Number of children there in guest list.')
|
||||
checkin = fields.Datetime('Check In', required=True)
|
||||
checkout = fields.Datetime('Check Out', required=True)
|
||||
virtual_room_id = fields.Many2one('hotel.virtual.room',
|
||||
string='Virtual Room Type',
|
||||
required=True)
|
||||
nights = fields.Integer('Nights', readonly=True)
|
||||
price = fields.Float(string='Total')
|
||||
amount_reservation = fields.Float(string='Total', readonly=True)
|
||||
partner_id = fields.Many2one(related='folio_wizard_id.partner_id')
|
||||
discount = fields.Float('discount')
|
||||
to_read = fields.Boolean(compute="_compute_to_read_assign")
|
||||
to_assign = fields.Boolean(compute="_compute_to_read_assign")
|
||||
|
||||
@api.multi
|
||||
def _compute_to_read_assign(self):
|
||||
for rec in self:
|
||||
user = self.env['res.users'].browse(self.env.uid)
|
||||
if user.has_group('hotel.group_hotel_call'):
|
||||
rec.to_read = rec.to_assign = True
|
||||
|
||||
@api.multi
|
||||
@api.onchange('product_id')
|
||||
def onchange_product_id(self):
|
||||
for line in self:
|
||||
if line.checkin and line.checkout:
|
||||
room = self.env['hotel.room'].search([
|
||||
('product_id.id','=',line.product_id.id)
|
||||
])
|
||||
if line.adults == 0:
|
||||
line.adults = room.capacity
|
||||
line.virtual_room_id = room.price_virtual_room.id
|
||||
checkout_dt = date_utils.get_datetime(line.checkout)
|
||||
checkout_dt -= timedelta(days=1)
|
||||
occupied = self.env['hotel.reservation'].occupied(
|
||||
line.checkin,
|
||||
checkout_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
rooms_occupied = occupied.mapped('product_id.id')
|
||||
if line.product_id.id in rooms_occupied:
|
||||
raise ValidationError(_("This room is occupied!, please, choice other room or change the reservation date"))
|
||||
|
||||
@api.multi
|
||||
@api.onchange('checkin', 'checkout', 'virtual_room_id', 'discount')
|
||||
def onchange_dates(self):
|
||||
for line in self:
|
||||
if not self.checkin:
|
||||
self.checkin = self.folio_wizard_id.checkin
|
||||
if not self.checkout:
|
||||
self.checkout = self.folio_wizard_id.checkout
|
||||
|
||||
hotel_tz = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'hotel_tz')
|
||||
start_date_utc_dt = date_utils.get_datetime(line.checkin)
|
||||
start_date_dt = date_utils.dt_as_timezone(start_date_utc_dt,
|
||||
hotel_tz)
|
||||
|
||||
if line.virtual_room_id:
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if pricelist_id:
|
||||
pricelist_id = int(pricelist_id)
|
||||
nights = days_diff = date_utils.date_diff(line.checkin,
|
||||
line.checkout,
|
||||
hours=False)
|
||||
res_price = 0
|
||||
res_partner = self.partner_id or self.env['res.partner'].browse('1')
|
||||
for i in range(0, nights):
|
||||
ndate = start_date_dt + timedelta(days=i)
|
||||
ndate_str = ndate.strftime(DEFAULT_SERVER_DATE_FORMAT)
|
||||
prod = line.virtual_room_id.product_id.with_context(
|
||||
lang=self.partner_id.lang,
|
||||
partner=self.partner_id.id,
|
||||
quantity=1,
|
||||
date=ndate_str,
|
||||
pricelist=pricelist_id,
|
||||
uom=line.product_id.uom_id.id)
|
||||
res_price += prod.price
|
||||
adults = self.env['hotel.room'].search([
|
||||
('product_id.id', '=', line.product_id.id)
|
||||
]).capacity
|
||||
res_price = res_price - (res_price * self.discount)/100
|
||||
line.amount_reservation = res_price
|
||||
line.price = res_price
|
||||
checkout_dt = date_utils.get_datetime(self.checkout)
|
||||
checkout_dt -= timedelta(days=1)
|
||||
occupied = self.env['hotel.reservation'].occupied(
|
||||
self.checkin,
|
||||
checkout_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
|
||||
rooms_occupied = occupied.mapped('product_id.id')
|
||||
domain_rooms = [
|
||||
('isroom', '=', True),
|
||||
('id', 'not in', rooms_occupied)
|
||||
]
|
||||
return {'domain': {'product_id': domain_rooms}}
|
||||
|
||||
class ServiceWizard(models.TransientModel):
|
||||
_name = 'hotel.service.wizard'
|
||||
|
||||
product_id = fields.Many2one('product.product',
|
||||
string="Service")
|
||||
folio_wizard_id = fields.Many2one('hotel.folio.wizard')
|
||||
discount = fields.Float('discount')
|
||||
price_unit = fields.Float('Unit Price', required=True, digits=dp.get_precision('Product Price'), default=0.0)
|
||||
price_total = fields.Float(compute='_compute_amount', string='Subtotal', readonly=True, store=True)
|
||||
product_uom_qty = fields.Float(string='Quantity', digits=dp.get_precision('Product Unit of Measure'), required=True, default=1.0)
|
||||
|
||||
@api.onchange('product_id')
|
||||
def onchange_product_id(self):
|
||||
if self.product_id:
|
||||
#TODO change pricelist for partner
|
||||
pricelist_id = self.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
prod = self.product_id.with_context(
|
||||
lang=self.folio_wizard_id.partner_id.lang,
|
||||
partner=self.folio_wizard_id.partner_id.id,
|
||||
quantity=1,
|
||||
date=fields.Datetime.now(),
|
||||
pricelist=pricelist_id,
|
||||
uom=self.product_id.uom_id.id)
|
||||
self.price_unit = prod.price
|
||||
|
||||
@api.depends('price_unit', 'product_uom_qty', 'discount')
|
||||
def _compute_amount(self):
|
||||
for ser in self:
|
||||
total = (ser.price_unit * ser.product_uom_qty)
|
||||
ser.price_total = total - (total * ser.discount) / 100
|
||||
101
hotel_calendar/wizard/wizard_reservation.xml
Normal file
101
hotel_calendar/wizard/wizard_reservation.xml
Normal file
@@ -0,0 +1,101 @@
|
||||
<?xml version="1.0" ?>
|
||||
<odoo>
|
||||
|
||||
<record model="ir.ui.view" id="hotel_folio_wizard">
|
||||
<field name="name">hotel.folio.wizard</field>
|
||||
<field name="model">hotel.folio.wizard</field>
|
||||
<field name="arch" type="xml">
|
||||
<form string="Reservation Wizard" >
|
||||
<sheet>
|
||||
<group>
|
||||
<group>
|
||||
<field name="checkin" required="1" colspan="1"/>
|
||||
<field name="checkout" required="1" colspan="1"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="call_center" invisible="1" />
|
||||
<field name="channel_type" required="1" attrs="{'readonly':[('call_center','=',True)]}"/>
|
||||
<field name="partner_id"/>
|
||||
</group>
|
||||
</group>
|
||||
<group>
|
||||
<field name="virtual_room_wizard_ids" nolabel="1"
|
||||
attrs="{'invisible': [('autoassign','=',False)]}">
|
||||
<tree editable="bottom" create="false" delete="false"
|
||||
decoration-danger="max_rooms < rooms_num"
|
||||
decoration-muted="can_confirm == False"
|
||||
decoration-success="max_rooms >= rooms_num and rooms_num > 0">
|
||||
<field name="min_stay" />
|
||||
<field name="max_rooms" />
|
||||
<field name="virtual_room_id" string="Room Type" readonly="1"/>
|
||||
<field name="rooms_num" attrs="{'readonly': [('can_confirm','=',False)]}" />
|
||||
<field name="checkin" widget="date" />
|
||||
<field name="checkout" widget="date" />
|
||||
<field name="discount" attrs="{'readonly': [('can_confirm','=',False)]}"/>
|
||||
<field name="price" attrs="{'readonly': [('can_confirm','=',False)]}"/>
|
||||
<field name="amount_reservation" readonly="1" />
|
||||
<field name="total_price" invisible="1" />
|
||||
<field name="can_confirm" invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<label for="autoassign" attrs="{'invisible': [('autoassign','=', False)]}"/>
|
||||
<field name="autoassign" attrs="{'invisible': [('autoassign','=', False)]}"/>
|
||||
<field name="confirm" invisible="1"/>
|
||||
<group colspan="2" class="oe_subtotal_footer">
|
||||
<field name="total"/>
|
||||
</group>
|
||||
<group>
|
||||
<field name="reservation_wizard_ids" colspan="4" string="Room Lines"
|
||||
nolabel="1" attrs="{'invisible': [('autoassign','=',True)]}">
|
||||
<tree string="Room Line" delete="false" editable="buttom">
|
||||
<field name="product_id" string="Room No" options="{'no_create': True}"/>
|
||||
<field name="virtual_room_id" options="{'no_create': True}" />
|
||||
<field name="checkin" />
|
||||
<field name="checkout" />
|
||||
<field name="nights" />
|
||||
<field name="adults" />
|
||||
<field name="children" />
|
||||
<field name="discount" />
|
||||
<field name="amount_reservation" />
|
||||
<field name="price" invisible = "1"/>
|
||||
<field name="partner_id" invisible = "1" />
|
||||
<field name="folio_wizard_id" invisible = "1" />
|
||||
<field name="to_read" invisible="1" />
|
||||
<field name="to_assign" invisible="1" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<group>
|
||||
<field name="service_wizard_ids" colspan="4" string="Services"
|
||||
nolabel="1" >
|
||||
<tree string="Services" editable="buttom">
|
||||
<field name="product_id" string="Service" options="{'no_create': True}"
|
||||
domain="[('isservice','=',True)]"/>
|
||||
<field name="product_uom_qty" />
|
||||
<field name="price_unit" />
|
||||
<field name="discount" />
|
||||
<field name="price_total" />
|
||||
</tree>
|
||||
</field>
|
||||
</group>
|
||||
<footer>
|
||||
<button name="create_folio" string="Create Reservations" type="object"
|
||||
class="oe_highlight" />
|
||||
</footer>
|
||||
</sheet>
|
||||
</form>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="open_wizard_reservations" model="ir.actions.act_window">
|
||||
<field name="name">Hotel Reservation Wizard</field>
|
||||
<field name="type">ir.actions.act_window</field>
|
||||
<field name="res_model">hotel.folio.wizard</field>
|
||||
<field name="view_id" ref="hotel_folio_wizard"/>
|
||||
<field name="view_type">form</field>
|
||||
<field name="view_mode">form</field>
|
||||
<field name="target">new</field>
|
||||
</record>
|
||||
|
||||
</odoo>
|
||||
15
hotel_calendar_channel_connector/README.rst
Normal file
15
hotel_calendar_channel_connector/README.rst
Normal file
@@ -0,0 +1,15 @@
|
||||
HOTEL CALENDAR WUBOOK
|
||||
=============
|
||||
- Show button for see reservations from wubook in hotel calendar view
|
||||
- Mark as read-only reservations from wubook
|
||||
|
||||
** UNDER DEVELOPMENT: NOT USE IN PRODUCTION **
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Creator
|
||||
------------
|
||||
|
||||
* Alexandre Díaz <alex@aloxa.eu>
|
||||
22
hotel_calendar_channel_connector/__init__.py
Normal file
22
hotel_calendar_channel_connector/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import models
|
||||
53
hotel_calendar_channel_connector/__manifest__.py
Normal file
53
hotel_calendar_channel_connector/__manifest__.py
Normal file
@@ -0,0 +1,53 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Hotel Calendar WuBook',
|
||||
'version': '1.0',
|
||||
'author': "Alexandre Díaz (Aloxa Solucións S.L.) <alex@aloxa.eu>",
|
||||
'website': 'https://www.eiqui.com',
|
||||
'category': 'eiqui/hotel',
|
||||
'summary': "Hotel Calendar",
|
||||
'description': "Hotel Calendar WuBook",
|
||||
'depends': [
|
||||
'hotel_calendar',
|
||||
'hotel_wubook_proto',
|
||||
],
|
||||
'external_dependencies': {
|
||||
'python': []
|
||||
},
|
||||
'data': [
|
||||
'views/hotel_reservation.xml',
|
||||
'views/general.xml',
|
||||
'views/actions.xml',
|
||||
],
|
||||
'qweb': [
|
||||
'static/src/xml/*.xml',
|
||||
],
|
||||
'test': [
|
||||
],
|
||||
|
||||
'installable': True,
|
||||
'auto_install': True,
|
||||
'application': False,
|
||||
'license': 'AGPL-3',
|
||||
}
|
||||
111
hotel_calendar_channel_connector/i18n/es.po
Normal file
111
hotel_calendar_channel_connector/i18n/es.po
Normal file
@@ -0,0 +1,111 @@
|
||||
# Translation of Odoo Server.
|
||||
# This file contains the translation of the following modules:
|
||||
# * hotel_calendar_wubook
|
||||
#
|
||||
msgid ""
|
||||
msgstr ""
|
||||
"Project-Id-Version: Odoo Server 10.0\n"
|
||||
"Report-Msgid-Bugs-To: \n"
|
||||
"POT-Creation-Date: 2018-05-22 06:41+0000\n"
|
||||
"PO-Revision-Date: 2018-05-22 06:41+0000\n"
|
||||
"Last-Translator: <>\n"
|
||||
"Language-Team: \n"
|
||||
"MIME-Version: 1.0\n"
|
||||
"Content-Type: text/plain; charset=UTF-8\n"
|
||||
"Content-Transfer-Encoding: \n"
|
||||
"Plural-Forms: \n"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#. openerp-web
|
||||
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_templates.xml:10
|
||||
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_view.xml:24
|
||||
#, python-format
|
||||
msgid "Channel:"
|
||||
msgstr "Canal:"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Final Price"
|
||||
msgstr "Precio Final"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Folio Pending Amount"
|
||||
msgstr "Pendiente en Ficha"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Hotel Reservation"
|
||||
msgstr "Reserva"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#. openerp-web
|
||||
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_view.xml:15
|
||||
#, python-format
|
||||
msgid "ISSUES"
|
||||
msgstr "AVISOS"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.hotel_reservation_view_form
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Mark as Read"
|
||||
msgstr "Marcar como leídp"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: code:addons/hotel_calendar_wubook/models/inherited_wubook_issue.py:33
|
||||
#, python-format
|
||||
msgid "Oops! Issue Reported!!"
|
||||
msgstr "Oops! ¡Aviso generado!"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Persons"
|
||||
msgstr "Personas"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Reservation Price"
|
||||
msgstr "Precio de Reserva"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.actions.act_window,name:hotel_calendar_wubook.hotel_reservation_action_manager_request
|
||||
msgid "Reservations to Assign from WuBook"
|
||||
msgstr "Reservas por Asignar desde WuBook"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Reserved Room Type"
|
||||
msgstr "Tipo Habitación Reservada"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.ui.view,arch_db:hotel_calendar_wubook.view_hotel_toassign_reservation_tree
|
||||
msgid "Room"
|
||||
msgstr "Habitación"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#. openerp-web
|
||||
#: code:addons/hotel_calendar_wubook/static/src/xml/hotel_calendar_templates.xml:4
|
||||
#, python-format
|
||||
msgid "Section:"
|
||||
msgstr "Sección"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.actions.act_window,name:hotel_calendar_wubook.calendar_wubook_issues_action
|
||||
msgid "WuBook Issues"
|
||||
msgstr "Problemas de WuBook"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.model,name:hotel_calendar_wubook.model_bus_hotel_calendar
|
||||
msgid "bus.hotel.calendar"
|
||||
msgstr "bus.hotel.calendar"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.model,name:hotel_calendar_wubook.model_hotel_reservation
|
||||
msgid "hotel reservation"
|
||||
msgstr "Reserva"
|
||||
|
||||
#. module: hotel_calendar_wubook
|
||||
#: model:ir.model,name:hotel_calendar_wubook.model_wubook_issue
|
||||
msgid "wubook.issue"
|
||||
msgstr "wubook.issue"
|
||||
|
||||
25
hotel_calendar_channel_connector/models/__init__.py
Normal file
25
hotel_calendar_channel_connector/models/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import inherited_hotel_reservation
|
||||
from . import inherited_bus_hotel_calendar
|
||||
from . import inherited_wubook_issue
|
||||
from . import inherited_hotel_calendar_management
|
||||
@@ -0,0 +1,63 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import datetime
|
||||
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
|
||||
from openerp import models, api
|
||||
from odoo.addons.hotel_calendar.controllers.bus import HOTEL_BUS_CHANNEL_ID
|
||||
|
||||
|
||||
class BusHotelCalendar(models.TransientModel):
|
||||
_inherit = 'bus.hotel.calendar'
|
||||
|
||||
@api.model
|
||||
def _generate_issue_notification(self, ntype, title, issue_id, section,
|
||||
message):
|
||||
user_id = self.env['res.users'].browse(self.env.uid)
|
||||
return {
|
||||
'type': 'issue',
|
||||
'subtype': ntype,
|
||||
'title': title,
|
||||
'username': user_id.partner_id.name,
|
||||
'userid': user_id.id,
|
||||
'issue': {
|
||||
'issue_id': issue_id,
|
||||
'section': section.upper(),
|
||||
'message': message,
|
||||
},
|
||||
}
|
||||
|
||||
@api.model
|
||||
def _generate_reservation_notif(self, vals):
|
||||
json = super(BusHotelCalendar, self)._generate_reservation_notif(vals)
|
||||
json['reservation'].update({
|
||||
'wrid': vals['wrid'],
|
||||
})
|
||||
return json
|
||||
|
||||
@api.model
|
||||
def send_issue_notification(self, ntype, title, issue_id, section,
|
||||
message):
|
||||
notif = self._generate_issue_notification(ntype, title, issue_id,
|
||||
section, message)
|
||||
self.env['bus.bus'].sendone(
|
||||
(self._cr.dbname, 'hotel.reservation',
|
||||
HOTEL_BUS_CHANNEL_ID), notif)
|
||||
@@ -0,0 +1,45 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp import models, api
|
||||
|
||||
|
||||
class HotelCalendarManagement(models.TransientModel):
|
||||
_inherit = 'hotel.calendar.management'
|
||||
|
||||
@api.model
|
||||
def _get_availability_values(self, avail, vroom):
|
||||
vals = super(HotelCalendarManagement, self)._get_availability_values(
|
||||
avail, vroom)
|
||||
vals.update({'wmax_avail': vals['avail']})
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def save_changes(self, pricelist_id, restriction_id, pricelist,
|
||||
restrictions, availability):
|
||||
res = super(HotelCalendarManagement, self).save_changes(
|
||||
pricelist_id,
|
||||
restriction_id,
|
||||
pricelist,
|
||||
restrictions,
|
||||
availability)
|
||||
self.env['wubook'].push_changes()
|
||||
return res
|
||||
@@ -0,0 +1,122 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import logging
|
||||
from datetime import datetime, timedelta
|
||||
from openerp import models, fields, api, _
|
||||
from openerp.tools import (
|
||||
DEFAULT_SERVER_DATE_FORMAT,
|
||||
DEFAULT_SERVER_DATETIME_FORMAT)
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class HotelReservation(models.Model):
|
||||
_inherit = "hotel.reservation"
|
||||
|
||||
@api.model
|
||||
def _generate_reservation_notif(self, action, ntype, title,
|
||||
product_id, reserv_id, partner_name,
|
||||
adults, children, checkin, checkout,
|
||||
folio_id, color, color_text, splitted,
|
||||
parent_reservation, room_name,
|
||||
partner_phone, state, fix_days):
|
||||
vals = super(HotelReservation, self)._generate_reservation_notif(
|
||||
action, ntype, title, product_id,
|
||||
reserv_id, partner_name, adults,
|
||||
children, checkin, checkout,
|
||||
folio_id, color, color_text, splitted, parent_reservation,
|
||||
room_name, partner_phone, state, fix_days)
|
||||
reserv = self.env['hotel.reservation'].browse(vals['reserv_id'])
|
||||
vals['reservation'].update({
|
||||
'fix_days': (reserv.wrid and reserv.wrid != '') or fix_days,
|
||||
'wchannel': (reserv.wchannel_id and reserv.wchannel_id.name),
|
||||
})
|
||||
return vals
|
||||
|
||||
@api.multi
|
||||
def _hcalendar_reservation_data(self, reservations):
|
||||
vals = super(HotelReservation, self)._hcalendar_reservation_data(
|
||||
reservations)
|
||||
hotel_reservation_obj = self.env['hotel.reservation']
|
||||
json_reservations = []
|
||||
for v_rval in vals[0]:
|
||||
reserv = hotel_reservation_obj.browse(v_rval[1])
|
||||
json_reservations.append((
|
||||
reserv.product_id.id,
|
||||
reserv.id,
|
||||
reserv.folio_id.partner_id.name,
|
||||
reserv.adults,
|
||||
reserv.children,
|
||||
reserv.checkin,
|
||||
reserv.checkout,
|
||||
reserv.folio_id.id,
|
||||
reserv.reserve_color,
|
||||
reserv.reserve_color_text,
|
||||
reserv.splitted,
|
||||
reserv.parent_reservation.id,
|
||||
# Read-Only
|
||||
False,
|
||||
# Fix Days
|
||||
(reserv.wrid and reserv.wrid != '') or reserv.splitted,
|
||||
# Fix Rooms
|
||||
False,
|
||||
reserv.overbooking))
|
||||
# Update tooltips
|
||||
vals[1][reserv.id].append(reserv.wchannel_id.name)
|
||||
return (json_reservations, vals[1])
|
||||
|
||||
@api.multi
|
||||
def send_bus_notification(self, naction, ntype, ntitle=''):
|
||||
hotel_cal_obj = self.env['bus.hotel.calendar']
|
||||
for record in self:
|
||||
hotel_cal_obj.send_reservation_notification({
|
||||
'action': naction,
|
||||
'type': ntype,
|
||||
'title': ntitle,
|
||||
'product_id': record.product_id.id,
|
||||
'reserv_id': record.id,
|
||||
'partner_name': record.partner_id.name,
|
||||
'adults': record.adults,
|
||||
'children': record.children,
|
||||
'checkin': record.checkin,
|
||||
'checkout': record.checkout,
|
||||
'folio_id': record.folio_id.id,
|
||||
'reserve_color': record.reserve_color,
|
||||
'reserve_color_text': record.reserve_color_text,
|
||||
'splitted': record.splitted,
|
||||
'parent_reservation': record.parent_reservation and
|
||||
record.parent_reservation.id or 0,
|
||||
'room_name': record.product_id.name,
|
||||
'partner_phone': record.partner_id.mobile
|
||||
or record.partner_id.phone or _('Undefined'),
|
||||
'state': record.state,
|
||||
'fix_days': record.splitted or record.wis_from_channel,
|
||||
'overbooking': record.overbooking,
|
||||
'price': record.folio_id.amount_total,
|
||||
'wrid': record.wrid,
|
||||
})
|
||||
|
||||
@api.multi
|
||||
def confirm(self):
|
||||
for record in self:
|
||||
if record.to_assign == True:
|
||||
record.write({'to_read': False, 'to_assign': False})
|
||||
return super(HotelReservation, self).confirm()
|
||||
@@ -0,0 +1,37 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from openerp import models, fields, api, _
|
||||
|
||||
|
||||
class WuBookIssue(models.Model):
|
||||
_inherit = 'wubook.issue'
|
||||
|
||||
@api.model
|
||||
def create(self, vals):
|
||||
issue_id = super(WuBookIssue, self).create(vals)
|
||||
self.env['bus.hotel.calendar'].send_issue_notification(
|
||||
'warn',
|
||||
_("Oops! Issue Reported!!"),
|
||||
issue_id.id,
|
||||
issue_id.section,
|
||||
issue_id.message)
|
||||
return issue_id
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 6.1 KiB |
@@ -0,0 +1,22 @@
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-md-9">
|
||||
<div>
|
||||
<h1>HOTEL CALENDAR WUBOOK</h1>
|
||||
<h2 class="text-muted">Hotel Calendar WuBook</h2>
|
||||
</div>
|
||||
<hr/>
|
||||
<p class="lead">Hotel Calendar WuBook</p>
|
||||
</div>
|
||||
|
||||
<hr/>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-9 mb32">
|
||||
<a target="_blank" href="http://www.eiqui.com">
|
||||
<img src="eiqui_logo.png" class="img-responsive center-block" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
BIN
hotel_calendar_channel_connector/static/sfx/book_cancelled.mp3
Normal file
BIN
hotel_calendar_channel_connector/static/sfx/book_cancelled.mp3
Normal file
Binary file not shown.
BIN
hotel_calendar_channel_connector/static/sfx/book_new.mp3
Normal file
BIN
hotel_calendar_channel_connector/static/sfx/book_new.mp3
Normal file
Binary file not shown.
50
hotel_calendar_channel_connector/static/src/css/view.css
Normal file
50
hotel_calendar_channel_connector/static/src/css/view.css
Normal file
@@ -0,0 +1,50 @@
|
||||
/*
|
||||
* Hotel Calendar JS v0.0.1a - 2017
|
||||
* GNU Public License
|
||||
* Aloxa Solucions S.L. <info@aloxa.eu>
|
||||
* Alexandre Díaz <alex@aloxa.eu>
|
||||
*/
|
||||
|
||||
/** ANIMATIONS **/
|
||||
@keyframes channel-manager-changes {
|
||||
0% {
|
||||
color: red;
|
||||
}
|
||||
5% {
|
||||
transform: rotate(10deg);
|
||||
}
|
||||
10% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
15% {
|
||||
transform: rotate(-10deg);
|
||||
}
|
||||
20% {
|
||||
transform: rotate(0deg);
|
||||
}
|
||||
100% {
|
||||
color: yellow;
|
||||
}
|
||||
}
|
||||
@keyframes channel-manager-changes-text {
|
||||
from {
|
||||
color: white;
|
||||
}
|
||||
to {
|
||||
color: black;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#pms-menu #btn_channel_manager_request.incoming i {
|
||||
animation-name: channel-manager-changes;
|
||||
animation-duration: 2s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-direction: alternate;
|
||||
}
|
||||
#pms-menu #btn_channel_manager_request.incoming span {
|
||||
animation-name: channel-manager-changes-text;
|
||||
animation-duration: 2s;
|
||||
animation-iteration-count: infinite;
|
||||
animation-direction: alternate;
|
||||
}
|
||||
@@ -0,0 +1,87 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSHotelCalendarControllerChannelConnector', function (require) {
|
||||
"use strict";
|
||||
|
||||
var PMSCalendarController = require('hotel_calendar.PMSCalendarController');
|
||||
var Core = require('web.core');
|
||||
|
||||
var QWeb = Core.qweb;
|
||||
|
||||
var PMSHotelCalendarControllerChannelConnector = PMSCalendarController.include({
|
||||
_sounds: [],
|
||||
SOUNDS: { NONE: 0, BOOK_NEW:1, BOOK_CANCELLED:2 },
|
||||
|
||||
init: function (parent, model, renderer, params) {
|
||||
this._super.apply(this, arguments);
|
||||
|
||||
this._sounds[this.SOUNDS.BOOK_NEW] = new Audio('hotel_calendar_channel_connector/static/sfx/book_new.mp3');
|
||||
this._sounds[this.SOUNDS.BOOK_CANCELLED] = new Audio('hotel_calendar_channel_connector/static/sfx/book_cancelled.mp3');
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Public
|
||||
//--------------------------------------------------------------------------
|
||||
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Private
|
||||
//--------------------------------------------------------------------------
|
||||
_play_sound: function(/*int*/SoundID) {
|
||||
this._sounds[SoundID].play();
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
// Handlers
|
||||
//--------------------------------------------------------------------------
|
||||
_onUpdateButtonsCounter: function (ev) {
|
||||
this._super(ev);
|
||||
var self = this;
|
||||
var domain_reservations = [['to_assign', '=', true], ['to_read', '=', true]];
|
||||
var domain_issues = [['to_read', '=', true]];
|
||||
$.when(
|
||||
this.model.search_count(domain_reservations),
|
||||
this.model.search_count(domain_issues),
|
||||
).then(function(a1, a2){
|
||||
self.renderer.update_buttons_counter_channel_connector(a1, a2);
|
||||
});
|
||||
},
|
||||
|
||||
_onBusNotification: function(notifications) {
|
||||
for (var notif of notifications) {
|
||||
if (notif[0][1] === 'hotel.reservation') {
|
||||
if (notif[1]['type'] === 'issue') {
|
||||
if (notif[1]['userid'] === this.dataset.context.uid) {
|
||||
continue;
|
||||
}
|
||||
|
||||
var issue = notif[1]['issue'];
|
||||
var qdict = issue;
|
||||
var msg = QWeb.render('HotelCalendarChannelConnector.NotificationIssue', qdict);
|
||||
if (notif[1]['subtype'] === 'notify') {
|
||||
this.do_notify(notif[1]['title'], msg, true);
|
||||
} else if (notif[1]['subtype'] === 'warn') {
|
||||
this.do_warn(notif[1]['title'], msg, true);
|
||||
}
|
||||
}
|
||||
else if (notif[1]['type'] === 'reservation') {
|
||||
var reserv = notif[1]['reservation'];
|
||||
if (reserv['wrid']) {
|
||||
if (notif[1]['action'] === 'create') {
|
||||
this._play_sound(this.SOUNDS.BOOK_NEW);
|
||||
} else if (notif[1]['action'] !== 'unlink' && reserv['state'] === 'cancelled') {
|
||||
this._play_sound(this.SOUNDS.BOOK_CANCELLED);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this._super(notifications);
|
||||
},
|
||||
|
||||
});
|
||||
|
||||
return PMSHotelCalendarControllerChannelConnector;
|
||||
|
||||
});
|
||||
@@ -0,0 +1,119 @@
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar.PMSCalendarModel', function (require) {
|
||||
"use strict";
|
||||
|
||||
var AbstractModel = require('web.AbstractModel'),
|
||||
Context = require('web.Context'),
|
||||
Core = require('web.core'),
|
||||
FieldUtils = require('web.field_utils'),
|
||||
Session = require('web.session');
|
||||
|
||||
|
||||
return AbstractModel.extend({
|
||||
init: function () {
|
||||
this._super.apply(this, arguments);
|
||||
this.end_date = null;
|
||||
},
|
||||
|
||||
load: function (params) {
|
||||
this.modelName = params.modelName;
|
||||
this.modelManagementName = 'hotel.calendar.management'
|
||||
},
|
||||
|
||||
save_pricelist: function(params) {
|
||||
return this._rpc({
|
||||
model: this.modelManagementName,
|
||||
method: 'save_changes',
|
||||
args: params,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
swap_reservations: function(fromIds, toIds) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'swap_reservations',
|
||||
args: [fromIds, toIds],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_calendar_data: function(oparams) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_all_data',
|
||||
args: oparams,
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
get_hcalendar_settings: function() {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'get_hcalendar_settings',
|
||||
args: [false],
|
||||
});
|
||||
},
|
||||
|
||||
get_room_types: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.type',
|
||||
method: 'search_read',
|
||||
args: [false, ['cat_id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_floors: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.floor',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_amenities: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.room.amenities',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
get_vrooms: function() {
|
||||
return this._rpc({
|
||||
model: 'hotel.virtual.room',
|
||||
method: 'search_read',
|
||||
args: [false, ['id','name']],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
search_count: function(domain) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'search_count',
|
||||
args: [domain],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
update_records: function(ids, vals) {
|
||||
return this._rpc({
|
||||
model: this.modelName,
|
||||
method: 'write',
|
||||
args: [ids, write_values],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
|
||||
folio_search_count: function(domain) {
|
||||
return this._rpc({
|
||||
model: 'hotel.folio',
|
||||
method: 'search_count',
|
||||
args: [domain],
|
||||
context: Session.user_context,
|
||||
});
|
||||
},
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,60 @@
|
||||
/* global odoo, $ */
|
||||
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
|
||||
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
|
||||
odoo.define('hotel_calendar_channel_connector.PMSHotelCalendarRendererChannelConnector', function (require) {
|
||||
'use strict';
|
||||
|
||||
var PMSCalendarRenderer = require('hotel_calendar.PMSCalendarRenderer');
|
||||
|
||||
var PMSHotelCalendarRendererChannelConnector = PMSCalendarRenderer.include({
|
||||
|
||||
update_buttons_counter_channel_connector: function (nreservations, nissues) {
|
||||
// Cloud Reservations
|
||||
var $button = this.$el.find('#btn_channel_manager_request');
|
||||
var $text = this.$el.find('#btn_channel_manager_request .cloud-text');
|
||||
if (nreservations > 0) {
|
||||
$button.addClass('incoming');
|
||||
$text.text(nreservations);
|
||||
$text.show();
|
||||
} else {
|
||||
$button.removeClass('incoming');
|
||||
$text.hide();
|
||||
}
|
||||
|
||||
// Issues
|
||||
var $ninfo = this.$el.find('#pms-menu #btn_action_issues div.ninfo');
|
||||
var $badge_issues = $ninfo.find('.badge');
|
||||
if (nissues > 0) {
|
||||
$badge_issues.text(nissues);
|
||||
$badge_issues.parent().show();
|
||||
$ninfo.show();
|
||||
} else {
|
||||
$ninfo.hide();
|
||||
}
|
||||
},
|
||||
|
||||
init_calendar_view: function () {
|
||||
var self = this;
|
||||
return this._super().then(function () {
|
||||
self.$el.find('#btn_channel_manager_request').on('click', function (ev) {
|
||||
self.do_action("hotel_calendar_wubook.hotel_reservation_action_manager_request");
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
_generate_reservation_tooltip_dict: function(tp) {
|
||||
var qdict = this._super(tp);
|
||||
qdict['channel_name'] = tp[5];
|
||||
return qdict;
|
||||
},
|
||||
|
||||
_generate_bookings_domain: function(tsearch) {
|
||||
var domain = this._super(tsearch);
|
||||
domain.splice(0, 0, '|');
|
||||
domain.push(['wrid', 'ilike', tsearch]);
|
||||
return domain;
|
||||
}
|
||||
});
|
||||
|
||||
return PMSHotelCalendarRendererChannelConnector;
|
||||
});
|
||||
@@ -0,0 +1,14 @@
|
||||
<template>
|
||||
|
||||
<t t-name="HotelCalendarChannelConnector.NotificationIssue">
|
||||
<b>Section:</b> <t t-esc="section"/><br/>
|
||||
<t t-esc="message"/>
|
||||
</t>
|
||||
|
||||
<t t-extend="HotelCalendar.TooltipReservation">
|
||||
<t t-jquery="ul.oe_tooltip_technical li:last-child" t-operation="after">
|
||||
<li t-if="channel_name"><b>Channel:</b> <t t-esc="channel_name"/></li>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</template>
|
||||
@@ -0,0 +1,29 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<templates xml:space="preserve">
|
||||
|
||||
<t t-extend="hotel_calendar.HotelCalendarView">
|
||||
<t t-jquery="button#btn_action_checkout" t-operation="before">
|
||||
<button class="btn col-xs-12 col-lg-12" id="btn_channel_manager_request">
|
||||
<div class="fa-stack fa-2x">
|
||||
<i class="fa fa-cloud fa-stack-2x"> </i>
|
||||
<span class="fa-stack-1x cloud-text">0</span>
|
||||
</div>
|
||||
</button>
|
||||
</t>
|
||||
<t t-jquery="input#bookings_search" t-operation="after">
|
||||
<button class="btn btn-default col-xs-12 col-lg-12" id="btn_action_issues" data-action="hotel_calendar_channel_connector.calendar_channel_connector_issues_action">
|
||||
<div class="ninfo"><span class="badge badge-danger">0</span></div>
|
||||
ISSUES
|
||||
</button>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
<t t-extend="HotelCalendar.Notification">
|
||||
<t t-jquery="ul > li:first-child" t-operation="before">
|
||||
<t t-if="wchannel">
|
||||
<li><b>Channel:</b> <t t-esc="wchannel"/></li>
|
||||
</t>
|
||||
</t>
|
||||
</t>
|
||||
|
||||
</templates>
|
||||
23
hotel_calendar_channel_connector/tests/__init__.py
Normal file
23
hotel_calendar_channel_connector/tests/__init__.py
Normal file
@@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import test_folio
|
||||
31
hotel_calendar_channel_connector/tests/test_folio.py
Normal file
31
hotel_calendar_channel_connector/tests/test_folio.py
Normal file
@@ -0,0 +1,31 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from datetime import timedelta
|
||||
from odoo.addons.hotel_calendar.tests.common import TestHotelCalendar
|
||||
from odoo.addons.hotel import date_utils
|
||||
|
||||
|
||||
class TestHotelReservations(TestHotelCalendar):
|
||||
|
||||
def test_cancel_folio(self):
|
||||
now_utc_dt = date_utils.now()
|
||||
23
hotel_calendar_channel_connector/views/actions.xml
Normal file
23
hotel_calendar_channel_connector/views/actions.xml
Normal file
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<record id="hotel_reservation_action_manager_request" model="ir.actions.act_window">
|
||||
<field name="name">Reservations to Assign from WuBook</field>
|
||||
<field name="res_model">hotel.reservation</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="view_id" ref="view_hotel_toassign_reservation_tree" />
|
||||
<field name="domain">[('to_assign','=',True),('to_read','=',True)]</field>
|
||||
</record>
|
||||
|
||||
|
||||
|
||||
<record id="calendar_channel_connector_issues_action" model="ir.actions.act_window">
|
||||
<field name="name">Channel Connector Issues</field>
|
||||
<field name="res_model">hotel.channel.connector.issue</field>
|
||||
<field name="view_mode">tree,form</field>
|
||||
<field name="domain">[('to_read','=',True)]</field>
|
||||
</record>
|
||||
|
||||
</data>
|
||||
</openerp>
|
||||
12
hotel_calendar_channel_connector/views/general.xml
Normal file
12
hotel_calendar_channel_connector/views/general.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<odoo>
|
||||
|
||||
<!-- Backend stuff -->
|
||||
<template id="assets_backend" inherit_id="web.assets_backend">
|
||||
<xpath expr="." position="inside">
|
||||
<link rel="stylesheet" href="/hotel_calendar_wubook/static/src/css/view.css" />
|
||||
<script type="text/javascript" src="/hotel_calendar_wubook/static/src/js/hotel_calendar_view.js"></script>
|
||||
</xpath>
|
||||
</template>
|
||||
|
||||
</odoo>
|
||||
85
hotel_calendar_channel_connector/views/hotel_reservation.xml
Normal file
85
hotel_calendar_channel_connector/views/hotel_reservation.xml
Normal file
@@ -0,0 +1,85 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<openerp>
|
||||
<data>
|
||||
|
||||
<!-- Tree view of hotel reservation -->
|
||||
<record model="ir.ui.view" id="view_hotel_toassign_reservation_tree">
|
||||
<field name="name">hotel.toassign.reservation.tree</field>
|
||||
<field name="model">hotel.reservation</field>
|
||||
<field name="arch" type="xml">
|
||||
<tree string="Hotel Reservation"
|
||||
decoration-muted="state == 'cancelled' and not overbooking"
|
||||
decoration-warning="overbooking"
|
||||
>
|
||||
<button icon="fa fa-2x fa-thumb-tack"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
id="mark_readed"
|
||||
name="mark_as_readed"
|
||||
attrs="{'invisible':[('to_read','=', False)]}"
|
||||
help="Mark as Read"
|
||||
/>
|
||||
<button icon="fa fa-1x fa-chain-broken"
|
||||
type="object"
|
||||
class="oe_stat_button"
|
||||
id="splitted"
|
||||
name="open_master"
|
||||
attrs="{'invisible':[('splitted','=', False)]}"
|
||||
/>
|
||||
<field name="state" />
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="go_folio" icon="fa fa-2x fa-file"
|
||||
name="open_folio"
|
||||
/>
|
||||
<field name="folio_id"/>
|
||||
<field name="product_id" string="Room"/>
|
||||
<button type="action" class="oe_stat_button"
|
||||
id="reservations_partner" icon="fa fa-2x fa-list-ul"
|
||||
name="%(hotel.open_hotel_reservation_form_tree_all)d"
|
||||
context="{'search_default_partner_id': partner_id}"
|
||||
/>
|
||||
<field name="partner_id"/>
|
||||
<field name="splitted" invisible="1" />
|
||||
<field name="parent_reservation" invisible="1" />
|
||||
<field name="virtual_room_id" string="Reserved Room Type"/>
|
||||
<field name="nights" />
|
||||
<field name="to_read" invisible="1"/>
|
||||
<field name="adults" string="Persons"/>
|
||||
<field name="checkin" widget="date"/>
|
||||
<field name="checkout" widget="date"/>
|
||||
<field name="create_date"/>
|
||||
<field name="overbooking" invisible="1" />
|
||||
<field name="last_updated_res" string="Updated on"/>
|
||||
<field name="origin_sale"/>
|
||||
<field name="overbooking" invisible="1" />
|
||||
<field name="to_assign" invisible="1"/>
|
||||
<!-- cardex_smart_button attrs depends on cardex_pending to be showed -->
|
||||
<field name="cardex_pending" invisible="1"/>
|
||||
<field name="price_unit" string="Reservation Price"/>
|
||||
<field name="discount" groups="sale.group_discount_per_so_line"/>
|
||||
<field name="price_total" string="Final Price"/>
|
||||
<field name="folio_pending_amount" string="Folio Pending Amount"/>
|
||||
<button type="object" class="oe_stat_button"
|
||||
id="cardex_smart_button" icon="fa fa-3x fa-money"
|
||||
name="action_pay_folio"
|
||||
attrs="{'invisible':[('folio_pending_amount','==',0)]}"
|
||||
/>
|
||||
</tree>
|
||||
</field>
|
||||
</record>
|
||||
|
||||
<record id="hotel_reservation_view_form" model="ir.ui.view">
|
||||
<field name="model">hotel.reservation</field>
|
||||
<field name="inherit_id" ref="hotel.view_hotel_reservation_form" />
|
||||
<field name="arch" type="xml">
|
||||
<xpath expr="//button[@name='unify']" position="after">
|
||||
<button name="mark_as_readed" string="Mark as Read"
|
||||
type="object" class="oe_highlight"
|
||||
icon="fa-1x fa-thumb-tack"
|
||||
attrs="{'invisible':[('to_read','=', False)]}"
|
||||
/>
|
||||
</xpath>
|
||||
</field>
|
||||
</record>
|
||||
</data>
|
||||
</openerp>
|
||||
18
hotel_channel_connector/README.rst
Normal file
18
hotel_channel_connector/README.rst
Normal file
@@ -0,0 +1,18 @@
|
||||
HOTEL WUBOOK PROTOTYPE (NOT USING ODOO CONNECTOR)
|
||||
=============
|
||||
- Experimental Connector for WuBook
|
||||
- Active push notifications
|
||||
- Create reservations
|
||||
- Update availability
|
||||
- Handle rooms
|
||||
|
||||
** UNDER DEVELOPMENT: NOT USE IN PRODUCTION **
|
||||
|
||||
|
||||
Credits
|
||||
=======
|
||||
|
||||
Creator
|
||||
------------
|
||||
|
||||
* Alexandre Díaz <alex@aloxa.eu>
|
||||
25
hotel_channel_connector/__init__.py
Normal file
25
hotel_channel_connector/__init__.py
Normal file
@@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import controllers
|
||||
from . import models
|
||||
from . import wubook
|
||||
from . import wizard
|
||||
68
hotel_channel_connector/__manifest__.py
Normal file
68
hotel_channel_connector/__manifest__.py
Normal file
@@ -0,0 +1,68 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
|
||||
{
|
||||
'name': 'Hotel WuBook Prototype',
|
||||
'version': '1.0',
|
||||
'author': "Alexandre Díaz (Aloxa Solucións S.L.) <alex@aloxa.eu>",
|
||||
'website': 'https://www.eiqui.com',
|
||||
'category': 'eiqui/hotel',
|
||||
'summary': "Hotel WuBook",
|
||||
'description': "Hotel WuBook Prototype",
|
||||
'depends': [
|
||||
'hotel',
|
||||
],
|
||||
'external_dependencies': {
|
||||
'python': ['xmlrpc']
|
||||
},
|
||||
'data': [
|
||||
'data/cron_jobs.xml',
|
||||
'wizard/wubook_installer.xml',
|
||||
'wizard/wubook_import_plan_prices.xml',
|
||||
'wizard/wubook_import_plan_restrictions.xml',
|
||||
'wizard/wubook_import_availability.xml',
|
||||
'views/general.xml',
|
||||
'views/res_config_views.xml',
|
||||
'views/inherited_hotel_reservation_views.xml',
|
||||
'views/inherited_hotel_virtual_room_views.xml',
|
||||
'views/inherited_hotel_virtual_room_availability_views.xml',
|
||||
'views/inherited_hotel_folio_views.xml',
|
||||
'views/inherited_product_pricelist_views.xml',
|
||||
'views/inherited_product_pricelist_item_views.xml',
|
||||
'views/inherited_reservation_restriction_views.xml',
|
||||
'views/inherited_reservation_restriction_item_views.xml',
|
||||
'views/inherited_res_partner_views.xml',
|
||||
'views/wubook_channel_info_views.xml',
|
||||
'views/wubook_issue_views.xml',
|
||||
'data/menus.xml',
|
||||
'data/sequences.xml',
|
||||
'security/ir.model.access.csv',
|
||||
'security/wubook_security.xml',
|
||||
# 'views/res_config.xml'
|
||||
],
|
||||
'test': [
|
||||
],
|
||||
'installable': True,
|
||||
'auto_install': False,
|
||||
'application': False,
|
||||
'license': 'AGPL-3',
|
||||
}
|
||||
22
hotel_channel_connector/controllers/__init__.py
Normal file
22
hotel_channel_connector/controllers/__init__.py
Normal file
@@ -0,0 +1,22 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
from . import main
|
||||
121
hotel_channel_connector/controllers/main.py
Normal file
121
hotel_channel_connector/controllers/main.py
Normal file
@@ -0,0 +1,121 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
##############################################################################
|
||||
#
|
||||
# OpenERP, Open Source Management Solution
|
||||
# Copyright (C) 2017 Solucións Aloxa S.L. <info@aloxa.eu>
|
||||
# Alexandre Díaz <dev@redneboa.es>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
##############################################################################
|
||||
import logging
|
||||
from openerp import http, _
|
||||
from openerp.http import request
|
||||
from openerp.exceptions import ValidationError
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
class website_wubook(http.Controller):
|
||||
# Called when created a reservation in wubook
|
||||
@http.route(['/wubook/push/reservations/<string:security_token>'],
|
||||
type='http', cors="*", auth="public", methods=['POST'],
|
||||
website=True, csrf=False)
|
||||
def wubook_push_reservations(self, security_token, **kwargs):
|
||||
# Check Security Token
|
||||
hotel_security_token = request.env['ir.default'].sudo().get(
|
||||
'wubook.config.settings', 'wubook_push_security_token')
|
||||
if security_token != hotel_security_token:
|
||||
# _logger.info("Invalid Tokens: '%s' != '%s'" %
|
||||
# (security_token, hotel_security_token))
|
||||
raise ValidationError(_('Invalid Security Token!'))
|
||||
|
||||
rcode = kwargs.get('rcode')
|
||||
lcode = kwargs.get('lcode')
|
||||
|
||||
# Correct Input?
|
||||
if not lcode or not rcode:
|
||||
raise ValidationError(_('Invalid Input Parameters!'))
|
||||
|
||||
# WuBook Check
|
||||
if rcode == '2000' and lcode == '1000':
|
||||
return request.make_response(
|
||||
'200 OK', [('Content-Type', 'text/plain')])
|
||||
|
||||
# Poor Security Check
|
||||
wlcode = request.env['ir.default'].sudo().get(
|
||||
'wubook.config.settings', 'wubook_lcode')
|
||||
if lcode != wlcode:
|
||||
raise ValidationError(_("Error! lcode doesn't match!"))
|
||||
|
||||
_logger.info(_("[WUBOOK->ODOO] Importing Booking..."))
|
||||
# Create Reservation
|
||||
request.env['wubook'].sudo().fetch_booking(lcode, rcode)
|
||||
|
||||
return request.make_response('200 OK',
|
||||
[('Content-Type', 'text/plain')])
|
||||
|
||||
# Called when modify room values (Delay: ~5mins)
|
||||
@http.route(['/wubook/push/rooms/<string:security_token>'], type='http',
|
||||
cors="*", auth="public", methods=['POST'], website=True,
|
||||
csrf=False)
|
||||
def wubook_push_rooms(self, security_token, **kwargs):
|
||||
# Check Security Token
|
||||
hotel_security_token = request.env['ir.default'].sudo().get(
|
||||
'wubook.config.settings', 'wubook_push_security_token')
|
||||
if security_token != hotel_security_token:
|
||||
# _logger.info("Invalid Tokens: '%s' != '%s'" %
|
||||
# (security_token, hotel_security_token))
|
||||
raise ValidationError(_('Invalid Security Token!'))
|
||||
|
||||
lcode = kwargs.get('lcode')
|
||||
dfrom = kwargs.get('dfrom')
|
||||
dto = kwargs.get('dto')
|
||||
|
||||
# Correct Input?
|
||||
if not lcode or not dfrom or not dto:
|
||||
raise ValidationError(_('Invalid Input Parameters!'))
|
||||
|
||||
# Poor Security Check
|
||||
wlcode = request.env['ir.default'].sudo().get(
|
||||
'wubook.config.settings', 'wubook_lcode')
|
||||
if lcode != wlcode:
|
||||
raise ValidationError(_("Error! lcode doesn't match!"))
|
||||
|
||||
_logger.info(_("[WUBOOK->ODOO] Updating values..."))
|
||||
wubook_obj = request.env['wubook'].sudo().with_context({
|
||||
'init_connection': False
|
||||
})
|
||||
if wubook_obj.init_connection():
|
||||
wubook_obj.fetch_rooms_values(dfrom, dto)
|
||||
|
||||
parity_restr_id = request.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_restrictions_id')
|
||||
if parity_restr_id:
|
||||
vroom_restr_obj = request.env['hotel.virtual.room.restriction']
|
||||
restr_id = vroom_restr_obj.sudo().browse(int(parity_restr_id))
|
||||
if restr_id and restr_id.wpid and restr_id.wpid != '0':
|
||||
wubook_obj.fetch_rplan_restrictions(dfrom, dto,
|
||||
rpid=restr_id.wpid)
|
||||
|
||||
parity_pricelist_id = request.env['ir.default'].sudo().get(
|
||||
'hotel.config.settings', 'parity_pricelist_id')
|
||||
if parity_pricelist_id:
|
||||
pricelist_id = request.env['product.pricelist'].sudo().browse(
|
||||
int(parity_pricelist_id))
|
||||
if pricelist_id and pricelist_id.wpid:
|
||||
wubook_obj.fetch_plan_prices(pricelist_id.wpid, dfrom, dto)
|
||||
wubook_obj.close_connection()
|
||||
|
||||
return request.make_response('200 OK',
|
||||
[('Content-Type', 'text/plain')])
|
||||
26
hotel_channel_connector/data/cron_jobs.xml
Normal file
26
hotel_channel_connector/data/cron_jobs.xml
Normal file
@@ -0,0 +1,26 @@
|
||||
<odoo noupdate="1">
|
||||
<record model="ir.cron" id="wubook_push_avail">
|
||||
<field name="name">WuBook Push Availability</field>
|
||||
<field name="interval_number">5</field>
|
||||
<field name="interval_type">minutes</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doall" eval="False" />
|
||||
<field name="model_id" ref="model_wubook" />
|
||||
<field name="code">model.push_changes()</field>
|
||||
</record>
|
||||
|
||||
<!-- <record id="wubook_corporate_fetch" model="ir.cron">
|
||||
<field name="name">WuBook Corporate Fetchable Properties</field>
|
||||
<field name="active" eval="True" />
|
||||
<field name="user_id" ref="base.user_root" />
|
||||
<field name="interval_number">4</field>
|
||||
<field name="interval_type">hours</field>
|
||||
<field name="numbercall">-1</field>
|
||||
<field name="doal">1</field>
|
||||
<field name="nextcall" >2016-12-31 23:59:59</field>
|
||||
<field name="model" eval="'wubook'" />
|
||||
<field name="function" eval="'corporate_fetch'" />
|
||||
<field name="args" eval="" />
|
||||
<field name="priority" eval="5" />
|
||||
</record> -->
|
||||
</odoo>
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user