gestioCOF/kfet/templates/kfet/history.html
2020-04-23 18:11:23 +02:00

127 lines
3.8 KiB
HTML

{% extends 'kfet/base_col_2.html' %}
{% load l10n staticfiles widget_tweaks %}
{% block extra_head %}
<link rel="stylesheet" type="text/css" href="{% static 'kfet/vendor/multiple-select/multiple-select.css' %}">
<script type="text/javascript" src="{% static 'kfet/vendor/multiple-select/multiple-select.js' %}"></script>
{{ filter_form.media }}
<script type="text/javascript" src="{% url 'js_reverse' %}" ></script>
<script type="text/javascript" src="{% static 'kfet/js/history.js' %}"></script>
<script type="text/javascript" src="{% static 'kfet/vendor/moment/moment-timezone-with-data-2012-2022.min.js' %}"></script>
{% endblock %}
{% block title %}Historique{% endblock %}
{% block header-title %}Historique{% endblock %}
{% block fixed %}
<aside>
<div class="heading">
<span id="nb_opes"></span>
<span class="sub">opérations</span>
</div>
<div class="text">
<ul class="list-unstyled">
<li style="position: relative;"><b>De</b> {{ filter_form.from_date|add_class:"form-control" }}</li>
<li style="position: relative;"><b>à</b> {{ filter_form.to_date|add_class:"form-control" }}</li>
<li><b>Caisses</b> {{ filter_form.checkouts }}</li>
<li><b>Comptes</b> {{ filter_form.accounts }}</li>
</ul>
</div>
<div class="buttons">
<button class="btn btn-primary" id="btn-fetch">Valider</button>
</div>
</aside>
{% endblock %}
{% block main %}
<table id="history" class="table">
</table>
<script type="text/javascript">
$(document).ready(function() {
settings = { 'subvention_cof': parseFloat({{ kfet_config.subvention_cof|unlocalize }})}
window.lock = 0;
khistory = new KHistory();
var $from_date = $('#id_from_date');
var $to_date = $('#id_to_date');
var $checkouts = $('#id_checkouts');
var $accounts = $('#id_accounts');
function getSelectedMultiple($el) {
var selected = [];
$el.find(':selected').each(function() {
selected.push($(this).val())
});
return selected;
}
function getHistory() {
var data = {};
if ($from_date.val())
data['from'] = moment($from_date.val()).format('YYYY-MM-DD HH:mm:ss');
if ($to_date.val())
data['to'] = moment($to_date.val()).format('YYYY-MM-DD HH:mm:ss');
var checkouts = getSelectedMultiple($checkouts);
if ($checkouts)
data['checkouts'] = checkouts;
var accounts = getSelectedMultiple($accounts);
data['accounts'] = accounts;
khistory.fetch(data).done(function () {
var nb_opes = khistory.$container.find('.entry:not(.canceled)').length;
$('#nb_opes').text(nb_opes);
});
}
let defaults_datetimepicker = {
timeZone : 'Europe/Paris',
format : 'YYYY-MM-DD HH:mm',
stepping : 5,
locale : 'fr',
showTodayButton: true
};
$from_date.datetimepicker($.extend({}, defaults_datetimepicker, {
defaultDate: moment().subtract(24, 'hours'),
}));
$to_date.datetimepicker($.extend({}, defaults_datetimepicker, {
defaultDate: moment(),
}));
$("#from_date").on("dp.change", function (e) {
$('#to_date').data("DateTimePicker").minDate(e.date);
});
$("#to_date").on("dp.change", function (e) {
$('#from_date').data("DateTimePicker").maxDate(e.date);
});
$("select").multipleSelect({
width: '100%',
filter: true,
allSelected: " ",
selectAllText: "Tout-te-s",
countSelected: "# sur %"
});
$("#btn-fetch").on('click', function() {
khistory.reset();
getHistory();
});
$(document).on('keydown', function (e) {
if (e.keyCode == 46) {
// DEL (Suppr)
khistory.cancel_selected()
}
});
getHistory();
});
</script>
{% endblock %}