{% sw_extends '@parent/storefront/base.html.twig' %}
{% block base_body %}
<span id="dmits-double-left" style="display:none">
{% sw_icon 'arrow-medium-double-left' style { 'size': 'fluid', 'pack': 'solid'} %}
</span>
<span id="dmits-left" style="display:none">
{% sw_icon 'arrow-medium-left' style { 'size': 'fluid', 'pack': 'solid'} %}
</span>
<span id="dmits-right"" style="display:none">
{% sw_icon 'arrow-medium-right' style { 'size': 'fluid', 'pack': 'solid'} %}
</span>
<span id="dmits-double-right" style="display:none">
{% sw_icon 'arrow-medium-double-right' style { 'size': 'fluid', 'pack': 'solid'} %}
</span>
{{ parent() }}
<style>
{% if not config('DmitsInquirySales.config.buyinquiryselectpopup')%}
@media screen and (max-width: 900px) {
.dmits-inquiry-sales-inquiry-distribution-shops{
min-height:150px;
min-width:150px;
font-size: 1em;
}
}
{% endif %}
.distribution-nav{
margin:auto;
margin-top:20px;
}
.distribution-nav .pagination{
display: inline-flex;
}
.searchBox,
.dmits-inquiry-sales-contactform,
.dmits-inquiry-sales-content-buy,
.dmits-inquiry-sales-content-buy-header,
.dmits-inquiry-sales-content-inquiry,
.dmits-inquiry-sales-content-inquiry-header,
#btn-dmits-inquirysales-back{
display: none;
}
.searchContent{
min-height: 80px;
}
.dmits-inquiry-sales-content-buy-header, .dmits-inquiry-sales-content-inquiry-header{
margin-bottom: 25px;
}
#btn-dmits-inquirysales-back{
margin-top:10x;
float: left;
}
.searchBoxContent option:first{
color:grey;
}
.dmits-inquiry-sales-inquiry-distribution-shops{
background-color: #fff;
}
.dmits-inquiry-sales-inquiry-distribution-shops img{
max-width: 190px;
max-height: 190px;
}
.dmits-inquiry-sales-table-head{
font-size:12px;
}
.line:before{
top:9px;
}
.dmits-inquiry-sales-form-error{display:none;}
.dmits-inquiry-sales-inquiry-distribution{
display:none;
}
.dmits-inquiry-sales-inquiry-distribution-mobile .dmits-inquiry-sales-inquiry-distribution{
display:block;
margin: auto;
margin-top: 10px;
}
@media screen and (min-width: 900px) {
#btn-dmits-inquirysales-back{
margin-top: -40px;
}
.nopartner #btn-dmits-inquirysales-back{
margin-top: 40px;
}
#step3 #btn-dmits-inquirysales-back,#step4 #btn-dmits-inquirysales-back, #stepcontact1 #btn-dmits-inquirysales-back{
margin-top: 10px;
}
.dmits-inquiry-sales-inquiry-distribution{
display: block;
}
.dmits-inquiry-sales-inquiry-distribution-mobile{
display:none;
}
.dmits-inquiry-sales-inquiry-distribution-mobile .dmits-inquiry-sales-inquiry-distribution{
display:none;
}
}
.dmits-inquiry-sales-tabs{
margin-bottom:20px;
}
.dmits-inquiry-sales-tabs button{
background:none;
width: 200px;
margin:auto;
}
.dmits-inquiry-sales-tabs button:focus{
outline:0;
}
.dmits-inquiry-sales-inquiry-distribution-shops{
display:grid;
}
.dmits-inquiry-sales-inquiry-distribution-shops img{
margin:auto;
}
.dmits-inquiry-sales-inquiry-distribution-shops .dmits-inquiry-sales-inquiry-distribution-additional-info{
font-size: 16px;
}
{{ config('DmitsInquirySales.config.customCss')|raw}}
</style>
{% if config('DmitsInquirySales.config.inquirypopup')%}
{% block dmits_inquirysales_requestform_modal %}
<!-- Modal -->
<div class="modal fade" data-width="1000" id="inquirysalesModalCenter"
tabindex="-1" role="dialog"
aria-labelledby="inquirysalesModalCenterTitle" aria-hidden="true">
<div style="max-width: 1200px;"
class="modal-dialog modal-dialog-centered" role="document">
<div class="modal-content">
{% block dmits_inquirysales_requestform_modalheader %}
<div class="modal-header">
<h5 class="modal-title" id="inquirysalesModalCenterTitle">
{{ 'dmits-inquirysales.popup.popupTitle'|trans }}
</h5>
<button type="button" class="close" data-dismiss="modal"
aria-label="Close">
<span aria-hidden="true">×</span>
</button>
</div>
{% endblock %}
{% block dmits_inquirysales_requestform_modalbody %}
<div class="modal-body">
<div class="dmits-inquiry-sales-contactform">
{% set template = "@Storefront/storefront/dmits/contactformcontent.html.twig" %}
{% sw_include template ignore missing %}
</div>
{% set template = "@Storefront/storefront/dmits/content.html.twig" %}
{% sw_include template ignore missing %}
</div>
{% endblock %}
</div>
</div>
</div>
{% endblock %}
{% else %}
<div class="inquirysalesinline">
<div class="dmits-inquiry-sales-contactform">
{% set template = "@Storefront/storefront/dmits/contactformcontent.html.twig" %}
{% sw_include template ignore missing %}
</div>
{% set template = "@Storefront/storefront/dmits/content.html.twig" %}
{% sw_include template ignore missing %}
<div class="col-12">
<button class="btn btn-primary" id="btn-dmits-inquirysales-back">{{ 'dmits-inquirysales.detail.inlineRequestBackButton'|trans }}</button>
</div>
</div>
{% endif %}
{% block dmits_inquirysales_requestform_script %}
<script>
var companyName="";
var companyId="";
var zipcode="";
var lat="";
var lng="";
var onlycountry=false;
var dmitsInquirySalesLIMITSHOP="{{config('DmitsInquirySales.config.showPerPageShop')}}";
var dmitsInquirySalesLIMITINQUIRY="{{config('DmitsInquirySales.config.showPerPageInquiry')}}";
var partnerid="{{page.product.customFields['dmits_inquiry_sales_custom_field__product_partnerid']}}";
function addLoader(){
$(".inquirysalesinline").addClass("nopartner");
$("#dmits-inquiry-sales-shop-output-message").html("");
$("#dmits-inquiry-sales-shop-output").html('<div style=" display: block;margin:auto;margin-top:10px;"class="loader" role="status"><span class="sr-only">Loading...</span></div>');
$("#dmits-inquiry-sales-output-message").html("");
$("#dmits-inquiry-sales-output").html('<div style=" display: block;margin:auto;margin-top:10px;"class="loader" role="status"><span class="sr-only">Loading...</span></div>');
}
function loadAllDistributions(page){
console.log(page);
addLoader();
var data = new FormData();
data.append("partnerId", partnerid);
data.append("offset", page);
data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
var xhr = new XMLHttpRequest();
xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-all-distributions') }}', true);
xhr.onload = function () {
var json=this.responseText;
var jsonResponse = JSON.parse(this.responseText);
$(".inquirysalesinline").addClass("nopartner");
if(jsonResponse.data.message=="error"){
//loadAllDistributions();
$("#dmits-inquiry-sales-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
$("#dmits-inquiry-sales-output").html("");
}else{
var htmlOutput="";
jsonResponse.data.forEach(element => {
var infos="";
if(element.company){
infos=infos+element.company+'<br>';
}
if(element.street && element.housenumber){
infos=infos+element.street+' '+element.housenumber+'<br>';
}else if(element.street){
infos=infos+element.street+'<br>';
}else if(element.housenumber){
infos=infos+element.housenumber+'<br>';
}
if(element.zip && element.city){
infos=infos+element.zip+' '+element.city+'<br>';
}else if(element.zip){
infos=infos+element.zip+'<br>';
}else if(element.city){
infos=infos+element.city+'<br>';
}
if(element.country){
infos=infos+element.country+'<br>';
}
if(element.telephone){
infos=infos+element.telephone+'<br>';
}
if(element.mail){
//infos=infos+element.mail+'<br>';
}
if(element.website){
//infos=infos+element.website+'<br>';
}
if(element.additional_info){
infos=infos+'<span class="dmits-inquiry-sales-inquiry-distribution-additional-info">'+element.additional_info+'<br></span>';
}
var additional1="";
var additional2="";
var additional3="";
var additional4="";
{%if config('DmitsInquirySales.config.additionalactive1')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia1')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia1')) %}
{%if config('DmitsInquirySales.config.additionalmedia1') %}
additional1='<img title="{{ 'dmits-inquirysales.additional1'|trans }}" alt="{{ 'dmits-inquirysales.additional1'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional1=additional1+' <span>{{ 'dmits-inquirysales.additional1'|trans|raw }}</span>' ;
{% endif %}
{%if config('DmitsInquirySales.config.additionalactive2')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia2')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia2')) %}
{%if config('DmitsInquirySales.config.additionalmedia2') %}
additional2='<img title="{{ 'dmits-inquirysales.additional2'|trans }}" alt="{{ 'dmits-inquirysales.additional2'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional2=additional2+' <span>{{ 'dmits-inquirysales.additional2'|trans|raw }}</span>' ;
{% endif %}
{%if config('DmitsInquirySales.config.additionalactive3')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia3')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia3')) %}
{%if config('DmitsInquirySales.config.additionalmedia3') %}
additional3='<img title="{{ 'dmits-inquirysales.additional3'|trans }}" alt="{{ 'dmits-inquirysales.additional3'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional3=additional3+' <span>{{ 'dmits-inquirysales.additional3'|trans|raw }}</span>' ;
{% endif %}
{%if config('DmitsInquirySales.config.additionalactive4')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia4')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia4')) %}
{%if config('DmitsInquirySales.config.additionalmedia4') %}
additional4='<img title="{{ 'dmits-inquirysales.additional4'|trans }}" alt="{{ 'dmits-inquirysales.additional4'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional4=additional4+' <span>{{ 'dmits-inquirysales.additional4'|trans|raw }}</span>' ;
{% endif %}
htmlOutput=htmlOutput+'<div class="row dmits-inquiry-sales-table-body"><div class="col-2"></div><div class="col-6">'+infos+'</div><div class="col-4"><div class="dmits-inquiry-sales-icons"><span class="dmits-inquiry-sales-icon" '+(element.additional1=="1"?'':'style="display:none"')+'>'+additional1+'</span> <span class="dmits-inquiry-sales-icon" '+(element.additional2=="1"?'':'style="display:none"')+'>'+additional2+'</span> <span class="dmits-inquiry-sales-icon" '+(element.additional3=="1"?'':'style="display:none"')+'>'+additional3+'</span> <span class="dmits-inquiry-sales-icon" '+(element.additional4=="1"?'':'style="display:none"')+'>'+additional4+'</span></div><button data-id="'+element.id+'" class="btn btn-primary dmits-inquiry-sales-inquiry-distribution" data-company="'+element.company+'">{{ 'dmits-inquirysales.popup.buttonPartner'|trans }}</button></div><div class="col-12 dmits-inquiry-sales-inquiry-distribution-mobile"><button data-id="'+element.id+'" class="btn btn-primary dmits-inquiry-sales-inquiry-distribution" data-company="'+element.company+'">{{ 'dmits-inquirysales.popup.buttonPartner'|trans }}</button></div></div>';
}
);
htmlOutput="<div class='dmits-inquiry-sales-table-container'>"+htmlOutput+"</div>";
var pagination= buildPagination(page+1,jsonResponse.count);
htmlOutput=htmlOutput+"<div class='row'>"+pagination+"</div>";
$("#dmits-inquiry-sales-output").html(htmlOutput);
$(".inquirysalesinline").removeClass("nopartner");
setSalesContainerHeight();
}
};
xhr.send(data);
}
function buildPagination(current,total){
var limit =dmitsInquirySalesLIMITINQUIRY;
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
var limit =dmitsInquirySalesLIMITSHOP;
}
var totalPages=Math.ceil(total/limit);
var pages="";
for(var i=1;i<=totalPages;i++){
var pageActive="";
if(i==current){
pageActive="active";
}
var pages=pages+'<li data-page="'+i+'" class="page-item '+pageActive+'"><label class="page-link" >'+i+'</label></li>';
}
var disableFirst="";
var disableLast="";
if(current==1){
disableFirst="disabled";
}
if(current==totalPages){
disableLast="disabled";
}
var pagination=`<nav aria-label="pagination" class="distribution-nav"><ul class="pagination">
<li data-page="`+1+`" class="page-item page-first `+disableFirst+`"> <label class="page-link" >`+$("#dmits-double-left").html()+`</label></li>
<li data-page="`+(current-1)+`" class="page-item page-prev `+disableFirst+`"><label class="page-link" >`+$("#dmits-left").html()+`</label></li>
`+pages+`
<li data-page="`+(current+1)+`" class="page-item page-next `+disableLast+`"> <label class="page-link" >`+$("#dmits-right").html()+`</label></li>
<li data-page="`+(totalPages)+`" class="page-item page-last `+disableLast+`"><label class="page-link" >`+$("#dmits-double-right").html()+`</label></li>
</ul></div>`;
return pagination;
}
$(document).on('click', ".distribution-nav li", function() {
if(!$(this).hasClass("disabled")){
var newpage=$(this).attr("data-page")-1;
if(lat && lng){
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
loadDistributionsShop(lat,lng,newpage);
}else{
loadDistributions(lat,lng,newpage);
}
}else{
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
loadAllDistributionsShop(newpage)
}else{
loadAllDistributions(newpage);
}
}
}
});
function loadDistributions(lat,lng,page){
addLoader();
var data = new FormData();
data.append("partnerId", partnerid);
data.append("offset", page);
data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
var xhr = new XMLHttpRequest();
xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-distributions') }}?lat='+lat+'&lng='+lng+'&country='+$("#dmits-inquiry-sales-country-select").val(), true);
xhr.onload = function () {
var json=this.responseText;
var jsonResponse = JSON.parse(this.responseText);
$(".inquirysalesinline").addClass("nopartner");
if(jsonResponse.data.message=="error"){
//loadAllDistributions();
$("#dmits-inquiry-sales-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
$("#dmits-inquiry-sales-output").html("");
}else{
var htmlOutput="";
jsonResponse.data.forEach(element => {
var infos="";
if(element.company){
infos=infos+element.company+'<br>';
}
if(element.street && element.housenumber){
infos=infos+element.street+' '+element.housenumber+'<br>';
}else if(element.street){
infos=infos+element.street+'<br>';
}else if(element.housenumber){
infos=infos+element.housenumber+'<br>';
}
if(element.zip && element.city){
infos=infos+element.zip+' '+element.city+'<br>';
}else if(element.zip){
infos=infos+element.zip+'<br>';
}else if(element.city){
infos=infos+element.city+'<br>';
}
if(element.country){
infos=infos+element.country+'<br>';
}
if(element.telephone){
infos=infos+element.telephone+'<br>';
}
if(element.mail){
//infos=infos+element.mail+'<br>';
}
if(element.website){
// infos=infos+element.website+'<br>';
}
if(element.additional_info){
infos=infos+'<span class="dmits-inquiry-sales-inquiry-distribution-additional-info">'+element.additional_info+'<br></span>';
}
var additional1="";
var additional2="";
var additional3="";
var additional4="";
{%if config('DmitsInquirySales.config.additionalactive1')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia1')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia1')) %}
{%if config('DmitsInquirySales.config.additionalmedia1') %}
additional1='<img title="{{ 'dmits-inquirysales.additional1'|trans }}" alt="{{ 'dmits-inquirysales.additional1'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional1=additional1+' <span>{{ 'dmits-inquirysales.additional1'|trans|raw }}</span>' ;
{% endif %}
{%if config('DmitsInquirySales.config.additionalactive2')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia2')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia2')) %}
{%if config('DmitsInquirySales.config.additionalmedia2') %}
additional2='<img title="{{ 'dmits-inquirysales.additional2'|trans }}" alt="{{ 'dmits-inquirysales.additional2'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional2=additional2+' <span>{{ 'dmits-inquirysales.additional2'|trans|raw }}</span>' ;
{% endif %}
{%if config('DmitsInquirySales.config.additionalactive3')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia3')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia3')) %}
{%if config('DmitsInquirySales.config.additionalmedia3') %}
additional3='<img title="{{ 'dmits-inquirysales.additional3'|trans }}" alt="{{ 'dmits-inquirysales.additional3'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional3=additional3+' <span>{{ 'dmits-inquirysales.additional3'|trans|raw }}</span>' ;
{% endif %}
{%if config('DmitsInquirySales.config.additionalactive4')%}
{% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia4')], context.context) %}
{% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia4')) %}
{%if config('DmitsInquirySales.config.additionalmedia4') %}
additional4='<img title="{{ 'dmits-inquirysales.additional4'|trans }}" alt="{{ 'dmits-inquirysales.additional4'|trans }}" src="{{(downloadurl.url)}}">' ;
{% endif %}
additional4=additional4+ ' <span>{{ 'dmits-inquirysales.additional4'|trans|raw }}</span>' ;
{% endif %}
htmlOutput=htmlOutput+'<div class="row dmits-inquiry-sales-table-body"><div class="col-2">'+(!onlycountry?Math.round(element.distance*1.61)+ ' {{ 'dmits-inquirysales.popup.km'|trans }}':'')+'</div><div class="col-6">'+infos+'</div><div class="col-4"><div class="dmits-inquiry-sales-icons"><span class="dmits-inquiry-sales-icon" '+(element.additional1=="1"?'':'style="display:none"')+'>'+additional1+'</span> <span class="dmits-inquiry-sales-icon" '+(element.additional2=="1"?'':'style="display:none"')+'>'+additional2+'</span> <span class="dmits-inquiry-sales-icon" '+(element.additional3=="1"?'':'style="display:none"')+'>'+additional3+'</span> <span class="dmits-inquiry-sales-icon" '+(element.additional4=="1"?'':'style="display:none"')+'>'+additional4+'</span></div><button data-id="'+element.id+'" class="btn btn-primary dmits-inquiry-sales-inquiry-distribution" data-company="'+element.company+'">{{ 'dmits-inquirysales.popup.buttonPartner'|trans }}</button></div><div class="col-12 dmits-inquiry-sales-inquiry-distribution-mobile"><button data-id="'+element.id+'" class="btn btn-primary dmits-inquiry-sales-inquiry-distribution" data-company="'+element.company+'">{{ 'dmits-inquirysales.popup.buttonPartner'|trans }}</button></div></div>';
}
);
htmlOutput="<div class='dmits-inquiry-sales-table-container'>"+htmlOutput+"</div>";
var pagination= buildPagination(page+1,jsonResponse.count);
htmlOutput=htmlOutput+"<div class='row'>"+pagination+"</div>";
$("#dmits-inquiry-sales-output").html(htmlOutput);
$(".inquirysalesinline").removeClass("nopartner");
setSalesContainerHeight();
}
};
xhr.send(data);
}
function loadAllDistributionsShop(page){
addLoader();
var data = new FormData();
data.append("partnerId", partnerid);
data.append("offset", page);
data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
var xhr = new XMLHttpRequest();
xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-distributions-shop') }}', true);
xhr.onload = function () {
var json=this.responseText;
var jsonResponse = JSON.parse(this.responseText);
$(".inquirysalesinline").addClass("nopartner");
if(jsonResponse.data.message=="error"){
$("#dmits-inquiry-sales-shop-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
$("#dmits-inquiry-sales-shop-output").html("");
}else{
var htmlOutput="";
jsonResponse.data.forEach(element => {
var showText=element.company;
var additional_info=element.additional_info;
if(additional_info==null){
additional_info="";
}else{
additional_info="<span>"+additional_info+"</span>";
}
if(element.mediaUrl){
showText="<div class='dmits-inquiry-sales-inquiry-distribution-image'><img src='"+element.mediaUrl+"'></div>";
}
htmlOutput=htmlOutput+"<div class='{% if config('DmitsInquirySales.config.buyColumns3')%}col-sm-4 {% else %}col-sm-6 {% endif %} col-12' style='text-align:center;margin:10px 0'><a target='_blank' href='"+element.website+"' class='btn btn-primary dmits-inquiry-sales-inquiry-distribution-shops' '>"+showText+" <span class='dmits-inquiry-sales-inquiry-distribution-additional-info'>"+additional_info+"</span></a></div>";
}
);
htmlOutput="<div class='row'>"+htmlOutput+"</div>" ;
var pagination= buildPagination(page+1,jsonResponse.count);
htmlOutput=htmlOutput+"<div class='row'>"+pagination+"</div>";
$("#dmits-inquiry-sales-shop-output").html(htmlOutput);
$(".inquirysalesinline").removeClass("nopartner");
setSalesContainerHeight();
}
};
xhr.send(data);
}
function loadDistributionsShop(lat,lng,page){
addLoader();
var data = new FormData();
data.append("partnerId", partnerid);
data.append("offset", page);
data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
var xhr = new XMLHttpRequest();
xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-distributions-shop') }}?lat='+lat+'&lng='+lng+'&country='+$("#dmits-inquiry-sales-country-select").val(), true);
xhr.onload = function () {
var json=this.responseText;
var jsonResponse = JSON.parse(this.responseText);
$(".inquirysalesinline").addClass("nopartner");
if(jsonResponse.data.message=="error"){
//loadAllDistributions();
$("#dmits-inquiry-sales-shop-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
$("#dmits-inquiry-sales-shop-output").html("");
}else{
var htmlOutput="";
jsonResponse.data.forEach(element => {
var showText=element.company;
var additional_info=element.additional_info;
if(additional_info==null){
additional_info="";
}else{
additional_info="<span>"+additional_info+"</span>";
}
if(element.mediaUrl){
showText="<div class='dmits-inquiry-sales-inquiry-distribution-image'><img src='"+element.mediaUrl+"'></div>";
}
htmlOutput=htmlOutput+"<div class='{% if config('DmitsInquirySales.config.buyColumns3')%}col-sm-4 {% else %}col-sm-6 {% endif %} col-12' style='text-align:center;margin:10px 0'><a target='_blank' href='"+element.website+"' class='btn btn-primary dmits-inquiry-sales-inquiry-distribution-shops' '>"+showText+" <span class='dmits-inquiry-sales-inquiry-distribution-additional-info'>"+additional_info+"</span></a></div>";
}
);
var pagination= buildPagination(page+1,jsonResponse.count);
htmlOutput=htmlOutput+pagination;
$("#dmits-inquiry-sales-shop-output").html("<div class='row'>"+htmlOutput+"</div>");
$(".inquirysalesinline").removeClass("nopartner");
}
};
xhr.send(data);
}
function loadZipgeo(){
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ path('frontend.action.dmits.inquiry-request-zipgeo') }}?zip='+$("#dmits-inquiry-sales-search-zipcode").val()+'&country='+$("#dmits-inquiry-sales-country-select").val(), true);
xhr.onload = function () {
var jsonResponse = JSON.parse(this.responseText);
$(".inquirysalesinline").addClass("nopartner");
if(jsonResponse.data.message=="error"){
//loadAllDistributions();
$("#dmits-inquiry-sales-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
$("#dmits-inquiry-sales-output").html("");
if($("#dmits-inquiry-sales-search-zipcode").val()=="" && $("#dmits-inquiry-sales-country-select").val()=="{{ 'dmits-inquirysales.countryplaceholder'|trans }}"){
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
loadAllDistributionsShop(0)
}else{
loadAllDistributions(0);
}
}
lat="";
lng="";
}else{
lat=jsonResponse.data.lat;
lng=jsonResponse.data.lng;
onlycountry=jsonResponse.data.onlyCountry;
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
loadDistributionsShop(jsonResponse.data.lat,jsonResponse.data.lng,0);
}else{
loadDistributions(jsonResponse.data.lat,jsonResponse.data.lng,0);
}
}
};
xhr.send();
}
$( "#dmits-inquiry-sales-country-select" ).change(function() {
loadZipgeo();
});
var timer1;
$( "#dmits-inquiry-sales-search-zipcode" ).keyup(function() {
$("#dmits-inquiry-sales-output").html("");
addLoader();
if($(this).val().length>=4){
var _this=this;
clearTimeout(timer1);
timer1= setTimeout(function(){
loadZipgeo();
},500);
}
if($(this).val().length==0){
if($( "#dmits-inquiry-sales-country-select" ).val()){
loadZipgeo();
}else{
loadAllDistributions(0);
}
}
});
loadCountries();
function loadCountries(){
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ path('frontend.action.dmits.inquiry-request-allcountries') }}', true);
xhr.onload = function () {
var jsonResponse = JSON.parse(this.responseText);
for(var country of jsonResponse.data.countries){
$("#dmits-inquiry-sales-country-select").append(new Option(country,country));
}
};
xhr.send();
}
function loadData(){
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
if(lat && lng){
loadDistributionsShop(lat,lng,0);
}else{
loadAllDistributionsShop(0);
}
}else{
if(lat && lng){
loadDistributions(lat,lng,0);
}else{
loadAllDistributions(0);
}
}
}
function loadGeoData(){
if ("geolocation" in navigator && zipcode=="") {
navigator.geolocation.getCurrentPosition(function(position) {
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
loadDistributionsShop(position.coords.latitude,position.coords.longitude,0);
}else{
loadDistributions(position.coords.latitude,position.coords.longitude,0);
}
lat=position.coords.latitude;
lng=position.coords.longitude;
var xhr = new XMLHttpRequest();
xhr.open('GET', '{{ path('frontend.action.dmits.inquiry-request-reversegeo') }}?lat='+position.coords.latitude+'&lng='+position.coords.longitude, true);
xhr.onload = function () {
var jsonResponse = JSON.parse(this.responseText);
$("#dmits-inquiry-sales-search-zipcode").val(jsonResponse.data.zip);
zipcode=jsonResponse.data.zip;
};
xhr.send();
},
function(){
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
if($( "#dmits-inquiry-sales-country-select" ).val()){
loadZipgeo();
}else{
loadAllDistributionsShop(0);
}
}else{
if($( "#dmits-inquiry-sales-country-select" ).val()){
loadZipgeo();
}else{
loadAllDistributions(0);
}
}
});
} else {
if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
if($( "#dmits-inquiry-sales-country-select" ).val()){
loadZipgeo();
}else{
loadAllDistributionsShop(0);
}
}else{
if($( "#dmits-inquiry-sales-country-select" ).val()){
loadZipgeo();
}else{
loadAllDistributions(0);
}
}
}
}
$(document).on('click', "#dmits-inquiry-sales-search-zipcode", function() {
if($("#dmits-inquiry-sales-search-zipcode").val()==""){
loadGeoData();
}
});
$(document).on('click', "#btn-dmits-inquirysales-back", function() {
if ($(".dmits-inquiry-sales-step-3").is(":visible")){
openInquiryWindow(this);
}else{
$(".inquirysalesinline").hide();
$("#btn-dmits-inquirysales-back").hide();
if($("body").find(".product-detail").length==0){
$(".cms-section-default").show();
}
else{
$(".product-detail").show();}
}
});
var html = "<div class='cms-section inquirysalesinlinesection'><div class='boxed'></div></div>";
$(".cms-sections").append(html);
function setSalesContainerHeight(){
var height= $(".searchBoxContent").height();
console.log(height);
$(".dmits-inquiry-sales-table-container").css("min-height",height+"px");
}
$(document).on('click', ".btn-dmits-inquirysales", function() {
$(".inquirysalesinline").addClass("nopartner");
$("#btn-dmits-inquirysales-back").show();
{% if not config('DmitsInquirySales.config.inquirypopup')%}
$(".inquirysalesinline").show();
;
if($("body").find(".product-detail").length==0){
//var html = "<div class='cms-section'><div class='boxed'>"+$(".inquirysalesinline").html()+"</div></div>";
//$(".cms-sections").append(html);
$(".cms-section-default").hide();
$(".inquirysalesinline").appendTo(".inquirysalesinlinesection .boxed");
$(".inquirysalesinlinesection").show();
}else{
$(".product-detail").hide();
$(".inquirysalesinline").appendTo(".container-main");
}
{% endif %}
if($(this).attr("id") =="requestContactformButton"){
openContactformWindow(this);
$(".inquirysalesinline").attr("id","stepcontact1");
}else{
{% if config('DmitsInquirySales.config.seperatebuttons')%}
if($(this).attr("id") =="requestBuyButton"){
openBuyWindow(this);
loadAllDistributionsShop(0);
$(".inquirysalesinline").attr("data-type","shop");
}else{
$(".inquirysalesinline").attr("data-type","form");
openInquiryWindow(this);
}
$(".dmits-inquiry-sales-tabs").hide();
{% endif %}
{% if not config('DmitsInquirySales.config.openpopupnpreset')%}
{% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
$(".dmits-inquiry-sales-steps").hide();
{% endif %}
{% if config('DmitsInquirySales.config.buyinquiryselectpopup')%}
$(".dmits-inquiry-sales-step-1").show();
$(".inquirysalesinline").attr("id","step1");
{% else %}
{% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
$(".dmits-inquiry-sales-step-2").show();
$(".inquirysalesinline").attr("id","step2");
{% endif %}
{% endif %}
{% endif %}
}
});
$(document).on('click', ".dmits-inquiry-sales-inquiry-distribution", function() {
companyId=$(this).attr("data-id");
companyName=$(this).attr("data-company");
$(".searchBoxSmall").hide();
$(".searchBox").hide();
$(".dmits-inquiry-sales-step-2").hide();
$(".dmits-inquiry-sales-step-3").show();
$(".inquirysalesinline").attr("id","step3");
$("#dmits-inquiry-sales-product").val($("h1.product-detail-name").text().trim());
$(".dmits-inquiry-sales-companyname").text(companyName);
console.log("dasd");
$(".dmits-inquiry-sales-content-inquiry-header span").hide();
$("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.titlePartnerForm'|trans }}");
});
$(document).on('click', ".searchBox input[type='checkbox'], #dmits-inquiry-sales-searchButton", function() {
loadData();
});
$(document).on('click', "#dmits-inquiry-sales-inquiry", function() {
openInquiryWindow(this);
});
function openContactformWindow(_this){
{% if config('DmitsInquirySales.config.inquirypopup')%}
$("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.contactformheadertitle'|trans }}");
$(".dmits-inquiry-sales-contactform h3").hide();
{% endif %}
$(".dmits-inquiry-sales-contactform").show();
$(".dmits-inquiry-sales-steps").hide();
$(".dmits-inquiry-sales-content-buy").hide();
$(".dmits-inquiry-sales-content-buy-header").hide();
$(".dmits-inquiry-sales-content-inquiry").hide();
$(".dmits-inquiry-sales-content-inquiry-header").hide();
$(".searchBox").hide();
}
function openInquiryWindow(_this){
$(".dmits-inquiry-sales-tabs button" ).removeClass("active");
$("#inquirysalesModalCenter" ).removeClass("dmits-inquiry-sales-buy-active");
$("#inquirysalesModalCenter" ).addClass("dmits-inquiry-sales-inquiry-active");
$(_this).addClass("active");
$(".searchBoxSmall").show();
$(".searchBox").show();
$(".searchContent").addClass("col-sm-9");
$(".searchContent").removeClass("col-sm-12");
loadData();
$(".dmits-inquiry-sales-contactform").hide();
$(".dmits-inquiry-sales-steps").hide();
$(".dmits-inquiry-sales-content-inquiry").show();
$(".dmits-inquiry-sales-content-inquiry-header").show();
$(".dmits-inquiry-sales-content-inquiry-header span").show();
$("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.titlePartnerSearch'|trans }}");
$(".dmits-inquiry-sales-content-buy").hide();
$(".dmits-inquiry-sales-content-buy-header").hide();
{% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
$(".dmits-inquiry-sales-step-1").hide();
{% else %}
$(".inquirysalesinline").attr("id","step1");
$(".dmits-inquiry-sales-step-1").show();
{% endif %}
}
function searchboxbuy(){
{% if config('DmitsInquirySales.config.searchBoxBuy')%}
$(".searchBoxSmall").show();
$(".searchBox").show();
$(".searchContent").addClass("col-sm-9");
$(".searchContent").removeClass("col-sm-12");
{% else %}
$(".searchBoxSmall").hide();
$(".searchBox").hide();
$(".searchContent").removeClass("col-sm-9");
$(".searchContent").addClass("col-sm-12");
{% endif %}
}
$(document).on('click', "#dmits-inquiry-sales-buy", function() {
openBuyWindow(this);
});
function openBuyWindow(_this){
$(".dmits-inquiry-sales-contactform").hide();
$(".dmits-inquiry-sales-tabs button" ).removeClass("active");
$("#inquirysalesModalCenter" ).removeClass("dmits-inquiry-sales-inquiry-active");
$("#inquirysalesModalCenter" ).addClass("dmits-inquiry-sales-buy-active");
searchboxbuy();
$(_this).addClass("active");
$("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.titlePartnerBuy'|trans }}");
loadData();
$(".dmits-inquiry-sales-content-inquiry").hide();
$(".dmits-inquiry-sales-content-inquiry-header").hide();
$(".dmits-inquiry-sales-steps").hide();
$(".dmits-inquiry-sales-content-buy").show();
$(".dmits-inquiry-sales-content-buy-header").show();
{% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
$(".dmits-inquiry-sales-step-1").hide();
{% else %}
$(".dmits-inquiry-sales-step-1").show();
$(".inquirysalesinline").attr("id","step1");
{% endif %}
}
{% if not config('DmitsInquirySales.config.buyinquiryselectpopup')%}
loadAllDistributionsShop(0);
loadAllDistributions(0);
{% endif %}
searchboxbuy();
{% if config('DmitsInquirySales.config.buyinquiryselectpopup')%}
$(".searchBoxSmall").hide();
$(".searchBox").hide();
{% else %}
$("#inquirysalesModalCenter" ).addClass("dmits-inquiry-sales-buy-active");
{% endif %}
var forms = document.getElementsByClassName('dmits-inquiry-sales-form-validation');
Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
var forms = document.getElementsByClassName('dmits-inquiry-sales-contactform-validation');
Array.prototype.filter.call(forms, function(form) {
form.addEventListener('submit', function(event) {
if (form.checkValidity() === false) {
event.preventDefault();
event.stopPropagation();
}
form.classList.add('was-validated');
}, false);
});
$(document).on('submit', ".dmits-inquiry-sales-form-validation", function(e) {
e.preventDefault();
var data = new FormData();
var form_data = jQuery(this).serializeArray();
jQuery.each(form_data, function (key, input) {
data.append(input.name, input.value);
});
$(".dmits-inquiry-sales-form-error").hide();
data.append("companyId", companyId);
data.append("productName", $("h1.product-detail-name").text());
var xhr = new XMLHttpRequest();
xhr.open('POST', '{{ path('frontend.action.dmits.send-request') }}', true);
xhr.onload = function () {
var jsonResponse = JSON.parse(this.responseText);
if(jsonResponse.data=='ok'){
$(".dmits-inquiry-sales-step-3").hide();
$(".dmits-inquiry-sales-companyname").text(companyName);
$(".dmits-inquiry-sales-step-4").show();
$(".inquirysalesinline").attr("id","step4");
}else{
refreshGRECaptcha();
$(".dmits-inquiry-sales-form-error").show();
}
};
xhr.send(data);
});
$(document).on('submit', ".dmits-inquiry-sales-contactform-validation", function(e) {
e.preventDefault();
var data = new FormData();
var form_data = jQuery(this).serializeArray();
jQuery.each(form_data, function (key, input) {
data.append(input.name, input.value);
});
$(".dmits-inquiry-sales-form-error").hide();
data.append("companyId", companyId);
data.append("productName", $("h1.product-detail-name").text());
var xhr = new XMLHttpRequest();
xhr.open('POST', '{{ path('frontend.action.dmits.send-contactformrequest') }}', true);
xhr.onload = function () {
var jsonResponse = JSON.parse(this.responseText);
if(jsonResponse.data=='ok'){
$("#dmits-inquiry-sales-contactform form").hide();
$("#dmits-inquiry-sales-contactform .dmits-inquiry-sales-contactform-headertext").hide();
$("#dmits-inquiry-sales-contactform .dmits-inquiry-sales-contactform-successtext").show();
}else{
refreshGRECaptcha();
$(".dmits-inquiry-sales-form-error").show();
}
};
xhr.send(data);
});
</script>
{% if config('DmitsInquirySales.config.googlerecaptchaactive') %}
<script src="https://www.google.com/recaptcha/api.js?render={{ config('DmitsInquirySales.config.googlerecaptchatoken') }}"></script>
<script>
function refreshGRECaptcha() {
var rca = document.querySelector('[name="dmits-inquiry-sales-rca"]').value;
if (rca == 1) {
var deftoken = document.querySelector("[name='dmits-inquiry-sales-deftoken']").value;
grecaptcha.execute(deftoken, {action: 'homepage'}).then(function (token) {
document.querySelectorAll("[name='dmits-inquiry-sales-token']").forEach(element => {
element.value = token;
});
document.querySelectorAll("[name='dmits-inquiry-sales-token']").value = token;
});
}
};
if (typeof grecaptcha !== 'undefined') {
setInterval(refreshGRECaptcha, 60 * 1000);
grecaptcha.ready(function () {
refreshGRECaptcha();
});
}
</script>
{% if config('DmitsInquirySales.config.googlerecaptchaalogovisible') %}
<style>
.grecaptcha-badge {
display: none;
}
</style>
{% else %}
<style>
.grecaptcha-badge {
opacity: 1;
visibility: visible;
}
</style>
{% endif %}
{% endif %}
{% endblock %}
{% endblock %}