mirror of
https://gitlab.crans.org/bde/nk20
synced 2025-06-29 04:40:55 +02:00
Lock invoices, delete them
This commit is contained in:
33
templates/treasury/invoice_confirm_delete.html
Normal file
33
templates/treasury/invoice_confirm_delete.html
Normal file
@ -0,0 +1,33 @@
|
||||
{% extends "base.html" %}
|
||||
{% load i18n %}
|
||||
{% load crispy_forms_tags %}
|
||||
|
||||
{% block content %}
|
||||
<div class="card bg-light shadow">
|
||||
<div class="card-header text-center">
|
||||
<h4>{% trans "Delete invoice" %}</h4>
|
||||
</div>
|
||||
{% if object.locked %}
|
||||
<div class="card-body">
|
||||
<div class="alert alert-danger">
|
||||
{% blocktrans %}This invoice is locked and can't be deleted.{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
{% else %}
|
||||
<div class="card-body">
|
||||
<div class="alert alert-warning">
|
||||
{% blocktrans %}Are you sure you want to delete this invoice? This action can't be undone.{% endblocktrans %}
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
<div class="card-footer text-center">
|
||||
<form method="post">
|
||||
{% csrf_token %}
|
||||
<a class="btn btn-primary" href="{% url 'treasury:invoice_list' %}">{% trans "Return to invoices list" %}</a>
|
||||
{% if not object.locked %}
|
||||
<button class="btn btn-danger" type="submit">{% trans "Delete" %}</button>
|
||||
{% endif %}
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
@ -5,13 +5,19 @@
|
||||
{% block content %}
|
||||
<p><a class="btn btn-default" href="{% url 'treasury:invoice_list' %}">{% trans "Invoices list" %}</a></p>
|
||||
|
||||
{% if not object.pk %}
|
||||
{% if object.pk and not object.locked %}
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
Warning: the LaTeX template is saved with this object. Updating the invoice implies regenerate it.
|
||||
Be careful if you manipulate old invoices.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% elif object.locked %}
|
||||
<div class="alert alert-info">
|
||||
{% blocktrans trimmed %}
|
||||
This invoice is locked and can no longer be edited.
|
||||
{% endblocktrans %}
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<form method="post" action="">
|
||||
@ -47,10 +53,12 @@
|
||||
</table>
|
||||
|
||||
{# Display buttons to add and remove products #}
|
||||
<div class="btn-group btn-block" role="group">
|
||||
<button type="button" id="add_more" class="btn btn-primary">{% trans "Add product" %}</button>
|
||||
<button type="button" id="remove_one" class="btn btn-danger">{% trans "Remove product" %}</button>
|
||||
</div>
|
||||
{% if not object.locked %}
|
||||
<div class="btn-group btn-block" role="group">
|
||||
<button type="button" id="add_more" class="btn btn-primary">{% trans "Add product" %}</button>
|
||||
<button type="button" id="remove_one" class="btn btn-danger">{% trans "Remove product" %}</button>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="btn-block">
|
||||
<button type="submit" class="btn btn-block btn-primary">{% trans "Submit" %}</button>
|
||||
@ -78,21 +86,21 @@
|
||||
{# Script that handles add and remove lines #}
|
||||
IDS = {};
|
||||
|
||||
$("#id_product_set-TOTAL_FORMS").val($(".row-formset").length - 1);
|
||||
$("#id_products-TOTAL_FORMS").val($(".row-formset").length - 1);
|
||||
|
||||
$('#add_more').click(function () {
|
||||
var form_idx = $('#id_product_set-TOTAL_FORMS').val();
|
||||
let form_idx = $('#id_products-TOTAL_FORMS').val();
|
||||
$('#form_body').append($('#for_real').html().replace(/__prefix__/g, form_idx));
|
||||
$('#id_product_set-TOTAL_FORMS').val(parseInt(form_idx) + 1);
|
||||
$('#id_product_set-' + parseInt(form_idx) + '-id').val(IDS[parseInt(form_idx)]);
|
||||
$('#id_products-TOTAL_FORMS').val(parseInt(form_idx) + 1);
|
||||
$('#id_products-' + parseInt(form_idx) + '-id').val(IDS[parseInt(form_idx)]);
|
||||
});
|
||||
|
||||
$('#remove_one').click(function () {
|
||||
let form_idx = $('#id_product_set-TOTAL_FORMS').val();
|
||||
let form_idx = $('#id_products-TOTAL_FORMS').val();
|
||||
if (form_idx > 0) {
|
||||
IDS[parseInt(form_idx) - 1] = $('#id_product_set-' + (parseInt(form_idx) - 1) + '-id').val();
|
||||
IDS[parseInt(form_idx) - 1] = $('#id_products-' + (parseInt(form_idx) - 1) + '-id').val();
|
||||
$('#form_body tr:last-child').remove();
|
||||
$('#id_product_set-TOTAL_FORMS').val(parseInt(form_idx) - 1);
|
||||
$('#id_products-TOTAL_FORMS').val(parseInt(form_idx) - 1);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
Reference in New Issue
Block a user