27ae64e4cf88d2583ff537701e2b7f687827c7f0
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 f_counter
= addLnk
.closest('table').prevAll('input[id$="TOTAL_FORMS"]');
34 var prev
= addLnk
.parent('td').parent('tr').prev('tr');
35 var copyOfLastInGroup
= prev
.clone();
36 copyOfLastInGroup
.find('input, select, td.cumulable').each(function(i
, e
){
37 var origName
= $
(e
).attr('id');
38 var origId
= $
(e
).attr('id');
39 $
(e
).attr('name', origName
.replace(namePatt
, '-' + formCount
+ '-'))
40 $
(e
).attr('id', origId
.replace(namePatt
, '-' + formCount
+ '-'))
44 prev
.after(copyOfLastInGroup
);
46 copyOfLastInGroup
.find('input, select').change(function(e
){
50 f_counter
.val(formCount
);
54 function totalByIndex(selector
, accessor
) {
56 aelector: the element where to display costs, and from which the index will be calculated.
57 accessor: a function to get all items that will be part of the total.
59 // $(selector).hide();
60 $
(selector
).each(function(){
62 var i
= $
(this).index();
63 var prevs
= accessor($
(this));
64 prevs
.each(function(){
65 var cell
= $
($
(this).children('td')[i]);
67 if (cell
.children('input').length
== 1) {
68 val
= cell
.children('input').val();
72 subtot
+= clean_float(val
);
74 $
(this).html(roundNumber(subtot
, 2));
78 function remun_totaux() {
79 $
('#global-cost tr td.monnaie.cumulable input[type="text"], #global-cost tr td.monnaie.cumulable input[type="hidden"]').each(function() {
82 totalByIndex('#global-cost td.sous-total',
83 function(x
){return x
.parent('tr').prevUntil(':not(.calculable)')});
84 totalByIndex('#global-cost th.total',
85 function(x
){return x
.parent('tr').prevAll('.sous-totaux')});
89 $
(document
).ready(function(){
91 $
('#global-cost input, #global-cost select').change(function() {
92 // remun_line($(this));
96 $
('#global-cost .addlink').click(function(e
){