diff --git a/templates/note/transaction_form.html b/templates/note/transaction_form.html index 842d8152..62e7137c 100644 --- a/templates/note/transaction_form.html +++ b/templates/note/transaction_form.html @@ -6,8 +6,15 @@ SPDX-License-Identifier: GPL-2.0-or-later {% load i18n static %} {% block content %} +
@@ -24,7 +31,7 @@ SPDX-License-Identifier: GPL-2.0-or-later
@@ -70,6 +77,7 @@ SPDX-License-Identifier: GPL-2.0-or-later var sources_notes_display = []; var dests = []; var dests_notes_display = []; + var transfer_mode = false; $(document).ready(function() { autoCompleteNote("source_note", "source_alias_matched", "source_note_list", sources, sources_notes_display, @@ -78,61 +86,131 @@ SPDX-License-Identifier: GPL-2.0-or-later "dest_alias", "dest_note"); }); + $("#switch_mode").click(function () { + transfer_mode ^= true; + if (transfer_mode) { + $("#switch_mode").text("Passer en mode virement"); + $("#emitters_div").show(); + $("#dests_div").attr('class', 'col-md-6'); + } + else { + $("#switch_mode").text("Passer en mode transfert"); + $("#emitters_div").hide(); + $("#dests_div").attr('class', 'col-md-12'); + } + }); + $("#transfer").click(function() { - sources_notes_display.forEach(function(source) { - dests_notes_display.forEach(function(dest) { + if (sources.length === 0) { + dests_notes_display.forEach(function (dest) { $.post("/api/note/transaction/transaction/", - { - "csrfmiddlewaretoken": CSRF_TOKEN, - "quantity": source[3] * dest[3], - "amount": $("#amount").val(), - "reason": $("#reason").val() + " (Transfert)", - "valid": true, - "polymorphic_ctype": {{ polymorphic_ctype }}, - "resourcetype": "Transaction", - "source": source[1], - "destination": dest[1] - }, function() { - sources_notes_display.length = 0; - sources.length = 0; - dests_notes_display.length = 0; - dests.length = 0; - $("#source_note_list").html(""); - $("#dest_note_list").html(""); - $("#source_alias_matched").html(""); - $("#dest_alias_matched").html(""); - $("#amount").val(""); - $("#reason").val(""); - refreshBalance(); - - let msgDiv = $("#messages"); - let html = msgDiv.html(); - html += "