Skip to content

Commit

Permalink
scope work unit export by client/project
Browse files Browse the repository at this point in the history
  • Loading branch information
dchapman1988 committed Jun 26, 2018
1 parent 4c814e9 commit cd78980
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
10 changes: 8 additions & 2 deletions app/controllers/clients_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,14 @@ def show
end

def export_work_units
@client = Client.find(params[:client_id])
@work_units = WorkUnit.for_client(@client)
require 'pry';binding.pry
if params[:scope] == 'projects'
@project = Project.find(params[:project_id])
@work_units = WorkUnit.for_project(@project)
elsif params[:scope] == 'clients'
@client = Client.find(params[:client_id])
@work_units = WorkUnit.for_client(@client)
end
_params = params[:export_date]
@start_date = Date.parse("#{_params['start_date(1i)']}/#{_params['start_date(2i)']}/#{_params['start_date(3i)']}")
@end_date = Date.parse("#{_params['end_date(1i)']}/#{_params['end_date(2i)']}/#{_params['end_date(3i)']}") + 1.days
Expand Down
7 changes: 6 additions & 1 deletion app/views/shared/_work_unit_index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@
= date_select :export_date, :start_date
= label_tag "End Date"
= date_select :export_date, :end_date
= hidden_field_tag :client_id, params[:id]
- if params[:controller] == 'projects'
= hidden_field_tag :scope, 'projects'
= hidden_field_tag :project_id, params[:id]
- elsif params[:controller] == 'clients'
= hidden_field_tag :scope, 'clients'
= hidden_field_tag :client_id, params[:id]
%br/
%br/
= submit_tag 'Export Selected Date Range', :class => "data_export_icon"
Expand Down

0 comments on commit cd78980

Please sign in to comment.