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.
145 lines
4.5 KiB
145 lines
4.5 KiB
{% extends "crud/detail.html" %}
|
|
{% load i18n crispy_forms_tags %}
|
|
|
|
{% block detail_content %}
|
|
<form method="post">
|
|
{% csrf_token %}
|
|
|
|
<fieldset>
|
|
<legend>Votação Nominal</legend>
|
|
<div>
|
|
Matéria: {{materia.materia}}
|
|
<br />
|
|
Ementa: {{materia.ementa|safe}}
|
|
</div>
|
|
<br />
|
|
{% if total == 0 %}
|
|
<div class="alert alert-info alert-dismissible " role="alert">
|
|
<div>Não existe nenhum parlamentar presente para que a votação ocorra.</div>
|
|
</div>
|
|
<a href="{% url 'sapl.sessao:sessaoplenaria_detail' object.pk %}" class="btn btn-warning">Voltar</a>
|
|
{% else %}
|
|
<fieldset class="form-group">
|
|
|
|
<legend>Votos</legend>
|
|
<div class="row">
|
|
{% for parlamentar in parlamentares %}
|
|
<div class="col-md-4" id="styleparlamentar">{{parlamentar.0.nome_parlamentar}}</div>
|
|
<div class="col-md-5">
|
|
{% if parlamentar.1 %} <input type="hidden" name="voto_parlamentar" value="{{parlamentar.1}}:{{parlamentar.0.id}}" /> {% endif %}
|
|
<select onchange="salva_votos(this)" id="voto_parlamentar" name="voto_parlamentar" class="form-control" {% if parlamentar.1 %} disabled {% endif %}>
|
|
<option value="Não Votou:{{parlamentar.0.id}}">Não Votou</option>
|
|
<option value="Sim:{{parlamentar.0.id}}" {% if parlamentar.1 == 'Sim' %} selected {% endif %}>Sim</option>
|
|
<option value="Não:{{parlamentar.0.id}}" {% if parlamentar.1 == 'Não' %} selected {% endif %}>Não</option>
|
|
<option value="Abstenção:{{parlamentar.0.id}}" {% if parlamentar.1 == 'Abstenção' %} selected {% endif %}>Abstenção</option>
|
|
</select>
|
|
</div>
|
|
{% endfor %}
|
|
</div>
|
|
|
|
<legend>Situação da Votação:</legend>
|
|
<div id="soma_votos"></div>
|
|
|
|
</fieldset>
|
|
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
{{ form.resultado_votacao|as_crispy_field }}
|
|
</div>
|
|
</div>
|
|
|
|
<br />
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
Observações<br/>
|
|
<textarea id="observacao" name="observacao" style="width:100%;" rows="7"></textarea>
|
|
</div>
|
|
</div>
|
|
|
|
<br /><br />
|
|
<div class="row">
|
|
<div class="col-md-12">
|
|
<div class="form-group row justify-content-between">
|
|
<input type="submit" id="cancelar-votacao" name="cancelar-votacao" value="Cancelar Votação" class="btn btn-warning" />
|
|
<input type="submit" id="salvar-votacao" name="salvar-votacao" value="Fechar Votação" class="btn btn-primary" />
|
|
</div>
|
|
</div>
|
|
</div>
|
|
{% endif %}
|
|
</fieldset>
|
|
</form>
|
|
{% endblock detail_content %}
|
|
|
|
{% block extra_js %}
|
|
<script>
|
|
function voltar() {
|
|
window.history.back();
|
|
}
|
|
|
|
function conta_votos() {
|
|
var votos_sim = 0;
|
|
var votos_nao = 0;
|
|
var votos_abstencao = 0;
|
|
var nao_votou = 0;
|
|
$('[name=voto_parlamentar]').each(function() {
|
|
if (($(this).is(':hidden')) == false) {
|
|
switch ($(this).val().substring(0,4)) {
|
|
case "Sim:":
|
|
votos_sim = votos_sim + 1;
|
|
break;
|
|
case "Não:":
|
|
votos_nao = votos_nao + 1;
|
|
break;
|
|
case "Abst":
|
|
votos_abstencao = votos_abstencao + 1;
|
|
break;
|
|
case "Não ":
|
|
nao_votou = nao_votou + 1;
|
|
break;
|
|
};
|
|
};
|
|
});
|
|
|
|
$("#soma_votos").empty();
|
|
$("#soma_votos").append("<div class='row'><div class='col-md-12'>Sim: " + votos_sim + "</div></div>");
|
|
$("#soma_votos").append("<div class='row'><div class='col-md-12'>Não: " + votos_nao + "</div></div>");
|
|
$("#soma_votos").append("<div class='row'><div class='col-md-12'>Abstenções: " + votos_abstencao + "</div></div>");
|
|
$("#soma_votos").append("<div class='row'><div class='col-md-12'>Ainda não votaram: " + nao_votou + "</div></div>");
|
|
var t = setTimeout(function(){
|
|
conta_votos();
|
|
}, 500);
|
|
}
|
|
|
|
function salva_votos(event){
|
|
$(event).each(function() {
|
|
let value = $(this).val();
|
|
let parlamentar_id = value.split(":")[1];
|
|
let parlamentar_voto = value.substring(0,4);
|
|
let url = window.location.pathname;
|
|
let tmp = url.split('/');
|
|
let id_ordem_expediente = tmp[5];
|
|
let is_ordemdia = (tmp[3].split('mat')[1] == 'ordemdia');
|
|
$.get("{% url 'sapl.sessao:votacao_nominal_parlamentar' %}",
|
|
{
|
|
parlamentar_id: parlamentar_id,
|
|
parlamentar_voto: parlamentar_voto,
|
|
id_ordem_expediente : id_ordem_expediente,
|
|
is_ordemdia: is_ordemdia
|
|
}, function(data, status) {
|
|
if(status == "success")
|
|
console.log("Voto salvo.");
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
$(window).on('beforeunload', function () {
|
|
$("input[type=submit], input[type=button]").prop("disabled", "disabled");
|
|
});
|
|
|
|
$(document).ready(function(){
|
|
conta_votos();
|
|
});
|
|
|
|
</script>
|
|
{% endblock extra_js%}
|
|
|