mirror of https://github.com/interlegis/sapl.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
110 lines
3.5 KiB
110 lines
3.5 KiB
{% extends "crud/form.html" %}
|
|
{% load i18n %}
|
|
{% load crispy_forms_tags %}
|
|
{% load common_tags %}
|
|
|
|
{% block extra_js %}
|
|
|
|
<script language="Javascript">
|
|
function recuperar_materia() {
|
|
var tipo_materia = $("#id_tipo_materia").val();
|
|
var numero_materia = $("#id_numero_materia").val();
|
|
var ano_materia = $("#id_ano_materia").val();
|
|
var tipo = $('#id_tipo').val();
|
|
var ano = $('#id_ano').val();
|
|
var numero = $('#id_numero').val();
|
|
var ementa = $('#id_ementa').val();
|
|
if (tipo_materia && numero_materia && ano_materia) {
|
|
$.get("/sessao/recuperar-materia",
|
|
{tipo_materia: tipo_materia,
|
|
numero_materia: numero_materia,
|
|
ano_materia: ano_materia},
|
|
function(data, status) {
|
|
$("#id_ementa").val(data.ementa);
|
|
$("#id_indexacao").val(data.indexacao);
|
|
}
|
|
);
|
|
}
|
|
}
|
|
var fields = ["#id_tipo_materia", "#id_numero_materia", "#id_ano_materia"]
|
|
for (i = 0; i < fields.length; i++) {
|
|
$(fields[i]).change(recuperar_materia);
|
|
}
|
|
|
|
function recuperar_norma() {
|
|
var tipo = $("#id_tipo").val();
|
|
var ano = $("#id_ano").val();
|
|
|
|
if (tipo) {
|
|
$.get("/norma/recuperar-numero-norma",{tipo: tipo,
|
|
ano: ano},
|
|
function(data, status) {
|
|
$("#id_numero").val(data.numero);
|
|
$("#id_ano").val(data.ano);
|
|
});
|
|
}
|
|
}
|
|
var fields = ["#id_tipo", "#id_ano"];
|
|
for (i = 0; i < fields.length; i++) {
|
|
$(fields[i]).change(recuperar_norma);
|
|
}
|
|
|
|
var numeroField = $("#id_numero");
|
|
|
|
numeroField.keyup(function() {
|
|
var numero = numeroField.val();
|
|
if (numero.startsWith("0")) {
|
|
numeroField.val(numero.replace(/^0+/, ''));
|
|
}
|
|
});
|
|
|
|
var modal_estilos = 'display: block;'
|
|
+'width: 85%; max-width: 600px;'
|
|
+'background: #fff; padding: 15px;'
|
|
+'border-radius: 5px;'
|
|
+'-webkit-box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);'
|
|
+'-moz-box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);'
|
|
+'box-shadow: 0px 6px 14px -2px rgba(0,0,0,0.75);'
|
|
+'position: fixed;'
|
|
+'top: 50%; left: 50%;'
|
|
+'transform: translate(-50%,-50%);'
|
|
+'z-index: 99999999; text-align: center';
|
|
|
|
var fundo_modal_estilos = 'top: 0; right: 0;'
|
|
+'bottom: 0; left: 0; position: fixed;'
|
|
+'background-color: rgba(0, 0, 0, 0.6); z-index: 99999999;'
|
|
+'display: none;';
|
|
|
|
var meu_modal = '<div id="fundo_modal" style="'+fundo_modal_estilos+'">'
|
|
+'<div id="meu_modal" style="'+modal_estilos+'">'
|
|
+'<h2>Atenção! Ano de apresentação e ano da norma são diferentes.</h2><br />'
|
|
+'<button id="close_model_btn" type="button" class="btn btn-warning" data-dismiss="modal">'
|
|
+'Compreendo e quero continuar</button>'
|
|
+'</div></div>';
|
|
|
|
function verifica_ano(){
|
|
let ano = $("select#id_ano.select").val();
|
|
let data_apresentacao = $("input#id_data.dateinput").val();
|
|
let ano_apresentacao = data_apresentacao.substr(data_apresentacao.length - 4);
|
|
|
|
if(ano && ano_apresentacao && ano_apresentacao != ano){
|
|
$('#fundo_modal').fadeIn();
|
|
}
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
$("body").append(meu_modal);
|
|
|
|
$("#fundo_modal, #close_model_btn").click(function(){ $("#fundo_modal").hide(); });
|
|
$("#meu_modal").click(function(e){ e.stopPropagation(); });
|
|
|
|
$("select#id_ano.select.form-control").blur(function(){
|
|
verifica_ano();
|
|
});
|
|
$("input#id_data.dateinput.form-control").blur(function(){
|
|
verifica_ano();
|
|
});
|
|
});
|
|
</script>
|
|
|
|
{% endblock %}
|
|
|