Skip to content

Instantly share code, notes, and snippets.

@drewblumberg
Created September 5, 2013 16:13
Show Gist options
  • Save drewblumberg/6452351 to your computer and use it in GitHub Desktop.
Save drewblumberg/6452351 to your computer and use it in GitHub Desktop.
Datagrid for progress reports
class Manage::ProgressReportsDatagrid
include Datagrid
scope do
ProgressReport.joins(:project => :account).includes(:project => :account)#.where("projects.manager_id" => )
end
# filter :name, :string do |val|
# self.where "accounts.name ILIKE ?", "%#{val}%"
# end
# filter :starts_on, :date, :header => 'Start of care date'
# filter :ends_on, :date, :header => 'Discharge date'
# filter :dob, :date, :header => 'DOB' do |val|
# self.where "accounts.dob = ?", val
# end
column :name, :header => 'Account', :html => true do |pr|
link_to pr.project.account.name, edit_manage_account_path(pr.project.account)
end
column :title, :header => 'Project', :html => true do |pr|
if !pr.project.title.nil?
link_to pr.project.title, edit_manage_project_path(pr.project)
end
end
column :due_date, :order => 'progress_reports.due_date' do |pr|
pr.due_date.strftime('%m/%d/%Y')
end
column :status, :order => 'progress_reports.due_date'
column :actions, :html => true do |pr|
str = ''
if current_manager.can_write?
str << "#{link_to 'Update', edit_manage_progress_report_path(pr), :class => 'link-edit'} "
end
str + link_to('Print', manage_progress_report_path(pr, :format => :pdf), :class => 'icon link-print', :target => '_blank')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment