}
-var namePatt = new RegExp(/-(\d+)-/);
-formCount = null;
-
-function ajouterLigne(addLnk) {
- if (formCount == null) {
- formCount = $('.remunform').length;
- }
- var prev = addLnk.parent('td').parent('tr').prev('tr');
- var copyOfLastInGroup = prev.clone();
- copyOfLastInGroup.find('input, select, td.cumulable').each(function(i, e){
- var origName = $(e).attr('id');
- var origId = $(e).attr('id');
- $(e).attr('name', origName.replace(namePatt, '-' + formCount + '-'))
- $(e).attr('id', origId.replace(namePatt, '-' + formCount + '-'))
- $(e).val('');
- });
-
- prev.after(copyOfLastInGroup);
-
- copyOfLastInGroup.find('input, select').change(function(e){
- remun_totaux();
- });
- formCount++;
-}
-
function loadSalaire() {
var implantation = $('#implantation').val();
var devise = $('#id_devise').val();
return Math.round(n * 100) / 100;
}
-function remun_line(input) {
- var idParts = input.attr('id').split('-');
- var prefix = idParts[0] + "-" + idParts[1];
- var field = idParts[2];
-
- var montant_annuel = $('#' + prefix + '-montant');
- var montant_annuel_euros = $('#' + prefix + '-montant_annuel_euros');
-
- /* auto calcul a besoin d'un type (autrement ca devient un champs requis)*/
- // if ($('#' + prefix + '-type').val() == '') {
- // montant_annuel.val('');
- // montant_annuel_euros.val('');
- // return;
- // }
-
- value = (montant_annuel.val());
- value = roundNumber(value, 2)
-
- montant_annuel.val(roundNumber(value, 2));
-
- var devise = $('#' + prefix + '-devise').val();
- var taux = parseFloat(DEVISES[devise]);
- if (isNaN(taux)) taux = 0;
- montant_annuel_euros.text(roundNumber((value * taux), 2));
-}
-
-function totalByIndex(selector, accessor) {
- /*
- aelector: the element where to display costs, and from which the index will be calculated.
- accessor: a function to get all items that will be part of the total.
- */
- $(selector).each(function(){
- var subtot = 0;
- var i = $(this).index();
- var prevs = accessor($(this));
- prevs.each(function(){
- var cell = $($(this).children('td')[i]);
- var val;
- if (cell.children('input').length == 1) {
- val = cell.children('input').val();
- } else {
- val = cell.html();
- }
- subtot += clean_float(val);
- });
- $(this).html(roundNumber(subtot, 2));
- });
-}
-
-function remun_totaux() {
- $('#global-cost tr td.monnaie.cumulable input[type="text"], #global-cost tr td.monnaie.cumulable input[type="hidden"]').each(function() {
- remun_line($(this));
- });
- totalByIndex('#global-cost td.sous-total',
- function(x){return x.parent('tr').prevUntil(':not(.calculable)')});
- totalByIndex('#global-cost th.total',
- function(x){return x.parent('tr').prevAll('.sous-totaux')});
-}
-
-
activateDossierDropDowns();
/* Ajout des datespickers sur les inputs loadés via AJAX.
});
contrat_mois();
- /* totaux remu */
- $('#global-cost input, #global-cost select').change(function() {
- // remun_line($(this));
- remun_totaux();
- });
-
/* Ajouter une ligne aux couts globals */
/*$('#type-remun').change(function() {
var dossier_id = $('#dossier').attr('dossier');
}
});
*/
- remun_totaux();
-
- $('#global-cost .addlink').click(function(e){
- e.preventDefault();
- el = $(this);
- ajouterLigne(el);
- });
-
/* Traitement de la recherche AJAX pour les dossiers de comparaison */
$(".results_on_deck").bind('added', function() {