mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-20 17:41:55 +02:00
Guests can pay with CB or coins, lot of other improvements
This commit is contained in:
@ -6,11 +6,16 @@
|
||||
{% load perms %}
|
||||
|
||||
{% block content %}
|
||||
<a href="{% url "activity:activity_detail" pk=activity.pk %}">
|
||||
<button class="btn btn-light">{% trans "Return to activity page" %}</button>
|
||||
</a>
|
||||
|
||||
<input id="alias" type="text" class="form-control" placeholder="Nom/note ...">
|
||||
|
||||
<hr>
|
||||
|
||||
<div id="entry_table">
|
||||
<h2 class="text-center">{{ entries.count }} {% if entries.count >= 2 %}{% trans "entries" %}{% else %}{% trans "entry" %}{% endif %}</h2>
|
||||
{% render_table table %}
|
||||
</div>
|
||||
{% endblock %}
|
||||
@ -41,6 +46,8 @@
|
||||
|
||||
let type = target.attr("data-type");
|
||||
let id = target.attr("data-id");
|
||||
let last_name = target.attr("data-last-name");
|
||||
let first_name = target.attr("data-first-name");
|
||||
|
||||
if (type === "membership") {
|
||||
$.post("/api/activity/entry/?format=json", {
|
||||
@ -56,18 +63,63 @@
|
||||
});
|
||||
}
|
||||
else {
|
||||
let line_obj = $("#buttons_guest_" + id);
|
||||
if (line_obj.length || target.attr('class').includes("table-success")) {
|
||||
line_obj.remove();
|
||||
return;
|
||||
}
|
||||
|
||||
let tr = "<tr class='text-center'>" +
|
||||
"<td id='buttons_guest_" + id + "' style='table-danger center' colspan='5'>" +
|
||||
"<button id='transaction_guest_" + id + "' class='btn btn-secondary'>Payer avec la note de l'hôte</button> " +
|
||||
"<button id='transaction_guest_" + id + "_especes' class='btn btn-secondary'>Payer en espèces</button> " +
|
||||
"<button id='transaction_guest_" + id + "_cb' class='btn btn-secondary'>Payer en CB</button></td>" +
|
||||
"<tr>";
|
||||
$(tr).insertAfter(target);
|
||||
|
||||
let makeTransaction = function() {
|
||||
$.post("/api/activity/entry/?format=json", {
|
||||
csrfmiddlewaretoken: CSRF_TOKEN,
|
||||
activity: {{ activity.id }},
|
||||
note: target.attr("data-inviter"),
|
||||
guest: id
|
||||
}).done(function () {
|
||||
addMsg("Entrée effectuée !", "success");
|
||||
reloadTable(true);
|
||||
}).fail(function (xhr) {
|
||||
errMsg(xhr.responseJSON);
|
||||
});
|
||||
};
|
||||
|
||||
let credit = function(credit_id, credit_name) {
|
||||
return function() {
|
||||
$.post("/api/note/transaction/transaction/",
|
||||
{
|
||||
"csrfmiddlewaretoken": CSRF_TOKEN,
|
||||
"quantity": 1,
|
||||
"amount": {{ activity.activity_type.guest_entry_fee }},
|
||||
"reason": "Crédit " + credit_name + " (invitation {{ activity.name }})",
|
||||
"valid": true,
|
||||
"polymorphic_ctype": {{ notespecial_ctype }},
|
||||
"resourcetype": "SpecialTransaction",
|
||||
"source": credit_id,
|
||||
"destination": target.attr('data-inviter'),
|
||||
"last_name": last_name,
|
||||
"first_name": first_name,
|
||||
"bank": ""
|
||||
}).done(function () {
|
||||
makeTransaction();
|
||||
reset();
|
||||
}).fail(function (xhr) {
|
||||
errMsg(xhr.responseJSON);
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
$("#transaction_guest_" + id).click(makeTransaction);
|
||||
$("#transaction_guest_" + id + "_especes").click(credit(1, "espèces"));
|
||||
$("#transaction_guest_" + id + "_cb").click(credit(2, "carte bancaire"));
|
||||
}
|
||||
$.post("/api/activity/entry/?format=json", {
|
||||
csrfmiddlewaretoken: CSRF_TOKEN,
|
||||
activity: {{ activity.id }},
|
||||
note: target.attr("data-inviter"),
|
||||
guest: id
|
||||
}).done(function () {
|
||||
addMsg("Entrée effectuée !", "success");
|
||||
reloadTable(true);
|
||||
}).fail(function(xhr) {
|
||||
errMsg(xhr.responseJSON);
|
||||
});
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user