diff --git app/models/mailer.rb app/models/mailer.rb
index 4bfa45b..21a62a2 100644
--- app/models/mailer.rb
+++ app/models/mailer.rb
@@ -97,10 +97,11 @@ class Mailer < ActionMailer::Base
end
end
- def reminder(user, issues, days)
+ def reminder(user, issues, days, respect_working_days)
set_language_if_valid user.language
@issues = issues
@days = days
+ @respect_working_days = respect_working_days
@issues_url = url_for(:controller => 'issues', :action => 'index',
:set_filter => 1, :assigned_to_id => user.id,
:sort => 'due_date:asc')
@@ -324,12 +325,16 @@ class Mailer < ActionMailer::Base
# Sends reminders to issue assignees
# Available options:
- # * :days => how many days in the future to remind about (defaults to 7)
- # * :tracker => id of tracker for filtering issues (defaults to all trackers)
- # * :project => id or identifier of project to process (defaults to all projects)
- # * :users => array of user/group ids who should be reminded
- # * :version => name of target version for filtering issues (defaults to none)
+ # * :days => how many days in the future to remind about (defaults to 7)
+ # * :tracker => id of tracker for filtering issues (defaults to all trackers)
+ # * :project => id or identifier of project to process (defaults to all projects)
+ # * :users => array of user/group ids who should be reminded
+ # * :version => name of target version for filtering issues (defaults to none)
+ # * :respect_working_days => if true the working days setting will be used to calculate the date difference
def self.reminders(options={})
+
+ extend Redmine::Utils::DateCalculation
+
days = options[:days] || 7
project = options[:project] ? Project.find(options[:project]) : nil
tracker = options[:tracker] ? Tracker.find(options[:tracker]) : nil
@@ -339,6 +344,12 @@ class Mailer < ActionMailer::Base
end
user_ids = options[:users]
+ days_requested = days
+ if options[:respect_working_days]
+ working_day_count = working_days(Date.today, (days + 7).day.from_now.to_date)
+ days = days + (days + 7 - working_day_count)
+ end
+
scope = Issue.open.where("#{Issue.table_name}.assigned_to_id IS NOT NULL" +
" AND #{Project.table_name}.status = #{Project::STATUS_ACTIVE}" +
" AND #{Issue.table_name}.due_date <= ?", days.day.from_now.to_date
@@ -359,7 +370,7 @@ class Mailer < ActionMailer::Base
end
issues_by_assignee.each do |assignee, issues|
- reminder(assignee, issues, days).deliver if assignee.is_a?(User) && assignee.active?
+ reminder(assignee, issues, days_requested, options[:respect_working_days]).deliver if assignee.is_a?(User) && assignee.active?
end
end
diff --git app/views/mailer/reminder.html.erb app/views/mailer/reminder.html.erb
index 506fd69..0394426 100644
--- app/views/mailer/reminder.html.erb
+++ app/views/mailer/reminder.html.erb
@@ -1,4 +1,4 @@
-
<%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %>
+<%= l(@respect_working_days ? :mail_body_reminder_working_days : :mail_body_reminder, :count => @issues.size, :days => @days) %>
<% @issues.each do |issue| -%>
diff --git app/views/mailer/reminder.text.erb app/views/mailer/reminder.text.erb
index c9e27dc..a48b2dd 100644
--- app/views/mailer/reminder.text.erb
+++ app/views/mailer/reminder.text.erb
@@ -1,4 +1,4 @@
-<%= l(:mail_body_reminder, :count => @issues.size, :days => @days) %>:
+<%= l(@respect_working_days ? :mail_body_reminder_working_days : :mail_body_reminder, :count => @issues.size, :days => @days) %>
<% @issues.each do |issue| -%>
* <%= "#{issue.project} - #{issue.tracker} ##{issue.id}: #{issue.subject}" %>
diff --git config/locales/de.yml config/locales/de.yml
index 5d0a14b..7129339 100644
--- config/locales/de.yml
+++ config/locales/de.yml
@@ -846,6 +846,7 @@ de:
mail_body_lost_password: 'Benutzen Sie den folgenden Link, um Ihr Kennwort zu ändern:'
mail_body_register: 'Um Ihr Konto zu aktivieren, benutzen Sie folgenden Link:'
mail_body_reminder: "%{count} Tickets, die Ihnen zugewiesen sind, müssen in den nächsten %{days} Tagen abgegeben werden:"
+ mail_body_reminder_working_days: "%{count} Tickets, die Ihnen zugewiesen sind, müssen in den nächsten %{days} Arbeitstagen abgegeben werden:"
mail_body_wiki_content_added: "Die Wiki-Seite '%{id}' wurde von %{author} hinzugefügt."
mail_body_wiki_content_updated: "Die Wiki-Seite '%{id}' wurde von %{author} aktualisiert."
mail_subject_account_activation_request: "Antrag auf %{value} Kontoaktivierung"
diff --git config/locales/en-GB.yml config/locales/en-GB.yml
index 67d53b5..e46720d 100644
--- config/locales/en-GB.yml
+++ config/locales/en-GB.yml
@@ -209,6 +209,7 @@ en-GB:
mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
mail_subject_reminder: "%{count} issue(s) due in the next %{days} days"
mail_body_reminder: "%{count} issue(s) that are assigned to you are due in the next %{days} days:"
+ mail_body_reminder_working_days: "%{count} issue(s) that are assigned to you are due in the next %{days} working days:"
mail_subject_wiki_content_added: "'%{id}' wiki page has been added"
mail_body_wiki_content_added: "The '%{id}' wiki page has been added by %{author}."
mail_subject_wiki_content_updated: "'%{id}' wiki page has been updated"
diff --git config/locales/en.yml config/locales/en.yml
index 4955ee5..8c52606 100644
--- config/locales/en.yml
+++ config/locales/en.yml
@@ -216,6 +216,7 @@ en:
mail_body_account_activation_request: "A new user (%{value}) has registered. The account is pending your approval:"
mail_subject_reminder: "%{count} issue(s) due in the next %{days} days"
mail_body_reminder: "%{count} issue(s) that are assigned to you are due in the next %{days} days:"
+ mail_body_reminder_working_days: "%{count} issue(s) that are assigned to you are due in the next %{days} working days:"
mail_subject_wiki_content_added: "'%{id}' wiki page has been added"
mail_body_wiki_content_added: "The '%{id}' wiki page has been added by %{author}."
mail_subject_wiki_content_updated: "'%{id}' wiki page has been updated"
diff --git lib/tasks/reminder.rake lib/tasks/reminder.rake
index 3807297..03a01a6 100644
--- lib/tasks/reminder.rake
+++ lib/tasks/reminder.rake
@@ -37,6 +37,7 @@ namespace :redmine do
options[:tracker] = ENV['tracker'].to_i if ENV['tracker']
options[:users] = (ENV['users'] || '').split(',').each(&:strip!)
options[:version] = ENV['version'] if ENV['version']
+ options[:respect_working_days] = !!ENV['respect_working_days']
Mailer.with_synched_deliveries do
Mailer.reminders(options)