-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
03b456c
commit a8469bc
Showing
8 changed files
with
99 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
# frozen_string_literal: true | ||
|
||
module ReportsHelper | ||
include PdfHelper | ||
|
||
def create_external_report_pdf(report, document_data = {}) | ||
render_to_string( | ||
template: "reports/external_report_pdf", | ||
type: "application/pdf", | ||
formats: [:pdf], | ||
assigns: { report: report, title: document_data[:title], document_body: document_data[:body], expiration_in_months: document_data[:expiration_in_months] } | ||
) | ||
end | ||
|
||
def report_body_text(pdf, document_body) | ||
pdf.bounding_box([(pdf.bounds.width - 500) / 2, pdf.cursor], width: 500, height: pdf.bounds.height - 98) do | ||
pdf.font("Times-Roman", size: 12) do | ||
pdf.move_down 30 | ||
|
||
pdf.text document_body, align: :justify | ||
end | ||
end | ||
end | ||
|
||
def document_body_form_column(record, options) | ||
text_area :record, :document_body, options.merge!(rows: 20, cols: 80) | ||
end | ||
|
||
def document_title_form_column(record, options) | ||
text_field :record, :document_title, options.merge!(value: "DECLARAÇÃO") | ||
end | ||
|
||
def expiration_in_months_form_column(record, options) | ||
merge_options = { min: 1, value: ReportConfiguration.where(use_at_assertion: true).order(order: :desc).first&.expiration_in_months } | ||
number_field :record, :expiration_in_months, options.merge!(merge_options) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# Copyright (c) Universidade Federal Fluminense (UFF). | ||
# This file is part of SAPOS. Please, consult the license terms in the LICENSE file. | ||
|
||
# frozen_string_literal: true | ||
|
||
require "prawn/measurement_extensions" | ||
|
||
new_document( | ||
@report.file_name, | ||
@title, | ||
override: { signature_type: :qr_code, expiration_in_months: @expiration_in_months }, | ||
pdf_type: :assertion, | ||
report: @report | ||
) do |pdf| | ||
report_body_text(pdf, @document_body) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters