|
|
|
@ -17,18 +17,19 @@ class CalendarController < ApplicationController |
|
|
|
first_of_month = Date.new(@year, @month, 1) |
|
|
|
last_of_month = first_of_month.end_of_month |
|
|
|
|
|
|
|
start_date = first_of_month - (first_of_month.cwday - 1) |
|
|
|
end_date = last_of_month + (7 - last_of_month.cwday) |
|
|
|
|
|
|
|
@filter_typ = params[:typ] |
|
|
|
@filter_art = params[:art] |
|
|
|
|
|
|
|
@entries = current_user.entries |
|
|
|
.where(date: first_of_month..last_of_month) |
|
|
|
@entries = @entries.where(praktikums_typ: @filter_typ) if @filter_typ.present? |
|
|
|
@entries = @entries.where(entry_art: @filter_art) if @filter_art.present? |
|
|
|
@entries = @entries.group_by { |e| e.date.to_date } |
|
|
|
entries_scope = current_user.entries.where(date: start_date..end_date) |
|
|
|
entries_scope = entries_scope.where(praktikums_typ: @filter_typ) if @filter_typ.present? |
|
|
|
entries_scope = entries_scope.where(entry_art: @filter_art) if @filter_art.present? |
|
|
|
|
|
|
|
@entries = entries_scope.group_by { |e| e.date.to_date } |
|
|
|
|
|
|
|
puts @entries |
|
|
|
@days = (first_of_month..last_of_month).to_a |
|
|
|
@days = (start_date..end_date).to_a |
|
|
|
end |
|
|
|
|
|
|
|
def week |
|
|
|
@ -47,6 +48,8 @@ class CalendarController < ApplicationController |
|
|
|
first = Date.commercial(@year, @week, 1) |
|
|
|
last = Date.commercial(@year, @week, 7) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@filter_typ = params[:typ] |
|
|
|
@filter_art = params[:art] |
|
|
|
|
|
|
|
|