Skip to content
Snippets Groups Projects
Commit 5e8c6ee6 authored by Antony Le Courtes's avatar Antony Le Courtes
Browse files

Correction lors de la demande de mise en paiement, pour que la liste de centre...

Correction lors de la demande de mise en paiement, pour que la liste de centre de coût permmette de choisir un EOTP même si son centre de coût parent n'est pas de la même activité (#48286)
parent ce6c640d
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,7 @@ ...@@ -6,8 +6,7 @@
* @param {string} id * @param {string} id
* @returns {DemandeMiseEnPaiement} * @returns {DemandeMiseEnPaiement}
*/ */
function DemandeMiseEnPaiement(id) function DemandeMiseEnPaiement(id) {
{
this.id = id; this.id = id;
this.element = $(".demande-mise-en-paiement#" + this.id); this.element = $(".demande-mise-en-paiement#" + this.id);
this.params = this.element.data('params'); this.params = this.element.data('params');
...@@ -15,8 +14,7 @@ function DemandeMiseEnPaiement(id) ...@@ -15,8 +14,7 @@ function DemandeMiseEnPaiement(id)
this.miseEnPaiementSequence = 1; this.miseEnPaiementSequence = 1;
this.changes = {}; this.changes = {};
this.showError = function (serviceElement, errorStr) this.showError = function (serviceElement, errorStr) {
{
var out = '<div class="alert alert-danger alert-dismissible" role="alert">' var out = '<div class="alert alert-danger alert-dismissible" role="alert">'
+ '<i class="fas fa-exclamation"></i> ' + '<i class="fas fa-exclamation"></i> '
+ errorStr + errorStr
...@@ -26,21 +24,17 @@ function DemandeMiseEnPaiement(id) ...@@ -26,21 +24,17 @@ function DemandeMiseEnPaiement(id)
} }
/** /**
* *
* *
* @returns {undefined} * @returns {undefined}
*/ */
this.demanderToutesHeuresEnPaiement = function () this.demanderToutesHeuresEnPaiement = function () {
{
this.element.find(".heures-non-dmep:visible").click(); this.element.find(".heures-non-dmep:visible").click();
} }
this.changeUpdate = function (miseEnPaiementId, propertyName, newValue) {
this.changeUpdate = function (miseEnPaiementId, propertyName, newValue)
{
if (this.changes[miseEnPaiementId] == undefined) { if (this.changes[miseEnPaiementId] == undefined) {
this.changes[miseEnPaiementId] = {}; this.changes[miseEnPaiementId] = {};
} }
...@@ -48,16 +42,12 @@ function DemandeMiseEnPaiement(id) ...@@ -48,16 +42,12 @@ function DemandeMiseEnPaiement(id)
} }
this.changeInsert = function (miseEnPaiementId, properties) {
this.changeInsert = function (miseEnPaiementId, properties)
{
this.changes[miseEnPaiementId] = properties; this.changes[miseEnPaiementId] = properties;
} }
this.changeDelete = function (miseEnPaiementId) {
this.changeDelete = function (miseEnPaiementId)
{
if (0 === miseEnPaiementId.indexOf('new-')) { if (0 === miseEnPaiementId.indexOf('new-')) {
delete this.changes[miseEnPaiementId]; delete this.changes[miseEnPaiementId];
} else { } else {
...@@ -66,13 +56,11 @@ function DemandeMiseEnPaiement(id) ...@@ -66,13 +56,11 @@ function DemandeMiseEnPaiement(id)
} }
/** /**
* *
* @returns {Boolean} * @returns {Boolean}
*/ */
this.valider = function () this.valider = function () {
{
var result = true; var result = true;
var services = {}; var services = {};
for (var id in this.misesEnPaiementListes) { for (var id in this.misesEnPaiementListes) {
...@@ -113,13 +101,11 @@ function DemandeMiseEnPaiement(id) ...@@ -113,13 +101,11 @@ function DemandeMiseEnPaiement(id)
} }
/** /**
* *
* @returns {boolean} * @returns {boolean}
*/ */
this.sauvegarder = function () this.sauvegarder = function () {
{
if (!this.valider()) { if (!this.valider()) {
alert('Enregistrement impossible'); alert('Enregistrement impossible');
return false; return false;
...@@ -129,31 +115,26 @@ function DemandeMiseEnPaiement(id) ...@@ -129,31 +115,26 @@ function DemandeMiseEnPaiement(id)
} }
/** /**
* Initialisation * Initialisation
* *
* @returns {undefined} * @returns {undefined}
*/ */
this.init = function () this.init = function () {
{
var that = this; var that = this;
this.element.find(".mise-en-paiement-liste").each(function () this.element.find(".mise-en-paiement-liste").each(function () {
{
var id = $(this).attr('id'); var id = $(this).attr('id');
that.misesEnPaiementListes[id] = new MiseEnPaiementListe(that, $(this)); that.misesEnPaiementListes[id] = new MiseEnPaiementListe(that, $(this));
that.misesEnPaiementListes[id].init(); that.misesEnPaiementListes[id].init();
}); });
this.element.find(".toutes-heures-non-dmep").on("click", function () this.element.find(".toutes-heures-non-dmep").on("click", function () {
{
that.demanderToutesHeuresEnPaiement(); that.demanderToutesHeuresEnPaiement();
}); });
this.element.find("form").on("submit", function () this.element.find("form").on("submit", function () {
{
return that.sauvegarder(); return that.sauvegarder();
}); });
} }
...@@ -164,17 +145,13 @@ function DemandeMiseEnPaiement(id) ...@@ -164,17 +145,13 @@ function DemandeMiseEnPaiement(id)
* @param {string} id * @param {string} id
* @returns {DemandeMiseEnPaiement} * @returns {DemandeMiseEnPaiement}
*/ */
DemandeMiseEnPaiement.get = function (id) DemandeMiseEnPaiement.get = function (id) {
{
if (null == DemandeMiseEnPaiement.instances) DemandeMiseEnPaiement.instances = new Array(); if (null == DemandeMiseEnPaiement.instances) DemandeMiseEnPaiement.instances = new Array();
if (null == DemandeMiseEnPaiement.instances[id]) DemandeMiseEnPaiement.instances[id] = new DemandeMiseEnPaiement(id); if (null == DemandeMiseEnPaiement.instances[id]) DemandeMiseEnPaiement.instances[id] = new DemandeMiseEnPaiement(id);
return DemandeMiseEnPaiement.instances[id]; return DemandeMiseEnPaiement.instances[id];
} }
/** /**
* Liste de mises en paiement (par service ou par service référentiel) * Liste de mises en paiement (par service ou par service référentiel)
* *
...@@ -184,8 +161,7 @@ DemandeMiseEnPaiement.get = function (id) ...@@ -184,8 +161,7 @@ DemandeMiseEnPaiement.get = function (id)
* @param {Object} element * @param {Object} element
* @returns {MiseEnPaiementListe} * @returns {MiseEnPaiementListe}
*/ */
function MiseEnPaiementListe(demandeMiseEnPaiement, element) function MiseEnPaiementListe(demandeMiseEnPaiement, element) {
{
this.demandeMiseEnPaiement = demandeMiseEnPaiement; this.demandeMiseEnPaiement = demandeMiseEnPaiement;
this.id = element.attr('id'); this.id = element.attr('id');
this.element = element; this.element = element;
...@@ -194,20 +170,17 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -194,20 +170,17 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
this.initializing = true; this.initializing = true;
/** /**
* Détermine si la liste est en lecture seule ou non * Détermine si la liste est en lecture seule ou non
* *
* @returns {boolean} * @returns {boolean}
*/ */
this.isReadOnly = function () this.isReadOnly = function () {
{
return this.element.hasClass('read-only'); return this.element.hasClass('read-only');
} }
this.valider = function () this.valider = function () {
{
var that = this; var that = this;
this.validation = true; this.validation = true;
...@@ -218,15 +191,13 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -218,15 +191,13 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
this.showError('Trop d\'heures de paiement ont été demandées.'); this.showError('Trop d\'heures de paiement ont été demandées.');
} }
this.element.find("select[name='centre-cout']").each(function () this.element.find("select[name='centre-cout']").each(function () {
{
if ($(this).val() == '') { if ($(this).val() == '') {
that.showError('Centre de coûts à définir.'); that.showError('Centre de coûts à définir.');
} }
}); });
this.element.find("select[name='domaine-fonctionnel']").each(function () this.element.find("select[name='domaine-fonctionnel']").each(function () {
{
if ($(this).val() == '') { if ($(this).val() == '') {
that.showError('Domaine fonctionnel à définir.'); that.showError('Domaine fonctionnel à définir.');
} }
...@@ -236,9 +207,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -236,9 +207,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.showError = function (errorStr) {
this.showError = function (errorStr)
{
var out = '<div class="alert alert-danger alert-dismissible" role="alert">' var out = '<div class="alert alert-danger alert-dismissible" role="alert">'
+ '<i class="fas fa-exclamation"></i> ' + '<i class="fas fa-exclamation"></i> '
+ errorStr + errorStr
...@@ -249,14 +218,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -249,14 +218,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @param {string} id * @param {string} id
* @returns {DemandeMiseEnPaiement} * @returns {DemandeMiseEnPaiement}
*/ */
this.removeMiseEnPaiement = function (id) this.removeMiseEnPaiement = function (id) {
{
miseEnPaiement = this.element.find(".mise-en-paiement#" + id); miseEnPaiement = this.element.find(".mise-en-paiement#" + id);
miseEnPaiement.empty(); miseEnPaiement.empty();
this.params['demandes-mep'][id] = 'removed'; this.params['demandes-mep'][id] = 'removed';
...@@ -267,7 +234,6 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -267,7 +234,6 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @param {Object} miseEnPaiementListe * @param {Object} miseEnPaiementListe
...@@ -276,8 +242,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -276,8 +242,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
* @param {string} centreCoutId * @param {string} centreCoutId
* @returns {DemandeMiseEnPaiement} * @returns {DemandeMiseEnPaiement}
*/ */
this.addMiseEnPaiement = function (id, heures, centreCoutId, domaineFonctionnelId, focus) this.addMiseEnPaiement = function (id, heures, centreCoutId, domaineFonctionnelId, focus) {
{
var that = this; var that = this;
var isNew = undefined === id; var isNew = undefined === id;
...@@ -294,8 +259,8 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -294,8 +259,8 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
this.element.append(this.renderMiseEnPaiement(id)); this.element.append(this.renderMiseEnPaiement(id));
WidgetInitializer.includeJs(Url('vendor/bootstrap-select-1.14.0/dist/js/bootstrap-select.min.js')); WidgetInitializer.includeJs(Url('vendor/bootstrap-select-1.14.0/js/bootstrap-select.min.js'));
WidgetInitializer.includeCss(Url('vendor/bootstrap-select-1.14.0/dist/css/bootstrap-select.min.css')); WidgetInitializer.includeCss(Url('vendor/bootstrap-select-1.14.0/css/bootstrap-select.min.css'));
$('.selectpicker').selectpicker(); $('.selectpicker').selectpicker();
if (isNew) { if (isNew) {
...@@ -308,23 +273,19 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -308,23 +273,19 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
/* Connexion des événements */ /* Connexion des événements */
var heuresElement = this.element.find(".mise-en-paiement#" + id + " input[name='heures']"); var heuresElement = this.element.find(".mise-en-paiement#" + id + " input[name='heures']");
heuresElement.on('change', function () heuresElement.on('change', function () {
{
that.onHeuresChange($(this)); that.onHeuresChange($(this));
}); });
this.element.find(".mise-en-paiement#" + id + " select[name='centre-cout']").on('change', function () this.element.find(".mise-en-paiement#" + id + " select[name='centre-cout']").on('change', function () {
{
that.onCentreCoutChange($(this)); that.onCentreCoutChange($(this));
}); });
this.element.find(".mise-en-paiement#" + id + " select[name='domaine-fonctionnel']").on('change', function () this.element.find(".mise-en-paiement#" + id + " select[name='domaine-fonctionnel']").on('change', function () {
{
that.onDomaineFonctionnelChange($(this)); that.onDomaineFonctionnelChange($(this));
}); });
this.element.find(".mise-en-paiement#" + id + " .action-delete").on('click', function () this.element.find(".mise-en-paiement#" + id + " .action-delete").on('click', function () {
{
that.removeMiseEnPaiement(id); that.removeMiseEnPaiement(id);
}); });
...@@ -336,9 +297,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -336,9 +297,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.renderMiseEnPaiement = function (id) {
this.renderMiseEnPaiement = function (id)
{
var data = this.params['demandes-mep'][id]; var data = this.params['demandes-mep'][id];
var out = '<tr class="mise-en-paiement" id="' + id + '"><td class="nombre" style="vertical-align:middle">'; var out = '<tr class="mise-en-paiement" id="' + id + '"><td class="nombre" style="vertical-align:middle">';
...@@ -359,9 +318,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -359,9 +318,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.renderHeures = function (data) {
this.renderHeures = function (data)
{
var out; var out;
var max = this.params['heures-total'] - this.params['heures-mep']; var max = this.params['heures-total'] - this.params['heures-mep'];
...@@ -375,9 +332,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -375,9 +332,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.renderCentreCout = function (data) {
this.renderCentreCout = function (data)
{
var outC = ''; var outC = '';
ccCount = Util.json.count(this.params['centres-cout']); ccCount = Util.json.count(this.params['centres-cout']);
...@@ -403,7 +358,8 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -403,7 +358,8 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
outC += this.renderCentreCoutOption(this.params['centres-cout'][ccId], ccId, data['centre-cout-id']); outC += this.renderCentreCoutOption(this.params['centres-cout'][ccId], ccId, data['centre-cout-id']);
outC += '</optgroup>'; outC += '</optgroup>';
} else if (this.params['centres-cout'][ccId]['parent'] == null) { } else (this.params['centres-cout'][ccId]['parent'] == null)
{
outC += this.renderCentreCoutOption(this.params['centres-cout'][ccId], ccId, data['centre-cout-id']); outC += this.renderCentreCoutOption(this.params['centres-cout'][ccId], ccId, data['centre-cout-id']);
} }
} }
...@@ -416,9 +372,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -416,9 +372,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.renderCentreCoutOption = function (params, value, selVal) {
this.renderCentreCoutOption = function (params, value, selVal)
{
var selected = value == selVal ? ' selected="selected"' : ''; var selected = value == selVal ? ' selected="selected"' : '';
var bad = params['bad'] != undefined; var bad = params['bad'] != undefined;
var badText = '<span title=\'Centre de coûts supprimé ou incohérent\' class=\'label label-danger\'>' + params['libelle'] + '</span>'; var badText = '<span title=\'Centre de coûts supprimé ou incohérent\' class=\'label label-danger\'>' + params['libelle'] + '</span>';
...@@ -427,9 +381,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -427,9 +381,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.renderDomaineFonctionnel = function (data) {
this.renderDomaineFonctionnel = function (data)
{
var outDF = ''; var outDF = '';
; ;
...@@ -451,8 +403,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -451,8 +403,7 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.renderActions = function (data) this.renderActions = function (data) {
{
var outA; var outA;
if (data['read-only']) { if (data['read-only']) {
...@@ -469,14 +420,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -469,14 +420,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @param {integer} centreCoutId * @param {integer} centreCoutId
* @returns {undefined} * @returns {undefined}
*/ */
this.centreCoutGetChildren = function (centreCoutId) this.centreCoutGetChildren = function (centreCoutId) {
{
var result = {}; var result = {};
for (var ccId in this.params['centres-cout']) { for (var ccId in this.params['centres-cout']) {
if (this.params['centres-cout'][ccId]['parent'] == centreCoutId) { if (this.params['centres-cout'][ccId]['parent'] == centreCoutId) {
...@@ -487,13 +436,11 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -487,13 +436,11 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @param {Object} element * @param {Object} element
*/ */
this.onHeuresChange = function (element) this.onHeuresChange = function (element) {
{
var miseEnPaiementId = element.parents('.mise-en-paiement').attr('id'); var miseEnPaiementId = element.parents('.mise-en-paiement').attr('id');
var heures = Formatter.stringToFloat(element.val()); var heures = Formatter.stringToFloat(element.val());
...@@ -508,14 +455,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -508,14 +455,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @param {Object} element * @param {Object} element
* @returns {undefined} * @returns {undefined}
*/ */
this.onCentreCoutChange = function (element) this.onCentreCoutChange = function (element) {
{
var miseEnPaiementId = element.parents('.mise-en-paiement').attr('id'); var miseEnPaiementId = element.parents('.mise-en-paiement').attr('id');
var centreCoutId = element.val(); var centreCoutId = element.val();
this.params['demandes-mep'][miseEnPaiementId]['centre-cout-id'] = centreCoutId; this.params['demandes-mep'][miseEnPaiementId]['centre-cout-id'] = centreCoutId;
...@@ -524,27 +469,23 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -524,27 +469,23 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @param {Object} element * @param {Object} element
* @returns {undefined} * @returns {undefined}
*/ */
this.onDomaineFonctionnelChange = function (element) this.onDomaineFonctionnelChange = function (element) {
{
var miseEnPaiementId = element.parents('.mise-en-paiement').attr('id'); var miseEnPaiementId = element.parents('.mise-en-paiement').attr('id');
var domaineFonctionnelId = element.val(); var domaineFonctionnelId = element.val();
this.demandeMiseEnPaiement.changeUpdate(miseEnPaiementId, 'domaine-fonctionnel-id', domaineFonctionnelId); this.demandeMiseEnPaiement.changeUpdate(miseEnPaiementId, 'domaine-fonctionnel-id', domaineFonctionnelId);
} }
/** /**
* *
* @returns {undefined} * @returns {undefined}
*/ */
this.onAddHeuresRestantes = function () this.onAddHeuresRestantes = function () {
{
if (this.params['heures-non-dmep'] < 0) { if (this.params['heures-non-dmep'] < 0) {
alert('Il est impossible d\'ajouter des HETD négatifs.'); alert('Il est impossible d\'ajouter des HETD négatifs.');
} else { } else {
...@@ -553,13 +494,11 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -553,13 +494,11 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* *
* @returns {undefined} * @returns {undefined}
*/ */
this.updateHeuresRestantes = function () this.updateHeuresRestantes = function () {
{
this.params['heures-dmep'] = 0; this.params['heures-dmep'] = 0;
for (var miseEnPaiementId in this.params['demandes-mep']) { for (var miseEnPaiementId in this.params['demandes-mep']) {
if (this.params['demandes-mep'][miseEnPaiementId] !== 'removed') { if (this.params['demandes-mep'][miseEnPaiementId] !== 'removed') {
...@@ -594,14 +533,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -594,14 +533,12 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* Initialisation des lignes du formulaire à partir des données * Initialisation des lignes du formulaire à partir des données
* *
* @returns {undefined} * @returns {undefined}
*/ */
this.populate = function () this.populate = function () {
{
for (var miseEnPaiementId in this.params['demandes-mep']) { for (var miseEnPaiementId in this.params['demandes-mep']) {
this.addMiseEnPaiement(miseEnPaiementId); this.addMiseEnPaiement(miseEnPaiementId);
} }
...@@ -609,17 +546,14 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -609,17 +546,14 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
/** /**
* Initialisation * Initialisation
* *
* @returns {undefined} * @returns {undefined}
*/ */
this.init = function () this.init = function () {
{
var that = this; var that = this;
this.element.find('.heures-non-dmep').on('click', function () this.element.find('.heures-non-dmep').on('click', function () {
{
that.onAddHeuresRestantes(); that.onAddHeuresRestantes();
}); });
this.populate(); this.populate();
...@@ -627,51 +561,40 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element) ...@@ -627,51 +561,40 @@ function MiseEnPaiementListe(demandeMiseEnPaiement, element)
} }
this.onChange = function () {
this.onChange = function ()
{
if (!this.initializing) { if (!this.initializing) {
$('.dmep-budget').dmepBudget('changed'); $('.dmep-budget').dmepBudget('changed');
} }
} }
this.getHeuresTotal = function () {
this.getHeuresTotal = function ()
{
return this.params['heures-total']; return this.params['heures-total'];
} }
this.getHeuresDMEP = function () this.getHeuresDMEP = function () {
{
return this.params['heures-dmep']; return this.params['heures-dmep'];
} }
this.getHeuresMEP = function () this.getHeuresMEP = function () {
{
return this.params['heures-mep']; return this.params['heures-mep'];
} }
this.getServiceAPayerElement = function () this.getServiceAPayerElement = function () {
{
return this.element.parents("div.service-a-payer"); return this.element.parents("div.service-a-payer");
} }
} }
/** /**
* paiementMiseEnPaiementRechercheForm * paiementMiseEnPaiementRechercheForm
*/ */
$.widget("ose.paiementMiseEnPaiementRechercheForm", { $.widget("ose.paiementMiseEnPaiementRechercheForm", {
onTypeIntervenantChange: function () onTypeIntervenantChange: function () {
{
var structureElement = this.getStructureElement() var structureElement = this.getStructureElement()
if (structureElement) { if (structureElement) {
structureElement.val(''); structureElement.val('');
...@@ -679,8 +602,7 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", { ...@@ -679,8 +602,7 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", {
this.onStructureChange(); this.onStructureChange();
}, },
onStructureChange: function () onStructureChange: function () {
{
var periodeElement = this.getPeriodeElement() var periodeElement = this.getPeriodeElement()
if (periodeElement) { if (periodeElement) {
periodeElement.val(''); periodeElement.val('');
...@@ -688,14 +610,12 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", { ...@@ -688,14 +610,12 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", {
this.onPeriodeChange(); this.onPeriodeChange();
}, },
onPeriodeChange: function () onPeriodeChange: function () {
{
this.intervenantsSelectNone(); this.intervenantsSelectNone();
this.getSuiteElement().click(); this.getSuiteElement().click();
}, },
onIntervenantsChange: function () onIntervenantsChange: function () {
{
if (this.getIntervenantsElement().is(':visible')) { if (this.getIntervenantsElement().is(':visible')) {
this.getSuiteElement().hide(); this.getSuiteElement().hide();
if (this.getIntervenantsElement().val() == null) { if (this.getIntervenantsElement().val() == null) {
...@@ -709,40 +629,32 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", { ...@@ -709,40 +629,32 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", {
} }
}, },
hideActions: function () hideActions: function () {
{
this.getAfficherElement().hide(); this.getAfficherElement().hide();
this.getExporterPdfElement().hide(); this.getExporterPdfElement().hide();
this.getExporterCsvEtat().hide(); this.getExporterCsvEtat().hide();
this.getExporterCsvWinpaie().hide(); this.getExporterCsvWinpaie().hide();
}, },
showActions: function () showActions: function () {
{
this.getAfficherElement().show(); this.getAfficherElement().show();
this.getExporterPdfElement().show(); this.getExporterPdfElement().show();
this.getExporterCsvEtat().show(); this.getExporterCsvEtat().show();
this.getExporterCsvWinpaie().show(); this.getExporterCsvWinpaie().show();
}, },
intervenantsSelectAll: function () intervenantsSelectAll: function () {
{
this.getIntervenantsElement().find("option").prop("selected", "selected"); this.getIntervenantsElement().find("option").prop("selected", "selected");
this.onIntervenantsChange(); this.onIntervenantsChange();
}, },
intervenantsSelectNone: function () intervenantsSelectNone: function () {
{
this.getIntervenantsElement().val([]); this.getIntervenantsElement().val([]);
this.onIntervenantsChange(); this.onIntervenantsChange();
}, },
_create: function () {
_create: function ()
{
var that = this; var that = this;
var $radios = this.element.find('input:radio[name=type-intervenant]'); var $radios = this.element.find('input:radio[name=type-intervenant]');
...@@ -750,13 +662,20 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", { ...@@ -750,13 +662,20 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", {
$radios.filter('[value=""]').attr('checked', true); $radios.filter('[value=""]').attr('checked', true);
} }
this.getTypeIntervenantElement().change(function () { that.onTypeIntervenantChange() }); this.getTypeIntervenantElement().change(function () {
this.getStructureElement().change(function () { that.onStructureChange() }); that.onTypeIntervenantChange()
this.getPeriodeElement().change(function () { that.onPeriodeChange() }); });
this.getIntervenantsElement().change(function () { that.onIntervenantsChange() }); this.getStructureElement().change(function () {
that.onStructureChange()
});
this.getPeriodeElement().change(function () {
that.onPeriodeChange()
});
this.getIntervenantsElement().change(function () {
that.onIntervenantsChange()
});
$("body").on("mise-en-paiement-form-submit", function (event, data) $("body").on("mise-en-paiement-form-submit", function (event, data) {
{
if ($("div .messenger, div .alert", event.div).length ? false : true) { if ($("div .messenger, div .alert", event.div).length ? false : true) {
document.location.href = event.a.data('url-redirect'); document.location.href = event.a.data('url-redirect');
...@@ -765,71 +684,56 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", { ...@@ -765,71 +684,56 @@ $.widget("ose.paiementMiseEnPaiementRechercheForm", {
this.onIntervenantsChange(); this.onIntervenantsChange();
}, },
getTypeIntervenantElement: function () getTypeIntervenantElement: function () {
{
return this.element.find('[name="type-intervenant"]'); return this.element.find('[name="type-intervenant"]');
}, },
getStructureElement: function () getStructureElement: function () {
{
return this.element.find('[name="structure"]'); return this.element.find('[name="structure"]');
}, },
getPeriodeElement: function () getPeriodeElement: function () {
{
return this.element.find('[name="periode"]'); return this.element.find('[name="periode"]');
}, },
getIntervenantsElement: function () getIntervenantsElement: function () {
{
return this.element.find('[name="intervenants[]"]'); return this.element.find('[name="intervenants[]"]');
}, },
getSuiteElement: function () getSuiteElement: function () {
{
return this.element.find('[name="suite"]'); return this.element.find('[name="suite"]');
}, },
getAfficherElement: function () getAfficherElement: function () {
{
return this.element.find('[name="afficher"]'); return this.element.find('[name="afficher"]');
}, },
getExporterPdfElement: function () getExporterPdfElement: function () {
{
return this.element.find('[name="exporter-pdf"]'); return this.element.find('[name="exporter-pdf"]');
}, },
getExporterCsvEtat: function () getExporterCsvEtat: function () {
{
return this.element.find('[name="exporter-csv-etat"]'); return this.element.find('[name="exporter-csv-etat"]');
}, },
getExporterCsvWinpaie: function () getExporterCsvWinpaie: function () {
{
return this.element.find('[name="exporter-csv-winpaie"]'); return this.element.find('[name="exporter-csv-winpaie"]');
}, },
getEtat: function () getEtat: function () {
{
return this.element.parents('.filter').data('etat'); return this.element.parents('.filter').data('etat');
} }
}); });
$(function () $(function () {
{
WidgetInitializer.add('paiement-mise-en-paiement-recherche-form', 'paiementMiseEnPaiementRechercheForm'); WidgetInitializer.add('paiement-mise-en-paiement-recherche-form', 'paiementMiseEnPaiementRechercheForm');
}); });
$.widget("ose.paiementMiseEnPaiementForm", { $.widget("ose.paiementMiseEnPaiementForm", {
onPeriodeChange: function () onPeriodeChange: function () {
{
var periodeId = this.getPeriodeElement().val(); var periodeId = this.getPeriodeElement().val();
var dates = this.element.data('dates-mise-en-paiement'); var dates = this.element.data('dates-mise-en-paiement');
var periodePaiementTardifId = this.element.data('periode-paiement-tardif-id'); var periodePaiementTardifId = this.element.data('periode-paiement-tardif-id');
...@@ -846,70 +750,59 @@ $.widget("ose.paiementMiseEnPaiementForm", { ...@@ -846,70 +750,59 @@ $.widget("ose.paiementMiseEnPaiementForm", {
}, },
_create: function () {
_create: function ()
{
var that = this; var that = this;
this.getPeriodeElement().change(function () { that.onPeriodeChange() }); this.getPeriodeElement().change(function () {
that.onPeriodeChange()
});
}, },
getPeriodeElement: function () {
getPeriodeElement: function ()
{
return this.element.find('[name="periode"]'); return this.element.find('[name="periode"]');
}, },
getDateMiseEnPaiementElement: function () {
getDateMiseEnPaiementElement: function ()
{
return this.element.find('[name="date-mise-en-paiement"]'); return this.element.find('[name="date-mise-en-paiement"]');
} }
}); });
$(function () $(function () {
{
WidgetInitializer.add('paiement-mise-en-paiement-form', 'paiementMiseEnPaiementForm'); WidgetInitializer.add('paiement-mise-en-paiement-form', 'paiementMiseEnPaiementForm');
}); });
$.widget("ose.dmepBudget", { $.widget("ose.dmepBudget", {
oriData: undefined, oriData: undefined,
depassement: false, depassement: false,
_create: function () _create: function () {
{
var that = this; var that = this;
this.oriData = this.getData(); this.oriData = this.getData();
this.getElementsEnveloppes().each(function () this.getElementsEnveloppes().each(function () {
{
that.setDiffValue($(this).data('type-ressource'), $(this).data('structure'), 0); that.setDiffValue($(this).data('type-ressource'), $(this).data('structure'), 0);
}); });
this.updateBlocageDepassement(); this.updateBlocageDepassement();
setTimeout(function () { that.update() }, 5000); setTimeout(function () {
that.update()
}, 5000);
}, },
update: function () {
update: function ()
{
var that = this; var that = this;
var updateUrl = this.element.data('update-url'); var updateUrl = this.element.data('update-url');
var diffData = this.getDiffData(); var diffData = this.getDiffData();
data = $.getJSON(updateUrl, function (data) { data = $.getJSON(updateUrl, function (data) {
that.getElementsEnveloppes().each(function () that.getElementsEnveloppes().each(function () {
{
var structureId = $(this).data('structure'); var structureId = $(this).data('structure');
var typeRessourceId = $(this).data('type-ressource'); var typeRessourceId = $(this).data('type-ressource');
...@@ -931,18 +824,17 @@ $.widget("ose.dmepBudget", { ...@@ -931,18 +824,17 @@ $.widget("ose.dmepBudget", {
that.updateBlocageDepassement(); that.updateBlocageDepassement();
}); });
setTimeout(function () { that.update() }, 5000); setTimeout(function () {
that.update()
}, 5000);
}, },
changed: function () {
changed: function ()
{
var that = this; var that = this;
var data = this.getDiffData(); var data = this.getDiffData();
this.getElementsEnveloppes().each(function () this.getElementsEnveloppes().each(function () {
{
var structureId = $(this).data('structure'); var structureId = $(this).data('structure');
var typeRessourceId = $(this).data('type-ressource'); var typeRessourceId = $(this).data('type-ressource');
var value = 0; var value = 0;
...@@ -960,9 +852,7 @@ $.widget("ose.dmepBudget", { ...@@ -960,9 +852,7 @@ $.widget("ose.dmepBudget", {
}, },
getDiffData: function () {
getDiffData: function ()
{
var data = this.getData(); var data = this.getData();
for (structureId in this.oriData) { for (structureId in this.oriData) {
...@@ -980,13 +870,10 @@ $.widget("ose.dmepBudget", { ...@@ -980,13 +870,10 @@ $.widget("ose.dmepBudget", {
}, },
getData: function () {
getData: function ()
{
var data = {}; var data = {};
$('.demande-mise-en-paiement .mise-en-paiement').each(function () $('.demande-mise-en-paiement .mise-en-paiement').each(function () {
{
var id = $(this).attr('id'); var id = $(this).attr('id');
var params = $(this).parents('.mise-en-paiement-liste').data('params'); var params = $(this).parents('.mise-en-paiement-liste').data('params');
var structureId = params['structure-id']; var structureId = params['structure-id'];
...@@ -1011,9 +898,7 @@ $.widget("ose.dmepBudget", { ...@@ -1011,9 +898,7 @@ $.widget("ose.dmepBudget", {
}, },
setDiffValue: function (typeRessourceId, structureId, value) {
setDiffValue: function (typeRessourceId, structureId, value)
{
var progress = this.getElementEnveloppe(typeRessourceId, structureId); var progress = this.getElementEnveloppe(typeRessourceId, structureId);
var bar = progress.find('.progress-bar'); var bar = progress.find('.progress-bar');
var dotation = progress.data('dotation'); var dotation = progress.data('dotation');
...@@ -1044,9 +929,7 @@ $.widget("ose.dmepBudget", { ...@@ -1044,9 +929,7 @@ $.widget("ose.dmepBudget", {
}, },
updateBlocageDepassement: function () {
updateBlocageDepassement: function ()
{
if (this.depassement) { if (this.depassement) {
$('.demande-mise-en-paiement .sauvegarde').hide(); $('.demande-mise-en-paiement .sauvegarde').hide();
$('.demande-mise-en-paiement .depassement-budget').show(); $('.demande-mise-en-paiement .depassement-budget').show();
...@@ -1058,21 +941,16 @@ $.widget("ose.dmepBudget", { ...@@ -1058,21 +941,16 @@ $.widget("ose.dmepBudget", {
}, },
getElementEnveloppe: function (typeRessourceId, structureId) {
getElementEnveloppe: function (typeRessourceId, structureId)
{
return this.element.find('.enveloppe[data-type-ressource=' + typeRessourceId + '][data-structure=' + structureId + ']'); return this.element.find('.enveloppe[data-type-ressource=' + typeRessourceId + '][data-structure=' + structureId + ']');
}, },
getElementsEnveloppes: function () {
getElementsEnveloppes: function ()
{
return this.element.find('.enveloppe'); return this.element.find('.enveloppe');
} }
}); });
$(function () $(function () {
{
WidgetInitializer.add('dmep-budget', 'dmepBudget'); WidgetInitializer.add('dmep-budget', 'dmepBudget');
}); });
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment