let live_invoice_was_emptied=false;
jQuery(document).ready(function($){
if(window.location.search.substring(1)=="popup"){
$.fancybox.open({
src:'#existing-account',
type:'inline',
modal: true
});
}
function getUrlParameter(name){
let params=new URLSearchParams(window.location.search);
return params.has(name);
}
if(getUrlParameter('platce')){
jQuery('.design-proforma select[name="VatRegistrationType"]').val('platce').trigger('change');
}else if(getUrlParameter('neplatce')){
jQuery('.design-proforma select[name="VatRegistrationType"]').val('neplatce').trigger('change');
}
$('.generator-popup .generator-popup__cta a').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_existing_user',
'action': 'cta_clicked'
});
console.log({
'event': 'generator_faktur_existing_user',
'action': 'cta_clicked'
})
});
$('#generator-try-idoklad-header').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_try_idoklad_clicked',
'button_position': 'header'
});
console.log({
'event': 'generator_faktur_try_idoklad_clicked',
'button_position': 'header'
})
});
$('#generator-try-idoklad-body').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_try_idoklad_clicked',
'button_position': 'body'
});
console.log({
'event': 'generator_faktur_try_idoklad_clicked',
'button_position': 'body'
})
});
$('#generator-try-idoklad-limit-reached').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_try_idoklad_clicked',
'button_position': 'limit_reached'
});
console.log({
'event': 'generator_faktur_try_idoklad_clicked',
'button_position': 'limit_reached'
})
});
$('#generator-want-free-invoice').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_summary_cta_clicked'
});
console.log({
'event': 'generator_faktur_summary_cta_clicked'
})
});
$('#generator-try-miniacademy').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_miniakademie_entered'
});
console.log({
'event': 'generator_faktur_miniakademie_entered'
})
});
$('.generator-miniakademie__item-video').on('click', function(){
let lesson_number=$(this).closest('.generator-miniakademie__item').data('number');
let lesson_title=$(this).closest('.generator-miniakademie__item').find('.generator-miniakademie__item-title span').text();
dataLayer.push({
'event': 'generator_faktur_miniakademie_video_started',
'lesson_number': lesson_number * 1,
'lesson_title': lesson_title
});
console.log({
'event': 'generator_faktur_miniakademie_video_started',
'lesson_number': lesson_number * 1,
'lesson_title': lesson_title
})
});
loadData();
$localstorage_counter_value=localStorage.getItem("idoklad_generator_counter");
if($localstorage_counter_value==null){
jQuery('.design-proforma__loading').hide();
jQuery('.design-proforma__generator').slideDown();
}else if(parseInt($localstorage_counter_value) >=5){
jQuery('.design-proforma__loading').hide();
jQuery('.design-proforma__generator').remove();
jQuery('.design-proforma__limit[data-limit="5"]').slideDown();
dataLayer.push({
'event': 'generator_faktur_limit_reached',
'type': 'page_loaded'
});
console.log({
'event': 'generator_faktur_limit_reached',
'type': 'page_loaded'
})
}else if(parseInt($localstorage_counter_value) >=10){
}else{
jQuery('.design-proforma__loading').hide();
jQuery('.design-proforma__generator').slideDown();
}
jQuery('.design-proforma__limit-continue').on('click', function(){
jQuery('.design-proforma__limit[data-limit="5"]').slideUp();
jQuery('.design-proforma__generator').slideDown();
})
jQuery("#step1 .actionLoadAres").on('click', function (e){
e.preventDefault();
let ic=jQuery("#company-id").val();
if(ic.length==0){
$.fancybox.open({
src:'<div class="message"><p>Pro načtení údajů z ARESu prosím zadejte IČ.</p></div>',
type:'html',
smallBtn:true
});
return false;
}
jQuery.ajax({
url: servicesUrl + "load-ares.php",
type: "POST",
dataType: "json",
cache: false,
data: {
company_id: ic,
country: (jQuery("#address-country").val()=="Česká republika" ? "CZ":"SK")
}}).done(function (response, textStatus, jqXHR){
if(response==null||response=="null"){
$.fancybox.open({
src:'<div class="message"><p>Subjekt se zadaným IČ ' + ic + ' se nepodařilo vyhledat.</p></div>',
type:'html',
smallBtn:true
});
return false;
}
let json=response;
let data=json["Record"];
if(data&&data["CompanyName"]){
let street=data["Address"]["Street"];
if(street.length==0) street=data["Address"]["City"];
jQuery('input[name="company-name"]').val(data["CompanyName"]).trigger('change');
jQuery('input[name="address-street"]').val(street + ' ' + data["Address"]["HouseNumber"]).trigger('change');
jQuery('input[name="address-postal"]').val(data["Address"]["PostalCode"]).trigger('change');
jQuery('input[name="address-city"]').val(data["Address"]["City"]).trigger('change');
if(data["IsIdentifiedPersonForVat"]==true){
jQuery('input[name="company_vatid"]').val(data["VatInfo"]["VatIdentificationNumber"]).trigger('change');
jQuery('select[name="VatRegistrationType"]').val(2).trigger('change');
jQuery('select[name="VatRegistrationType"]').data("selectBox-selectBoxIt").refresh();
}else if(data["VatInfo"]["VatPayerStatus"]=="11"){
jQuery('input[name="company_vatid"]').val(data["VatInfo"]["VatIdentificationNumber"]).trigger('change');
}}
}).fail(function(){
$.fancybox.open({
src:'<div class="message"><p>Subjekt se zadaným IČ ' + ic + ' se nepodařilo vyhledat.</p></div>',
type:'html',
smallBtn:true
});
return false;
});
return false;
});
jQuery("#step1 .actionNextStep").on('click', function (e){
e.preventDefault();
if(validateInputs(jQuery("#step1"))){
$("#step1 .actionNextStep").prop("disabled", true);
$("#step1 .actionNextStep").removeClass("site-button--borderprimary");
$("#step1 .actionNextStep").text("Probíhá kontrola zadaných údajů...");
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_customer',
'validity': 'valid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_customer',
'validity': 'valid'
})
jQuery.ajax({
url: '/wp-content/themes/solitea-idoklad/services/' + "generate-invoice-check-limit.php",
type: "POST",
dataType: "json",
cache: false,
data: {
supplier_ic:jQuery('.design-proforma input[name="company-id"]').val(),
supplier_email:jQuery('.design-proforma input[name="email"]').val()
}}).done(function (data){
if(data.allowed=="false"){
$("#step1 .actionNextStep").prop("disabled", false);
$("#step1 .actionNextStep").addClass("site-button--borderprimary");
$("#step1 .actionNextStep").text("Pokračujte na odběratele");
jQuery('.design-proforma__generator').remove();
jQuery('.design-proforma__limit[data-limit="5"]').slideDown();
localStorage.setItem("idoklad_generator_counter", 5);
dataLayer.push({
'event': 'generator_faktur_limit_reached',
'type': 'supplier_control'
});
console.log({
'event': 'generator_faktur_limit_reached',
'type': 'supplier_control'
})
}else if(data.allowed=="true"){
jQuery.ajax({
url: '/wp-content/themes/solitea-idoklad/services/' + "existing-idoklad-account-checker-v2.php",
type: "POST",
dataType: "json",
cache: false,
data: {
emailaddress:jQuery('.design-proforma input[name="email"]').val()
}}).done(function (data){
console.log(data)
if(data==false){
jQuery.ajax({
url: '/wp-content/themes/solitea-idoklad/services/' + "generate-invoice-last-invoice-number.php",
type: "POST",
dataType: "json",
cache: false,
data: {
supplier_ic:jQuery('.design-proforma input[name="company-id"]').val(),
supplier_email:jQuery('.design-proforma input[name="email"]').val()
}}).done(function (data){
console.log(data.new);
$('.design-proforma input[name="invoice-serialnumber"]').val(data.new)
$("#step1 .actionNextStep").prop("disabled", false);
$("#step1 .actionNextStep").addClass("site-button--borderprimary");
$("#step1 .actionNextStep").text("Pokračujte na odběratele");
jQuery("#step2").removeClass("design-proforma__item--notallowed");
jQuery("#step2").find('.design-proforma__item-header').trigger('click');
});
}else if(data==true){
$.fancybox.open({
src:'#existing-account',
type:'inline',
modal: true
});
dataLayer.push({
'event': 'generator_faktur_existing_user',
'action': 'popup_viewed'
});
console.log({
'event': 'generator_faktur_existing_user',
'action': 'popup_viewed'
})
$("#step1 .actionNextStep").prop("disabled", false);
$("#step1 .actionNextStep").addClass("site-button--borderprimary");
$("#step1 .actionNextStep").text("Pokračujte na odběratele");
}});
}});
}else{
$.fancybox.open({
src:'<div class="message"><p>Před pokračováním prosím doplňte či opravte data ve formuláři.</p></div>',
type:'html',
smallBtn:true
});
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_customer',
'validity': 'invalid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_customer',
'validity': 'invalid'
})
}
return false;
});
jQuery("#step2 .actionLoadBuyerAres").on('click', function (e){
e.preventDefault();
let ic=jQuery("#buyer-company-id").val();
if(ic.length==0){
$.fancybox.open({
src:'<div class="message"><p>Pro načtení údajů z ARESu prosím zadejte IČ.</p></div>',
type:'html',
smallBtn:true
});
return false;
}
jQuery.ajax({
url: servicesUrl + "load-ares.php",
type: "POST",
dataType: "json",
cache: false,
data: {
company_id: ic,
country: (jQuery("#buyer-country").val()=="Česká republika" ? "CZ":"SK")
}}).done(function (response, textStatus, jqXHR){
if(response==null||response=="null"){
$.fancybox.open({
src:'<div class="message"><p>Subjekt se zadaným IČ ' + ic + ' se nepodařilo vyhledat.</p></div>',
type:'html',
smallBtn:true
});
return false;
}
let json=response;
let data=json["Record"];
if(data&&data["CompanyName"]){
let street=data["Address"]["Street"];
if(street.length==0) street=data["Address"]["City"];
jQuery('input[name="buyer-company-name"]').val(data["CompanyName"]).trigger('change');
jQuery('input[name="buyer-address-street"]').val(street + ' ' + data["Address"]["HouseNumber"]).trigger('change');
jQuery('input[name="buyer-address-postal"]').val(data["Address"]["PostalCode"]).trigger('change');
jQuery('input[name="buyer-address-city"]').val(data["Address"]["City"]).trigger('change');
if(data["IsIdentifiedPersonForVat"]==true){
jQuery('input[name="buyer-company-vatid"]').val(data["VatInfo"]["VatIdentificationNumber"]).trigger('change');
}else if(data["VatInfo"]["VatPayerStatus"]=="11"){
jQuery('input[name="buyer-company-vatid"]').val(data["VatInfo"]["VatIdentificationNumber"]).trigger('change');
}}
}).fail(function(){
$.fancybox.open({
src:'<div class="message"><p>Subjekt se zadaným IČ ' + ic + ' se nepodařilo vyhledat.</p></div>',
type:'html',
smallBtn:true
});
return false;
});
return false;
});
jQuery("#step2 .actionNextStep").on('click', function (e){
e.preventDefault();
if(validateInputs(jQuery("#step2"))){
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_payment_details',
'validity': 'valid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_payment_details',
'validity': 'valid'
})
$("#step3").removeClass("design-proforma__item--notallowed");
$("#step3").find('.design-proforma__item-header').trigger('click');
jQuery('.design-proforma select[name="payment-method"]').trigger('change');
jQuery('.design-proforma input[name="invoice-variable"]').trigger('change');
}else{
$.fancybox.open({
src:'<div class="message"><p>Před pokračováním prosím doplňte či opravte data ve formuláři.</p></div>',
type:'html',
smallBtn:true
});
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_payment_details',
'validity': 'invalid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_payment_details',
'validity': 'invalid'
})
}
return false;
});
jQuery("#BankCode").select2({
tags: true,
width: '100%'
});
jQuery("#step3 .actionNextStep").on('click', function (e){
e.preventDefault();
if(validateInputs(jQuery("#step3"))){
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_items',
'validity': 'valid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_items',
'validity': 'valid'
})
if($('.design-proforma__table-main tr.item[data-item="1"]').length==0){
$('.design-proforma__table-addline.actionAddItem').click();
}
$("#step4").removeClass("design-proforma__item--notallowed");
$("#step4").find('.design-proforma__item-header').trigger('click');
}else{
$.fancybox.open({
src:'<div class="message"><p>Před pokračováním prosím doplňte či opravte data ve formuláři.</p></div>',
type:'html',
smallBtn:true
});
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_items',
'validity': 'invalid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_items',
'validity': 'invalid'
})
}
return false;
});
$('.design-proforma select[name="payment-method"]').on('change', function(){
let selectedPaymentMethod=jQuery(this).find(":selected").val();
if(selectedPaymentMethod=="Převodem"){
jQuery('input[name="BankAccount"]').data('required', 1);
jQuery('input[name="BankAccount"]').attr('data-required', 1);
jQuery('input[name="BankAccount"]').parent().find('.required-star').show();
jQuery('select[name="BankCode"]').data('required', 1);
jQuery('select[name="BankCode"]').attr('data-required', 1);
jQuery('select[name="BankCode"]').parent().find('.required-star').show();
}else{
jQuery('input[name="BankAccount"]').data('required', 0);
jQuery('input[name="BankAccount"]').attr('data-required', 0);
jQuery('input[name="BankAccount"]').parent().find('.required-star').hide();
jQuery('select[name="BankCode"]').data('required', 0);
jQuery('select[name="BankCode"]').attr('data-required', 0);
jQuery('select[name="BankCode"]').parent().find('.required-star').hide();
}});
jQuery("#step4 .actionAddItem").click(function (e){
e.preventDefault();
if(jQuery('.design-proforma__table-main tr.item:not(.hidden)').length < 9){
step2AddNewItem();
}else{
$.fancybox.open({
src:'<div class="message"><p>Byl dosažen maximální limit počtu položek faktury v bezplatném generátoru. Pokud potřebujete vystavit fakturu s více položkami, <a href="https://app.idoklad.cz/Account/Registration" target="_blank">vyzkoušejte zdarma náš fakturační program iDoklad</a>.</p></div>',
type:'html',
smallBtn:true
});
}
return false;
});
jQuery("#step4").on("click", ".actionDeleteItem", function (e){
e.preventDefault();
var itemNumber=jQuery(this).closest("tr").attr("data-item");
jQuery("#step4 .items tr[data-item='" + itemNumber + "']").remove();
let newNumber=itemNumber * 1;
console.log(newNumber)
for (let row=1; row <=9; row++){
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_name tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_price tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_quantity tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_unit tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_price_total tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_tax tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_price_without_tax tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_price_only_tax tspan').html('');
}
jQuery("#step4 .items .item:not(.hidden)").each(function(index){
let curNum=index + 1;
jQuery(this).attr('data-item', curNum)
jQuery(this).data('item', curNum);
jQuery(this).find('input[name="item[name]"]').trigger('click');
jQuery(this).find('input[name="item[price]"]').trigger('click');
jQuery(this).find('input[name="item[count]"]').trigger('click');
jQuery(this).find('input[name="item[unit]"]').trigger('click');
})
countInvoiceTotalPrice();
return false;
});
jQuery(document).on('change keyup keydown keypress click', '.design-proforma .items table input[name="item[price]"], .design-proforma .items table input[name="item[count]"], .design-proforma .items table select[name="item[tax]"]', function(){
let item_number=jQuery(this).closest('tr.item').data('item');
countItemTotalPrice(item_number);
});
jQuery("#step4 .actionNextStep").on('click', function (e){
e.preventDefault();
if(validateInputs(jQuery("#step4"))){
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_dates',
'validity': 'valid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_dates',
'validity': 'valid'
})
$("#step5").removeClass("design-proforma__item--notallowed");
$("#step5").find('.design-proforma__item-header').trigger('click');
$(".design-proforma #invoice-serialnumber").trigger('click');
$(".design-proforma #issue-date").trigger('click');
$(".design-proforma #due-date").trigger('click');
$(".design-proforma #tax-date").trigger('click');
}else{
$.fancybox.open({
src:'<div class="message"><p>Před pokračováním prosím doplňte či opravte data ve formuláři.</p></div>',
type:'html',
smallBtn:true
});
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_dates',
'validity': 'invalid'
});
console.log({
'event': 'generator_faktur_form_engaged',
'button_label': 'continue_to_invoice_dates',
'validity': 'invalid'
})
}
return false;
});
jQuery(document).on('change', '.design-proforma #issue-date, .design-proforma #due-date', function(){
let issue_date=jQuery('.design-proforma #issue-date').val();
let due_date=jQuery('.design-proforma #due-date').val();
if(issue_date > due_date){
$.fancybox.open({
src:'<div class="message"><p>Zadané datum splatnosti faktury předchází datu vystavení faktury. Nezapomeňte prosím opravit tuto chybu.</p></div>',
type:'html',
smallBtn:true
});
}});
$('html').on('dragover', function(e){
e.stopPropagation();
e.preventDefault();
});
$('.design-proforma label[for=logo], .design-proforma label[for=razitko]').on('dragenter', function (e){
e.stopPropagation();
e.preventDefault();
});
$('.design-proforma label[for=logo], .design-proforma label[for=razitko]').on('dragover', function (e){
e.stopPropagation();
e.preventDefault();
});
$('.design-proforma label[for=logo]').on('drop', function(e){
e.stopPropagation();
e.preventDefault();
uploadImageFile(e.originalEvent.dataTransfer.files[0], '#logo_nahled');
});
$('.design-proforma #logo').on('change', function(){
let file=$(this).prop("files")[0];
uploadImageFile(file, '#logo_nahled');
})
$('.design-proforma label[for=razitko]').on('drop', function(e){
e.stopPropagation();
e.preventDefault();
uploadImageFile(e.originalEvent.dataTransfer.files[0], '#razitko_nahled');
});
$('.design-proforma #razitko').on('change', function(){
let file=$(this).prop("files")[0];
uploadImageFile(file, '#razitko_nahled');
})
function uploadImageFile(file, id){
let form=new FormData();
form.append("image", file);
$.ajax({
url: '/wp-content/themes/solitea-idoklad/services/' + "invoice-generator-image-file-upload.php",
type: "POST",
data: form,
contentType: false,
processData: false,
success: function(result){
let data=JSON.parse(result);
$('.design-proforma .design-proforma__file ' + id).empty();
$('.design-proforma .design-proforma__file ' + id).append('<img src="' + data[0]['url'] + '">');
if(id=="#logo_nahled"){
$('.design-proforma__template #template_invoice_logo').attr('xlink:href', data[0]['url']);
}else if(id=="#razitko_nahled"){
$('.design-proforma__template #template_invoice_signature').attr('xlink:href', data[0]['url']);
}}
});
}
function step2AddNewItem(){
var newIndex=parseInt(jQuery("#step4 .items table tr:last").attr("data-item")) + 1;
var $item=jQuery("#step4 .items tr.itemTemplate").clone();
$item.attr("data-item", newIndex);
$item.removeClass("hidden");
$item.removeClass("itemTemplate");
$item.appendTo("#step4 .items table");
$item.find("select").select2(
{
minimumResultsForSearch: 5,
dropdownParent: jQuery('table.design-proforma__table-main'),
width: '100%',
}
);
jQuery(document.body).on("change",".taxProperty select",function(){
});
var $discount=jQuery("#step2 .items tr.discountTemplate").clone();
$discount.attr("data-item", newIndex);
$discount.removeClass("discountTemplate");
$discount.appendTo("#step2 .items table");
}
function validateInputs($parent){
var hasErrors=false;
jQuery(".design-proforma__formbox").removeClass("hasError");
jQuery(".design-proforma__formbox").removeClass("hasFormatError");
$parent.find("input[data-required='1'],textarea[data-required='1'],select[data-required='1']").each(function (){
if(jQuery(this).is(":visible")&&removeNewLines(jQuery(this).val()).length==0){
if(!jQuery(this).closest(".design-proforma__formbox").hasClass("hasFormatError")){
jQuery(this).closest(".design-proforma__formbox").addClass("hasError");
}
jQuery(this).removeAttr("style");
if(!jQuery(this).closest(".design-proforma__table").hasClass("hasFormatError")){
jQuery(this).closest(".design-proforma__table").addClass("hasError");
jQuery(this).css('border', '1px solid #f00');
}
hasErrors=true;
}});
$parent.find("[data-format='ic']").each(function (){
if(jQuery(this).is(":visible")&&jQuery(this).val().length > 0){
var ic=jQuery(this).val();
var country=(jQuery("#address-country").val()=="Česká republika" ? "CZ":"SK");
if(!validateIC(ic, country)){
console.log('nevalidni ico')
jQuery(this).closest(".design-proforma__formbox").addClass("hasFormatError");
hasErrors=true;
}}
});
$parent.find("[data-format='bankcode']").each(function (){
if(jQuery(this).is(":visible")&&jQuery(this).val().length > 0){
if(jQuery(this).val().length==4){
var codeFound=false;
for (var i=0; i < bank_codes.length; i++){
var bank=bank_codes[i];
var bankCode=jQuery(this).val();
if(bankCode==bank.Code){
codeFound=true;
break;
}}
if(!codeFound){
jQuery(this).closest(".invoice-reg__form-box").addClass("hasFormatError");
hasErrors=true;
}}else{
jQuery(this).closest(".invoice-reg__form-box").addClass("hasFormatError");
hasErrors=true;
}}
});
$parent.find("[data-format='bankaccount']").each(function (){
if(jQuery(this).is(":visible")&&jQuery(this).val().length > 0){
var bankaccountnum=jQuery(this).val();
if(!onlyNumbers(bankaccountnum)){
jQuery(this).closest(".invoice-reg__form-box").addClass("hasFormatError");
hasErrors=true;
}}
});
$parent.find("[data-format='email']").each(function (){
if(jQuery(this).is(":visible")&&jQuery(this).val().length > 0){
if(!validateEmail(jQuery(this).val())||jQuery(this).hasClass("foxentry-input-invalid")){
jQuery(this).closest(".invoice-reg__form-box").addClass("hasFormatError");
hasErrors=true;
}}
});
$parent.find("[data-format='multiemail']").each(function (){
if(jQuery(this).is(":visible")&&jQuery(this).val().length > 0){
if(!validateMultiEmail(jQuery(this).val())){
jQuery(this).closest(".invoice-reg__form-box").addClass("hasFormatError");
hasErrors=true;
}}
});
return !hasErrors;
}
function refreshSelects(){
jQuery("select").each(function (){
if(jQuery(this).hasClass("select2-hidden-accessible")!=null){
$(this).select2("destroy");
$(this).select2();
}});
}
function animateScroll($target, minus){
if(minus==null) minus=0;
$root.animate({
scrollTop: $target.offset().top - minus
}, 500);
}
function numberSpaces(number){
return number.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ')
}
function validateIC(ic, country){
var result=false;
if(country!="CZ"&&country!="SK") return true;
jQuery.ajax({
url: servicesUrl + "load-ares.php",
type: "POST",
dataType: "json",
cache: false,
async: false,
data: {
company_id: ic,
country: country
}}).done(function (response, textStatus, jqXHR){
if(response==null||response=="null"){
result=false;
}else{
result=true;
}});
return result;
}
function validateDate(date){
if(date.length!=10) return false;
var dateParts=date.toString().split(".");
if(dateParts.length!=3) return false;
var day=parseInt(dateParts[0]);
if(day > 31||day < 1) return false;
var month=parseInt(dateParts[1]);
if(month > 12||month < 1) return false;
var year=parseInt(dateParts[2]);
if(year > 2050||year < 1900) return false;
return true;
}
function validateEmail(email){
var re=/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(email);
}
function validateMultiEmail(emails){
var text=emails.toString();
while (text.indexOf(";") > 0){
text=text.replace(";", ",");
}
while (text.indexOf(" ") > 0){
text=text.replace(" ", "");
}
var isValid=true;
emails=text.split(",");
for (var i=0; i < emails.length; i++){
if(!validateEmail(emails[i])) isValid=false;
}
return isValid;
}
function validatePhone(phone){
var re=/^(\+[0-9]{1,3})?()?[0-9]{3}()?[0-9]{3}()?[0-9]{3}$/;
return re.test(phone);
}
function removeNewLines(text){
var result=text;
while (result.indexOf("\r") > -1){
result=result.replace("\r", "");
}
while (result.indexOf("\n") > -1){
result=result.replace("\n", "");
}
return result;
}
function getUniqueId(){
return Math.round(new Date().getTime() + (Math.random() * 100));
}
function numberWithSeparator(x){
return x.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1 ')
}
function numberWithComma(x){
return x.toString().replace(".", ",")
}
function dateToTime(date){
if(date.length!=10) return 0;
date=date.split(".");
var day=parseInt(date[0]);
var month=parseInt(date[1]);
var year=parseInt(date[2]);
return (new Date(year, month - 1, day, 0, 0, 1)).getTime();
}
function onlyNumbers(str){
return /^[\d\-]+$/.test(str);
}
$('.design-proforma select[name="VatRegistrationType"], .design-proforma input[name="color2"]').on('change', function(){
generateInvoiceThumbnailAndPrepareItemsTable();
});
$('.design-proforma select[name="VatRegistrationType"]').on('change', function(){
let vat_registration_type=$('.design-proforma select[name="VatRegistrationType"]').val();
if(vat_registration_type=='neplatce'){
jQuery('.design-proforma__tax-date').addClass('design-proforma__tax-date--invisible');
$('.design-proforma__template #template_invoice_total_price_label').attr('transform', 'translate(1274 2746)');
$('.design-proforma__template #template_invoice_total_price').attr('transform', 'translate(2090 2746)');
$('.design-proforma__template #template_invoice_items_quantity').attr('transform', 'translate(1399 1743)');
$('.design-proforma__template #template_invoice_items_unit').attr('transform', 'translate(1687 1743)');
$('.design-proforma__template #template_invoice_items_price').attr('transform', 'translate(1796 1743)');
$('.design-proforma__template #template_invoice_items_tax').hide();
$('.design-proforma__template #template_invoice_items_price_without_tax').hide();
$('.design-proforma__template #template_invoice_items_price_only_tax').hide();
$('.design-proforma__template #template_invoice_tax_date_label').hide();
$('.design-proforma__template #template_invoice_tax_date').hide();
$('.design-proforma__template #template_vat_rates').hide();
for (let i=1; i <=9; i++){
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_quantity').attr('transform', 'translate(1463 1818)');
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_unit').attr('transform', 'translate(1687 1818)');
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_price').attr('transform', 'translate(1962 1818)');
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_tax').hide();
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_price_without_tax').hide();
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_price_only_tax').hide();
countItemTotalPrice(i);
}}else{
jQuery('.design-proforma__tax-date').removeClass('design-proforma__tax-date--invisible');
$('.design-proforma__template #template_invoice_total_price_label').attr('transform', 'translate(1274 3050)');
$('.design-proforma__template #template_invoice_total_price').attr('transform', 'translate(2090 3050)');
$('.design-proforma__template #template_invoice_items_quantity').attr('transform', 'translate(670 1743)');
$('.design-proforma__template #template_invoice_items_unit').attr('transform', 'translate(930 1743)');
$('.design-proforma__template #template_invoice_items_price').attr('transform', 'translate(1035 1743)');
$('.design-proforma__template #template_invoice_items_tax').show();
$('.design-proforma__template #template_invoice_items_price_without_tax').show();
$('.design-proforma__template #template_invoice_items_price_only_tax').show();
$('.design-proforma__template #template_invoice_tax_date_label').show();
$('.design-proforma__template #template_invoice_tax_date').show();
$('.design-proforma__template #template_vat_rates').show();
for (let i=1; i <=9; i++){
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_quantity').attr('transform', 'translate(729 1818)');
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_unit').attr('transform', 'translate(940 1818)');
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_price').attr('transform', 'translate(1200 1818)');
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_tax').show();
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_price_without_tax').show();
$('.design-proforma__template #template_invoice_items_' + i + '_invoice_item_price_only_tax').show();
countItemTotalPrice(i);
}}
$(".design-proforma #invoice-serialnumber").trigger('click');
$(".design-proforma #issue-date").trigger('click');
$(".design-proforma #due-date").trigger('click');
$(".design-proforma #tax-date").trigger('click');
countInvoiceTotalPrice();
});
$('.design-proforma .design-proforma__item--toggle .design-proforma__item-header').on('click', function(){
if(!$(this).parent().hasClass('design-proforma__item--notallowed')){
let item_id=$(this).parent().attr('id');
if($(this).parent().hasClass('design-proforma__item--closed')){
$('.design-proforma .design-proforma__item--toggle').each(function(){
if($(this).is('#' + item_id)){
$(this).removeClass('design-proforma__item--closed');
$(this).find('.design-proforma__item-content').slideDown();
}else{
$(this).addClass('design-proforma__item--closed');
$(this).find('.design-proforma__item-content').slideUp();
}})
}else{
}}
});
$('.design-proforma #text_before').on('ifChecked', function(){
$('.design-proforma #text_before_area').slideDown();
});
$('.design-proforma #text_before').on('ifUnchecked', function(){
$('.design-proforma #text_before_area').slideUp();
});
$('.design-proforma #text_after').on('ifChecked', function(){
$('.design-proforma #text_after_area').slideDown();
});
$('.design-proforma #text_after').on('ifUnchecked', function(){
$('.design-proforma #text_after_area').slideUp();
});
$('.design-proforma .design-proforma__submit button').on('click', function(){
jQuery('.design-proforma .design-proforma__submit button').hide();
jQuery('.design-proforma .design-proforma__submit-failed').hide();
jQuery('.design-proforma .design-proforma__submit-wait').show();
if(validateInputs(jQuery("#step1"))&&validateInputs(jQuery("#step2"))&&validateInputs(jQuery("#step3"))&&validateInputs(jQuery("#step4"))&&validateInputs(jQuery("#step5"))){
}else{
$.fancybox.open({
src:'<div class="message"><p>Nelze vytvořit fakturu, protože nejsou vyplněna všechna povinná pole nebo neodpovídají požadovanému formátu. Prosím, zkontrolujte a opravte tato pole.</p></div>',
type:'html',
smallBtn:true
});
jQuery('.design-proforma .design-proforma__submit-wait').hide();
jQuery('.design-proforma .design-proforma__submit button').show();
return -1;
}
if(jQuery('.design-proforma #submit-save').is(":checked")){
saveData();
}else{
removeData();
}
jQuery.ajax({
url: '/wp-content/themes/solitea-idoklad/services/' + "generate-invoice-check-limit.php",
type: "POST",
dataType: "json",
cache: false,
data: {
supplier_ic:jQuery('.design-proforma input[name="company-id"]').val(),
supplier_email:jQuery('.design-proforma input[name="email"]').val()
}}).done(function (data){
if(data.allowed=="false"){
jQuery('.design-proforma__generator').remove();
jQuery('.design-proforma__limit[data-limit="5"]').slideDown();
localStorage.setItem("idoklad_generator_counter", 5);
dataLayer.push({
'event': 'generator_faktur_limit_reached',
'type': 'control_before_invoice_generation'
});
console.log({
'event': 'generator_faktur_limit_reached',
'type': 'control_before_invoice_generation'
})
}else if(data.allowed=="true"){
let vat_registration_type=$('.design-proforma select[name="VatRegistrationType"]').val();
let invoice_color=$('.design-proforma input[name="color2"]:checked').val();
let supplier_ic=$('.design-proforma input[name="company-id"]').val();
let supplier_dic=$('.design-proforma input[name="company_vatid"]').val();
let supplier_company=$('.design-proforma input[name="company-name"]').val();
let supplier_email=$('.design-proforma input[name="email"]').val();
let supplier_phone=$('.design-proforma input[name="phone"]').val();
let supplier_address=$('.design-proforma input[name="address-street"]').val();
let supplier_city=$('.design-proforma input[name="address-city"]').val();
let supplier_psc=$('.design-proforma input[name="address-postal"]').val();
let supplier_country=$('.design-proforma select[name="address-country"]').val();
let customer_ic=$('.design-proforma input[name="buyer-company-id"]').val();
let customer_dic=$('.design-proforma input[name="buyer-company-vatid"]').val();
let customer_company=$('.design-proforma input[name="buyer-company-name"]').val();
let customer_country=$('.design-proforma select[name="buyer-country"]').val();
let customer_name=$('.design-proforma input[name="buyer-contact-name"]').val();
let customer_surname=$('.design-proforma input[name="buyer-contact-surname"]').val();
let customer_email=$('.design-proforma input[name="buyer-contact-email"]').val();
let customer_phone=$('.design-proforma input[name="buyer-contact-phone"]').val();
let customer_address=$('.design-proforma input[name="buyer-address-street"]').val();
let customer_city=$('.design-proforma input[name="buyer-address-city"]').val();
let customer_psc=$('.design-proforma input[name="buyer-address-postal"]').val();
let payment_method=$('.design-proforma select[name="payment-method"]').val();
let payment_bank_account_number=$('.design-proforma input[name="BankAccount"]').val();
let payment_bank_code=$('.design-proforma select[name="BankCode"]').val();
let payment_variable_symbol=$('.design-proforma input[name="invoice-variable"]').val();
let payment_constant_symbol=$('.design-proforma input[name="ConstantSymbolId"]').val();
let text_before_items=$('.design-proforma input[name="text_before"]').is(':checked');
let text_before_items_value=$('.design-proforma textarea[name="invoice-textbeforeitems"]').val();
let invoice_items=[];
$('.design-proforma .items table tbody tr.item:not(.hidden)').each(function(){
let invoice_item_name=$(this).find('input[name="item[name]"]').val();
let invoice_item_price=$(this).find('input[name="item[price]"]').val();
let invoice_item_quantity=$(this).find('input[name="item[count]"]').val();
let invoice_item_unit=$(this).find('input[name="item[unit]"]').val();
let invoice_item_tax=$(this).find('select[name="item[tax]"]').val();
let invoice_item_price_total=invoice_item_price * invoice_item_quantity;
invoice_items.push({
invoice_item_name: invoice_item_name,
invoice_item_price: invoice_item_price,
invoice_item_quantity: invoice_item_quantity,
invoice_item_unit: invoice_item_unit,
invoice_item_tax: invoice_item_tax,
invoice_item_price_total: invoice_item_price_total
});
})
let text_after_items=$('.design-proforma input[name="text_after"]').is(':checked');
let text_after_items_value=$('.design-proforma textarea[name="invoice-textafteritems"]').val();
let invoice_number=$('.design-proforma input[name="invoice-serialnumber"]').val();
let invoice_creation_date=$('.design-proforma input[name="issue-date"]').val();
let invoice_due_date=$('.design-proforma input[name="due-date"]').val();
let invoice_taxable_supply_date=$('.design-proforma input[name="tax-date"]').val();
let invoice_logo=$('.design-proforma #logo_nahled img').attr('src');
let invoice_signature=$('.design-proforma #razitko_nahled img').attr('src');
let invoice_data={
vat_registration_type:vat_registration_type,
invoice_color:invoice_color,
supplier_ic:supplier_ic,
supplier_dic:supplier_dic,
supplier_company:supplier_company,
supplier_email:supplier_email,
supplier_phone:supplier_phone,
supplier_address:supplier_address,
supplier_city:supplier_city,
supplier_psc:supplier_psc,
supplier_country:supplier_country,
customer_ic:customer_ic,
customer_dic:customer_dic,
customer_company:customer_company,
customer_country:customer_country,
customer_name:customer_name,
customer_surname:customer_surname,
customer_email:customer_email,
customer_phone:customer_phone,
customer_address:customer_address,
customer_city:customer_city,
customer_psc:customer_psc,
payment_method:payment_method,
payment_bank_account_number:payment_bank_account_number,
payment_bank_code:payment_bank_code,
payment_variable_symbol:payment_variable_symbol,
payment_constant_symbol:payment_constant_symbol,
text_before_items:text_before_items,
text_before_items_value:text_before_items_value,
invoice_items:JSON.stringify(invoice_items),
text_after_items:text_after_items,
text_after_items_value:text_after_items_value,
invoice_number:invoice_number,
invoice_creation_date:invoice_creation_date,
invoice_due_date:invoice_due_date,
invoice_taxable_supply_date:invoice_taxable_supply_date,
invoice_logo:invoice_logo,
invoice_signature:invoice_signature
}
console.log(invoice_data)
$.ajax({
url: '/wp-content/themes/solitea-idoklad/services/' + "generate-invoice.php",
type: "POST",
cache: false,
data: invoice_data
}).done(function (data){
let response=JSON.parse(data);
console.log(response)
if(response.pdf_status=="OK"&&response.db_status=="OK"&&response.db_status_counter=="OK"&&response.smartemailing_status=="created"){
console.log(response.file);
console.log(response.file_direct_url);
$('.design-proforma .design-proforma__generator').hide();
$("html").animate({
scrollTop: $("#generator-faktur").offset().top - 100
},
800,
function(){
$('.design-proforma .design-proforma__thxbox').slideDown();
downloadURI(response.file, (response.file).substring((response.file).lastIndexOf('/')+1));
jQuery('.design-proforma .design-proforma__submit-wait').hide();
jQuery('.design-proforma .design-proforma__submit button').show();
}
);
let current_generator_counter=0;
if(localStorage.getItem("idoklad_generator_counter")!==null){
current_generator_counter=localStorage.getItem("idoklad_generator_counter");
}
let new_generator_counter=parseInt(current_generator_counter) + 1;
localStorage.setItem("idoklad_generator_counter", new_generator_counter);
dataLayer.push({
'event': 'generator_faktur_invoice_downloaded',
'generated_invoices_counter': new_generator_counter * 1
});
console.log({
'event': 'generator_faktur_invoice_downloaded',
'generated_invoices_counter': new_generator_counter * 1
})
}else{
jQuery('.design-proforma .design-proforma__submit-wait').hide();
jQuery('.design-proforma .design-proforma__submit button').show();
jQuery('.design-proforma .design-proforma__submit-failed').slideDown();
}});
}});
});
$('.design-proforma .design-proforma__thx #create-new-invoice').on('click', function(){
dataLayer.push({
'event': 'generator_faktur_create_new_invoice'
});
console.log({
'event': 'generator_faktur_create_new_invoice'
})
location.reload();
})
$('.design-proforma #submit-save').on('ifChecked', function(){
saveData();
});
$('.design-proforma #submit-save').on('ifUnchecked', function(){
removeData();
});
$('.design-proforma__template').on('click', function(){
$(this).find('.template').toggleClass('template--hidden');
})
$('.design-proforma input, .design-proforma select, .design-proforma textarea').on('click change keydown keyup keypress ifChecked ifUnchecked', function(){
let current_field_id=$(this).attr('id');
let current_field_value=$(this).val();
updateLiveInvoice(current_field_id, current_field_value)
});
$(document).on('click change keydown keyup keypress', '.design-proforma input[name="item[name]"], .design-proforma input[name="item[price]"], .design-proforma input[name="item[count]"], .design-proforma input[name="item[unit]"]', function(){
let current_field_name=$(this).attr('name');
let current_field_value=$(this).val();
let current_field_row_number=$(this).closest('tr.item').data('item');
console.log(current_field_name)
console.log(current_field_value)
console.log(current_field_row_number)
switch (current_field_name){
case 'item[name]':
$('.design-proforma__template #template_invoice_items_' + current_field_row_number + '_invoice_item_name tspan').html(current_field_value);
break;
case 'item[price]':
$('.design-proforma__template #template_invoice_items_' + current_field_row_number + '_invoice_item_price tspan').html(current_field_value);
break;
case 'item[count]':
$('.design-proforma__template #template_invoice_items_' + current_field_row_number + '_invoice_item_quantity tspan').html(current_field_value);
break;
case 'item[unit]':
$('.design-proforma__template #template_invoice_items_' + current_field_row_number + '_invoice_item_unit tspan').html(current_field_value);
break;
default:
break;
}});
$(document).on('click change keydown keyup keypress ifChecked ifUnchecked', '.design-proforma input, .design-proforma select, .design-proforma textarea', function(){
if(live_invoice_was_emptied==false){
live_invoice_was_emptied=true;
clearLiveTemplate();
}})
});
let last_served_field="";
function updateLiveInvoice(current_field_id, current_field_value){
console.log('trigger action called: ' + current_field_id + " with val: " + current_field_value);
if(current_field_id!==last_served_field){
dataLayer.push({
'event': 'generator_faktur_form_engaged',
'action_type': 'changes_in_field',
'field_id': current_field_id
});
console.log({
'event': 'generator_faktur_form_engaged',
'action_type': 'changes_in_field',
'field_id': current_field_id
})
last_served_field=current_field_id;
}
let coordinate_y_start=43;
let coordinate_y_step=51;
let coordinate_y_current=coordinate_y_start;
console.log(current_field_id)
switch (current_field_id){
case 'user-VatRegistrationType':
case 'company-id':
case 'company_vatid':
case 'address-street':
case 'address-city':
case 'address-postal':
case 'address-country':
coordinate_y_start=43;
coordinate_y_step=51;
coordinate_y_current=coordinate_y_start;
let company_id=jQuery('.design-proforma input#company-id').val();
let company_vatid=jQuery('.design-proforma input#company_vatid').val();
let address_street=jQuery('.design-proforma input#address-street').val();
let address_city=jQuery('.design-proforma input#address-city').val();
let address_postal=jQuery('.design-proforma input#address-postal').val();
let address_country=jQuery('.design-proforma select#address-country option:selected').val();
let vat_registration_type=jQuery('.design-proforma select#user-VatRegistrationType option:selected').val();
jQuery('.design-proforma__template #template_supplier_data').html('');
let template_supplier_data='';
template_supplier_data +='<tspan x="0" y="' + coordinate_y_current + '">' + address_street + '</tspan>';
coordinate_y_current +=coordinate_y_step;
template_supplier_data +='<tspan x="0" y="' + coordinate_y_current + '">' + address_postal + " " + address_city + '</tspan>';
coordinate_y_current +=coordinate_y_step;
template_supplier_data +='<tspan x="0" y="' + coordinate_y_current + '">' + address_country + '</tspan>';
coordinate_y_current +=coordinate_y_step;
if(company_id.length!==0){
template_supplier_data +='<tspan x="0" y="' + coordinate_y_current + '">IČ: ' + company_id + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
if(company_vatid.length!==0){
template_supplier_data +='<tspan x="0" y="' + coordinate_y_current + '">DIČ: ' + company_vatid + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
let supplier_vat_note='';
if(vat_registration_type=="neplatce"){
supplier_vat_note="Nejsme plátci DPH";
}else if(vat_registration_type="platce"){
supplier_vat_note="Jsme plátci DPH";
}else if(vat_registration_type="identifikovana-osoba"){
supplier_vat_note="Jsme identifikovaná osoba";
}
template_supplier_data +='<tspan x="0" y="' + coordinate_y_current + '">' + supplier_vat_note + '</tspan>';
coordinate_y_current +=coordinate_y_step;
jQuery('.design-proforma__template #template_supplier_data').html(template_supplier_data);
break;
case 'company-name':
jQuery('.design-proforma__template #template_supplier_company tspan').text(current_field_value)
break;
case 'email':
if(current_field_value.length!==0){
jQuery('.design-proforma__template #template_supplier_email tspan').text('E-mail: ' + current_field_value)
}else{
jQuery('.design-proforma__template #template_supplier_email tspan').text('');
}
break;
case 'phone':
if(current_field_value.length!==0){
jQuery('.design-proforma__template #template_supplier_phone tspan').text('Telefon: ' + current_field_value)
}else{
jQuery('.design-proforma__template #template_supplier_phone tspan').text('');
}
case 'buyer-company-id':
case 'buyer-company-vatid':
case 'buyer-contact-name':
case 'buyer-contact-surname':
case 'buyer-address-street':
case 'buyer-address-city':
case 'buyer-address-postal':
case 'buyer-country':
case 'buyer-contact-email':
case 'buyer-contact-phone':
coordinate_y_start=43;
coordinate_y_step=51;
coordinate_y_current=coordinate_y_start;
let buyer_company_id=jQuery('.design-proforma input#buyer-company-id').val();
let buyer_company_vatid=jQuery('.design-proforma input#buyer-company-vatid').val();
let buyer_contact_name=jQuery('.design-proforma input#buyer-contact-name').val();
let buyer_contact_surname=jQuery('.design-proforma input#buyer-contact-surname').val();
let buyer_address_street=jQuery('.design-proforma input#buyer-address-street').val();
let buyer_address_city=jQuery('.design-proforma input#buyer-address-city').val();
let buyer_address_postal=jQuery('.design-proforma input#buyer-address-postal').val();
let buyer_country=jQuery('.design-proforma select#buyer-country option:selected').val();
let buyer_contact_email=jQuery('.design-proforma input#buyer-contact-email').val();
let buyer_contact_phone=jQuery('.design-proforma input#buyer-contact-phone').val();
jQuery('.design-proforma__template #template_customer_data').html('');
let template_customer_data='';
if(buyer_contact_name.length > 0||buyer_contact_surname.length > 0){
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">' + buyer_contact_name + " " + buyer_contact_surname + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">' + buyer_address_street + '</tspan>';
coordinate_y_current +=coordinate_y_step;
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">' + buyer_address_postal + " " + buyer_address_city + '</tspan>';
coordinate_y_current +=coordinate_y_step;
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">' + buyer_country + '</tspan>';
coordinate_y_current +=coordinate_y_step;
if(buyer_company_id.length!==0){
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">IČ: ' + buyer_company_id + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
if(buyer_company_vatid.length!==0){
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">DIČ: ' + buyer_company_vatid + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
if(buyer_contact_email.length!==0){
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">E-mail: ' + buyer_contact_email + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
if(buyer_contact_phone.length!==0){
template_customer_data +='<tspan x="0" y="' + coordinate_y_current + '">Telefon: ' + buyer_contact_phone + '</tspan>';
coordinate_y_current +=coordinate_y_step;
}
jQuery('.design-proforma__template #template_customer_data').html(template_customer_data);
break;
case 'buyer-company-name':
jQuery('.design-proforma__template #template_customer_company tspan').text(current_field_value);
break;
case 'payment-method':
jQuery('.design-proforma__template #template_payment_method tspan').text(current_field_value);
break;
case 'BankAccount':
case 'BankCode':
let bank_account=jQuery('.design-proforma input#BankAccount').val();
let bank_code=jQuery('.design-proforma select#BankCode').val();
jQuery('.design-proforma__template #template_payment_bank_account tspan').text(bank_account + "/" + bank_code);
break;
case 'invoice-variable':
jQuery('.design-proforma__template #template_payment_variable_symbol tspan').text(current_field_value);
break;
case 'ConstantSymbolId':
jQuery('.design-proforma__template #template_payment_constant_symbol tspan').text(current_field_value);
break;
case 'text_before':
if(!jQuery('.design-proforma input#text_before').is(':checked')){
jQuery('.design-proforma__template #template_text_before_items_value tspan').text('');
}else{
jQuery('.design-proforma__template #template_text_before_items_value tspan').text(jQuery('.design-proforma textarea#proforma_before').val());
}
break;
case 'proforma_before':
jQuery('.design-proforma__template #template_text_before_items_value tspan').text(current_field_value);
break;
case 'text_after':
if(!jQuery('.design-proforma input#text_after').is(':checked')){
jQuery('.design-proforma__template #template_text_after_items_value tspan').text('');
}else{
jQuery('.design-proforma__template #template_text_after_items_value tspan').text(jQuery('.design-proforma textarea#invoice-textafteritems').val());
}
break;
case 'invoice-textafteritems':
jQuery('.design-proforma__template #template_text_after_items_value tspan').text(current_field_value);
break;
case 'invoice-serialnumber':
jQuery('.design-proforma__template #template_invoice_number tspan').text(current_field_value);
break;
case 'issue-date':
jQuery('.design-proforma__template #template_invoice_creation_date tspan').text(new Date(current_field_value).toLocaleDateString().replace(/ /g,''));
break;
case 'due-date':
jQuery('.design-proforma__template #template_invoice_due_date tspan').text(new Date(current_field_value).toLocaleDateString().replace(/ /g,''));
break;
case 'tax-date':
jQuery('.design-proforma__template #template_invoice_tax_date tspan').text(new Date(current_field_value).toLocaleDateString().replace(/ /g,''));
break;
default:
break;
}}
function clearLiveTemplate(){
console.log('clearing template');
jQuery('.design-proforma__template #template_supplier_data').html('<tspan x="0" y="43"></tspan>');
jQuery('.design-proforma__template #template_supplier_company tspan').text('');
jQuery('.design-proforma__template #template_supplier_email tspan').text('');
jQuery('.design-proforma__template #template_supplier_phone tspan').text('');
jQuery('.design-proforma__template #template_customer_data').html('<tspan x="0" y="43"></tspan>');
jQuery('.design-proforma__template #template_customer_company tspan').text('');
jQuery('.design-proforma__template #template_payment_method tspan').text('');
jQuery('.design-proforma__template #template_payment_bank_account tspan').text('');
jQuery('.design-proforma__template #template_payment_variable_symbol tspan').text('');
jQuery('.design-proforma__template #template_payment_constant_symbol tspan').text('');
jQuery('.design-proforma__template #template_text_before_items_value tspan').text('');
jQuery('.design-proforma__template #template_text_before_items_value tspan').text('');
jQuery('.design-proforma__template #template_text_after_items_value tspan').text('');
jQuery('.design-proforma__template #template_text_after_items_value tspan').text('');
jQuery('.design-proforma__template #template_invoice_number tspan').text('');
jQuery('.design-proforma__template #template_invoice_creation_date tspan').text('');
jQuery('.design-proforma__template #template_invoice_due_date tspan').text('');
for (let row=1; row <=9; row++){
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_name tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_price tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_quantity tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_unit tspan').html('');
jQuery('.design-proforma__template #template_invoice_items_' + row + '_invoice_item_price_total tspan').html('');
}
jQuery('.design-proforma__template #template_invoice_logo').attr('xlink:href', '');
jQuery('.design-proforma__template #template_invoice_signature').attr('xlink:href', '');
jQuery('.design-proforma__template #template_payment_total_price tspan').text('');
jQuery('.design-proforma__template #template_invoice_total_price tspan').text('');
}
const downloadURI=(uri, name)=> {
const link=document.createElement("a");
link.download=name;
link.href=uri;
link.target="_blank";
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
}
function generateInvoiceThumbnailAndPrepareItemsTable(){
let vat_registration_type=jQuery('.design-proforma select[name="VatRegistrationType"]').val();
let invoice_color=jQuery('.design-proforma input[name="color2"]:checked').val();
let base_path="/wp-content/themes/solitea-idoklad/assets/images/lp-generator/templates/";
let folder_category="";
let filename=invoice_color + "_template.png";
switch (vat_registration_type){
case "neplatce":
folder_category="neplatce_dph";
break;
case "platce":
folder_category="platce_dph";
break;
case "identifikovana-osoba":
folder_category="identifikovana_osoba";
break;
default:
folder_category="neplatce_dph";
filename="svetle_modra_template.png"
break;
}
jQuery('.design-proforma .design-proforma__template .template img').attr("src", base_path + folder_category + "/" + filename);
if(vat_registration_type=="platce"||vat_registration_type=="identifikovana-osoba"){
jQuery('.design-proforma__table-main').removeClass('design-proforma__table-main--neplatce');
}else{
jQuery('.design-proforma__table-main').addClass('design-proforma__table-main--neplatce');
}
console.log("vat_registration_type: " + vat_registration_type + " | invoice_color: " + invoice_color);
}
function loadData(){
if(localStorage.getItem("idoklad_generator_data")!==null){
let invoice_data_string=localStorage.getItem("idoklad_generator_data");
let invoice_data=JSON.parse(invoice_data_string);
live_invoice_was_emptied=true;
clearLiveTemplate();
jQuery('.design-proforma select[name="VatRegistrationType"]').val(invoice_data["vat_registration_type"]).trigger('change');
jQuery('.design-proforma input[name="color2"][value="' + invoice_data["invoice_color"] + '"]').prop("checked", true).trigger('change');
generateInvoiceThumbnailAndPrepareItemsTable();
jQuery('.design-proforma input[name="company-id"]').val(invoice_data["supplier_ic"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="company-id"]').attr('id'),
invoice_data["supplier_ic"]
);
jQuery('.design-proforma input[name="company_vatid"]').val(invoice_data["supplier_dic"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="company_vatid"]').attr('id'),
invoice_data["supplier_dic"]
);
jQuery('.design-proforma input[name="company-name"]').val(invoice_data["supplier_company"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="company-name"]').attr('id'),
invoice_data["supplier_company"]
);
jQuery('.design-proforma input[name="email"]').val(invoice_data["supplier_email"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="email"]').attr('id'),
invoice_data["supplier_email"]
);
jQuery('.design-proforma input[name="phone"]').val(invoice_data["supplier_phone"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="phone"]').attr('id'),
invoice_data["supplier_phone"]
);
jQuery('.design-proforma input[name="address-street"]').val(invoice_data["supplier_address"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="address-street"]').attr('id'),
invoice_data["supplier_address"]
);
jQuery('.design-proforma input[name="address-city"]').val(invoice_data["supplier_city"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="address-city"]').attr('id'),
invoice_data["supplier_city"]
);
jQuery('.design-proforma input[name="address-postal"]').val(invoice_data["supplier_psc"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="address-postal"]').attr('id'),
invoice_data["supplier_psc"]
);
jQuery('.design-proforma select[name="address-country"]').val(invoice_data["supplier_country"]);
updateLiveInvoice(
jQuery('.design-proforma select[name="address-country"]').attr('id'),
invoice_data["supplier_country"]
);
jQuery('.design-proforma input[name="BankAccount"]').val(invoice_data["payment_bank_account_number"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="BankAccount"]').attr('id'),
invoice_data["payment_bank_account_number"]
);
jQuery('.design-proforma input[name="BankCode"]').val(invoice_data["payment_bank_code"]);
updateLiveInvoice(
jQuery('.design-proforma input[name="BankCode"]').attr('id'),
invoice_data["payment_bank_code"]
);
jQuery('.design-proforma #logo_nahled').append('<img src="' + invoice_data["invoice_logo"] + '">');
jQuery('.design-proforma__template #template_invoice_logo').attr('xlink:href', invoice_data["invoice_logo"]);
jQuery('.design-proforma #razitko_nahled').append('<img src="' + invoice_data["invoice_signature"] + '">');
jQuery('.design-proforma__template #template_invoice_signature').attr('xlink:href', invoice_data["invoice_signature"]);
jQuery('.design-proforma #submit-save').iCheck('check').trigger('change');
}}
function saveData(){
let vat_registration_type=jQuery('.design-proforma select[name="VatRegistrationType"]').val();
let invoice_color=jQuery('.design-proforma input[name="color2"]:checked').val();
let supplier_ic=jQuery('.design-proforma input[name="company-id"]').val();
let supplier_dic=jQuery('.design-proforma input[name="company_vatid"]').val();
let supplier_company=jQuery('.design-proforma input[name="company-name"]').val();
let supplier_email=jQuery('.design-proforma input[name="email"]').val();
let supplier_phone=jQuery('.design-proforma input[name="phone"]').val();
let supplier_address=jQuery('.design-proforma input[name="address-street"]').val();
let supplier_city=jQuery('.design-proforma input[name="address-city"]').val();
let supplier_psc=jQuery('.design-proforma input[name="address-postal"]').val();
let supplier_country=jQuery('.design-proforma select[name="address-country"]').val();
let payment_bank_account_number=jQuery('.design-proforma input[name="BankAccount"]').val();
let payment_bank_code=jQuery('.design-proforma input[name="BankCode"]').val();
let invoice_logo=jQuery('.design-proforma #logo_nahled img').attr('src');
let invoice_signature=jQuery('.design-proforma #razitko_nahled img').attr('src');
let invoice_data={
vat_registration_type:vat_registration_type,
invoice_color:invoice_color,
supplier_ic:supplier_ic,
supplier_dic:supplier_dic,
supplier_company:supplier_company,
supplier_email:supplier_email,
supplier_phone:supplier_phone,
supplier_address:supplier_address,
supplier_city:supplier_city,
supplier_psc:supplier_psc,
supplier_country:supplier_country,
payment_bank_account_number:payment_bank_account_number,
payment_bank_code:payment_bank_code,
invoice_logo:invoice_logo,
invoice_signature:invoice_signature
}
let invoice_data_string=JSON.stringify(invoice_data);
localStorage.setItem("idoklad_generator_data", invoice_data_string);
}
function removeData(){
localStorage.removeItem("idoklad_generator_data");
}
function countItemTotalPrice(number){
let item_price=jQuery('.design-proforma .design-proforma__table table .item[data-item="' + number + '"] input[name="item[price]"]').val();
if(item_price!==undefined){
let standardizedValue=item_price.replace(',', '.');
let decimalIndex=standardizedValue.indexOf('.');
if(decimalIndex!==-1){
let integerPart=standardizedValue.substring(0, decimalIndex);
let decimalPart=standardizedValue.substring(decimalIndex + 1);
if(decimalPart.length > 2){
decimalPart=decimalPart.substring(0, 2);
}
let newValue=integerPart + '.' + decimalPart;
jQuery('.design-proforma .design-proforma__table table .item[data-item="' + number + '"] input[name="item[price]"]').val(newValue);
item_price=newValue;
}}
let item_count=jQuery('.design-proforma .design-proforma__table table .item[data-item="' + number + '"] input[name="item[count]"]').val();
let item_total=(item_price * 1) * (item_count * 1);
let item_tax=jQuery('.design-proforma .design-proforma__table table .item[data-item="' + number + '"] select[name="item[tax]"]').val();
let vat_registration_type=jQuery('.design-proforma select[name="VatRegistrationType"]').val();
let item_price_only_tax=(item_total * 1) * ((item_tax * 1) / 100);
let item_price_with_tax=(item_total * 1) + (item_price_only_tax * 1);
if(!isNaN(item_total)){
if(vat_registration_type=="neplatce"){
jQuery('.design-proforma .design-proforma__table table .item[data-item="' + number + '"] .itemTotalPrice').text(item_total.toFixed(2).replace(".", ",") + " Kč");
jQuery('.design-proforma__template #template_invoice_items_' + number + '_invoice_item_price_total tspan').html(parseFloat(item_total).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ","));
}else{
jQuery('.design-proforma__template #template_invoice_items_' + number + '_invoice_item_tax tspan').html(item_tax + " %");
jQuery('.design-proforma__template #template_invoice_items_' + number + '_invoice_item_price_without_tax tspan').html(parseFloat(item_total).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ","));
jQuery('.design-proforma__template #template_invoice_items_' + number + '_invoice_item_price_only_tax tspan').html(parseFloat(item_price_only_tax).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ","));
jQuery('.design-proforma .design-proforma__table table .item[data-item="' + number + '"] .itemTotalPrice').text(item_total.toFixed(2).replace(".", ",") + " Kč");
jQuery('.design-proforma__template #template_invoice_items_' + number + '_invoice_item_price_total tspan').html(parseFloat(item_price_with_tax).toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ","));
}}
countInvoiceTotalPrice();
}
function countInvoiceTotalPrice(){
console.log('countInvoiceTotalPrice')
let total=0;
let total_inc_tax=0;
let vat_registration_type=jQuery('.design-proforma select[name="VatRegistrationType"]').val();
let vat_rates=[];
jQuery('.design-proforma .design-proforma__table table .item .itemTotalPrice').each(function(){
let item_number=jQuery(this).closest('tr.item').data('item');
let price_as_string=jQuery(this).text().replace(",", ".");
let price;
let price_inc_tax;
price=parseFloat(price_as_string);
total +=price;
if(vat_registration_type!=='neplatce'){
let tax_value=parseInt(jQuery('.design-proforma .design-proforma__table table .item[data-item="' + item_number + '"] select[name="item[tax]"]').val());
price_inc_tax=parseFloat(price_as_string) * ((tax_value / 100) + 1);
total_inc_tax +=price_inc_tax;
vat_rates.push(tax_value);
}})
let total_string=total.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ",");
total_string +=" Kč";
let total_string_inc_tax;
if(vat_registration_type!=='neplatce'){
total_string_inc_tax=total_inc_tax.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ",");
total_string_inc_tax +=" Kč";
}
if(vat_registration_type=='neplatce'){
jQuery('.design-proforma #invoice-total').html(total_string);
jQuery('.design-proforma__template #template_payment_total_price tspan').html(total_string);
jQuery('.design-proforma__template #template_invoice_total_price tspan').html(total_string);
}else{
jQuery('.design-proforma #invoice-total').html(total_string + " bez DPH  (" + total_string_inc_tax + " s DPH)");
jQuery('.design-proforma__template #template_payment_total_price tspan').html(total_string_inc_tax);
jQuery('.design-proforma__template #template_invoice_total_price tspan').html(total_string_inc_tax);
}
if(vat_registration_type!=='neplatce'){
for (let i=1; i <=3; i++){
jQuery('.design-proforma__template #template_vat_rate_' + i + '_rate tspan').html('');
jQuery('.design-proforma__template #template_vat_rate_' + i + '_base tspan').html('');
jQuery('.design-proforma__template #template_vat_rate_' + i + '_vat_amount tspan').html('');
jQuery('.design-proforma__template #template_vat_rate_' + i + '_total tspan').html('');
}
let vat_rates_unique=[...new Set(vat_rates)];
console.log(vat_rates_unique)
vat_rates_unique=vat_rates_unique.sort(function(a, b){
return b - a;
});
console.log(vat_rates_unique)
for(let i=1; i <=vat_rates_unique.length; i++){
let vat_rate=vat_rates_unique[i-1];
jQuery('.design-proforma__template #template_vat_rate_' + i + '_rate tspan').html(vat_rate + " %");
let line_base=0;
let line_vat_amount=0;
let line_total=0;
jQuery('.design-proforma .design-proforma__table table tr.item').each(function(){
let current_item_tax=jQuery(this).find('select[name="item[tax]"]').val();
if(parseInt(current_item_tax)==parseInt(vat_rate)){
line_base +=parseFloat(jQuery(this).find('.itemTotalPrice').text().replace(",", "."));
line_vat_amount +=parseFloat(jQuery(this).find('.itemTotalPrice').text().replace(",", ".")) * (parseInt(vat_rate) / 100);
}})
line_total=(line_base + line_vat_amount);
let line_base_string=line_base.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ",");
let line_vat_amount_string=line_vat_amount.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ",");
let line_total_string=line_total.toLocaleString(undefined, {minimumFractionDigits: 2, maximumFractionDigits: 2}).replace(".", ",");
jQuery('.design-proforma__template #template_vat_rate_' + i + '_base tspan').html(line_base_string);
jQuery('.design-proforma__template #template_vat_rate_' + i + '_vat_amount tspan').html(line_vat_amount_string);
jQuery('.design-proforma__template #template_vat_rate_' + i + '_total tspan').html(line_total_string);
}}
}
function generateTest(number){
if(number==1){
jQuery('.design-proforma select[name="VatRegistrationType"]').val('neplatce').trigger('change');
jQuery('.design-proforma input[name="color2"][value="svetle_modra"]').click();
jQuery('.design-proforma input[name="company-id"]').val('11678968').trigger('change');
jQuery('.design-proforma input[name="company_vatid"]').val('').trigger('change');
jQuery('.design-proforma input[name="company-name"]').val('Ing. Lukáš Prokop').trigger('change');
jQuery('.design-proforma input[name="email"]').val('prokop@webite.cz').trigger('change');
jQuery('.design-proforma input[name="phone"]').val('732405415').trigger('change');
jQuery('.design-proforma input[name="address-street"]').val('Vachova 39/3').trigger('change');
jQuery('.design-proforma input[name="address-city"]').val('Brno').trigger('change');
jQuery('.design-proforma input[name="address-postal"]').val('60200').trigger('change');
jQuery('#step1 .actionNextStep').trigger('click');
jQuery('.design-proforma input[name="buyer-company-id"]').val('05897921').trigger('change');
jQuery('.design-proforma input[name="buyer-company-vatid"]').val('CZ05897921').trigger('change');
jQuery('.design-proforma input[name="buyer-company-name"]').val('Webite, s.r.o.').trigger('change');
jQuery('.design-proforma input[name="buyer-contact-name"]').val('Martin').trigger('change');
jQuery('.design-proforma input[name="buyer-contact-surname"]').val('Weigel').trigger('change');
jQuery('.design-proforma input[name="buyer-contact-email"]').val('weigel@webite.cz').trigger('change');
jQuery('.design-proforma input[name="buyer-contact-phone"]').val('+420 792 20 20 90').trigger('change');
jQuery('.design-proforma input[name="buyer-address-street"]').val('Lidická 718/77').trigger('change');
jQuery('.design-proforma input[name="buyer-address-city"]').val('Brno').trigger('change');
jQuery('.design-proforma input[name="buyer-address-postal"]').val('60200').trigger('change');
jQuery('#step2 .actionNextStep').trigger('click');
jQuery('.design-proforma select[name="payment-method"]').val("Převodem").trigger('change');
jQuery('.design-proforma input[name="BankAccount"]').val('12345678').trigger('change');
jQuery('.design-proforma select[name="BankCode"]').val('2010').trigger('change');
jQuery('.design-proforma input[name="invoice-variable"]').val(20230005).trigger('change');
jQuery('.design-proforma input[name="ConstantSymbolId"]').val(1234).trigger('change');
jQuery('#step3 .actionNextStep').trigger('click');
jQuery('.design-proforma input[name="text_before"]').iCheck('check');
jQuery('.design-proforma textarea[name="invoice-textbeforeitems"]').text('Fakturuji vám následující položky:');
jQuery('.design-proforma .design-proforma__table .item[data-item="1"] input[name="item[name]"]').val('IT práce').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="1"] input[name="item[price]"]').val('35000').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="1"] input[name="item[count]"]').val('1').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="1"] input[name="item[unit]"]').val('ks').trigger('change');
countItemTotalPrice(1);
jQuery('.design-proforma__table-addline.actionAddItem').click();
jQuery('.design-proforma .design-proforma__table .item[data-item="2"] input[name="item[name]"]').val('podpora').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="2"] input[name="item[price]"]').val('7320').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="2"] input[name="item[count]"]').val('1').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="2"] input[name="item[unit]"]').val('ks').trigger('change');
countItemTotalPrice(2);
jQuery('.design-proforma__table-addline.actionAddItem').click();
jQuery('.design-proforma .design-proforma__table .item[data-item="3"] input[name="item[name]"]').val('školení').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="3"] input[name="item[price]"]').val('850').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="3"] input[name="item[count]"]').val('5').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="3"] input[name="item[unit]"]').val('ks').trigger('change');
countItemTotalPrice(3);
jQuery('.design-proforma__table-addline.actionAddItem').click();
jQuery('.design-proforma .design-proforma__table .item[data-item="4"] input[name="item[name]"]').val('poradenství').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="4"] input[name="item[price]"]').val('450').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="4"] input[name="item[count]"]').val('5').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="4"] input[name="item[unit]"]').val('hod').trigger('change');
countItemTotalPrice(4);
jQuery('.design-proforma__table-addline.actionAddItem').click();
jQuery('.design-proforma .design-proforma__table .item[data-item="5"] input[name="item[name]"]').val('úklid').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="5"] input[name="item[price]"]').val('1200').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="5"] input[name="item[count]"]').val('1').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="5"] input[name="item[unit]"]').val('ks').trigger('change');
countItemTotalPrice(5);
jQuery('.design-proforma__table-addline.actionAddItem').click();
jQuery('.design-proforma .design-proforma__table .item[data-item="6"] input[name="item[name]"]').val('překlad').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="6"] input[name="item[price]"]').val('3617').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="6"] input[name="item[count]"]').val('1').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="6"] input[name="item[unit]"]').val('ks').trigger('change');
countItemTotalPrice(6);
jQuery('.design-proforma__table-addline.actionAddItem').click();
jQuery('.design-proforma .design-proforma__table .item[data-item="7"] input[name="item[name]"]').val('terapeutické služby').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="7"] input[name="item[price]"]').val('699').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="7"] input[name="item[count]"]').val('9').trigger('change');
jQuery('.design-proforma .design-proforma__table .item[data-item="7"] input[name="item[unit]"]').val('hod').trigger('change');
countItemTotalPrice(7);
jQuery('.design-proforma input[name="text_before"]').iCheck('check');
jQuery('.design-proforma input[name="text_after"]').iCheck('check');
jQuery('.design-proforma textarea[name="invoice-textafteritems"]').text('Zaplaťte mi prosím včas. Děkuji.').trigger('change');
jQuery('#step4 .actionNextStep').trigger('click');
jQuery('.design-proforma input[name="invoice-serialnumber"]').trigger('change');
jQuery('.design-proforma input[name="issue-date"]').trigger('change');
jQuery('.design-proforma input[name="due-date"]').trigger('change');
jQuery('#step5 .actionNextStep').trigger('click');
jQuery('.design-proforma #logo_nahled').append('<img src="https://www.idoklad.cz/wp-content/themes/solitea-idoklad/assets/files/pdf_faktury_media/613803874_mr_beans_holiday_ver2.jpg">');
jQuery('.design-proforma__template #template_invoice_logo').attr('xlink:href', "https://www.idoklad.cz/wp-content/themes/solitea-idoklad/assets/files/pdf_faktury_media/613803874_mr_beans_holiday_ver2.jpg");
jQuery('.design-proforma #razitko_nahled').append('<img src="https://www.idoklad.cz/wp-content/themes/solitea-idoklad/assets/files/pdf_faktury_media/637167283_michael-jordan-personal-autograph.png">');
jQuery('.design-proforma__template #template_invoice_signature').attr('xlink:href', "https://www.idoklad.cz/wp-content/themes/solitea-idoklad/assets/files/pdf_faktury_media/637167283_michael-jordan-personal-autograph.png");
}};