Added total stuff

bzr revid: nicolas.vanhoren@openerp.com-20121002143848-1bgyz62vxn01dsvi
This commit is contained in:
niv-openerp
2012-10-02 16:38:48 +02:00
parent ab97cd9907
commit 43322be885
3 changed files with 76 additions and 8 deletions
@@ -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;
}
@@ -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;
@@ -6,11 +6,11 @@
<table>
<tr>
<th> </th>
<th t-foreach="widget.dates" t-as="date">
<th t-foreach="widget.dates" t-as="date" class="oe_timesheet_weekly_date_head">
<t t-esc="date.toString('ddd')"/><br />
<t t-esc="date.toString('MMM d')"/>
</th>
<th>TOTAL</th>
<th class="oe_timesheet_weekly_date_head">TOTAL</th>
</tr>
<tr t-foreach="widget.accounts" t-as="account">
<td class="oe_timesheet_weekly_account"><t t-esc="widget.account_names[account.account]"/></td>
@@ -24,6 +24,21 @@
</td>
<td t-att-data-account-total="account.account"> </td>
</tr>
<tr>
<td>
<div class="oe_timesheet_weekly_adding_tot">
<div class="oe_timesheet_weekly_adding"><button>Add Row</button></div>
<div class="oe_timesheet_weekly_tottot"><span>TOTAL</span></div>
</div>
</td>
<t t-set="day_count" t-value="0"/>
<t t-foreach="widget.dates" t-as="date">
<td class="oe_timesheet_weekly_box" t-att-data-day-total="day_count">
</td>
<t t-set="day_count" t-value="day_count + 1"/>
</t>
<td class="oe_timesheet_weekly_supertotal"> </td>
</tr>
</table>
</div>
</t>