Skip to content

Commit

Permalink
Declaração sendo gerada a partir da query com texto fixo.
Browse files Browse the repository at this point in the history
  • Loading branch information
¨caiovelp¨ committed Sep 11, 2024
1 parent 04c0a7f commit 98f03c8
Show file tree
Hide file tree
Showing 5 changed files with 51 additions and 12 deletions.
4 changes: 3 additions & 1 deletion app/helpers/assertions_helper.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
# app/helpers/assertions_helper.rb
module AssertionsHelper
include PdfHelper
include AssertionsPdfHelper
end

end
48 changes: 38 additions & 10 deletions app/helpers/assertions_pdf_helper.rb
Original file line number Diff line number Diff line change
@@ -1,14 +1,42 @@
# frozen_string_literal: true

# app/helpers/assertions_pdf_helper.rb
module AssertionsPdfHelper
def common_header_part(pdf, options = {}, &block)
data_table = yield
pdf.indent(5) do
text_table(pdf, data_table, 8)
end
include AssertionHelperConcern
def assertion_box_text_print(pdf)
pdf.move_down 50
text = I18n.t("activerecord.attributes.assertion.fixed")
box_width = 400
box_height = 100
pdf.text_box text, at: [(pdf.bounds.width - box_width) / 2, pdf.cursor], width: box_width, height: box_height, align: :justify, inline_format: true
end

def assertion_table(pdf, options = {})
assertions = options[:assertion]
assertion_box_text_print(pdf)
pdf.move_down 120

pdf.move_down 5
unless options[:hide_stroke]
pdf.horizontal_line 0, 560
results = get_avulso_results(assertions)
rows = results[:rows]

counter = 1
box_width = 400
rows.each do |row|
pdf.text_box(
"<b>#{counter}. Nome da disciplina: #{row[1]}</b>
<b>Carga horária total: #{row[2]}</b>
<b>Período: #{row[3]}.#{row[4]}</b>
<b>Nota final: #{row[5]}</b>
<b>Situação final: #{row[6]}</b>\n",
at: [(pdf.bounds.width - box_width) / 2, pdf.cursor],
width: box_width,
align: :left,
size: 12,
inline_format: true
)
counter += 1
pdf.move_down 80
end
end

end
end
end
6 changes: 6 additions & 0 deletions app/helpers/concerns/assertion_helper_concern.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# app/helpers/concerns/assertion_helper_concern.rb
module AssertionHelperConcern
def get_avulso_results(assertions)
assertions.query.execute
end
end
4 changes: 3 additions & 1 deletion app/views/assertions/assertion_pdf.pdf.prawn
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ new_document(
"Assertion",
pdf_type: :assertion
) do |pdf|
pdf.text "SQL Query:", size: 14, style: :bold
assertion_table(
pdf, assertion: @assertion
)

end
1 change: 1 addition & 0 deletions config/locales/assertion.pt-BR.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ pt-BR:
assertion:
name: "Nome da Declaração"
params: "Parâmetros configuráveis da declaração"
fixed: "TESTE - Declaro, para os devidos fins, que FULANO DE TAL, CPF: 000.000.000-00, cursou como aluno avulso as seguintes disciplinas do Programa de Pós-Graduação em Computação, nos termos do parágrafo único do Art. 18 do Regulamento dos Programas de Pós-Graduação Stricto Sensu da Universidade Federal Fluminense:"

models:
assertion:
Expand Down

0 comments on commit 98f03c8

Please sign in to comment.