diff --git a/app/controllers/concerns/shared_pdf_concern.rb b/app/controllers/concerns/shared_pdf_concern.rb index af78e2ce..ec5bc9fc 100644 --- a/app/controllers/concerns/shared_pdf_concern.rb +++ b/app/controllers/concerns/shared_pdf_concern.rb @@ -34,7 +34,7 @@ def render_course_classes_summary_pdf(course_class) ) end - def render_enrollments_academic_transcript_pdf(enrollment, filename = "transcript.pdf") + def render_enrollments_academic_transcript_pdf(enrollment, filename = "transcript.pdf", signature_override = nil) class_enrollments = enrollment.class_enrollments .where(situation: ClassEnrollment::APPROVED) .joins(:course_class) @@ -51,11 +51,12 @@ def render_enrollments_academic_transcript_pdf(enrollment, filename = "transcrip enrollment: enrollment, class_enrollments: class_enrollments, accomplished_phases: accomplished_phases, + signature_override: signature_override } ) end - def render_enrollments_grades_report_pdf(enrollment, filename = "grades_report.pdf") + def render_enrollments_grades_report_pdf(enrollment, filename = "grades_report.pdf", signature_override = nil) class_enrollments = enrollment.class_enrollments .where(situation: ClassEnrollment::APPROVED) .joins(:course_class) @@ -71,7 +72,8 @@ def render_enrollments_grades_report_pdf(enrollment, filename = "grades_report.p enrollment: enrollment, class_enrollments: class_enrollments, accomplished_phases: accomplished_phases, - deferrals: deferrals + deferrals: deferrals, + signature_override: signature_override } ) end diff --git a/app/controllers/enrollments_controller.rb b/app/controllers/enrollments_controller.rb index 8e4dcb7c..cbba7774 100644 --- a/app/controllers/enrollments_controller.rb +++ b/app/controllers/enrollments_controller.rb @@ -143,7 +143,8 @@ class EnrollmentsController < ApplicationController :accomplishments, :deferrals, :phase_due_dates ] config.update.columns = columns - [:phase_due_dates] - config.show.columns = columns - [:accomplishments] + config.show.columns = columns - [:accomplishments] + config.show.columns.add :academic_transcript, :grades_report config.actions.exclude :deleted_records end @@ -213,28 +214,36 @@ def to_pdf end end - def academic_transcript_pdf + def override_signature_transcript_pdf + academic_transcript_pdf(params[:signature_type]) + end + + def override_signature_grades_report_pdf + grades_report_pdf(params[:signature_type]) + end + + def academic_transcript_pdf(signature_type = nil) enrollment = Enrollment.find(params[:id]) respond_to do |format| format.pdf do title = I18n.t("pdf_content.enrollment.academic_transcript.title") student = enrollment.student.name filename = "#{title} - #{student}.pdf" - send_data render_enrollments_academic_transcript_pdf(enrollment, filename), + send_data render_enrollments_academic_transcript_pdf(enrollment, filename, signature_type), filename: filename, type: "application/pdf" end end end - def grades_report_pdf + def grades_report_pdf(signature_type = nil) enrollment = Enrollment.find(params[:id]) respond_to do |format| format.pdf do title = I18n.t("pdf_content.enrollment.grades_report.title") student = enrollment.student.name filename = "#{title} - #{student}.pdf" - send_data render_enrollments_grades_report_pdf(enrollment, filename), + send_data render_enrollments_grades_report_pdf(enrollment, filename, signature_type), filename: filename, type: "application/pdf" end diff --git a/app/helpers/enrollments_helper.rb b/app/helpers/enrollments_helper.rb index efd9f976..be4ff076 100644 --- a/app/helpers/enrollments_helper.rb +++ b/app/helpers/enrollments_helper.rb @@ -100,7 +100,7 @@ def delayed_phase_search_column(record, input_name) :record, :phases, options_for_select([["Alguma", "all"]] + Phase.where(active: true).map { |phase| [phase.name, phase.id] } - ), + ), { include_blank: as_(:_select_) }, select_html_options ) + @@ -120,14 +120,14 @@ def accomplishments_search_column(record, input_name) select_html_options = { name: "search[accomplishments][phase]" } day_html_options = { name: "search[accomplishments][day]" } month_html_options = { name: "search[accomplishments][month]" } - year_html_options = { name: "search[accomplishments][year]"} + year_html_options = { name: "search[accomplishments][year]" } ( select( :record, :phases, options_for_select([["Todas", "all"]] + Phase.all.map { |phase| [phase.name, phase.id] } - ), + ), { include_blank: as_(:_select_) }, select_html_options ) + @@ -339,4 +339,14 @@ def options_for_association_conditions(association, record) def permit_rs_browse_params [:page, :update, :utf8] end + + def academic_transcript_show_column(record, column) + render(partial: "enrollments/show_academic_transcript_signature_override_links", + locals: { record: record }) + end + + def grades_report_show_column(record, column) + render(partial: "enrollments/show_grades_report_signature_override_links", + locals: { record: record }) + end end diff --git a/app/helpers/pdf_helper.rb b/app/helpers/pdf_helper.rb index 512b29f9..61896ab0 100644 --- a/app/helpers/pdf_helper.rb +++ b/app/helpers/pdf_helper.rb @@ -508,9 +508,14 @@ def qrcode_signature(pdf, options = {}) def setup_pdf_config(pdf_type, options) pdf_type_property = :"use_at_#{pdf_type}" - options[:pdf_config] || - ReportConfiguration.where(pdf_type_property => true).order(order: :desc).first || - ReportConfiguration.new + config = options[:pdf_config] || + ReportConfiguration.where(pdf_type_property => true).order(order: :desc).first || + ReportConfiguration.new + if options[:signature_override].present? + config.signature_type = options[:signature_override] + end + + config end def generate_qr_code_key diff --git a/app/views/enrollments/_show_academic_transcript_signature_override_links.html.erb b/app/views/enrollments/_show_academic_transcript_signature_override_links.html.erb new file mode 100644 index 00000000..82ba1285 --- /dev/null +++ b/app/views/enrollments/_show_academic_transcript_signature_override_links.html.erb @@ -0,0 +1,5 @@ +
+ <%= link_to 'Sem Assinatura', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :no_signature), target: "_blank" %> + <%= link_to 'Assinatura Manual', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :manual), target: "_blank" %> + <%= link_to 'Assinatura por QR Code', override_signature_transcript_pdf_enrollment_path(id: @record.id, signature_type: :qr_code), target: "_blank" %> +
diff --git a/app/views/enrollments/_show_grades_report_signature_override_links.html.erb b/app/views/enrollments/_show_grades_report_signature_override_links.html.erb new file mode 100644 index 00000000..de761741 --- /dev/null +++ b/app/views/enrollments/_show_grades_report_signature_override_links.html.erb @@ -0,0 +1,7 @@ +
+
+ <%= link_to 'Sem Assinatura', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :no_signature, transcript: true), target: "_blank" %> + <%= link_to 'Assinatura Manual', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :manual, transcript: true), target: "_blank" %> + <%= link_to 'Assinatura por QR Code', override_signature_grades_report_pdf_enrollment_path(id: @record.id, signature_type: :qr_code, transcript: true), target: "_blank" %> +
+
\ No newline at end of file diff --git a/app/views/enrollments/academic_transcript_pdf.pdf.prawn b/app/views/enrollments/academic_transcript_pdf.pdf.prawn index 8d1f849a..028a820b 100644 --- a/app/views/enrollments/academic_transcript_pdf.pdf.prawn +++ b/app/views/enrollments/academic_transcript_pdf.pdf.prawn @@ -11,7 +11,8 @@ new_document( watermark: cannot?( :generate_report_without_watermark, @enrollment ), - pdf_type: :transcript + pdf_type: :transcript, + signature_override: @signature_override ) do |pdf| enrollment_student_header(pdf, enrollment: @enrollment) diff --git a/app/views/enrollments/grades_report_pdf.pdf.prawn b/app/views/enrollments/grades_report_pdf.pdf.prawn index 6225dfc2..894056af 100644 --- a/app/views/enrollments/grades_report_pdf.pdf.prawn +++ b/app/views/enrollments/grades_report_pdf.pdf.prawn @@ -11,7 +11,8 @@ new_document( :generate_report_without_watermark, @enrollment ) ), - pdf_type: :grades_report + pdf_type: :grades_report, + signature_override: @signature_override ) do |pdf| enrollment_student_header(pdf, enrollment: @enrollment) diff --git a/config/locales/enrollment.pt-BR.yml b/config/locales/enrollment.pt-BR.yml index 29edb2a2..7c256888 100644 --- a/config/locales/enrollment.pt-BR.yml +++ b/config/locales/enrollment.pt-BR.yml @@ -42,6 +42,8 @@ pt-BR: thesis_defense_committee_professors: "Banca Avaliadora" accomplishment_conclusion_date_not_given: "---------/----" obs_to_academic_transcript: "Observação para o Histórico" + grades_report: "Boletim" + academic_transcript: "Histórico" errors: models: diff --git a/config/routes.rb b/config/routes.rb index 9d4f1f08..de6b21bc 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -187,7 +187,9 @@ end member do get "academic_transcript_pdf" + get "academic_transcript/:signature_type.pdf", to: "enrollments#override_signature_transcript_pdf", as: :override_signature_transcript_pdf get "grades_report_pdf" + get "grades_report/:signature_type.pdf", to: "enrollments#override_signature_grades_report_pdf", as: :override_signature_grades_report_pdf end end