var currency = localStorage.getItem('wl_valuta'); var valutas = {"1":{"valutaID":"1","valuta":"SRD","administratie_koers":"1.000000","douane_koers":"1.000000","inkoop_koers":"1.000000","active":"1"},"2":{"valutaID":"2","valuta":"USD","administratie_koers":"30.000000","douane_koers":"29.500000","inkoop_koers":"30.000000","active":"1"},"3":{"valutaID":"3","valuta":"EUR","administratie_koers":"27.500000","douane_koers":"23.500000","inkoop_koers":"25.500000","active":"1"}}; var bezorgkosten_prijs = 50; var bezorgkosten_product_id = 999999999999999; var bezorgkosten_name = '9999999999999999'; //stop items in de local storage na klikken op de knop $(document).on('click','.diensten_inner_image','data',function(){ //clear_wl_shop_items_from_local_storage(); }); $(document).on('click','.wl_shop_remove_row','data',function(){ var deze = $(this); wl_shop_ask_to_delete(deze); }); function wl_shop_hoe_product_toevoegen(deze){ //var vorige = deze.prev(); //var aantal = vorige.val(); var deze_entry_id = deze.data('entry_id'); var vorige = deze.closest('.wl_shop_productpage').find('#wl_shop_id_'+deze_entry_id); var aantal = vorige.val(); wl_alert('confirm', 'Wil u '+aantal+' stuks optellen bij het product in de winkelmand? Of wil u het product als extra regel toevoegen in de winkelmand?',wl_shop_product_optellen,product_als_nieuwe_regel_toevoegen,'Optellen','Nieuwe regel',deze); } function wl_shop_product_optellen(deze){ // var vorige = deze.prev(); // var aantal = vorige.val(); var deze_entry_id = deze.data('entry_id'); var vorige = deze.closest('.wl_shop_productpage').find('#wl_shop_id_'+deze_entry_id); var aantal = vorige.val(); aantal = aantal * 1; var deze_artikelid = deze.data('artikelid'); var retrieved_array_optellen = JSON.parse(localStorage.getItem("wl_shop_"+deze_entry_id)); var aantal_in_storage = retrieved_array_optellen.aantal; aantal_in_storage = aantal_in_storage * 1; nieuw_aantal = aantal_in_storage + aantal; // $('.wl_shop_row_'+deze_artikelid).remove(); add_product_to_winkelmand(deze, nieuw_aantal); } $(document).on('click','.wl_bestel_product','data',function(){ wl_shop_count_items = 0; var deze = $(this); //var vorige = deze.prev(); //var aantal = vorige.val(); process_info_from_product(deze); }); function process_info_from_product(deze,aantal,timestamp,timestamp_group,kaartje_tekst){ var deze_entry_id = deze.data('entry_id'); var vorige = deze.closest('.wl_shop_productpage').find('#wl_shop_id_'+deze_entry_id); // var deze_artikelid = deze.data('artikelid'); if (aantal == null){ aantal = vorige.val(); } aantal = aantal * 1; //alert(aantal); if (aantal == '' || aantal == 0){ var html = 'Vul eerst een aantal in'; vorige.velocity("callout.shake"); wl_alert('alert', html,false,false,'Ok',''); return false; } if (localStorage.getItem("wl_shop_"+deze_entry_id) === null) { add_product_to_winkelmand(deze,aantal,null,timestamp,timestamp_group,kaartje_tekst); }else{ //alert('bestaat al'); //wl_alert('confirm', 'Product komt al voor in de winkelmand, toch toevoegen?',wl_shop_hoe_product_toevoegen,false,'Ja','Nee',deze); ////// wl_shop_product_optellen(deze); var nw_count_items = 1; product_als_nieuwe_regel_toevoegen(deze,aantal,timestamp,timestamp_group,kaartje_tekst,nw_count_items) } } function product_als_nieuwe_regel_toevoegen(deze,aantal,timestamp,timestamp_group,kaartje_tekst,nw_count_items){ //var vorige = deze.prev(); //var aantal = vorige.val(); var deze_entry_id = deze.data('entry_id'); var vorige = deze.closest('.wl_shop_productpage').find('#wl_shop_id_'+deze_entry_id); // var aantal = vorige.val(); aantal = aantal * 1; var deze_artikelid = deze.data('artikelid'); // wl_shop_count_items = (wl_shop_count_items + 1) *1; wl_shop_count_items = nw_count_items * 1; if (localStorage.getItem('wl_shop_'+deze_entry_id+'_'+nw_count_items) === null) { $('.wl_shop_row').remove(); add_product_to_winkelmand(deze, aantal, wl_shop_count_items,timestamp,timestamp_group,kaartje_tekst); }else{ //alert('bestaat al: wl_shop_'+deze_artikelid+'_'+wl_shop_count_items); nw_count_items ++ product_als_nieuwe_regel_toevoegen(deze,aantal,timestamp,timestamp_group,kaartje_tekst,nw_count_items); } } function add_product_to_winkelmand(deze, nieuw_aantal, count_items,timestamp,timestamp_group,kaartje_tekst){ //var vorige = deze.prev(); //var aantal = vorige.val(); var deze_entry_id = deze.data('entry_id'); var vorige = deze.closest('.wl_shop_productpage').find('#wl_shop_id_'+deze_entry_id); var aantal = vorige.val(); if (nieuw_aantal != null && nieuw_aantal != false ){ aantal = nieuw_aantal; } aantal = aantal * 1; var origineel_aantal = aantal; //var deze_opmerking = $('#wl_shop_opmerking_'+deze_entry_id).val(); var deze_opmerking = ''; var opmerking_el = deze.closest('.wl_shop_productpage_wrapper').find('#wl_shop_opmerking_'+deze_entry_id); if (opmerking_el.length){ deze_opmerking = opmerking_el.val(); } // alert(kaartje_tekst); // return false; ///zet tekst voor kaartje erin if (kaartje_tekst != null && kaartje_tekst != false ){ deze_opmerking = kaartje_tekst; } var deze_product = deze.data('product'); //var deze_prijs = deze.data('prijs'); ///////var deze_prijs = deze.data('prijs_'+current_valuta); var deze_prijs = deze.data('prijs'); var deze_artikelid = deze.data('artikelid'); var deze_image = deze.data('wl_image'); var deze_href = deze.data('wl_href'); var artikel_id_identifier = '0'; if (count_items != null){ artikel_id_identifier = deze_entry_id+"_"+count_items; //alert('deze_artikelid= '+deze_artikelid) } //var array = [deze_artikelid,deze_product,aantal,deze_prijs,deze_image,deze_href,artikel_id_identifier,deze_opmerking,deze_entry_id,timestamp]; /* var array = ['\'artikel\':\''+deze_artikelid+'\ ','\'product\':\''+deze_product+'"','"aantal":"'+aantal,'"prijs":"'+deze_prijs+'"','"image":"'+deze_image+'"','"href":"'+deze_href+'"','"artikeid":"'+artikel_id_identifier+'"','"opmerking":"'+deze_opmerking+'"','"entryid":"'+deze_entry_id+"'",'"timestamp":"'+timestamp+'"']; */ //alert(timestamp); // if (timestamp != null && timestamp != false ){ if (timestamp == null || timestamp == false ){ var d=new Date(); timestamp = d.getTime(); } if (timestamp_group == null || timestamp_group == false ){ timestamp_group = 0; }else{ // timestamp_group = timestamp; } var array = {'artikelid':deze_artikelid,'product':deze_product,'aantal':aantal,'prijs':deze_prijs,'image':deze_image,'href':deze_href,'artikel_identifier':artikel_id_identifier,'opmerking':deze_opmerking,'productID':deze_entry_id,'timestamp':timestamp,'timestamp_group':timestamp_group}; if (count_items != null){ // deze_artikelid = deze_artikelid+"_"+count_items; deze_entry_id = deze_entry_id+"_"+count_items; //alert('deze_artikelid= '+deze_artikelid) } localStorage.setItem('wl_shop_'+deze_entry_id, JSON.stringify(array)); //localStorage.setItem('wl_shop_'+deze_entry_id, JSON.stringify(array)); //localStorage.setItem('wl_shop_'+deze_artikelid, array); //array2 = JSON.parse(localStorage.getItem("array")); if ($('#wl_shop_insert_here').length){ get_items_from_local_storage(); }else{ update_winkelmand_icoon(); } if (deze_artikelid != 'kaartje' && deze_artikelid != 'VAAS'){ wl_alert('confirm', ''+origineel_aantal+' item(s) toegevoegd aan de winkelmand! Wilt u de winkelmand nu bekijken?',wl_shop_ga_naar_winkelmand,remove_green_color_alert,'Mandje bekijken','Verder shoppen',deze); $('.confirm_txt_content').addClass('wl-shop_alert_winkelmand'); } //////// wl_shop_count_items = 0; } function wl_shop_ga_naar_winkelmand(){ $('.winkelmand_link').trigger('click'); window.setTimeout(function(){ $('.confirm_txt_content').removeClass('wl-shop_alert_winkelmand'); }, 500); } function remove_green_color_alert(){ window.setTimeout(function(){ $('.confirm_txt_content').removeClass('wl-shop_alert_winkelmand'); wl_shop_pulse_widget(); }, 500); } function dynamicSort(property) { var sortOrder = 1; if(property[0] === "-") { sortOrder = -1; property = property.substr(1); } return function (a,b) { /* next line works with strings and numbers, * and you may want to customize it to your needs */ var result = (a[property] < b[property]) ? -1 : (a[property] > b[property]) ? 1 : 0; return result * sortOrder; } } function get_items_from_local_storage(focus){ var order_info = new Object(); var koers_array = get_koers_per_regio(); var koers = koers_array[0]; var koers_label = koers_array[1]; $('.valuta_changer').html(koers_label); //koers2 = koers[1]; //console.log('koers: '+koers_label); var display_aantal = 0; var totaal_prijs = 0; $('.wl_shop_row').remove(); var tr_mail = ""; var arraysort_var = new Array(); var sorted_arraysort_var = new Array(); for (i = 0; i < localStorage.length; i++) { //console.log(localStorage.key(i) + "=[" + localStorage.getItem(localStorage.key(i)) + "]"); if(localStorage.key(i).indexOf('wl_shop_') == 0 ){ arraysort_var.push(JSON.parse(localStorage.getItem(localStorage.key(i)))); } } arraysort_var.sort(dynamicSort("timestamp")); order_info['bon_regels'] = arraysort_var; for (i = 0; i < arraysort_var.length; i++) { //var retrieved_array = JSON.parse(arraysort_var[i]); var retrieved_array = arraysort_var[i]; /* var product_code = retrieved_array[0]; var product_naam = retrieved_array[1]; var product_aantal = retrieved_array[2]; var product_prijs = retrieved_array[3]; var product_image = retrieved_array[4]; var product_href = retrieved_array[5]; var product_identifier = retrieved_array[6]; var product_opmerking = retrieved_array[7]; var entryID = retrieved_array[8]; */ var product_code = retrieved_array.artikelid; var product_naam = retrieved_array.product; var product_aantal = retrieved_array.aantal; var product_prijs = retrieved_array.prijs; var product_image = retrieved_array.image; var product_href = retrieved_array.href; var product_identifier = retrieved_array.artikel_identifier; var product_opmerking = retrieved_array.opmerking; var entryID = retrieved_array.productID; var product_timestamp_group = retrieved_array.timestamp_group; //alert(product_opmerking); if (product_identifier == '0' || product_identifier == null){ product_identifier = entryID; } var product_opmerking_insert = ""; if (product_opmerking != ''){ //alert('t'); product_opmerking_insert = "
Opmerking: "+product_opmerking+"
"; } //current_eenheid = 'kg'; //current_region_eenheid = 1; product_prijs = product_prijs * 1; product_prijs = product_prijs * current_region_eenheid; //console.log('product_prijs '+product_prijs); //console.log('product_prijs tomoney'+product_prijs.toMoney(2)); var product_prijs_tbv_totaal = product_prijs.toMoney(2); //////var totaal_prijs_excl_aantal = ((product_prijs_tbv_totaal * 1)) * (koers * 1); /////////// var totaal_prijs_excl_aantal = ((product_prijs * 1)) * (koers * 1); var totaal_prijs_excl_aantal = ((product_prijs * 1)) / (koers * 1); totaal_prijs_excl_aantal = totaal_prijs_excl_aantal.toMoney(2); var totaal_prijs_product = ((totaal_prijs_excl_aantal * 1) * (product_aantal *1)); //var totaal_prijs_product = ((product_aantal *1) * (product_prijs_tbv_totaal * 1)) * (koers * 1); totaal_prijs = totaal_prijs + totaal_prijs_product; totaal_prijs_product = totaal_prijs_product.toMoney(2); /////////// product_prijs = (product_prijs * 1) * (koers * 1); product_prijs = (product_prijs * 1) / (koers * 1); product_prijs = product_prijs.toMoney(2); ///check of product in boeket zit var product_code_insert = "
art# "+product_code+"
"; var product_opmerking_insert = ""; if (product_opmerking != ''){ //alert('t'); product_opmerking_insert = "
Opmerking: "+product_opmerking+"
"; } /////check op bezorgkosten row if (product_identifier != bezorgkosten_product_id){ var tr_data = ""; }else{ var tr_data = ""; } $('#wl_shop_insert_here').append(tr_data); tr_mail += ""; // console.log('product_aantal: '+product_aantal+' display_aantal: '+display_aantal); product_aantal = product_aantal * 1; display_aantal = (display_aantal *1) + product_aantal; // console.log('display_aantal 2: '+display_aantal); } //console.log('display_aantal 3: '+display_aantal); display_aantal = display_aantal * 1; display_aantal = display_aantal.toFixed(0); var winkelmand_aantal = "
"+display_aantal+"
"; $('.wl-shop_winkelmand_aantal').remove(); if (display_aantal != 0){ console.log('display_aantal 4: '+display_aantal); $('.winkelmand_link').append(winkelmand_aantal); if (focus != null){ var focus_item = $('#'+focus); var focus_waarde = focus_item.val(); focus_item.focus(); focus_item.val(''); focus_item.val(focus_waarde); } $('.wl_shop_mandje_leeg').hide(); $('.wl_shop_table_wrapper').show(); $('.wl_shop_total_price').html(totaal_prijs.toMoney(2)); wl_shop_pulse_widget(); //tr_mail += "
ProductAantal ("+current_eenheid+")Prijs "+koers_label+"Totaal "+koers_label+"
"+product_naam+"
"+product_code_insert+""+product_opmerking_insert+"
"+product_prijs+""+totaal_prijs_product+"
"+product_naam+""+product_prijs+""+totaal_prijs_product+"
"+product_naam+"
art: "+product_code+""+product_opmerking_insert+"
"+product_aantal+""+product_prijs+""+totaal_prijs_product+"
Totaal "+koers_label+""+totaal_prijs.toMoney(2)+"
"; //$('#contact_iframe').contents().find('#winkelmanditems_html').val(tr_mail); tr_mail += "Totaal"+totaal_prijs.toMoney(2)+""; $('#contact_iframe').contents().find('#winkelmanditems_html').val(tr_mail); }else{ $('.wl_shop_mandje_leeg').show(); $('.wl_shop_table_wrapper').hide(); } $('.wl_unit_converter').html(current_eenheid); return order_info; } function wl_shop_ask_to_delete(deze){ wl_alert('confirm', 'Wilt u dit item verwijderen uit de winkelmand?',wl_shop_delete_row,false,'ja','nee',deze); } function wl_shop_delete_row(deze){ var deze_id = deze.attr('id'); var deze_time_group = deze.data('timegroup'); deze_id_stripped = deze_id.substring(7); $('.wl_shop_row_'+deze_id_stripped).hide(1000); $('.wl_shop_row_'+deze_id_stripped).find('td').fadeOut(150); localStorage.removeItem('wl_shop_'+deze_id_stripped); if (!deze.hasClass('delete_only_this') && deze.data('timegroup') != 0){ wl_shop_delete_others_from_timegroup(deze_time_group); } // update_winkelmand_icoon(); window.setTimeout(function(){ get_items_from_local_storage() }, 1000); } function wl_shop_delete_others_from_timegroup(deze_time_group){ $('[data-timegroup="'+deze_time_group+'"]').each(function( i ) { var die = $(this); wl_shop_only_delete_row(die); }); } function wl_shop_only_delete_row(deze){ var deze_id = deze.attr('id'); deze_id_stripped = deze_id.substring(7); $('.wl_shop_row_'+deze_id_stripped).hide(1000); $('.wl_shop_row_'+deze_id_stripped).find('td').fadeOut(150); localStorage.removeItem('wl_shop_'+deze_id_stripped); } function wl_shop_auto_delete_row(deze_id){ // var deze_id = deze.attr('id'); //deze_id_stripped = deze_id.substring(7); $('.wl_shop_row_'+deze_id).hide(1000); $('.wl_shop_row_'+deze_id).find('td').fadeOut(150); //}, 100); localStorage.removeItem('wl_shop_'+deze_id); // update_winkelmand_icoon(); window.setTimeout(function(){ get_items_from_local_storage() }, 1000); } function clear_wl_shop_items_from_local_storage(){ //loop door alle Localstorage items heen Object.keys(localStorage).forEach(function(key){ //if(key.startsWith("wl_shop_") ){ if(key.indexOf('wl_shop_') == 0 ){ //console.log(key); localStorage.removeItem(key); } get_items_from_local_storage(); //console.log(localStorage.getItem(key)); }); } $(document).on('input','.wl_numbers_only','',function(){ var deze = $(this); var deze_waarde = deze.val(); deze_waarde = deze_waarde.replace(/[^0-9\.\,]/g,''); if (deze_waarde.indexOf(',') > -1){ deze_waarde = deze_waarde.replace(/,/g, '.'); } deze.val(deze_waarde); }); $(document).on('input','.wl_shop_aantal_table','',function(){ var deze = $(this); var deze_identifier = deze.data('localstorage_id'); //deze_identifier = deze_identifier.substring(12); //deze_identifier = "wl_shop_"+deze_identifier; //alert(deze_identifier); var deze_id = deze.attr('id'); var deze_product_prijs = deze.data('product_prijs'); var deze_waarde = deze.val(); var retrieved_array = JSON.parse(localStorage.getItem(deze_identifier)); /* var product_code = retrieved_array[0]; var product_naam = retrieved_array[1]; //var product_aantal = retrieved_array[2]; var product_aantal = deze_waarde; var product_prijs = retrieved_array[3] * 1; var product_image = retrieved_array[4]; var product_href = retrieved_array[5]; var product_identifier = retrieved_array[6]; var product_opmerking = retrieved_array[7]; var entryID = retrieved_array[8]; var timestamp = retrieved_array[9]; */ var product_code = retrieved_array.artikelid; var product_naam = retrieved_array.product; var product_aantal = deze_waarde; var product_prijs = retrieved_array.prijs; var product_image = retrieved_array.image; var product_href = retrieved_array.href; var product_identifier = retrieved_array.artikel_identifier; var product_opmerking = retrieved_array.opmerking; var entryID = retrieved_array.productID; var timestamp = retrieved_array.timestamp; var timestamp_group = retrieved_array.timestamp_group; //alert('aantal= '+product_aantal); //var array = [product_code,product_naam,product_aantal,product_prijs,product_image,product_href,product_identifier,product_opmerking,entryID]; var array = {'artikelid':product_code,'product':product_naam,'aantal':product_aantal,'prijs':product_prijs,'image':product_image,'href':product_href,'artikel_identifier':product_identifier,'opmerking':product_opmerking,'productID':entryID,'timestamp':timestamp,'timestamp_group':timestamp_group}; localStorage.setItem(deze_identifier, JSON.stringify(array)); //get_items_from_local_storage(deze_id); var totaal_prijs = 0; var eenheids_prijs = deze.closest('.wl_shop_row').find('.eenheids_prijs').html(); eenheids_prijs = eenheids_prijs * 1; deze_waarde = deze_waarde * 1; //console.log('deze_waarde= '+deze_waarde+' eenheids_prijs='+eenheids_prijs); var nieuwe_berekende_totaal_prijs = deze_waarde * eenheids_prijs; deze.closest('.wl_shop_row').find('.totaal_product').html(nieuwe_berekende_totaal_prijs.toMoney(2)); $('.totaal_product').each(function() { var dit = $(this); var waarde = dit.html() * 1; //console.log(waarde); totaal_prijs = totaal_prijs + waarde; }); $('.wl_shop_total_price').html(totaal_prijs.toMoney(2)) //deze.focus(); }); $(document).on('change','.wl_shop_aantal_table','',function(){ get_items_from_local_storage(); }); /* $(document).on('change','.wl_numbers_only','',function(){ var deze = $(this); var tt = deze.val(); if (tt.indexOf(',') > -1){ tt = tt.replace(/,/g, '.'); deze.val(tt); deze.trigger('change'); } }); */ function update_winkelmand_icoon(){ var display_aantal = 0; for (i = 0; i < localStorage.length; i++) { //console.log(localStorage.key(i) + "=[" + localStorage.getItem(localStorage.key(i)) + "]"); //if(localStorage.key(i).startsWith("wl_shop_") ){ if(localStorage.key(i).indexOf('wl_shop_') == 0 ){ var retrieved_array = JSON.parse(localStorage.getItem(localStorage.key(i))); //var product_aantal = retrieved_array[2]; var product_aantal = retrieved_array.aantal; product_aantal = product_aantal * 1; display_aantal = display_aantal + product_aantal; } } var winkelmand_aantal = "
"+display_aantal+"
"; $('.wl-shop_winkelmand_aantal').remove(); if (display_aantal != 0){ $('.winkelmand_link').append(winkelmand_aantal); $('.wl_shop_mandje_leeg').hide(); $('.wl_shop_table_wrapper').show(); wl_shop_pulse_widget(); }else{ $('.wl_shop_mandje_leeg').show(); $('.wl_shop_table_wrapper').hide(); } } prevent_double_pulse = false; function wl_shop_pulse_widget(){ if (prevent_double_pulse == false){ prevent_double_pulse = true; window.setTimeout(function(){ $('.wl-shop_winkelmand_aantal').addClass('wl-shop_winkelmand_aantal_anim'); window.setTimeout(function(){ $('.wl-shop_winkelmand_aantal').removeClass('wl-shop_winkelmand_aantal_anim'); }, 500); window.setTimeout(function(){ prevent_double_pulse = false; }, 2000); }, 100); } } $(document).ready(function () { update_winkelmand_icoon(); }); $(document).on('input','.wl_shop_required',function(){ var deze = $(this); if (deze.hasClass('error_required')){ deze.removeClass('error_required'); } }); $(document).on('click','.wl_shop_plaats_bestelling','data',function(){ //alert('check login, check aflever adres, schiet order er in'); var error = ""; $('.wl_shop_required').each(function(){ console.log($(this)); if ($(this).val()=='' && $(this).is(':visible')) { error += $(this).data('label') + " is verplicht.
"; $(this).addClass('error_required'); }else{ $(this).removeClass('error_required'); } }) if ($('#lever_methodeID').val()==1) { if ($('#bon_aflever_adres').val().trim()=='') { error +="Vul aflever adres in.
"; $('#bon_aflever_adres').addClass('error_required'); }else{ $('#bon_aflever_adres').removeClass('error_required'); } } if(error!=''){ wl_alert('alert',error); }else{ console.log("collect data en verzend bestelling, geen errors gevonden."); var order_data = new Object(); order_data = get_items_from_local_storage(); $('.wl_shop_order_data').each(function(){ order_data[$(this).attr('name')] = $(this).val(); }) currency = localStorage.getItem('wl_valuta'); order_data['valuta'] = currency; //alert(currency); //return false; var afrekenen_ar = new Array(); console.log('order',order_data); $('.loading').show(); for (var key in valutas) { if (currency==valutas[key]['valuta']) { order_data['valutaID'] = key; order_data['dagkoers'] = valutas[key]['administratie_koers']; } } var func_attributes = new Array(); func_attributes[0]=0; func_attributes[1]=1; func_attributes[2]='webshop'; func_attributes[3]='2024-04-27 08:14:27'; func_attributes[4]=order_data['bon_regels']; func_attributes[5]=order_data['bon_opmerking']; func_attributes[6]=0; func_attributes[7]=''; func_attributes[8]=''; func_attributes[9]=0; func_attributes[10]=0; func_attributes[11]=0; func_attributes[12]=0; func_attributes[13]=0; func_attributes[14]=0; func_attributes[15]=0; func_attributes[16]=0; func_attributes[17]=0; func_attributes[18]=0; func_attributes[19]=0; func_attributes[21]=order_data['bestelling_lever_datum']; func_attributes[22]=order_data['valutaID']; func_attributes[23]=valutas[2]['administratie_koers']; func_attributes[24]=valutas[3]['administratie_koers']; func_attributes[25]=order_data['dagkoers']; func_attributes[26]=0; func_attributes[27]=0; func_attributes[28]=order_data['lever_methodeID']; func_attributes[29]=0; func_attributes[30]=order_data['bon_aflever_adres']; func_attributes[31]=order_data['bon_aflever_stad']; func_attributes[32]=order_data['betaal_methodeID']; func_attributes[33]=order_data['levering_rondeID']; //console.log(func_attributes); //return false; $('.loading').show(); $.ajax({ url: "../backend/process_ajax.php", type: "POST", data: {class:'bon',task:'bon_to_database',attributes:func_attributes}, cache: false, async:true, success: function (html) { if($.isNumeric(html)){ //returnpath +='&bonID='+html; } wl_alert('alert', 'Bon is opgeslagen '+html,clear_wl_shop_items_from_local_storage,false,'Ok'); }, error: function(error){ wl_alert('alert','Connection lost, please try again.',back_to_start,false,'Ok','',false); }, complete: function(){ $('.loading').hide(); } }); } }); $(document).on('click','#login','data',function(){ var email = $('#login_email').val(); var password = $('#login_password').val(); var subdir = ""; var protocol = location.protocol; var http_path = protocol+"//"+window.location.host+subdir; if(email=='' || password==''){ alert("Vul email en wachtwoord in aub."); }else{ $('.loading').show(); $.ajax({ url: http_path+'/process_ajax.php', type: 'POST', data: {class:'debiteur_connector',task:'login_debiteur',login_email:email,login_password:password}, cache: false, dataType:'json', success: function (html) { console.log(html); if (html.error) { wl_alert('alert',html.error); }else{ hide_login(); wl_alert('alert', 'Welkom '+html.debiteur); $('#login_link_box').html(""+html.debiteur_initials+""); console.log(window.location.pathname) if (window.location.pathname.indexOf('winkelmand')) { // $('.contact_formulier_container').show(); // $('#not_logged_in').hide(); window.location.reload(); } } }, error: function(error,ermes){ wl_alert('alert','Connection lost, please try again.' + error,false,false,'Ok','',false); console.log(ermes,error); }, complete: function(){ $('.loading').hide(); } }); } }); $(document).on('click','#trigger_login_bx','data',function(){ $('.login_link').trigger('click'); }); $(document).on('click','.update_prijzen','data',function(){ var productIDs = new Object(); var val = ''; for (i = 0; i < localStorage.length; i++) { //console.log(localStorage.key(i) + "=[" + localStorage.getItem(localStorage.key(i)) + "]"); val = localStorage.key(i); //if(localStorage.key(i).startsWith("wl_shop_") ){ if(localStorage.key(i).indexOf('wl_shop_') == 0 ){ var retrieved_array = JSON.parse(localStorage.getItem(localStorage.key(i))); //alert(retrieved_array.entryid); console.log(retrieved_array); retrieved_array.productID = retrieved_array.productID * 1; productIDs[val] = retrieved_array.productID; } } // alert(productIDs); //console.log(productIDs); $.ajax({ url: '../process_ajax.php', type: 'POST', data: {class:'product_connector',task:'wl_shop_get_prijzen_for_IDs',attributes:productIDs}, cache: false, dataType:'json', success: function (html) { //alert(html); console.log('currency',currency); //var rows = html.split('|'); var rows = html; console.log(html); var prijzen_aangepast = false; for (var key in rows) { // var detail = rows[key].split('='); // var detail[0] = key; //alert(detail[1]); var retrieved_array = JSON.parse(localStorage.getItem(key)); var old_prijs = retrieved_array.prijs * 1; /* var product_code = retrieved_array[0]; var product_naam = retrieved_array[1]; var product_aantal = retrieved_array[2]; var product_prijs = detail[1] * 1; var product_image = retrieved_array[4]; var product_href = retrieved_array[5]; var product_identifier = retrieved_array[6]; var product_opmerking = retrieved_array[7]; var entryID = retrieved_array[8]; */ var product_code = retrieved_array.artikelid; var product_naam = retrieved_array.product; var product_aantal = retrieved_array.aantal; // var product_prijs = rows[key]['prijs_'+currency] * 1; var product_prijs = rows[key]['prijs_SRD'] * 1; var product_image = retrieved_array.image; var product_href = retrieved_array.href; var product_identifier = retrieved_array.artikel_identifier; var product_opmerking = retrieved_array.opmerking; var entryID = retrieved_array.productID; var timestamp = retrieved_array.timestamp; var timestamp_group = retrieved_array.timestamp_group; //alert('aantal= '+product_aantal); //var array = [product_code,product_naam,product_aantal,product_prijs,product_image,product_href,product_identifier,product_opmerking,entryID]; var array = {'artikelid':product_code,'product':product_naam,'aantal':product_aantal,'prijs':product_prijs,'image':product_image,'href':product_href,'artikel_identifier':product_identifier,'opmerking':product_opmerking,'productID':entryID,'timestamp':timestamp,'timestamp_group':timestamp_group}; if (product_prijs != 0){ localStorage.setItem(key, JSON.stringify(array)); if (old_prijs != product_prijs){ prijzen_aangepast = true; } } // localStorage.detail[0][3] = 200; } if (prijzen_aangepast){ wl_alert('alert','Prijzen in de winkelmand zijn geupdatet',false,false,'Ok','',false); } get_items_from_local_storage(); }, error: function(error){ wl_alert('alert','Connection lost, please try again.' + error,false,false,'Ok','',false); //console.log('error'+error); }, complete: function(){ $('.loading').hide(); } }); }); function calculate_boeket_prijs(deze){ if (deze == null || deze == false ){ deze = $('.totaal_prijs:visible'); } var deze_container = deze.closest('.boeket_container'); var target_element = deze_container.find('.totaal_prijs'); var deze_optellen = deze_container.find('.add_form_a_active'); current_valuta = localStorage.getItem("wl_valuta"); current_valuta = current_valuta.toLowerCase(); totaal_prijs_boeket = 0; deze_optellen.each(function( i ) { var die = $(this); // var convert_prijs = 0; // if (typeof die.data('data-prijs_'+current_valuta) !== 'undefined'){ var convert_prijs = die.attr('data-prijs_'+current_valuta) * 1; if (die.hasClass('select_related')){ convert_prijs = convert_prijs * (deze_container.find('.wl_shop_aantal_table_inline').val() * 1); } // alert(convert_prijs); totaal_prijs_boeket = totaal_prijs_boeket + convert_prijs; }); target_element.html(totaal_prijs_boeket.toMoney(2)); deze_container.find('.totaal_product_prijs').find('.current_prijs_lable').html(current_valuta); } $(document).on('click','.add_form_a','',function(){ var deze = $(this); deze.closest('.add_to_product_wrapper').find('.add_form_a').removeClass('add_form_a_active'); deze.addClass('add_form_a_active'); calculate_boeket_prijs(deze); if (!deze.hasClass('add_kaartje')){ return false; } var deze_container = deze.closest('.add_to_product_container'); var textarea_target = deze_container.find('.wl_input_length'); var textarea = textarea_target.find('.add_kaartje_textarea'); if (deze.hasClass('add_kaartje_yes')){ textarea_target.slideDown(300); window.setTimeout(function(){ textarea.addClass('textarea_opacity'); }, 300); }else{ textarea_target.slideUp(300); textarea.removeClass('textarea_opacity'); } }); $(document).on('input','.wl_shop_aantal_table_inline','data',function(e){ var deze = $(this); calculate_boeket_prijs(deze); }); $(document).on('click','.plusus','data',function(e){ var deze = $(this); var prev = deze.prev(); var cur_val = prev.val() * 1; var new_val = cur_val + 1; if (new_val > 0){ prev.val(new_val); if (deze.hasClass('in_winkelmand')){ prev.trigger('input'); var speed = 20; pulse_widget(speed); }else{ var verkoop_prijs = $('#voeg_toe_winkelmand').data('verkoop_prijs') * 1; verkoop_prijs = get_prijs_from_wishes(verkoop_prijs); var new_display_prijs = new_val * verkoop_prijs; $('#product_product_totaal').html(new_display_prijs.toMoney(2)); } } }); $(document).on('click','.minus','data',function(e){ var deze = $(this); var next = deze.next(); var cur_val = next.val() * 1; var new_val = cur_val - 1; if (new_val > 0){ next.val(new_val); if (deze.hasClass('in_winkelmand')){ next.trigger('input'); var speed = 20; pulse_widget(speed); }else{ var verkoop_prijs = $('#voeg_toe_winkelmand').data('verkoop_prijs') * 1; verkoop_prijs = get_prijs_from_wishes(verkoop_prijs); var new_display_prijs = new_val * verkoop_prijs; $('#product_product_totaal').html(new_display_prijs.toMoney(2)); } } }); /* $(document).on('click','.wl_bestel_product_2','data',function(e){ var d=new Date(); var timestamp = d.getTime(); var timestamp_group = timestamp; var deze = $(this); var deze_container = deze.closest('.diensten_inner_left_padding'); var aantal = deze_container.find('.wl_shop_aantal_table_inline').val(); //voeg product regel toe: var main_product_pass = false; var main_product = deze_container.find('.select_related.add_form_a_active'); if (main_product.length){ // alert(aantal); main_product_pass = true; if (aantal == 0){ wl_alert('alert','Vul eerst een aantal in'); return false; } }else{ wl_alert('alert','Selecteer eerst een item!'); return false; } //voeg kaartje toe var kaartje_pass = false; var kaartje_product = deze_container.find('.add_kaartje_yes.add_form_a_active'); if (kaartje_product.length){ kaartje_pass = true; var kaartje_tekst = deze_container.find('.add_kaartje_textarea').val(); if (kaartje_tekst == ''){ wl_alert('alert','[kaartje_niet_ingevuld]'); return false; } } if (main_product_pass){ process_info_from_product(main_product,aantal,timestamp,timestamp_group); } aantal = 1; timestamp = timestamp * 1; timestamp = timestamp + 1; //voeg vaas toe var vaas_product = deze_container.find('.add_vaas_yes.add_form_a_active'); if (vaas_product.length){ process_info_from_product(vaas_product,aantal,timestamp,timestamp_group); } timestamp = timestamp + 1; if (kaartje_pass){ process_info_from_product(kaartje_product,aantal,timestamp,timestamp_group,kaartje_tekst); } }); */ /* $(document).on('change','#lever_methodeID','',function(){ var deze = $(this); deze_val = deze.val(); if (deze.val() == '1'){ $('.row_levering_rondeID,.row_bon_aflever_adresID,.row_bon_aflever_stadID').slideDown(500); wl_alert('alert','U heeft voor bezorgen gekozen, er wordt SRD75,- bezorgkosten gerekend voor bezorgingen buiten de leverronde!'); /// var d=new Date(); var timestamp = 9999999999999; var deze_entry_id = bezorgkosten_product_id; var array = {'artikelid':'bezorg','product':bezorgkosten_name,'aantal':'1','prijs':bezorgkosten_prijs,'image':'','href':'javascript:void(0)','artikel_identifier':'0','opmerking':'','productID':deze_entry_id,'timestamp':timestamp,'timestamp_group':timestamp}; //localStorage.setItem('wl_shop_'+deze_artikelid, JSON.stringify(array)); localStorage.setItem('wl_shop_'+deze_entry_id, JSON.stringify(array)); get_items_from_local_storage(); }else{ $('.row_levering_rondeID,.row_bon_aflever_adresID,.row_bon_aflever_stadID').slideUp(500); wl_shop_auto_delete_row(bezorgkosten_product_id); } }); */ function nextWeekdayDate(date, day_in_week) { var ret = new Date(date||new Date()); ret.setDate(ret.getDate() + (day_in_week - 1 - ret.getDay() + 7) % 7 + 1); ret = ret.toISOString().split('T')[0] return ret; } function nextDay(x){ // var now = new Date(); let today = new Date(); let tomorrow = new Date(); tomorrow.setDate(today.getDate() + 1); now = tomorrow; now.setDate(now.getDate() + (x+(7-now.getDay())) % 7); now = now.toISOString().split('T')[0] return now; } var leverronde_used = false; /* $(document).on('change','#levering_rondeID','',function(){ var deze = $(this); deze_val = deze.val(); if (deze.val() == '3'){ //// wl_alert('alert','U heeft voor bezorgen gekozen, er wordt SRD75,- bezorgkosten gerekend voor bezorgingen buiten de leverronde!'); /// var d=new Date(); var timestamp = 9999999999999; var deze_entry_id = bezorgkosten_product_id; var array = {'artikelid':'bezorg','product':bezorgkosten_name,'aantal':'1','prijs':bezorgkosten_prijs,'image':'','href':'javascript:void(0)','artikel_identifier':'0','opmerking':'','productID':deze_entry_id,'timestamp':timestamp,'timestamp_group':timestamp}; //localStorage.setItem('wl_shop_'+deze_artikelid, JSON.stringify(array)); localStorage.setItem('wl_shop_'+deze_entry_id, JSON.stringify(array)); if (leverronde_used){ leverronde_used = false; $('#bestelling_lever_datum').val(''); $('#bestelling_lever_datum').trigger('input'); } get_items_from_local_storage(); }else{ leverronde_used = true; var data_volgorde = deze.find(':selected').data('volgorde') * 1; /// alert(data_volgorde); if (data_volgorde >= 1){ // data_volgorde = data_volgorde -1; // alert(data_volgorde); var get_date = new Date(); // $('#bestelling_lever_datum').val(nextWeekdayDate(get_date, data_volgorde)); $('#bestelling_lever_datum').val(nextDay(data_volgorde)); $('#bestelling_lever_datum').trigger('input'); } // console.log(nextWeekdayDate(get_date, 5)); // alert(nextWeekdayDate(get_date, 5)); wl_shop_auto_delete_row(bezorgkosten_product_id); } }); */ $(document).on('click','.resetlink','data',function() { wl_alert("confirm", "
", reset_password, false, 'Reset wachtwoord', 'Annuleren'); $('#username').focus(); }); function reset_password(){ var deze = $('#email_alert'); var deze_val = deze.val(); var error = ""; if(deze_val != ''){ $.ajax({ url: '../process_ajax.php', type: 'POST', data: {task:'reset_password',email_adres:deze_val}, cache: false, success: function (html) { if (html != ''){ wl_alert('alert',html,focus_email_field); } }, error: function(error){ ////// wl_alert('alert','Connection lost, please try again.' + error,false,false,'Ok','',false); wl_alert('alert','Connection lost, please try again!',false,false,'Ok','',false); //console.log('error'+error); }, complete: function(){ $('.loading').hide(); } }); } } $(document).on('click','.changelink','data',function() { show_errors_in_changepassword = false; show_password_change_alert(); }); var show_errors_in_changepassword = false; global_old_pw = ''; global_new_password = ''; global_new_confirm_password = ''; function show_password_change_alert(){ wl_alert("confirm", "


", change_password, false, 'Save', 'Cancel'); /* if (show_errors_in_changepassword){ $('#current_password').val(global_old_pw); $('#new_password,#confirm_new_password').addClass('error_required') }*/ if (show_errors_in_changepassword){ $('#current_password').val(global_old_pw); $('#new_password').val(global_new_password); $('#confirm_new_password').val(global_new_confirm_password); //$('#new_password,#confirm_new_password').addClass('error_required') $('.login_input_reset').each(function( i ) { var die = $(this); if (die.val() == ''){ die.addClass('error_required'); } }); if (global_new_password != global_new_confirm_password){ $('#new_password,#confirm_new_password').addClass('error_required').val(''); } } }; function change_password(){ var deze = $('#current_password'); var current_pw = deze.val(); var new_pw = $('#new_password').val(); var new2_pw = $('#confirm_new_password').val(); global_old_pw = current_pw; global_new_password = new_pw; global_new_confirm_password = new2_pw; var error = ''; $('.login_input_reset').each(function( i ) { var die = $(this); if (die.val() == ''){ error += ''+die.attr('placeholder')+' is een verplicht veld!

'; } }); if (new_pw.length < 8){ error +='Wachtwoord moet uit minimaal 8 characters bestaan'; } if (error != ''){ show_errors_in_changepassword = true; wl_alert('alert',error,show_password_change_alert,false,'Ok','',false); return false; }else{ show_errors_in_changepassword = false; } if (new_pw != new2_pw){ show_errors_in_changepassword = true; wl_alert('alert','Wachtwoorden komen niet overeen!',show_password_change_alert,false,'Ok','',false); return false; }else{ show_errors_in_changepassword = false; } if(error == ''){ $.ajax({ url: '../process_ajax.php', type: 'POST', data: {task:'change_password',old_password:current_pw,new_password:new_pw}, cache: false, success: function (html) { if (html != ''){ wl_alert('alert',html); } }, error: function(error){ ////// wl_alert('alert','Connection lost, please try again.' + error,false,false,'Ok','',false); wl_alert('alert','Connection lost, please try again!',false,false,'Ok','',false); //console.log('error'+error); }, complete: function(){ $('.loading').hide(); } }); } } Number.prototype.toMoney_old = function(decPlaces) { if (decPlaces == null){ decPlaces = 0 } var n = this, decPlaces = decPlaces, decSeparator = ",", thouSeparator = ".", sign = n < 0 ? "-" : "", i = parseInt(n = Math.abs(+n || 0)) + "", j = (j = i.length) > 3 ? j % 3 : 0, decimals = Number(Math.round(n +'e'+ decPlaces) +'e-'+ decPlaces).toFixed(decPlaces), result = sign + (j ? i.substr(0, j) + thouSeparator : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + thouSeparator) + (decPlaces ? decSeparator + Math.abs(decimals-i).toFixed(decPlaces).slice(2) : ""); return result; }; Number.prototype.toMoney = function(decPlaces) { if (decPlaces == null){ decPlaces = 0 } var result = Math.round(parseFloat((this * Math.pow(10, decPlaces)).toFixed(13))) / Math.pow(10, decPlaces); result = result.toFixed(decPlaces); return result; }; ////////////