Class: ReportsManager::LTReport

Inherits:
ApplicationService show all
Defined in:
app/services/reports_manager/lt_report.rb

Instance Method Summary collapse

Methods inherited from ApplicationService

call

Constructor Details

#initialize(user_id, property_id, report_type) ⇒ LTReport

Returns a new instance of LTReport.



5
6
7
8
9
# File 'app/services/reports_manager/lt_report.rb', line 5

def initialize(user_id, property_id, report_type)
  @user_id = user_id
  @property_id = property_id
  @report_type = report_type
end

Instance Method Details

#callObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'app/services/reports_manager/lt_report.rb', line 11

def call
  lt_defects = ApplicationHelper.lt_defects
  defect_ids = []
  lt_defects.each do |defect|
    defect_ids += defect[1]['ids']
  end
  defect_ids_str = defect_ids.join(',')

  view_data = {}
  view_data['header_text'] = 'U.S. INSPECTION GROUP, INC.'
  view_data['sub_header_text'] = 'Corp Office:  848 Livingston Road, Suite 101 PMB 53, Crossville, TN 38555 <br/>West Coast Office:  3652 Lake Park Road, Fallbrook, CA 92028<br/>PH: 866/863-8744  FX: 866/573-3280  E-mail: hazards@usinspectiongroup.com'
  view_data['footer_text'] = "<div style='margin-left: 25pt;'>\n \n Neither the inspector nor U.S. Inspection Group (USIG) assume any liability whatsoever expressed or implied that the above noted health and safety hazards constitute all of the health and safety deficiencies that may be present on the property.  Any and all liability for the health and safety hazards noted above, as well as any health and safety hazards that my exist on the property but were not observed by the inspector, are the full and absolute responsibility of the property owner and not the inspector nor USIG.\n\nA copy of this form was also sent to USIG's offices.</div>"

  view_data['property_id'] = @property_id
  view_data['user_id'] = @user_id
  view_data['report_type'] = @report_type
  view_data['property'] = Property.find_by_id(@property_id)
  view_data['lt_defects'] = lt_defects
  view_data['all_defects'] = true
  view_data['property_lt_defects'] = InspectionDetail.where(property_id: @property_id).where(deficiency_definition_id: defect_ids)
  view_data['user'] = User.find_by_id(@user_id)
  view_data['file_name'] = view_data['property']['property_name'].gsub('[^A-Za-z0-9]', '-') + '-LT_Defects'
  view_data['getSource'] = 'S'
  view_data
end