mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-25 11:37:22 +02:00
Add transaction type field
This commit is contained in:
committed by
Bombar Maxime
parent
a1f37f0eea
commit
7b98244360
@ -15,6 +15,18 @@ function pretty_money(value) {
|
||||
+ (Math.abs(value) % 100 < 10 ? "0" : "") + (Math.abs(value) % 100) + " €";
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a message on the top of the page.
|
||||
* @param msg The message to display
|
||||
* @param alert_type The type of the alert. Choices: info, success, warning, danger
|
||||
*/
|
||||
function addMsg(msg, alert_type) {
|
||||
let msgDiv = $("#messages");
|
||||
let html = msgDiv.html();
|
||||
html += "<div class=\"alert alert-" + alert_type + "\">" + msg + "</div>\n";
|
||||
msgDiv.html(html);
|
||||
}
|
||||
|
||||
/**
|
||||
* Reload the balance of the user on the right top corner
|
||||
*/
|
||||
@ -256,11 +268,8 @@ function de_validate(id, validated) {
|
||||
refreshHistory();
|
||||
},
|
||||
error: function(err) {
|
||||
let msgDiv = $("#messages");
|
||||
let html = msgDiv.html();
|
||||
html += "<div class='alert alert-danger'>Une erreur est survenue lors de la validation/dévalidation " +
|
||||
"de cette transaction : " + err.responseText + "</div>";
|
||||
msgDiv.html(html);
|
||||
addMsg("Une erreur est survenue lors de la validation/dévalidation " +
|
||||
"de cette transaction : " + err.responseText, "danger");
|
||||
|
||||
refreshBalance();
|
||||
// error if this method doesn't exist. Please define it.
|
||||
|
@ -128,6 +128,22 @@ function addConso(dest, amount, type, category_id, category_name, template_id, t
|
||||
consumeAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset the page as its initial state.
|
||||
*/
|
||||
function reset() {
|
||||
notes_display.length = 0;
|
||||
notes.length = 0;
|
||||
buttons.length = 0;
|
||||
$("#note_list").html("");
|
||||
$("#alias_matched").html("");
|
||||
$("#consos_list").html("");
|
||||
displayNote(null, "");
|
||||
refreshHistory();
|
||||
refreshBalance();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Apply all transactions: all notes in `notes` buy each item in `buttons`
|
||||
*/
|
||||
@ -161,19 +177,14 @@ function consume(source, dest, quantity, amount, reason, type, category, templat
|
||||
"valid": true,
|
||||
"polymorphic_ctype": type,
|
||||
"resourcetype": "TemplateTransaction",
|
||||
"type": "template",
|
||||
"source": source,
|
||||
"destination": dest,
|
||||
"category": category,
|
||||
"template": template
|
||||
}, function() {
|
||||
notes_display.length = 0;
|
||||
notes.length = 0;
|
||||
buttons.length = 0;
|
||||
$("#note_list").html("");
|
||||
$("#alias_matched").html("");
|
||||
$("#consos_list").html("");
|
||||
displayNote(null, "");
|
||||
refreshHistory();
|
||||
refreshBalance();
|
||||
});
|
||||
}, reset).fail(function (e) {
|
||||
reset();
|
||||
|
||||
addMsg("Une erreur est survenue lors de la transaction : " + e.responseText, "danger");
|
||||
});
|
||||
}
|
||||
|
Reference in New Issue
Block a user