diff --git a/redmine/app/controllers/application.rb b/redmine/app/controllers/application.rb
index 3061359b2..e1e842b0b 100644
--- a/redmine/app/controllers/application.rb
+++ b/redmine/app/controllers/application.rb
@@ -88,7 +88,7 @@ class ApplicationController < ActionController::Base
render :nothing => true, :status => 403
false
end
-
+
# store current uri in session.
# return to this location by calling redirect_back_or_default
def store_location
diff --git a/redmine/app/controllers/issues_controller.rb b/redmine/app/controllers/issues_controller.rb
index effd3145e..45a618b01 100644
--- a/redmine/app/controllers/issues_controller.rb
+++ b/redmine/app/controllers/issues_controller.rb
@@ -16,15 +16,23 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class IssuesController < ApplicationController
- layout 'base'
+ layout 'base', :except => :export_pdf
before_filter :find_project, :authorize
helper :custom_fields
include CustomFieldsHelper
+ helper :ifpdf
+ include IfpdfHelper
def show
@status_options = @issue.status.workflows.find(:all, :include => :new_status, :conditions => ["role_id=? and tracker_id=?", self.logged_in_user.role_for_project(@project.id), @issue.tracker.id]).collect{ |w| w.new_status } if self.logged_in_user
@custom_values = @issue.custom_values.find(:all, :include => :custom_field)
+ end
+
+ def export_pdf
+ @custom_values = @issue.custom_values.find(:all, :include => :custom_field)
+ @options_for_rfpdf ||= {}
+ @options_for_rfpdf[:file_name] = "#{@project.name}_#{@issue.long_id}.pdf"
end
def edit
diff --git a/redmine/app/controllers/projects_controller.rb b/redmine/app/controllers/projects_controller.rb
index a3dac1e04..1d38aad7c 100644
--- a/redmine/app/controllers/projects_controller.rb
+++ b/redmine/app/controllers/projects_controller.rb
@@ -16,7 +16,7 @@
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
class ProjectsController < ApplicationController
- layout 'base'
+ layout 'base', :except => :export_issues_pdf
before_filter :find_project, :authorize, :except => [ :index, :list, :add ]
before_filter :require_admin, :only => [ :add, :destroy ]
@@ -26,7 +26,9 @@ class ProjectsController < ApplicationController
include SearchFilterHelper
helper :custom_fields
include CustomFieldsHelper
-
+ helper :ifpdf
+ include IfpdfHelper
+
def index
list
render :action => 'list' unless request.xhr?
@@ -208,15 +210,23 @@ class ProjectsController < ApplicationController
search_filter_init_list_issues
search_filter_update if params[:set_filter]
+ @results_per_page_options = [ 15, 25, 50, 100 ]
+ if params[:per_page] and @results_per_page_options.include? params[:per_page].to_i
+ @results_per_page = params[:per_page].to_i
+ session[:results_per_page] = @results_per_page
+ else
+ @results_per_page = session[:results_per_page] || @results_per_page_options.first
+ end
+
@issue_count = Issue.count(:include => [:status, :project], :conditions => search_filter_clause)
- @issue_pages = Paginator.new self, @issue_count, 15, @params['page']
+ @issue_pages = Paginator.new self, @issue_count, @results_per_page, @params['page']
@issues = Issue.find :all, :order => sort_clause,
:include => [ :author, :status, :tracker, :project ],
:conditions => search_filter_clause,
:limit => @issue_pages.items_per_page,
:offset => @issue_pages.current.offset
- render :action => "list_issues", :layout => false if request.xhr?
+ render :layout => false if request.xhr?
end
# Export filtered/sorted issues list to CSV
@@ -227,20 +237,44 @@ class ProjectsController < ApplicationController
search_filter_init_list_issues
@issues = Issue.find :all, :order => sort_clause,
- :include => [ :author, :status, :tracker, :project ],
+ :include => [ :author, :status, :tracker, :project, :custom_values ],
:conditions => search_filter_clause
+ ic = Iconv.new('ISO-8859-1', 'UTF-8')
export = StringIO.new
- CSV::Writer.generate(export, ',') do |csv|
- csv << %w(Id Status Tracker Subject Author Created Updated)
+ CSV::Writer.generate(export, l(:general_csv_separator)) do |csv|
+ # csv header fields
+ headers = [ "#", l(:field_status), l(:field_tracker), l(:field_subject), l(:field_author), l(:field_created_on), l(:field_updated_on) ]
+ for custom_field in @project.all_custom_fields
+ headers << custom_field.name
+ end
+ csv << headers.collect {|c| ic.iconv(c) }
+ # csv lines
@issues.each do |issue|
- csv << [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
+ fields = [issue.id, issue.status.name, issue.tracker.name, issue.subject, issue.author.display_name, l_datetime(issue.created_on), l_datetime(issue.updated_on)]
+ for custom_field in @project.all_custom_fields
+ fields << (show_value issue.custom_value_for(custom_field))
+ end
+ csv << fields.collect {|c| ic.iconv(c.to_s) }
end
end
export.rewind
- send_data(export.read,
- :type => 'text/csv; charset=utf-8; header=present',
- :filename => 'export.csv')
+ send_data(export.read, :type => 'text/csv; header=present', :filename => 'export.csv')
+ end
+
+ # Export filtered/sorted issues to PDF
+ def export_issues_pdf
+ sort_init 'issues.id', 'desc'
+ sort_update
+
+ search_filter_init_list_issues
+
+ @issues = Issue.find :all, :order => sort_clause,
+ :include => [ :author, :status, :tracker, :project, :custom_values ],
+ :conditions => search_filter_clause
+
+ @options_for_rfpdf ||= {}
+ @options_for_rfpdf[:file_name] = "export.pdf"
end
def move_issues
diff --git a/redmine/app/helpers/application_helper.rb b/redmine/app/helpers/application_helper.rb
index 4dc4acc27..835ac4859 100644
--- a/redmine/app/helpers/application_helper.rb
+++ b/redmine/app/helpers/application_helper.rb
@@ -49,7 +49,7 @@ module ApplicationHelper
def link_to_user(user)
link_to user.display_name, :controller => 'account', :action => 'show', :id => user
end
-
+
def format_date(date)
l_date(date) if date
end
@@ -57,7 +57,7 @@ module ApplicationHelper
def format_time(time)
l_datetime(time) if time
end
-
+
def pagination_links_full(paginator, options={}, html_options={})
html = ''
html << link_to_remote(('« ' + l(:label_previous)),
diff --git a/redmine/app/helpers/custom_fields_helper.rb b/redmine/app/helpers/custom_fields_helper.rb
index ac8b55565..8eb16de0d 100644
--- a/redmine/app/helpers/custom_fields_helper.rb
+++ b/redmine/app/helpers/custom_fields_helper.rb
@@ -53,9 +53,11 @@ module CustomFieldsHelper
# Return a string used to display a custom value
def show_value(custom_value)
+ return "" unless custom_value
+
case custom_value.custom_field.field_format
when "date"
- format_date(custom_value.value.to_date)
+ l_date(custom_value.value.to_date) if custom_value.value
when "bool"
l_YesNo(custom_value.value == "1")
else
diff --git a/redmine/app/helpers/ifpdf_helper.rb b/redmine/app/helpers/ifpdf_helper.rb
new file mode 100644
index 000000000..e09136db2
--- /dev/null
+++ b/redmine/app/helpers/ifpdf_helper.rb
@@ -0,0 +1,43 @@
+# redMine - project management software
+# Copyright (C) 2006 Jean-Philippe Lang
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+require 'iconv'
+
+module IfpdfHelper
+
+ class IFPDF < FPDF
+
+ def Cell(w,h=0,txt='',border=0,ln=0,align='',fill=0,link='')
+ @ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
+ super w,h,@ic.iconv(txt),border,ln,align,fill,link
+ end
+
+ def MultiCell(w,h,txt,border=0,align='J',fill=0)
+ @ic ||= Iconv.new('ISO-8859-1', 'UTF-8')
+ super w,h,txt,border,align,fill
+ end
+
+ def Footer
+ SetY(-15)
+ SetX(-30)
+ SetFont('Helvetica', 'I', 8)
+ Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C')
+ end
+
+ end
+
+end
diff --git a/redmine/app/helpers/search_filter_helper.rb b/redmine/app/helpers/search_filter_helper.rb
index 62ff5f291..f17ffeebf 100644
--- a/redmine/app/helpers/search_filter_helper.rb
+++ b/redmine/app/helpers/search_filter_helper.rb
@@ -86,6 +86,11 @@ module SearchFilterHelper
] + @project.versions.collect {|s| [s.name, s.id, ["issues.fixed_version_id=?", s.id]] }
}
+ search_filter_criteria('author_id') {
+ [ [('['+l(:label_all)+']'), "A", nil],
+ ] + @project.users.collect {|s| [s.display_name, s.id, ["issues.author_id=?", s.id]] }
+ }
+
search_filter_criteria('assigned_to_id') {
[ [('['+l(:label_all)+']'), "A", nil],
[('['+l(:label_none)+']'), "N", ["issues.assigned_to_id is null"]]
diff --git a/redmine/app/models/enumeration.rb b/redmine/app/models/enumeration.rb
index 122da15c5..b5c8ed6e7 100644
--- a/redmine/app/models/enumeration.rb
+++ b/redmine/app/models/enumeration.rb
@@ -29,6 +29,10 @@ class Enumeration < ActiveRecord::Base
def self.get_values(option)
find(:all, :conditions => ['opt=?', option])
end
+
+ def option_name
+ OPTIONS[self.opt]
+ end
private
def check_integrity
diff --git a/redmine/app/models/issue.rb b/redmine/app/models/issue.rb
index 489dad885..9327aa7bb 100644
--- a/redmine/app/models/issue.rb
+++ b/redmine/app/models/issue.rb
@@ -53,6 +53,11 @@ class Issue < ActiveRecord::Base
def long_id
"%05d" % self.id
end
+
+ def custom_value_for(custom_field)
+ self.custom_values.each {|v| return v if v.custom_field_id == custom_field.id }
+ return nil
+ end
private
# Creates an history for the issue
diff --git a/redmine/app/models/project.rb b/redmine/app/models/project.rb
index ee848cb30..ae7436910 100644
--- a/redmine/app/models/project.rb
+++ b/redmine/app/models/project.rb
@@ -43,6 +43,11 @@ class Project < ActiveRecord::Base
:conditions => ["is_for_all=? or project_id=?", true, self.id])
#(CustomField.for_all + custom_fields).uniq
end
+
+ def all_custom_fields
+ @all_custom_fields ||= IssueCustomField.find(:all, :include => :projects,
+ :conditions => ["is_for_all=? or project_id=?", true, self.id])
+ end
protected
def validate
diff --git a/redmine/app/views/documents/show.rhtml b/redmine/app/views/documents/show.rhtml
index 89693de89..2b8da670f 100644
--- a/redmine/app/views/documents/show.rhtml
+++ b/redmine/app/views/documents/show.rhtml
@@ -18,7 +18,7 @@
-
<%= format_date(attachment.created_on) %> | diff --git a/redmine/app/views/enumerations/new.rhtml b/redmine/app/views/enumerations/new.rhtml index aa0e68173..0a773519d 100644 --- a/redmine/app/views/enumerations/new.rhtml +++ b/redmine/app/views/enumerations/new.rhtml @@ -1,4 +1,4 @@ -