*******************************************************************************/
+function elements_comparaison(devise_id) {
+ var chargement_devise = $.getJSON("/dae/devise/code", {'devise': devise_id});
+ chargement_devise.success(function(data) {
+ /* data.devise
+ data.taux_euro
+ data.devise_code */
+ $('#elements-comparaison input').each(function() {
+ var input = $(this);
+ var montant = data.taux_euro * parseFloat(input.val());
+ input.parent().find(".devise_euro").html(clean_float(montant) + " EUR");
+ input.parent().find(".devise").html(data.devise_code);
+ });
+ });
+ chargement_devise.error(function(data) {
+ alert(data.responseText);
+ });
+}
+
+/* filter les postes en fonction de l'implantation choisie */
+function charger_postes(implantation_id) {
+ var selected = $("#id_poste :selected").val();
+ var params = {'implantation_id' : implantation_id};
+ var chargement_p = $.getJSON('/dae/liste_postes', params);
+ chargement_p.success(function(data) {
+ var items = [];
+
+ var options = "";
+ $.each(data, function(index) {
+ select = "";
+ if (data[index][0] == selected)
+ select = " selected=selected ";
+ options += '<option ' + select + ' value="' + data[index][0] + '">' + data[index][1] + '</option>';
+ });
+
+ $("#id_poste").html(options);
+ });
+}
+
/* Construction dynamique des valeurs de point en fonction de l'implantation choisie */
function charger_valeurs_point(implantation_id) {
var params = {'implantation_id' : implantation_id};
$("#id_valeur_point_min").html(options);
$("#id_valeur_point_max").html(options);
- alert("Les valeurs de point on été ajustées en fonction de cette implantation.");
+ alert("Les valeurs de point et les postes ont été ajustés en fonction de cette implantation.");
});
}
var valeur_point_input;
inputs.each(function() {
var input = $(this);
- if (input.attr('id').match('id_coefficient*')) {
- coeff = clean_float(input.val())
+
+ if (input.attr('id').match('id_classement*')) {
+ classement_id = input.val();
}
if (input.attr('id').match('id_valeur_point*')) {
valeur_point_input = input;
});
- /* on suggère un salaire de base en fonction du coefficient et de la valeur du point */
- valeur_point_text = valeur_point_input.find(":selected").text();
- if (valeur_point_text == "")
- valeur_point = 0;
- else
- valeur_point = clean_float(valeur_point_text.split(" ")[0]);
+ var chargement_coeff = $.getJSON("/dae/coefficient", {'classement': classement_id});
+ chargement_coeff.success(function(data){
+ coeff = data.coefficient;
+
+ /* on suggère un salaire de base en fonction du coefficient et de la valeur du point */
+ valeur_point_text = valeur_point_input.find(":selected").text();
+ if (valeur_point_text == "")
+ valeur_point = 0;
+ else
+ valeur_point = clean_float(valeur_point_text.split(" ")[0]);
- salaire = clean_float(valeur_point * coeff);
- salaire_input.val(salaire);
+ salaire = clean_float(valeur_point * coeff);
+ salaire_input.val(salaire);
- taux_euro = clean_float(ligne.find(".taux").html())
- total = 0;
- total = salaire + indemn + autre;
- total_euro = total * taux_euro;
+ taux_euro = parseFloat(ligne.find(".taux").html())
+ total = 0;
+ total = salaire + indemn + autre;
+ total_euro = total * taux_euro;
- ligne.find(".total-devise").text(total.toFixed(2));
- ligne.find(".total-euro").text(total_euro.toFixed(2));
+ ligne.find(".total-devise").text(clean_float(total));
+ ligne.find(".total-euro").text(clean_float(total_euro));
+ });
}
$(document).ready(function() {
+ /* Lorsqu'on choisit un poste dans la liste on recharge la page avec le
+ poste chargé dans la view (grâce à son id dans l'URL).*/
+ $('#id_poste').change(function() {
+ window.location = '/dae/poste/' + $(this).val();
+ });
+
/* La fonctionnalité de présélection, est activé uniquement si aucune implantation n'a déjà été
sélectionnée.
Lorsque l'implantation est changée, on ajuste les valeurs de points en fonction de cette sélection */
var implantation_id = $("#id_implantation").val();
$("#id_implantation").change(function() {
var implantation_id = this.value;
+ charger_postes(implantation_id);
charger_valeurs_point(implantation_id);
});
$('#id_classement_min, #id_classement_max').change(function(e) {
var classement = $(this);
- var ligne = classement.parents("tr");
- var chargement_coeff = $.getJSON("/dae/coefficient", {'classement': classement.val()});
- chargement_coeff.success(function(data){
- var inputs = ligne.find("input");
- inputs.each(function() {
- var input = $(this);
- if (input.attr('id').match('id_coefficient*'))
- input.val(data.coefficient);
- });
- recalculer_ligne(classement);
- });
- chargement_coeff.error(function(data){
- });
+ recalculer_ligne(classement);
});
/* refresh des totaux à chaque changement quelconque */
contrat_mois();
});
contrat_mois();
+
+ /* on charge les postes reliés à cette implantation */
+ charger_postes($("#id_implantation :selected").val());
+
+ $('#id_devise_comparaison, #elements-comparaison input').change(function(e) {
+ elements_comparaison($('#id_devise_comparaison').val());
+ });
+ elements_comparaison($('#id_devise_comparaison').val());
});