ol.breadcrumb li.active Relatórios do Planejamento section.widget header h5 span.fw-semi-bold ' RELATÓRIO DO PLANEJAMENTO .widget-body = form_tag(impressoes_path, id: 'form_impressao', method: :post, target: "_blank") do input(type="hidden" name="data_pdf" value="") .brbr .brbr .halfbr a.link_modal.form-pdf#folha_de_pagamento href="#" Dados da Folha de Pagamento #myModal.modal.fade role="dialog" style="height: 100%" aria-hidden="true" .modal-dialog role="document" .modal-content .modal-header button.close aria-label="Close" data-dismiss="modal" type="button" span aria-hidden="true" × h4 Dados da Folha de Pagamento = simple_form_for( @relatorio_do_planejamento, url: imprimir_loa_relatorios_do_planejamento_index_path(), method: :get, html: {id: "form-modal", target: "_blank"} ) do |f| = f.input :relatorio, as: :hidden, input_html: { id: "relatorio" } = f.input :orcamento_id, as: :hidden, input_html: { value: "#{contexto_atual.id}" } = f.hidden_field :button, id: 'planejamento' .modal-body .row .col-sm-5 = f.input :mes, label: "Mês", collection: @meses, include_blank: "Selecione", input_html: { class: 's2', id: 'mes'} .col-sm-7 = f.input :unidade_orcamentaria, label: "Unidade Orçamentaria", collection: @unidades_orcamentarias, label_method: :codigo_e_nome, include_blank: "Selecione", input_html: {class: "s2" , id: "unidades_orcamentaria"} .row .col-sm-9 .col-sm-3 = f.button :button, 'Gerar PDF', type: 'button', name: "tipo_de_relatorio", value: "pdf", class: "btn btn-success", id: "botao_pdf" javascript: $(document).ready(function(){ $(".div-form").hide(); $(".submit-pdf").hide(); $("#botao_pdf").on("click", function(){ if($("#mes").val() != ""){ $('#planejamento').val('pdf') $('#form-modal').submit(); } }); $(".link_modal").on("click", function(){ reiniciaModal(); selecionaFormParaExibir($(this)); exibirBotoesSubmit($(this)); }); }); function reiniciaModal(){ $("#form-modal")[0].reset(); $("#myModal").modal("show"); } function selecionaFormParaExibir(modalSelecionado){ var idDoElemento = $(modalSelecionado).attr("id"); $("." + idDoElemento).show() $("#relatorio").val(idDoElemento) $(".select2-container").width("100%"); } function exibirBotoesSubmit(modalSelecionado) { if (modalSelecionado.hasClass("form-pdf")) { $("#botao_pdf").show(); } else { $(".submit-pdf").hide(); } }