var DPHprice = 1.21; var totalprice = 0.00; function itemsum(){ totalprice = 0.00; $( ".hiddenRand" ).each(function() { var randID = $( this ).val(); var showPenal = false; $( this ).parent().children('.sItTbl').children('.rwShopItem').each(function() { var price = $( this ).children('.price_' + randID).val(); var delkarole = $( this ).children('.delkarole_' + randID).val(); var input = $( this ).children('.sItCellOn').children('.sItCellForm').children('.inp_' + randID).val(); var PriceInt = (price * input); var showPrice = ""; if(input!=0){ if(delkarole!="") { if(input % delkarole === 0) {} else { PriceInt += 125; showPrice = "*"; showPenal = true; } }} PriceInt = PriceInt.toFixed(2); totalprice = (parseFloat(PriceInt) + parseFloat(totalprice)); showPrice = PriceInt + "Kč" + showPrice; $( this ).children('.sItCellOn').children('.showPrice_' + randID).text(showPrice); }); if(showPenal==true){ $( this ).parent().children( ".sItCellPenal" ).show(50); } else { $( this ).parent().children( ".sItCellPenal" ).hide(50); } }); if(totalprice!=0.00){ $( ".btn_con_1_n" ).removeClass("continue_btn_G"); } else { $( ".btn_con_1_n" ).addClass("continue_btn_G"); } $( "#priceWithoutDPH" ).text(totalprice.toFixed(2)); $( "#priceWithDPH" ).text((parseFloat(totalprice)*parseFloat(DPHprice)).toFixed(2)); } function replaceInput(vari){ $(vari).select(); } function isNumberKey(txt, evt) { var charCode = (evt.which) ? evt.which : evt.keyCode; if (charCode > 31 && (charCode < 48 || charCode > 57) && charCode != 37 && charCode != 39) return false; return true; } function checkfield(itm){ if($(itm).val()<0){ $(itm).val(0);} } var totalItems = 0; function addItem(id){ $(".spinner").fadeIn(20); $(".submenu_content").css("display", "none"); var rndID = makeid(); var postData = { itmID: id, randID: rndID }; $.ajax({ type: 'POST', url: 'e_shop_load.php', data: postData, success: function (data) { $('.shop_item').prepend(data); totalItems += 1; basketShow(); itemsum(); if ($(window).width() <= 767) { $(window).scrollTop($('.shop_item').offset().top); } $(".spinner").fadeOut(20); }, error: function(err){ $(".spinner").fadeOut(20); alert("Chyba ve zpracování dat. Zkontrolujte své připojení a zkuste to znovu."); } }); } function delItem(randID){ $("#" + randID).remove(); totalItems -= 1; basketShow(); itemsum(); } function basketShow(){ if(totalItems > 0){ $(".empty_basket").css("display", "none"); } else { $(".empty_basket").css("display", "block"); } } function makeid() { var text = ""; var possible = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; for (var i = 0; i < 10; i++) text += possible.charAt(Math.floor(Math.random() * possible.length)); return text; } function isEmail(email) { var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/; return regex.test(email); } function isTelephone(tel) { var regex = /^([\+][0-9]{3}){0,1}?[\s]?[0-9]{3}?[\s]?[0-9]{3}[\s]?[0-9]{3}$/; return regex.test(tel); } function checkpsc(psc){ res = /^\d{3} ?\d{2}$/; return psc.search(res) == 0;} var objok = false; function objchecker(isColored){ var impStyle = "field-style-imp"; var impXStyle = "field-style-warn"; if(isColored){ impStyle = "field-style-warn"; impXStyle = "field-style-imp"; } var spalert = 0; var name = $('#Name').attr('value'); var street = $('#Ulice').attr('value'); var town = $('#Mesto').attr('value'); var psc = $('#PSC').attr('value'); var dodaci_name = $('#dodName').attr('value'); var dodaci_street = $('#dodUlice').attr('value'); var dodaci_town = $('#dodMesto').attr('value'); var dodaci_psc = $('#dodPSC').attr('value'); var mail = $('#email').attr('value'); var tel = $('#telefon').attr('value'); if(name=="") { spalert = 1; $('#Name').removeClass(impXStyle).addClass(impStyle); } else { $('#Name').removeClass("field-style-imp").removeClass("field-style-warn");} if(street=="") { spalert = 1; $('#Ulice').removeClass(impXStyle).addClass(impStyle); } else { $('#Ulice').removeClass("field-style-imp").removeClass("field-style-warn");} if(town=="") { spalert = 1; $('#Mesto').removeClass(impXStyle).addClass(impStyle); } else { $('#Mesto').removeClass("field-style-imp").removeClass("field-style-warn");} if(checkpsc(psc) == false) { spalert = 1; $('#PSC').removeClass(impXStyle).addClass(impStyle); } else { $('#PSC').removeClass("field-style-imp").removeClass("field-style-warn");} if(!$('#dod_checkbox').is(':checked')){ if(dodaci_name=="") { spalert = 1; $('#dodName').removeClass(impXStyle).addClass(impStyle); } else { $('#dodName').removeClass("field-style-imp").removeClass("field-style-warn");} if(dodaci_street=="") { spalert = 1; $('#dodUlice').removeClass(impXStyle).addClass(impStyle); } else { $('#dodUlice').removeClass("field-style-imp").removeClass("field-style-warn");} if(dodaci_town=="") { spalert = 1; $('#dodMesto').removeClass(impXStyle).addClass(impStyle); } else { $('#dodMesto').removeClass("field-style-imp").removeClass("field-style-warn");} if(checkpsc(dodaci_psc) == false){ spalert = 1; $('#dodPSC').removeClass(impXStyle).addClass(impStyle); } else { $('#dodPSC').removeClass("field-style-imp").removeClass("field-style-warn");} } else { $('#dodName').removeClass("field-style-imp").removeClass("field-style-warn"); $('#dodUlice').removeClass("field-style-imp").removeClass("field-style-warn"); $('#dodMesto').removeClass("field-style-imp").removeClass("field-style-warn"); $('#dodPSC').removeClass("field-style-imp").removeClass("field-style-warn"); } if(isEmail(mail)==false){ spalert = 1; $('#email').removeClass(impXStyle).addClass(impStyle); } else { $('#email').removeClass("field-style-imp").removeClass("field-style-warn");} if(isTelephone(tel) == false){ spalert = 1; $('#telefon').removeClass(impXStyle).addClass(impStyle); } else { $('#telefon').removeClass("field-style-imp").removeClass("field-style-warn");} $('input[name="doprava"]').parent().css('color', 'black'); if($('input[name="doprava"]').is(':checked')) { } else { spalert = 1; if(isColored){ $('input[name="doprava"]').parent().css('color', 'red'); } } $('input[name="platba"]').parent().css('color', 'black'); if($('input[name="platba"]').is(':checked')) { } else { spalert = 1; if(isColored){ $('input[name="platba"]').parent().css('color', 'red'); } } if(spalert == 0){ objok = true; } else { objok = false; } if(objok == true){ $( ".btn_con_2_n" ).removeClass("continue_btn_G"); } else { $( ".btn_con_2_n" ).addClass("continue_btn_G"); } } var subpod = false; function obchodnipodminky(){ if($('#obchpodminky').is(':checked')){ subpod = true; $(".btn_alert_terms").fadeOut(200); $( ".btn_con_3_n" ).removeClass("continue_btn_G"); } else { subpod = false; $( ".btn_con_3_n" ).addClass("continue_btn_G"); } } $(document).ready(function () { resetForms(); $(".RulesOpenClick").click(function () { $(".overlayCertif").fadeOut(200); $(".overlayRules").fadeIn(200); }); $(".CertifOpenClick").click(function () { $(".overlayRules").fadeOut(200); $(".overlayCertif").fadeIn(200); }); $(".CertifCloseClick").click(function () { $(".overlayCertif").fadeOut(200); }); $(".btn_con_1_n").click(function () { if(totalprice!=0.00){ $(".btn_con_1").fadeOut(200,function(){ $(".btn_con_2").fadeIn(200); }); $(".content_sortiment").fadeOut(200,function(){ $(".content_objednavatel").fadeIn(200); }); $("#head_m_sortiment").removeClass('head_menu_act'); $("#head_m_objednavatel").addClass('head_menu_act'); $(".menu_sortiment").slideUp(200); objchecker(false); if ($(window).width() <= 767) { $(window).scrollTop($('.head_right').offset().top); } } }); $(".btn_con_2_n").click(function () { if(objok==true){ createfin(); $(".btn_con_2").fadeOut(200,function(){ $(".btn_con_3").fadeIn(200); }); $(".content_objednavatel").fadeOut(200,function(){ $(".content_souhrn").fadeIn(200); }); $("#head_m_objednavatel").removeClass('head_menu_act'); $("#head_m_shrnuti").addClass('head_menu_act'); obchodnipodminky(); if ($(window).width() <= 767) { $(window).scrollTop($('.head_right').offset().top); } } else { objchecker(true); } }); $(".btn_con_3_n").click(function () { if(subpod==true){ $(".btn_con_3").fadeOut(200,function(){ $(".btn_con_4").fadeIn(200); }); $("#head_m_shrnuti").removeClass('head_menu_act'); $(".menu_sum_img").slideUp(200); $(".content_souhrn").fadeOut(200); $(".content_right").fadeOut(200); senddata(); if ($(window).width() <= 767) { $(window).scrollTop($('.head_right').offset().top); } } else { $(".btn_alert_terms").fadeIn(100); } }); $(".btn_con_5_n").click(function () { sendrating(); }); $(".btn_con_3_p").click(function () { $(".btn_con_3").fadeOut(200,function(){ $(".btn_con_2").fadeIn(200); }); $(".content_souhrn").fadeOut(200,function(){ $(".content_objednavatel").fadeIn(200); }); $("#head_m_shrnuti").removeClass('head_menu_act'); $("#head_m_objednavatel").addClass('head_menu_act'); objchecker(false); }); $(".btn_con_2_p").click(function () { $(".btn_con_2").fadeOut(200,function(){ $(".btn_con_1").fadeIn(200); }); $(".content_objednavatel").fadeOut(200,function(){ $(".content_sortiment").fadeIn(200); }); $("#head_m_objednavatel").removeClass('head_menu_act'); $("#head_m_sortiment").addClass('head_menu_act'); $(".menu_sortiment").slideDown(200); }); $(".menu_click").click(function () { if($('.nav_menu').css('display') == 'none'){ $('.nav_menu').show(); } else { $('.nav_menu').hide(); } }); $(".menu_item_row").click(function () { if ($(window).width() <= 1080) { if($(this).parent().children(".submenu_content").css('display') == 'none'){ $(".submenu_content").css("display", "none"); $(this).parent().children(".submenu_content").css("display", "block"); } else { $(this).parent().children(".submenu_content").css("display", "none"); } } }); $(".menu_item").hover(function () { if ($(window).width() >= 1080) { $(this).children(".submenu_content").css("display", "block"); } }, function () { if ($(window).width() > 1080) { $(this).children(".submenu_content").css("display", "none"); } }); }); function resetForms() { document.getElementById('Name').value = ''; document.getElementById('IC').value = ''; document.getElementById('DIC').value = ''; document.getElementById('Ulice').value = ''; document.getElementById('Mesto').value = ''; document.getElementById('PSC').value = ''; document.getElementById('dodName').value = ''; document.getElementById('dodUlice').value = ''; document.getElementById('dodMesto').value = ''; document.getElementById('dodPSC').value = ''; document.getElementById('email').value = ''; document.getElementById('telefon').value = ''; document.getElementById('dod_checkbox').checked = true; document.getElementById('obchpodminky').checked = false; document.getElementById('komentar').value = ''; $('input[name=platba]').attr('checked',false); $('input[name=doprava]').attr('checked',false); } function getDataAll(){ var sortiment = []; $( ".hiddenRand" ).each(function() { var randID = $( this ).val(); var groupID = $( this ).parent().children('.hiddenID').val(); $( this ).parent().children('.sItTbl').children('.rwShopItem').each(function() { var itemID = $( this ).children('.id_' + randID).val(); var input = $( this ).children('.sItCellOn').children('.sItCellForm').children('.inp_' + randID).val(); if(input==0 || input==""){ } else { var fullitem = [randID, groupID, itemID, input]; sortiment.push(fullitem); } }); }); var postData = { data : 1, name : $('#Name').attr('value'), IC : $('#IC').attr('value'), DIC : $('#DIC').attr('value'), street : $('#Ulice').attr('value'), town : $('#Mesto').attr('value'), psc : $('#PSC').attr('value'), zeme : $('#Zeme').attr('value'), dod_checkbox : $("#dod_checkbox").is(':checked') ? 1 : 0, dodaci_name : $('#dodName').attr('value'), dodaci_street : $('#dodUlice').attr('value'), dodaci_town : $('#dodMesto').attr('value'), dodaci_psc : $('#dodPSC').attr('value'), dodaci_zeme : $('#dodZeme').attr('value'), obchodpod : $("#obchpodminky").is(':checked') ? 1 : 0, mail : $('#email').attr('value'), tel : $('#telefon').attr('value'), komentar: $('#komentar').val(), doprava : $('input[name="doprava"]:checked').val(), platba : $('input[name="platba"]:checked').val(), sortiment : JSON.stringify(sortiment) }; return postData; } function createfin(){ var postData = getDataAll(); $.ajax({ type: 'POST', url: 'e_shop_souhrn.php', data: postData, success: function (data) { $('.content_souhrn').html(data); }, error: function(err){ alert("Chyba ve zpracování dat. Zkontrolujte své připojení a zkuste to znovu."); } }); } function senddata(){ var postData = getDataAll(); $.ajax({ type: 'POST', url: 'e_shop_mail.php', data: postData, success: function (data) { if(data.split('_')[0]=="OK"){ $('#zakaznikID').val(data.split('_')[1]); setTimeout(function() { $(".content_right").fadeIn(200); $(".content_finish").fadeIn(200); $(".btn_con_4").fadeOut(200,function(){ $(".btn_con_5").fadeIn(200); }); }, 2000); } else { setTimeout(function() { $(".btn_con_4").fadeOut(200); $(".content_right").fadeIn(200); $(".content_error").fadeIn(200); }, 1000); } }, error: function(err){ alert("Chyba ve zpracování dat. Zkontrolujte své připojení a zkuste to znovu."); } }); } function sendrating(){ var postData = { data : 1, sortiment : $('input[name="sortiment"]:checked').val(), design : $('input[name="design"]:checked').val(), obsluznost : $('input[name="obsluznost"]:checked').val(), funkcnost : $('input[name="funkcnost"]:checked').val(), IDzakaznik : $('#zakaznikID').attr('value') }; $.ajax({ type: 'POST', url: 'e_shop_rating.php', data: postData, success: function (data) { $(".menu_left").fadeOut(200); $(".content_finish").fadeOut(200,function(){ $(".content_aftersend").fadeIn(200); }); }, error: function(err){ $(".menu_left").fadeOut(200); $(".content_finish").fadeOut(200,function(){ $(".content_aftersend").fadeIn(200); }); } }); }