diff --git a/cotisations/templates/cotisations/new_facture.html b/cotisations/templates/cotisations/new_facture.html index 2dfa52c2..f2586e8b 100644 --- a/cotisations/templates/cotisations/new_facture.html +++ b/cotisations/templates/cotisations/new_facture.html @@ -38,18 +38,20 @@ with this program; if not, write to the Free Software Foundation, Inc., {{ venteform.management_form }}
- {{ form.as_table }} -
+-
Prix total : 0,00 €
@@ -63,19 +65,23 @@ with this program; if not, write to the Free Software Foundation, Inc., prices[{{ article.id|escapejs }}] = {{ article.prix }}; {% endfor %} - var template = `{{ venteform.empty_form.as_table }}
`; + var template = `Article : + {% bootstrap_form venteform.empty_form label_class='sr-only' %} + + ` function add_article(){ // Index start at 0 => new_index = number of items var new_index = document.getElementsByClassName('product_to_sell').length; - document.getElementById('id_form-TOTAL_FORMS').value = - parseInt(document.getElementById('id_form-TOTAL_FORMS').value) + 1; + document.getElementById('id_form-TOTAL_FORMS').value ++; var new_article = document.createElement('div'); - new_article.className = 'product_to_sell'; + new_article.className = 'product_to_sell form-inline'; new_article.innerHTML = template.replace(/__prefix__/g, new_index); - document.getElementById('form_set') - .appendChild(new_article); + document.getElementById('form_set').appendChild(new_article); add_listenner_for_id(new_index); } @@ -106,18 +112,28 @@ with this program; if not, write to the Free Software Foundation, Inc., .addEventListener("onkeypress", update_price, true); document.getElementById('id_form-' + i.toString() + '-quantity') .addEventListener("change", update_price, true); + document.getElementById('id_form-' + i.toString() + '-article-remove') + .addEventListener("click", function(event) { + var article = event.target.parentNode; + article.parentNode.removeChild(article); + document.getElementById('id_form-TOTAL_FORMS').value --; + update_price(); + } + ) } - function set_cheque_info_visibility(){ - var visible = document.getElementById("id_paiement").value == document.getElementById("id_paiement").getAttribute('data-cheque'); - p = document.getElementById("id_paiement") - console.log(p); + function set_cheque_info_visibility() { + var paiement = document.getElementById("id_Facture-paiement"); + var visible = paiement.value == paiement.getAttribute('data-cheque'); + p = document.getElementById("id_Facture-paiement"); var display = 'none'; if (visible) { display = 'block'; } - document.getElementById("id_cheque").parentNode.style.display = display; - document.getElementById("id_banque").parentNode.style.display = display; + document.getElementById("id_Facture-cheque") + .parentNode.style.display = display; + document.getElementById("id_Facture-banque") + .parentNode.style.display = display; } // Add events manager when DOM is fully loaded @@ -129,7 +145,7 @@ with this program; if not, write to the Free Software Foundation, Inc., for (i = 0; i < product_count; ++i){ add_listenner_for_id(i); } - document.getElementById("id_paiement") + document.getElementById("id_Facture-paiement") .addEventListener("change", set_cheque_info_visibility, true); set_cheque_info_visibility(); update_price();