Commit | Line | Data |
---|---|---|
dfc31755 OL |
1 | /******************************************************************************* |
2 | * EMBAUCHE | |
3 | *******************************************************************************/ | |
66796c1f OL |
4 | function proposition_comparaison(devise_id) { |
5 | var chargement_devise = $.getJSON("/dae/devise/code", {'devise': devise_id}); | |
6 | chargement_devise.success(function(data) { | |
7 | var salaire = $("#id_salaire").val(); | |
8 | var montant = parseFloat(data.taux_euro) * parseFloat(salaire); | |
9 | $("#salaire-propose-euros").html(clean_float(montant)); | |
10 | }); | |
11 | chargement_devise.error(function(data) { | |
12 | alert(data.responseText); | |
13 | }); | |
14 | } | |
dfc31755 | 15 | |
179f6b49 OL |
16 | function activateDossierDropDowns() { |
17 | $('#id_classement, #id_devise').change(loadSalaire); | |
18 | } | |
19 | ||
661da766 | 20 | |
179f6b49 | 21 | function loadSalaire() { |
059d7fc3 | 22 | var implantation = $('#implantation').val(); |
a30962a4 | 23 | var devise = $('#id_devise').val(); |
059d7fc3 OL |
24 | var classement = $('#id_classement').val(); |
25 | if (implantation && devise && classement) { | |
26 | $.getJSON('/dae/salaire/' + implantation + '/' + devise + '/' + classement, | |
27 | function(data) { | |
7167d28f OL |
28 | if (data.status == 'OK') { |
29 | $('#id_salaire').val(clean_float(data.salaire_devise)); | |
30 | $('#id_salaire').trigger('change'); | |
31 | } | |
059d7fc3 OL |
32 | }); |
33 | } | |
179f6b49 OL |
34 | } |
35 | ||
36 | function round2(n) { | |
37 | return Math.round(n * 100) / 100; | |
38 | } | |
39 | ||
179f6b49 OL |
40 | activateDossierDropDowns(); |
41 | ||
179f6b49 OL |
42 | /* Ajout des datespickers sur les inputs loadés via AJAX. |
43 | On s'assure qu'on est pas dans le cas initial où ils sont déjà ajoutés. | |
44 | (La façon dont c'est fait requiert que les inputs soient uniquement dans la partie AJAX).*/ | |
45 | function datepicker() { | |
46 | var date_pickers = $(".datetimeshortcuts"); | |
47 | if (date_pickers.length == 0) | |
48 | DateTimeShortcuts.init(); | |
49 | } | |
50 | ||
51 | function activateEmployeDropDown() { | |
52 | $('#id_employe').change(loadEmploye); | |
53 | } | |
54 | ||
55 | function loadEmploye() { | |
56 | var employeUrl = '/dae/employe/' + $(this).val(); | |
57 | $('#form-employe').html('<tr><td>Chargement...</td></tr>') | |
58 | .load(employeUrl, activateEmployeDropDown); | |
59 | var dossierUrl = '/dae/dossier/' + $('#poste').val() + | |
60 | '/' + $(this).val(); | |
61 | $('#form-dossier').html('<tr><td>Chargement...</td></tr>') | |
62 | .load(dossierUrl, function() { | |
63 | datepicker(); | |
64 | activateDossierDropDowns(); | |
72db8238 | 65 | $("#id_contrat_date_debut, #id_contrat_date_fin").focusout(function() {contrat_mois();}); |
179f6b49 OL |
66 | }); |
67 | } | |
68 | ||
dfc31755 | 69 | $(document).ready(function() { |
179f6b49 OL |
70 | |
71 | /* Lorsqu'on choisit un poste dans la liste on recharge la page avec le | |
72 | poste chargé dans la view (grâce à son id dans l'URL).*/ | |
73 | $('#id_poste').change(function() { | |
74 | window.location = '/dae/embauche/' + $(this).val(); | |
75 | }); | |
76 | ||
77 | /* on lance le JS au chargement de la page, la toute première fois, | |
78 | puis on cable le change au select pour le rechargement. */ | |
72db8238 | 79 | //loadEmploye(); |
179f6b49 OL |
80 | activateEmployeDropDown(); |
81 | ||
72db8238 OL |
82 | /* calcul de la différence en mois */ |
83 | $("#id_contrat_date_debut, #id_contrat_date_fin").focusout(function() { | |
84 | contrat_mois(); | |
85 | }); | |
86 | contrat_mois(); | |
87 | ||
057763bc | 88 | /* Ajouter une ligne aux couts globals */ |
0a085c42 | 89 | /*$('#type-remun').change(function() { |
58ad4beb | 90 | var dossier_id = $('#dossier').attr('dossier'); |
057763bc OL |
91 | if ($(this).val() != '') { |
92 | $('#global-cost').html('<tr><td>Chargement...</td></tr>') | |
93 | .load('/dae/add-remun/' + | |
58ad4beb | 94 | dossier_id + '/' + |
057763bc OL |
95 | $(this).val(), function() { |
96 | $('#type-remun').val(''); | |
97 | }); | |
98 | } | |
99 | }); | |
0a085c42 | 100 | */ |
03b395db OL |
101 | /* Traitement de la recherche AJAX pour les dossiers de comparaison */ |
102 | $(".results_on_deck").bind('added', function() { | |
103 | ||
104 | /* récupération du choix dans la liste */ | |
105 | var input_id = $(this).attr('id').replace('_on_deck', ''); | |
106 | var prefix_dossier_connexe = $(this).attr('id').replace('recherche_on_deck', ''); | |
107 | var input = $('#'+input_id); | |
108 | var dossier_id = input.val(); | |
109 | ||
110 | /* interrogation par AJAX pour récupérer les données du dossier */ | |
111 | var chargement_dossier = $.getJSON("/dae/dossier_resume/" + dossier_id); | |
112 | chargement_dossier.success(function(data) { | |
113 | $('#' + prefix_dossier_connexe + 'implantation').val(data['implantation']); | |
0ebb99b3 | 114 | $('#' + prefix_dossier_connexe + 'classement').val(data['classement']); |
b9098c33 | 115 | $('#' + prefix_dossier_connexe + 'cmp_dossier').val(data['d_id']); |
0ebb99b3 | 116 | $('#' + prefix_dossier_connexe + 'statut').val(data['statut']); |
03b395db OL |
117 | $('#' + prefix_dossier_connexe + 'poste').val(data['poste']); |
118 | $('#' + prefix_dossier_connexe + 'personne').val(data['personne']); | |
119 | $('#' + prefix_dossier_connexe + 'montant').val(data['montant']); | |
120 | $('#' + prefix_dossier_connexe + 'devise').val(data['devise']); | |
121 | $('#' + prefix_dossier_connexe + 'montant_euros').val(data['montant_euros']); | |
122 | }); | |
123 | chargement_dossier.error(function(data) { | |
124 | alert(data.responseText); | |
125 | }); | |
126 | ||
127 | /* on ne veut pas afficher la personne en-dessous */ | |
128 | $(this).find('div').remove(); | |
129 | input.val(''); | |
03b395db | 130 | }); |
5d3caec3 BS |
131 | $(".results_on_deck").each(function(i, e){ |
132 | var input_id = $(this).attr('id').replace('_on_deck', ''); | |
133 | var prefix_dossier_connexe = $(this).attr('id').replace('recherche_on_deck', ''); | |
134 | var input = $('#'+input_id); | |
135 | var dossier_id = input.val(); | |
136 | var lnk = $(this).parent().find('.clear-cmp a'); | |
137 | if (dossier_id != null && dossier_id == '') { | |
138 | lnk.show() | |
139 | } | |
140 | lnk.click(function(e){ | |
141 | e.preventDefault(); | |
142 | $('#' + prefix_dossier_connexe + 'implantation').val(''); | |
143 | $('#' + prefix_dossier_connexe + 'classement').val(''); | |
144 | $('#' + prefix_dossier_connexe + 'cmp_dossier').val(''); | |
145 | $('#' + prefix_dossier_connexe + 'statut').val(''); | |
146 | $('#' + prefix_dossier_connexe + 'poste').val(''); | |
147 | $('#' + prefix_dossier_connexe + 'personne').val(''); | |
148 | $('#' + prefix_dossier_connexe + 'montant').val(''); | |
149 | $('#' + prefix_dossier_connexe + 'devise').val(''); | |
150 | $('#' + prefix_dossier_connexe + 'montant_euros').val(''); | |
151 | lnk.hide(); | |
152 | }); | |
153 | }); | |
dfc31755 | 154 | }); |