126 lines
3.9 KiB
HTML
126 lines
3.9 KiB
HTML
{% extends 'kfet/base_col_2.html' %}
|
|
{% load l10n static widget_tweaks bootstrap %}
|
|
|
|
{% 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.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" id="history-form">
|
|
{{ filter_form|bootstrap}}
|
|
</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_start');
|
|
var $to_date = $('#id_end');
|
|
var $checkout = $('#id_checkout');
|
|
var $account = $('#id_account');
|
|
|
|
function getHistory() {
|
|
data = $("#history-form").find("input, select, textarea").serialize();
|
|
|
|
khistory.fetch(data).done(function () {
|
|
var nb_opes = khistory.$container.find('.entry:not(.canceled)').length;
|
|
$('#nb_opes').text(nb_opes);
|
|
});
|
|
}
|
|
|
|
const history_limit = '{{ history_limit }}';
|
|
// trigrammes speciaux (LIQ, #13)
|
|
// Peuvent être consulté a une date plus vielle que history_limit
|
|
const history_no_limit_accounts = [{% for id in history_no_limit_account_ids %}'{{ id }}', {% endfor %}];
|
|
const history_no_limit = '{{ history_no_limit }}';
|
|
|
|
let defaults_datetimepicker = {
|
|
timeZone : 'Europe/Paris',
|
|
format : 'YYYY-MM-DD HH:mm',
|
|
stepping : 5,
|
|
locale : 'fr',
|
|
minDate : history_limit,
|
|
showTodayButton: true,
|
|
widgetPositioning: {
|
|
horizontal: "left",
|
|
vertical: "bottom",
|
|
}
|
|
};
|
|
|
|
$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);
|
|
});
|
|
|
|
$account.on("change", function (e) {
|
|
const selected_id = $account.val();
|
|
if (history_no_limit_accounts.includes(selected_id)) {
|
|
// it is a special account
|
|
// earlier history limit
|
|
$from_date.data("DateTimePicker").minDate(history_no_limit);
|
|
}
|
|
else {
|
|
// normal history limit + reset to date for good measure
|
|
if ($to_date.val() < history_limit) {
|
|
// setting a min date > max_date causes errors
|
|
$from_date.data("DateTimePicker").maxDate(history_limit);
|
|
$to_date.data("DateTimePicker").minDate(history_limit);
|
|
}
|
|
$from_date.data("DateTimePicker").minDate(history_limit);
|
|
}
|
|
});
|
|
|
|
$("#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 %}
|