$(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($('.count-box').length > 0){ $('.count-box').each(function(){ $(this).CountUpCircle({ duration: 500 }); }); /* $('.count-box').each(function(){ var width = $(this).closest('li').width(); var height = width; var line_height = height; $(this).css('width',width+'px'); $(this).css('height',height+'px'); $(this).css('line-height',height+'px'); $(window).on('resize', function(){ var width = $(this).closest('li').width(); var height = width; var line_height = height; $(this).css('width',width+'px'); $(this).css('height',height+'px'); $(this).css('line-height',height+'px'); }); }); */ } 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'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(); //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()); $.post('get_select_sub_cat.php', {product_category : $(this).val()}, function(data) { $('#sub_categorie').replaceWith(data); }); 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(); } else if($(this).val() == 3){ $('#product_image, #product_name, #product_number, #product_auteur, #product_editeur, #product_qte, #product_buy_price, #product_sell_price').show(); } else if($(this).val() == 4){ $('#product_image, #product_name, #product_qte, #product_auteur, #product_editeur, #product_buy_price, #product_sell_price, #product_number').show(); } else if($(this).val() == 5){ $('#product_image, #product_name, #product_qte, #product_taille_poids, #product_buy_price, #product_sell_price, #product_number').show(); }else if($(this).val() == 6){ $('#product_image, #product_name, #product_qte, #product_conditionnement, #product_taille_poids, #product_buy_price, #product_sell_price, #product_number').show(); } else if($(this).val() == 8){ $('#product_image, #product_name, #product_qte, #product_auteur, #product_editeur, #product_buy_price, #product_number, #product_sell_price').show(); }else if($(this).val() == 9){ $('#product_image, #product_name, #product_qte, #product_taille_poids, #product_buy_price, #product_sell_price, #product_number').show(); } } if(chemin.indexOf('action=manage')) { $('.search_product_input[id!=product_type]').val('').hide(); if($(this).val() == 1){ $('#search_product_name, #search_product_number, #search_product_auteur, #search_product_editeur, #search_product_qte, #search_product_buy_price, #search_product_sell_price').show(); } else if($(this).val() == 2){ $('#search_product_name, #search_product_etat, #search_product_qte, #search_product_price').show(); } else if($(this).val() == 3){ $('#search_product_name, #search_product_number, #search_product_auteur, #search_product_editeur, #search_product_qte, #search_product_buy_price, #search_product_sell_price').show(); } else if($(this).val() == 4){ $('#search_product_name, #search_product_qte, #search_product_auteur, #search_product_editeur, #search_product_buy_price, #search_product_number').show(); } else if($(this).val() == 5){ $('#search_product_name, #search_product_qte, #search_product_taille_poids, #search_product_buy_price, #search_product_number').show(); } else if($(this).val() == 6){ $('#search_product_name, #search_product_qte, #search_product_taille_poids, #search_product_buy_price, #search_product_number').show(); } else if($(this).val() == 8){ $('#search_product_name, #search_product_qte, #search_product_auteur, #search_product_editeur, #search_product_buy_price, #search_product_number').show(); } else if($(this).val() == 9){ $('#search_product_name, #search_product_qte, #search_product_taille_poids, #search_product_buy_price, #search_product_number').show(); } // 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() { $('#search_button').click(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 = ''; $.ajax({ url : 'search_products.php', async: false, type : 'POST', // Le type de la requête HTTP, ici devenu POST data : "product_type="+product_type+"&product_name="+product_name+"&product_number="+product_number+"&product_qte="+product_qte+"&product_auteur="+product_auteur+"&product_editeur="+product_editeur, success : function(code_html, statut){ // code_html contient le HTML renvoyé $("ul.manage_list").empty().append(code_html); } }); /* 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() { 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(); $.ajax({ url : 'search_products.php', async: false, type : 'POST', // Le type de la requête HTTP, ici devenu POST data : "product_type="+product_type+"&product_name="+product_name+"&product_number="+product_number+"&product_qte="+product_qte+"&product_auteur="+product_auteur+"&product_editeur="+product_editeur, success : function(code_html, statut){ // code_html contient le HTML renvoyé $("ul.manage_list").empty().append(code_html); } }); }); */ //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 d'afficher la liste des sous catégories correspondantes à tel ou tel site $('#choice_cat_sub').change(function() { var 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_cat_list").empty().append(xhr.responseText); } }; xhr.open("POST", "search_sub_cat.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("categorie="+categorie); if($(this).val() != ''){ $('.add_sub_cat_bloc, .sub_cat_list').show(); } else { $('.add_sub_cat_bloc, .sub_cat_list').hide().val(''); $('#site_cible').val(''); } if($(this).val() == 1){ $('.pictures_form.add_sub_cat_bloc').removeClass('col-lg-6 col-md-6 col-sm-6').css('padding-left','0').css('padding-right','0'); $('#product_type').show(); $('.tri_products').removeClass('hidden'); } else { $('.pictures_form.add_sub_cat_bloc').addClass('col-lg-6 col-md-6 col-sm-6'); $('#product_type').hide().val(''); $('.tri_products').addClass('hidden'); } }); //Permet l'ajout d'une sous catégorie à la liste de sous catégorie du site choisit $('#submit_sub_cat_btn').click(function() { var site_cible = $('#choice_cat_sub').val(); var categorie_name = $('#categorie_name').val(); var product_category = $('#product_type').val() if($('#choice_cat_sub').val() != '1'){ product_category = null; } alert(site_cible); alert(categorie_name); alert(product_category); if( categorie_name != '' && ( site_cible != '' && site_cible != 'Choisir le site')) { 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)) { $('#categorie_name').val(''); $('#product_type').val(''); $('#choice_cat_sub').trigger('change'); } }; xhr.open("POST", "create_sub_cat.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("site_cible="+site_cible+"&categorie_name="+categorie_name+"&product_category="+product_category); } }); $('#img_input').click(function(){ $('#couverture_recto').click(); }); $('#cloud_upload').click(function(){ $('#field_upload').click(); }); $('.cloud_upload').click(function(){ $(this).next().click(); }); $('#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(); if($('#product_categorie_search').length > 0){ var product_session_cat = $('#product_categorie_search').val(); if(product_session_cat != ''){ $('#product_type').val(product_session_cat).trigger('change'); } } //log emails controles $('table.list_mails tr').on('click', function() { var email_id = $(this).attr('email_id'); if($('.emails_contenu[email_id='+email_id+']').hasClass('hidden')) $('.emails_contenu[email_id='+email_id+']').removeClass('hidden') else $('.emails_contenu[email_id='+email_id+']').addClass('hidden') }); $('table.list_mails tr.unread').on('click', function() { $.post('stateMails.php', {email_id : $(this).attr('email_id')}, function(data) { }); }); if($('#tabMails').length > 0){ $('#tabMails a').click(function (e) { e.preventDefault() $(this).tab('show') }); } /* // alert('r'); $('#valid_newsletters').on('click', function(e) { e.preventDefault(); var array_test = []; var i = 0; $(this).closest('form').find('input, textarea').each(function(){ array_test[$(this).attr('name')] = $(this).val(); }); console.log(array_test); $.post('saveNewsletter.php', {datas : array_test}, function(data) { }); }); */ $('.tri_products #product_type').on('change', function(){ var pCat = $(this).val(); $('li.li_cat[pc!="'+pCat+'"]').hide(); $('li.li_cat[pc="'+pCat+'"]').show(); if(pCat == '') $('li.li_cat').show(); }); $('.partner_boxe .img_cont').each(function(){ var w = $(this).outerWidth(); var h = w+'px'; $(this).css('height', h); }); $(window).on('resize', function() { $('.partner_boxe .img_cont').each(function(){ var w = $(this).outerWidth(); var h = w+'px'; $(this).css('height', h); }); }); }); //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('news.php') != -1) destination = "news"; if(chemin.indexOf('evenements.php') != -1) destination = "evenements"; if(chemin.indexOf('books.php') != -1) destination = "books"; if(chemin.indexOf('products.php') != -1) destination = "products"; if(destination_page != '') destination = destination_page; xhr.onreadystatechange = function() { if (xhr.readyState == 4 && (xhr.status == 200 || xhr.status == 0)) { // alert(xhr.responseText); // Données textuelles récupérées // console.log(xhr.responseText); $("#myModal .modal-body").empty().append(xhr.responseText); } }; 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)) { $('#choice_cat_sub').trigger('change'); } }; xhr.open("POST", "delete_sub_cat.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("categorie_id="+id); } function delete_mail(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)) { $('.delete_mail[id='+id+']').parent().parent().next().remove(); $('.delete_mail[id='+id+']').parent().parent().remove(); } }; xhr.open("POST", "delete_mail.php", true); xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xhr.send("email_id="+id); } //Ajouter un utilisateur dans la base de donnée function add_customer(){ var site_id = $('#choice_cat_sub_customers').val(); 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+"&site_id="+site_id); } 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 site_id = $('#choice_cat_sub_customers').val(); 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+"&site_id="+site_id); } 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 $("#choice_cat_sub_customers").trigger('change'); } }; 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'); $("#choice_cat_sub_customers").trigger('change'); } }; 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 delete_entry(id){ var art_link = 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('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); }); } function check_quantity(product_id){ if($('.manage_list li[product_id='+product_id+'] input[name=product_qte]').val() == 0){ $('.manage_list li[product_id='+product_id+'] input[name=product_qte]').parent().parent().parent().addClass('bg-danger'); } else { $('.manage_list li[product_id='+product_id+'] input[name=product_qte]').parent().parent().parent().removeClass('bg-danger'); } } function quantity_list_modify(product_id){ var line_id = product_id; // var cible = '.manage_list li[product_id='+line_id+'] input[name=product_qte]'; var update_qte = ''; var product_id = ''; if($('.manage_list li[product_id='+line_id+'] input[name=product_qte]').val() != ''){ product_id = $('.manage_list li[product_id='+line_id+'] input[name=product_qte]').parent().parent().parent().attr('product_id'); update_qte = $('.manage_list li[product_id='+line_id+'] input[name=product_qte]').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é } }); } function buy_price_list_modify(product_id){ var line_id = product_id; var update_buy_price = ''; var product_id = ''; if($('.manage_list li[product_id='+line_id+'] input[name=product_buy_price]').val() != ''){ product_id = $('.manage_list li[product_id='+line_id+'] input[name=product_buy_price]').parent().parent().parent().attr('product_id'); update_buy_price = $('.manage_list li[product_id='+line_id+'] input[name=product_buy_price]').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é } }); } function sell_price_list_modify(product_id){ var line_id = product_id; var update_sell_price = ''; var product_id = ''; if($('.manage_list li[product_id='+line_id+'] input[name=product_sell_price]').val() != ''){ product_id = $('.manage_list li[product_id='+line_id+'] input[name=product_sell_price]').parent().parent().parent().attr('product_id'); update_sell_price = $('.manage_list li[product_id='+line_id+'] input[name=product_sell_price]').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é } }); } function update_sub_cat(id){ var sub_cat_id = id; var title_sub_cat = $('#valid_'+id).parent().prev().find('input').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='+sub_cat_id+'&title_sub_cat='+title_sub_cat, success : function(code_html, statut){ // code_html contient le HTML renvoyé } }); } function accept_command(command_id){ $('tr[command-id='+command_id+']').remove(); $.post('commandes_temp.php', { command_id: command_id, action : 'accept' }, function(data) { window.location.reload(); }); } function deny_command(command_id){ $('tr[command-id='+command_id+']').remove(); $.post('commandes_temp.php', { command_id: command_id, action : 'deny' }, function(data) { window.location.reload(); }); } function honor_command(command_id){ $('tr[command-id='+command_id+']').remove(); $.post('commandes_temp.php', { command_id: command_id, action : 'honor' }, function(data) { window.location.reload(); }); }