mirror of
https://github.com/OCA/pms.git
synced 2025-01-29 00:17:45 +02:00
[IMP] Cancelled & Days Option
This commit is contained in:
@@ -83,7 +83,7 @@ input#bookings_search {
|
||||
}
|
||||
|
||||
#pms-menu .menu-button-box, #pms-menu .menu-search-box, #pms-menu .menu-filter-box {
|
||||
margin-top: 2em !important;
|
||||
margin-top: 1em !important;
|
||||
}
|
||||
|
||||
#pms-menu .menu-filter-box .filter-record {
|
||||
@@ -123,9 +123,14 @@ input#bookings_search {
|
||||
}
|
||||
|
||||
/** SELECT 2 **/
|
||||
#pms-menu .select2-container {
|
||||
#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;
|
||||
|
||||
@@ -16,7 +16,6 @@ var AbstractController = require('web.AbstractController'),
|
||||
|
||||
var PMSCalendarController = AbstractController.extend({
|
||||
custom_events: _.extend({}, AbstractController.prototype.custom_events, {
|
||||
onLoadCalendarSettings: '_onLoadCalendarSettings',
|
||||
onLoadViewFilters: '_onLoadViewFilters',
|
||||
onUpdateButtonsCounter: '_onUpdateButtonsCounter',
|
||||
onSwapReservations: '_onSwapReservations',
|
||||
@@ -24,6 +23,8 @@ var PMSCalendarController = AbstractController.extend({
|
||||
onApplyFilters: '_onApplyFilters',
|
||||
}),
|
||||
|
||||
_last_dates: [],
|
||||
|
||||
init: function (parent, model, renderer, params) {
|
||||
this._super.apply(this, arguments);
|
||||
this.displayName = params.displayName;
|
||||
@@ -40,17 +41,11 @@ var PMSCalendarController = AbstractController.extend({
|
||||
var self = this;
|
||||
|
||||
this._multi_calendar.setElement(this.renderer.$el.find('#hcal_widget'));
|
||||
this._multi_calendar.on('tab_changed', function(ev, active_index){
|
||||
if (active_index) {
|
||||
self._refresh_filters(active_index);
|
||||
}
|
||||
});
|
||||
this._multi_calendar.reset();
|
||||
this._multi_calendar.start();
|
||||
|
||||
this._assign_multi_calendar_events();
|
||||
this._load_calendars();
|
||||
this._assign_view_events();
|
||||
this._load_calendar_settings();
|
||||
},
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
@@ -128,8 +123,8 @@ var PMSCalendarController = AbstractController.extend({
|
||||
}
|
||||
|
||||
var options = {
|
||||
startDate: HotelCalendar.toMomentUTC(self.renderer._last_dates[0], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
days: self._view_options['days'] + 1,
|
||||
startDate: HotelCalendar.toMomentUTC(self._last_dates[0], HotelConstants.ODOO_DATETIME_MOMENT_FORMAT),
|
||||
days: self._view_options['days'],
|
||||
rooms: rooms,
|
||||
endOfWeek: parseInt(self._view_options['eday_week']) || 6,
|
||||
divideRoomsByCapacity: self._view_options['divide_rooms_by_capacity'] || false,
|
||||
@@ -173,6 +168,35 @@ var PMSCalendarController = AbstractController.extend({
|
||||
return domain;
|
||||
},
|
||||
|
||||
_load_calendar_settings: function (ev) {
|
||||
var self = this;
|
||||
return this.model.get_hcalendar_settings().then(function(options){
|
||||
self._view_options = options;
|
||||
|
||||
if (['xs', 'md'].indexOf(self._find_bootstrap_environment()) >= 0) {
|
||||
self._view_options['days'] = 7;
|
||||
}
|
||||
|
||||
var date_begin = moment().startOf('day');
|
||||
var days = self._view_options['days'];
|
||||
if (self._view_options['days'] === 'month') {
|
||||
days = date_begin.daysInMonth();
|
||||
}
|
||||
self._last_dates[0] = date_begin.clone();
|
||||
self._last_dates[1] = date_begin.clone().add(days, 'd');
|
||||
|
||||
var $dateTimePickerBegin = self.renderer.$el.find('#pms-menu #date_begin');
|
||||
var $dateEndDays = self.renderer.$el.find('#pms-menu #date_end_days');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateEndDays.val(self._view_options['days']);
|
||||
|
||||
//self.renderer.init_calendar_view();
|
||||
self._load_calendars();
|
||||
self._assign_view_events();
|
||||
});
|
||||
},
|
||||
|
||||
_reload_active_calendar: function() {
|
||||
var self = this;
|
||||
var filterDates = this.renderer.get_view_filter_dates();
|
||||
@@ -180,10 +204,11 @@ var PMSCalendarController = AbstractController.extend({
|
||||
// Clip dates
|
||||
var dfrom = filterDates[0].clone(),
|
||||
dto = filterDates[1].clone();
|
||||
if (filterDates[0].isBetween(this.renderer._last_dates[0], this.renderer._last_dates[1], 'days') && filterDates[1].isAfter(this.renderer._last_dates[1], 'day')) {
|
||||
dfrom = this.renderer._last_dates[1].clone().local().startOf('day').utc();
|
||||
} else if (this.renderer._last_dates[0].isBetween(filterDates[0], filterDates[1], 'days') && this.renderer._last_dates[1].isAfter(filterDates[0], 'day')) {
|
||||
dto = this.renderer._last_dates[0].clone().local().endOf('day').utc();
|
||||
|
||||
if (filterDates[0].isBetween(this._last_dates[0], this._last_dates[1], 'days') && filterDates[1].isAfter(this._last_dates[1], 'day')) {
|
||||
dfrom = this._last_dates[1].clone().local().startOf('day').utc();
|
||||
} else if (this._last_dates[0].isBetween(filterDates[0], filterDates[1], 'days') && this._last_dates[1].isAfter(filterDates[0], 'day')) {
|
||||
dto = this._last_dates[0].clone().local().endOf('day').utc();
|
||||
}
|
||||
|
||||
var oparams = [
|
||||
@@ -210,7 +235,7 @@ var PMSCalendarController = AbstractController.extend({
|
||||
|
||||
self._multi_calendar._assign_extra_info(active_calendar);
|
||||
}.bind(this)).then(function(){
|
||||
self.renderer._last_dates = filterDates;
|
||||
self._last_dates = filterDates;
|
||||
});
|
||||
},
|
||||
|
||||
@@ -314,6 +339,12 @@ var PMSCalendarController = AbstractController.extend({
|
||||
self._multi_calendar.update_active_tab_name(active_calendar_record.name);
|
||||
});
|
||||
});
|
||||
|
||||
this._multi_calendar.on('tab_changed', function(ev, active_index){
|
||||
if (active_index) {
|
||||
self._refresh_filters(active_index);
|
||||
}
|
||||
});
|
||||
},
|
||||
|
||||
_assign_multi_calendar_events: function() {
|
||||
@@ -561,7 +592,7 @@ var PMSCalendarController = AbstractController.extend({
|
||||
this._multi_calendar.on_calendar('hcalOnDateChanged', function(ev){
|
||||
var $dateTimePickerBegin = this.renderer.$el.find('#pms-menu #date_begin');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(ev.detail.date_begin.local().add(1, 'd'));
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(ev.detail.date_begin.local());
|
||||
this._reload_active_calendar();
|
||||
}.bind(this));
|
||||
},
|
||||
@@ -588,20 +619,6 @@ var PMSCalendarController = AbstractController.extend({
|
||||
});
|
||||
},
|
||||
|
||||
_onLoadCalendarSettings: function (ev) {
|
||||
var self = this;
|
||||
return this.model.get_hcalendar_settings().then(function(options){
|
||||
self._view_options = options;
|
||||
var date_begin = moment().startOf('day');
|
||||
if (['xs', 'md'].indexOf(self._find_bootstrap_environment()) >= 0) {
|
||||
self._view_options['days'] = 7;
|
||||
} else {
|
||||
self._view_options['days'] = 30;
|
||||
}
|
||||
self.renderer.load_hcalendar_options(self._view_options);
|
||||
});
|
||||
},
|
||||
|
||||
_onViewAttached: function (ev) {
|
||||
this._multi_calendar.recalculate_reservation_positions();
|
||||
},
|
||||
@@ -769,9 +786,12 @@ var PMSCalendarController = AbstractController.extend({
|
||||
var active_calendar = this._multi_calendar.get_active_calendar();
|
||||
if (active_calendar && date_begin) {
|
||||
var days = $dateEndDays.val();
|
||||
if (days === 'month') {
|
||||
days = date_begin.daysInMonth();
|
||||
}
|
||||
var date_end = date_begin.clone().add(days, 'd');
|
||||
if (!date_begin.isSame(this.renderer._last_dates[0].clone().utc(), 'd') || !date_end.isSame(this.renderer._last_dates[1].clone().utc(), 'd')) {
|
||||
active_calendar.setStartDate(date_begin, days, false, function(){
|
||||
if (!date_begin.isSame(this._last_dates[0].clone().utc(), 'd') || !date_end.isSame(this._last_dates[1].clone().utc(), 'd')) {
|
||||
active_calendar.setStartDate(date_begin, $dateEndDays.val(), false, function(){
|
||||
this._reload_active_calendar();
|
||||
}.bind(this));
|
||||
}
|
||||
@@ -791,9 +811,7 @@ var PMSCalendarController = AbstractController.extend({
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(start_date.local());
|
||||
$dateEndDays.data("ignore_onchange", true);
|
||||
console.log("---- LLL");
|
||||
console.log(active_calendar.getOptions('days'));
|
||||
$dateEndDays.val(active_calendar.getOptions('days'));
|
||||
$dateEndDays.val(active_calendar.getOptions('orig_days'));
|
||||
$dateEndDays.trigger('change');
|
||||
|
||||
/* Overbooking Led */
|
||||
|
||||
@@ -25,7 +25,6 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
searchview_hidden: true,
|
||||
|
||||
// Custom Options
|
||||
_view_options: {},
|
||||
_reserv_tooltips: {},
|
||||
_days_tooltips: [],
|
||||
_last_dates: [false, false],
|
||||
@@ -55,27 +54,14 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
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().set({'hour': 0, 'minute': 0, 'second': 0}).clone().utc();
|
||||
var date_end = date_begin.clone().add($dateEndDays.val(), 'd').set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc();
|
||||
|
||||
console.log("---- YEAH");
|
||||
console.log(date_end.format("DD-MM-YYYY"));
|
||||
var days = $dateEndDays.val();
|
||||
if (days === 'month') {
|
||||
days = date_begin.daysInMonth();
|
||||
}
|
||||
var date_end = date_begin.clone().add(days, 'd').set({'hour': 23, 'minute': 59, 'second': 59}).clone().utc();
|
||||
return [date_begin, date_end];
|
||||
},
|
||||
|
||||
load_hcalendar_options: function(options) {
|
||||
// View Options
|
||||
this._view_options = options;
|
||||
var date_begin = moment().startOf('day');
|
||||
var $dateTimePickerBegin = this.$el.find('#pms-menu #date_begin');
|
||||
var $dateEndDays = this.$el.find('#pms-menu #date_end_days');
|
||||
//$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
//$dateTimePickerEnd.data("ignore_onchange", true);
|
||||
$dateEndDays.val(30);
|
||||
$dateEndDays.trigger('change');
|
||||
this._last_dates = this.get_view_filter_dates();
|
||||
},
|
||||
|
||||
update_buttons_counter: function(ncheckouts, ncheckins, noverbookings, ncancelled) {
|
||||
var self = this;
|
||||
// Checkouts Button
|
||||
@@ -135,25 +121,18 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
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: '1 Week'},
|
||||
// {id:12, text: '2 Weeks'},
|
||||
// {id:21, text: '3 Weeks'},
|
||||
// {id:30, text: '1 Month'},
|
||||
// {id:60, text: '2 Months'},
|
||||
// {id:90, text: '3 Months'},
|
||||
// ],
|
||||
// allowClear: true
|
||||
// });
|
||||
|
||||
|
||||
var date_begin = moment().startOf('day');
|
||||
$dateTimePickerBegin.data("ignore_onchange", true);
|
||||
$dateTimePickerBegin.data("DateTimePicker").date(date_begin);
|
||||
$dateEndDays.val(30);
|
||||
$dateEndDays.trigger('change');
|
||||
this._last_dates = this.get_view_filter_dates();
|
||||
$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){
|
||||
@@ -201,7 +180,6 @@ var HotelCalendarView = AbstractRenderer.extend({
|
||||
});
|
||||
|
||||
return $.when(
|
||||
this.trigger_up('onLoadCalendarSettings'),
|
||||
this.trigger_up('onUpdateButtonsCounter'),
|
||||
this.trigger_up('onLoadViewFilters'),
|
||||
);
|
||||
|
||||
@@ -429,6 +429,10 @@
|
||||
}
|
||||
|
||||
tr.hcal-row-room-type-group-overbooking-item td {
|
||||
background-color: #fccc9f;
|
||||
}
|
||||
|
||||
tr.hcal-row-room-type-group-cancelled-item td {
|
||||
background-color: #fcebeb;
|
||||
}
|
||||
|
||||
|
||||
@@ -61,8 +61,11 @@ function HotelCalendar(/*String*/querySelector, /*Dictionary*/options, /*List*/p
|
||||
showOverbookings: false,
|
||||
showCancelled: false,
|
||||
}, options);
|
||||
|
||||
this.options.startDate = this.options.startDate.clone();
|
||||
this.options.startDate.subtract('1', 'd');
|
||||
this.options.orig_days = this.options.days;
|
||||
this.options.days = this.parseDays(this.options.days);
|
||||
this.options.rooms = _.map(this.options.rooms, function(item){ return item.clone(); });
|
||||
|
||||
// Check correct values
|
||||
@@ -110,7 +113,7 @@ HotelCalendar.prototype = {
|
||||
},
|
||||
|
||||
//==== CALENDAR
|
||||
setStartDate: function(/*String,MomentObject*/date, /*Int?*/days, /*Bool*/fullUpdate, /*Functions*/callback) {
|
||||
setStartDate: function(/*String,MomentObject*/date, /*Int*/days, /*Bool*/fullUpdate, /*Functions*/callback) {
|
||||
if (moment.isMoment(date)) {
|
||||
this.options.startDate = date;
|
||||
} else if (typeof date === 'string'){
|
||||
@@ -122,7 +125,8 @@ HotelCalendar.prototype = {
|
||||
|
||||
this.options.startDate.subtract('1','d');
|
||||
if (typeof days !== 'undefined') {
|
||||
this.options.days = days;
|
||||
this.options.orig_days = days;
|
||||
this.options.days = this.parseDays(days);
|
||||
}
|
||||
this._endDate = this.options.startDate.clone().add(this.options.days, 'd');
|
||||
|
||||
@@ -132,13 +136,21 @@ HotelCalendar.prototype = {
|
||||
this._updateView(!fullUpdate, callback);
|
||||
},
|
||||
|
||||
getOptions: function(/*String?*/key) {
|
||||
getOptions: function(/*String?*/key) {+
|
||||
console.log(this.options);
|
||||
if (typeof key !== 'undefined') {
|
||||
return this.options[key];
|
||||
}
|
||||
return this.options;
|
||||
},
|
||||
|
||||
parseDays: function(/*Int/String*/days) {
|
||||
if (days === 'month') {
|
||||
return moment().daysInMonth();
|
||||
}
|
||||
return days;
|
||||
},
|
||||
|
||||
toggleOverbookingsVisibility: function(/*Bool*/show) {
|
||||
this.options.showOverbookings = !this.options.showOverbookings;
|
||||
},
|
||||
@@ -467,7 +479,7 @@ HotelCalendar.prototype = {
|
||||
}
|
||||
|
||||
// Search End Cell
|
||||
if (reservation.endDate.clone().local().isSameOrBefore(this._endDate, 'd')) {
|
||||
if (reservation.endDate.clone().subtract(1, 'd').local().isSameOrBefore(this._endDate, 'd')) {
|
||||
reservation._drawModes[1] = 'hard-end';
|
||||
limits.right = this.getCell(reservation.endDate.clone().subtract(1, 'd').local(),
|
||||
reservation.room,
|
||||
@@ -1021,7 +1033,7 @@ HotelCalendar.prototype = {
|
||||
button.style.minHeight = 0;
|
||||
button.addEventListener('click', function(){
|
||||
this.setStartDate(this.options.startDate.clone().subtract(this.options.paginatorStepsMax-1, 'd'), undefined, true);
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone(), 'date_end': this._endDate.clone() });
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone().add(1, 'd'), 'date_end': this._endDate.clone() });
|
||||
}.bind(this));
|
||||
var buttonIcon = document.createElement('i');
|
||||
buttonIcon.classList.add('fa', 'fa-2x', 'fa-angle-double-left');
|
||||
@@ -1033,7 +1045,7 @@ HotelCalendar.prototype = {
|
||||
button.firstElementChild.classList.add('fa-angle-left');
|
||||
button.addEventListener('click', function(){
|
||||
this.setStartDate(this.options.startDate.subtract(this.options.paginatorStepsMin-1, 'd'), undefined, true);
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone(), 'date_end': this._endDate.clone() });
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone().add(1, 'd'), 'date_end': this._endDate.clone() });
|
||||
}.bind(this));
|
||||
cell.appendChild(button);
|
||||
|
||||
@@ -1046,7 +1058,7 @@ HotelCalendar.prototype = {
|
||||
} else {
|
||||
button.addEventListener('click', function(){
|
||||
this.setStartDate(moment().utc(), undefined, true);
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone(), 'date_end': this._endDate.clone() });
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone().add(1, 'd'), 'date_end': this._endDate.clone() });
|
||||
}.bind(this));
|
||||
}
|
||||
cell.appendChild(button);
|
||||
@@ -1057,7 +1069,7 @@ HotelCalendar.prototype = {
|
||||
button.firstElementChild.classList.add('fa-angle-right');
|
||||
button.addEventListener('click', function(){
|
||||
this.setStartDate(this.options.startDate.add(this.options.paginatorStepsMin+1, 'd'), undefined, true);
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone(), 'date_end': this._endDate.clone() });
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone().add(1, 'd'), 'date_end': this._endDate.clone() });
|
||||
}.bind(this));
|
||||
cell.appendChild(button);
|
||||
button = button.cloneNode(true);
|
||||
@@ -1066,7 +1078,7 @@ HotelCalendar.prototype = {
|
||||
button.firstElementChild.classList.add('fa-angle-double-right');
|
||||
button.addEventListener('click', function(){
|
||||
this.setStartDate(this.options.startDate.add(this.options.paginatorStepsMax+1, 'd'), undefined, true);
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone(), 'date_end': this._endDate.clone() });
|
||||
this._dispatchEvent('hcalOnDateChanged', { 'date_begin': this.options.startDate.clone().add(1, 'd'), 'date_end': this._endDate.clone() });
|
||||
}.bind(this));
|
||||
cell.appendChild(button);
|
||||
|
||||
@@ -1787,12 +1799,10 @@ HotelCalendar.prototype = {
|
||||
|
||||
reserv._html.style.left = `${boundsInit.left-etableOffset.left}px`;
|
||||
reserv._html.style.width = `${(boundsEnd.left-boundsInit.left)+boundsEnd.width}px`;
|
||||
if (reserv._drawModes[0] === 'soft-start' && reserv._drawModes[1] === 'soft-end') {
|
||||
if (reserv._drawModes[0] === 'soft-start') {
|
||||
clearBorderLeft(reserv._html);
|
||||
clearBorderRight(reserv._html);
|
||||
} else if (reserv._drawModes[0] === 'soft-start') {
|
||||
clearBorderLeft(reserv._html);
|
||||
} else if (reserv._drawModes[1] === 'soft-end') {
|
||||
}
|
||||
if (reserv._drawModes[1] === 'soft-end') {
|
||||
clearBorderRight(reserv._html);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<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-7 col-md-7">
|
||||
<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">
|
||||
@@ -13,8 +13,8 @@
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group nopadding col-xs-5 col-md-5">
|
||||
<input id="date_end_days" required="required" />
|
||||
<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">
|
||||
|
||||
Reference in New Issue
Block a user