var particulier = true; var instantie = false; $(document).on('click','#adverteer_cancel','data',function(){ wl_alert('confirm','Weet u zeker dat u wilt cancellen?',cancel_add); }) function cancel_add(){ location.href='?cancelled'; } $(document).on('click','#adverteer_payment','data',function(){ var aantal = 1; var price = 4.5; var entryID = $('#entryID').val(); if(aantal>0){ $('#loading').show(400); $.ajax({ url: "/process_ajax.php", type: "POST", data: {task:'prepare_payment',aantal:aantal,unit_price:price,entryID:entryID}, cache: false, async: true, timeout: 15000, dataType: 'json', success: function (p) { //var ems = JSON.parse(html); //console.log(html); for (var key in p) { if (p.hasOwnProperty(key)) { console.log(key + " -> " + p[key]); $("").attr("type", "hidden") .attr("name", key) .attr("value", p[key]) .appendTo("#payment_form"); } } $('#payment_form').submit(); }, error: function(xhr, textStatus, errorThrown){ $('#loading').hide(400); //alert('Verzenden mislukt, probeer het later nog eens. ('+errorThrown+')'); var txt = 'Verzenden mislukt, probeer het later nog eens. ('+errorThrown+')'; wl_alert('alert',txt,false,false,'OK'); }, complete: function(){ $('.loading').hide(); } }); }else{ wl_alert('alert','Aantal credits moet ingevuld zijn en groter dan 0'); } }); $(document).on('click','.instantie_a','data',function(){ console.log($(this).data('showhide')); if ($(this).hasClass('instantie_a_active')){ return false; } if($(this).data('showhide')=='particulier'){ //$('#particulier_bx').show(400); particulier = true; instantie = false; $('#idvoornaam').attr('placeholder','Naam'); $('.idvoornaam').text('Naam'); $('#instantie_bx').hide(400); $('#show_add').show(400); $('#adverteer').hide(); $('.adver_akkoord').hide(); $('.upload_label').hide(); $('.particulier_upload_label').show(); if ($('#show_add').hasClass('show_add_active')){ $('.upload_form').show(); }else{ $('.upload_form').hide(); } }else{ particulier = false; instantie = true; $('#idvoornaam').attr('placeholder','Contactpersoon'); $('.idvoornaam').text('Contactpersoon (wordt niet vermeld op website)'); //$('#particulier_bx').hide(400); $('#instantie_bx').show(400); $('#show_add').hide(400).removeClass('show_add_active'); $('#adverteer').show(400); $('.adver_akkoord').show(400); $('.add_row').hide(400); $('.upload_label').hide(); $('.instantie_upload_label').show(); window.setTimeout(function(){ $('.upload_form').show(); }, 450); } $('.instantie_a').removeClass('instantie_a_active') $(this).addClass('instantie_a_active'); }); var add_row_toggled_on = true; $(document).on('click','#show_add','data',function(){ var deze = $(this); $('.add_row').toggle(400); if (add_row_toggled_on){ deze.addClass('show_add_active'); window.setTimeout(function(){ $('.add_row').css('display','flex'); }, 450); add_row_toggled_on = false; }else{ deze.removeClass('show_add_active'); add_row_toggled_on = true; } $('#adverteer').toggle(); $('.adver_akkoord').toggle(); }); $(document).on('click','#adverteer_credit','data',function(){ var aantal = -1; var entryID = $('#entryID').val()*1; // if(aantal>0){ $('#loading').show(400); $.ajax({ url: "/process_ajax.php", type: "POST", data: {task:'gebruik_credit',aantal:aantal,entryID:entryID}, cache: false, async: true, timeout: 15000, // dataType: 'json', success: function (html) { $('#adverteren_form').html(html); location.href='?account=1&message='+html; }, error: function(xhr, textStatus, errorThrown){ $('#loading').hide(400); //alert('Verzenden mislukt, probeer het later nog eens. ('+errorThrown+')'); var txt = 'Verzenden mislukt, probeer het later nog eens. ('+errorThrown+')'; wl_alert('alert',txt,false,false,'OK'); }, complete: function(){ $('.loading').hide(); } }); // }else{ // wl_alert('alert','Aantal credits moet ingevuld zijn en groter dan 0'); // } }) $(document).on('change','.adverdata','data',function(){ $(this).removeClass('errorfield'); }); $(document).on('click','#adverteer','data',function(){ //alert('hier'); var error = ''; $('.adverdata').each(function(){ var dit = $(this); val=dit.val(); name=dit.attr("name"); id=dit.attr("id"); required=dit.attr("required"); //console.log(instantie,particulier); if(instantie && (dit.hasClass('required_instantie'))){ // if($(this).val().trim()==''){ // error +=name+' is een verplicht veld
'; // } /////////error = notEmpty_required(id, error); error += notEmpty_required_new(id); } if(particulier && (dit.hasClass('required_particulier') || required)){ // if($(this).val().trim()==''){ // error +=name+' is een verplicht veld
'; // } //////////error = notEmpty_required(id, error); if (dit.is(':visible')){ error += notEmpty_required_new(id); } } //if(required)error = notEmpty_required(id, error); }); if (!$('#akkoord_voorwaarden').is(":checked") && $('#akkoord_voorwaarden').is(":visible")){ error += "
  • Akkoord met de algemene voorwaarden
  • "; } //if(leeftijd=='0')error = "Vul alstublieft een valide leeftijd in
    "+error; if (error!=''){ error="

    Nog in te vullen:

    "; $('.alert_txt_content').addClass('error_message'); wl_alert("alert",error); if ($('#leeftijd').hasClass('errorfield')){ $('#jaarbx').closest('.formfield').addClass('is-invalid'); $('#maandbx').closest('.formfield').addClass('is-invalid'); } return false; }else{ $('.alert_txt_content').removeClass('error_message'); var adverdata = new Object(); $('.adverdata').each(function(){ var deze = $(this); var val= deze.val() adverdata[$(this).attr("name")]=val; // console.log(id); // console.log(adverdata); }); fetchAjaxAd('advertenties', 'adverteer', adverdata); } }); function fetchAjaxAd(classI,taskI, moduleI){ // var fd = new FormData(); // var files = $('#file')[0].files[0]; // fd.append('file',files); $.ajax({ url:http_path+'/process_ajax.php', type: 'POST', timeout : '60000', data: {classO:classI,task:taskI,module:moduleI}, cache: false, success: function (html, response) { $('.button_s').addClass('ajax_succes'); console.log(response); console.log(moduleI); if(taskI=='unique'){ if(html=='ERROR'){ $('.alert_txt_content').addClass('error_message'); $('#idgebruikersnaam').addClass('errorfield'); wl_alert('alert', 'Deze gebruikersnaam is niet beschikbaar, kies een andere gebruikersnaam (Tip: U kan ook uw e-mailadres als gebruikersnaam invullen)!'); }else{ registerData=fetchAttributes(); fetchAjax('lid', 'register', registerData); document.getElementById("registerform").reset(); } }else{ if (html.substring(0,5)=="Error") { wl_alert("alert",html); }else if(html.substring(0,4)=="http"){ location.href=html; }else{ $('#adverteren_form').html(html); $('#adverteren_form').velocity("scroll", { duration: 500, offset: -72, easing: "easeOutQuart" }); } } }, error: function(jqXHR, exception){ console.log('jqXHR',jqXHR); console.log('exception',exception); $('.button_s').addClass('ajax_fail'); $('.button_s').val(moduleI); wl_alert('alert', 'Check uw Internet connectie of probeer het later opnieuw!', '', '', 'Ok', '', ''); } }); } $(document).on('click','.edit_entry_baasje','',function(){ console.log('in adverteren js edit entry'); var entryID = $(this).data('entryid'); var iframe_url = '/cbox-front.php?CBID=entryID&classCB=advertenties&taskCB=build_edit_entry_block&betalen=0&entryID='+entryID; show_wl_iframe(iframe_url,'',close_clickobject=''); }); function refresh_add(entryID){ console.log('in de refresh_add functie'); var func_attributes = new Array(); func_attributes[0]=entryID; $.ajax({ url: '/process_ajax.php', type: 'POST', data: {class:'advertenties',task:'build_entry_block',attributes:func_attributes}, cache: false, async: true, success: function (html) { $('#adverteren_form').html(html); }, complete: function(){ }, error: function(){ wl_alert('alert', 'Check uw Internet connectie of probeer het later opnieuw!', '', '', 'Ok', '', ''); } }) }