e8732c511363f7109f8bc54b7ce43834ea3ee222
2 function clean_float(value
){
3 if (isNaN(value
) || value
== undefined
)
6 output
= parseFloat(value
);
7 output
= Math
.round(output
*100)/100;
11 function charger_valeurs_point(implantation_id
) {
12 var params
= {'implantation_id' : implantation_id
};
13 $
.getJSON('/dae/liste_valeurs_point', params
, function(data
) {
17 $
.each(data
, function() {
18 options
+= '<option value="' + this.id
+ '">' + this.label
+ '</option>';
21 $
("#id_valeur_point_min").html(options
);
22 $
("#id_valeur_point_max").html(options
);
26 function recalculer(element
) {
27 var ligne
= element
.parents("tr");
28 var inputs
= ligne
.find("input, select");
30 var valeur_point_input
;
31 inputs
.each(function() {
33 if (input
.attr('id').match('id_coefficient*')) {
34 coeff
= clean_float(input
.val())
36 if (input
.attr('id').match('id_valeur_point*')) {
37 valeur_point_input
= input
;
39 if (input
.attr('id').match('id_salaire*')) {
40 salaire_input
= input
;
41 salaire
= clean_float(input
.val())
43 if (input
.attr('id').match('id_indemn*')) {
44 indemn
= clean_float(input
.val())
46 if (input
.attr('id').match('id_autre*')) {
47 autre
= clean_float(input
.val())
52 /* on suggère un salaire de base en fonction du coefficient et de la valeur du point */
53 valeur_point_text
= valeur_point_input
.find(":selected").text();
54 valeur_point
= clean_float(valeur_point_text
.split(" ")[0]);
55 if (valeur_point
> 0 && coeff
> 0) {
56 salaire
= clean_float(valeur_point
* coeff
);
57 salaire_input
.val(salaire
);
60 taux_euro
= clean_float(ligne
.find(".taux").html())
62 total
= salaire
+ indemn
+ autre
;
63 total_euro
= total
* taux_euro
;
65 ligne
.find(".total-devise").text(total
.toFixed(2));
66 ligne
.find(".total-euro").text(total_euro
.toFixed(2));
70 $
(document
).ready(function() {
72 /* La fonctionnalité de présélection, est activé uniquement si aucune implantation n'a déjà été
74 Lorsque l'implantation est changée, on ajuste les valeurs de points en fonction de cette
75 sélection, UNIQUEMENT si aucune valeur n'est encore définie. */
76 var implantation_id
= $
("#id_implantation").val();
77 if (implantation_id
== "") {
79 $
("#id_implantation").change(function() {
80 var implantation_id
= this.value
;
81 charger_valeurs_point(implantation_id
);
86 $
('#id_valeur_point_min, #id_valeur_point_max').change(function(e
) {
87 var vp_input
= $
(this);
88 var ligne
= vp_input
.parents("tr");
90 var chargement_devise
= $
.getJSON("/dae/devise", {'valeur_point': this.value
});
91 chargement_devise
.success(function(data
) {
92 var selects
= ligne
.find("select");
93 selects
.each(function() {
95 if (s
.attr('id').match('id_devise*'))
97 ligne
.find(".taux").text(data
.taux_euro
)
98 ligne
.find(".devise_code").text(data
.devise_code
)
100 recalculer(vp_input
);
102 chargement_devise
.error(function(data
) {
107 $
('#id_devise_min, #id_devise_max').change(function(e
) {
109 var ligne
= input
.parents("tr");
110 var chargement_devise
= $
.getJSON("/dae/devise/code", {'devise': this.value
});
111 chargement_devise
.success(function(data
) {
112 ligne
.find(".taux").text(data
.taux_euro
)
113 ligne
.find(".devise_code").text(data
.devise_code
)
116 chargement_devise
.error(function(data
) {
117 alert(data
.responseText
);
118 ligne
.find(".taux").text(0)
119 ligne
.find(".devise_code").text("???")
124 $
('#id_classement_min, #id_classement_max').change(function(e
) {
125 var classement
= $
(this);
126 var ligne
= classement
.parents("tr");
127 var chargement_coeff
= $
.getJSON("/dae/coefficient", {'classement': classement
.val()});
128 chargement_coeff
.success(function(data
){
129 var inputs
= ligne
.find("input");
130 inputs
.each(function() {
132 if (input
.attr('id').match('id_coefficient*'))
133 input
.val(data
.coefficient
);
135 recalculer(classement
);
137 chargement_coeff
.error(function(data
){
142 $
('#classement input, #classement select').change(function() {