[IMP]:Added Upstream Patch for HR Attendance
This commit is contained in:
parent
3826601311
commit
61bebe4dcb
@ -38,11 +38,18 @@ var GreetingMessage = Widget.extend({
|
|||||||
if (this.next_action != 'hr_attendance.hr_attendance_action_kiosk_mode' && this.next_action.tag != 'hr_attendance_kiosk_mode') {
|
if (this.next_action != 'hr_attendance.hr_attendance_action_kiosk_mode' && this.next_action.tag != 'hr_attendance_kiosk_mode') {
|
||||||
this.activeBarcode = false;
|
this.activeBarcode = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.attendance = action.attendance;
|
this.attendance = action.attendance;
|
||||||
|
// We receive the check in/out times in UTC
|
||||||
|
// This widget only deals with display, which should be in browser's TimeZone
|
||||||
|
this.attendance.check_in = this.attendance.check_in && moment.utc(this.attendance.check_in).local();
|
||||||
|
this.attendance.check_out = this.attendance.check_out && moment.utc(this.attendance.check_out).local();
|
||||||
|
this.previous_attendance_change_date = action.previous_attendance_change_date && moment.utc(action.previous_attendance_change_date).local();
|
||||||
|
|
||||||
// check in/out times displayed in the greeting message template.
|
// check in/out times displayed in the greeting message template.
|
||||||
this.attendance.check_in_time = (new Date((new Date(this.attendance.check_in)).valueOf() - (new Date()).getTimezoneOffset()*60*1000)).toTimeString().slice(0,8);
|
this.format_time = 'HH:mm:ss';
|
||||||
this.attendance.check_out_time = this.attendance.check_out && (new Date((new Date(this.attendance.check_out)).valueOf() - (new Date()).getTimezoneOffset()*60*1000)).toTimeString().slice(0,8);
|
this.attendance.check_in_time = this.attendance.check_in && this.attendance.check_in.format(this.format_time);
|
||||||
this.previous_attendance_change_date = action.previous_attendance_change_date;
|
this.attendance.check_out_time = this.attendance.check_out && this.attendance.check_out.format(this.format_time);
|
||||||
this.employee_name = action.employee_name;
|
this.employee_name = action.employee_name;
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -57,13 +64,13 @@ var GreetingMessage = Widget.extend({
|
|||||||
|
|
||||||
welcome_message: function() {
|
welcome_message: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var now = new Date((new Date(this.attendance.check_in)).valueOf() - (new Date()).getTimezoneOffset()*60*1000);
|
var now = this.attendance.check_in.clone();
|
||||||
this.return_to_main_menu = setTimeout( function() { self.do_action(self.next_action, {clear_breadcrumbs: true}); }, 5000);
|
this.return_to_main_menu = setTimeout( function() { self.do_action(self.next_action, {clear_breadcrumbs: true}); }, 5000);
|
||||||
|
|
||||||
if (now.getHours() < 5) {
|
if (now.hours() < 5) {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Good night"));
|
this.$('.o_hr_attendance_message_message').append(_t("Good night"));
|
||||||
} else if (now.getHours() < 12) {
|
} else if (now.hours() < 12) {
|
||||||
if (now.getHours() < 8 && Math.random() < 0.3) {
|
if (now.hours() < 8 && Math.random() < 0.3) {
|
||||||
if (Math.random() < 0.75) {
|
if (Math.random() < 0.75) {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("The early bird catches the worm"));
|
this.$('.o_hr_attendance_message_message').append(_t("The early bird catches the worm"));
|
||||||
} else {
|
} else {
|
||||||
@ -72,16 +79,16 @@ var GreetingMessage = Widget.extend({
|
|||||||
} else {
|
} else {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Good morning"));
|
this.$('.o_hr_attendance_message_message').append(_t("Good morning"));
|
||||||
}
|
}
|
||||||
} else if (now.getHours() < 17){
|
} else if (now.hours() < 17){
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Good afternoon"));
|
this.$('.o_hr_attendance_message_message').append(_t("Good afternoon"));
|
||||||
} else if (now.getHours() < 23){
|
} else if (now.hours() < 23){
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Good evening"));
|
this.$('.o_hr_attendance_message_message').append(_t("Good evening"));
|
||||||
} else {
|
} else {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Good night"));
|
this.$('.o_hr_attendance_message_message').append(_t("Good night"));
|
||||||
}
|
}
|
||||||
if(this.previous_attendance_change_date){
|
if(this.previous_attendance_change_date){
|
||||||
var last_check_out_date = new Date((new Date(this.previous_attendance_change_date)).valueOf() - (new Date()).getTimezoneOffset()*60*1000);
|
var last_check_out_date = this.previous_attendance_change_date.clone();
|
||||||
if(now.valueOf() - last_check_out_date.valueOf() > 1000*60*60*24*7){
|
if(now - last_check_out_date > 24*7*60*60*1000){
|
||||||
this.$('.o_hr_attendance_random_message').html(_t("Glad to have you back, it's been a while!"));
|
this.$('.o_hr_attendance_random_message').html(_t("Glad to have you back, it's been a while!"));
|
||||||
} else {
|
} else {
|
||||||
if(Math.random() < 0.02){
|
if(Math.random() < 0.02){
|
||||||
@ -93,33 +100,33 @@ var GreetingMessage = Widget.extend({
|
|||||||
|
|
||||||
farewell_message: function() {
|
farewell_message: function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
var now = new Date((new Date(this.attendance.check_out)).valueOf() - (new Date()).getTimezoneOffset()*60*1000);
|
var now = this.attendance.check_out.clone();
|
||||||
this.return_to_main_menu = setTimeout( function() { self.do_action(self.next_action, {clear_breadcrumbs: true}); }, 5000);
|
this.return_to_main_menu = setTimeout( function() { self.do_action(self.next_action, {clear_breadcrumbs: true}); }, 5000);
|
||||||
|
|
||||||
if(this.previous_attendance_change_date){
|
if(this.previous_attendance_change_date){
|
||||||
var last_check_in_date = new Date((new Date(this.previous_attendance_change_date)).valueOf() - (new Date()).getTimezoneOffset()*60*1000);
|
var last_check_in_date = this.previous_attendance_change_date.clone();
|
||||||
if(now.valueOf() - last_check_in_date.valueOf() > 1000*60*60*12){
|
if(now - last_check_in_date > 1000*60*60*12){
|
||||||
this.$('.o_hr_attendance_warning_message').append(_t("Warning! Last check in was over 12 hours ago.<br/>If this isn't right, please contact Human Resources."));
|
this.$('.o_hr_attendance_warning_message').append(_t("Warning! Last check in was over 12 hours ago.<br/>If this isn't right, please contact Human Resources."));
|
||||||
clearTimeout(this.return_to_main_menu);
|
clearTimeout(this.return_to_main_menu);
|
||||||
this.activeBarcode = false;
|
this.activeBarcode = false;
|
||||||
} else if(now.valueOf() - last_check_in_date.valueOf() > 1000*60*60*8){
|
} else if(now - last_check_in_date > 1000*60*60*8){
|
||||||
this.$('.o_hr_attendance_random_message').html(_t("Another good day's work! See you soon!"));
|
this.$('.o_hr_attendance_random_message').html(_t("Another good day's work! See you soon!"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (now.getHours() < 12) {
|
if (now.hours() < 12) {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Have a good day!"));
|
this.$('.o_hr_attendance_message_message').append(_t("Have a good day!"));
|
||||||
} else if (now.getHours() < 14) {
|
} else if (now.hours() < 14) {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Have a nice lunch!"));
|
this.$('.o_hr_attendance_message_message').append(_t("Have a nice lunch!"));
|
||||||
if (Math.random() < 0.05) {
|
if (Math.random() < 0.05) {
|
||||||
this.$('.o_hr_attendance_random_message').html(_t("Eat breakfast as a king, lunch as a merchant and supper as a beggar"));
|
this.$('.o_hr_attendance_random_message').html(_t("Eat breakfast as a king, lunch as a merchant and supper as a beggar"));
|
||||||
} else if (Math.random() < 0.06) {
|
} else if (Math.random() < 0.06) {
|
||||||
this.$('.o_hr_attendance_random_message').html(_t("An apple a day keeps the doctor away"));
|
this.$('.o_hr_attendance_random_message').html(_t("An apple a day keeps the doctor away"));
|
||||||
}
|
}
|
||||||
} else if (now.getHours() < 17) {
|
} else if (now.hours() < 17) {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Have a good afternoon"));
|
this.$('.o_hr_attendance_message_message').append(_t("Have a good afternoon"));
|
||||||
} else {
|
} else {
|
||||||
if (now.getHours() < 18 && Math.random() < 0.2) {
|
if (now.hours() < 18 && Math.random() < 0.2) {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Early to bed and early to rise, makes a man healthy, wealthy and wise"));
|
this.$('.o_hr_attendance_message_message').append(_t("Early to bed and early to rise, makes a man healthy, wealthy and wise"));
|
||||||
} else {
|
} else {
|
||||||
this.$('.o_hr_attendance_message_message').append(_t("Have a good evening"));
|
this.$('.o_hr_attendance_message_message').append(_t("Have a good evening"));
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
flectra.define('hr_attendance.kiosk_mode', function (require) {
|
flectra.define('hr_attendance.kiosk_mode', function (require) {
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
var ajax = require('web.ajax');
|
||||||
var core = require('web.core');
|
var core = require('web.core');
|
||||||
var Widget = require('web.Widget');
|
var Widget = require('web.Widget');
|
||||||
var Session = require('web.session');
|
var Session = require('web.session');
|
||||||
@ -27,6 +28,8 @@ var KioskMode = Widget.extend({
|
|||||||
self.$el.html(QWeb.render("HrAttendanceKioskMode", {widget: self}));
|
self.$el.html(QWeb.render("HrAttendanceKioskMode", {widget: self}));
|
||||||
self.start_clock();
|
self.start_clock();
|
||||||
});
|
});
|
||||||
|
// Make a RPC call every day to keep the session alive
|
||||||
|
self._interval = window.setInterval(this._callServer.bind(this), (60*60*1000*24));
|
||||||
return $.when(def, this._super.apply(this, arguments));
|
return $.when(def, this._super.apply(this, arguments));
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -55,8 +58,15 @@ var KioskMode = Widget.extend({
|
|||||||
destroy: function () {
|
destroy: function () {
|
||||||
core.bus.off('barcode_scanned', this, this._onBarcodeScanned);
|
core.bus.off('barcode_scanned', this, this._onBarcodeScanned);
|
||||||
clearInterval(this.clock_start);
|
clearInterval(this.clock_start);
|
||||||
|
clearInterval(this._interval);
|
||||||
this._super.apply(this, arguments);
|
this._super.apply(this, arguments);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_callServer: function () {
|
||||||
|
// Make a call to the database to avoid the auto close of the session
|
||||||
|
return ajax.rpc("/web/webclient/version_info", {});
|
||||||
|
},
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
core.action_registry.add('hr_attendance_kiosk_mode', KioskMode);
|
core.action_registry.add('hr_attendance_kiosk_mode', KioskMode);
|
||||||
|
Loading…
Reference in New Issue
Block a user