Commit | Line | Data |
---|---|---|
f87fe1a1 OL |
1 | /* string to float */ |
2 | function clean_float(value){ | |
57bd966c | 3 | if (isNaN(value) || value == undefined || value == "") { |
f87fe1a1 | 4 | output = 0; |
57bd966c OL |
5 | } |
6 | else { | |
f87fe1a1 OL |
7 | output = parseFloat(value); |
8 | output = Math.round(output*100)/100; | |
57bd966c | 9 | } |
d300f7c6 | 10 | return output; |
f87fe1a1 | 11 | } |
72db8238 | 12 | |
3bb57906 OL |
13 | function roundNumber(num, dec) { |
14 | var result = Math.round(num*Math.pow(10,dec))/Math.pow(10,dec); | |
15 | return result; | |
16 | } | |
17 | ||
72db8238 OL |
18 | /* stocker le texte par défaut à afficher */ |
19 | var note_duree_indeterminee = ""; | |
20 | ||
21 | function contrat_mois() { | |
22 | if (note_duree_indeterminee == "") | |
23 | note_duree_indeterminee = $("#note-duree").html(); | |
24 | var debut = $("#id_date_debut, #id_contrat_date_debut").val(); | |
25 | var fin = $("#id_date_fin, #id_contrat_date_fin").val(); | |
26 | if (debut == "" || fin == "") | |
27 | note = note_duree_indeterminee; | |
28 | else { | |
7eda942c OL |
29 | var d = debut.split('-'); |
30 | j = d[0]; m = d[1];a = d[2]; | |
31 | var d1 = new Date(a, m, j); | |
7eda942c OL |
32 | |
33 | var d = fin.split('-'); | |
34 | j = d[0]; m = d[1];a = d[2]; | |
35 | var d2 = new Date(a, m, j); | |
7eda942c | 36 | |
72db8238 OL |
37 | var duree = Math.round((d2-d1) / (1000*60*60*24) / (365/12)); |
38 | note = duree + " mois"; | |
39 | } | |
40 | $("#note-duree").html(note); | |
41 | } | |
42 |