forked from DGNum/gestioCOF
Annulations sur K-Psul
- Ajout de l'annulation depuis l'historique - La view kpsul_perform_operations envoie le statut cof pour le websocket. Cela sert à l'affichage de l'historique
This commit is contained in:
parent
b8ae482a60
commit
e7f37351a7
3 changed files with 51 additions and 9 deletions
|
@ -320,3 +320,15 @@ input[type=number]::-webkit-outer-spin-button {
|
|||
background-color:#C8102E;
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
/* History */
|
||||
|
||||
#history div.general.ui-selected, #history div.general.ui-selecting,
|
||||
#history div.ope.ui-selected, #history div.ope.ui-selecting {
|
||||
background-color:#C8102E;
|
||||
color:#FFF;
|
||||
}
|
||||
|
||||
#history .canceled {
|
||||
text-decoration:line-through;
|
||||
}
|
||||
|
|
|
@ -88,7 +88,7 @@
|
|||
</div>
|
||||
</div>
|
||||
<div class="col-sm-4">
|
||||
<div id="history_data">
|
||||
<div id="history">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -98,8 +98,6 @@
|
|||
</form>
|
||||
|
||||
<!--
|
||||
<button type="button" id="perform_operations">Valider</button>
|
||||
|
||||
<form id="cancel_form">
|
||||
Opé annul 1:<input type="text" name="operation"><br>
|
||||
Opé annul 2:<input type="text" name="operation">
|
||||
|
@ -330,8 +328,8 @@ $(document).ready(function() {
|
|||
var cancelButton = $('#cancel_operations');
|
||||
var cancelForm = $('#cancel_form');
|
||||
|
||||
function cancelOperations() {
|
||||
var data = cancelForm.serialize();
|
||||
function cancelOperations(opes_array) {
|
||||
var data = { 'operations' : opes_array }
|
||||
$.ajax({
|
||||
dataType: "json",
|
||||
url : "{% url 'kfet.kpsul.cancel_operations' %}",
|
||||
|
@ -340,6 +338,7 @@ $(document).ready(function() {
|
|||
})
|
||||
.done(function(data) {
|
||||
console.log(data);
|
||||
history_container.find('.ui-selected').removeClass('ui-selected');
|
||||
})
|
||||
.fail(function($xhr) {
|
||||
var data = $xhr.responseJSON;
|
||||
|
@ -542,7 +541,6 @@ $(document).ready(function() {
|
|||
return false;
|
||||
});
|
||||
|
||||
|
||||
// -----
|
||||
// Basket
|
||||
// -----
|
||||
|
@ -562,7 +560,7 @@ $(document).ready(function() {
|
|||
}
|
||||
|
||||
function addPurchase(id, nb) {
|
||||
var amount_euro = amountEuroPurchase(id, nb);
|
||||
var amount_euro = amountEuroPurchase(id, nb).toFixed(2);
|
||||
var index = addPurchaseToFormset(article_data[1], nb, amount_euro);
|
||||
article_basket_html = $(item_basket_default_html);
|
||||
article_basket_html
|
||||
|
@ -805,7 +803,7 @@ $(document).ready(function() {
|
|||
// History
|
||||
// -----
|
||||
|
||||
var history_container = $('#history_data');
|
||||
var history_container = $('#history');
|
||||
var history_operationgroup_html = '<div class="opegroup"><div class="general"></div></div>';
|
||||
var history_operation_html = '<div class="ope"></div>';
|
||||
|
||||
|
@ -864,6 +862,37 @@ $(document).ready(function() {
|
|||
history_container.find('.opegroup').remove();
|
||||
}
|
||||
|
||||
// -----
|
||||
// Cancel from history
|
||||
// -----
|
||||
|
||||
history_container.selectable({
|
||||
filter: 'div.opegroup div.general, div.ope',
|
||||
selected: function(e, ui) {
|
||||
$(ui.selected).each(function() {
|
||||
if ($(this).hasClass('general'))
|
||||
$(this).siblings('.ope').addClass('ui-selected');
|
||||
});
|
||||
},
|
||||
unselected: function(e, ui) {
|
||||
$(ui.unselected).each(function() {
|
||||
if ($(this).hasClass('general'))
|
||||
$(this).siblings('.ope').removeClass('ui-selected');
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$(document).on('keypress', function (e) {
|
||||
if (e.keyCode == 46) {
|
||||
// DEL (Suppr)
|
||||
var opes_to_cancel = [];
|
||||
history_container.find('.ope.ui-selected').each(function () {
|
||||
opes_to_cancel.push($(this).attr('data-ope'));
|
||||
});
|
||||
cancelOperations(opes_to_cancel);
|
||||
}
|
||||
});
|
||||
|
||||
function cancelOpeGroup(opegroup) {
|
||||
var opegroup_html = history_container.find('[data-opegroup='+opegroup['id']+']');
|
||||
opegroup_html.find('.amount').text(opegroup['amount']);
|
||||
|
|
|
@ -590,6 +590,7 @@ def kpsul_perform_operations(request):
|
|||
'amount': operationgroup.amount,
|
||||
'checkout__name': operationgroup.checkout.name,
|
||||
'at': operationgroup.at,
|
||||
'is_cof': operationgroup.is_cof,
|
||||
'valid_by__trigramme': ( operationgroup.valid_by and
|
||||
operationgroup.valid_by.trigramme or None),
|
||||
'on_acc__trigramme': operationgroup.on_acc.trigramme,
|
||||
|
@ -633,7 +634,7 @@ def kpsul_cancel_operations(request):
|
|||
# Checking if BAD REQUEST (opes_pk not int or not existing)
|
||||
try:
|
||||
# Set pour virer les doublons
|
||||
opes_post = set(map(int, filter(None, request.POST.getlist('operation', []))))
|
||||
opes_post = set(map(int, filter(None, request.POST.getlist('operations[]', []))))
|
||||
except ValueError:
|
||||
return JsonResponse(data, status=400)
|
||||
opes_all = (
|
||||
|
|
Loading…
Reference in a new issue