javascript et finalisation de la vue new fiche avant l'ajout de modification/ajout de fiche

This commit is contained in:
Pierr0
2023-12-30 19:18:25 +01:00
parent d279249503
commit 85c00fde0a
6 changed files with 129 additions and 47 deletions

View File

@@ -25,7 +25,7 @@
</a>
</li>
<li>
<a href="index.php?direction=nouvelleFiche" class="nav-link px-0"> <span class="d-none d-sm-inline">Fiche du mois</span>
<a href="index.php?direction=nouvelleFiche&currentList" class="nav-link px-0"> <span class="d-none d-sm-inline">Fiche du mois</span>
</a>
</li>
</ul>

View File

@@ -1,6 +1,8 @@
$(document).ready(function () {
calcPrixTotalFrsF();
calcPrixTotalFrsHorsF();
updatePrixTotal();
/**
* Partie enregistrement frais F
*/
@@ -19,6 +21,7 @@ $(document).ready(function () {
formTotal.html((val * mttFrs).toFixed(2) + ' €');
calcPrixTotalFrsF();
updatePrixTotal();
}
})
@@ -56,16 +59,11 @@ $(document).ready(function () {
if (canAdd == true) {
var line = $('tr.fraisHF:first').clone();
lastId = $('tr.fraisHF').length
/*
line.find("#dateFrsHF").html(date.val());
line.find("#LibelleFrsHF").html(libelle.val());
line.find("#MttFrsHF").html(parseFloat(montant.val()).toFixed(2) + ' €');
*/
line.find('.btn').attr('id', 'frsSup-' + lastId)
var line = $('<tr id="fraisHf-' + lastId + '" class="fraisHF"></tr>');
var tdDate = $('<td scope="row" id="dateFrsHF"></td>');
var tdDate = $('<th scope="row" id="dateFrsHF"></th>');
tdDate.html(date.val());
var tdLibelle = $('<td id="LibelleFrsHF"></td>');
tdLibelle.html(libelle.val());
@@ -81,7 +79,14 @@ $(document).ready(function () {
$(line).append(btn)
line.insertBefore('.newFraisForm')
date.val('')
libelle.val('')
montant.val('')
}
calcPrixTotalFrsHorsF();
updatePrixTotal();
})
@@ -95,10 +100,12 @@ $(document).on('click', '.btnSuprFraisHf', function () {
console.log(id)
$('#fraisHf-' + id).remove()
calcPrixTotalFrsHorsF();
updatePrixTotal();
})
/**
* Calcul prix total
* Calcul prix total frais forfaitaires
*/
function calcPrixTotalFrsF() {
@@ -107,4 +114,26 @@ function calcPrixTotalFrsF() {
prixTotal += parseFloat($(this).html().replace('€', ''))
})
$('.prixTotalFrsF').html('<strong>TOTAL :</strong> ' + prixTotal.toFixed(2) + ' €')
$('.prixTotalFrsF').attr('data-prix', prixTotal.toFixed(2))
}
/**
* Calcul prix total frais hors forfait
*/
function calcPrixTotalFrsHorsF() {
var prixTotal = 0;
$('td#MttFrsHF').each(function () {
prixTotal += parseFloat($(this).html().replace('€', ''))
})
$('#total-frais-HF').html('<strong>TOTAL :</strong> ' + prixTotal.toFixed(2) + ' €')
$('#total-frais-HF').attr('data-prix', prixTotal.toFixed(2))
}
/**
* Calcul prix total de la fiche
*/
function updatePrixTotal() {
var total = parseFloat($('#total-frais-HF').attr('data-prix'))
total += parseFloat($('.prixTotalFrsF').attr('data-prix'))
$('#total-fiche').html('<strong>TOTAL :</strong> ' + total.toFixed(2) + ' €')
}