You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

calendars_controller.rb 2.2KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. # frozen_string_literal: true
  2. # Redmine - project management software
  3. # Copyright (C) 2006-2021 Jean-Philippe Lang
  4. #
  5. # This program is free software; you can redistribute it and/or
  6. # modify it under the terms of the GNU General Public License
  7. # as published by the Free Software Foundation; either version 2
  8. # of the License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU General Public License
  16. # along with this program; if not, write to the Free Software
  17. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  18. class CalendarsController < ApplicationController
  19. menu_item :calendar
  20. before_action :find_optional_project
  21. rescue_from Query::StatementInvalid, :with => :query_statement_invalid
  22. helper :issues
  23. helper :projects
  24. helper :queries
  25. include QueriesHelper
  26. def show
  27. if params[:year] and params[:year].to_i > 1900
  28. @year = params[:year].to_i
  29. if params[:month] and params[:month].to_i > 0 and params[:month].to_i < 13
  30. @month = params[:month].to_i
  31. end
  32. end
  33. @year ||= User.current.today.year
  34. @month ||= User.current.today.month
  35. @calendar = Redmine::Helpers::Calendar.new(Date.civil(@year, @month, 1), current_language, :month)
  36. retrieve_query
  37. @query.group_by = nil
  38. @query.sort_criteria = nil
  39. if @query.valid?
  40. events = []
  41. events +=
  42. @query.issues(
  43. :include => [:tracker, :assigned_to, :priority],
  44. :conditions => [
  45. "((start_date BETWEEN ? AND ?) OR (due_date BETWEEN ? AND ?))",
  46. @calendar.startdt, @calendar.enddt,
  47. @calendar.startdt, @calendar.enddt
  48. ]
  49. )
  50. events +=
  51. @query.versions(
  52. :conditions => [
  53. "effective_date BETWEEN ? AND ?",
  54. @calendar.startdt, @calendar.enddt
  55. ]
  56. )
  57. @calendar.events = events
  58. end
  59. render :action => 'show', :layout => false if request.xhr?
  60. end
  61. end