[RFC] Clean reposiroty

This commit is contained in:
Darío Lodeiros
2020-08-01 22:34:47 +02:00
parent b5c170eddc
commit aac22ef43f
412 changed files with 7 additions and 39258 deletions

View File

@@ -1,6 +0,0 @@
CALL CENTER REPORT
=============
Export call center report in xls format

View File

@@ -1,21 +0,0 @@
# -*- 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 . import wizard

View File

@@ -1,48 +0,0 @@
# -*- 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/>.
#
##############################################################################
{
'name': 'Call Center Report',
'version': '1.0',
'author': "Dario Lodeiros",
'website': 'https://www.eiqui.com',
'category': 'reports',
'summary': "Export services and reservation report in xls format",
'description': "Call Center Report",
'depends': [
'hotel',
],
'external_dependencies': {
'python': ['xlsxwriter']
},
'data': [
'wizard/call_center_report.xml',
'data/menus.xml',
],
'qweb': [],
'test': [
],
'installable': True,
'auto_install': False,
'application': False,
'license': 'AGPL-3',
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem id="call_center_report_wizard" name="Call Center Report"
parent="hotel.hotel_management_menu"
groups="hotel.group_hotel_call,hotel.group_hotel_manager"
action="action_open_call_center_report_wizard" sequence="1000" />
</data>
</odoo>

View File

@@ -1,171 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * cash_daily_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 10.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2018-05-20 07:33+0000\n"
"PO-Revision-Date: 2018-05-20 09:34+0200\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: \n"
"Language: es\n"
"X-Generator: Poedit 1.8.7.1\n"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:85
#, python-format
msgid "Amount"
msgstr "Importe"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:78
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
#, python-format
msgid "Cash Daily Report"
msgstr "Informe de caja"
#. module: cash_daily_report
#: model:ir.actions.act_window,name:cash_daily_report.action_open_cash_daily_report_wizard
#: model:ir.ui.menu,name:cash_daily_report.cash_daily_report_wizard
msgid "Cash Daily Report Wizard"
msgstr "Informe de caja diaria"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:82
#, python-format
msgid "Client"
msgstr "Cliente"
#. module: cash_daily_report
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
msgid "Close"
msgstr "Cerrar"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_create_uid
msgid "Created by"
msgstr "Creado por"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_create_date
msgid "Created on"
msgstr "Creado en"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:83
#, python-format
msgid "Date"
msgstr "Fecha"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_display_name
msgid "Display Name"
msgstr "Mostrar Nombre"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_date_end
msgid "End Date"
msgstr "Fecha finalización"
#. module: cash_daily_report
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
msgid "Generate XLS"
msgstr "Generar XLS"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_id
msgid "ID"
msgstr "ID"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:84
#, python-format
msgid "Journal"
msgstr "Diario"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard___last_update
msgid "Last Modified on"
msgstr "Última modificación en"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_write_uid
msgid "Last Updated by"
msgstr "Última actualización por"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_write_date
msgid "Last Updated on"
msgstr "Última actualización en"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:80
#, python-format
msgid "Name"
msgstr "Nombre"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:128
#, python-format
msgid "Not Any Payments"
msgstr "No hay movimientos"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:81
#, python-format
msgid "Reference"
msgstr "Referencia"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_date_start
msgid "Start Date"
msgstr "Fecha de inicio"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:143
#, python-format
msgid "TOTAL"
msgstr "TOTAL"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:139
#, python-format
msgid "TOTAL PAYMENT RETURNS"
msgstr "TOTAL DEVOLUCIONES"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:134
#, python-format
msgid "TOTAL PAYMENTS"
msgstr "TOTAL PAGOS"
#. module: cash_daily_report
#: model:ir.ui.menu,name:cash_daily_report.menu_account_finance_xls_reports
msgid "XLS Reports"
msgstr "XLS Reports"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_xls_binary
msgid "Xls binary"
msgstr "Xls archivo"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_xls_filename
msgid "Xls filename"
msgstr "Xls nombre de archivo"
#. module: cash_daily_report
#: model:ir.model,name:cash_daily_report.model_cash_daily_report_wizard
msgid "cash.daily.report.wizard"
msgstr "cash.daily.report.wizard"
#. module: cash_daily_report
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
msgid "or"
msgstr "o"

View File

@@ -1,21 +0,0 @@
# -*- 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 . import call_center_report

View File

@@ -1,348 +0,0 @@
# -*- 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 io import BytesIO
from datetime import datetime, date
import xlsxwriter
import base64
from odoo import api, fields, models, _
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT, DEFAULT_SERVER_DATETIME_FORMAT
class CallCenterReportWizard(models.TransientModel):
_name = 'call.center.report.wizard'
@api.model
def _get_default_date_start(self):
return datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT)
@api.model
def _get_default_date_end(self):
return datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT)
date_start = fields.Date("Start Date", default=_get_default_date_start)
date_end = fields.Date("End Date", default=_get_default_date_end)
xls_filename = fields.Char()
xls_binary = fields.Binary()
@api.model
def _export(self):
date_format = "%d-%m-%Y"
time_format = "%H:%M"
file_data = BytesIO()
workbook = xlsxwriter.Workbook(file_data, {
'strings_to_numbers': True,
'default_date_format': 'dd/mm/yyyy'
})
company_id = self.env.user.company_id
workbook.set_properties({
'title': 'Exported data from ' + company_id.name,
'subject': 'Payments Data from Odoo of ' + company_id.name,
'author': 'Odoo',
'manager': u'Call Center',
'company': company_id.name,
'category': 'Hoja de Calculo',
'keywords': 'payments, odoo, data, ' + company_id.name,
'comments': 'Created with Python in Odoo and XlsxWriter'})
workbook.use_zip64()
xls_cell_format_date = workbook.add_format({
'num_format': 'dd/mm/yyyy'
})
xls_cell_format_money = workbook.add_format({
'num_format': '#,##0.00'
})
xls_cell_format_header = workbook.add_format({
'bg_color': '#CCCCCC'
})
worksheet = workbook.add_worksheet(_('Call Center Report - Production'))
worksheet.write('A1', _('Ficha'), xls_cell_format_header)
worksheet.write('B1', _('Fecha de Pedido'), xls_cell_format_header)
worksheet.write('C1', _('Cliente'), xls_cell_format_header)
worksheet.write('D1', _('Producto'), xls_cell_format_header)
worksheet.write('E1', _('Noches/Uds'), xls_cell_format_header)
worksheet.write('F1', _('Adultos'), xls_cell_format_header)
worksheet.write('G1', _('Checkin'), xls_cell_format_header)
worksheet.write('H1', _('In-Hora'), xls_cell_format_header)
worksheet.write('I1', _('Checkout'), xls_cell_format_header)
worksheet.write('J1', _('Creado por'), xls_cell_format_header)
worksheet.write('K1', _('Total'), xls_cell_format_header)
worksheet.set_column('B:B', 20)
worksheet.set_column('C:C', 20)
worksheet.set_column('D:D', 20)
worksheet.set_column('E:E', 20)
worksheet.set_column('F:F', 13)
reservations_obj = self.env['hotel.reservation']
reservations = reservations_obj.search([
('checkin', '>=', self.date_start),
('checkout', '<=', self.date_end),
('state', '=', 'done'),
('channel_type', '=', 'call'),
('folio_id.pending_amount', '<', 1),
])
offset = 1
total_reservation_amount = 0.0
for k_res, v_res in enumerate(reservations):
checkin_date = datetime.strptime(v_res.checkin, DEFAULT_SERVER_DATE_FORMAT)
checkout_date = datetime.strptime(v_res.checkout, DEFAULT_SERVER_DATE_FORMAT)
worksheet.write(k_res+offset, 0, v_res.folio_id.name)
worksheet.write(k_res+offset, 1, v_res.folio_id.date_order,
xls_cell_format_date)
worksheet.write(k_res+offset, 2, v_res.partner_id.name)
worksheet.write(k_res+offset, 3, v_res.room_type_id.name)
worksheet.write(k_res+offset, 4, v_res.nights)
worksheet.write(k_res+offset, 5, v_res.adults)
worksheet.write(k_res+offset, 6, checkin_date.strftime(date_format),
xls_cell_format_date)
worksheet.write(k_res+offset, 7, v_res.arrival_hour)
worksheet.write(k_res+offset, 8, checkout_date.strftime(date_format),
xls_cell_format_date)
worksheet.write(k_res+offset, 9, v_res.create_uid.name)
worksheet.write(k_res+offset, 10, v_res.price_total,
xls_cell_format_money)
total_reservation_amount += v_res.price_total
folio_ids = reservations.mapped('folio_id.id')
folios = self.env['hotel.folio'].browse(folio_ids)
services = self.env['hotel.service'].browse()
for folio in folios:
services += folio.service_ids.filtered(lambda r:
r.channel_type == 'call' and r.folio_id.pending_amount < 1)
offset += len(reservations)
total_service_amount = k_line = 0.0
for k_service, v_service in enumerate(services):
worksheet.write(k_service+offset, 0, v_service.folio_id.name)
worksheet.write(k_service+offset, 1, v_service.folio_id.date_order,
xls_cell_format_date)
worksheet.write(k_service+offset, 2, v_service.folio_id.partner_id.name)
worksheet.write(k_service+offset, 3, v_service.product_id.name)
worksheet.write(k_service+offset, 4, v_service.product_qty)
worksheet.write(k_service+offset, 5, '')
worksheet.write(k_service+offset, 6, '')
worksheet.write(k_service+offset, 7, '')
worksheet.write(k_service+offset, 8, '')
worksheet.write(k_service+offset, 9, v_service .create_uid.name)
worksheet.write(k_service+offset, 10, v_service.price_total,
xls_cell_format_money)
total_service_amount += v_service.price_total
offset += len(services)
#~ if total_reservation_amount == 0 and total_service_amount == 0:
#~ raise UserError(_('No Hay reservas de Call Center'))
line = offset
if k_line:
line = k_line + offset
if total_reservation_amount > 0:
line += 1
worksheet.write(line, 9, _('TOTAL RESERVAS'))
worksheet.write(line, 10, total_reservation_amount,
xls_cell_format_money)
if total_service_amount > 0:
line += 1
worksheet.write(line, 9, _('TOTAL SERVICIOS'))
worksheet.write(line, 10, total_service_amount,
xls_cell_format_money)
line += 1
worksheet.write(line, 9, _('TOTAL'))
worksheet.write(line, 10 , total_reservation_amount + total_service_amount,
xls_cell_format_money)
worksheet = workbook.add_worksheet(_('Call Center Report - Sales'))
worksheet.write('A1', _('Estado'), xls_cell_format_header)
worksheet.write('B1', _('Ficha'), xls_cell_format_header)
worksheet.write('C1', _('Fecha de Pedido'), xls_cell_format_header)
worksheet.write('D1', _('Cliente'), xls_cell_format_header)
worksheet.write('E1', _('Producto'), xls_cell_format_header)
worksheet.write('F1', _('Noches/Uds'), xls_cell_format_header)
worksheet.write('G1', _('Adultos'), xls_cell_format_header)
worksheet.write('H1', _('Checkin'), xls_cell_format_header)
worksheet.write('I1', _('In-Hora'), xls_cell_format_header)
worksheet.write('J1', _('Checkout'), xls_cell_format_header)
worksheet.write('K1', _('Creado por'), xls_cell_format_header)
worksheet.write('L1', _('Total'), xls_cell_format_header)
worksheet.set_column('B:B', 20)
worksheet.set_column('C:C', 20)
worksheet.set_column('D:D', 20)
worksheet.set_column('E:E', 20)
worksheet.set_column('F:F', 13)
reservations_obj = self.env['hotel.reservation']
reservations = reservations_obj.search([
('folio_id.date_order', '>=', self.date_start),
('folio_id.date_order', '<=', self.date_end),
('channel_type','=','call'),
])
offset = 1
total_reservation_amount = 0.0
for k_res, v_res in enumerate(reservations):
checkin_date = datetime.strptime(v_res.checkin, DEFAULT_SERVER_DATE_FORMAT)
checkout_date = datetime.strptime(v_res.checkout, DEFAULT_SERVER_DATE_FORMAT)
worksheet.write(k_res+offset, 0, v_res.state)
worksheet.write(k_res+offset, 1, v_res.folio_id.name)
worksheet.write(k_res+offset, 2, v_res.folio_id.date_order,
xls_cell_format_date)
worksheet.write(k_res+offset, 3, v_res.partner_id.name)
worksheet.write(k_res+offset, 4, v_res.room_type_id.name)
worksheet.write(k_res+offset, 5, v_res.nights)
worksheet.write(k_res+offset, 6, v_res.adults)
worksheet.write(k_res+offset, 7, checkin_date.strftime(date_format),
xls_cell_format_date)
worksheet.write(k_res+offset, 8, v_res.arrival_hour)
worksheet.write(k_res+offset, 9, checkout_date.strftime(date_format),
xls_cell_format_date)
worksheet.write(k_res+offset, 10, v_res.create_uid.name)
worksheet.write(k_res+offset, 11, v_res.price_total,
xls_cell_format_money)
total_reservation_amount += v_res.price_total
folio_ids = reservations.mapped('folio_id.id')
folios = self.env['hotel.folio'].browse(folio_ids)
services = self.env['hotel.service'].browse()
for folio in folios:
services += folio.service_ids.filtered(lambda r:
r.channel_type == 'call' and r.folio_id.pending_amount < 1)
offset += len(reservations)
total_service_amount = k_line = 0.0
for k_service, v_service in enumerate(services):
worksheet.write(k_service+offset, 1, v_service.folio_id.state)
worksheet.write(k_service+offset, 1, v_service.folio_id.name)
worksheet.write(k_service+offset, 2, v_service.folio_id.date_order,
xls_cell_format_date)
worksheet.write(k_service+offset, 3, v_service.folio_id.partner_id.name)
worksheet.write(k_service+offset, 4, v_service.product_id.name)
worksheet.write(k_service+offset, 5, v_service.product_qty)
worksheet.write(k_service+offset, 6, '')
worksheet.write(k_service+offset, 7, '')
worksheet.write(k_service+offset, 8, '')
worksheet.write(k_service+offset, 9, '')
worksheet.write(k_service+offset, 10, v_service .create_uid.name)
worksheet.write(k_service+offset, 11, v_service.price_total,
xls_cell_format_money)
total_service_amount += v_service.price_total
offset += len(services)
#~ if total_reservation_amount == 0 and total_service_amount == 0:
#~ raise UserError(_('No Hay reservas de Call Center'))
line = offset
if k_line:
line = k_line + offset
if total_reservation_amount > 0:
line += 1
worksheet.write(line, 10, _('TOTAL RESERVAS'))
worksheet.write(line, 11, total_reservation_amount,
xls_cell_format_money)
if total_service_amount > 0:
line += 1
worksheet.write(line, 10, _('TOTAL SERVICIOS'))
worksheet.write(line, 11, total_service_amount,
xls_cell_format_money)
line += 1
worksheet.write(line, 10, _('TOTAL'))
worksheet.write(line, 11 , total_reservation_amount + total_service_amount,
xls_cell_format_money)
worksheet = workbook.add_worksheet(_('Call Center Report - Cancelations'))
worksheet.write('A1', _('Estado'), xls_cell_format_header)
worksheet.write('B1', _('Ficha'), xls_cell_format_header)
worksheet.write('C1', _('Fecha de Pedido'), xls_cell_format_header)
worksheet.write('D1', _('Cliente'), xls_cell_format_header)
worksheet.write('E1', _('Producto'), xls_cell_format_header)
worksheet.write('F1', _('Noches/Uds'), xls_cell_format_header)
worksheet.write('G1', _('Adultos'), xls_cell_format_header)
worksheet.write('H1', _('Checkin'), xls_cell_format_header)
worksheet.write('I1', _('In-Hora'), xls_cell_format_header)
worksheet.write('J1', _('Checkout'), xls_cell_format_header)
worksheet.write('K1', _('Creado por'), xls_cell_format_header)
worksheet.write('K1', _('Cancelado en'), xls_cell_format_header)
worksheet.write('L1', _('Precio Final'), xls_cell_format_header)
worksheet.write('M1', _('Precio Original'), xls_cell_format_header)
worksheet.set_column('B:B', 20)
worksheet.set_column('C:C', 20)
worksheet.set_column('D:D', 20)
worksheet.set_column('E:E', 20)
worksheet.set_column('F:F', 13)
reservations_obj = self.env['hotel.reservation']
reservations = reservations_obj.search([
('last_updated_res', '>=', self.date_start),
('last_updated_res', '<=', self.date_end),
('channel_type','=','call'),
('state','=','cancelled'),
])
offset = 1
total_reservation_amount = 0.0
for k_res, v_res in enumerate(reservations):
checkin_date = datetime.strptime(v_res.checkin, DEFAULT_SERVER_DATE_FORMAT)
checkout_date = datetime.strptime(v_res.checkout, DEFAULT_SERVER_DATE_FORMAT)
worksheet.write(k_res+offset, 0, v_res.state)
worksheet.write(k_res+offset, 1, v_res.folio_id.name)
worksheet.write(k_res+offset, 2, v_res.folio_id.date_order,
xls_cell_format_date)
worksheet.write(k_res+offset, 3, v_res.partner_id.name)
worksheet.write(k_res+offset, 4, v_res.room_type_id.name)
worksheet.write(k_res+offset, 5, v_res.nights)
worksheet.write(k_res+offset, 6, v_res.adults)
worksheet.write(k_res+offset, 7, checkin_date.strftime(date_format),
xls_cell_format_date)
worksheet.write(k_res+offset, 8, v_res.arrival_hour)
worksheet.write(k_res+offset, 9, checkout_date.strftime(date_format),
xls_cell_format_date)
worksheet.write(k_res+offset, 10, v_res.create_uid.name)
worksheet.write(k_res+offset, 9, v_res.last_updated_res,
xls_cell_format_date)
worksheet.write(k_res+offset, 11, v_res.price_total,
xls_cell_format_money)
worksheet.write(k_res+offset, 12, v_res.price_total - v_res.discount,
xls_cell_format_money)
total_reservation_amount += v_res.price_total
offset += len(reservations)
#~ if total_reservation_amount == 0 and total_service_amount == 0:
#~ raise UserError(_('No Hay reservas de Call Center'))
line = offset
if k_line:
line = k_line + offset
if total_reservation_amount > 0:
line += 1
worksheet.write(line, 11, _('TOTAL RESERVAS'))
worksheet.write(line, 12, total_reservation_amount,
xls_cell_format_money)
workbook.close()
file_data.seek(0)
tnow = fields.Datetime.now().replace(' ', '_')
return {
'xls_filename': 'call_%s.xlsx' %self.env.user.company_id.property_name,
'xls_binary': base64.encodestring(file_data.read()),
}
def export(self):
self.write(self._export())
return {
"type": "ir.actions.do_nothing",
}

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" ?>
<odoo>
<record model="ir.ui.view" id="view_call_center_report_wizard">
<field name="name">call.center.report.wizard</field>
<field name="model">call.center.report.wizard</field>
<field name="arch" type="xml">
<form string="Call Center Report" >
<group>
<group>
<field name="date_start" required="1" />
</group>
<group>
<field name="date_end" required="1" />
</group>
</group>
<group>
<group>
<field name="xls_filename" invisible="1"/>
<field name="xls_binary" filename="xls_filename" readonly="1" />
</group>
</group>
<footer>
<button name="export" string="Generate XLS" type="object" class="oe_highlight" />
or
<button string="Close" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_open_call_center_report_wizard" model="ir.actions.act_window">
<field name="name">Call Center Report Wizard</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">call.center.report.wizard</field>
<field name="view_id" ref="view_call_center_report_wizard"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@@ -1,13 +0,0 @@
CASH DAILY REPORT
=============
Export payments report in xls format
Credits
=======
Creator
------------
* Alexandre Díaz <dev@redneboa.es>

View File

@@ -1,21 +0,0 @@
# -*- 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 . import wizard

View File

@@ -1,51 +0,0 @@
# -*- 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/>.
#
##############################################################################
{
'name': 'Cash Daily Report',
'version': '1.0',
'author': "Alexandre Díaz <dev@redneboa.es>",
'website': 'https://www.eiqui.com',
'category': 'reports',
'summary': "Export payments report in xls format",
'description': "Cash Daily Report",
'depends': [
'account',
'account_payment_return',
'hotel',
],
'external_dependencies': {
'python': ['xlsxwriter']
},
'data': [
'wizard/cash_daily_report.xml',
'data/menus.xml',
'data/cron_jobs.xml',
],
'qweb': [],
'test': [
],
'installable': True,
'auto_install': False,
'application': False,
'license': 'AGPL-3',
}

View File

@@ -1,23 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data noupdate="0">
<!-- Scheduler For To Inform Guest About Reservation Before 24 Hours -->
<record model="ir.cron" id="period_lock_date">
<field name="name">Automatic Period Lock Date</field>
<field name="interval_number">1</field>
<field name="user_id" ref="base.user_root" />
<field name="interval_type">days</field>
<field name="numbercall">-1</field>
<field name="doall" eval="False" />
<field name="state">code</field>
<field name="model_id" ref="model_cash_daily_report_wizard" />
<field name="nextcall" eval="(DateTime.now() + timedelta(days=1)).strftime('%Y-%m-%d 04:00:00')"/>
<field name="code">model.automatic_period_lock_date()</field>
</record>
</data>
</odoo>

View File

@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<menuitem id="cash_daily_report_wizard" name="Cash Daily Report Wizard"
parent="hotel.hotel_reports_menu"
action="action_open_cash_daily_report_wizard"
sequence="45" />
<menuitem id="hotel_payments_menu" name="Payments"
sequence="80"
parent="hotel.hotel_management_menu"
groups="hotel.group_hotel_user"/>
<menuitem id="hotel_supplier_payment_menu" name="Supplier Payments"
sequence="80"
parent="hotel_payments_menu"
groups="hotel.group_hotel_user"
action="account.action_account_payments_payable"/>
<record id="action_account_payments_internal" model="ir.actions.act_window">
<field name="name">Internal Transfers</field>
<field name="res_model">account.payment</field>
<field name="view_mode">tree,kanban,form,graph</field>
<field name="context">{'default_payment_type': 'transfer', 'search_default_transfers_filter': 1}</field>
<field name="domain">[]</field>
<field name="view_id" ref="account.view_account_supplier_payment_tree"/>
<field name="help" type="html">
<p class="oe_view_nocontent_create">
Click to register a payment
</p><p>
Payments are used to register liquidity movements (send, collect or transfer money).
You can then process those payments by your own means or by using installed facilities.
</p>
</field>
</record>
<menuitem id="hotel_transfer_menu" name="Internal Transfer"
sequence="100"
parent="hotel_payments_menu"
groups="hotel.group_hotel_user"
action="cash_daily_report.action_account_payments_internal"/>
</odoo>

View File

@@ -1,203 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * cash_daily_report
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-08-02 10:07+0000\n"
"PO-Revision-Date: 2019-08-02 10:07+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: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:85
#, python-format
msgid "Amount"
msgstr "Importe"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:78
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
#, python-format
msgid "Cash Daily Report"
msgstr "Informe de caja"
#. module: cash_daily_report
#: model:ir.actions.act_window,name:cash_daily_report.action_open_cash_daily_report_wizard
#: model:ir.ui.menu,name:cash_daily_report.cash_daily_report_wizard
msgid "Cash Daily Report Wizard"
msgstr "Informe de caja diaria"
#. module: cash_daily_report
#: model:ir.actions.act_window,help:cash_daily_report.action_account_payments_internal
msgid "Click to register a payment"
msgstr "Pulse para registrar un pago"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:82
#, python-format
msgid "Client/Supplier"
msgstr "Client/Supplier"
#. module: cash_daily_report
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
msgid "Close"
msgstr "Cerrar"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_create_uid
msgid "Created by"
msgstr "Creado por"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_create_date
msgid "Created on"
msgstr "Creado en"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:83
#, python-format
msgid "Date"
msgstr "Fecha"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_display_name
msgid "Display Name"
msgstr "Nombre mostrado"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_date_end
msgid "End Date"
msgstr "Fecha de finalización"
#. module: cash_daily_report
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
msgid "Generate XLS"
msgstr "Generar XLS"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_id
msgid "ID"
msgstr "ID (identificación)"
#. module: cash_daily_report
#: model:ir.ui.menu,name:cash_daily_report.hotel_transfer_menu
msgid "Internal Transfer"
msgstr "Transferencias Internas"
#. module: cash_daily_report
#: model:ir.actions.act_window,name:cash_daily_report.action_account_payments_internal
msgid "Internal Transfers"
msgstr "Internal Transfers"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:84
#, python-format
msgid "Journal"
msgstr "Diario"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard___last_update
msgid "Last Modified on"
msgstr "Última modificación en"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_write_uid
msgid "Last Updated by"
msgstr "Última actualización de"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_write_date
msgid "Last Updated on"
msgstr "Última actualización en"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:80
#, python-format
msgid "Name"
msgstr "Nombre"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:159
#, python-format
msgid "Not Any Payments"
msgstr "No hay movimientos"
#. module: cash_daily_report
#: model:ir.ui.menu,name:cash_daily_report.hotel_payments_menu
msgid "Payments"
msgstr "Pagos"
#. module: cash_daily_report
#: model:ir.actions.act_window,help:cash_daily_report.action_account_payments_internal
msgid "Payments are used to register liquidity movements (send, collect or transfer money).\n"
" You can then process those payments by your own means or by using installed facilities."
msgstr "Los pagos se utilizan para registrar movimientos de liquidez (enviar, recibir o transferir dinero).\n"
"Puede procesar esos pagos por sus propios medios o utilizando los servicios instalados."
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:81
#, python-format
msgid "Reference"
msgstr "Referencia"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_date_start
msgid "Start Date"
msgstr "Fecha de Inicio"
#. module: cash_daily_report
#: model:ir.ui.menu,name:cash_daily_report.hotel_supplier_payment_menu
msgid "Supplier Payments"
msgstr "Pagos a Proveedor"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:216
#, python-format
msgid "TOTAL"
msgstr "TOTAL"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:201
#, python-format
msgid "TOTAL EXPENSES"
msgstr "TOTAL EXPENSES"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:185
#, python-format
msgid "TOTAL PAYMENT RETURNS"
msgstr "TOTAL DEVOLUCIONES"
#. module: cash_daily_report
#: code:addons/cash_daily_report/wizard/cash_daily_report.py:169
#, python-format
msgid "TOTAL PAYMENTS"
msgstr "TOTAL PAGOS"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_xls_binary
msgid "Xls Binary"
msgstr "Xls Binary"
#. module: cash_daily_report
#: model:ir.model.fields,field_description:cash_daily_report.field_cash_daily_report_wizard_xls_filename
msgid "Xls Filename"
msgstr "Xls Filename"
#. module: cash_daily_report
#: model:ir.model,name:cash_daily_report.model_cash_daily_report_wizard
msgid "cash.daily.report.wizard"
msgstr "cash.daily.report.wizard"
#. module: cash_daily_report
#: model:ir.ui.view,arch_db:cash_daily_report.view_cash_daily_report_wizard
msgid "or"
msgstr "o"

View File

@@ -1,21 +0,0 @@
# -*- 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 . import cash_daily_report

View File

@@ -1,307 +0,0 @@
# -*- 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 io import BytesIO
import datetime
import xlsxwriter
import base64
from odoo import api, fields, models, _
from openerp.exceptions import UserError
from openerp.tools import DEFAULT_SERVER_DATE_FORMAT
class CashDailyReportWizard(models.TransientModel):
FILENAME = 'cash_daily_report.xls'
_name = 'cash.daily.report.wizard'
@api.model
def automatic_period_lock_date(self):
# The secong month day close the mont previous
days = 2
closeday = datetime.date.today().replace(day=days)
if datetime.date.today() >= closeday:
companies = self.env['res.company'].search([])
for record in companies:
lastday = datetime.date.today().replace(day=1) + \
datetime.timedelta(days=-1)
if record.period_lock_date != lastday:
record.write({
'period_lock_date': lastday
})
@api.model
@api.model
def _get_default_date_start(self):
return datetime.datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT)
@api.model
def _get_default_date_end(self):
return datetime.datetime.now().strftime(DEFAULT_SERVER_DATE_FORMAT)
date_start = fields.Date("Start Date", default=_get_default_date_start)
date_end = fields.Date("End Date", default=_get_default_date_end)
xls_filename = fields.Char()
xls_binary = fields.Binary()
@api.model
def _export(self):
file_data = BytesIO()
workbook = xlsxwriter.Workbook(file_data, {
'strings_to_numbers': True,
'default_date_format': 'dd/mm/yyyy'
})
company_id = self.env.user.company_id
workbook.set_properties({
'title': 'Exported data from ' + company_id.name,
'subject': 'Payments Data from Odoo of ' + company_id.name,
'author': 'Odoo',
'manager': u'Alexandre Díaz Cuadrado',
'company': company_id.name,
'category': 'Hoja de Calculo',
'keywords': 'payments, odoo, data, ' + company_id.name,
'comments': 'Created with Python in Odoo and XlsxWriter'})
workbook.use_zip64()
xls_cell_format_date = workbook.add_format({
'num_format': 'dd/mm/yyyy'
})
xls_cell_format_money = workbook.add_format({
'num_format': '#,##0.00'
})
xls_cell_format_header = workbook.add_format({
'bg_color': '#CCCCCC'
})
worksheet = workbook.add_worksheet(_('Cash Daily Report'))
worksheet.write('A1', _('Name'), xls_cell_format_header)
worksheet.write('B1', _('Reference'), xls_cell_format_header)
worksheet.write('C1', _('Client/Supplier'), xls_cell_format_header)
worksheet.write('D1', _('Date'), xls_cell_format_header)
worksheet.write('E1', _('Journal'), xls_cell_format_header)
worksheet.write('F1', _('Amount'), xls_cell_format_header)
worksheet.set_column('C:C', 50)
worksheet.set_column('D:D', 11)
account_payments_obj = self.env['account.payment']
account_payments = account_payments_obj.search([
('payment_date', '>=', self.date_start),
('payment_date', '<=', self.date_end),
])
offset = 1
total_account_payment_amount = 0.0
total_account_payment = 0.0
total_account_expenses = 0.0
payment_journals = {}
expense_journals = {}
total_dates = {}
for k_payment, v_payment in enumerate(account_payments):
where = v_payment.partner_id.name
amount = v_payment.amount if v_payment.payment_type in ('inbound') \
else -v_payment.amount
if v_payment.payment_type == 'transfer':
where = v_payment.destination_journal_id.name
total_account_payment += -amount
if v_payment.destination_journal_id.name not in payment_journals:
payment_journals.update({v_payment.destination_journal_id.name: -amount})
else:
payment_journals[v_payment.destination_journal_id.name] += -amount
if v_payment.payment_date not in total_dates:
total_dates.update({v_payment.payment_date: {v_payment.destination_journal_id.name: -amount}})
else:
if v_payment.destination_journal_id.name not in total_dates[v_payment.payment_date]:
total_dates[v_payment.payment_date].update({v_payment.destination_journal_id.name: -amount})
else:
total_dates[v_payment.payment_date][v_payment.destination_journal_id.name] += -amount
if amount < 0:
total_account_expenses += -amount
if v_payment.journal_id.name not in expense_journals:
expense_journals.update({v_payment.journal_id.name: amount})
else:
expense_journals[v_payment.journal_id.name] += amount
if v_payment.payment_date not in total_dates:
total_dates.update({v_payment.payment_date: {v_payment.journal_id.name: amount}})
else:
if v_payment.journal_id.name not in total_dates[v_payment.payment_date]:
total_dates[v_payment.payment_date].update({v_payment.journal_id.name: amount})
else:
total_dates[v_payment.payment_date][v_payment.journal_id.name] += amount
else:
total_account_payment += amount
if v_payment.journal_id.name not in payment_journals:
payment_journals.update({v_payment.journal_id.name: amount})
else:
payment_journals[v_payment.journal_id.name] += amount
if v_payment.payment_date not in total_dates:
total_dates.update({v_payment.payment_date: {v_payment.journal_id.name: amount}})
else:
if v_payment.journal_id.name not in total_dates[v_payment.payment_date]:
total_dates[v_payment.payment_date].update({v_payment.journal_id.name: amount})
else:
total_dates[v_payment.payment_date][v_payment.journal_id.name] += amount
worksheet.write(k_payment+offset, 0, v_payment.create_uid.login)
worksheet.write(k_payment+offset, 1, v_payment.communication)
worksheet.write(k_payment+offset, 2, where)
worksheet.write(k_payment+offset, 3, v_payment.payment_date,
xls_cell_format_date)
worksheet.write(k_payment+offset, 4, v_payment.journal_id.name)
worksheet.write(k_payment+offset, 5, amount,
xls_cell_format_money)
total_account_payment_amount += amount
payment_returns_obj = self.env['payment.return']
payment_returns = payment_returns_obj.search([
('date', '>=', self.date_start),
('date', '<=', self.date_end),
])
offset += len(account_payments)
total_payment_returns_amount = k_line = 0.0
return_journals = {}
for k_payment, v_payment in enumerate(payment_returns):
for k_line, v_line in enumerate(v_payment.line_ids):
if v_payment.journal_id.name not in return_journals:
return_journals.update({v_payment.journal_id.name: -v_line.amount})
else:
return_journals[v_payment.journal_id.name] += -v_line.amount
if v_payment.date not in total_dates:
total_dates.update({v_payment.date: {v_payment.journal_id.name: -v_line.amount}})
else:
if v_payment.journal_id.name not in total_dates[v_payment.date]:
total_dates[v_payment.date].update({v_payment.journal_id.name: -v_line.amount})
else:
total_dates[v_payment.date][v_payment.journal_id.name] += -v_line.amount
worksheet.write(k_line+offset, 0, v_payment.create_uid.login)
worksheet.write(k_line+offset, 1, v_line.reference)
worksheet.write(k_line+offset, 2, v_line.partner_id.name)
worksheet.write(k_line+offset, 3, v_payment.date,
xls_cell_format_date)
worksheet.write(k_line+offset, 4, v_payment.journal_id.name)
worksheet.write(k_line+offset, 5, -v_line.amount,
xls_cell_format_money)
total_payment_returns_amount += -v_line.amount
offset += len(v_payment.line_ids)
if total_account_payment_amount == 0 and total_payment_returns_amount == 0:
raise UserError(_('Not Any Payments'))
line = offset
if k_line:
line = k_line + offset
result_journals = {}
# NORMAL PAYMENTS
if total_account_payment != 0:
line += 1
worksheet.write(line, 4, _('TOTAL PAYMENTS'), xls_cell_format_header)
worksheet.write(line, 5, total_account_payment,
xls_cell_format_header)
for journal in payment_journals:
line += 1
worksheet.write(line, 4, _(journal))
worksheet.write(line, 5, payment_journals[journal],
xls_cell_format_money)
if journal not in result_journals:
result_journals.update({journal: payment_journals[journal]})
else:
result_journals[journal] += payment_journals[journal]
# RETURNS
if total_payment_returns_amount != 0:
line += 1
worksheet.write(line, 4, _('TOTAL PAYMENT RETURNS'), xls_cell_format_header)
worksheet.write(line, 5, total_payment_returns_amount,
xls_cell_format_header)
for journal in return_journals:
line += 1
worksheet.write(line, 4, _(journal))
worksheet.write(line, 5, return_journals[journal],
xls_cell_format_money)
if journal not in result_journals:
result_journals.update({journal: return_journals[journal]})
else:
result_journals[journal] += return_journals[journal]
# EXPENSES
if total_account_expenses != 0:
line += 1
worksheet.write(line, 4, _('TOTAL EXPENSES'), xls_cell_format_header)
worksheet.write(line, 5, -total_account_expenses,
xls_cell_format_header)
for journal in expense_journals:
line += 1
worksheet.write(line, 4, _(journal))
worksheet.write(line, 5, -expense_journals[journal],
xls_cell_format_money)
if journal not in result_journals:
result_journals.update({journal: expense_journals[journal]})
else:
result_journals[journal] += expense_journals[journal]
#TOTALS
line += 1
worksheet.write(line, 4, _('TOTAL'), xls_cell_format_header)
worksheet.write(
line,
5,
total_account_payment + total_payment_returns_amount - total_account_expenses,
xls_cell_format_header)
for journal in result_journals:
line += 1
worksheet.write(line, 4, _(journal))
worksheet.write(line, 5, result_journals[journal],
xls_cell_format_money)
worksheet = workbook.add_worksheet(_('Por dia'))
worksheet.write('A1', _('Date'), xls_cell_format_header)
columns = ('B1','C1','D1','E1','F1','G1','H1')
i = 0
column_journal = {}
for journal in result_journals:
worksheet.write(columns[i], _(journal), xls_cell_format_header)
i += 1
column_journal.update({journal: i})
worksheet.set_column('C:C', 50)
worksheet.set_column('D:D', 11)
offset = 1
total_dates = sorted(total_dates.items(), key=lambda x: x[0])
for k_day, v_day in enumerate(total_dates):
worksheet.write(k_day+offset, 0, v_day[0])
for journal in v_day[1]:
worksheet.write(k_day+offset, column_journal[journal], v_day[1][journal])
workbook.close()
file_data.seek(0)
tnow = fields.Datetime.now().replace(' ', '_')
return {
'xls_filename': 'cash_daily_report_%s.xlsx' % tnow,
'xls_binary': base64.encodestring(file_data.read()),
}
def export(self):
self.write(self._export())
return {
"type": "ir.actions.do_nothing",
}

View File

@@ -1,41 +0,0 @@
<?xml version="1.0" ?>
<odoo>
<record model="ir.ui.view" id="view_cash_daily_report_wizard">
<field name="name">cash.daily.report.wizard</field>
<field name="model">cash.daily.report.wizard</field>
<field name="arch" type="xml">
<form string="Cash Daily Report" >
<group>
<group>
<field name="date_start" required="1" />
</group>
<group>
<field name="date_end" required="1" />
</group>
</group>
<group>
<group>
<field name="xls_filename" invisible="1"/>
<field name="xls_binary" filename="xls_filename" readonly="1" />
</group>
</group>
<footer>
<button name="export" string="Generate XLS" type="object" class="oe_highlight" />
or
<button string="Close" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_open_cash_daily_report_wizard" model="ir.actions.act_window">
<field name="name">Cash Daily Report Wizard</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">cash.daily.report.wizard</field>
<field name="view_id" ref="view_cash_daily_report_wizard"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@@ -1,15 +0,0 @@
GLASOF EXPORTER
=============
** UNDER DEVELOPMENT: NOT USE IN PRODUCTION **
Export Odoo data to glasof xls format
Credits
=======
Creator
------------
* Alexandre Díaz <dev@redneboa.es>

View File

@@ -1,21 +0,0 @@
# -*- 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 . import wizard

View File

@@ -1,48 +0,0 @@
# -*- 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/>.
#
##############################################################################
{
'name': 'Glasof Exporter',
'version': '1.0',
'author': "Alexandre Díaz <dev@redneboa.es>",
'website': 'https://www.eiqui.com',
'category': 'hotel/glasof',
'summary': "Export Odoo Data to xls compatible with Glasof",
'description': "Glasof Exporter",
'depends': [
'account',
],
'external_dependencies': {
'python': ['xlsxwriter']
},
'data': [
'wizard/glasof_wizard.xml',
'data/menus.xml',
],
'qweb': [],
'test': [
],
'installable': True,
'auto_install': False,
'application': False,
'license': 'AGPL-3',
}

View File

@@ -1,11 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<data>
<menuitem id="glasof_exporter" name="Glasof Exporter"
parent="account.menu_finance_legal_statement"
groups="account.group_account_manager,account.group_account_user"
action="action_open_glasof_exporter" sequence="10" />
</data>
</odoo>

View File

@@ -1,21 +0,0 @@
# -*- 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 . import glasof_wizard

View File

@@ -1,256 +0,0 @@
# -*- 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 io import BytesIO
import xlsxwriter
import base64
from odoo import api, fields, models, _
class GlassofExporterWizard(models.TransientModel):
FILENAME = 'invoices_glasof.xls'
_name = 'glasof.exporter.wizard'
date_start = fields.Date("Start Date")
date_end = fields.Date("End Date")
export_journals = fields.Boolean("Export Account Movements?", default=True)
export_invoices = fields.Boolean("Export Invoices?", default=True)
seat_num = fields.Integer("Seat Number Start", default=1)
xls_journals_filename = fields.Char()
xls_journals_binary = fields.Binary()
xls_invoices_filename = fields.Char()
xls_invoices_binary = fields.Binary()
@api.model
def _export_journals(self):
file_data = BytesIO()
workbook = xlsxwriter.Workbook(file_data, {
'strings_to_numbers': True,
'default_date_format': 'dd/mm/yyyy'
})
company_id = self.env.user.company_id
workbook.set_properties({
'title': 'Exported data from ' + company_id.name,
'subject': 'PMS Data from Odoo of ' + company_id.name,
'author': 'Odoo ALDA PMS',
'manager': 'Jose Luis Algara',
'company': company_id.name,
'category': 'Hoja de Calculo',
'keywords': 'pms, odoo, alda, data, ' + company_id.name,
'comments': 'Created with Python in Odoo and XlsxWriter'})
workbook.use_zip64()
xls_cell_format_seat = workbook.add_format({'num_format': '#'})
xls_cell_format_date = workbook.add_format({
'num_format': 'dd/mm/yyyy'
})
xls_cell_format_saccount = workbook.add_format({
'num_format': '000000'
})
xls_cell_format_money = workbook.add_format({
'num_format': '#,##0.00'
})
xls_cell_format_header = workbook.add_format({
'bg_color': '#CCCCCC'
})
worksheet = workbook.add_worksheet('Simples-1')
worksheet.write('A1', _('Seat'), xls_cell_format_header)
worksheet.write('B1', _('Date'), xls_cell_format_header)
worksheet.write('C1', _('SubAccount'), xls_cell_format_header)
worksheet.write('D1', _('Description'), xls_cell_format_header)
worksheet.write('E1', _('Concept'), xls_cell_format_header)
worksheet.write('F1', _('Debit'), xls_cell_format_header)
worksheet.write('G1', _('Credit'), xls_cell_format_header)
worksheet.write('H1', _('Seat Type'), xls_cell_format_header)
worksheet.set_column('B:B', 11)
worksheet.set_column('E:E', 50)
account_move_obj = self.env['account.move']
account_moves = account_move_obj.search([
('date', '>=', self.date_start),
('date', '<=', self.date_end),
])
start_seat = self.seat_num
nrow = 1
for move in account_moves:
nmove = True
for line in move.line_ids:
if line.journal_id.type in ('cash', 'bank'):
worksheet.write(nrow, 0, nmove and start_seat or '',
xls_cell_format_seat)
worksheet.write(nrow, 1, nmove and line.date or '',
xls_cell_format_date)
worksheet.write(nrow, 2, line.account_id.code,
xls_cell_format_saccount)
worksheet.write(nrow, 3, '')
worksheet.write(nrow, 4, line.ref and line.ref[:50] or '')
worksheet.write(nrow, 5, line.debit, xls_cell_format_money)
worksheet.write(nrow, 6, line.credit,
xls_cell_format_money)
worksheet.write(nrow, 7, '')
nmove = False
nrow += 1
start_seat += 1
workbook.close()
file_data.seek(0)
tnow = fields.Datetime.now().replace(' ', '_')
return {
'xls_journals_filename': 'journals_glasof_%s.xlsx' % tnow,
'xls_journals_binary': base64.encodestring(file_data.read()),
}
@api.model
def _export_invoices(self):
file_data = BytesIO()
workbook = xlsxwriter.Workbook(file_data, {
'strings_to_numbers': True,
'default_date_format': 'dd/mm/yyyy'
})
company_id = self.env.user.company_id
workbook.set_properties({
'title': 'Exported data from ' + company_id.name,
'subject': 'PMS Data from Odoo of ' + company_id.name,
'author': 'Odoo ALDA PMS',
'manager': 'Jose Luis Algara',
'company': company_id.name,
'category': 'Hoja de Calculo',
'keywords': 'pms, odoo, alda, data, ' + company_id.name,
'comments': 'Created with Python in Odoo and XlsxWriter'})
workbook.use_zip64()
xls_cell_format_seat = workbook.add_format({'num_format': '#'})
xls_cell_format_date = workbook.add_format({
'num_format': 'dd/mm/yyyy'
})
xls_cell_format_saccount = workbook.add_format({
'num_format': '000000'
})
xls_cell_format_money = workbook.add_format({
'num_format': '#,##0.00'
})
xls_cell_format_odec = workbook.add_format({
'num_format': '#,#0.0'
})
xls_cell_format_header = workbook.add_format({
'bg_color': '#CCCCCC'
})
worksheet = workbook.add_worksheet('ventas')
account_inv_obj = self.env['account.invoice']
account_invs = account_inv_obj.search([
('date', '>=', self.date_start),
('date', '<=', self.date_end),
])
nrow = 1
for inv in account_invs:
if inv.partner_id.parent_id:
firstname = inv.partner_id.parent_id.firstname or ''
lastname = inv.partner_id.parent_id.lastname or ''
else:
firstname = inv.partner_id.firstname or ''
lastname = inv.partner_id.lastname or ''
worksheet.write(nrow, 0, inv.number)
worksheet.write(nrow, 1, inv.date_invoice, xls_cell_format_date)
worksheet.write(nrow, 2, '')
worksheet.write(nrow, 3, inv.partner_id.vat and
inv.partner_id.vat[:2] or '')
worksheet.write(nrow, 4, inv.partner_id.vat and
inv.partner_id.vat[2:] or '')
worksheet.write(nrow, 5, lastname)
worksheet.write(nrow, 6, '')
worksheet.write(nrow, 7, firstname)
worksheet.write(nrow, 8, 705.0, xls_cell_format_odec)
worksheet.write(nrow, 9, inv.amount_untaxed, xls_cell_format_money)
if any(inv.tax_line_ids):
worksheet.write(nrow,
10,
inv.tax_line_ids[0].tax_id.amount,
xls_cell_format_money)
else:
worksheet.write(nrow, 10, '')
worksheet.write(nrow, 11, inv.tax_line_ids and
inv.tax_line_ids[0].amount or '',
xls_cell_format_money)
worksheet.write(nrow, 12, '')
worksheet.write(nrow, 13, '')
worksheet.write(nrow, 14, '')
worksheet.write(nrow, 15, '')
worksheet.write(nrow, 16, '')
worksheet.write(nrow, 17, '')
worksheet.write(nrow, 18, '')
worksheet.write(nrow, 19, '')
worksheet.write(nrow, 20, '')
worksheet.write(nrow, 21, 'S')
worksheet.write(nrow, 22, '')
if inv.type == 'out_refund':
worksheet.write(nrow, 23, inv.invoice_origin)
else:
worksheet.write(nrow, 23, '')
worksheet.write(nrow, 24, '')
worksheet.write(nrow, 25, '')
worksheet.write(nrow, 27, '')
worksheet.write(nrow, 28, '')
worksheet.write(nrow, 29, '')
worksheet.write(nrow, 30, '')
worksheet.write(nrow, 31, '')
worksheet.write(nrow, 32, '')
worksheet.write(nrow, 33, '')
worksheet.write(nrow, 34, '')
worksheet.write(nrow, 35, '')
worksheet.write(nrow, 36, '')
worksheet.write(nrow, 37, '')
worksheet.write(nrow, 38, '')
worksheet.write(nrow, 39, '')
worksheet.write(nrow, 40, '')
worksheet.write(nrow, 41, '')
worksheet.write(nrow, 42, '')
worksheet.write(nrow, 43, '430')
nrow += 1
workbook.add_worksheet('compras')
workbook.close()
file_data.seek(0)
tnow = fields.Datetime.now().replace(' ', '_')
return {
'xls_invoices_filename': 'invoices_glasof_%s.xlsx' % tnow,
'xls_invoices_binary': base64.encodestring(file_data.read()),
}
def export(self):
towrite = {}
if self.export_journals:
towrite.update(self._export_journals())
if self.export_invoices:
towrite.update(self._export_invoices())
if any(towrite):
self.write(towrite)
return {
"type": "ir.actions.do_nothing",
}

View File

@@ -1,52 +0,0 @@
<?xml version="1.0" ?>
<odoo>
<record model="ir.ui.view" id="view_glasof_exporter_wizard">
<field name="name">glasof.exporter.wizard</field>
<field name="model">glasof.exporter.wizard</field>
<field name="arch" type="xml">
<form string="Export to Glasof" >
<group>
<group>
<field name="date_start" required="1" />
</group>
<group>
<field name="date_end" required="1" />
</group>
</group>
<group>
<field name="export_journals" />
<field name="export_invoices" />
</group>
<group attrs="{'invisible': [('export_journals', '=', False)]}">
<field name="seat_num" />
</group>
<group>
<group attrs="{'invisible': [('export_journals', '=', False)]}">
<field name="xls_journals_filename" invisible="1"/>
<field name="xls_journals_binary" filename="xls_journals_filename" readonly="1" />
</group>
<group attrs="{'invisible': [('export_invoices', '=', False)]}">
<field name="xls_invoices_filename" invisible="1"/>
<field name="xls_invoices_binary" filename="xls_invoices_filename" readonly="1" />
</group>
</group>
<footer>
<button name="export" string="Generate XLS" type="object" class="oe_highlight" />
or
<button string="Close" class="oe_link" special="cancel" />
</footer>
</form>
</field>
</record>
<record id="action_open_glasof_exporter" model="ir.actions.act_window">
<field name="name">Export to Glasof</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">glasof.exporter.wizard</field>
<field name="view_id" ref="view_glasof_exporter_wizard"/>
<field name="view_mode">form</field>
<field name="target">new</field>
</record>
</odoo>

View File

@@ -1,61 +0,0 @@
.. This file is going to be generated by oca-gen-addon-readme. Manual changes will be overwritten.
HOTEL CALENDAR
==============
This module allows you to handle reservations, prices and restriction plans in a user friendly calendar view.
Description
------------
This module extends the functionality of roomdoo.
The calendar displays your rooms in a range of dates.
The rooms can be filtered by class, type or even amenities creating new calendars for easily manage all your reservations.
You can manage prices and restrictions day by day using the calendar management view.
This module adds two new view types: ``pms`` and ``mpms``.
The module also incorporates a longpolling for delivering instant notification when using the calendar.
Installation
------------
This module depends on modules ``hotel``, ``bus``, ``web``, ``calendar``, and ``web_widget_color``.
Ensure yourself to have all them in your addons list.
Configuration
-------------
No action required. The module is pre-configured with default values.
You will find the hotel calendar settings in `Settings > Users & Companies > Hotels > Your Hotel > Calendar Settings Tab`.
Reservation colors can be configured by company in `Settings > Users & Companies > Companies > Your Company > Hotel Preferences Tab.`
Usage
-----
To use this module, you need to:
* Go to Hotel Calendar menu for managing reservations.
* Go to Hotel Calendar Management for managing prices and restrictions.
* Go to Hotel Management/Configuration/Calendars menu for managing calendar tabs.
Shortcuts
_________
* ``CTRL + LEFT MOUSE CLICK`` on a reservation - start reservation swap
* ``ESC`` - cancel active action (ie. swap)
Credits
-------
Authors
_______
- Alexandre Díaz <dev@redneboa.es>
Contributors
____________
* Pablo Quesada <pabloqb@gmail.com>
Roadmap
-------
* [ ] Implement the calendar view as an Odoo native view type.
* [ ] Re-design the calendar using SVG or other Odoo native approach.
Do you want to contribute? Please, do not hesitate to contact any of the authors or contributors.

View File

@@ -1,4 +0,0 @@
# 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

View File

@@ -1,42 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Roomdoo Calendar',
'summary': 'A calendar view for user friendly handling your roomdoo property.',
'version': '11.0.2.0',
'development_status': 'Beta',
'category': 'Generic Modules/Hotel Management',
'website': 'https://github.com/hootel/hootel',
'author': 'Alexandre Díaz <dev@redneboa.es>',
'license': "AGPL-3",
'application': False,
'installable': True,
'depends': [
'bus',
'web',
'calendar',
'hotel',
'web_widget_color',
],
# 'external_dependencies': {
# 'python': []
# },
'data': [
'views/general.xml',
'views/actions.xml',
'views/inherited_hotel_property_views.xml',
'views/inherited_res_company_views.xml',
'views/inherited_res_users_views.xml',
'views/hotel_reservation_views.xml',
'views/hotel_calendar_management_views.xml',
'views/hotel_calendar_views.xml',
'data/menus.xml',
'security/ir.model.access.csv',
],
'qweb': [
'static/src/xml/hotel_calendar_management_view.xml',
'static/src/xml/hotel_calendar_templates.xml',
'static/src/xml/hotel_calendar_view.xml',
],
}

View File

@@ -1,3 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import bus

View File

@@ -1,21 +0,0 @@
# 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)

View File

@@ -1,29 +0,0 @@
<?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.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_calendar_record_menu" name="Calendars"
parent="hotel.hotel_configuration_menu" sequence="10"
groups="hotel.group_hotel_manager"
action="hotel_calendar_action_form_tree" />
</odoo>

File diff suppressed because it is too large Load Diff

View File

@@ -1,14 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import inherited_hotel_property
from . import hotel_calendar
from . import bus_hotel_calendar
from . import hotel_calendar_management
from . import inherited_hotel_reservation
from . import inherited_res_company
from . import inherited_res_users
from . import inherited_hotel_room_type_restriction_item
from . import inherited_product_pricelist_item
from . import inherited_hotel_folio
from . import ir_actions_act_window_view
from . import ir_ui_view

View File

@@ -1,137 +0,0 @@
# 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
'''
# Business methods
@api.model
def _generate_reservation_notif(self, vals):
user_id = self.env['res.users'].browse(self.env.uid)
return {
'type': 'reservation',
'action': vals['action'],
'subtype': vals['type'],
'title': vals['title'],
'username': user_id.partner_id.name,
'userid': user_id.id,
'reservation': {
'room_id': vals['room_id'],
'id': vals['reserv_id'],
'name': vals['partner_name'],
'adults': vals['adults'],
'childer': vals['children'],
'checkin': vals['checkin'],
'checkout': vals['checkout'],
'folio_id': vals['folio_id'],
'bgcolor': vals['reserve_color'],
'color': 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_room': False,
'overbooking': vals['overbooking'],
'price_room_services_set': vals['price_room_services_set'],
'amount_total': vals['pending_amount'] + vals['invoices_paid'],
'real_dates': vals['real_dates'],
'channel_type': vals['channel_type'],
},
'tooltip': {
'folio_name': vals['folio_name'],
'name': vals['partner_name'],
'phone': vals['partner_phone'],
'email': vals['partner_email'],
'room_type_name': vals['room_type_name'],
'adults': vals['adults'],
'children': vals['children'],
'checkin': vals['checkin'],
'checkout': vals['checkout'],
'arrival_hour': vals['arrival_hour'],
'departure_hour': vals['departure_hour'],
'price_room_services_set': vals['price_room_services_set'],
'invoices_paid': vals['invoices_paid'],
'pending_amount': vals['pending_amount'],
'type': vals['reservation_type'],
'closure_reason': vals['closure_reason'],
'out_service_description': vals['out_service_description'],
'splitted': vals['splitted'],
'real_dates': vals['real_dates'],
'channel_type': vals['channel_type'],
'board_service_name': vals['board_service_name'],
'services': vals['services'],
}
}
@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['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['room_type_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 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)

View File

@@ -1,23 +0,0 @@
# 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 HotelCalendar(models.Model):
""" Used to show and filter rooms and reservations in the PMS Calendar. """
_name = 'hotel.calendar'
# Default methods
@api.model
def _get_default_hotel(self):
return self.env.user.hotel_id
# Fields declaration
name = fields.Char('Name', required=True)
hotel_id = fields.Many2one('hotel.property', 'Hotel', required=True, ondelete='restrict',
default=_get_default_hotel)
room_type_ids = fields.Many2many('hotel.room.type', string='Room Type')
segmentation_ids = fields.Many2many('hotel.room.type.class', string='Segmentation')
location_ids = fields.Many2many('hotel.floor', string='Location')
amenity_ids = fields.Many2many('hotel.amenity', string='Amenity')

View File

@@ -1,277 +0,0 @@
# 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 timedelta
from odoo.tools import (
DEFAULT_SERVER_DATE_FORMAT,
DEFAULT_SERVER_DATETIME_FORMAT)
from odoo import models, api, _, fields
from odoo.exceptions import AccessError, ValidationError
_logger = logging.getLogger(__name__)
class HotelCalendarManagement(models.TransientModel):
_name = 'hotel.calendar.management'
# Business methods
def get_hcalendar_settings(self):
return {
'eday_week': self.env.user.hotel_id.pms_end_day_week,
'eday_week_offset': self.env.user.hotel_id.pms_end_day_week_offset,
'days': self.env.user.hotel_id.pms_default_num_days,
'show_notifications': self.env.user.pms_show_notifications,
'show_num_rooms': self.env.user.hotel_id.pms_show_num_rooms,
}
@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 _hcalendar_room_json_data(self, rooms):
json_data = []
for room in rooms:
json_data.append({
'id': room.id,
'name': room.name,
'capacity': room.get_capacity(),
'price': room.list_price,
'total_rooms': room.total_rooms_count,
})
return json_data
@api.model
def _hcalendar_pricelist_json_data(self, prices):
json_data = {}
room_type_obj = self.env['hotel.room.type']
for rec in prices:
room_type_id = room_type_obj.search([
('product_id.product_tmpl_id', '=', rec.product_tmpl_id.id)
], limit=1)
if not room_type_id:
continue
# TODO: date_end - date_start loop
json_data.setdefault(room_type_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:
json_data.setdefault(rec.room_type_id.id, []).append({
'id': rec.id,
'date': rec.date,
'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_events_json_data(self, dfrom, dto):
date_start = fields.Date.from_string(dfrom) - 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 self.env.user.hotel_id.pms_allowed_events_tags:
domain.append(('categ_ids', 'in', self.env.user.hotel_id.pms_allowed_events_tags))
if self.env.user.hotel_id.pms_denied_events_tags:
domain.append(
('categ_ids', 'not in', self.env.user.hotel_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):
date_start = fields.Date.from_string(dfrom)
date_end = fields.Date.from_string(dto)
date_diff = abs((date_end - date_start).days) + 1
room_type_obj = self.env['hotel.room.type']
room_types = room_type_obj.search([])
json_data = {}
for room_type in room_types:
for i in range(0, date_diff):
cur_date = date_start + timedelta(days=i)
cur_date_str = cur_date.strftime(DEFAULT_SERVER_DATE_FORMAT)
self.env.cr.execute('''
SELECT
hrl.id
FROM hotel_reservation_line AS hrl
WHERE date = %s
''', ((cur_date_str),))
line_ids = [r[0] for r in self.env.cr.fetchall()]
reservation_ids = self.env['hotel.reservation.line'].browse(line_ids).\
mapped('reservation_id.id')
reservations = self.env['hotel.reservation'].\
browse(reservation_ids).filtered(
lambda r: r.state != 'cancelled'
and not r.overbooking and not r.reselling
)
reservations_rooms = reservations.mapped('room_id.id')
free_rooms = self.env['hotel.room'].search([
('id', 'not in', reservations_rooms),
])
rooms_linked = self.env['hotel.room.type'].search([
('id', '=', room_type.id)
]).room_ids
free_rooms = free_rooms & rooms_linked
json_data.setdefault(room_type.id, []).append({
'date': cur_date_str,
'num': len(free_rooms),
})
return json_data
@api.model
def get_hcalendar_all_data(self, dfrom, dto, pricelist_id, restriction_id,
withRooms):
hotel_id = self.env.user.hotel_id.id
if not dfrom or not dto:
raise ValidationError(_('Input Error: No dates defined!'))
vals = {}
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
if not pricelist_id:
pricelist_id = self.env.user.hotel_id.default_pricelist_id.id
# TODO: refactoring res.config.settings', 'default_restriction_id by the current hotel.property.restriction_id
if not restriction_id:
restriction_id = self.env.user.hotel_id.default_restriction_id.id
# TODO: ensure pricelist_id and restriction_id belong to the current hotel
vals.update({'pricelist_id': pricelist_id})
vals.update({'restriction_id': restriction_id})
restriction_item_ids = self.env['hotel.room.type.restriction.item'].search([
('date', '>=', dfrom), ('date', '<=', dto),
('restriction_id', '=', restriction_id),
])
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)
# TODO REVIEW: what are json_rc and json_events used for in calendar management ¿?
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 [],
'count_reservations': json_rc or [],
'events': json_events or [],
})
if withRooms:
room_ids = self.env['hotel.room.type'].search([
('hotel_id', '=', hotel_id)
], order='sequence ASC') or None
if not room_ids:
raise AccessError(
_("Wrong hotel and company access settings for this user. "
"No room types found for hotel %s") % self.env.user.hotel_id.name)
json_rooms = self._hcalendar_room_json_data(room_ids)
vals.update({'rooms': json_rooms or []})
return vals
@api.model
def save_changes(self, pricelist_id, restriction_id, pricelist,
restrictions, availability=False):
room_type_obj = self.env['hotel.room.type']
product_pricelist_item_obj = self.env['product.pricelist.item']
room_type_rest_item_obj = self.env['hotel.room.type.restriction.item']
# Save Pricelist
for k_price in pricelist.keys():
room_type_id = room_type_obj.browse([int(k_price)])
room_type_prod_tmpl_id = room_type_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', '=', room_type_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': room_type_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 = room_type_rest_item_obj.search([
('date', '=', restriction['date']),
('restriction_id', '=', int(restriction_id)),
('room_type_id', '=', int(k_res)),
], limit=1)
vals = self._get_restrictions_values(restriction)
if not res_id:
vals.update({
'date': restriction['date'],
'restriction_id': int(restriction_id),
'room_type_id': int(k_res),
})
res_id = room_type_rest_item_obj.create(vals)
else:
res_id.write(vals)

View File

@@ -1,34 +0,0 @@
# Copyright 2018-2019 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api, _
class HotelFolio(models.Model):
_inherit = 'hotel.folio'
# ORM overrides
def write(self, vals):
ret = super(HotelFolio, self).write(vals)
fields_to_check = ('reservation_ids', 'service_ids', 'pending_amount')
fields_checked = [elm for elm in fields_to_check if elm in vals]
if any(fields_checked):
for record in self:
record.reservation_ids.send_bus_notification('write', 'noshow')
return ret
def unlink(self):
for record in self:
record.reservation_ids.send_bus_notification('unlink', 'warn',
_("Folio Deleted"))
return super(HotelFolio, self).unlink()
# Business methods
def compute_amount(self):
ret = super(HotelFolio, self).compute_amount()
with self.env.norecompute():
for record in self:
record.reservation_ids.send_bus_notification('write', 'noshow')
return ret

View File

@@ -1,51 +0,0 @@
# Copyright 2019 Pablo Quesada
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class HotelProperty(models.Model):
_inherit = 'hotel.property'
# Fields declaration
pms_show_num_rooms = fields.Integer('Number of rooms to show',
default=0)
pms_divide_rooms_by_capacity = fields.Boolean('Divide rooms by capacity',
default=True)
pms_end_day_week = fields.Selection([
('1', 'Monday'),
('2', 'Tuesday'),
('3', 'Wednesday'),
('4', 'Thursday'),
('5', 'Friday'),
('6', 'Saturday'),
('7', 'Sunday')
], string='Highlight column of day', 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_default_num_days = fields.Selection([
('month', '1 Month'),
('21', '3 Weeks'),
('14', '2 Weeks'),
('7', '1 Week')
], string='Default number of days', default='month')
# TODO: review the use of the following option in the calendar js functions
pms_type_move = fields.Selection([
('normal', 'Normal'),
('assisted', 'Assisted'),
('allow_invalid', 'Allow Invalid')
], string='Reservation move mode', default='normal')
pms_allowed_events_tags = fields.Many2many(
'calendar.event.type',
string="Allow Calendar Event Tags")
pms_denied_events_tags = fields.Many2many(
'calendar.event.type',
string="Deny Calendar Event Tags")

View File

@@ -1,521 +0,0 @@
# 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 timedelta
from odoo import models, fields, api, _
from odoo.models import operator
from odoo.exceptions import AccessError, ValidationError
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
_logger = logging.getLogger(__name__)
class HotelReservation(models.Model):
_inherit = 'hotel.reservation'
# Fields declaration
reserve_color = fields.Char(compute='_compute_color', string='Color',
store=True)
reserve_color_text = fields.Char(compute='_compute_color', string='Color',
store=True)
# TODO: Add the following method into _compute_color
def _generate_color(self):
self.ensure_one()
company_id = self.env.user.company_id
if self.reservation_type == 'staff':
reserv_color = company_id.color_staff
reserv_color_text = company_id.color_letter_staff
elif self.reservation_type == 'out':
reserv_color = company_id.color_dontsell
reserv_color_text = company_id.color_letter_dontsell
elif self.to_assign:
reserv_color = company_id.color_to_assign
reserv_color_text = company_id.color_letter_to_assign
elif self.state == 'draft':
reserv_color = company_id.color_pre_reservation
reserv_color_text = company_id.color_letter_pre_reservation
elif self.state == 'confirm':
if self.folio_id.pending_amount <= 0:
reserv_color = company_id.color_reservation_pay
reserv_color_text = company_id.color_letter_reservation_pay
else:
reserv_color = company_id.color_reservation
reserv_color_text = company_id.color_letter_reservation
elif self.state == 'booking':
if self.folio_id.pending_amount <= 0:
reserv_color = company_id.color_stay_pay
reserv_color_text = company_id.color_letter_stay_pay
else:
reserv_color = company_id.color_stay
reserv_color_text = company_id.color_letter_stay
else:
if self.folio_id.pending_amount <= 0:
reserv_color = company_id.color_checkout
reserv_color_text = company_id.color_letter_checkout
else:
reserv_color = company_id.color_payment_pending
reserv_color_text = company_id.color_letter_payment_pending
return reserv_color, reserv_color_text
# Constraints and onchanges
@api.depends('state', 'reservation_type', 'folio_id.pending_amount', 'to_assign')
def _compute_color(self):
for record in self:
colors = record._generate_color()
record.update({
'reserve_color': colors[0],
'reserve_color_text': colors[1],
})
# ORM overrides
@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
def write(self, vals):
_logger.info("RESERV WRITE")
ret = super(HotelReservation, self).write(vals)
self.send_bus_notification('write', 'noshow')
return ret
def unlink(self):
self.send_bus_notification('unlink',
'warn',
_("Reservation Deleted"))
return super(HotelReservation, self).unlink()
# Business methods
@api.model
def _hcalendar_room_data(self, rooms):
_logger.warning('_found [%s] rooms for hotel [%s]', len(rooms), self.env.user.hotel_id.id)
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_id = self.env.user.hotel_id.default_pricelist_id.id
json_rooms = [
{
'id': room.id,
'name': room.name,
'capacity': room.capacity,
'class_name': room.room_type_id.class_id.name,
'class_id': room.room_type_id.class_id.id,
'shared_id': room.shared_room_id,
'price': room.room_type_id
and ['pricelist', room.room_type_id.id, pricelist_id,
room.room_type_id.name] or 0,
'room_type_name': room.room_type_id.name,
'room_type_id': room.room_type_id.id,
'floor_id': room.floor_id.id,
'amentity_ids': room.room_type_id.room_amenity_ids.ids,
} for room in rooms]
return json_rooms
@api.model
def _hcalendar_reservation_data(self, reservations):
_logger.warning('_found [%s] reservations for hotel [%s]', len(reservations), self.env.user.hotel_id.id)
json_reservations = []
json_reservation_tooltips = {}
for reserv in reservations:
json_reservations.append({
'room_id': reserv['room_id'],
'id': reserv['id'],
'name': reserv['closure_reason'] or _('Out of service')
if reserv['reservation_type'] == 'out'
else reserv['partner_name'],
'adults': reserv['adults'],
'childrens': reserv['children'],
'checkin': reserv['checkin'],
'checkout': reserv['checkout'],
'folio_id': reserv['folio_id'],
'bgcolor': reserv['reserve_color'],
'color': reserv['reserve_color_text'],
'splitted': reserv['splitted'],
'parent_reservation': reserv['parent_reservation'] or False,
'read_only': False, # Read-Only
'fix_days': reserv['splitted'], # Fix Days
'fix_room': False, # Fix Rooms
'overbooking': reserv['overbooking'],
'state': reserv['state'],
'price_room_services_set': reserv['price_room_services_set'],
'amount_total': reserv['amount_total'],
'real_dates': [reserv['real_checkin'], reserv['real_checkout']],
'channel_type': reserv['channel_type'],
})
json_reservation_tooltips.update({
reserv['id']: {
'folio_name': reserv['folio_name'],
'name': _('Out of service')
if reserv['reservation_type'] == 'out'
else reserv['partner_name'],
'phone': reserv['mobile'] or reserv['phone']
or _('Phone not provided'),
'email': reserv['email'] or _('Email not provided'),
'room_type_name': reserv['room_type'],
'adults': reserv['adults'],
'children': reserv['children'],
'checkin': reserv['checkin'],
'checkout': reserv['checkout'],
'arrival_hour': reserv['arrival_hour'],
'departure_hour': reserv['departure_hour'],
'price_room_services_set': reserv['price_room_services_set'],
'invoices_paid': reserv['invoices_paid'],
'pending_amount': reserv['pending_amount'],
'type': reserv['reservation_type'] or 'normal',
'closure_reason': reserv['closure_reason'],
'out_service_description': reserv['out_service_description']
or _('No reason given'),
'splitted': reserv['splitted'],
'channel_type': reserv['channel_type'],
'real_dates': [reserv['real_checkin'], reserv['real_checkout']],
'board_service_name': reserv['board_service_name'] or _('No board services'),
'services': reserv['services'],
}
})
return json_reservations, json_reservation_tooltips
@api.model
def _hcalendar_event_data(self, events):
# TODO: Filter events by hotel
json_events = [
{
'id': event.id,
'name': event.name,
'date': event.start,
'location': event.location,
} for event in events]
return json_events
@api.model
def _hcalendar_calendar_data(self, calendars):
_logger.warning('_found [%s] calendars for hotel [%s]', len(calendars), self.env.user.hotel_id.id)
return [
{
'id': calendar.id,
'name': calendar.name,
'segmentation_ids': calendar.segmentation_ids.ids,
'location_ids': calendar.location_ids.ids,
'amenity_ids': calendar.amenity_ids.ids,
'room_type_ids': calendar.room_type_ids.ids,
} for calendar in calendars]
@api.model
def get_hcalendar_reservations_data(self, dfrom_dt, dto_dt, rooms):
rdfrom_dt = dfrom_dt + timedelta(days=1) # Ignore checkout
rdfrom_str = rdfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
dto_str = dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
self.env.cr.execute('''
SELECT
hr.id, hr.room_id, hr.adults, hr.children, hr.checkin, hr.checkout, hr.reserve_color, hr.reserve_color_text,
hr.splitted, hr.parent_reservation, hr.overbooking, hr.state, hr.real_checkin, hr.real_checkout,
hr.out_service_description, hr.arrival_hour, hr.departure_hour, hr.channel_type,
hr.price_room_services_set,
hf.id as folio_id, hf.name as folio_name, hf.reservation_type, hf.invoices_paid, hf.pending_amount,
hf.amount_total,
rp.mobile, rp.phone, rp.email, rp.name as partner_name,
pt.name as room_type,
array_agg(pt2.name) FILTER (WHERE pt2.show_in_calendar = TRUE) as services,
rcr.name as closure_reason,
hbs.name as board_service_name
FROM hotel_reservation AS hr
LEFT JOIN hotel_folio AS hf ON hr.folio_id = hf.id
LEFT JOIN hotel_room_type AS hrt ON hr.room_type_id = hrt.id
LEFT JOIN product_product AS pp ON hrt.product_id = pp.id
LEFT JOIN product_template AS pt ON pp.product_tmpl_id = pt.id
LEFT JOIN res_partner AS rp ON hf.partner_id = rp.id
LEFT JOIN room_closure_reason as rcr
ON hf.closure_reason_id = rcr.id
LEFT JOIN hotel_board_service_room_type_rel AS hbsrt ON hr.board_service_room_id = hbsrt.id
LEFT JOIN hotel_board_service AS hbs ON hbsrt.hotel_board_service_id = hbs.id
LEFT JOIN hotel_service AS hs ON hr.id = hs.reservation_id
LEFT JOIN product_product AS pp2 ON hs.product_id = pp2.id
LEFT JOIN product_template AS pt2 ON pp2.product_tmpl_id = pt2.id
WHERE room_id IN %s AND (
(checkin <= %s AND checkout >= %s AND checkout <= %s)
OR (checkin >= %s AND checkout <= %s)
OR (checkin >= %s AND checkin <= %s AND checkout >= %s)
OR (checkin <= %s AND checkout >= %s))
GROUP BY hr.id, hf.id, pt.name, rcr.name, hbs.name, rp.mobile, rp.phone, rp.email, rp.name
ORDER BY checkin DESC, checkout ASC, adults DESC, children DESC
''', (tuple(rooms.ids),
rdfrom_str, rdfrom_str, dto_str,
rdfrom_str, dto_str,
rdfrom_str, dto_str, dto_str,
rdfrom_str, dto_str))
return self._hcalendar_reservation_data(self.env.cr.dictfetchall())
@api.model
def get_hcalendar_pricelist_data(self, dfrom_dt, dto_dt):
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_id = self.env.user.hotel_id.default_pricelist_id.id
hotel_id = self.env.user.hotel_id.id
room_types_ids = self.env['hotel.room.type'].search([
('hotel_id', '=', hotel_id)
])
dfrom_str = dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
dto_str = dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)
self.env.cr.execute('''
WITH RECURSIVE gen_table_days AS (
SELECT hrt.id, %s::Date AS date, hrt.sequence
FROM hotel_room_type AS hrt
UNION ALL
SELECT hrt.id, (td.date + INTERVAL '1 day')::Date, hrt.sequence
FROM gen_table_days as td
LEFT JOIN hotel_room_type AS hrt ON hrt.id=td.id
WHERE td.date < %s
)
SELECT
TO_CHAR(gtd.date, 'DD/MM/YYYY') as date, gtd.id as room_type_id, gtd.sequence,
pt.name, ppi.fixed_price as price, pt.list_price
FROM gen_table_days AS gtd
LEFT JOIN hotel_room_type AS hrt ON hrt.id = gtd.id
LEFT JOIN product_product AS pp ON pp.id = hrt.product_id
LEFT JOIN product_template AS pt ON pt.id = pp.product_tmpl_id
LEFT JOIN product_pricelist_item AS ppi ON ppi.date_start = gtd.date AND ppi.date_end = gtd.date AND ppi.product_tmpl_id = pt.id
WHERE gtd.id IN %s
ORDER BY gtd.id ASC, gtd.date ASC
''', (dfrom_str, dto_str, tuple(room_types_ids.ids)))
query_results = self.env.cr.dictfetchall()
json_data = {}
for results in query_results:
if results['room_type_id'] not in json_data:
json_data.setdefault(results['room_type_id'], {}).update({
'title': results['name'],
'room': results['room_type_id'],
'sequence': results['sequence'],
})
json_data[results['room_type_id']].setdefault('days', {}).update({
results['date']: results['price'] or results['list_price']
})
json_data_by_sequence = list(json_data.values())
json_data_by_sequence.sort(key=operator.itemgetter('sequence'))
json_rooms_prices = {}
for prices in json_data_by_sequence:
json_rooms_prices.setdefault(pricelist_id, []).append(prices)
return json_rooms_prices
@api.model
def get_hcalendar_restrictions_data(self, dfrom_dt, dto_dt):
""" Returns the room type restrictions between dfrom_dt and dto_dt
for the room types of the current_hotel within the default restriction plan
"""
hotel_id = self.env.user.hotel_id.id
restriction_id = self.env.user.hotel_id.default_restriction_id.id
json_rooms_rests = {}
room_typed_ids = self.env['hotel.room.type'].search([
('hotel_id', '=', hotel_id)
], order='sequence ASC')
room_type_rest_obj = self.env['hotel.room.type.restriction.item']
rtype_rest_ids = room_type_rest_obj.search([
('room_type_id', 'in', room_typed_ids.ids),
('date', '>=', dfrom_dt),
('date', '<=', dto_dt),
('restriction_id', '=', restriction_id)
])
for room_type in room_typed_ids:
days = {}
rest_ids = rtype_rest_ids.filtered(
lambda x: x.room_type_id == room_type)
for rest_id in rest_ids:
days.update({
fields.Date.from_string(rest_id.date).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({room_type.id: days})
return json_rooms_rests
@api.model
def get_hcalendar_events_data(self, dfrom_dt, dto_dt):
user_id = self.env['res.users'].browse(self.env.uid)
domain = [
'|', '&',
('start', '<=', dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)),
('stop', '>=', dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)),
'&',
('start', '>=', dfrom_dt.strftime(DEFAULT_SERVER_DATE_FORMAT)),
('stop', '<=', dto_dt.strftime(DEFAULT_SERVER_DATE_FORMAT))
]
if self.env.user.hotel_id.pms_allowed_events_tags:
domain.append(('categ_ids', 'in', self.env.user.hotel_id.pms_allowed_events_tags))
if self.env.user.hotel_id.pms_denied_events_tags:
domain.append(
('categ_ids', 'not in', self.env.user.hotel_id.pms_denied_events_tags))
events_raw = self.env['calendar.event'].search(domain)
return self._hcalendar_event_data(events_raw)
@api.model
def get_hcalendar_calendar_data(self):
hotel_id = self.env.user.hotel_id.id
calendars = self.env['hotel.calendar'].search([
('hotel_id', '=', hotel_id)
])
res = self._hcalendar_calendar_data(calendars)
return res
@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!'))
hotel_id = self.env.user.hotel_id.id
dfrom_dt = fields.Date.from_string(dfrom)
dto_dt = fields.Date.from_string(dto)
rooms = self.env['hotel.room'].search([
('hotel_id', '=', hotel_id)
], order='sequence ASC') or None
if not rooms:
raise AccessError(
_("No rooms found for hotel %s. "
"Please, review the rooms configured for this hotel.") % self.env.user.hotel_id.name)
json_res, json_res_tooltips = self.get_hcalendar_reservations_data(
dfrom_dt, dto_dt, rooms)
vals = {
'rooms': withRooms and self._hcalendar_room_data(rooms) or [],
'reservations': json_res,
'tooltips': json_res_tooltips,
'pricelist': self.get_hcalendar_pricelist_data(dfrom_dt, dto_dt),
'restrictions': self.get_hcalendar_restrictions_data(dfrom_dt,
dto_dt),
'events': self.get_hcalendar_events_data(dfrom_dt, dto_dt),
'calendars': withRooms and self.get_hcalendar_calendar_data()
or []
}
return vals
@api.model
def get_hcalendar_settings(self):
type_move = self.env.user.hotel_id.pms_type_move
return {
'divide_rooms_by_capacity': self.env.user.hotel_id.pms_divide_rooms_by_capacity,
'eday_week': self.env.user.hotel_id.pms_end_day_week,
'eday_week_offset': self.env.user.hotel_id.pms_end_day_week_offset,
'days': self.env.user.hotel_id.pms_default_num_days,
'allow_invalid_actions': type_move == 'allow_invalid',
'assisted_movement': type_move == 'assisted',
'default_arrival_hour': self.env.user.hotel_id.default_arrival_hour,
'default_departure_hour': self.env.user.hotel_id.default_departure_hour,
'show_notifications': self.env.user.pms_show_notifications,
'show_pricelist': self.env.user.pms_show_pricelist,
'show_availability': self.env.user.pms_show_availability,
'show_num_rooms': self.env.user.hotel_id.pms_show_num_rooms,
}
def generate_bus_values(self, naction, ntype, ntitle=''):
self.ensure_one()
return {
'action': naction,
'type': ntype,
'title': ntitle,
'room_id': self.room_id.id,
'reserv_id': self.id,
'folio_name': self.folio_id.name,
'partner_name': (self.closure_reason_id.name or _('Out of service'))
if self.reservation_type == 'out' else self.partner_id.name,
'adults': self.adults,
'children': self.children,
'checkin': self.checkin,
'checkout': self.checkout,
'arrival_hour': self.arrival_hour,
'departure_hour': self.departure_hour,
'folio_id': self.folio_id.id,
'reserve_color': self.reserve_color,
'reserve_color_text': self.reserve_color_text,
'splitted': self.splitted,
'parent_reservation': self.parent_reservation
and self.parent_reservation.id or 0,
'room_name': self.room_id.name,
'room_type_name': self.room_type_id.name,
'partner_phone': self.partner_id.mobile
or self.partner_id.phone or _('Undefined'),
'partner_email': self.partner_id.email or _('Undefined'),
'state': self.state,
'fix_days': self.splitted,
'overbooking': self.overbooking,
'price_room_services_set': self.price_room_services_set,
'invoices_paid': self.folio_id.invoices_paid,
'pending_amount': self.folio_id.pending_amount,
'reservation_type': self.reservation_type or 'normal',
'closure_reason': self.closure_reason_id.name,
'out_service_description': self.out_service_description
or _('No reason given'),
'real_dates': [self.real_checkin, self.real_checkout],
'channel_type': self.channel_type,
'board_service_name': self.board_service_room_id.hotel_board_service_id.name or _('No board services'),
'services': [service.product_id.name for service in self.service_ids
if service.product_id.show_in_calendar] or False,
}
def send_bus_notification(self, naction, ntype, ntitle=''):
hotel_cal_obj = self.env['bus.hotel.calendar']
for record in self:
if not isinstance(record.id, models.NewId) \
and not isinstance(record.folio_id.id, models.NewId) \
and not isinstance(record.partner_id.id, models.NewId):
hotel_cal_obj.send_reservation_notification(
record.generate_bus_values(naction, ntype, ntitle))
@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(to_reservs):
raise ValidationError(_("Invalid swap parameters"))
max_from_persons = max(
from_reservs.mapped(lambda x: x.adults))
max_to_persons = max(
to_reservs.mapped(lambda x: x.adults))
from_room = from_reservs[0].room_id
to_room = to_reservs[0].room_id
from_overbooking = from_reservs[0].overbooking
to_overbooking = to_reservs[0].overbooking
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({
'room_id': to_room.id,
'overbooking': to_overbooking,
})
for record in to_reservs:
record.with_context({'ignore_avail_restrictions': True}).write({
'room_id': from_room.id,
'overbooking': from_overbooking,
})
return True

View File

@@ -1,76 +0,0 @@
# 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, api
_logger = logging.getLogger(__name__)
class HotelRoomTypeRestrictionItem(models.Model):
_inherit = 'hotel.room.type.restriction.item'
# ORM overrides
@api.model
def create(self, vals):
res = super(HotelRoomTypeRestrictionItem, self).create(vals)
if res.restriction_id.id == self.env.user.hotel_id.default_restriction_id.id:
self.env['bus.hotel.calendar'].send_restriction_notification({
'restriction_id': res.restriction_id.id,
'date': res.date,
'min_stay': res.min_stay,
'min_stay_arrival': res.min_stay_arrival,
'max_stay': res.max_stay,
'max_stay_arrival': res.max_stay_arrival,
'closed': res.closed,
'closed_departure': res.closed_departure,
'closed_arrival': res.closed_arrival,
'room_type_id': res.room_type_id.id,
'id': res.id,
})
return res
def write(self, vals):
ret_vals = super(HotelRoomTypeRestrictionItem, self).write(vals)
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
for record in self:
bus_hotel_calendar_obj.send_restriction_notification({
'restriction_id': record.restriction_id.id,
'date': record.date,
'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,
'room_type_id': record.room_type_id.id,
'id': record.id,
})
return ret_vals
def unlink(self):
default_restriction_id = self.env.user.hotel_id.default_restriction_id.id
# Construct dictionary with relevant info of removed records
unlink_vals = []
for record in self:
if record.restriction_id.id != default_restriction_id:
continue
unlink_vals.append({
'restriction_id': record.restriction_id.id,
'date': record.date,
'min_stay': 0,
'min_stay_arrival': 0,
'max_stay': 0,
'max_stay_arrival': 0,
'closed': False,
'closed_departure': False,
'closed_arrival': False,
'room_type_id': record.room_type_id.id,
'id': record.id,
})
res = super(HotelRoomTypeRestrictionItem, 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

View File

@@ -1,122 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api
class ProductPricelistItem(models.Model):
_inherit = 'product.pricelist.item'
# ORM overrides
@api.model
def create(self, vals):
res = super(ProductPricelistItem, self).create(vals)
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_default_id:
pricelist_default_id = int(pricelist_default_id)
pricelist_id = res.pricelist_id.id
product_tmpl_id = res.product_tmpl_id.id
date_start = res.date_start
room_type = self.env['hotel.room.type'].search([
('product_id.product_tmpl_id', '=', product_tmpl_id)
], limit=1)
if pricelist_id == pricelist_default_id and room_type:
prod = room_type.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,
'room_id': room_type.id,
'price': prod_price,
'id': self.id,
})
return res
def write(self, vals):
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_default_id:
pricelist_default_id = int(pricelist_default_id)
ret_vals = super(ProductPricelistItem, self).write(vals)
bus_calendar_obj = self.env['bus.hotel.calendar']
room_type_obj = self.env['hotel.room.type']
if vals.get('fixed_price'):
for record in self:
pricelist_id = vals.get('pricelist_id') or \
record.pricelist_id.id
if pricelist_id != pricelist_default_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
room_type = room_type_obj.search([
('product_id.product_tmpl_id', '=', product_tmpl_id)
], limit=1)
if room_type and date_start:
prod = room_type.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,
'room_id': room_type.id,
'price': prod_price,
'id': record.id,
})
return ret_vals
def unlink(self):
# TODO: refactoring res.config.settings', 'default_pricelist_id' by the current hotel.property.pricelist_id
pricelist_default_id = self.env['ir.default'].sudo().get(
'res.config.settings', 'default_pricelist_id')
if pricelist_default_id:
pricelist_default_id = int(pricelist_default_id)
# Construct dictionary with relevant info of removed records
unlink_vals = []
for record in self:
if record.pricelist_id.id != pricelist_default_id:
continue
room_type = self.env['hotel.room.type'].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,
'room': room_type,
'id': record.id,
})
# Do Normal Stuff
res = super(ProductPricelistItem, self).unlink()
# Do extra operations
bus_calendar_obj = self.env['bus.hotel.calendar']
for vals in unlink_vals:
pricelist_id = vals['pricelist_id']
date_start = vals['date']
room_type = vals['room']
prod = room_type.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,
'room_id': room_type.id,
'price': prod.price,
'id': vals['id'],
})
return res

View File

@@ -1,29 +0,0 @@
# Copyright 2019 Pablo Quesada
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, fields
class ResCompany(models.Model):
_inherit = 'res.company'
# Fields declaration
color_pre_reservation = fields.Char('Pre-reservation', default='#A24680')
color_reservation = fields.Char('Confirmed Reservation ', default='#7C7BAD')
color_reservation_pay = fields.Char('Paid Reservation', default='#584D76')
color_stay = fields.Char('Checkin', default='#FF4040')
color_stay_pay = fields.Char('Paid Checkin', default='#82BF07')
color_checkout = fields.Char('Checkout', default='#7E7E7E')
color_dontsell = fields.Char('Dont Sell', default='#000000')
color_staff = fields.Char('Staff', default='#C08686')
color_to_assign = fields.Char('Ota Reservation to Assign', default='#ED722E')
color_payment_pending = fields.Char('Payment Pending', default='#A24689')
color_letter_pre_reservation = fields.Char('Letter Pre-reservation', default='#FFFFFF')
color_letter_reservation = fields.Char('Letter Confirmed Reservation ', default='#FFFFFF')
color_letter_reservation_pay = fields.Char('Letter Paid Reservation', default='#FFFFFF')
color_letter_stay = fields.Char('Letter Checkin', default='#FFFFFF')
color_letter_stay_pay = fields.Char('Letter Stay Pay', default='#FFFFFF')
color_letter_checkout = fields.Char('Letter Checkout', default='#FFFFFF')
color_letter_dontsell = fields.Char('Letter Dont Sell', default='#FFFFFF')
color_letter_staff = fields.Char('Letter Staff', default='#FFFFFF')
color_letter_to_assign = fields.Char('Letter Ota to Assign', default='#FFFFFF')
color_letter_payment_pending = fields.Char('Letter Payment Pending', default='#FFFFFF')

View File

@@ -1,34 +0,0 @@
# 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'
# Fields declaration
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)
# ORM overrides
def __init__(self, pool, cr):
""" Override of __init__ to add access rights.
Access rights are disabled by default, but allowed on some specific
fields defined in self.SELF_{READ/WRITE}ABLE_FIELDS.
"""
super(ResUsers, self).__init__(pool, cr)
# duplicate list to avoid modifying the original reference
type(self).SELF_WRITEABLE_FIELDS = list(self.SELF_WRITEABLE_FIELDS)
type(self).SELF_WRITEABLE_FIELDS.extend([
'pms_show_notifications',
'pms_show_pricelist',
'pms_show_availability',
])
# duplicate list to avoid modifying the original reference
type(self).SELF_READABLE_FIELDS = list(self.SELF_READABLE_FIELDS)
type(self).SELF_READABLE_FIELDS.extend([
'pms_show_notifications',
'pms_show_pricelist',
'pms_show_availability',
])

View File

@@ -1,10 +0,0 @@
# 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'
# Fields declaration
view_mode = fields.Selection(selection_add=[('pms', "PMS"), ('mpms', 'Management PMS')])

View File

@@ -1,10 +0,0 @@
# 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'
# Fields declaration
type = fields.Selection(selection_add=[('pms', "PMS"), ('mpms', 'Management PMS')])

View File

@@ -1,8 +0,0 @@
.. [ This file is optional, it should explain how to configure
the module before using it; it is aimed at advanced users. ]
No action required. The module is pre-configured with default values.
You will find the hotel calendar settings in `Settings > Users & Companies > Hotels > Your Hotel > Calendar Settings Tab`.
Reservation colors can be configured by company in `Settings > Users & Companies > Companies > Your Company > Hotel Preferences Tab.`

View File

@@ -1,2 +0,0 @@
# authors are taken from the __manifest__.py file
* Pablo Quesada <pabloqb@gmail.com>

View File

@@ -1,2 +0,0 @@
.. [ This file is optional and contains additional credits, other than
authors, contributors, and maintainers. ]

View File

@@ -1,10 +0,0 @@
.. [ This file must be max 2-3 paragraphs, and is required. ]
This module extends the functionality of roomdoo.
The calendar displays your rooms in a range of dates.
The rooms can be filtered by class, type or even amenities creating new calendars for easily manage all your reservations.
You can manage prices and restrictions day by day using the calendar management view.
This module adds two new view types: ``pms`` and ``mpms``.
The module also incorporates a longpolling for delivering instant notification when using the calendar.

View File

@@ -1,5 +0,0 @@
.. [ This file must only be present if there are very specific
installation instructions, such as installing non-python dependencies. The audience is systems administrators. ]
This module depends on modules ``hotel``, ``bus``, ``web``, ``calendar``, and ``web_widget_color``.
Ensure yourself to have all them in your addons list.

View File

@@ -1,5 +0,0 @@
.. [ Enumerate known caveats and future potential improvements.
It is mostly intended for end-users, and can also help potential new contributors discovering new features to implement. ]
- [ ] Implement the calendar view as an Odoo native view type.
- [ ] Re-design the calendar using SVG or other Odoo native approach.

View File

@@ -1,14 +0,0 @@
.. [ This file must be present and contains the usage instructions
for end-users. As all other rst files included in the README, it MUST NOT contain reStructuredText sections
only body text (paragraphs, lists, tables, etc). Should you need a more elaborate structure to explain the addon,
please create a Sphinx documentation (which may include this file as a "quick start" section). ]
To use this module, you need to:
* Go to Hotel Calendar menu for managing reservations.
* Go to Hotel Calendar Management for managing prices and restrictions.
* Go to Hotel Management/Configuration/Calendars menu for managing calendar tabs.
Shortcuts
* `CTRL + LEFT MOUSE CLICK`` on a reservation - Start reservation swap
* ``ESC`` - cancel active action (ie. swap)

View File

@@ -1,4 +0,0 @@
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
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
access_hotel_calendar,access_hotel_calendar,model_hotel_calendar,base.group_user,1,0,0,0
1 id name model_id:id group_id:id perm_read perm_write perm_create perm_unlink
2 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
3 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
4 access_hotel_calendar access_hotel_calendar model_hotel_calendar base.group_user 1 0 0 0

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.1 KiB

View File

@@ -1,396 +0,0 @@
/*
* 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;
}
*/
.o_hotel_calendar_view {
display: flex;
height: 100%;
}
.nopadding {
padding: 0 !important;
margin: 0 !important;
}
#pms-menu {
overflow: auto;
background-color: #f8f8f8;
height: 100%;
padding: 0 2.5em;
}
#pms-menu .input-group span, #pms-menu input {
border-radius: 0;
}
#pms-menu button {
border-radius: 0;
border: 1px solid lightgray;
font-size: x-small;
}
#pms-calendar: {
flex: 1 1 auto;
overflow: auto;
}
#pms-search {
position: fixed;
z-index: 9;
}
#hcal_widget {
max-height: 100%;
}
#multicalendar_panels {
background-color: white;
border-left: 1px solid #ddd;
}
.nav-tabs > li > a {
border-radius: 0;
}
.nav-tabs {
padding-top: 4px;
}
/* BUTTON STATES */
.navbar-default {
border-color: #f8f8f8;
}
.unify-enabled {
background-color: #43A200;
color: white;
}
.divide-enabled {
background-color: #43A200;
color: white;
}
.overbooking-enabled {
background-color: #43A200;
color: white;
}
.cancelled-enabled {
background-color: #43A200;
}
.swap-from {
background-color: #E7CF1D;
color: #7C7BAD;
}
.swap-to {
background-color: #43A200;
color: white;
}
.unify-enabled i, .divide-enabled i, .cancelled-enabled i, .overbooking-enabled i, .swap-to i {
color: white;
}
.swap-from i {
color: #7C7BAD;
}
/* END: BUTTON STATES */
input#bookings_search {
border-top-left-radius: 0;
border-top-right-radius: 0;
border: 1px solid lightgray;
}
#pms-menu .menu-date-box {
margin-top: 2px !important;
}
#pms-menu .menu-button-box, #pms-menu .menu-search-box, #pms-menu .menu-filter-box {
margin-top: 1em !important;
}
#pms-menu .menu-filter-box .filter-record {
margin-top: 1em;
}
#pms-menu .menu-filter-box h4 {
cursor: pointer;
}
#pms-menu .menu-filter-box h4 i {
transition: all 0.5s ease;
}
#pms-menu .button-box {
text-align: left;
min-height: 3.5em;
padding: 3px;
transition: all 0.5s ease;
overflow: hidden;
}
.overbooking-highlight {
color: white;
background-color: #FFA500;
}
.overbooking-highlight i {
color: white;
}
.multi-calendar-tab-plus {
background-color: darkgray;
font-weight: bold;
color: white;
}
#pms-menu div[id^=btn_] {
padding: 2px;
}
.warn-message {
text-align: center;
line-height: 100vh;
font-size: xx-large;
color: gray;
}
/** SELECT 2 **/
#pms-menu .select2-container, #pms-menu .select2-choice {
border-radius: 0;
}
#pms-menu .select2-choice {
height: 100%;
padding: 2px;
}
/** BOOTSTRAP **/
.badge-danger {
background-color: #d34f2a !important;
}
/** ODOO **/
.o_chat_window {
z-index: 8 !important;
}
.o_button_icon {
display: inline-block;
width: 37px;
padding: 0px 3px;
text-align: center;
vertical-align: middle;
color: #7C7BAD;
font-size: 24px;
}
.o_button_text {
display: inline-block;
vertical-align: middle;
max-width: 70%;
line-height: 1.2;
text-align: left;
}
.text-hidden-xs {
overflow: hidden;
text-overflow: ellipsis;
}
/** POPOVER **/
.popover-content {
font-family: Garuda, sans-serif;
font-size: 12px;
padding: 0px;
}
.popover .h3, .popover h3 {
margin-top: 2px;
margin-bottom: 2px;
}
.popover {
max-width: 400px;
border-radius: 0px;
padding: 0px;
}
.popover .container {
max-width: 100%;
}
.popover .container p {
margin-top: 2px;
margin-bottom: 0px;
}
.popover .container p.email {
word-wrap: break-word;
}
.popover .container p.board {
margin-top: 0px;
}
.popover header {
font-size: 1.2em;
}
.fa-1_5x {
font-size: 1.5em;
}
.fa-2_5x {
font-size: 2.5em;
}
.fa-text-inside {
font-family: Garuda, sans-serif;
font-size: 12px;
}
.popover .col-sm-2, .popover .col-sm-4, .popover .col-sm-6, .popover .col-sm-12 {
padding-top: 3px;
padding-bottom: 3px;
}
/* custom styles for popover info */
.popover .circle {
height:35px;
min-width:35px;
line-height:35px;
border-radius:50px;
text-align:center;
color:#fff;
background:#777;
margin-right: .65em;
padding: 0 5px;
}
.popover .bg-gray-lighter {
background-color: #ddd;
color: #777;
}
.popover .text-gray-dark {
color: #777;
}
/* Spacing in Bootstrap v4.0 */
.mt-3 {
margin-top: 3px;
}
.mt-5 {
margin-top: 5px;
}
.mt-10 {
margin-top: 10px !important;
}
.my-10 {
margin-top: 10px !important;
margin-bottom: 10px !important;
}
.mt-25 {
margin-top: 25px;
}
.mr-5 {
margin-right: 5px;
}
.mx-15 {
margin-left: 15px;
margin-right: 15px;
}
.mx-25 {
margin-left: 25px;
margin-right: 25px;
}
.px-0 {
padding-left: 0px;
padding-right: 0px;
}
.py-5 {
padding-top: 5px;
padding-bottom: 5px;
}
.pt-9 {
padding-top: 9px;
}
.pb-3 {
padding-bottom: 3px;
}
.pb-10 {
padding-bottom: 10px;
}
.pl-5 {
padding-left: 5px;
}
.pr-0 {
padding-right: 0px;
}
/* WARNING: The .row-eq-height class uses CSS3's flexbox layout mode,
which is not supported in Internet Explorer 9 and below. */
.row-eq-height {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
}
/* TODO: Use Odoo Colours based on http://www.odoo.com/openerp_website/static/src/less/variables.less */
div.diagonal {
overflow: hidden;
background-color: #777;
}
.diagonal:before {
content: "";
border-top: 700px solid #777;
border-right: 500px solid #ddd;
position: absolute;
left: 40%;
bottom: 0;
}
div.diagonal_pending_amount {
background-color: #A24689;
}
.diagonal_pending_amount::before {
border-top-color: #A24689;
}
div.triangle-right {
overflow: hidden;
color: white;
background-color: #7c7bad;
}
.triangle-right:before {
content: "";
position: absolute;
border: 26px solid #ddd;
height: 0;
width: 100%;
left: 47%;
top: 0;
bottom: 0;
margin: auto;
border-left-color: transparent;
}
div.on-top {
position: inherit;
}
div.pull-right-custom {
float: right !important;
margin-right: 15px;
color: #777;
text-align: right;
}
@keyframes blinker {
50% { opacity: 0; }
}

View File

@@ -1,192 +0,0 @@
// 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);
},
load: function (params) {
this.modelName = params.modelName;
this.modelManagementName = 'hotel.calendar.management'
},
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) {
var dialog = bootbox.dialog({
message: '<div class="text-center"><i class="fa fa-spin fa-spinner"></i> Getting Calendar Data From Server...</div>',
onEscape: false,
closeButton: false,
size: 'small',
backdrop: false,
});
return this._rpc({
model: this.modelName,
method: 'get_hcalendar_all_data',
args: oparams,
context: Session.user_context,
}, {
xhr: function () {
var xhr = new window.XMLHttpRequest();
//Download progress
xhr.addEventListener("readystatechange", function() {
if (this.readyState == this.DONE) {
console.log(`[HotelCalendar] Downloaded ${(parseInt(xhr.getResponseHeader("Content-Length"), 10)/1024).toFixed(3)}KiB of data`);
}
}, false);
return xhr;
},
success: function() {
dialog.modal('hide');
},
shadow: true,
});
},
get_hcalendar_settings: function() {
return this._rpc({
model: this.modelName,
method: 'get_hcalendar_settings',
args: [false],
});
},
get_room_types: function() {
var domain = [['hotel_id', '=', Session.hotel_id]];
return this._rpc({
model: 'hotel.room.type',
method: 'search_read',
args: [domain, ['id','name']],
context: Session.user_context,
});
},
get_floors: function() {
var domain = [('|',
['hotel_ids', 'in', Session.hotel_id],
['hotel_ids', '=', false]
)];
return this._rpc({
model: 'hotel.floor',
method: 'search_read',
args: [domain, ['id','name']],
context: Session.user_context,
});
},
get_amenities: function() {
var domain = [('|',
['hotel_ids', 'in', Session.hotel_id],
['hotel_ids', '=', false]
)];
// TODO: Filter rooms by amenities is not working
return this._rpc({
model: 'hotel.amenity',
method: 'search_read',
args: [domain, ['id','name']],
context: Session.user_context,
});
},
get_room_type_class: function() {
var domain = [('|',
['hotel_ids', 'in', Session.hotel_id],
['hotel_ids', '=', false]
)];
return this._rpc({
model: 'hotel.room.type.class',
method: 'search_read',
args: [domain, ['id','name']],
context: Session.user_context,
});
},
search_count: function(domain) {
domain.push(['hotel_id', '=', Session.hotel_id]);
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, vals],
context: Session.user_context,
});
},
update_or_create_calendar_record: function(ids, vals) {
if (!ids) {
return this._rpc({
model: 'hotel.calendar',
method: 'create',
args: [vals],
context: Session.user_context,
});
}
return this._rpc({
model: 'hotel.calendar',
method: 'write',
args: [ids, vals],
context: Session.user_context,
});
},
folio_search_count: function(domain) {
return this._rpc({
model: 'hotel.folio',
method: 'search_count',
args: [domain],
context: Session.user_context,
});
},
split_reservation: function(id, nights) {
return this._rpc({
model: this.modelName,
method: 'split',
args: [[id], nights],
context: Session.user_context,
})
},
unify_reservations: function(reserv_ids) {
return this._rpc({
model: this.modelName,
method: 'unify_ids',
args: [reserv_ids],
context: Session.user_context,
})
},
save_changes: function(params) {
// params.splice(0, 0, false); // FIXME: ID=False because first parameter its an integer
return this._rpc({
model: 'hotel.calendar.management',
method: 'save_changes',
args: params,
context: Session.user_context,
})
}
});
});

View File

@@ -1,284 +0,0 @@
/* 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,
/** VIEW METHODS **/
init: function(parent, state, params) {
this._super.apply(this, arguments);
},
start: function () {
this.init_calendar_view();
return this._super();
},
on_attach_callback: function() {
this._super();
if (!this._is_visible) {
// FIXME: Workaround for restore "lost" reservations (Drawn when the view is hidden)
this.trigger_up('onViewAttached');
}
},
/** CUSTOM METHODS **/
get_view_filter_dates: function () {
var $dateTimePickerBegin = this.$el.find('#pms-menu #date_begin');
var $dateEndDays = this.$el.find('#pms-menu #date_end_days');
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().clone();
var days = $dateEndDays.val();
if (days === 'month') {
days = date_begin.daysInMonth();
}
var date_end = date_begin.clone().add(days, 'd');
return [date_begin, date_end];
},
update_buttons_counter: function(ncheckouts, ncheckins, noverbookings, ncancelled) {
var self = this;
// Checkouts Button
var $ninfo = self.$el.find('#pms-menu #btn_action_checkout span.ninfo');
$ninfo.text(ncheckouts);
// Checkins Button
$ninfo = self.$el.find('#pms-menu #btn_action_checkin span.ninfo');
$ninfo.text(ncheckins);
// OverBookings
$ninfo = self.$el.find('#pms-menu #btn_action_overbooking span.ninfo');
$ninfo.text(noverbookings);
if (noverbookings) {
$ninfo.parent().parent().addClass('overbooking-highlight');
} else {
$ninfo.parent().parent().removeClass('overbooking-highlight');
}
// Cancelled
$ninfo = self.$el.find('#pms-menu #btn_action_cancelled span.ninfo');
$ninfo.text(ncancelled);
if (ncancelled) {
$ninfo.parent().parent().addClass('cancelled-highlight');
} else {
$ninfo.parent().parent().removeClass('cancelled-highlight');
}
},
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,
widgetPositioning:{
horizontal: 'auto',
vertical: 'bottom'
}
};
var $dateTimePickerBegin = this.$el.find('#pms-menu #date_begin');
var $dateEndDays = this.$el.find('#pms-menu #date_end_days');
$dateTimePickerBegin.datetimepicker(DTPickerOptions);
$dateEndDays.select2({
data: [
{id:7, text: '1w'},
{id:12, text: '2w'},
{id:21, text: '3w'},
{id:'month', text: '1m'},
{id:60, text: '2m'},
{id:90, text: '3m'},
],
allowClear: true,
minimumResultsForSearch: -1
});
/* 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) {
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
}
}
});
/* BUTTONS */
var $button = this.$el.find('#pms-menu #btn_action_bookings');
$button.on('click', function(ev){ self._open_search_tree('book'); });
$button = this.$el.find('#pms-menu #btn_action_checkins');
$button.on('click', function(ev){ self._open_search_tree('checkin'); });
$button = this.$el.find('#pms-menu #btn_action_invoices');
$button.on('click', function(ev){ self._open_search_tree('invoice'); });
$button = this.$el.find('#pms-menu #btn_action_folios');
$button.on('click', function(ev){ self._open_search_tree('folio'); });
// $button = this.$el.find('#pms-menu #bookings_search');
// $button.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);
});
return $.when(
this.trigger_up('onUpdateButtonsCounter'),
this.trigger_up('onLoadViewFilters'),
);
},
loadViewFilters: function(resultsHotelRoomType, resultsHotelFloor, resultsHotelRoomAmenities, resultsHotelVirtualRooms) {
var $list = this.$el.find('#pms-menu #type_list');
$list.html('');
resultsHotelRoomType.forEach(function(item, index){
$list.append(`<option value="${item.id}">${item.name}</option>`);
});
$list.select2();
$list.on('change', function(ev){
this.trigger_up('onApplyFilters');
}.bind(this));
// Get Floors
$list = this.$el.find('#pms-menu #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.trigger_up('onApplyFilters');
}.bind(this));
// Get Amenities
$list = this.$el.find('#pms-menu #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.trigger_up('onApplyFilters');
}.bind(this));
// Get Virtual Rooms
$list = this.$el.find('#pms-menu #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.trigger_up('onApplyFilters');
}.bind(this));
},
_generate_search_domain: function(tsearch, type) {
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]);
if (type === 'invoice') {
domain.splice(0, 0, '|');
domain.push(['number', 'ilike', tsearch]);
}
return domain;
},
_generate_search_res_model: function(type) {
var model = '';
var title = '';
if (type === 'book') {
model = 'hotel.reservation';
title = _t('Reservations');
} else if (type === 'checkin') {
model = 'hotel.checkin.partner';
title = _t('Checkins');
} else if (type === 'invoice') {
model = 'account.invoice';
title = _t('Invoices');
} else if (type === 'folio') {
model = 'hotel.folio'
title = _t('Folios');
}
return [model, title];
},
_open_search_tree: function(type) {
var $elm = this.$el.find('#pms-menu #bookings_search');
var searchQuery = $elm.val();
var domain = false;
if (searchQuery) {
domain = this._generate_search_domain(searchQuery, type);
} else {
domain = [];
}
var [model, title] = this._generate_search_res_model(type);
this.do_action({
type: 'ir.actions.act_window',
view_mode: 'form',
view_type: 'tree,form',
res_model: model,
views: [[false, 'list'], [false, 'form']],
domain: domain,
name: searchQuery?`${title} for ${searchQuery}`:`All ${title}`
});
$elm.val('');
},
});
return HotelCalendarView;
});

View File

@@ -1,179 +0,0 @@
// 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"]],
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'];
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_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();
});
},
});
var PMSCalendarView = AbstractView.extend({
display_name: _lt('Calendar PMS'),
icon: 'fa-calendar',
//jsLibs: [],
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.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);
//Core.view_registry.add('pms', HotelCalendarView);
return PMSCalendarView;
});

View File

@@ -1,176 +0,0 @@
// 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',
onLoadNewContentCalendar: '_onLoadNewContentCalendar',
}),
/**
* @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) {
var self = this;
this.model.save_changes(_.toArray(ev.data)).then(function(results){
self.renderer.resetSaveState();
});
},
_onLoadNewContentCalendar: function (ev) {
var self = this;
var params = this.renderer.generate_params();
var oparams = [params['dates'][0], params['dates'][1], params['prices'], params['restrictions'], false];
this.model.get_hcalendar_data(oparams).then(function(results){
self.renderer._days_tooltips = results['events'];
self.renderer._hcalendar.setData(results['prices'], results['restrictions'], results['availability'], results['count_reservations']);
self.renderer._assign_extra_info();
});
this.renderer._last_dates = params['dates'];
this.renderer.$CalendarHeaderDays = this.renderer.$el.find("div.table-room_type-data-header");
this.renderer._on_scroll(); // FIXME: Workaround for update sticky header
},
_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 HRoomType(
r['id'],
r['name'],
r['capacity'],
r['price'],
);
rooms.push(nroom);
}
// Get Pricelists
self.renderer._pricelist_id = results['pricelist_id'];
self.renderer._restriction_id = results['restriction_id'];
$.when(
self.model.get_pricelist_plans(),
self.model.get_restriction_plans(),
).then(function(a1, a2){
self.renderer.loadViewFilters(a1, a2);
})
self.renderer.create_calendar(rooms);
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 (notifications) {
if (!this.renderer._hcalendar) {
return;
}
for (var notif of notifications) {
if (notif[0][1] === 'hotel.reservation') {
switch (notif[1]['type']) {
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(HotelConstants.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 room_type
var restriction = notif[1]['restriction'];
var room_type = Object.keys(restriction)[0];
var day = Object.keys(restriction[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day);
var rest = {};
rest[room_type] = [{
'date': dt.format(HotelConstants.ODOO_DATE_MOMENT_FORMAT),
'min_stay': restriction[room_type][day][0],
'min_stay_arrival': restriction[room_type][day][1],
'max_stay': restriction[room_type][day][2],
'max_stay_arrival': restriction[room_type][day][3],
'closed': restriction[room_type][day][4],
'closed_arrival': restriction[room_type][day][5],
'closed_departure': restriction[room_type][day][6],
'id': restriction[room_type][day][7]
}];
this.renderer._hcalendar.addRestrictions(rest);
break;
}
}
}
},
});
return MPMSCalendarController;
});

View File

@@ -1,72 +0,0 @@
// 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) {
// params.splice(0, 0, false); // FIXME: ID=False because first parameter its an integer
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_pricelist_plans: function () {
var domain = [['pricelist_type', '=', 'daily']];
domain.push('|',['hotel_ids', 'in', Session.hotel_id],
['hotel_ids', '=', false]);
return this._rpc({
model: 'product.pricelist',
method: 'search_read',
args: [domain, ['id','name']],
context: Session.user_context,
});
},
get_restriction_plans: function () {
var domain = [['hotel_id', '=', Session.hotel_id]];
return this._rpc({
model: 'hotel.room.type.restriction',
method: 'search_read',
args: [domain, ['id','name']],
context: Session.user_context,
});
},
get_hcalendar_settings: function () {
return this._rpc({
model: this.modelName,
method: 'get_hcalendar_settings',
args: [false],
});
},
});
});

View File

@@ -1,512 +0,0 @@
/* 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 **/
get_values_to_save: function() {
var btn_save = this.$el.find('#btn_save_changes');
if (!btn_save.hasClass('need-save')) {
return false;
}
var pricelist = this._hcalendar.getPricelist(true);
var restrictions = this._hcalendar.getRestrictions(true);
var params = this.generate_params();
return [params['prices'], params['restrictions'], pricelist, restrictions];
},
save_changes: function() {
var oparams = this.get_values_to_save();
if (oparams) {
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-room_type-data-header");
// Sticky Header Days
$('.o_content').scroll(this._on_scroll.bind(this));
// Initialize Save Button state to disable
document.getElementById("btn_save_changes").disabled = true;
},
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 $dateTimePickerBegin = self.$el.find('#mpms-search #date_begin');
$dateTimePickerBegin.data("ignore_onchange", true);
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
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');
document.getElementById("btn_save_changes").disabled = false;
} else {
btn_save.removeClass('need-save');
document.getElementById("btn_save_changes").disabled = true;
}
});
},
_on_scroll: function() {
var curScrollPos = $('.o_content').scrollTop();
if (curScrollPos > 0) {
this.$CalendarHeaderDays.css({
top: `${curScrollPos-this.$ehcal.position().top}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 DTPickerOptions = {
viewMode: 'months',
icons : {
time: 'fa fa-clock-o',
date: 'fa fa-calendar',
up: 'fa fa-chevron-up',
down: 'fa fa-chevron-down'
},
locale : moment.locale(),
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');
$dateTimePickerBegin.datetimepicker(DTPickerOptions);
$dateTimePickerBegin.on("dp.change", function (e) {
$dateTimePickerBegin.data("DateTimePicker").hide(); // TODO: Odoo uses old datetimepicker version
self.on_change_filter_date(e, true);
});
var $dateEndDays = this.$el.find('#mpms-search #date_end_days');
$dateEndDays.select2({
data: [
{id:7, text: '1w'},
{id:12, text: '2w'},
{id:21, text: '3w'},
{id:'month', text: '1m'},
{id:60, text: '2m'},
{id:90, text: '3m'},
],
allowClear: true,
minimumResultsForSearch: -1
});
$dateEndDays.on("change", function (e) {
self.on_change_filter_date();
});
// 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 date_begin = $dateTimePickerBegin.data("DateTimePicker").date().subtract(14, 'd');
$dateTimePickerBegin.data("ignore_onchange", true);
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
self.on_change_filter_date(ev, true);
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 date_begin = $dateTimePickerBegin.data("DateTimePicker").date().subtract(7, 'd');
$dateTimePickerBegin.data("ignore_onchange", true);
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
self.on_change_filter_date(ev, true);
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 date_begin = $dateTimePickerBegin.data("DateTimePicker").date().add(14, 'd');
$dateTimePickerBegin.data("ignore_onchange", true);
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
self.on_change_filter_date(ev, true);
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 date_begin = $dateTimePickerBegin.data("DateTimePicker").date().add(7, 'd');
$dateTimePickerBegin.data("ignore_onchange", true);
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
self.on_change_filter_date(ev, true);
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 date_begin = moment().startOf('day');
$dateTimePickerBegin.data("ignore_onchange", true);
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
self.on_change_filter_date(ev, true);
ev.preventDefault();
});
// Save Button
this.$el.find("#btn_save_changes").on('click', function(ev) {
document.getElementById(this.id).disabled = true;
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 $dateTimePickerBegin = this.$el.find('#mpms-search #date_begin');
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
var $dateEndDays = this.$el.find('#mpms-search #date_end_days');
$dateEndDays.val('month');
$dateEndDays.trigger('change');
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 $dateEndDays = this.$el.find('#mpms-search #date_end_days');
// FIXME: Hackish onchange ignore (Used when change dates from code)
if ($dateTimePickerBegin.data("ignore_onchange") || $dateEndDays.data("ignore_onchange")) {
$dateTimePickerBegin.data("ignore_onchange", false);
$dateEndDays.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) {
var days = $dateEndDays.val();
if (days === 'month') {
days = date_begin.daysInMonth();
}
var date_end = date_begin.set({'hour': 23, 'minute': 59, 'second': 59}).clone().add(days, 'd');
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() {
this.trigger_up('onLoadNewContentCalendar');
},
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 $dateEndDays = this.$el.find('#mpms-search #date_end_days');
var date_begin = $dateTimePickerBegin.data("DateTimePicker").date().set({'hour': 0, 'minute': 0, 'second': 0}).clone();
var days = $dateEndDays.val();
if (days === 'month') {
days = date_begin.daysInMonth();
}
var date_end = date_begin.set({'hour': 23, 'minute': 59, 'second': 59}).clone().add(days, 'd');
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');
document.getElementById("btn_save_changes").disabled = true;
fnCallback();
return;
}
new Dialog(self, {
title: _t("Unsaved Changes!"),
buttons: [
{
text: _t("Yes, save it"),
classes: 'btn-primary',
close: true,
click: function() {
document.getElementById("btn_save_changes").disabled = true;
self.save_changes();
fnCallback();
}
},
{
text: _t("No"),
close: true,
click: function() {
btn_save.removeClass('need-save');
document.getElementById("btn_save_changes").disabled = true;
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;
});

View File

@@ -1,661 +0,0 @@
/* 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-room_type-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;
debugger;
/** 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 HRoomType(
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.room.type.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 room_type = Object.keys(avail)[0];
var day = Object.keys(avail[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day);
var availability = {};
availability[room_type] = [{
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
'avail': avail[room_type][day][0],
'no_ota': avail[room_type][day][1],
'id': avail[room_type][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 room_type
var restriction = notif[1]['restriction'];
var room_type = Object.keys(restriction)[0];
var day = Object.keys(restriction[room_type])[0];
var dt = HotelCalendarManagement.toMoment(day);
var rest = {};
rest[room_type] = [{
'date': dt.format(ODOO_DATE_MOMENT_FORMAT),
'min_stay': restriction[room_type][day][0],
'min_stay_arrival': restriction[room_type][day][1],
'max_stay': restriction[room_type][day][2],
'max_stay_arrival': restriction[room_type][day][3],
'closed': restriction[room_type][day][4],
'closed_arrival': restriction[room_type][day][5],
'closed_departure': restriction[room_type][day][6],
'id': restriction[room_type][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-room_type-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;
});

View File

@@ -1,93 +0,0 @@
// 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;
});

View File

@@ -1,20 +0,0 @@
// 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: "€",
};
});

View File

@@ -1,398 +0,0 @@
// Copyright 2018 Alexandre Díaz <dev@redneboa.es>
// License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
odoo.define('hotel_calendar.MultiCalendar', function(require) {
'use strict';
var core = require('web.core');
var session = require('web.session');
var Widget = require('web.Widget');
var HotelConstants = require('hotel_calendar.Constants');
var QWeb = core.qweb;
var MultiCalendar = Widget.extend({
_calendars: [],
_calendar_records: [],
_active_index: -1,
_events: {},
_tabs: [],
_dataset: {},
_base: null,
init: function(parent) {
this._super.apply(this, arguments);
},
start: function() {
this._super.apply(this, arguments);
this._create_tabs_panel();
},
on: function(event_name, callback) {
this.$el.on(event_name, callback.bind(this));
},
reset: function() {
for (var i in this._calendars) {
delete this._calendars[i];
}
for (var [$tab, $panel] of this._tabs) {
$tab.remove();
$panel.remove();
}
$('#multicalendar_tabs').remove();
$('#multicalendar_panels').remove();
this._calendars = [];
this._calendar_records = [];
this._tabs = [];
this._datasets = {};
this._active_index = -1;
this._events = {};
},
get_calendar: function(index) {
return this._calendars[index-1];
},
get_calendar_record: function(index) {
return this._calendar_records[index-1];
},
get_tab: function(index) {
return this._tabs[index];
},
get_active_index: function() {
return this._active_index;
},
get_active_calendar: function() {
return this._calendars[this._active_index-1];
},
get_active_tab: function() {
return this._tabs[this._active_index];
},
update_active_tab_name: function(name) {
var [$tab, $panel] = this.get_tab(this.get_active_index());
$tab.text(name);
},
get_active_filters: function() {
var calendar = this.get_active_calendar();
var domain = calendar.getDomain(HotelCalendar.DOMAIN.ROOMS);
var filters = {};
for (var rule of domain) {
filters[rule[0]] = rule[2];
}
return filters;
},
recalculate_reservation_positions: function() {
var active_calendar = this.get_active_calendar();
if (active_calendar) {
setTimeout(function(calendar){
calendar._updateOffsets();
calendar._updateReservations(false);
}.bind(this, active_calendar), 200);
}
},
remove_reservation: function(reserv_id) {
this._dataset['reservations'] = _.reject(this._dataset['reservations'], {id: reserv_id});
for (var calendar of this._calendars) {
var reserv = calendar.getReservation(reserv_id);
if (reserv) {
calendar.removeReservation(reserv);
}
}
},
remove_extra_room_row: function(reserv, only_active_calendar) {
if (only_active_calendar) {
this.get_active_calendar().removeExtraRoomRow(reserv);
} else {
for (var calendar of this._calendars) {
calendar.removeExtraRoomRow(reserv);
}
}
},
swap_reservations: function(outReservs, inReservs) {
for (var calendar of this._calendars) {
calendar.swapReservations(outReservs, inReservs);
}
},
set_active_calendar: function(index) {
this._tabs[index+1][0].tab('show');
},
set_datasets: function(pricelist, restrictions, reservations) {
this._dataset = {
pricelist: pricelist,
restrictions: restrictions,
reservations: reservations,
};
},
set_options: function(options) {
this._options = options;
},
set_base_element: function(element) {
this._base = element;
},
merge_pricelist: function(pricelist, calendar) {
var keys = _.keys(pricelist);
for (var k of keys) {
var pr = pricelist[k];
for (var pr_k in pr) {
var pr_item = pricelist[k][pr_k];
var pr_fk = _.findKey(this._dataset['pricelist'][k], {'room': pr_item.room});
if (pr_fk) {
this._dataset['pricelist'][k][pr_fk].room = pr_item.room;
this._dataset['pricelist'][k][pr_fk].days = _.extend(this._dataset['pricelist'][k][pr_fk].days, pr_item.days);
if (pr_item.title) {
this._dataset['pricelist'][k][pr_fk].title = pr_item.title;
}
} else {
if (!(k in this._dataset['pricelist'])) {
this._dataset['pricelist'][k] = [];
}
this._dataset['pricelist'][k].push({
'room': pr_item.room,
'days': pr_item.days,
'title': pr_item.title
});
}
}
}
if (!calendar) {
for (var calendar of this._calendars) {
calendar.setPricelist(this._dataset['pricelist']);
}
} else {
calendar.setPricelist(this._dataset['pricelist']);
}
},
merge_restrictions: function(restrictions, calendar) {
var room_type_ids = Object.keys(restrictions);
for (var vid of room_type_ids) {
if (vid in this._dataset['restrictions']) {
this._dataset['restrictions'][vid] = _.extend(this._dataset['restrictions'][vid], restrictions[vid]);
}
else {
this._dataset['restrictions'][vid] = restrictions[vid];
}
}
if (!calendar) {
for (var calendar of this._calendars) {
calendar.setRestrictions(this._dataset['restrictions']);
}
} else {
calendar.setRestrictions(this._dataset['restrictions']);
}
},
merge_reservations: function(reservations, calendar) {
for (var r of reservations) {
var rindex = _.findKey(this._dataset['reservations'], {'id': r.id});
if (rindex) {
this._dataset['reservations'][rindex] = r;
} else {
this._dataset['reservations'].push(r);
}
}
if (!calendar) {
for (var calendar of this._calendars) {
calendar.addReservations(reservations);
}
} else {
calendar.addReservations(reservations);
}
},
merge_days_tooltips: function(new_tooltips) {
for (var nt of new_tooltips) {
var fnt = _.find(this._days_tooltips, function(item) { return item['id'] === nt['id']});
if (fnt) {
fnt = nt;
} else {
this._days_tooltips.push(nt);
}
}
},
create_calendar: function(calendar_record) {
var [$tab, $panel] = this._create_tab(calendar_record['name'], `calendar-pane-${calendar_record['name']}`);
var calendar = new HotelCalendar(
$panel[0],
this._options,
this._dataset['pricelist'],
this._dataset['restrictions'],
this._base);
this._assign_calendar_events(calendar);
this._assign_extra_info(calendar);
calendar.setReservations(this._dataset['reservations']);
this._calendars.push(calendar);
this._calendar_records.push(calendar_record);
return this._calendars.length-1;
},
on_calendar: function(event_name, callback) {
this._events[event_name] = callback;
},
_create_tab: function(name, id, options) {
var self = this;
var sanitized_id = this._sanitizeId(id);
var $tab = $('<a/>', _.extend({
id: this._sanitizeId(name),
href: `#${sanitized_id}`,
text: name,
role: 'tab',
}, options)).data('tabindex', this._tabs.length).appendTo($('<li/>').prependTo(this.$tabs));
$tab.on('shown.bs.tab', function(ev){
self._active_index = $(ev.target).data('tabindex');
self.recalculate_reservation_positions();
if (ev.relatedTarget) {
var prev_index = $(ev.relatedTarget).data('tabindex');
if (prev_index) {
self.get_calendar(prev_index).cancelSwap();
}
}
self.$el.trigger('tab_changed', [self._active_index]);
});
$tab[0].dataset.toggle = 'tab';
var $panel = $('<div/>', {
id: sanitized_id,
class: 'tab-pane',
role: 'tabpanel'
}).appendTo(this.$tabs_content);
this._tabs.push([$tab, $panel]);
return this._tabs[this._tabs.length-1];
},
_create_tabs_panel: function() {
var self = this;
this.$el.empty();
this.$tabs = $('<ul/>', {
class: 'nav nav-tabs',
id: 'multicalendar_tabs'
}).appendTo(this.$el);
this.$tabs_content = $('<div/>', {
class: 'tab-content',
id: 'multicalendar_panels'
}).appendTo(this.$el);
// '+' Tab
var [$tab, $panel] = this._create_tab('+', 'default', {class: 'multi-calendar-tab-plus'});
$tab.on('shown.bs.tab', function(ev){
ev.preventDefault();
var calendar_record = {
id: false,
name: `Calendar #${self._calendars.length}`,
segmentation_ids: [],
location_ids: [],
amenity_ids: [],
room_type_ids: []
};
var new_calendar_id = self.create_calendar(calendar_record);
self.set_active_calendar(new_calendar_id);
});
$('<p/>', {
class: 'warn-message',
text: "NO CALENDAR DEFINED!",
}).appendTo($panel);
},
_assign_calendar_events: function(calendar) {
for (var event_name in this._events) {
calendar.addEventListener(event_name, this._events[event_name]);
}
},
_assign_extra_info: function(calendar) {
var self = this;
$(calendar.etable).find('.hcal-cell-room-type-group-item.btn-hcal-left').on("mouseenter", function(){
var $this = $(this);
var room = calendar.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');
} else {
var qdict = {
'room_type_name': room.getUserData('room_type_name'),
'name': room.number
};
$this.tooltip({
animation: true,
html: true,
placement: 'right',
title: QWeb.render('HotelCalendar.TooltipRoom', qdict)
}).tooltip('show');
}
});
$(calendar.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['date'], HotelConstants.ODOO_DATE_MOMENT_FORMAT);
return ndate.isSame(cdate, 'd');
});
if (data.length > 0) {
$elm.addClass('hcal-event-day');
$elm.append("<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['name'],
'date': item['date'],
'location': item['location']
};
})
};
$this.attr('title', '');
$this.tooltip({
animation: true,
html: true,
placement: 'bottom',
title: QWeb.render('HotelCalendar.TooltipEvent', qdict)
}).tooltip('show');
}
}.bind(elm, data));
}
});
},
_sanitizeId: function(/*String*/str) {
return str.replace(/[^a-zA-Z0-9\-_]/g, '_');
},
});
return MultiCalendar;
});

View File

@@ -1,985 +0,0 @@
/**
* 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'>&times;</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;
}));

View File

@@ -1,537 +0,0 @@
/*
* 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;
}
#cal-pag-prev-plus, #cal-pag-prev, #cal-pag-selector, #cal-pag-next, #cal-pag-next-plus {
min-height: 0px;
}
.hcalendar-container {
display: flex;
flex-flow: column;
}
.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;
font-size: 12px;
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;
}
.btn-hcal { }
.btn-hcal.hcal-cell-current-day {
background-color: #7c7bad66;
color: #654a37;
}
.btn-hcal.hcal-cell-end-week {
background-color: #EDEDED83;
}
.btn-hcal-3d {
border: 1px solid #eaeaea;
border-top-width: 0;
border-bottom-width: 0;
/*border-color: white black black white !important;*/
}
.btn-hcal-flat {
background-color: white;
border: 1px solid #eaeaea;
}
.btn-hcal-left {
background-color: white;
border: 1px solid #eaeaea;
border-left-width: 0;
}
.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: #9b18704d !important;
}
.hcal-table-day {
height: 100%;
border-collapse: collapse !important;
border: 0 dotted #eaeaea;
border-width: 1px 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: 3em;
font-size: 7px;
vertical-align: middle;
font-weight: bold;
border: 0.5px solid #eaeaea !important;
}
.hcal-table-day td:hover:not(.hcal-cell-highlight):not(.hcal-cell-invalid) {
background-color: #FCFEE1 !important;
}
.hcal-cell-current-day {
background-color: #7C7BADA5;
}
.hcal-cell-end-week {
background-color: #EDEDED83;
}
.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;
font-size: 12px;
}
.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: 0 double #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: 0 6px;
border-style: solid;
}
.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-invalid-unify {
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-unify-selected {
background-color: #005B96 !important;
border-color: #99bdd5 !important;
}
.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-reservation-unify-selected {
background-color: #005B96 !important;
border-color: #99bdd5 !important;
}
.hcal-reservation-to-divide {
pointer-events: none;
}
.hcal-reservation-divide-l {
background-color: transparent;
border: 2px dashed black;
cursor: copy;
pointer-events: none;
border-color: black;
border-right-style: solid;
position: absolute;
z-index: 9;
}
.hcal-reservation-divide-r {
background-color: transparent;
border: 2px dashed black;
cursor: copy;
pointer-events: none;
border-color: black;
border-left-style: solid;
position: absolute;
z-index: 9;
}
.hcal-row-room-type-group-item {
text-align: center;
}
tr.hcal-row-room-type-group-overbooking-item td {
background-color: #fccc9f;
}
tr.hcal-row-room-type-group-cancelled-item td {
background-color: #fcebeb;
}
.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: smaller;
white-space: nowrap;
text-overflow: ellipsis;
}
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;
font-size: 10px;
}
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-radius: 0px;
}
.input-price {
width: 100%;
border-style: none !important;
border-radius: 0 !important;
text-align: center;
}
.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 */
}

View File

@@ -1,198 +0,0 @@
/*
* Hotel Calendar Management JS v0.0.1a - 2017
* GNU Public License
* Aloxa Solucions S.L. <info@aloxa.eu>
* Alexandre Díaz <alex@aloxa.eu>
*/
#pms-search-cal-pag {
text-align: center;
}
#mpms-search {
padding: 0.5em;
}
.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: 130px;
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: 58px !important;
}
.hcal-management-medium > tbody > tr > td, .hcal-management-medium > table > tbody > tr > td {
height: 80px !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-room_types {
flex: 1 1 auto;
margin-top: 1.2em;
}
.table-room_type-data-header {
z-index: 1;
}
.table-room_type-data-header .hcal-management-table tr td {
background-color: white;
}
#hcal_management_widget {
overflow: auto;
display: flex;
}
#hcal-management-container-dd {
overflow: auto;
flex: 1 1 auto;
}
#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;
}
.filter-title {
overflow: hidden;
text-overflow: ellipsis;
}
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;
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,551 +0,0 @@
//! 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});

View File

@@ -1,81 +0,0 @@
<?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" 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>
</button>
</td>
<td class="col-xs-2 col-lg-2">
<select class="list form-control" id="price_list"/>
<select class="list form-control" id="restriction_list"/>
</td>
<td class="col-xs-4 col-lg-4">
<table style="margin: 0 auto">
<tbody>
<tr>
<td>
<span class="filter-title">FROM</span>
<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>
<span class="filter-title">RANGE</span>
<div class="input-group date">
<input id="date_end_days" required="required" class="form-control" />
</div>
<!-- <span class="filter-title">TO</span><br/>-->
<!-- <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>
</td>
<td class="col-xs-1 col-lg-1">
<strong class="filter-title">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" id="pms-search-cal-pag">
<button id="cal-pag-prev-plus" class="btn btn-sm"><i class="fa fa-2x fa-angle-double-left"></i></button>
<button id="cal-pag-prev" class="btn btn-sm"><i class="fa fa-2x fa-angle-left"></i></button>
<button id="cal-pag-selector" class="btn btn-sm"><i class="fa fa-2x fa-calendar"></i></button>
<button id="cal-pag-next" class="btn btn-sm"><i class="fa fa-2x fa-angle-right"></i></button>
<button id="cal-pag-next-plus" class="btn btn-sm"><i class="fa fa-2x fa-angle-double-right"></i></button>
</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>
</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>

View File

@@ -1,378 +0,0 @@
<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="oadults != nadults">
<strong>Adults:</strong> <t t-esc="oadults"/><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="oadults != nadults">
<strong>Adults:</strong> <t t-esc="nadults"/><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.ConfirmSplitOperation">
<div class="content">
<p>The following changes will be made...</p>
<span><strong>Split Reservation</strong></span><br/>
<p>Are you sure you want to make this changes?</p>
</div>
</t>
<t t-name="HotelCalendar.ConfirmUnifyOperation">
<div class="content">
<p>The following changes will be made...</p>
<span><strong>Unify Reservations</strong></span><br/>
<p>Are you sure you want to make this changes?</p>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.Channel.ota">
<div id="channel_info"></div>
</t>
<t t-name="HotelCalendar.TooltipReservation.Channel.direct">
<div class="row row-eq-height">
<div class="col-sm-12 col-xs-12 bg-gray-light">
Sales Channel: <b class="mt-10"><t t-esc="channel_type"/></b>
</div>
</div>
<div class="row row-eq-height">
<div class="col-sm-12 col-xs-12 bg-gray-light">
<t t-if="channel_type =='call'">
TODO: add call center information
</t>
</div>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.Customer">
<div class="row row-eq-height">
<div class="col-sm-6 col-xs-6 bg-gray-light">
<i class="fa fa-user-circle fa-2x fa-pull-left mt-5"/>
<header><t t-esc="name"/></header>
<p><t t-esc="phone"/></p>
<p class="email"><t t-esc="email"/></p>
</div>
<div class="col-sm-6 col-xs-6 bg-gray-lighter">
<i class="fa fa-hotel fa-2_5x fa-pull-left mt-5 text-gray-dark"/>
<header class="mt-5"><t t-esc="room_type_name"/></header>
<p><t t-esc="board_service_name"/></p>
<span class="circle pull-left" id="price_room">
<t t-if="!splitted">
<t t-esc="price_room_services_set" t-widget="monetary"/>
</t>
<t t-else="">
<i class="fa fa-chain-broken fa-1_5x pt-9"/>
</t>
</span>
<p>Adults: <t t-esc="adults"/></p>
<p class="children">Children: <t t-esc="children"/></p>
</div>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.Sale">
<div class="row row-eq-height mt-3">
<div id="folio_pending_amount"
t-attf-class="col-sm-6 col-xs-6 bg-gray-light pb-3 pr-0 diagonal {{pending_amount gt 0 ? 'diagonal_pending_amount':''}}">
<div class="on-top">
<div class="pull-left">
<p>Folio Pending</p>
<t t-if="pending_amount.length > '6'">
<h3 t-attf-style="font-size:calc(22px - #{pending_amount.length}px)"><t t-esc="pending_amount" t-widget="monetary"/></h3> <!-- FIXME: HARD CURRENCY -->
</t>
<t t-else="">
<h3><t t-esc="pending_amount" t-widget="monetary"/></h3> <!-- FIXME: HARD CURRENCY -->
</t>
</div>
<div class="pull-right-custom">
<t t-if="invoices_paid.length > '6'">
<h3 t-attf-style="font-size:calc(22px - #{invoices_paid.length}px)"><t t-esc="invoices_paid" t-widget="monetary"/></h3> <!-- FIXME: HARD CURRENCY -->
</t>
<t t-else="">
<h3><t t-esc="invoices_paid" t-widget="monetary"/></h3> <!-- FIXME: HARD CURRENCY -->
</t>
<p>Total Paid</p>
</div>
</div>
</div>
<div class="col-sm-6 col-xs-6 bg-gray-light">
<t t-if="channel_type == 'web'">
<t t-call="HotelCalendar.TooltipReservation.Channel.ota"/>
</t>
<t t-else="">
<t t-call="HotelCalendar.TooltipReservation.Channel.direct"/>
</t>
</div>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.Dates">
<div class="row row-eq-height mt-3">
<div class="col-sm-12 col-xs-12 triangle-right">
<div class="col-sm-6 col-xs-6 px-0">
<i class="fa fa-sign-in fa-2x fa-pull-left pl-5 py-5"/>
<h3><t t-esc="checkin"/></h3>
<p><t t-esc="checkin_day_of_week"/> <t t-esc="arrival_hour"/></p>
</div>
<div class="col-sm-6 col-xs-6 text-gray-dark">
<i class="fa fa-sign-out fa-2x fa-pull-left pl-5 py-5"/>
<h3><t t-esc="checkout"/></h3>
<p><t t-esc="checkout_day_of_week"/> <t t-esc="departure_hour"/></p>
</div>
</div>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.Footer">
<div class="row row-eq-height mt-10">
<div class="col-sm-4 btn_popover_open_folio pr-0">
<i class="fa fa-file-text-o fa-2x fa-pull-left" role="button"
title="View Folio Details"> <span class="fa-text-inside"><t t-esc="folio_name"/></span></i>
</div>
<div class="col-sm-2 btn_popover_open_reservation">
<span class="fa fa-suitcase fa-2x" role="button"
title="View Reservation Details" />
</div>
<div class="col-sm-2 btn_popover_open_checkin">
<span class="fa fa-user-plus fa-2x" role="button"
title="Checkin" />
</div>
<div class="col-sm-2">
<span class="fa fa-envelope fa-2x" role="button"
title="Send Reservation Email" />
</div>
<div class="col-sm-2 btn_popover_open_payment_folio" data-toggle="collapse" data-target="#payment_reservation">
<span class="fa fa-money fa-2x" role="button"
title="Folio Payments" id="payment_folio" />
<span class="fa fa-money fa-2x collapse btn_popover_open_payment_reservation" role="button"
title="Reservation Payments" id="payment_reservation" />
</div>
<t t-if="reservation_type =='normal'">
<div class="col-sm-2 btn_popover_open_invoice">
<span class="fa fa-pencil-square-o fa-2x" role="button"
title="Invoice Folio" />
</div>
</t>
</div>
<div class="row row-eq-height mt-10">
<div class="col-sm-12">
<t t-if="services">
<t t-foreach='services' t-as='ps'>
<i class="fa fa-exclamation-circle"/> <t t-esc='ps'/>
</t>
</t>
<t t-if="splitted">
<p><i class="fa fa-exclamation-circle"/> This reservation is part of splitted reservation.</p>
</t>
</div>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.normal">
<div class="container">
<t t-call="HotelCalendar.TooltipReservation.Customer"/>
<t t-call="HotelCalendar.TooltipReservation.Sale"/>
<t t-call="HotelCalendar.TooltipReservation.Dates"/>
<t t-call="HotelCalendar.TooltipReservation.Footer"/>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.staff">
<div class="container">
<div class="row row-eq-height">
<div class="col-sm-6 col-xs-6 bg-danger">
<i class="fa fa-black-tie fa-2x fa-pull-left mt-5"/>
<header><t t-esc="name"/></header>
<p><t t-esc="phone"/></p>
<p class="email"><t t-esc="email"/></p>
</div>
<div class="col-sm-6 col-xs-6 bg-gray-lighter">
<i class="fa fa-hotel fa-2_5x fa-pull-left mt-5"/>
<header class="mt-5"><t t-esc="room_type_name"/></header>
<p><t t-esc="board_service_name"/></p>
<p>Adults: <t t-esc="adults"/></p>
<p class="children">Children: <t t-esc="children"/></p>
</div>
</div>
<t t-call="HotelCalendar.TooltipReservation.Dates"/>
<t t-call="HotelCalendar.TooltipReservation.Footer"/>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation.out">
<div class="container">
<div class="row row-eq-height">
<div class="col-sm-6 col-xs-6 bg-gray-lighter">
<i class="fa fa-ban fa-2x fa-pull-left"/>
<header><t t-esc="name"/></header>
<p><t t-esc="out_service_description"/></p>
</div>
<div class="col-sm-6 col-xs-6 bg-gray-light">
<i class="fa fa-hotel fa-2x fa-pull-left"/>
<header><t t-esc="room_type_name"/></header>
<p><t t-esc="closure_reason"/></p>
</div>
</div>
<t t-call="HotelCalendar.TooltipReservation.Dates"/>
<div class="row row-eq-height my-10">
<div class="col-sm-4 btn_popover_open_folio">
<i class="fa fa-file-text-o fa-2x fa-pull-left" role="button"
title="View Folio Details"> <span class="fa-text-inside"><t t-esc="folio_name"/></span></i>
</div>
<div class="col-sm-2 btn_popover_open_reservation">
<span class="fa fa-suitcase fa-2x" role="button"
title="View Reservation Details" />
</div>
</div>
</div>
</t>
<t t-name="HotelCalendar.TooltipReservation">
<t t-call="HotelCalendar.TooltipReservation.#{ reservation_type }"/>
</t>
<t t-name="HotelCalendar.TooltipRoom">
<div class="oe_tooltip_string"><t t-esc="name"/></div>
<p><b>Room Type:</b> <t t-esc="room_type_name"/></p>
</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_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>
</t>
</template>

View File

@@ -1,146 +0,0 @@
<?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 o_hotel_calendar_view">
<div class="col-lg-2 hidden-xs hidden-sm" id="pms-menu">
<div class="row nopadding menu-date-box">
<div class="form-group nopadding col-xs-8 col-md-8">
<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>
</div>
<div class="form-group nopadding col-xs-4 col-md-4">
<input id="date_end_days" required="required" class="pull-right" />
</div>
</div>
<div class="col-xs-12 col-md-12 nopadding menu-button-box">
<div class="col-xs-6 col-md-6" id="btn_action_checkout">
<button class="btn btn-default col-xs-12 col-md-12 button-box" data-action="hotel_calendar.hotel_reservation_action_checkout">
<i class="fa fa-fw o_button_icon fa-sign-out"> </i>
<div class="o_button_text">
<span class="ninfo">0</span><br/>
<span class="text-hidden-xs">Checkouts</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_action_checkin">
<button class="btn btn-default col-xs-12 col-md-12 button-box" data-action="hotel_calendar.hotel_reservation_action_checkin">
<i class="fa fa-fw o_button_icon fa-sign-in"> </i>
<div class="o_button_text">
<span class="ninfo">0</span><br/>
<span class="text-hidden-xs">Checkins</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_swap">
<button class="btn btn-default col-xs-12 col-md-12 button-box">
<div class='led led-disabled'></div>
<i class="fa fa-fw o_button_icon fa-retweet"> </i>
<div class="o_button_text">
<span class="text-hidden-xs ntext">Start Swap</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_action_control">
<button class="btn btn-default col-xs-12 col-md-12 button-box" data-action="hotel.open_wizard_reservations">
<i class="fa fa-fw o_button_icon fa-magic"> </i>
<div class="o_button_text">
<span class="text-hidden-xs">Wizard</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_action_overbooking">
<button class="btn btn-default col-xs-12 col-md-12 button-box">
<div class='led led-disabled'></div>
<i class="fa fa-fw o_button_icon fa-clock-o"> </i>
<div class="o_button_text">
<span class="ninfo">0</span><br/>
<span class="text-hidden-xs">Overbook.</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_action_cancelled">
<button class="btn btn-default col-xs-12 col-md-12 button-box">
<div class='led led-disabled'></div>
<i class="fa fa-fw o_button_icon fa-calendar-times-o"> </i>
<div class="o_button_text">
<span class="ninfo">0</span><br/>
<span class="text-hidden-xs">Cancelled</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_action_divide">
<button class="btn btn-default col-xs-12 col-md-12 button-box">
<div class='led led-disabled'></div>
<i class="fa fa-fw o_button_icon fa-scissors"> </i>
<div class="o_button_text">
<span class="text-hidden-xs">Divide</span>
</div>
</button>
</div>
<div class="col-xs-6 col-md-6" id="btn_action_unify">
<button class="btn btn-default col-xs-12 col-md-12 button-box">
<div class='led led-disabled'></div>
<i class="fa fa-fw o_button_icon fa-compress"> </i>
<div class="o_button_text">
<span class="text-hidden-xs">Unify</span>
</div>
</button>
</div>
</div>
<div class="col-xs-12 col-md-12 nopadding menu-search-box">
<div class="input-group">
<input type="edit" id="bookings_search" placeholder="Name, Mail, Vat, Book..." class="form-control extra-search" />
<span class="input-group-addon bg-primary">
<span class="fa fa-search"></span>
</span>
</div>
<button class="btn btn-primary col-xs-6 col-md-6" id="btn_action_bookings">
Books
</button>
<button class="btn btn-primary col-xs-6 col-md-6" id="btn_action_checkins">
Checkins
</button>
<button class="btn btn-primary col-xs-6 col-md-6" id="btn_action_invoices">
Invoices
</button>
<button class="btn btn-primary col-xs-6 col-md-6" id="btn_action_folios">
Folios
</button>
</div>
<div class="col-xs-12 col-md-12 nopadding menu-filter-box">
<h4 data-toggle="collapse" data-target="#filters"><i class="fa fa-chevron-circle-right"></i> Filters</h4>
<div id="filters" class="collapse">
<select class="form-control" id="type_list" placeholder="Select Segmentation..." multiple="multiple"/>
<select class="list form-control" id="floor_list" placeholder="Select Location..." multiple="multiple"/>
<select class="list form-control" id="amenities_list" placeholder="Select Amenities..." multiple="multiple"/>
<select class="list form-control" id="virtual_list" placeholder="Select Type..." multiple="multiple"/>
<div class="filter-record col-xs-12 col-md-12" style="padding:4px">
<div class="col-xs-8 col-md-8 nopadding">
<input type="edit" id="calendar_name" class="form-control" />
</div>
<div class="col-xs-2 col-md-2 nopadding">
<button class="btn btn-primary col-xs-12 col-md-12" id="btn_save_calendar_record">
<i class="fa fa-fw fa-save"> </i>
</button>
</div>
<div class="col-xs-2 col-md-2 nopadding">
<button class="btn btn-primary col-xs-12 col-md-12" id="btn_reload_calendar_filters">
<i class="fa fa-fw fa-refresh"> </i>
</button>
</div>
</div>
</div>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-10 nopadding" id="pms-calendar">
<div id="hcal_widget" class="col-xs-12 col-md-12 nopadding" />
</div>
</div>
</t>
</templates>

View File

@@ -1,2 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).

View File

@@ -1,41 +0,0 @@
# -*- 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.default_pricelist_id = cls.pricelist_1.id
cls.default_restriction_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')

View File

@@ -1,424 +0,0 @@
# -*- 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)
room_types = (self.hotel_room_type_budget, self.hotel_room_type_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.default_pricelist_id,
self.default_restriction_id,
True)
for room_type in room_types:
for k_pr, v_pr in hcal_data['prices'].iteritems():
if k_pr == room_type.id: # Only Check Test Cases
for k_info, v_info in enumerate(v_pr):
if k_info >= len(self.prices_tmp[room_type.id]):
break
self.assertEqual(v_info['price'],
self.prices_tmp[room_type.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_room_type_budget.product_id.product_tmpl_id.id,
self.hotel_room_type_special.product_id.product_tmpl_id.id
)
pr_ids = prices_obj.search([
('pricelist_id', '=', self.default_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.default_pricelist_id,
self.default_restriction_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)
room_types = (self.hotel_room_type_budget, self.hotel_room_type_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.default_pricelist_id,
self.default_restriction_id,
True)
for room_type in room_types:
for k_pr, v_pr in hcal_data['restrictions'].iteritems():
if k_pr == room_type.id: # Only Check Test Cases
for k_info, v_info in enumerate(v_pr):
rest_items = self.restrictions_min_stay_tmp[room_type.id]
if k_info >= len(rest_items):
break
self.assertEqual(
v_info['min_stay'],
self.restrictions_min_stay_tmp[room_type.id][k_info],
"Hotel Calendar Management Restrictions \
doesn't match!")
# REMOVE RESTRICTIONS
rest_it_obj = self.env['hotel.room.type.restriction.item'].sudo(
self.user_hotel_manager)
rest_ids = rest_it_obj.search([
('restriction_id', '=', self.default_restriction_id),
('room_type_id', 'in', (self.hotel_room_type_budget.id,
self.hotel_room_type_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.default_pricelist_id,
self.default_restriction_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)
room_types = (self.hotel_room_type_budget, self.hotel_room_type_special)
hotel_cal_mngt_obj = self.env['hotel.calendar.management'].sudo(
self.user_hotel_manager)
room_type_avail_obj = self.env['hotel.room.type.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.default_pricelist_id,
self.default_restriction_id,
True)
for room_type in room_types:
for k_pr, v_pr in hcal_data['availability'].iteritems():
if k_pr == room_type.id: # Only Check Test Cases
for k_info, v_info in enumerate(v_pr):
if k_info >= len(self.avails_tmp[room_type.id]):
break
self.assertEqual(
v_info['avail'],
self.avails_tmp[room_type.id][k_info],
"Hotel Calendar Management Availability \
doesn't match!")
# CHANGE AVAIL
avail_ids = room_type_avail_obj.search([
('room_type_id', 'in', (self.hotel_room_type_budget.id,
self.hotel_room_type_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.default_pricelist_id,
self.default_restriction_id,
True)
for room_type in room_types:
for k_pr, v_pr in hcal_data['availability'].iteritems():
if k_pr == room_type.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 = room_type_avail_obj.search([
('room_type_id', 'in', (self.hotel_room_type_budget.id,
self.hotel_room_type_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.default_pricelist_id,
self.default_restriction_id,
True)
for room_type in room_types:
for k_pr, v_pr in hcal_data['availability'].iteritems():
if k_pr == room_type.id: # Only Check Test Cases
for k_info, v_info in enumerate(v_pr):
self.assertEqual(
v_info['avail'],
room_type.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)
room_types = (self.hotel_room_type_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_room_type_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_room_type_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_room_type_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.default_pricelist_id,
self.default_restriction_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.default_pricelist_id,
self.default_restriction_id,
True)
for room_type in room_types:
for k_pr, v_pr in hcal_data['availability'].iteritems():
if k_pr == room_type.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 == room_type.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 == room_type.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)
room_types = (self.hotel_room_type_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.default_pricelist_id,
self.default_restriction_id,
True)
avail_end_utc_dt = reserv_end_utc_dt - timedelta(days=1)
for room_type in room_types:
for k_pr, v_pr in hcal_data['count_reservations'].iteritems():
if k_pr == room_type.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.default_pricelist_id,
self.default_restriction_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.default_pricelist_id,
self.default_restriction_id,
True)
with self.assertRaises(ValidationError):
hcal_data = hotel_cal_mngt_obj.get_hcalendar_all_data(
False,
False,
self.default_pricelist_id,
self.default_restriction_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 default 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")

View File

@@ -1,66 +0,0 @@
# -*- 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)
room_type_tmpl_id = self.hotel_room_type_special.product_id.product_tmpl_id
pritem_obj = self.env['product.pricelist.item']
plitem = pritem_obj.search([
('pricelist_id', '=', self.default_pricelist_id),
('product_tmpl_id', '=', room_type_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_room_type_special.id,
now_utc_str,
999.9)
plitem = pritem_obj.search([
('pricelist_id', '=', self.default_pricelist_id),
('product_tmpl_id', '=', room_type_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")

View File

@@ -1,289 +0,0 @@
# -*- 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 room_type_pr in v_pr:
# Only Check Test Cases
if room_type_pr['room'] in self.prices_tmp.keys():
sorted_dates = sorted(
room_type_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!")
room_type_prices = self.prices_tmp[room_type_pr['room']]
for k_price, v_price in enumerate(room_type_prices):
self.assertEqual(
v_price,
room_type_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.default_pricelist_id),
('product_tmpl_id', 'in', (
self.hotel_room_type_budget.product_id.product_tmpl_id.id,
self.hotel_room_type_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))
room_types = (self.hotel_room_type_budget, self.hotel_room_type_special)
for room_type in room_types:
for k_pr, v_pr in hcal_data['pricelist'].iteritems():
for room_type_pr in v_pr:
if room_type_pr['room'] == room_type.id: # Only Check Test Cases
self.assertEqual(
room_type.list_price,
room_type_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(
'res.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(
'res.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")

View File

@@ -1,28 +0,0 @@
<?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_mode">tree,form</field>
<field name="domain">[('real_checkin','=', datetime.datetime.now().strftime('%Y-%m-%d')),
('state', 'in', ['confirm']),
('reservation_type', 'not in', ['out'])]</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_mode">tree,form</field>
<field name="domain">[('real_checkout','=', datetime.datetime.now().strftime('%Y-%m-%d')),
('state', 'in', ['booking']),
('reservation_type', 'not in', ['out'])]</field>
</record>
<record model="ir.actions.act_window" id="hotel_calendar_action_form_tree">
<field name="name">Hotel Calendar</field>
<field name="res_model">hotel.calendar</field>
<field name="view_mode">tree,form</field>
</record>
</odoo>

View File

@@ -1,32 +0,0 @@
<?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/lib/hcalendar/js/hcalendar.js"></script>
<script type="text/javascript" src="/hotel_calendar/static/src/js/widgets/MultiCalendar.js"></script>
<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>
</xpath>
</template>
</odoo>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0"?>
<odoo>
<record model="ir.ui.view" id="hotel_calendar_management_view_mpms">
<field name="name">hotel.calendar.management.mpms</field>
<field name="model">hotel.calendar.management</field>
<field name="arch" type="xml">
<mpms></mpms>
</field>
</record>
</odoo>

View File

@@ -1,38 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Form view of hotel room -->
<record model="ir.ui.view" id="hotel_calendar_view_form">
<field name="name">hotel.calendar.form</field>
<field name="model">hotel.calendar</field>
<field name="arch" type="xml">
<form string="Hotel Calendar">
<sheet>
<group>
<field name="name" />
<field name="hotel_id" invisible="0"/>
</group>
<group>
<field name="segmentation_ids" />
<field name="location_ids" />
<field name="amenity_ids" />
<field name="room_type_ids" />
</group>
</sheet>
</form>
</field>
</record>
<!-- Tree view of hotel room -->
<record model="ir.ui.view" id="hotel_calendar_view_tree">
<field name="name">hotel.calendar.tree</field>
<field name="model">hotel.calendar</field>
<field name="arch" type="xml">
<tree string="Hotel Calendar">
<field name="hotel_id" />
<field name="name" />
</tree>
</field>
</record>
</odoo>

View File

@@ -1,12 +0,0 @@
<?xml version="1.0"?>
<odoo>
<record model="ir.ui.view" id="hotel_reservation_view_pms">
<field name="name">hotel.reservation.pms</field>
<field name="model">hotel.reservation</field>
<field name="arch" type="xml">
<pms></pms>
</field>
</record>
</odoo>

View File

@@ -1,31 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="hotel_property_views_form" model="ir.ui.view">
<field name="model">hotel.property</field>
<field name="inherit_id" ref="hotel.hotel_property_views_form" />
<field name="arch" type="xml">
<xpath expr="//page[@name='hotel_settings']" position="after">
<page string='Calendar Settings' name="hotel_calendar">
<group colspan="4">
<group string="Rooms and Reservations">
<field name="pms_show_num_rooms" />
<field name="pms_divide_rooms_by_capacity" />
<field name="pms_type_move" required="True" />
</group>
<group string="Calendar (PMS)">
<field name="pms_end_day_week" required="True" />
<field name="pms_end_day_week_offset" required="True" />
<field name="pms_default_num_days" required="True" />
</group>
<group string="Events">
<field name="pms_allowed_events_tags" widget="many2many_tags" />
<field name="pms_denied_events_tags" widget="many2many_tags" />
</group>
</group>
</page>
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0"?>
<odoo>
<record id="room_type_view_form" model="ir.ui.view">
<field name="model">hotel.room.type</field>
<field name="inherit_id" ref="hotel.hotel_room_type_view_form" />
<field name="arch" type="xml">
<xpath expr="//field[@name='name']" position="after">
<field name="hcal_sequence" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,14 +0,0 @@
<?xml version="1.0"?>
<odoo>
<record id="hotel_room_view_form" model="ir.ui.view">
<field name="model">hotel.room</field>
<field name="inherit_id" ref="hotel.hotel_room_view_form" />
<field name="arch" type="xml">
<xpath expr="//div[hasclass('oe_title')]" position="inside">
<field name="hcal_sequence" />
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,43 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<!-- Hotel Settings -->
<record id="res_company_view_form" model="ir.ui.view">
<field name="name">view.company.form</field>
<field name="model">res.company</field>
<field name="inherit_id" ref="base.view_company_form"/>
<field name="arch" type="xml">
<xpath expr="//page" position="after">
<page string="Hotel Preferences" name="hotel_preferences">
<group>
<group string="Reservation Background Colors">
<field name="color_pre_reservation" widget="color" />
<field name="color_reservation" widget="color" />
<field name="color_reservation_pay" widget="color" />
<field name="color_stay" widget="color" />
<field name="color_stay_pay" widget="color" />
<field name="color_checkout" widget="color" />
<field name="color_dontsell" widget="color" />
<field name="color_staff" widget="color" />
<field name="color_to_assign" widget="color" />
<field name="color_payment_pending" widget="color" />
</group>
<group string="Reservation Letter Colors">
<field name="color_letter_pre_reservation" widget="color" />
<field name="color_letter_reservation" widget="color" />
<field name="color_letter_reservation_pay" widget="color" />
<field name="color_letter_stay" widget="color" />
<field name="color_letter_stay_pay" widget="color" />
<field name="color_letter_checkout" widget="color" />
<field name="color_letter_dontsell" widget="color" />
<field name="color_letter_staff" widget="color" />
<field name="color_letter_to_assign" widget="color" />
<field name="color_letter_payment_pending" widget="color" />
</group>
</group>
</page>
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,20 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<odoo>
<record id="view_users_form_simple_modif" model="ir.ui.view">
<field name="model">res.users</field>
<field name="inherit_id" ref="base.view_users_form_simple_modif" />
<field name="arch" type="xml">
<xpath expr="//group[@name='preferences']" position="after">
<group string="Calendar (PMS) Preferences" name="preferences_calendar">
<group col="8" colspan="4">
<field name="pms_show_notifications" />
<field name="pms_show_pricelist" />
<field name="pms_show_availability" />
</group>
</group>
</xpath>
</field>
</record>
</odoo>

View File

@@ -1,12 +0,0 @@
HOTEL CALENDAR CHANNEL CONNECTOR
===================================
Unify 'hotel_calendar' and 'hotel_channel_connector'
Credits
=======
Creator
------------
* Alexandre Díaz <alex@aloxa.eu>

View File

@@ -1,3 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from . import models

View File

@@ -1,33 +0,0 @@
# Copyright 2018 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
{
'name': 'Hotel Calendar Channel Connector',
'version': '11.0.2.0',
'author': "Alexandre Díaz <dev@redneboa.es>",
'website': 'https://github.com/hootel/hootel',
'category': 'hotel/addon',
'summary': "Hotel Calendar Channel Connector",
'description': "Unify 'hotel_calendar' and 'hotel_channel_connector'",
'depends': [
'hotel_calendar',
'hotel_channel_connector',
],
'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,
'license': 'AGPL-3',
}

View File

@@ -1,88 +0,0 @@
# Translation of Odoo Server.
# This file contains the translation of the following modules:
# * hotel_calendar_channel_connector
#
msgid ""
msgstr ""
"Project-Id-Version: Odoo Server 11.0\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-03-13 21:59+0000\n"
"PO-Revision-Date: 2019-03-13 23:01+0100\n"
"Last-Translator: <>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=(n != 1);\n"
"Language: es\n"
"X-Generator: Poedit 1.8.7.1\n"
#. module: hotel_calendar_channel_connector
#: model:ir.actions.act_window,name:hotel_calendar_channel_connector.calendar_channel_connector_issues_action
msgid "Channel Connector Issues"
msgstr "Aviso de Conexión"
#. module: hotel_calendar_channel_connector
#. openerp-web
#: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_view.xml:30
#, python-format
msgid "Channel:"
msgstr "Canal:"
#. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_channel_connector.model_hotel_reservation
msgid "Hotel Reservation"
msgstr "Reserva del hotel"
#. module: hotel_calendar_channel_connector
#. openerp-web
#: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_view.xml:11
#, python-format
msgid "Issues"
msgstr "Avisos"
#. module: hotel_calendar_channel_connector
#: model:ir.ui.view,arch_db:hotel_calendar_channel_connector.hotel_reservation_view_form
msgid "Mark as Read"
msgstr "Marcar como leído"
#. module: hotel_calendar_channel_connector
#: model:ir.actions.act_window,name:hotel_calendar_channel_connector.hotel_reservation_action_manager_request
msgid "Reservations to Assign from Channel"
msgstr "Reservas por asignar"
#. module: hotel_calendar_channel_connector
#. openerp-web
#: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_templates.xml:4
#, python-format
msgid "Section:"
msgstr "Sección:"
#. module: hotel_calendar_channel_connector
#. openerp-web
#: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_view.xml:20
#, python-format
msgid "To Assign"
msgstr "Por Asignar"
#. module: hotel_calendar_channel_connector
#. openerp-web
#: code:addons/hotel_calendar_channel_connector/static/src/xml/hotel_calendar_templates.xml:11
#, python-format
msgid "WuBook:"
msgstr "WuBook:"
#. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_channel_connector.model_bus_hotel_calendar
msgid "bus.hotel.calendar"
msgstr "bus.hotel.calendar"
#. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_channel_connector.model_hotel_calendar_management
msgid "hotel.calendar.management"
msgstr "hotel.calendar.management"
#. module: hotel_calendar_channel_connector
#: model:ir.model,name:hotel_calendar_channel_connector.model_hotel_room_type_availability
msgid "hotel.room.type.availability"
msgstr "hotel.room.type.availability"

View File

@@ -1,6 +0,0 @@
# Copyright 2018-2019 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_bus_hotel_calendar
from . import inherited_hotel_calendar_management
from . import inherited_hotel_room_type_availability

View File

@@ -1,80 +0,0 @@
# Copyright 2018-2019 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
import logging
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
_logger = logging.getLogger(__name__)
class BusHotelCalendar(models.TransientModel):
_inherit = 'bus.hotel.calendar'
@api.model
def _generate_reservation_notif(self, vals):
notif = super(BusHotelCalendar, self)._generate_reservation_notif(vals)
reserv = self.env['hotel.reservation'].browse(vals['reserv_id'])
if any(reserv.channel_bind_ids):
notif['tooltip'].update({
'ota_name': reserv.channel_bind_ids[0].ota_id.name,
'ota_reservation_id': reserv.channel_bind_ids[0].ota_reservation_id,
'external_id': reserv.channel_bind_ids[0].external_id,
})
elif reserv.splitted and reserv.parent_reservation.channel_bind_ids:
# chunks in splitted reservation has not channel_bind_ids
notif['tooltip'].update({
'ota_name': reserv.parent_reservation.channel_bind_ids[0].ota_id.name,
'ota_reservation_id': reserv.parent_reservation.channel_bind_ids[0].ota_reservation_id,
'external_id': reserv.parent_reservation.channel_bind_ids[0].external_id,
})
return notif
@api.model
def _generate_availability_notification(self, vals):
date_dt = datetime.strptime(vals['date'], DEFAULT_SERVER_DATE_FORMAT)
return {
'type': 'availability',
'availability': {
vals['room_type_id']: {
date_dt.strftime("%d/%m/%Y"): {
'quota': vals['quota'],
'max_avail': vals['max_avail'],
'id': vals['id'],
'no_ota': vals['no_ota'],
'channel_avail': vals['channel_avail'],
},
},
},
}
@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)
@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 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)

View File

@@ -1,107 +0,0 @@
# Copyright 2019 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from datetime import timedelta
from odoo import models, api, fields
from odoo.tools import DEFAULT_SERVER_DATE_FORMAT
class HotelCalendarManagement(models.TransientModel):
_inherit = 'hotel.calendar.management'
@api.model
def _hcalendar_availability_json_data(self, dfrom, dto):
date_start = fields.Date.from_string(dfrom)
date_end = fields.Date.from_string(dto)
date_diff = abs((date_end - date_start).days) + 1
hotel_room_type_avail_obj = self.env['hotel.room.type.availability']
room_types = self.env['hotel.room.type'].search([])
json_data = {}
for room_type in room_types:
json_data[room_type.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 = hotel_room_type_avail_obj.search([
('date', '=', cur_date_str),
('room_type_id', '=', room_type.id)
])
json_data[room_type.id].append(
self._generate_avalaibility_data(room_type, cur_date_str, avail))
return json_data
@api.model
def _generate_avalaibility_data(self, room_type, date, avail):
avalaibility_data = {
'id': False,
'date': date,
'no_ota': False,
'quota': room_type.channel_bind_ids.default_quota,
'max_avail': room_type.channel_bind_ids.default_max_avail,
'channel_avail': room_type.channel_bind_ids.default_availability
}
if avail:
avalaibility_data = {
'id': avail.id,
'date': avail.date,
'no_ota': avail.no_ota,
'quota': avail.quota,
'max_avail': avail.max_avail,
'channel_avail': avail.channel_bind_ids.channel_avail
}
return avalaibility_data
@api.model
def _get_availability_values(self, vals):
vals = {
'quota': vals['quota'],
'max_avail': vals['max_avail'],
'no_ota': vals['no_ota'],
}
return vals
def save_changes(self, pricelist_id, restriction_id, pricelist,
restrictions, availability={}):
res = super(HotelCalendarManagement, self).save_changes(
pricelist_id,
restriction_id,
pricelist,
restrictions,
availability=availability)
room_type_obj = self.env['hotel.room.type']
room_type_avail_obj = self.env['hotel.room.type.availability']
# Save Availability
for k_avail in availability.keys():
room_type_id = room_type_obj.browse(int(k_avail))
for avail in availability[k_avail]:
vals = self._get_availability_values(avail)
avail_id = room_type_avail_obj.search([
('date', '=', avail['date']),
('room_type_id', '=', room_type_id.id),
], limit=1)
if not avail_id:
vals.update({
'date': avail['date'],
'room_type_id': room_type_id.id,
})
avail_id = room_type_avail_obj.with_context({
'mail_create_nosubscribe': True,
}).create(vals)
else:
avail_id.write(vals)
self.env['channel.backend'].cron_push_changes()
return res
@api.model
def get_hcalendar_all_data(self, dfrom, dto, pricelist_id, restriction_id,
withRooms):
res = super(HotelCalendarManagement, self).get_hcalendar_all_data(
dfrom, dto, pricelist_id, restriction_id, withRooms)
json_avails = self._hcalendar_availability_json_data(dfrom, dto)
res.update({
'availability': json_avails or [],
})
return res

View File

@@ -1,58 +0,0 @@
# 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, api
_logger = logging.getLogger(__name__)
class HotelReservation(models.Model):
_inherit = "hotel.reservation"
def _hcalendar_reservation_data(self, reservations):
vals = super(HotelReservation, self)._hcalendar_reservation_data(reservations)
# TODO: Improve performance by doing a SQL as in get_hcalendar_reservations_data()
hotel_reservation_obj = self.env['hotel.reservation']
for v_rval in vals[0]:
reserv = hotel_reservation_obj.browse(v_rval['id'])
v_rval.update({
'fix_days': reserv.splitted or reserv.is_from_ota,
})
# Update tooltips
if any(reserv.channel_bind_ids):
vals[1][reserv.id].update({
'ota_name': reserv.channel_bind_ids[0].ota_id.name,
'ota_reservation_id': reserv.channel_bind_ids[0].ota_reservation_id,
'external_id': reserv.channel_bind_ids[0].external_id,
})
elif reserv.splitted and reserv.parent_reservation.channel_bind_ids:
# chunks in splitted reservation has not channel_bind_ids
vals[1][reserv.id].update({
'ota_name': reserv.parent_reservation.channel_bind_ids[0].ota_id.name,
'ota_reservation_id': reserv.parent_reservation.channel_bind_ids[0].ota_reservation_id,
'external_id': reserv.parent_reservation.channel_bind_ids[0].external_id,
})
# REVIEW: What happens if the reservation is splitted and no parent with channel_bind_ids ¿?
return vals
def generate_bus_values(self, naction, ntype, ntitle=''):
self.ensure_one()
vals = super(HotelReservation, self).generate_bus_values(naction, ntype, ntitle)
vals.update({
'fix_days': self.splitted or self.is_from_ota,
})
if any(self.channel_bind_ids):
vals.update({
'ota_name': self.channel_bind_ids[0].ota_id.name,
'ota_reservation_id': self.channel_bind_ids[0].ota_reservation_id,
'external_id': self.channel_bind_ids[0].external_id,
})
return vals
def confirm(self):
for record in self:
if record.to_assign:
record.write({'to_assign': False})
return super(HotelReservation, self).confirm()

View File

@@ -1,50 +0,0 @@
# Copyright 2018-2019 Alexandre Díaz <dev@redneboa.es>
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl).
from odoo import models, api
class HotelRoomTypeAvailability(models.Model):
_inherit = 'hotel.room.type.availability'
def _prepare_notif_values(self, record):
return {
'date': record.date,
'quota': record.quota,
'no_ota': record.no_ota,
'max_avail': record.max_avail,
'room_type_id': record.room_type_id.id,
'id': record.id,
'channel_avail': record.channel_bind_ids.channel_avail,
}
@api.model
def create(self, vals):
res = super(HotelRoomTypeAvailability, self).create(vals)
self.env['bus.hotel.calendar'].send_availability_notification(
self._prepare_notif_values(res)
)
return res
def write(self, vals):
ret_vals = super(HotelRoomTypeAvailability, self).write(vals)
bus_hotel_calendar_obj = self.env['bus.hotel.calendar']
for record in self:
bus_hotel_calendar_obj.send_availability_notification(
self._prepare_notif_values(record)
)
return ret_vals
def unlink(self):
# Construct dictionary with relevant info of removed records
unlink_vals = []
for record in self:
unlink_vals.append(
self._prepare_notif_values(record)
)
res = super(HotelRoomTypeAvailability, 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

View File

@@ -1 +0,0 @@
* Alexandre Díaz <dev@redneboa.es>

Some files were not shown because too many files have changed in this diff Show More