diff --git a/app/controllers/reports_controller.rb b/app/controllers/reports_controller.rb index 836106386..9599f551c 100644 --- a/app/controllers/reports_controller.rb +++ b/app/controllers/reports_controller.rb @@ -146,14 +146,20 @@ class ReportsController < ApplicationController def generate content = params[:data] content = I18n.t('projects.reports.new.no_content_for_PDF_html') if content.blank? + + template = {} + respond_to do |format| format.pdf do - render pdf: 'report', header: { html: { template: 'reports/header.pdf.erb' }}, - footer: { html: { template: 'reports/footer.pdf.erb', - locals: { current_time: I18n.l(Time.zone.now, format: :full) }}}, + render pdf: 'report', header: { html: { template: 'reports/templates/template_1/_header.html.erb', locals: {template: template} }}, + footer: { html: { template: 'reports/templates/template_1/_footer.html.erb', locals: {template: template} }}, locals: { content: content }, - template: 'reports/report.pdf.erb', - disable_javascript: true + cover: render_to_string(partial: 'reports/templates/template_1/report.html.erb', + locals: { + template: template + }), + disable_javascript: true, + template: 'reports/report.pdf.erb' end format.docx do @user = current_user diff --git a/app/views/reports/templates/template_1/_footer.html.erb b/app/views/reports/templates/template_1/_footer.html.erb new file mode 100644 index 000000000..c7a4d0f52 --- /dev/null +++ b/app/views/reports/templates/template_1/_footer.html.erb @@ -0,0 +1,93 @@ + + + + + + + + + + + + + + + + + + +
+
+ ANALYST(S) +
+
+ <%= template[:analysts] %> +
+
+
+ ANALYST EMPLOYEE NO. +
+
+ <%= template[:analyst_number] %> +
+
+
+ CHECKED BY: +
+
+ <%= template[:checked_by] %> +
+
+ PAGE OF +
Single-Sided
+ + diff --git a/app/views/reports/templates/template_1/_header.html.erb b/app/views/reports/templates/template_1/_header.html.erb new file mode 100644 index 000000000..cd617006a --- /dev/null +++ b/app/views/reports/templates/template_1/_header.html.erb @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + +
+ GENERAL CONTINUATION SHEET + +
+ PRODUCT +
+
+ <%= template[:product] %> +
+
+
+ SAMPLE NUMBER +
+
+ <%= template[:sample_number] %> +
+
+ + diff --git a/app/views/reports/templates/template_1/_report.html.erb b/app/views/reports/templates/template_1/_report.html.erb new file mode 100644 index 000000000..a6ccbb77d --- /dev/null +++ b/app/views/reports/templates/template_1/_report.html.erb @@ -0,0 +1,300 @@ + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ ANALYST WORKSHEET + +
+ 1. PRODUCT +
+
+ <%= template[:product] %> +
+
+
+ 2. SAMPLE NUMBER +
+
+ <%= template[:sample_number] %> +
+
+ + + + + + + + + + +
+
+ 3. SEALS +
+
+ + INTACT +
+ + NONE + + + BROKEN +
+
+
+ 4. DATE RECEIVED +
+
+ <%= template[:date_recieved] %> +
+
+
+ 5.RECEIVED FROM +
+
+ <%= template[:recieved_from] %> +
+
+
+ 6. DISTRICT OR LABORATORY +
+
+ <%= template[:district_laboratory] %> +
+
+
+ 7. DESCRIPTION OF SAMPLE +
+
+ <%= template[:sample_description] %> +
+
+
+ 8. NET CONTENTS +
+
+ + + + + + + + + + + + + +
+ + NOT APPLICABLE + DECLARE/UNIT <%= template.dig(:net_contents, :declare_unit) %>
+ + NOT DETERMINED + AMOUNT FOUND <%= template.dig(:net_contents, :amount_found) %>
<%= template.dig(:net_contents, :units_examined) %> UNITS EXAMINED% of DECLARED <%= template.dig(:net_contents, :declared_percent) %>
+
+
+ 9. LABELING +
+
+ + + + + + + + + + +
+ <%= template.dig(:labeling, :originals_submitted) %> ORIGINAL(S) SUBMITTED +
+ <%= template.dig(:labeling, :copies_submitted) %> COPIES SUBMITTED +
+ + NONE +
+
+
+ 10. SUMMARY OF ANALYSIS +
+
+ <%= template[:analysis_summary] %> +
+
+
+ 11. RESERVE SAMPLE +
+
+ <%= template[:reserve_sample] %> +
+
+
+ 12. a. ANALYST SIGNATURE (Broke Seal ) +
+
+ <%= template.dig(:analyst_signature, :a) %> +
+
+
+ 13. WORKSHEET CHECK +
+
+
+ a. BY +
+
+ <%= template.dig(:worksheet_check, :by) %> +
+
+
+ b. DATE +
+
+ <%= template.dig(:worksheet_check, :date) %> +
+
+
+ b. +
+
+ <%= template.dig(:analyst_signature, :b) %> +
+
+
+ 13. DATE REPORTED +
+
+ <%= template[:date_reported] %> +
+
+
+ c. +
+
+ <%= template.dig(:analyst_signature, :c) %> +
+
+ PAGE 1 OF +
+