{{ form.media }}
<script src="{{ MEDIA_URL }}js/dae.js" /></script>
+ <script src="{{ MEDIA_URL }}js/dae-poste.js" /></script>
<link href="{{ MEDIA_URL }}/css/redmond/jquery-ui-1.8.11.custom.css"
--- /dev/null
+/*******************************************************************************
+* POSTE
+*******************************************************************************/
+
+/* Construction dynamique des valeurs de point en fonction de l'implantation choisie */
+function charger_valeurs_point(implantation_id) {
+ var params = {'implantation_id' : implantation_id};
+ var chargement_vp = $.getJSON('/dae/liste_valeurs_point', params);
+ chargement_vp.success(function(data) {
+ var items = [];
+
+ var options = "";
+ $.each(data, function() {
+ options += '<option value="' + this.id + '">' + this.label + '</option>';
+ });
+
+ $("#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.");
+ });
+}
+
+/* Calcul des totaux dans les 2 devises, selon les champs sélectionnés. Cette fonction
+est appelée À chaque modification du formulaire de classement. */
+function recalculer_ligne(element) {
+ var ligne = element.parents("tr");
+ var inputs = ligne.find("input, select");
+ var salaire_input;
+ 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_valeur_point*')) {
+ valeur_point_input = input;
+ }
+ if (input.attr('id').match('id_salaire*')) {
+ salaire_input = input;
+ salaire = clean_float(input.val())
+ }
+ if (input.attr('id').match('id_indemn*')) {
+ indemn = clean_float(input.val())
+ }
+ if (input.attr('id').match('id_autre*')) {
+ autre = clean_float(input.val())
+ }
+
+ });
+
+ /* 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);
+
+ taux_euro = clean_float(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));
+
+}
+
+/* recalcule tout le classement */
+function recalculer_tout() {
+ $("#classement tr *[name*=devise]").each(function() {
+ recalculer_ligne($(this));
+ });
+}
+
+$(document).ready(function() {
+
+ /* 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_valeurs_point(implantation_id);
+ });
+
+
+ $('#id_valeur_point_min, #id_valeur_point_max').change(function(e) {
+ var vp_input = $(this);
+ var ligne = vp_input.parents("tr").parent(); // en fait on travaille sur tout le tableau dans ce cas!
+
+ var chargement_devise = $.getJSON("/dae/devise", {'valeur_point': this.value});
+ chargement_devise.success(function(data) {
+ var selects = ligne.find("select");
+ selects.each(function() {
+ var s = $(this);
+ if (s.attr('id').match('id_devise*'))
+ s.val(data.devise)
+ ligne.find(".taux").text(data.taux_euro)
+ ligne.find(".devise_code").text(data.devise_code)
+ });
+
+ /* on synchronise les valeurs de points */
+ $('#id_valeur_point_min, #id_valeur_point_max').each(function() {
+ var vp = $(this);
+ if (vp.val() != vp_input.val()) {
+ vp.val(vp_input.val())
+ }
+ });
+
+ recalculer_ligne(vp_input);
+ });
+ chargement_devise.error(function(data) {
+ alert(data.responseText);
+ });
+
+ });
+
+ $('#id_devise_min, #id_devise_max').change(function(e) {
+ var input = $(this);
+ var ligne = input.parents("tr");
+ var chargement_devise = $.getJSON("/dae/devise/code", {'devise': this.value});
+ chargement_devise.success(function(data) {
+ ligne.find(".taux").text(data.taux_euro)
+ ligne.find(".devise_code").text(data.devise_code)
+ recalculer_ligne(input);
+ });
+ chargement_devise.error(function(data) {
+ alert(data.responseText);
+ ligne.find(".taux").text(0)
+ ligne.find(".devise_code").text("???")
+ });
+
+ });
+
+ $('#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){
+ });
+ });
+
+ /* refresh des totaux à chaque changement quelconque */
+ $('#classement input, #classement select').change(function() {
+ recalculer_ligne($(this));
+ });
+
+ /* au chargement, on calcule tout */
+ recalculer_tout();
+
+});
output = Math.round(output*100)/100;
return output;
}
-
-/* Construction dynamique des valeurs de point en fonction de l'implantation choisie */
-function charger_valeurs_point(implantation_id) {
- var params = {'implantation_id' : implantation_id};
- var chargement_vp = $.getJSON('/dae/liste_valeurs_point', params);
- chargement_vp.success(function(data) {
- var items = [];
-
- var options = "";
- $.each(data, function() {
- options += '<option value="' + this.id + '">' + this.label + '</option>';
- });
-
- $("#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.");
- });
-}
-
-/* Calcul des totaux dans les 2 devises, selon les champs sélectionnés. Cette fonction
-est appelée À chaque modification du formulaire de classement. */
-function recalculer_ligne(element) {
- var ligne = element.parents("tr");
- var inputs = ligne.find("input, select");
- var salaire_input;
- 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_valeur_point*')) {
- valeur_point_input = input;
- }
- if (input.attr('id').match('id_salaire*')) {
- salaire_input = input;
- salaire = clean_float(input.val())
- }
- if (input.attr('id').match('id_indemn*')) {
- indemn = clean_float(input.val())
- }
- if (input.attr('id').match('id_autre*')) {
- autre = clean_float(input.val())
- }
-
- });
-
- /* 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);
-
- taux_euro = clean_float(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));
-
-}
-
-/* recalcule tout le classement */
-function recalculer_tout() {
- $("#classement tr *[name*=devise]").each(function() {
- recalculer_ligne($(this));
- });
-}
-
-$(document).ready(function() {
-
- /* 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_valeurs_point(implantation_id);
- });
-
-
- $('#id_valeur_point_min, #id_valeur_point_max').change(function(e) {
- var vp_input = $(this);
- var ligne = vp_input.parents("tr").parent(); // en fait on travaille sur tout le tableau dans ce cas!
-
- var chargement_devise = $.getJSON("/dae/devise", {'valeur_point': this.value});
- chargement_devise.success(function(data) {
- var selects = ligne.find("select");
- selects.each(function() {
- var s = $(this);
- if (s.attr('id').match('id_devise*'))
- s.val(data.devise)
- ligne.find(".taux").text(data.taux_euro)
- ligne.find(".devise_code").text(data.devise_code)
- });
-
- /* on synchronise les valeurs de points */
- $('#id_valeur_point_min, #id_valeur_point_max').each(function() {
- var vp = $(this);
- if (vp.val() != vp_input.val()) {
- vp.val(vp_input.val())
- }
- });
-
- recalculer_ligne(vp_input);
- });
- chargement_devise.error(function(data) {
- alert(data.responseText);
- });
-
- });
-
- $('#id_devise_min, #id_devise_max').change(function(e) {
- var input = $(this);
- var ligne = input.parents("tr");
- var chargement_devise = $.getJSON("/dae/devise/code", {'devise': this.value});
- chargement_devise.success(function(data) {
- ligne.find(".taux").text(data.taux_euro)
- ligne.find(".devise_code").text(data.devise_code)
- recalculer_ligne(input);
- });
- chargement_devise.error(function(data) {
- alert(data.responseText);
- ligne.find(".taux").text(0)
- ligne.find(".devise_code").text("???")
- });
-
- });
-
- $('#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){
- });
- });
-
- /* refresh des totaux à chaque changement quelconque */
- $('#classement input, #classement select').change(function() {
- recalculer_ligne($(this));
- });
-
- /* au chargement, on calcule tout */
- recalculer_tout();
-
-});