From c83e79487171bae46637fde2d2d7e92dcabbe92d Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Tue, 21 Nov 2006 22:27:47 +0000 Subject: [PATCH] git-svn-id: http://redmine.rubyforge.org/svn/trunk@51 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- .../app/controllers/documents_controller.rb | 3 ++ redmine/app/controllers/issues_controller.rb | 3 ++ .../app/controllers/projects_controller.rb | 2 +- redmine/app/controllers/reports_controller.rb | 36 +++++++++++++++++++ .../app/controllers/versions_controller.rb | 4 +-- redmine/app/helpers/ifpdf_helper.rb | 9 +++-- redmine/app/views/issues/export_pdf.rfpdf | 1 + redmine/app/views/projects/activity.rhtml | 2 +- redmine/app/views/projects/changelog.rhtml | 3 +- .../views/projects/export_issues_pdf.rfpdf | 1 + redmine/app/views/projects/gantt.rfpdf | 19 ++++++---- redmine/app/views/projects/list_issues.rhtml | 18 +++++----- .../views/reports/issue_report_details.rhtml | 2 +- redmine/app/views/welcome/index.rhtml | 2 +- 14 files changed, 81 insertions(+), 24 deletions(-) diff --git a/redmine/app/controllers/documents_controller.rb b/redmine/app/controllers/documents_controller.rb index f2693577..3107b3ed 100644 --- a/redmine/app/controllers/documents_controller.rb +++ b/redmine/app/controllers/documents_controller.rb @@ -40,6 +40,9 @@ class DocumentsController < ApplicationController @attachment = @document.attachments.find(params[:attachment_id]) @attachment.increment_download send_file @attachment.diskfile, :filename => @attachment.filename + rescue + flash.now[:notice] = l(:notice_file_not_found) + render :text => "", :layout => true, :status => 404 end def add_attachment diff --git a/redmine/app/controllers/issues_controller.rb b/redmine/app/controllers/issues_controller.rb index c279e643..45b4fe63 100644 --- a/redmine/app/controllers/issues_controller.rb +++ b/redmine/app/controllers/issues_controller.rb @@ -119,6 +119,9 @@ class IssuesController < ApplicationController def download @attachment = @issue.attachments.find(params[:attachment_id]) send_file @attachment.diskfile, :filename => @attachment.filename + rescue + flash.now[:notice] = l(:notice_file_not_found) + render :text => "", :layout => true, :status => 404 end private diff --git a/redmine/app/controllers/projects_controller.rb b/redmine/app/controllers/projects_controller.rb index 0198e975..a2b7abb4 100644 --- a/redmine/app/controllers/projects_controller.rb +++ b/redmine/app/controllers/projects_controller.rb @@ -395,7 +395,7 @@ class ProjectsController < ApplicationController @show_files = 1 end - unless params[:show_documentss] == "0" + unless params[:show_documents] == "0" Attachment.find(:all, :joins => "LEFT JOIN documents ON documents.id = attachments.container_id", :conditions => ["attachments.container_type='Document' and documents.project_id=? and attachments.created_on>=? and attachments.created_on<=?", @project.id, @date_from, @date_to] ).each { |i| @events_by_day[i.created_on.to_date] ||= [] @events_by_day[i.created_on.to_date] << i diff --git a/redmine/app/controllers/reports_controller.rb b/redmine/app/controllers/reports_controller.rb index 4a2f7972..985c937f 100644 --- a/redmine/app/controllers/reports_controller.rb +++ b/redmine/app/controllers/reports_controller.rb @@ -60,6 +60,42 @@ class ReportsController < ApplicationController end end + def delays + @trackers = Tracker.find(:all) + if request.get? + @selected_tracker_ids = @trackers.collect {|t| t.id.to_s } + else + @selected_tracker_ids = params[:tracker_ids].collect { |id| id.to_i.to_s } if params[:tracker_ids] and params[:tracker_ids].is_a? Array + end + @selected_tracker_ids ||= [] + @raw = + ActiveRecord::Base.connection.select_all("SELECT datediff( a.created_on, b.created_on ) as delay, count(a.id) as total + FROM issue_histories a, issue_histories b, issues i + WHERE a.status_id =5 + AND a.issue_id = b.issue_id + AND a.issue_id = i.id + AND i.tracker_id in (#{@selected_tracker_ids.join(',')}) + AND b.id = ( + SELECT min( c.id ) + FROM issue_histories c + WHERE b.issue_id = c.issue_id ) + GROUP BY delay") unless @selected_tracker_ids.empty? + @raw ||=[] + + @x_from = 0 + @x_to = 0 + @y_from = 0 + @y_to = 0 + @sum_total = 0 + @sum_delay = 0 + @raw.each do |r| + @x_to = [r['delay'].to_i, @x_to].max + @y_to = [r['total'].to_i, @y_to].max + @sum_total = @sum_total + r['total'].to_i + @sum_delay = @sum_delay + r['total'].to_i * r['delay'].to_i + end + end + private # Find project of id params[:id] def find_project diff --git a/redmine/app/controllers/versions_controller.rb b/redmine/app/controllers/versions_controller.rb index 57f56bf8..d1980d74 100644 --- a/redmine/app/controllers/versions_controller.rb +++ b/redmine/app/controllers/versions_controller.rb @@ -39,8 +39,8 @@ class VersionsController < ApplicationController @attachment.increment_download send_file @attachment.diskfile, :filename => @attachment.filename rescue - flash[:notice] = l(:notice_file_not_found) - redirect_to :controller => 'projects', :action => 'list_files', :id => @project + flash.now[:notice] = l(:notice_file_not_found) + render :text => "", :layout => true, :status => 404 end def destroy_file diff --git a/redmine/app/helpers/ifpdf_helper.rb b/redmine/app/helpers/ifpdf_helper.rb index e09136db..4e7a173f 100644 --- a/redmine/app/helpers/ifpdf_helper.rb +++ b/redmine/app/helpers/ifpdf_helper.rb @@ -20,7 +20,9 @@ require 'iconv' module IfpdfHelper class IFPDF < FPDF - + + attr_accessor :footer_date + 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 @@ -32,9 +34,12 @@ module IfpdfHelper end def Footer + SetFont('Helvetica', 'I', 8) + SetY(-15) + SetX(15) + Cell(0, 5, @footer_date, 0, 0, 'L') SetY(-15) SetX(-30) - SetFont('Helvetica', 'I', 8) Cell(0, 5, PageNo().to_s + '/{nb}', 0, 0, 'C') end diff --git a/redmine/app/views/issues/export_pdf.rfpdf b/redmine/app/views/issues/export_pdf.rfpdf index b3756d8c..a8622dd5 100644 --- a/redmine/app/views/issues/export_pdf.rfpdf +++ b/redmine/app/views/issues/export_pdf.rfpdf @@ -1,5 +1,6 @@ <% pdf=IfpdfHelper::IFPDF.new pdf.AliasNbPages + pdf.footer_date = format_date(Date.today) pdf.AddPage render :partial => 'issues/pdf', :locals => { :pdf => pdf, :issue => @issue } diff --git a/redmine/app/views/projects/activity.rhtml b/redmine/app/views/projects/activity.rhtml index 84275a6e..670e572a 100644 --- a/redmine/app/views/projects/activity.rhtml +++ b/redmine/app/views/projects/activity.rhtml @@ -13,7 +13,7 @@ <%= end_form_tag %> <% @events_by_day.keys.sort {|x,y| y <=> x }.each do |day| %> -

<%= format_date(day) %>

+

<%= day_name(day.cwday) %> <%= format_date(day) %>

<% end %> -

<%= issue.fixed_version.name %> - <%= format_date(issue.fixed_version.effective_date) %>
+

<%= l(:label_version) %>: <%= issue.fixed_version.name %>

+

<%= format_date(issue.fixed_version.effective_date) %>
<%=h issue.fixed_version.description %>