2017-06-12 01:51:10 +02:00
|
|
|
{% extends 'kfet/base_col_2.html' %}
|
2016-09-24 14:18:26 +02:00
|
|
|
{% load staticfiles %}
|
|
|
|
|
2016-08-26 15:30:40 +02:00
|
|
|
{% block title %}Transferts{% endblock %}
|
2017-06-12 01:51:10 +02:00
|
|
|
{% block header-title %}Transferts{% endblock %}
|
2016-08-26 15:30:40 +02:00
|
|
|
|
2017-06-12 01:51:10 +02:00
|
|
|
{% block fixed %}
|
2016-08-26 15:30:40 +02:00
|
|
|
|
2017-06-12 01:51:10 +02:00
|
|
|
<div class="buttons">
|
|
|
|
<a class="btn btn-primary" href="{% url 'kfet.transfers.create' %}">
|
|
|
|
Nouveaux
|
|
|
|
</a>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
{% endblock %}
|
|
|
|
|
|
|
|
{% block main %}
|
|
|
|
|
|
|
|
<div id="history">
|
|
|
|
{% for transfergroup in transfergroups %}
|
|
|
|
<div class="opegroup transfergroup" data-transfergroup="{{ transfergroup.pk }}">
|
|
|
|
<span>{{ transfergroup.at }}</span>
|
|
|
|
<span>{{ transfergroup.valid_by.trigramme }}</span>
|
|
|
|
<span>{{ transfergroup.comment }}</span>
|
2016-08-26 20:14:00 +02:00
|
|
|
</div>
|
2017-06-12 01:51:10 +02:00
|
|
|
{% for transfer in transfergroup.transfers.all %}
|
|
|
|
<div class="ope transfer{% if transfer.canceled_at %} canceled{% endif %}" data-transfer="{{ transfer.pk }}" data-transfergroup="{{ transfergroup.pk }}">
|
|
|
|
<span class="amount">{{ transfer.amount }} €</span>
|
|
|
|
<span class="from_acc">{{ transfer.from_acc.trigramme }}</span>
|
|
|
|
<span class="glyphicon glyphicon-arrow-right"></span>
|
|
|
|
<span class="to_acc">{{ transfer.to_acc.trigramme }}</span>
|
2016-08-26 20:14:00 +02:00
|
|
|
</div>
|
2017-06-12 01:51:10 +02:00
|
|
|
{% endfor %}
|
|
|
|
{% endfor %}
|
2016-08-26 15:30:40 +02:00
|
|
|
</div>
|
|
|
|
|
2016-09-24 14:18:26 +02:00
|
|
|
<script type="text/javascript">
|
|
|
|
|
|
|
|
$(document).ready(function() {
|
|
|
|
|
|
|
|
lock = 0;
|
|
|
|
|
|
|
|
function displayErrors(html) {
|
|
|
|
$.alert({
|
|
|
|
title: 'Erreurs',
|
|
|
|
content: html,
|
|
|
|
backgroundDismiss: true,
|
|
|
|
animation: 'top',
|
|
|
|
closeAnimation: 'bottom',
|
|
|
|
keyboardEnabled: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function cancelTransfers(transfers_array, password = '') {
|
|
|
|
if (lock == 1)
|
|
|
|
return false
|
|
|
|
lock = 1;
|
|
|
|
var data = { 'transfers' : transfers_array }
|
|
|
|
$.ajax({
|
|
|
|
dataType: "json",
|
|
|
|
url : "{% url 'kfet.transfers.cancel' %}",
|
|
|
|
method : "POST",
|
|
|
|
data : data,
|
|
|
|
beforeSend: function ($xhr) {
|
|
|
|
$xhr.setRequestHeader("X-CSRFToken", csrftoken);
|
|
|
|
if (password != '')
|
|
|
|
$xhr.setRequestHeader("KFetPassword", password);
|
|
|
|
},
|
|
|
|
|
|
|
|
})
|
|
|
|
.done(function(data) {
|
|
|
|
for (var i=0; i<data['canceled'].length; i++) {
|
|
|
|
$('#history').find('.transfer[data-transfer='+data['canceled'][i]+']')
|
|
|
|
.addClass('canceled');
|
|
|
|
}
|
|
|
|
$('#history').find('.ui-selected').removeClass('ui-selected');
|
|
|
|
lock = 0;
|
|
|
|
})
|
|
|
|
.fail(function($xhr) {
|
|
|
|
var data = $xhr.responseJSON;
|
|
|
|
switch ($xhr.status) {
|
|
|
|
case 403:
|
|
|
|
requestAuth(data, function(password) {
|
|
|
|
cancelTransfers(transfers_array, password);
|
|
|
|
});
|
|
|
|
break;
|
|
|
|
case 400:
|
|
|
|
displayErrors(getErrorsHtml(data));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
lock = 0;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
$('#history').selectable({
|
|
|
|
filter: 'div.transfergroup, div.transfer',
|
|
|
|
selected: function(e, ui) {
|
|
|
|
$(ui.selected).each(function() {
|
|
|
|
if ($(this).hasClass('transfergroup')) {
|
|
|
|
var transfergroup = $(this).attr('data-transfergroup');
|
|
|
|
$(this).siblings('.ope').filter(function() {
|
|
|
|
return $(this).attr('data-transfergroup') == transfergroup
|
|
|
|
}).addClass('ui-selected');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
},
|
|
|
|
});
|
|
|
|
|
|
|
|
$(document).on('keydown', function (e) {
|
|
|
|
if (e.keyCode == 46) {
|
|
|
|
// DEL (Suppr)
|
|
|
|
var transfers_to_cancel = [];
|
|
|
|
$('#history').find('.transfer.ui-selected').each(function () {
|
|
|
|
transfers_to_cancel.push($(this).attr('data-transfer'));
|
|
|
|
});
|
|
|
|
if (transfers_to_cancel.length > 0)
|
|
|
|
cancelTransfers(transfers_to_cancel);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
</script>
|
|
|
|
|
2016-08-26 15:30:40 +02:00
|
|
|
{% endblock %}
|