source: timingandestimationplugin/branches/trac0.12-Permissions/timingandestimationplugin/htdocs/query.js

Last change on this file was 10653, checked in by Russ Tyndall, 12 years ago

better hour totaler on /query screen fix #9040

File size: 1019 bytes
Line 
1$(document).ready(function(){
2  // Fields we will total
3  var columns = ['totalhours','estimatedhours'];
4  var tbodies = $('table.listing.tickets tbody');
5
6  tbodies.each(function(idx, tbody){
7    tbody = $(tbody);
8    if(tbody.has('tr.even').length == 0) return true;
9    var tfoot = $('<tbody class="foot"></tbody>');
10    var totalsRow = $('tr:first-child',tbody).clone();
11    tfoot.append(totalsRow);
12
13    // Build footer row
14    $('td',totalsRow).empty()
15      .css('background-color','#EEF')
16      .css('text-align','right')
17      .css('padding','0.1em 0.5em')
18      .css('border','1px solid #DDD');
19
20    $.each(columns,function(idx, field){
21      // count totals
22      var total = 0;
23      $('td.'+field,tbody).each(function(cidx, cell){
24    $(cell).css('text-align','right');
25    var val = Number($(cell).text());
26    if(!isNaN(val))total+=val;
27      });
28
29      //set total text in each footer row
30      $('td.'+field,totalsRow).text(total.toString());
31    });
32
33    // attach footer row
34    tbody.after(tfoot);
35  });
36});
Note: See TracBrowser for help on using the repository browser.