From 43322be88525a16b4e5f0266acb4bcc402ee1d6c Mon Sep 17 00:00:00 2001 From: niv-openerp Date: Tue, 2 Oct 2012 16:38:48 +0200 Subject: [PATCH] Added total stuff bzr revid: nicolas.vanhoren@openerp.com-20121002143848-1bgyz62vxn01dsvi --- .../static/src/css/timesheet.css | 35 +++++++++++++++---- .../static/src/js/timesheet.js | 30 ++++++++++++++++ .../static/src/xml/timesheet.xml | 19 ++++++++-- 3 files changed, 76 insertions(+), 8 deletions(-) diff --git a/addons/hr_timesheet_sheet/static/src/css/timesheet.css b/addons/hr_timesheet_sheet/static/src/css/timesheet.css index e609bb636b4..40ef259e1c5 100644 --- a/addons/hr_timesheet_sheet/static/src/css/timesheet.css +++ b/addons/hr_timesheet_sheet/static/src/css/timesheet.css @@ -1,25 +1,34 @@ -.oe_timesheet_weekly table { +.openerp .oe_timesheet_weekly { + overflow-x: auto; +} + +.openerp .oe_timesheet_weekly table { width: 100%; } -.oe_timesheet_weekly th { +.openerp .oe_timesheet_weekly th { text-align: right; color: #069; font-family: 'Helvetica Neue', Arial, Verdana, 'Nimbus Sans L', sans-serif; font-size: 10px; } -.oe_timesheet_weekly td { +.openerp .oe_timesheet_weekly th.oe_timesheet_weekly_date_head { + width: 60px; +} + +.openerp .oe_timesheet_weekly td { text-align: right; vertical-align: middle; } -.oe_timesheet_weekly .oe_timesheet_weekly_account { +.openerp .oe_timesheet_weekly .oe_timesheet_weekly_account { text-align: left; + padding-right: 30px; } -.oe_timesheet_weekly td input { +.openerp .oe_timesheet_weekly td input { border: 1px solid #CCC; padding: 5px 2px !important; color: #666 !important; @@ -30,11 +39,25 @@ min-width: 0 !important; } -.oe_timesheet_weekly td .oe_timesheet_weekly_box { +.openerp .oe_timesheet_weekly td .oe_timesheet_weekly_box { padding: 5px 2px !important; color: #666 !important; font-size: 14px; font-weight: bold; width: 38px; display: inline-block; +} + +.openerp .oe_timesheet_weekly .oe_timesheet_weekly_adding_tot { + display: table; + width: 100%; +} + +.openerp .oe_timesheet_weekly .oe_timesheet_weekly_adding { + display: table-cell; + text-align: left; +} + +.openerp .oe_timesheet_weekly .oe_timesheet_weekly_tottot { + display: table-cell; } \ No newline at end of file diff --git a/addons/hr_timesheet_sheet/static/src/js/timesheet.js b/addons/hr_timesheet_sheet/static/src/js/timesheet.js index 16d42261585..e836278fef0 100644 --- a/addons/hr_timesheet_sheet/static/src/js/timesheet.js +++ b/addons/hr_timesheet_sheet/static/src/js/timesheet.js @@ -147,6 +147,8 @@ openerp.hr_timesheet_sheet = function(instance) { } else { account.days[day_count].lines[0].unit_amount += num - self.sum_box(account, day_count); self.get_total(account).html(self.sum_total(account)); + self.get_day_total(day_count).html(self.sum_day_total(day_count)); + self.get_super_total().html(self.sum_super_total()); self.sync(); } }); @@ -156,6 +158,10 @@ openerp.hr_timesheet_sheet = function(instance) { }); self.get_total(account).html(self.sum_total(account)); }); + _.each(_.range(self.dates.length), function(day_count) { + self.get_day_total(day_count).html(self.sum_day_total(day_count)); + }); + self.get_super_total().html(self.sum_super_total()); }, get_box: function(account, day_count) { return this.$('[data-account="' + account.account + '"][data-day-count="' + day_count + '"]'); @@ -163,6 +169,12 @@ openerp.hr_timesheet_sheet = function(instance) { get_total: function(account) { return this.$('[data-account-total="' + account.account + '"]'); }, + get_day_total: function(day_count) { + return this.$('[data-day-total="' + day_count + '"]'); + }, + get_super_total: function() { + return this.$('.oe_timesheet_weekly_supertotal'); + }, sum_box: function(account, day_count) { var line_total = 0; _.each(account.days[day_count].lines, function(line) { @@ -179,6 +191,23 @@ openerp.hr_timesheet_sheet = function(instance) { }); return total; }, + sum_day_total: function(day_count) { + var total = 0; + _.each(this.accounts, function(account) { + _.each(account.days[day_count].lines, function(line) { + total += line.unit_amount; + }); + }); + return total; + }, + sum_super_total: function(account) { + var self = this; + var total = 0; + _.each(self.accounts, function(account) { + total += self.sum_total(account); + }); + return total; + }, sync: function() { var self = this; var ops = []; @@ -197,6 +226,7 @@ openerp.hr_timesheet_sheet = function(instance) { tmp[k] = v[0]; } }); + // we have to remove some keys, because analytic lines are shitty _.each(_.keys(tmp), function(key) { if (auth_keys[key] === undefined) { tmp[key] = undefined; diff --git a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml index e27df42d47d..73b95eb4840 100644 --- a/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml +++ b/addons/hr_timesheet_sheet/static/src/xml/timesheet.xml @@ -6,11 +6,11 @@ - - + @@ -24,6 +24,21 @@ + + + + + + + + +
+
TOTALTOTAL
+
+
+
TOTAL
+
+
+