front : téléchargement de média command : suppression des média archivés - regénération des miniatures - import des fichiers Arcadia
207 lines
5.8 KiB
JavaScript
Vendored
207 lines
5.8 KiB
JavaScript
Vendored
|
|
$(document).ready(function() {
|
|
|
|
// ---- Gestion des utilisateurs : filtre role
|
|
$(".filter_role_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_user_input").val('');
|
|
var roleId = $(".filter_role").val();
|
|
tableSearch('.datatable tr.data_row', 'attr-role', roleId)
|
|
});
|
|
|
|
// ---- Gestion des dossiers : filtre sujet
|
|
$(".filter_sujet_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_user_input").val('');
|
|
var sujetId = $(".filter_sujet").val();
|
|
tableSearch('.datatable tr.data_row', 'attr-sujet', sujetId)
|
|
});
|
|
|
|
// ---- Gestion des utilisateurs : recherche d'utilisateur
|
|
$(".filter_user_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_role").val(0);
|
|
var search = $(".filter_user_input").val();
|
|
tableGlobalSearch('.datatable tr.data_row', search, [1,2,3]);
|
|
});
|
|
|
|
// ---- Gestion des dossiers : recherche un dossier
|
|
$(".filter_dossier_btn").on('click', function(event) {
|
|
event.preventDefault();
|
|
$(".filter_sujet").val(0);
|
|
var search = $(".filter_dossier_input").val();
|
|
tableGlobalSearch('.datatable tr.data_row', search, [1]);
|
|
});
|
|
|
|
// ---- Edition des utilisateurs : suppression d'utilisateur
|
|
$(".btn_delete_user").on('click', function(event) {
|
|
event.preventDefault();
|
|
var form = $(".deleteform");
|
|
$.fancyConfirm({
|
|
title : "Suppression d'un utilisateur",
|
|
message : "Êtes-vous sûr de vouloir supprimer cet utilisateur ?",
|
|
okButton : 'Supprimer',
|
|
noButton : 'Annuler',
|
|
callback : function (value) {
|
|
if (value) {
|
|
form.submit();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// ---- Edition des dossiers : suppression d'un dossier
|
|
$(".btn_delete_dossier").on('click', function(event) {
|
|
event.preventDefault();
|
|
var form = $(".deleteform");
|
|
$.fancyConfirm({
|
|
title : "Suppression d'un dossier",
|
|
message : "Êtes-vous sûr de vouloir supprimer ce dossier ?",
|
|
okButton : 'Supprimer',
|
|
noButton : 'Annuler',
|
|
callback : function (value) {
|
|
if (value) {
|
|
form.submit();
|
|
}
|
|
}
|
|
});
|
|
});
|
|
// ---- Ajout des utilisateurs : vérification du matricule
|
|
$(".check_matricule").on('blur', function(event) {
|
|
var matricule = $(this).val();
|
|
if(matricule == "") return false;
|
|
|
|
$(".loader").show();
|
|
$.ajaxSetup({
|
|
headers: {
|
|
'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
|
|
}
|
|
});
|
|
|
|
$.ajax({
|
|
url: '/check-matricule',
|
|
method: 'POST',
|
|
dataType : 'json',
|
|
data: {
|
|
matricule: matricule,
|
|
},
|
|
success: function(result){
|
|
$(".loader").hide();
|
|
if(result.exist_bdd){
|
|
$.fancyMessage({
|
|
title : "Attention",
|
|
message : "Ce matricule existe déjà. Veuillez en indiquer un autre.",
|
|
type : "error",
|
|
});
|
|
}else if(result.exist_ldap){
|
|
$("#firstname").val(result.ldap_user.firstname);
|
|
$("#lastname").val(result.ldap_user.lastname);
|
|
$("#email").val(result.ldap_user.email);
|
|
$.fancyMessage({
|
|
title : "Information",
|
|
message : "Ce matricule existe chez LDC. Le formulaire a été complété.",
|
|
type : "info",
|
|
});
|
|
}
|
|
},
|
|
error: function(jqXHR, textStatus, errorThrown) {
|
|
$(".loader").hide();
|
|
}
|
|
});
|
|
});
|
|
|
|
initSelector(".selector_marques");
|
|
initSelector(".selector_sujets");
|
|
});
|
|
|
|
|
|
// ---- Module de gestion de liste de données
|
|
window.initSelector = function($selector){
|
|
var datavalue = [];
|
|
|
|
// Init du module
|
|
$($selector+" .selector_values li").each(function() {
|
|
datavalue.push($(this).attr("data-value"));
|
|
});
|
|
$($selector+" .selector_choices li").each(function() {
|
|
var id = $(this).attr("data-value");
|
|
if(datavalue.indexOf(id)!= -1){
|
|
$(this).addClass('selected');
|
|
}
|
|
});
|
|
$($selector+" .selector_dataValues").val(datavalue.join());
|
|
|
|
// Recherche d'un élément
|
|
$($selector+" .selector_filter").off().on('keyup', function(event) {
|
|
var options = $(this).parent($selector).find(".selector_choices li");
|
|
var search = $(this).val();
|
|
$(options).each(function() {
|
|
|
|
if($(this).html().toUpperCase().indexOf(search.toUpperCase()) != -1 || search == ""){
|
|
$(this).css("display", "block");
|
|
}else{
|
|
$(this).css("display", "none");
|
|
}
|
|
});
|
|
});
|
|
|
|
// Ajout d'un élément
|
|
$($selector+" .selector_choices" ).off().on( "click", "li", function() {
|
|
if(!$(this).hasClass('selected')){
|
|
var id = $(this).attr("data-value");
|
|
var text = $(this).html();
|
|
$(this).addClass('selected');
|
|
$(this).parent().parent().find('.selector_values').append('<li data-value="'+id+'">'+text+' </li>');
|
|
datavalue.push(id);
|
|
$($selector+" .selector_dataValues").val(datavalue.join());
|
|
}
|
|
});
|
|
// Suppression d'un élément
|
|
$($selector+" .selector_values" ).off().on( "click", "li", function() {
|
|
var id = $(this).attr("data-value");
|
|
var text = $(this).html();
|
|
$(this).parent().parent().find('.selector_choices li[data-value="'+id+'"]').removeClass('selected');
|
|
$(this).remove();
|
|
var index = datavalue.indexOf(id);
|
|
if (index > -1) {
|
|
datavalue.splice(index, 1);
|
|
}
|
|
$($selector+" .selector_dataValues").val(datavalue.join());
|
|
});
|
|
}
|
|
|
|
|
|
// --- Fct pour rechercher sur un attribut d'une ligne
|
|
function tableSearch(field, attr, search){
|
|
$(field).each(function (index, value) {
|
|
if($(this).attr(attr) == search || search == 0){
|
|
$(this).show();
|
|
}else{
|
|
$(this).hide();
|
|
}
|
|
});
|
|
}
|
|
|
|
// --- Fct pour rechercher dans des colonnes d'une table
|
|
function tableGlobalSearch(field, search, cols){
|
|
var search = search.toUpperCase();
|
|
|
|
$(field).each(function (index, value) {
|
|
var $row = $(this);
|
|
var find = false;
|
|
$.each(cols, function (index, value) {
|
|
var dataCol = $row.find("td:nth-of-type("+value+")").text().toUpperCase();
|
|
|
|
if (dataCol.indexOf(search) != -1) {
|
|
find = true;
|
|
return false;
|
|
}
|
|
});
|
|
|
|
if(find){
|
|
$row.show();
|
|
}else{
|
|
$row.hide();
|
|
}
|
|
});
|
|
}
|