1 var namePatt
= new RegExp(/-(\d
+)-/);
4 function remun_line(input
) {
5 var idParts
= input
.attr('id').split('-');
6 var prefix
= idParts
[0] + "-" + idParts
[1];
7 var field
= idParts
[2];
9 var montant_annuel
= input
.closest('table').find('#' + prefix
+ '-montant');
10 var montant_annuel_euros
= input
.closest('table').find('#' + prefix
+ '-montant_annuel_euros');
12 /* auto calcul a besoin d'un type (autrement ca devient un champs requis)*/
13 // if ($('#' + prefix + '-type').val() == '') {
14 // montant_annuel.val('');
15 // montant_annuel_euros.val('');
19 value
= montant_annuel
.val();
21 montant_annuel
.val(roundNumber(value
, 2));
23 var devise
= input
.closest('table').find('#' + prefix
+ '-devise').val();
24 var taux
= parseFloat(DEVISES
[devise]);
25 if (isNaN(taux
)) taux
= 0;
26 montant_annuel_euros
.text(roundNumber((value
* taux
), 2));
29 function ajouterLigne(addLnk
) {
30 if (formCount
== null) {
31 formCount
= addLnk
.closest('table').find('.remunform').length
;
33 var prev
= addLnk
.parent('td').parent('tr').prev('tr');
34 var copyOfLastInGroup
= prev
.clone();
35 copyOfLastInGroup
.find('input, select, td.cumulable').each(function(i
, e
){
36 var origName
= $
(e
).attr('id');
37 var origId
= $
(e
).attr('id');
38 $
(e
).attr('name', origName
.replace(namePatt
, '-' + formCount
+ '-'))
39 $
(e
).attr('id', origId
.replace(namePatt
, '-' + formCount
+ '-'))
43 prev
.after(copyOfLastInGroup
);
45 copyOfLastInGroup
.find('input, select').change(function(e
){
52 function totalByIndex(selector
, accessor
) {
54 aelector: the element where to display costs, and from which the index will be calculated.
55 accessor: a function to get all items that will be part of the total.
57 // $(selector).hide();
58 $
(selector
).each(function(){
60 var i
= $
(this).index();
61 var prevs
= accessor($
(this));
62 prevs
.each(function(){
63 var cell
= $
($
(this).children('td')[i]);
65 if (cell
.children('input').length
== 1) {
66 val
= cell
.children('input').val();
70 subtot
+= clean_float(val
);
72 $
(this).html(roundNumber(subtot
, 2));
76 function remun_totaux() {
77 $
('#global-cost tr td.monnaie.cumulable input[type="text"], #global-cost tr td.monnaie.cumulable input[type="hidden"]').each(function() {
80 totalByIndex('#global-cost td.sous-total',
81 function(x
){return x
.parent('tr').prevUntil(':not(.calculable)')});
82 totalByIndex('#global-cost th.total',
83 function(x
){return x
.parent('tr').prevAll('.sous-totaux')});
87 $
(document
).ready(function(){
89 $
('#global-cost input, #global-cost select').change(function() {
90 // remun_line($(this));
94 $
('#global-cost .addlink').click(function(e
){