$(document).ready(function(){
if($('a[data-toggle="tab"]').length > 0){
$('a[data-toggle="tab"]').on('shown.bs.tab', function (e) {
$('#calendar').fullCalendar('render');;
});
$('#myTab a:first').tab('show');
}
if($('.input_heure').length > 0)
$('.input_heure').mask('00:00:00');
var chemin = window.location.pathname;
var art_id = $(this).attr("id");
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
$('#nav1 li').removeClass('active')
if(chemin.indexOf('index.php') != -1)
$('#nav1 #one').addClass('active')
if(chemin.indexOf('categories.php') != -1)
$('#nav1 #two').addClass('active')
if(chemin.indexOf('articles.php') != -1)
$('#nav1 #three').addClass('active')
if(chemin.indexOf('products.php') != -1)
$('#nav1 #four').addClass('active')
if(chemin.indexOf('evenements.php') != -1)
$('#nav1 #five').addClass('active')
if(chemin.indexOf('books.php') != -1)
$('#nav1 #six').addClass('active')
if(chemin.indexOf('photos.php') != -1)
$('#nav1 #seven').addClass('active')
if(chemin.indexOf('customers.php') != -1 || chemin.indexOf('newsletters.php') != -1 )
$('#nav1 #height').addClass('active')
if(chemin.indexOf('selectable.php') != -1)
$('#nav1 #nine').addClass('active')
if(chemin.indexOf('contact.php') != -1)
$('#nav1 #nine').addClass('active')
//gestion du statut indéterminé des checkbox
if($("#customers_search_engine input[type=checkbox]").length > 0){
var $check = $("#customers_search_engine input[type=checkbox]"), el;
$check.data('checked',0).click(function(e) {
el = $(this);
switch(el.data('checked')) {
// unchecked, going indeterminate
case 0:
el.data('checked',1);
el.prop('indeterminate',true);
break;
// indeterminate, going checked
case 1:
el.data('checked',2);
el.prop('indeterminate',false);
el.prop('checked',true);
break;
// checked, going unchecked
default:
el.data('checked',0);
el.prop('indeterminate',false);
el.prop('checked',false);
}
});
}
//Gère la taille des blocs de la page d'accueil
if($('.box_accueil').length > 0)
$('.box_accueil').sameHeights('.white_background');
//Permet l'effacement d'un article, d'une news, d'un évènement, d'un livre ou d'un produit
$(".btn_delete").click(function(){
var art_link = $(this).attr("id");
var chemin = window.location.pathname;
var destination = '';
var page_article = '';
if(chemin.indexOf('articles.php') != -1){
destination = "articles.php";
page_article = "articles.php?action=delete_article&article_id="+art_link;
}
if(chemin.indexOf('articles_pdf.php') != -1){
destination = "articles_pdf.php";
page_article = "articles_pdf.php?action=delete_article&article_id="+art_link;
}
if(chemin.indexOf('news.php') != -1){
destination = "news.php";
page_article = "news.php?action=delete_news&news_id="+art_link;
}
if(chemin.indexOf('evenements.php') != -1){
destination = "evenements.php";
page_article = "evenements.php?action=delete_evenement&evenement_id="+art_link;
}
if(chemin.indexOf('books.php') != -1){
destination = "books.php";
page_article = "books.php?action=delete_books&book_id="+art_link;
}
if(chemin.indexOf('products.php') != -1){
destination = "products.php";
page_article = "products.php?action=delete_product&product_id="+art_link;
}
contenu = '';
contenu += '
';
contenu += 'Voulez vous vraiment supprimer cet élément ?
';
contenu += '
';
contenu += '';
contenu += 'ANNULER';
contenu += '
';
contenu += '';
contenu += '
SUPPRIMER';
contenu += '
';
contenu += '
';
// var Contenu = 'Voulez vous vraiment supprimer cet élément ?
SupprimerAnnuler'
jQuery.ajax({
url: destination,
context: document.body
}).done(function() {
$("#myModalDelete .modal-body").empty();
$("#myModalDelete .modal-body").append(contenu);
});
});
//Permet l'effacement d'un article, d'une news, d'un évènement, d'un livre ou d'un produit
$(".manage_list input[name=product_qte], .manage_list input[name=product_buy_price], .manage_list input[name=product_sell_price]").on('keyup', function(){
if($(this).val() == 0){
$(this).parent().parent().parent().addClass('bg-danger');
} else {
$(this).parent().parent().parent().removeClass('bg-danger');
}
});
$(".manage_list input[name=product_qte]").on('keyup', function(){
var update_qte = '';
var product_id = '';
if($(this).val() != ''){
product_id = $(this).parent().parent().parent().attr('product_id');
update_qte = $(this).val();
}
$.ajax({
url : 'update_product.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=update&product_id='+product_id+'&product_qte='+update_qte,
success : function(code_html, statut){ // code_html contient le HTML renvoyé
}
});
});
$(".manage_list input[name=product_buy_price]").on('keyup', function(){
var update_buy_price = '';
var product_id = '';
if($(this).val() != ''){
product_id = $(this).parent().parent().parent().attr('product_id');
update_buy_price = $(this).val();
}
$.ajax({
url : 'update_product.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=update&product_id='+product_id+'&product_buy_price='+update_buy_price,
success : function(code_html, statut){ // code_html contient le HTML renvoyé
}
});
});
$(".manage_list input[name=product_sell_price]").on('keyup', function(){
var update_sell_price = '';
var product_id = '';
if($(this).val() != ''){
product_id = $(this).parent().parent().parent().attr('product_id');
update_sell_price = $(this).val();
}
$.ajax({
url : 'update_product.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=update&product_id='+product_id+'&product_sell_price='+update_sell_price,
success : function(code_html, statut){ // code_html contient le HTML renvoyé
}
});
});
//Permet l'affichage ou non du datepicker si sollicité pour la page
if($( "#datepicker_debut" ).length > 0)
$( "#datepicker_debut" ).datepicker();
if($( "#datepicker_fin" ).length > 0)
$( "#datepicker_fin" ).datepicker();
if($( "#user_extend_birth" ).length > 0)
$( "#user_extend_birth" ).datepicker();
//Configuration de la gallerie de photo
if($('#blueimp-gallery').lengh > 0){
var borderless = true
$('#blueimp-gallery').data('useBootstrapModal', !borderless).toggleClass('blueimp-gallery-controls', borderless);
}
if($("#links").length > 0){
document.getElementById('links').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = {index: link, event: event},
links = this.getElementsByTagName('a');
blueimp.Gallery(links, options);
};
}
//Indicateur de sélection de la catégorie pour affichage visuel
if($('#cat_edit').length > 0){
var selected_option = $('#cat_edit').val();
$('.select_edit #categorie option').each(function(){
if(this.value == selected_option )
{
$(this).attr('selected','selected');
}
});
}
$('.select_edit #categorie').change(function(){
$('.select_edit #categorie option').each(function(){
$(this).removeAttr('selected');
});
});
//Permet d'afficher les champs correspondants au type de produit sélectionné
// Premier cas: ne change que de l'affichage
// second cas: envoie les informations en AJAX pour traitement PHP
$('#product_type').change(function() {
chemin = window.location.href;
if(chemin.indexOf('action=create') != -1)
{
$('.product_input').hide();
$('.product_input input').val('');
$('#product_categorie').val($(this).val());
if($(this).val() == 1){
$('#product_image, #product_name, #product_number, #product_auteur, #product_editeur, #product_qte, #product_buy_price, #product_sell_price').show();
} else if($(this).val() == 2){
$('#product_image, #product_name, #product_etat, #product_qte, #product_conditionnement, #product_price, #product_disponibilite').show();
}
}
if(chemin.indexOf('action=manage'))
{
// var chemin = $(this).attr('id');
var product_type= $('#product_type').val();
var product_name = $('#search_product_name').val();
var product_number = $('#search_product_number').val();
var product_qte = $('#search_product_qte').val();
var product_auteur = $('#search_product_auteur').val();
var product_editeur = $('#search_product_editeur').val();
// var destination = '';
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
$("ul.manage_list").empty().append(xhr.responseText);
}
};
xhr.open("POST", "search_products.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("product_type="+product_type+"&product_name="+product_name+"&product_number="+product_number+"&product_qte="+product_qte+"&product_auteur="+product_auteur+"&product_editeur="+product_editeur);
// xhr.send(null);
}
});
//Gère la barre de recherche de la page des produits afin de permettre une recherche à la volée
$('#search_product_name, #search_product_number, #search_product_auteur, #search_product_editeur').keyup(function() {
if($(this).val().length >= 3){
// var chemin = $(this).attr('id');
var product_type= $('#product_type').val();
var product_name = $('#search_product_name').val();
var product_number = $('#search_product_number').val();
var product_qte = $('#search_product_qte').val();
var product_auteur = $('#search_product_auteur').val();
var product_editeur = $('#search_product_editeur').val();
// var destination = '';
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
$("ul.manage_list").empty().append(xhr.responseText);
}
};
xhr.open("POST", "search_products.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("product_type="+product_type+"&product_name="+product_name+"&product_number="+product_number+"&product_qte="+product_qte+"&product_auteur="+product_auteur+"&product_editeur="+product_editeur);
// xhr.send(null);
}
if($('#search_product_name').val() == '' && $('#search_product_number').val() == '' && $('#search_product_auteur').val() == '' && $('#search_product_editeur').val() == '' )
{
window.location.reload();
}
});
//Gère la barre de recherche de la page des produits afin de permettre une recherche à la volée
$('#search_product_qte').keyup(function() {
// if($(this).val().length >= 3){
// var chemin = $(this).attr('id');
var product_type= $('#product_type').val();
var product_name = $('#search_product_name').val();
var product_number = $('#search_product_number').val();
var product_qte = $('#search_product_qte').val();
var product_auteur = $('#search_product_auteur').val();
var product_editeur = $('#search_product_editeur').val();
// var destination = '';
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
$("ul.manage_list").empty().append(xhr.responseText);
}
};
xhr.open("POST", "search_products.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("product_type="+product_type+"&product_name="+product_name+"&product_number="+product_number+"&product_qte="+product_qte+"&product_auteur="+product_auteur+"&product_editeur="+product_editeur);
// xhr.send(null);
// }
});
//Gère la barre de recherche de la page des produits afin de permettre une recherche à la volée
/* $('.search_product_input').keyup(function() {
// var chemin = $(this).attr('id');
var product_type= $('#product_type').val();
var product_name = $('#search_product_name').val();
var product_number = $('#search_product_number').val();
var product_qte = $('#search_product_qte').val();
var product_auteur = $('#search_product_auteur').val();
var product_editeur = $('#search_product_editeur').val();
// var destination = '';
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
$("ul.manage_list").empty().append(xhr.responseText);
}
};
xhr.open("POST", "search_products.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("product_type="+product_type+"&product_name="+product_name+"&product_number="+product_number+"&product_qte="+product_qte+"&product_auteur="+product_auteur+"&product_editeur="+product_editeur);
// xhr.send(null);
}); */
//Permet l'ajout d'une sous catégorie à la liste de sous catégorie du site choisit
$('#submit_sub_cat_btn').click(function() {
var categorie_name = $('#categorie_name').val();
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
$(".sub_cat_list").empty().append(xhr.responseText);
}
};
xhr.open("POST", "create_sub_cat.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("categorie_name="+categorie_name);
});
$('#img_input').click(function(){
$('#couverture_recto').click();
});
$('#cloud_upload.pictures').click(function(){
$('#multiupload').click();
});
/*
$('.cloud_upload').click(function(){
$(this).next().click();
});
*/
$('#cloud_upload').click(function(){
$(this).next().click();
});
$('#field_upload').on('change', function(){
var upload_length = $('#field_upload').get(0).files.length;
var resultFileSize = 0;
for(var i = 0; i < upload_length; i++){
resultFileSize = resultFileSize + $('#field_upload').get(0).files[i]['size'];
}
if(resultFileSize >= 16777216){
if($('input[name=envoye_edit]').length > 0)
$('input[name=envoye_edit]').prop('disabled', true);
if($('input[name=envoye]').length > 0)
$('input[name=envoye]').prop('disabled', true);
$('.alertFileSize').removeClass('hidden');
} else {
if($('input[name=envoye_edit]').length > 0)
$('input[name=envoye_edit]').prop('disabled', false);
if($('input[name=envoye]').length > 0)
$('input[name=envoye]').prop('disabled', false);
$('.alertFileSize').addClass('hidden');
}
});
$('#categorie').change(function() {
var id_categorie = $(this).val();
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
$('#sub_categorie').replaceWith(xhr.responseText);
}
};
xhr.open("POST", "create_article_ajax.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("categorie_id="+id_categorie);
});
$('.delete_button_pictures_folder').click(function(){
var contenu = '';
var nom_dossier = $(this).attr('nom_dossier');
contenu += '
';
contenu += 'Voulez vous vraiment supprimer le dossier photo ?
';
contenu += '
';
contenu += '';
contenu += 'ANNULER';
contenu += '
';
contenu += '';
contenu += '
VALIDER';
contenu += '
';
contenu += '
';
$("#myModalDelete .modal-body").empty().append(contenu);
});
$('.delete_button_pictures_one').click(function(){
var contenu = '';
var photo_id = $(this).attr('photo_id');
var page_courante = $(this).attr('page_courante');
contenu += '
';
contenu += 'Voulez vous vraiment supprimer le dossier photo ?
';
contenu += '
';
contenu += '';
contenu += 'ANNULER';
contenu += '
';
contenu += '';
contenu += '
VALIDER';
contenu += '
';
contenu += '
';
$("#myModalDelete .modal-body").empty().append(contenu);
});
$('input[type="text"].customer_search_input').keyup(function(){
search_customer();
});
$('input[type="checkbox"].customer_search_input').click(function(){
$('#customer_newsletter_search').is(':indeterminate')
search_customer();
});
$('#choice_cat_sub_customers').change(function(){
$('#customers_search_engine, div.ajout_customer, div.list_customer').show();
search_customer();
});
$('div.box_accueil strong').click(function(){
var id = $(this).attr('id');
var destination_page = $(this).parent().parent().parent().parent().parent().parent().parent().attr('destination');
show_art_popup(id, destination_page);
});
CKEDITOR.on('instanceReady', function() {
$('.cke_button').each(function() {
$(this).attr('data-toggle', 'tooltip');
$(this).attr('data-original-title', $(this).find('.cke_button_label').text());
$(this).attr('title', $(this).find('.cke_button_label').text());
$('[data-toggle="tooltip"]').tooltip();
});
});
if($('[data-toggle="tooltip"]').length > 0)
$('[data-toggle="tooltip"]').tooltip();
$('.add_line_maj').on('click',function() {
$.ajax({
url : 'manage_menu_ajax.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=create&type=line_maj',
success : function(code_html, statut){ // code_html contient le HTML renvoyé
$('#liste_menu').empty().append(code_html);
}
});
// var html_line_maj = '';
// html_line_maj += '';
});
$('.line_user_extend form').on('submit', function(e){
e.preventDefault();
var $this = $(this);
// Envoi de la requête HTTP en mode asynchrone
$.ajax({
url: $this.attr('action'), // Le nom du fichier indiqué dans le formulaire
type: $this.attr('method'), // La méthode indiquée dans le formulaire (get ou post)
data: $this.serialize(), // Je sérialise les données (j'envoie toutes les valeurs présentes dans le formulaire)
success: function(html) { // Je récupère la réponse du fichier PHP
alert(html); // J'affiche cette réponse
}
});
});
/* UPDATE POSITION MEMBER */
$(".bloc_valid_edit_member #btn_up").on('click', function(e){
// e.preventDefault();
var member_id = $(this).closest('.line_member').find('input[name=member_id]').val();
var other_member_id = $(this).closest('.line_member').prev().find('input[name=member_id]').val();
var actual_position = $(this).closest('.line_member').find('input[name=member_position]').val();
var other_position = $(this).closest('.line_member').prev().find('input[name=member_position]').val();
var direction = 'up';
$.ajax({
url : 'update_team.php',
type : 'POST',
data : 'member_id='+member_id+'&other_member_id='+other_member_id+'&actual_position='+actual_position+'&other_position='+other_position+'&direction='+direction,
success : function(code_html, statut){
document.location.href="team.php"
}
});
return false;
});
$(".bloc_valid_edit_member #btn_down").on('click', function(e){
e.preventDefault();
var member_id = $(this).closest('.line_member').find('input[name=member_id]').val();
var other_member_id = $(this).closest('.line_member').next().find('input[name=member_id]').val();
var actual_position = $(this).closest('.line_member').find('input[name=member_position]').val();
var other_position = $(this).closest('.line_member').next().find('input[name=member_position]').val();
var direction = 'down';
$.ajax({
url : 'update_team.php',
type : 'POST',
data : 'member_id='+member_id+'&other_member_id='+other_member_id+'&actual_position='+actual_position+'&other_position='+other_position+'&direction='+direction,
success : function(code_html, statut){
document.location.href="team.php"
}
});
return false;
});
var timeT = 0;
$('.input_switch').each(function(){
var switchCp = this;
timeT = timeT + 50;
setTimeout(function() {
$(switchCp).bootstrapSwitch('size','mini');
if($(switchCp).hasClass('.switch_adh')){
$(switchCp).bootstrapSwitch('offColor','danger');
$(switchCp).bootstrapSwitch('onColor','success');
$(switchCp).bootstrapSwitch('onText','OUI');
$(switchCp).bootstrapSwitch('offText','NON');
}
}, timeT);
});
// setTimeout(function() {
// $(".input_switch").bootstrapSwitch('size','mini');
// $(".input_switch.switch_adh").bootstrapSwitch('offColor','danger');
// $(".input_switch.switch_adh").bootstrapSwitch('onColor','success');
// $(".input_switch.switch_adh").bootstrapSwitch('onText','OUI');
// $(".input_switch.switch_adh").bootstrapSwitch('offText','NON');
// }, 500);
$('.input_switch.switch_article').on('switchChange.bootstrapSwitch', function(event, state) {
var article_id = $(this).closest('span').attr('article');
var article_statut = ( (state == true) ? 1 : 0 );
// alert(article_id+'-'+article_statut);
$.post('manageOnlineStatutArticle.php', {article_id : article_id, article_statut : article_statut}, function(data){});
});
$('.input_switch.switch_adh').on('switchChange.bootstrapSwitch', function(event, state) {
var adh_id = $(this).closest('span').attr('adh');
var adh_pending = ( (state == true) ? 1 : 0 );
// alert(article_id+'-'+article_statut);
$.post('temp_users_extend.php', {action : 'edit_pending', adh_id : adh_id, adh_pending : adh_pending}, function(data){});
});
$('.user_civilite').on('click', function(){
$('.bloc_civilite').removeClass('active');
$(this).closest('.bloc_civilite').addClass('active');
});
$('.user_statut').on('click', function(){
$('.bloc_statut').removeClass('active');
$(this).closest('.bloc_statut').addClass('active');
});
$('.adh_civilite').on('click change', function(){
$('.bloc_civilite').removeClass('active');
$(this).closest('.bloc_civilite').addClass('active');
});
$('.adh_statut').on('click change', function(){
$('.bloc_statut').removeClass('active');
$(this).closest('.bloc_statut').addClass('active');
});
$('.adh_adhesion').on('click change', function(){
$('.bloc_adhesion').removeClass('active');
$(this).closest('.bloc_adhesion').addClass('active');
});
$('.bloc_civilite, .bloc_statut, .bloc_adhesion').on('click', function(){
$(this).children('input[type=radio]').prop('checked', true).trigger('change');
});
if($('div.pictures_folder a').length > 0){
var height_link = 0;
$('div.pictures_folder a').each(function(){
if($(this).outerHeight() > height_link)
height_link = $(this).outerHeight();
});
$('div.pictures_folder a').css('height', height_link+'px');
$(window).on('resize', function(){
var height_link = 0;
$('div.pictures_folder a').each(function(){
if($(this).outerHeight() > height_link)
height_link = $(this).outerHeight();
});
$('div.pictures_folder a').css('height', height_link+'px');
});
}
if($('#pdfView').length > 0){
var pdf = $('#pdfView').attr('chemin');
PDFObject.embed(pdf, "#pdfView");
}
$('.display_help_resize').on('click', function() {
var element = $(this);
setTimeout(() => {
element.next().css("height",element.next().find("video").height()+"px")
}, 200);
});
if($('#tabMails').length > 0){
$('#tabMails a').click(function (e) {
e.preventDefault()
$(this).tab('show')
});
}
if($('#accordion').length > 0){
$( "#accordion" ).accordion();
}
function uploadajax(ttl,cl, real_name, sub_cat, microtime, action){
var fileList = $('#multiupload').prop("files");
$('#prog'+cl).removeClass('loading-prep').addClass('upload-image');
var form_data = "";
form_data = new FormData();
form_data.append("upload_image", fileList[cl]);
form_data.append("real_name", real_name);
form_data.append("sub_cat", sub_cat);
form_data.append("microtime", microtime);
form_data.append("action", action);
var request = $.ajax({
url: "upload.php",
cache: false,
contentType: false,
processData: false,
async: true,
data: form_data,
type: 'POST',
xhr: function() {
var xhr = $.ajaxSettings.xhr();
if(xhr.upload){
xhr.upload.addEventListener('progress', function(event){
var percent = 0;
if (event.lengthComputable) {
percent = Math.ceil(event.loaded / event.total * 100);
}
$('#prog'+cl).text(percent+'%')
}, false);
}
return xhr;
},
success: function (res, status) {
if (status == 'success') {
percent = 0;
$('#prog' + cl).text('');
$('#prog' + cl).text('--Success: ');
if (cl < ttl) {
uploadajax(ttl, cl + 1, real_name, sub_cat, microtime, action);
} else {
$('#upcvr').after('Toutes vos photos ont été envoyées.
Actualiser la page ');
}
}
},
fail: function (res) {
alert('Failed');
}
})
}
$('#upcvr').click(function(){
var real_name = $('#dossier_photo').val();
var sub_cat = $('#sub_categorie').val();
var microtime = Date.now();
var action = $('#action').val();
var fileList = $('#multiupload').prop("files");
$('#uploadsts').html('');
var i;
for ( i = 0; i < fileList.length; i++) {
$('#uploadsts').append(''+fileList[i].name+'
');
if(i == fileList.length-1){
uploadajax(fileList.length-1,0, real_name, sub_cat, microtime, action);
}
}
});
});
function manage_panel_adh(bloc_id){
$('.adh_bloc').removeClass('active');
$('#'+bloc_id).addClass('active');
$('.adh_menu').removeClass('active');
$('.adh_menu.'+bloc_id).addClass('active');
}
function manageOnlineStatut(id){
alert(id);
}
//Permet de visualiser les articles, news, evenements, books ou produit dans une popup
function show_art_popup(id, destination_page){
var chemin = window.location.pathname;
var destination = '';
var art_id = id;
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
if(chemin.indexOf('articles.php') != -1)
destination = "articles";
if(chemin.indexOf('articles_pdf.php') != -1)
destination = "articles_pdf";
if(chemin.indexOf('news.php') != -1)
destination = "news";
if(chemin.indexOf('evenements.php') != -1)
destination = "evenements";
if(destination_page != '')
destination = destination_page;
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
$("#myModal .modal-body").empty().append(xhr.responseText);
setTimeout(function() {
if($("#myModal .modal-body #pdfView").length > 0){
var pdf = $("#myModal .modal-body #pdfView").attr('chemin');
// alert(pdf);
PDFObject.embed(pdf, "#pdfView");
}
}, 1500);
}
};
xhr.open("POST", "temp.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("id_cible="+art_id+"&page="+destination);
}
$.fn.sameHeights = function(childrenSelector) {
$(this).each(function(){
var tallest = 0;
$(this).children(childrenSelector).each(function(i){
if (tallest < $(this).height()) { tallest = $(this).height(); }
});
$(this).children(childrenSelector).css({'height': tallest});
});
return this;
};
// Fonction en charge d'appeler l'action de lete de la sous catégorie
function delete_sub_cat(id){
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
$(".sub_cat_list").empty().append(xhr.responseText);
}
};
xhr.open("POST", "delete_sub_cat.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("categorie_id="+id);
}
function make_old(id){
console.log(id);
$.post('stateMails.php', {email_id : id}, function(data) {
$('.unread_mail[email_id="'+id+'"]').remove();
window.location.reload();
});
}
function delete_mail(id){
$.post('delete_mail.php', {email_id : id}, function(data) {
$('.read_mail[email_id="'+id+'"]').remove();
window.location.reload();
});
}
function edit_sub_cat(id){
var sub_cat_description = $('li.sub_cat_li[sub_cat_id="'+id+'"] input.sub_cat_name').val();
$.ajax({
url : 'update_sub_cat.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=update&sub_cat_id='+id+'&title_sub_cat='+sub_cat_description,
success : function(code_html, statut){ // code_html contient le HTML renvoyé
}
});
}
//Ajouter un utilisateur dans la base de donnée
function add_customer()
{
var customer_firstname = $('#customer_firstname').val();
var customer_lastname = $('#customer_lastname').val();
var customer_email = $('#customer_email').val();
if($('#customer_newsletter').is(':checked'))
var customer_newsletter = true;
else
var customer_newsletter = false;
if($('#customer_accept_contact').is(':checked'))
var customer_accept_contact = true;
else
var customer_accept_contact = false;
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
show_customers();
$('#add_customer_form input[type="text"]').val('');
}
};
xhr.open("POST", "create_customer.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("customer_firstname="+customer_firstname+"&customer_lastname="+customer_lastname+"&customer_email="+customer_email+"&customer_newsletter="+customer_newsletter+"&customer_accept_contact="+customer_accept_contact);
}
function show_customers(){
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
$('#list_customer_by_site').empty().append(xhr.responseText);
}
};
xhr.open("POST", "search_customers.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("action=action");
};
//Fonction de gestion de l'xhr pour l'ajax
function getXMLHttpRequest() {
var xhr = null;
if (window.XMLHttpRequest || window.ActiveXObject) {
if (window.ActiveXObject) {
try {
xhr = new ActiveXObject("Msxml2.XMLHTTP");
} catch(e) {
xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
} else {
xhr = new XMLHttpRequest();
}
} else {
alert("Votre navigateur ne supporte pas l'objet XMLHTTPRequest...");
return null;
}
return xhr;
}
function search_customer(){
// var chemin = $(this).attr('id');
var customer_firstname_search = $('#customer_firstname_search').val();
var customer_lastname_search = $('#customer_lastname_search').val();
var customer_email_search = $('#customer_email_search').val();
if($('#customer_newsletter_search').is(':checked') || $('#customer_newsletter_search').is(':indeterminate')){
if($('#customer_newsletter_search').is(':checked'))
var customer_newsletter_search = true;
if($('#customer_newsletter_search').is(':indeterminate'))
var customer_newsletter_search = false;
} else {
var customer_newsletter_search = '';
}
if($('#customer_contact_search').is(':checked') || $('#customer_contact_search').is(':indeterminate')){
if($('#customer_contact_search').is(':checked'))
var customer_contact_search = true;
if($('#customer_contact_search').is(':indeterminate'))
var customer_contact_search = false;
} else {
var customer_contact_search = '';
}
// var destination = '';
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
$("#list_customer_by_site").empty().append(xhr.responseText);
}
};
xhr.open("POST", "search_customers.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("customer_firstname_search="+customer_firstname_search+"&customer_lastname_search="+customer_lastname_search+"&customer_email_search="+customer_email_search+"&customer_newsletter_search="+customer_newsletter_search+"&customer_contact_search="+customer_contact_search);
}
function update_customer(id, action, value)
{
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
var site_id = $('#choice_cat_sub_customers').val();
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
// alert(xhr.responseText); // Données textuelles récupérées
search_customer()
}
};
xhr.open("POST", "update_customer.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("customer_id="+id+"&action="+action+"&value="+value);
}
function delete_customer_popup(id)
{
var contenu = '';
contenu += '
';
contenu += 'Voulez vous vraiment supprimer cet utilisateur ?
';
contenu += '
';
contenu += '';
contenu += 'ANNULER';
contenu += '
';
contenu += '';
contenu += 'VALIDER';
contenu += '
';
contenu += '
';
$("#myModalDelete .modal-body").empty().append(contenu);
}
function delete_customer(id)
{
var xhr = getXMLHttpRequest(); // Voyez la fonction getXMLHttpRequest() définie dans la partie précédente
xhr.onreadystatechange = function() {
if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) {
$('#myModalDelete').modal('hide');
search_customer();
}
};
xhr.open("POST", "delete_customer.php", true);
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xhr.send("customer_id="+id);
}
function load_demandes_rdv()
{
$.ajax({
url : 'manage_rdv.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=manage',
success : function(code_html, statut){ // code_html contient le HTML renvoyé
$('#list_demande_rdv').empty().append(code_html);
if($( "#datepicker" ).length > 0){
$( "#datepicker" ).datepicker({ dateFormat: 'yy-mm-dd' });
}
}
});
}
function create_demandes_rdv(id, nom, prenom)
{
var prenom = prenom;
var nom = nom;
var heure_debut = $("#"+id+" #heure_debut_rdv").val();
var heure_fin = $("#"+id+" #heure_fin_rdv").val();
var date = $("#"+id+" #datepicker").val();
heure_debut = date+'T'+heure_debut+':00-05:00';
heure_fin = date+'T'+heure_fin+':00-05:00';
$.ajax({
url : 'manage_rdv.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=create&id='+id+'&prenom='+prenom+'&nom='+nom+'&heure_debut='+heure_debut+'&heure_fin='+heure_fin,
success : function(code_html, statut){ // code_html contient le HTML renvoyé
window.location.reload();
}
});
}
function add_first_level(id){
$.ajax({
url : 'manage_menu_ajax.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=create&type=line_first_level&parent_id='+$(id).attr('id'),
success : function(code_html, statut){ // code_html contient le HTML renvoyé
$('#liste_menu').empty().append(code_html);
}
});
}
function add_second_level(id){
$.ajax({
url : 'manage_menu_ajax.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=create&type=line_second_level&parent_id='+$(id).attr('id'),
success : function(code_html, statut){ // code_html contient le HTML renvoyé
$('#liste_menu').empty().append(code_html);
}
});
}
function delete_line_menu(id, parent){
$.ajax({
url : 'manage_menu_ajax.php',
type : 'POST', // Le type de la requête HTTP, ici devenu POST
data : 'action=delete&menu_id='+id+'&parent_id='+parent.id,
success : function(code_html, statut){ // code_html contient le HTML renvoyé
if(code_html.indexOf('