@@ -304,53 +304,6 private | |||||
304 | scope |
|
304 | scope | |
305 | end |
|
305 | end | |
306 |
|
306 | |||
307 | # Retrieves the date range based on predefined ranges or specific from/to param dates |
|
|||
308 | def retrieve_date_range |
|
|||
309 | @free_period = false |
|
|||
310 | @from, @to = nil, nil |
|
|||
311 |
|
||||
312 | if params[:period_type] == '1' || (params[:period_type].nil? && !params[:period].nil?) |
|
|||
313 | case params[:period].to_s |
|
|||
314 | when 'today' |
|
|||
315 | @from = @to = Date.today |
|
|||
316 | when 'yesterday' |
|
|||
317 | @from = @to = Date.today - 1 |
|
|||
318 | when 'current_week' |
|
|||
319 | @from = Date.today - (Date.today.cwday - 1)%7 |
|
|||
320 | @to = @from + 6 |
|
|||
321 | when 'last_week' |
|
|||
322 | @from = Date.today - 7 - (Date.today.cwday - 1)%7 |
|
|||
323 | @to = @from + 6 |
|
|||
324 | when 'last_2_weeks' |
|
|||
325 | @from = Date.today - 14 - (Date.today.cwday - 1)%7 |
|
|||
326 | @to = @from + 13 |
|
|||
327 | when '7_days' |
|
|||
328 | @from = Date.today - 7 |
|
|||
329 | @to = Date.today |
|
|||
330 | when 'current_month' |
|
|||
331 | @from = Date.civil(Date.today.year, Date.today.month, 1) |
|
|||
332 | @to = (@from >> 1) - 1 |
|
|||
333 | when 'last_month' |
|
|||
334 | @from = Date.civil(Date.today.year, Date.today.month, 1) << 1 |
|
|||
335 | @to = (@from >> 1) - 1 |
|
|||
336 | when '30_days' |
|
|||
337 | @from = Date.today - 30 |
|
|||
338 | @to = Date.today |
|
|||
339 | when 'current_year' |
|
|||
340 | @from = Date.civil(Date.today.year, 1, 1) |
|
|||
341 | @to = Date.civil(Date.today.year, 12, 31) |
|
|||
342 | end |
|
|||
343 | elsif params[:period_type] == '2' || (params[:period_type].nil? && (!params[:from].nil? || !params[:to].nil?)) |
|
|||
344 | begin; @from = params[:from].to_s.to_date unless params[:from].blank?; rescue; end |
|
|||
345 | begin; @to = params[:to].to_s.to_date unless params[:to].blank?; rescue; end |
|
|||
346 | @free_period = true |
|
|||
347 | else |
|
|||
348 | # default |
|
|||
349 | end |
|
|||
350 |
|
||||
351 | @from, @to = @to, @from if @from && @to && @from > @to |
|
|||
352 | end |
|
|||
353 |
|
||||
354 | def parse_params_for_bulk_time_entry_attributes(params) |
|
307 | def parse_params_for_bulk_time_entry_attributes(params) | |
355 | attributes = (params[:time_entry] || {}).reject {|k,v| v.blank?} |
|
308 | attributes = (params[:time_entry] || {}).reject {|k,v| v.blank?} | |
356 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} |
|
309 | attributes.keys.each {|k| attributes[k] = '' if attributes[k] == 'none'} |
General Comments 0
You need to be logged in to leave comments.
Login now