Select Git revision
FormAwareTrait.php
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
service.js 17.27 KiB
/***************************************************************************************************************************************************
Propre à l'affichage des services
/***************************************************************************************************************************************************/
$.widget("ose.serviceListe", {
totaux: {},
total: 0,
showHideTypesIntervention: function () {
var count = 0;
for (var i in this.totaux) {
if (this.totaux[i] != 0) {
count++;
this.element.find("table.service tr th." + i).show(); // entête
this.element.find("table.service tr.service-ligne td.type-intervention." + i).show();
this.element.find("table.service tfoot tr td." + i).show(); // total
} else {
this.element.find("table.service tr th." + i).hide(); // entête
this.element.find("table.service tr.service-ligne td.type-intervention." + i).hide();
this.element.find("table.service tfoot tr td." + i).hide(); // total
}
}
this.element.find("table.service #total-general").attr('colspan', count);
if (count == 0) {
this.element.find("table.service tfoot").hide();
} else {
this.element.find("table.service tfoot").show();
}
},
calculTotaux: function () {
var that = this;
this.totaux = {};
this.total = 0;
this.element.find("table.service tr.service-ligne td.type-intervention").each(function () {
var typeInterventionCode = $(this).data('type-intervention-code');
var value = $(this).data('value');
if (that.totaux[typeInterventionCode] == undefined) that.totaux[typeInterventionCode] = 0;
that.totaux[typeInterventionCode] += value;
that.total += value;
});
// on met à jour aussi les entêtes et les totaux
for (var ti in this.totaux) {
var heures = this.totaux[ti];
this.element.find("table.service tfoot tr td." + ti).html(Util.formattedHeures(heures));
}
this.element.find("table.service #total-general").html(Util.formattedHeures(this.total));
},
showHideDetails: function (serviceId, action) {
var tr = this.element.find("#service-" + serviceId + "-volume-horaire-tr");
var button = this.element.find("#service-" + serviceId + "-ligne td.actions .service-details-button");
if (undefined === action) {
if (tr.css('display') === 'none') {
action = 'show';
} else {
action = 'hide';
}
}
if (action === 'show') {
button.html('<i class="fas fa-chevron-up"></i>');
tr.show(200);
} else {
button.html('<i class="fas fa-chevron-down"></i>');