diff --git a/app/views/cost_reports/_cost_entry_table.rhtml b/app/views/cost_reports/_cost_entry_table.rhtml index 04e143ac5c..1e0c9e4e4e 100644 --- a/app/views/cost_reports/_cost_entry_table.rhtml +++ b/app/views/cost_reports/_cost_entry_table.rhtml @@ -1,20 +1,24 @@ <% list = [:spent_on, :user_id, :activity_id, :issue_id, :comments, :project_id] %> - +
- <% list.each do |field| %><% end %> - - - + + <% list.each do |field| %><% end %> + + + + - <% if show_result(@query, 0) != show_result(@query) %> - - - <% else %> - - <% end %> - + + <% if show_result(@query, 0) != show_result(@query) %> + + + <% else %> + + <% end %> + + <% @query.each_direct_result do |result| %> @@ -39,4 +43,10 @@ <% end %> <% end %> -
<%= label_for(field) %><%= @cost_type.try(:unit_plural) || l(:units) %><%= l(:field_costs) %>
<%= label_for(field) %><%= @cost_type.try(:unit_plural) || l(:units) %><%= l(:field_costs) %>
<%= show_result @query %><%= show_result @query, 0 %><%= show_result @query %>
<%= show_result @query %><%= show_result @query, 0 %><%= show_result @query %>
\ No newline at end of file + + + diff --git a/app/views/cost_reports/_simple_cost_report_table.rhtml b/app/views/cost_reports/_simple_cost_report_table.rhtml index bcbed09625..52effd03cf 100644 --- a/app/views/cost_reports/_simple_cost_report_table.rhtml +++ b/app/views/cost_reports/_simple_cost_report_table.rhtml @@ -3,23 +3,27 @@ list = @query.collect {|r| r.important_fields }.flatten.uniq show_units = list.include? "cost_type_id" %> - +
- <% list.each do |field| %><% end %> - - <% if show_units %> - - <% end %> - + + <% list.each do |field| %><% end %> + + <% if show_units %> + + <% end %> + + - - - + + + + + <% @query.each do |result| %> @@ -41,3 +45,9 @@ show_units = list.include? "cost_type_id" <% end %>
<%= label_for(field) %><%= label_for(:label_count) %><%= label_for(:field_units) %><%= label_for(:label_sum) %>
<%= label_for(field) %><%= label_for(:label_count) %><%= label_for(:field_units) %><%= label_for(:label_sum) %>
- <%= @query.count %> - > - <%= show_result @query %> -
+ <%= @query.count %> + > + <%= show_result @query %> +
+ + diff --git a/app/views/cost_reports/index.rhtml b/app/views/cost_reports/index.rhtml index 45cfe3a20c..4b778cfd36 100644 --- a/app/views/cost_reports/index.rhtml +++ b/app/views/cost_reports/index.rhtml @@ -1,6 +1,7 @@ <% content_for :header_tags do %> <%= javascript_include_tag "select_list_move_optgroup", :plugin => "redmine_reporting" %> <%= javascript_include_tag "reporting", :plugin => "redmine_reporting" %> + <%= javascript_include_tag "sortable", :plugin => "redmine_reporting" %> <%= stylesheet_link_tag 'reporting', :plugin => 'redmine_reporting' %> <% end %> diff --git a/assets/javascripts/sortable.js b/assets/javascripts/sortable.js new file mode 100644 index 0000000000..f7f570e67a --- /dev/null +++ b/assets/javascripts/sortable.js @@ -0,0 +1,336 @@ +/* +Table sorting script by Joost de Valk, check it out at http://www.joostdevalk.nl/code/sortable-table/. +Based on a script from http://www.kryogenix.org/code/browser/sorttable/. +Distributed under the MIT license: http://www.kryogenix.org/code/browser/licence.html . + +Copyright (c) 1997-2007 Stuart Langridge, Joost de Valk. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. + +Version 1.5.7 +*/ + +/* You can change these values */ +var image_path = ""; +var image_up = "arrowup.gif"; +var image_down = "arrowdown.gif"; +var image_none = "arrownone.gif"; +var europeandate = true; +var alternate_row_colors = true; + +/* Don't change anything below this unless you know what you're doing */ +// addEvent(window, "load", sortables_init); + +var SORT_COLUMN_INDEX; +var thead = false; + +function sortables_init() { + // Find table with id sortable-table and make them sortable + if (!document.getElementById) return; + tbl = document.getElementById("sortable-table"); + ts_makeSortable(tbl); +} + +function ts_makeSortable(t) { + if (t.rows && t.rows.length > 0) { + if (t.tHead && t.tHead.rows.length > 0) { + var firstRow = t.tHead.rows[t.tHead.rows.length-1]; + thead = true; + } else { + var firstRow = t.rows[0]; + } + } + if (!firstRow) return; + + // We have a first row: assume it's the header, and make its contents clickable links + for (var i=0;i'+txt+'  ↓'; + } + } + if (alternate_row_colors) { + alternate(t); + } +} + +function ts_getInnerText(el) { + if (typeof el == "string") return el; + if (typeof el == "undefined") { return el }; + if (el.innerText) return el.innerText; //Not needed but it is faster + var str = ""; + + var cs = el.childNodes; + var l = cs.length; + for (var i = 0; i < l; i++) { + switch (cs[i].nodeType) { + case 1: //ELEMENT_NODE + str += ts_getInnerText(cs[i]); + break; + case 3: //TEXT_NODE + str += cs[i].nodeValue; + break; + } + } + return str; +} + +function ts_resortTable(lnk, clid) { + var span; + for (var ci=0;ci'; + newRows.reverse(); + span.setAttribute('sortdir','up'); + } else { + ARROW = '  ↑'; + span.setAttribute('sortdir','down'); + } + // We appendChild rows that already exist to the tbody, so it moves them rather than creating new ones + // don't do sortbottom rows + for (i=0; i'; + } + } + } + span.innerHTML = ARROW; + alternate(t); +} + +function getParent(el, pTagName) { + if (el == null) { + return null; + } else if (el.nodeType == 1 && el.tagName.toLowerCase() == pTagName.toLowerCase()) { + return el; + } else { + return getParent(el.parentNode, pTagName); + } +} + +function sort_date(date) { + // y2k notes: two digit years less than 50 are treated as 20XX, greater than 50 are treated as 19XX + dt = "00000000"; + if (date.length == 11) { + mtstr = date.substr(3,3); + mtstr = mtstr.toLowerCase(); + switch(mtstr) { + case "jan": var mt = "01"; break; + case "feb": var mt = "02"; break; + case "mar": var mt = "03"; break; + case "apr": var mt = "04"; break; + case "may": var mt = "05"; break; + case "jun": var mt = "06"; break; + case "jul": var mt = "07"; break; + case "aug": var mt = "08"; break; + case "sep": var mt = "09"; break; + case "oct": var mt = "10"; break; + case "nov": var mt = "11"; break; + case "dec": var mt = "12"; break; + // default: var mt = "00"; + } + dt = date.substr(7,4)+mt+date.substr(0,2); + return dt; + } else if (date.length == 10) { + if (europeandate == false) { + dt = date.substr(6,4)+date.substr(0,2)+date.substr(3,2); + return dt; + } else { + dt = date.substr(6,4)+date.substr(3,2)+date.substr(0,2); + return dt; + } + } else if (date.length == 8) { + yr = date.substr(6,2); + if (parseInt(yr) < 50) { + yr = '20'+yr; + } else { + yr = '19'+yr; + } + if (europeandate == true) { + dt = yr+date.substr(3,2)+date.substr(0,2); + return dt; + } else { + dt = yr+date.substr(0,2)+date.substr(3,2); + return dt; + } + } + return dt; +} + +function ts_sort_date(a,b) { + dt1 = sort_date(ts_getInnerText(a.cells[SORT_COLUMN_INDEX])); + dt2 = sort_date(ts_getInnerText(b.cells[SORT_COLUMN_INDEX])); + + if (dt1==dt2) { + return 0; + } + if (dt1