custom/plugins/DmitsInquirySales/src/Resources/views/storefront/base.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@parent/storefront/base.html.twig' %}
  2. {% block base_body %}
  3. <span id="dmits-double-left" style="display:none">
  4.  {% sw_icon 'arrow-medium-double-left' style { 'size': 'fluid', 'pack': 'solid'} %}
  5. </span>
  6. <span id="dmits-left" style="display:none">
  7.  {% sw_icon 'arrow-medium-left' style { 'size': 'fluid', 'pack': 'solid'} %}
  8. </span>
  9. <span id="dmits-right"" style="display:none">
  10. {% sw_icon 'arrow-medium-right' style { 'size': 'fluid', 'pack': 'solid'} %}
  11. </span>
  12. <span id="dmits-double-right" style="display:none">
  13.  {% sw_icon 'arrow-medium-double-right' style { 'size': 'fluid', 'pack': 'solid'} %}
  14. </span>
  15.     {{ parent() }}
  16.     <style>
  17.         {% if not config('DmitsInquirySales.config.buyinquiryselectpopup')%}
  18.           @media screen and (max-width: 900px) {
  19.             .dmits-inquiry-sales-inquiry-distribution-shops{
  20.                 min-height:150px;
  21.                 min-width:150px;
  22.                 font-size: 1em;
  23.             }
  24.             }
  25.         {% endif %}
  26.         .distribution-nav{
  27.         margin:auto;
  28.         margin-top:20px;
  29.         }
  30.         .distribution-nav .pagination{
  31.         display: inline-flex;
  32.         }
  33.         
  34.         .searchBox, 
  35.         .dmits-inquiry-sales-contactform,
  36.         .dmits-inquiry-sales-content-buy,
  37.         .dmits-inquiry-sales-content-buy-header,
  38.         .dmits-inquiry-sales-content-inquiry,
  39.         .dmits-inquiry-sales-content-inquiry-header,
  40.         #btn-dmits-inquirysales-back{
  41.         display: none;
  42.         }
  43.         .searchContent{
  44.         min-height: 80px;
  45.         }
  46.         
  47.         .dmits-inquiry-sales-content-buy-header, .dmits-inquiry-sales-content-inquiry-header{
  48.         margin-bottom: 25px;
  49.         }
  50.         
  51.         #btn-dmits-inquirysales-back{
  52.         margin-top:10x;
  53.         float: left;
  54.         }
  55.         
  56.         .searchBoxContent option:first{
  57.         color:grey;
  58.         }
  59.         
  60.         
  61.         
  62.         .dmits-inquiry-sales-inquiry-distribution-shops{
  63.         background-color: #fff;
  64.         }
  65.         .dmits-inquiry-sales-inquiry-distribution-shops img{
  66.             max-width: 190px;
  67.     max-height: 190px;
  68.         }
  69.         
  70.         .dmits-inquiry-sales-table-head{
  71.         font-size:12px;
  72.         }
  73.         .line:before{
  74.         top:9px;
  75.         }
  76.         
  77.         .dmits-inquiry-sales-form-error{display:none;}
  78.         .dmits-inquiry-sales-inquiry-distribution{
  79.         display:none;
  80.         }
  81.           .dmits-inquiry-sales-inquiry-distribution-mobile .dmits-inquiry-sales-inquiry-distribution{
  82.                 display:block;
  83.                 margin: auto;
  84.                 margin-top: 10px;
  85.             }
  86.         
  87.   @media screen and (min-width: 900px) {
  88. #btn-dmits-inquirysales-back{
  89.         margin-top: -40px;
  90.         }
  91.     .nopartner #btn-dmits-inquirysales-back{
  92.         margin-top: 40px;
  93.         }    
  94.         
  95.    #step3 #btn-dmits-inquirysales-back,#step4 #btn-dmits-inquirysales-back, #stepcontact1 #btn-dmits-inquirysales-back{
  96.         margin-top: 10px;
  97.         }     
  98.         .dmits-inquiry-sales-inquiry-distribution{
  99.             display: block;
  100.         }
  101.             .dmits-inquiry-sales-inquiry-distribution-mobile{
  102.                 display:none;
  103.             }
  104.         .dmits-inquiry-sales-inquiry-distribution-mobile .dmits-inquiry-sales-inquiry-distribution{
  105.                 display:none;
  106.             }
  107.         }
  108.         
  109.      
  110.         
  111.         
  112.       .dmits-inquiry-sales-tabs{
  113.       margin-bottom:20px;
  114.       }
  115.         
  116.         
  117.   .dmits-inquiry-sales-tabs button{
  118.   background:none;
  119.   width: 200px;
  120.   margin:auto;
  121.   
  122.   }    
  123.   .dmits-inquiry-sales-tabs button:focus{
  124. outline:0;
  125.   
  126.   }    
  127.         
  128.         
  129. .dmits-inquiry-sales-inquiry-distribution-shops{
  130. display:grid;
  131. }
  132. .dmits-inquiry-sales-inquiry-distribution-shops img{
  133. margin:auto;
  134. }
  135. .dmits-inquiry-sales-inquiry-distribution-shops .dmits-inquiry-sales-inquiry-distribution-additional-info{
  136. font-size: 16px;
  137. }
  138. {{ config('DmitsInquirySales.config.customCss')|raw}}
  139.     </style>
  140.      
  141.      
  142.     {% if config('DmitsInquirySales.config.inquirypopup')%}
  143.         {% block dmits_inquirysales_requestform_modal %}
  144.         <!-- Modal -->
  145.         <div class="modal fade" data-width="1000" id="inquirysalesModalCenter"
  146.             tabindex="-1" role="dialog"
  147.             aria-labelledby="inquirysalesModalCenterTitle" aria-hidden="true">
  148.             <div style="max-width: 1200px;"
  149.                 class="modal-dialog modal-dialog-centered" role="document">
  150.                 <div class="modal-content">
  151.         
  152.                     {% block dmits_inquirysales_requestform_modalheader %}
  153.                     <div class="modal-header">
  154.                         <h5 class="modal-title" id="inquirysalesModalCenterTitle">
  155.                             {{ 'dmits-inquirysales.popup.popupTitle'|trans }}
  156.                         </h5>
  157.                         <button type="button" class="close" data-dismiss="modal"
  158.                             aria-label="Close">
  159.                             <span aria-hidden="true">&times;</span>
  160.                         </button>
  161.                     </div>
  162.                     {% endblock %}
  163.     
  164.                     {% block dmits_inquirysales_requestform_modalbody %}
  165.                     <div class="modal-body">
  166.                              <div class="dmits-inquiry-sales-contactform">        
  167.         {% set template = "@Storefront/storefront/dmits/contactformcontent.html.twig" %}
  168.                                             {% sw_include template ignore missing %}
  169.         </div>
  170.                         {% set template = "@Storefront/storefront/dmits/content.html.twig" %}
  171.                         {% sw_include template ignore missing %}    
  172.                     </div>
  173.                     {% endblock %}
  174.                 </div>
  175.             </div>
  176.         </div>
  177.         {% endblock %}
  178.         
  179.         {% else %}
  180.         
  181.         <div class="inquirysalesinline">
  182.        
  183.                 <div class="dmits-inquiry-sales-contactform">        
  184.         {% set template = "@Storefront/storefront/dmits/contactformcontent.html.twig" %}
  185.                                             {% sw_include template ignore missing %}
  186.         </div>
  187.         {% set template = "@Storefront/storefront/dmits/content.html.twig" %}
  188.                                             {% sw_include template ignore missing %}    
  189.                                       
  190.                                             <div class="col-12">
  191.                 <button class="btn btn-primary" id="btn-dmits-inquirysales-back">{{ 'dmits-inquirysales.detail.inlineRequestBackButton'|trans }}</button>
  192.                                             
  193.                                             </div>
  194.                     </div>
  195.      {% endif %}
  196.     
  197.     {% block dmits_inquirysales_requestform_script %}
  198.     
  199.     
  200.     <script>
  201.         var companyName="";
  202.         var companyId="";
  203.         var zipcode="";
  204.         var lat="";
  205.         var lng="";
  206.         var onlycountry=false;
  207.         var dmitsInquirySalesLIMITSHOP="{{config('DmitsInquirySales.config.showPerPageShop')}}";
  208.         var dmitsInquirySalesLIMITINQUIRY="{{config('DmitsInquirySales.config.showPerPageInquiry')}}";
  209.         var partnerid="{{page.product.customFields['dmits_inquiry_sales_custom_field__product_partnerid']}}";
  210.     function addLoader(){
  211.         $(".inquirysalesinline").addClass("nopartner");
  212.         $("#dmits-inquiry-sales-shop-output-message").html("");
  213.         $("#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>');    
  214.         
  215.         $("#dmits-inquiry-sales-output-message").html("");
  216.         $("#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>');    
  217.         }
  218.     
  219.         function loadAllDistributions(page){
  220.             console.log(page);
  221.             addLoader();
  222.             
  223.              var data = new FormData();
  224.              data.append("partnerId", partnerid);
  225.              data.append("offset", page);
  226.              data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
  227.              data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
  228.              data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
  229.              data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
  230.              
  231.             var xhr = new XMLHttpRequest();
  232.             xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-all-distributions') }}', true);
  233.             xhr.onload = function () {
  234.         
  235.                 var    json=this.responseText;
  236.                 var jsonResponse = JSON.parse(this.responseText);
  237.                 $(".inquirysalesinline").addClass("nopartner");
  238.                 if(jsonResponse.data.message=="error"){
  239.                     
  240.                     
  241.                     //loadAllDistributions();
  242.                     $("#dmits-inquiry-sales-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
  243.                     $("#dmits-inquiry-sales-output").html("");
  244.                     
  245.                     }else{
  246.                         
  247.                 var htmlOutput="";
  248.                 jsonResponse.data.forEach(element => {
  249.                     var infos="";
  250.                     if(element.company){
  251.                         infos=infos+element.company+'<br>';
  252.                     }
  253.                     if(element.street && element.housenumber){
  254.                         infos=infos+element.street+' '+element.housenumber+'<br>';
  255.                     }else if(element.street){
  256.                         infos=infos+element.street+'<br>';
  257.                     }else if(element.housenumber){
  258.                         infos=infos+element.housenumber+'<br>';
  259.                     }
  260.                     if(element.zip && element.city){
  261.                         infos=infos+element.zip+' '+element.city+'<br>';
  262.                     }else if(element.zip){
  263.                         infos=infos+element.zip+'<br>';
  264.                     }else if(element.city){
  265.                         infos=infos+element.city+'<br>';
  266.                     }
  267.                     if(element.country){
  268.                         infos=infos+element.country+'<br>';
  269.                     }
  270.                     if(element.telephone){
  271.                         infos=infos+element.telephone+'<br>';
  272.                     }
  273.                     if(element.mail){
  274.                         //infos=infos+element.mail+'<br>';
  275.                     }
  276.                     if(element.website){
  277.                         //infos=infos+element.website+'<br>';
  278.                     }
  279.                     if(element.additional_info){
  280.                         infos=infos+'<span class="dmits-inquiry-sales-inquiry-distribution-additional-info">'+element.additional_info+'<br></span>';
  281.                     }
  282.                     var additional1="";
  283.                     var additional2="";
  284.                     var additional3="";
  285.                     var additional4="";
  286.                     
  287.                     {%if config('DmitsInquirySales.config.additionalactive1')%} 
  288.                         {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia1')], context.context) %}
  289.                         {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia1')) %}
  290.                                 {%if config('DmitsInquirySales.config.additionalmedia1') %}
  291.                                 
  292.                              additional1='<img title="{{ 'dmits-inquirysales.additional1'|trans }}" alt="{{ 'dmits-inquirysales.additional1'|trans }}" src="{{(downloadurl.url)}}">'  ;   
  293.     
  294.     
  295.     
  296.                         {% endif %}
  297.                         additional1=additional1+' <span>{{ 'dmits-inquirysales.additional1'|trans|raw }}</span>'  ;   
  298.                     {% endif %}
  299.                     
  300.                     {%if config('DmitsInquirySales.config.additionalactive2')%} 
  301.                     {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia2')], context.context) %}
  302.                     {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia2')) %}
  303.                             {%if config('DmitsInquirySales.config.additionalmedia2') %}
  304.                             
  305.                          additional2='<img title="{{ 'dmits-inquirysales.additional2'|trans }}" alt="{{ 'dmits-inquirysales.additional2'|trans }}" src="{{(downloadurl.url)}}">'  ;   
  306.                     {% endif %}
  307.                     additional2=additional2+' <span>{{ 'dmits-inquirysales.additional2'|trans|raw }}</span>'  ;   
  308.                 {% endif %}
  309.                 
  310.                 {%if config('DmitsInquirySales.config.additionalactive3')%} 
  311.                 {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia3')], context.context) %}
  312.                 {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia3')) %}
  313.                          {%if config('DmitsInquirySales.config.additionalmedia3') %}
  314.                          
  315.                       additional3='<img title="{{ 'dmits-inquirysales.additional3'|trans }}"  alt="{{ 'dmits-inquirysales.additional3'|trans }}" src="{{(downloadurl.url)}}">'  ;   
  316.                 {% endif %}
  317.                 additional3=additional3+' <span>{{ 'dmits-inquirysales.additional3'|trans|raw }}</span>'  ;   
  318.             {% endif %}
  319.             {%if config('DmitsInquirySales.config.additionalactive4')%} 
  320.             {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia4')], context.context) %}
  321.             {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia4')) %}
  322.                     {%if config('DmitsInquirySales.config.additionalmedia4') %}
  323.                     
  324.                  additional4='<img title="{{ 'dmits-inquirysales.additional4'|trans }}" alt="{{ 'dmits-inquirysales.additional4'|trans }}"  src="{{(downloadurl.url)}}">'  ;   
  325.             {% endif %}
  326.             additional4=additional4+' <span>{{ 'dmits-inquirysales.additional4'|trans|raw }}</span>'  ;   
  327.         {% endif %}
  328.                     
  329.                     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>';
  330.                     }
  331.             
  332.                 );
  333.                 htmlOutput="<div class='dmits-inquiry-sales-table-container'>"+htmlOutput+"</div>";
  334.             var pagination=    buildPagination(page+1,jsonResponse.count);
  335.              htmlOutput=htmlOutput+"<div class='row'>"+pagination+"</div>";
  336.                 $("#dmits-inquiry-sales-output").html(htmlOutput);    
  337.                 $(".inquirysalesinline").removeClass("nopartner");
  338.                 setSalesContainerHeight();
  339.                     }
  340.             };
  341.             xhr.send(data);
  342.         }
  343.         function buildPagination(current,total){
  344.             var limit =dmitsInquirySalesLIMITINQUIRY;
  345.             if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  346.                 var limit =dmitsInquirySalesLIMITSHOP;
  347.             }
  348.             
  349.             var totalPages=Math.ceil(total/limit);
  350.             
  351.                             var pages="";
  352.             for(var i=1;i<=totalPages;i++){
  353.             var pageActive="";
  354.             if(i==current){
  355.                 pageActive="active";    
  356.             }
  357.                 
  358.                 var pages=pages+'<li data-page="'+i+'" class="page-item '+pageActive+'"><label class="page-link" >'+i+'</label></li>';
  359.             }
  360.             var disableFirst="";
  361.             var disableLast="";
  362.             if(current==1){
  363.                 disableFirst="disabled";
  364.                 
  365.             }
  366.             if(current==totalPages){
  367.                 disableLast="disabled";
  368.             }
  369.                             
  370.                             var pagination=`<nav aria-label="pagination" class="distribution-nav"><ul class="pagination">
  371.                                 <li data-page="`+1+`" class="page-item page-first `+disableFirst+`"> <label class="page-link" >`+$("#dmits-double-left").html()+`</label></li>
  372.                                 <li data-page="`+(current-1)+`" class="page-item page-prev `+disableFirst+`"><label class="page-link" >`+$("#dmits-left").html()+`</label></li>
  373.                                 `+pages+`
  374.                                 <li data-page="`+(current+1)+`" class="page-item page-next `+disableLast+`"> <label class="page-link" >`+$("#dmits-right").html()+`</label></li>
  375.                                 <li data-page="`+(totalPages)+`" class="page-item page-last `+disableLast+`"><label class="page-link" >`+$("#dmits-double-right").html()+`</label></li>
  376.                                 </ul></div>`;
  377. return pagination;
  378.             }
  379.         $(document).on('click', ".distribution-nav li", function() {
  380. if(!$(this).hasClass("disabled")){
  381. var newpage=$(this).attr("data-page")-1;
  382. if(lat && lng){
  383.     if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  384.         loadDistributionsShop(lat,lng,newpage);
  385.     }else{
  386.         loadDistributions(lat,lng,newpage);
  387.     }
  388. }else{
  389.       if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  390.           loadAllDistributionsShop(newpage)
  391.         }else{
  392.             loadAllDistributions(newpage);
  393.         }
  394. }
  395. }
  396.         });
  397.         
  398.         function loadDistributions(lat,lng,page){
  399.             addLoader();
  400.              var data = new FormData();
  401.              data.append("partnerId", partnerid);
  402.              data.append("offset", page);
  403.              data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
  404.              data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
  405.              data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
  406.              data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
  407.              
  408.             var xhr = new XMLHttpRequest();
  409.             xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-distributions') }}?lat='+lat+'&lng='+lng+'&country='+$("#dmits-inquiry-sales-country-select").val(), true);
  410.             xhr.onload = function () {
  411.         
  412.                 var    json=this.responseText;
  413.                 var jsonResponse = JSON.parse(this.responseText);
  414.                 $(".inquirysalesinline").addClass("nopartner");
  415.                 if(jsonResponse.data.message=="error"){
  416.                     
  417.                     
  418.                     //loadAllDistributions();
  419.                     $("#dmits-inquiry-sales-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
  420.                     $("#dmits-inquiry-sales-output").html("");
  421.                     
  422.                     }else{
  423.                 
  424.                 var htmlOutput="";
  425.                 jsonResponse.data.forEach(element => {
  426.                     var infos="";
  427.                     if(element.company){
  428.                         infos=infos+element.company+'<br>';
  429.                     }
  430.                     if(element.street && element.housenumber){
  431.                         infos=infos+element.street+' '+element.housenumber+'<br>';
  432.                     }else if(element.street){
  433.                         infos=infos+element.street+'<br>';
  434.                     }else if(element.housenumber){
  435.                         infos=infos+element.housenumber+'<br>';
  436.                     }
  437.                     if(element.zip && element.city){
  438.                         infos=infos+element.zip+' '+element.city+'<br>';
  439.                     }else if(element.zip){
  440.                         infos=infos+element.zip+'<br>';
  441.                     }else if(element.city){
  442.                         infos=infos+element.city+'<br>';
  443.                     }
  444.                     if(element.country){
  445.                         infos=infos+element.country+'<br>';
  446.                     }
  447.                     if(element.telephone){
  448.                         infos=infos+element.telephone+'<br>';
  449.                     }
  450.                     if(element.mail){
  451.                         //infos=infos+element.mail+'<br>';
  452.                     }
  453.                     if(element.website){
  454.                     //    infos=infos+element.website+'<br>';
  455.                     }
  456.                     if(element.additional_info){
  457.                         infos=infos+'<span class="dmits-inquiry-sales-inquiry-distribution-additional-info">'+element.additional_info+'<br></span>';
  458.                     }
  459.                     var additional1="";
  460.                     var additional2="";
  461.                     var additional3="";
  462.                     var additional4="";
  463.                     
  464.                     {%if config('DmitsInquirySales.config.additionalactive1')%} 
  465.                         {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia1')], context.context) %}
  466.                         {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia1')) %}
  467.                                 {%if config('DmitsInquirySales.config.additionalmedia1') %}
  468.                                 
  469.                               additional1='<img title="{{ 'dmits-inquirysales.additional1'|trans }}" alt="{{ 'dmits-inquirysales.additional1'|trans }}" src="{{(downloadurl.url)}}">'  ;   
  470.                               
  471.                               
  472.                               
  473.                               {% endif %}
  474.                               additional1=additional1+' <span>{{ 'dmits-inquirysales.additional1'|trans|raw }}</span>'  ;   
  475.                           {% endif %}
  476.                           
  477.                           {%if config('DmitsInquirySales.config.additionalactive2')%} 
  478.                           {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia2')], context.context) %}
  479.                           {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia2')) %}
  480.                                   {%if config('DmitsInquirySales.config.additionalmedia2') %}
  481.                                   
  482.                                additional2='<img title="{{ 'dmits-inquirysales.additional2'|trans }}" alt="{{ 'dmits-inquirysales.additional2'|trans }}" src="{{(downloadurl.url)}}">'  ;   
  483.                           {% endif %}
  484.                           additional2=additional2+' <span>{{ 'dmits-inquirysales.additional2'|trans|raw }}</span>'  ;   
  485.                       {% endif %}
  486.                       
  487.                       {%if config('DmitsInquirySales.config.additionalactive3')%} 
  488.                       {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia3')], context.context) %}
  489.                       {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia3')) %}
  490.                                {%if config('DmitsInquirySales.config.additionalmedia3') %}
  491.                                
  492.                             additional3='<img title="{{ 'dmits-inquirysales.additional3'|trans }}"  alt="{{ 'dmits-inquirysales.additional3'|trans }}" src="{{(downloadurl.url)}}">'  ;   
  493.                       {% endif %}
  494.                       additional3=additional3+' <span>{{ 'dmits-inquirysales.additional3'|trans|raw }}</span>'  ;   
  495.                   {% endif %}
  496.                   {%if config('DmitsInquirySales.config.additionalactive4')%} 
  497.                   {% set media = searchMedia([config('DmitsInquirySales.config.additionalmedia4')], context.context) %}
  498.                   {% set downloadurl = media.get(config('DmitsInquirySales.config.additionalmedia4')) %}
  499.                           {%if config('DmitsInquirySales.config.additionalmedia4') %}
  500.                           
  501.                        additional4='<img title="{{ 'dmits-inquirysales.additional4'|trans }}" alt="{{ 'dmits-inquirysales.additional4'|trans }}"  src="{{(downloadurl.url)}}">'  ;   
  502.             {% endif %}
  503.             additional4=additional4+ ' <span>{{ 'dmits-inquirysales.additional4'|trans|raw }}</span>'  ;   
  504.         {% endif %}
  505.                     
  506.                     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>';
  507.                     }
  508.                 );
  509.                 htmlOutput="<div class='dmits-inquiry-sales-table-container'>"+htmlOutput+"</div>";
  510.                 var pagination=    buildPagination(page+1,jsonResponse.count);
  511.                  htmlOutput=htmlOutput+"<div class='row'>"+pagination+"</div>";
  512.                 
  513.                     $("#dmits-inquiry-sales-output").html(htmlOutput);    
  514.                 $(".inquirysalesinline").removeClass("nopartner");
  515.                setSalesContainerHeight();
  516.                     }
  517.                 };
  518.             xhr.send(data);
  519.         }
  520.         function loadAllDistributionsShop(page){ 
  521.             addLoader();
  522.             var data = new FormData();
  523.             data.append("partnerId", partnerid);
  524.             data.append("offset", page);
  525.             data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
  526.             data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
  527.             data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
  528.             data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
  529.             
  530.            var xhr = new XMLHttpRequest();
  531.            xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-distributions-shop') }}', true);
  532.            xhr.onload = function () {
  533.        
  534.                var    json=this.responseText;
  535.                var jsonResponse = JSON.parse(this.responseText);
  536.                $(".inquirysalesinline").addClass("nopartner");
  537.                if(jsonResponse.data.message=="error"){
  538.                    
  539.                    
  540.    
  541.                    $("#dmits-inquiry-sales-shop-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
  542.                    $("#dmits-inquiry-sales-shop-output").html("");
  543.                    
  544.                    }else{
  545.                     
  546.                
  547.                var htmlOutput="";
  548.                jsonResponse.data.forEach(element => {
  549.                var showText=element.company;
  550.                var additional_info=element.additional_info;
  551.                if(additional_info==null){
  552.                    additional_info="";
  553.                }else{
  554.                    additional_info="<span>"+additional_info+"</span>";
  555.                }
  556.                if(element.mediaUrl){
  557.                    showText="<div class='dmits-inquiry-sales-inquiry-distribution-image'><img src='"+element.mediaUrl+"'></div>";
  558.                    }
  559.                
  560.                
  561.                    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>";
  562.                    }
  563.            
  564.                );
  565.                htmlOutput="<div class='row'>"+htmlOutput+"</div>"      ;
  566.                var pagination=    buildPagination(page+1,jsonResponse.count);
  567.                htmlOutput=htmlOutput+"<div class='row'>"+pagination+"</div>";
  568.                $("#dmits-inquiry-sales-shop-output").html(htmlOutput);
  569.                $(".inquirysalesinline").removeClass("nopartner");
  570.                setSalesContainerHeight();
  571.                
  572.                    }    
  573.            };
  574.            xhr.send(data);
  575.        }
  576.     
  577.         function loadDistributionsShop(lat,lng,page){
  578.            
  579.             addLoader();
  580.              var data = new FormData();
  581.              data.append("partnerId", partnerid);
  582.              data.append("offset", page);
  583.              data.append("additional1", $("#dmits-inquiry-sales-additional1").is(":checked"));
  584.              data.append("additional2", $("#dmits-inquiry-sales-additional2").is(":checked"));
  585.              data.append("additional3", $("#dmits-inquiry-sales-additional3").is(":checked"));
  586.              data.append("additional4", $("#dmits-inquiry-sales-additional4").is(":checked"));
  587.              
  588.             var xhr = new XMLHttpRequest();
  589.             xhr.open('POST', '{{ path('frontend.action.dmits.inquiry-request-distributions-shop') }}?lat='+lat+'&lng='+lng+'&country='+$("#dmits-inquiry-sales-country-select").val(), true);
  590.             xhr.onload = function () {
  591.         
  592.                 var    json=this.responseText;
  593.                 var jsonResponse = JSON.parse(this.responseText);
  594.                 $(".inquirysalesinline").addClass("nopartner");
  595.                 if(jsonResponse.data.message=="error"){
  596.                     
  597.                     
  598.                     //loadAllDistributions();
  599.                     $("#dmits-inquiry-sales-shop-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
  600.                     $("#dmits-inquiry-sales-shop-output").html("");
  601.                     
  602.                     }else{
  603.                 
  604.             
  605.                 
  606.                 var htmlOutput="";
  607.                 jsonResponse.data.forEach(element => {
  608.                 var showText=element.company;
  609.                 var additional_info=element.additional_info;
  610.                 if(additional_info==null){
  611.                        additional_info="";
  612.                    }else{
  613.                        additional_info="<span>"+additional_info+"</span>";
  614.                    }
  615.                 if(element.mediaUrl){
  616.                     showText="<div class='dmits-inquiry-sales-inquiry-distribution-image'><img src='"+element.mediaUrl+"'></div>";
  617.                     }
  618.                 
  619.                 
  620.                     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>";
  621.                     }
  622.             
  623.                 );
  624.                 var pagination=    buildPagination(page+1,jsonResponse.count);
  625.                 htmlOutput=htmlOutput+pagination;
  626.                 
  627.                 $("#dmits-inquiry-sales-shop-output").html("<div class='row'>"+htmlOutput+"</div>");
  628.                 $(".inquirysalesinline").removeClass("nopartner");
  629.                     }    
  630.             };
  631.             xhr.send(data);
  632.         }
  633. function loadZipgeo(){
  634.     var xhr = new XMLHttpRequest();
  635.     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);
  636.     xhr.onload = function () {
  637.         var jsonResponse = JSON.parse(this.responseText);
  638.         $(".inquirysalesinline").addClass("nopartner");
  639.         if(jsonResponse.data.message=="error"){
  640.             
  641.             
  642.             //loadAllDistributions();
  643.             $("#dmits-inquiry-sales-output-message").html("{{ 'dmits-inquirysales.error.nopartner'|trans|raw }}");
  644.             $("#dmits-inquiry-sales-output").html("");
  645.         
  646.             if($("#dmits-inquiry-sales-search-zipcode").val()=="" && $("#dmits-inquiry-sales-country-select").val()=="{{ 'dmits-inquirysales.countryplaceholder'|trans }}"){
  647.                   if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  648.                       loadAllDistributionsShop(0)
  649.                     }else{
  650.                         loadAllDistributions(0);
  651.                     }
  652.                 }
  653.             lat="";
  654.             lng="";
  655.             }else{
  656.                 
  657.                 lat=jsonResponse.data.lat;
  658.                 lng=jsonResponse.data.lng;
  659.                 onlycountry=jsonResponse.data.onlyCountry;
  660.             if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  661.                 loadDistributionsShop(jsonResponse.data.lat,jsonResponse.data.lng,0);
  662.             }else{
  663.                 loadDistributions(jsonResponse.data.lat,jsonResponse.data.lng,0);
  664.             }
  665.                 
  666.             
  667.         
  668.         
  669.             }
  670.     };
  671.     xhr.send();
  672.     
  673. }
  674.     $( "#dmits-inquiry-sales-country-select" ).change(function() {
  675.         loadZipgeo();    
  676.     });
  677.         
  678.         var timer1;
  679.         $( "#dmits-inquiry-sales-search-zipcode" ).keyup(function() {
  680.             $("#dmits-inquiry-sales-output").html("");
  681.             addLoader();
  682.         
  683.             if($(this).val().length>=4){
  684.             var _this=this;
  685.                     clearTimeout(timer1);
  686.                     timer1= setTimeout(function(){
  687.                 
  688.                 
  689.                                 
  690.                         
  691.                         loadZipgeo();    
  692.                 
  693.           
  694.                 
  695.             },500);
  696.             }
  697.             if($(this).val().length==0){
  698.                 if($( "#dmits-inquiry-sales-country-select" ).val()){
  699.                     loadZipgeo();    
  700.                     }else{
  701.                         loadAllDistributions(0);
  702.                         }
  703.                 
  704.             }
  705.             
  706.         });
  707.     
  708.     
  709.         loadCountries();
  710.     function loadCountries(){
  711.         var xhr = new XMLHttpRequest();
  712.         xhr.open('GET', '{{ path('frontend.action.dmits.inquiry-request-allcountries') }}', true);
  713.         xhr.onload = function () {
  714.             var jsonResponse = JSON.parse(this.responseText);
  715.       
  716.         for(var country of     jsonResponse.data.countries){
  717.       
  718. $("#dmits-inquiry-sales-country-select").append(new Option(country,country));
  719.             
  720.             }
  721.   
  722.         };
  723.         xhr.send();
  724.    }
  725. function loadData(){
  726.       if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  727.           if(lat && lng){
  728.               loadDistributionsShop(lat,lng,0);
  729.                  }else{
  730.              loadAllDistributionsShop(0);
  731.              }
  732.           
  733.       }else{
  734.           if(lat && lng){
  735.               loadDistributions(lat,lng,0);
  736.                  }else{
  737.                      loadAllDistributions(0);
  738.              }
  739.       }
  740. }
  741.     
  742.         function loadGeoData(){
  743.             if ("geolocation" in navigator && zipcode=="") {
  744.                 navigator.geolocation.getCurrentPosition(function(position) {
  745.         
  746.                     
  747.                     
  748.                     if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  749.                         loadDistributionsShop(position.coords.latitude,position.coords.longitude,0);
  750.                     }else{
  751.                         loadDistributions(position.coords.latitude,position.coords.longitude,0);
  752.                     }
  753.                     lat=position.coords.latitude;
  754.                     lng=position.coords.longitude;
  755.                     
  756.                       
  757.                     var xhr = new XMLHttpRequest();
  758.                     xhr.open('GET', '{{ path('frontend.action.dmits.inquiry-request-reversegeo') }}?lat='+position.coords.latitude+'&lng='+position.coords.longitude, true);
  759.                     xhr.onload = function () {
  760.         
  761.                     
  762.                         var jsonResponse = JSON.parse(this.responseText);
  763.      
  764.                         $("#dmits-inquiry-sales-search-zipcode").val(jsonResponse.data.zip);
  765.                         zipcode=jsonResponse.data.zip;
  766.               
  767.                     };
  768.                     xhr.send();
  769.         
  770.         
  771.         
  772.                       
  773.                     },
  774.                 function(){
  775.                         if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  776.                             if($( "#dmits-inquiry-sales-country-select" ).val()){
  777.                                 loadZipgeo();
  778.                             }else{
  779.                                 loadAllDistributionsShop(0);
  780.                                 }
  781.                             
  782.                         }else{
  783.                             if($( "#dmits-inquiry-sales-country-select" ).val()){
  784.                                 loadZipgeo();
  785.                             }else{
  786.                                 loadAllDistributions(0);
  787.                                 }
  788.                         }
  789.                         
  790.                     });    
  791.             } else {
  792.                 
  793.                 
  794.                 if($(".inquirysalesinline" ).attr("data-type")=="shop" || $("#inquirysalesModalCenter" ).hasClass("dmits-inquiry-sales-buy-active")){
  795.                     if($( "#dmits-inquiry-sales-country-select" ).val()){
  796.                         loadZipgeo();
  797.                     }else{
  798.                         loadAllDistributionsShop(0);
  799.                         }
  800.                 }else{
  801.                     if($( "#dmits-inquiry-sales-country-select" ).val()){
  802.                         loadZipgeo();
  803.                     }else{
  804.                         loadAllDistributions(0);
  805.                         }
  806.                 }
  807.             }
  808.         }
  809.         $(document).on('click', "#dmits-inquiry-sales-search-zipcode", function() {
  810.         if($("#dmits-inquiry-sales-search-zipcode").val()==""){
  811.             loadGeoData();
  812.             }
  813.             
  814.         });
  815.         
  816.         $(document).on('click', "#btn-dmits-inquirysales-back", function() {
  817.             if ($(".dmits-inquiry-sales-step-3").is(":visible")){
  818.                 openInquiryWindow(this);
  819.                 }else{
  820.                     $(".inquirysalesinline").hide();
  821.                     $("#btn-dmits-inquirysales-back").hide();
  822.             
  823.                     if($("body").find(".product-detail").length==0){
  824.                         $(".cms-section-default").show();
  825.                     }
  826.                     else{
  827.                         $(".product-detail").show();}
  828.             
  829.             
  830.                 }
  831.             
  832.         });
  833.         var html = "<div class='cms-section inquirysalesinlinesection'><div class='boxed'></div></div>";
  834.         $(".cms-sections").append(html);
  835. function setSalesContainerHeight(){
  836.     
  837. var height=    $(".searchBoxContent").height();
  838. console.log(height);
  839.         $(".dmits-inquiry-sales-table-container").css("min-height",height+"px");
  840. }
  841.          $(document).on('click', ".btn-dmits-inquirysales", function() {
  842.              $(".inquirysalesinline").addClass("nopartner");
  843.              
  844.              $("#btn-dmits-inquirysales-back").show();
  845.              {% if not config('DmitsInquirySales.config.inquirypopup')%}
  846.                  $(".inquirysalesinline").show();
  847.                  ;
  848.                  if($("body").find(".product-detail").length==0){
  849.                  //var html = "<div class='cms-section'><div class='boxed'>"+$(".inquirysalesinline").html()+"</div></div>";
  850.                  //$(".cms-sections").append(html);
  851.                  $(".cms-section-default").hide();
  852.                  $(".inquirysalesinline").appendTo(".inquirysalesinlinesection .boxed");
  853.                  $(".inquirysalesinlinesection").show();
  854.                  }else{
  855.                  $(".product-detail").hide();
  856.                  $(".inquirysalesinline").appendTo(".container-main");
  857.                  }
  858.                  
  859.              {% endif %}
  860.              if($(this).attr("id") =="requestContactformButton"){
  861.                  openContactformWindow(this);
  862.                  $(".inquirysalesinline").attr("id","stepcontact1");
  863.              }else{
  864.              
  865.              {% if config('DmitsInquirySales.config.seperatebuttons')%}
  866.       
  867.              
  868.                 if($(this).attr("id") =="requestBuyButton"){
  869.                     openBuyWindow(this);
  870.                     loadAllDistributionsShop(0);
  871.                     $(".inquirysalesinline").attr("data-type","shop");
  872.                     }else{
  873.                         $(".inquirysalesinline").attr("data-type","form");
  874.                         openInquiryWindow(this);
  875.                         }
  876.                    $(".dmits-inquiry-sales-tabs").hide();
  877.              {% endif %}
  878.              
  879.              {% if not config('DmitsInquirySales.config.openpopupnpreset')%}
  880.                  {% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
  881.                      $(".dmits-inquiry-sales-steps").hide();
  882.                  {% endif %}
  883.                  {% if config('DmitsInquirySales.config.buyinquiryselectpopup')%}
  884.                      $(".dmits-inquiry-sales-step-1").show();
  885.                      $(".inquirysalesinline").attr("id","step1");
  886.                  {% else %}
  887.                      {% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
  888.                          $(".dmits-inquiry-sales-step-2").show();
  889.                          $(".inquirysalesinline").attr("id","step2");
  890.                      {% endif %}
  891.                  {% endif %}
  892.              {% endif %}
  893.              }
  894.         });
  895.         $(document).on('click', ".dmits-inquiry-sales-inquiry-distribution", function() {
  896.             
  897.             companyId=$(this).attr("data-id");
  898.             companyName=$(this).attr("data-company");
  899.             $(".searchBoxSmall").hide();
  900.             $(".searchBox").hide();
  901.             
  902.             $(".dmits-inquiry-sales-step-2").hide();
  903.             $(".dmits-inquiry-sales-step-3").show();
  904.             $(".inquirysalesinline").attr("id","step3");
  905.             $("#dmits-inquiry-sales-product").val($("h1.product-detail-name").text().trim());
  906.             $(".dmits-inquiry-sales-companyname").text(companyName);
  907.             console.log("dasd");
  908.             
  909.             $(".dmits-inquiry-sales-content-inquiry-header span").hide();
  910.             
  911.             $("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.titlePartnerForm'|trans }}");
  912.             
  913.         });
  914.         $(document).on('click', ".searchBox input[type='checkbox'], #dmits-inquiry-sales-searchButton", function() {
  915.             loadData();
  916.         });
  917.    
  918.             
  919.         
  920.         
  921.         $(document).on('click', "#dmits-inquiry-sales-inquiry", function() {
  922.     
  923.             openInquiryWindow(this);
  924.         });
  925.         
  926.         function openContactformWindow(_this){
  927.             {% if config('DmitsInquirySales.config.inquirypopup')%}
  928.             
  929.             $("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.contactformheadertitle'|trans }}");
  930.             $(".dmits-inquiry-sales-contactform h3").hide();
  931.             
  932.             {% endif %}
  933.  
  934.             
  935.             $(".dmits-inquiry-sales-contactform").show();
  936.             $(".dmits-inquiry-sales-steps").hide();
  937.             $(".dmits-inquiry-sales-content-buy").hide();
  938.             $(".dmits-inquiry-sales-content-buy-header").hide();
  939.             $(".dmits-inquiry-sales-content-inquiry").hide();
  940.             $(".dmits-inquiry-sales-content-inquiry-header").hide();
  941.             $(".searchBox").hide();
  942.             
  943.         }
  944.         
  945.         function openInquiryWindow(_this){
  946.             $(".dmits-inquiry-sales-tabs button" ).removeClass("active");
  947.             $("#inquirysalesModalCenter" ).removeClass("dmits-inquiry-sales-buy-active");
  948.             $("#inquirysalesModalCenter" ).addClass("dmits-inquiry-sales-inquiry-active");
  949.             $(_this).addClass("active");
  950.             $(".searchBoxSmall").show();
  951.             $(".searchBox").show();
  952.             $(".searchContent").addClass("col-sm-9");
  953.             $(".searchContent").removeClass("col-sm-12");
  954.             loadData();
  955.             $(".dmits-inquiry-sales-contactform").hide();
  956.             $(".dmits-inquiry-sales-steps").hide();
  957.             $(".dmits-inquiry-sales-content-inquiry").show();
  958.             $(".dmits-inquiry-sales-content-inquiry-header").show();
  959.             $(".dmits-inquiry-sales-content-inquiry-header span").show();
  960.             $("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.titlePartnerSearch'|trans }}");
  961.             
  962.             $(".dmits-inquiry-sales-content-buy").hide();
  963.             $(".dmits-inquiry-sales-content-buy-header").hide();
  964.             {% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
  965.                 $(".dmits-inquiry-sales-step-1").hide();
  966.             {% else %}
  967.             $(".inquirysalesinline").attr("id","step1");
  968.                 $(".dmits-inquiry-sales-step-1").show();
  969.             {% endif %}
  970.             }
  971.         function searchboxbuy(){
  972.             {% if config('DmitsInquirySales.config.searchBoxBuy')%}
  973.             $(".searchBoxSmall").show();
  974.             $(".searchBox").show();
  975.             $(".searchContent").addClass("col-sm-9");
  976.             $(".searchContent").removeClass("col-sm-12");
  977.             
  978.             {% else %}
  979.             $(".searchBoxSmall").hide();
  980.             $(".searchBox").hide();
  981.             $(".searchContent").removeClass("col-sm-9");
  982.             $(".searchContent").addClass("col-sm-12");
  983.         {% endif %}
  984.         }
  985.         $(document).on('click', "#dmits-inquiry-sales-buy", function() {
  986.             openBuyWindow(this);
  987.     
  988.         });
  989. function openBuyWindow(_this){
  990.     $(".dmits-inquiry-sales-contactform").hide();
  991.     $(".dmits-inquiry-sales-tabs button" ).removeClass("active");
  992.     $("#inquirysalesModalCenter" ).removeClass("dmits-inquiry-sales-inquiry-active");
  993.     $("#inquirysalesModalCenter" ).addClass("dmits-inquiry-sales-buy-active");
  994.     
  995.     searchboxbuy();
  996.     
  997.     $(_this).addClass("active");
  998.     $("#inquirysalesModalCenterTitle").text("{{ 'dmits-inquirysales.popup.titlePartnerBuy'|trans }}");
  999.     loadData();
  1000.     $(".dmits-inquiry-sales-content-inquiry").hide();
  1001.     $(".dmits-inquiry-sales-content-inquiry-header").hide();
  1002.     $(".dmits-inquiry-sales-steps").hide();
  1003.     
  1004.     $(".dmits-inquiry-sales-content-buy").show();
  1005.     $(".dmits-inquiry-sales-content-buy-header").show();
  1006.     {% if not config('DmitsInquirySales.config.buyinquiryselectpopuptabs')%}
  1007.         $(".dmits-inquiry-sales-step-1").hide();
  1008.     {% else %}
  1009.         $(".dmits-inquiry-sales-step-1").show();
  1010.         $(".inquirysalesinline").attr("id","step1");
  1011.     {% endif %}
  1012. }
  1013.         
  1014.         {% if not config('DmitsInquirySales.config.buyinquiryselectpopup')%}
  1015.             loadAllDistributionsShop(0);
  1016.             loadAllDistributions(0);
  1017.         {% endif %}
  1018.         searchboxbuy();
  1019.         {% if config('DmitsInquirySales.config.buyinquiryselectpopup')%}
  1020.             $(".searchBoxSmall").hide();
  1021.             $(".searchBox").hide();
  1022.             {% else %}
  1023.             $("#inquirysalesModalCenter" ).addClass("dmits-inquiry-sales-buy-active");
  1024.         {% endif %}
  1025.     
  1026.         var forms = document.getElementsByClassName('dmits-inquiry-sales-form-validation');
  1027.         Array.prototype.filter.call(forms, function(form) {
  1028.             form.addEventListener('submit', function(event) {
  1029.                 if (form.checkValidity() === false) {
  1030.                     event.preventDefault();
  1031.                     event.stopPropagation();
  1032.                 }
  1033.                 form.classList.add('was-validated');
  1034.             }, false);
  1035.         });
  1036.         var forms = document.getElementsByClassName('dmits-inquiry-sales-contactform-validation');
  1037.         Array.prototype.filter.call(forms, function(form) {
  1038.             form.addEventListener('submit', function(event) {
  1039.                 if (form.checkValidity() === false) {
  1040.                     event.preventDefault();
  1041.                     event.stopPropagation();
  1042.                 }
  1043.                 form.classList.add('was-validated');
  1044.             }, false);
  1045.         });
  1046.     
  1047.         $(document).on('submit', ".dmits-inquiry-sales-form-validation", function(e) {
  1048.             e.preventDefault();
  1049.              var data = new FormData();
  1050.             var form_data = jQuery(this).serializeArray();
  1051.             jQuery.each(form_data, function (key, input) {
  1052.                 data.append(input.name, input.value);
  1053.             });
  1054.     
  1055.     $(".dmits-inquiry-sales-form-error").hide();
  1056.     
  1057.             data.append("companyId", companyId);
  1058.             data.append("productName", $("h1.product-detail-name").text());
  1059.             var xhr = new XMLHttpRequest();
  1060.             xhr.open('POST', '{{ path('frontend.action.dmits.send-request') }}', true);
  1061.             xhr.onload = function () {
  1062.     
  1063.                 var jsonResponse = JSON.parse(this.responseText);
  1064.                 if(jsonResponse.data=='ok'){
  1065.                      $(".dmits-inquiry-sales-step-3").hide();
  1066.                     $(".dmits-inquiry-sales-companyname").text(companyName);
  1067.                     $(".dmits-inquiry-sales-step-4").show();
  1068.                     $(".inquirysalesinline").attr("id","step4");
  1069.                 }else{
  1070.                     refreshGRECaptcha();
  1071.                     $(".dmits-inquiry-sales-form-error").show();
  1072.                     }
  1073.       
  1074.             };
  1075.             xhr.send(data);
  1076.    
  1077.         });
  1078.         $(document).on('submit', ".dmits-inquiry-sales-contactform-validation", function(e) {
  1079.             e.preventDefault();
  1080.              var data = new FormData();
  1081.             var form_data = jQuery(this).serializeArray();
  1082.             jQuery.each(form_data, function (key, input) {
  1083.                 data.append(input.name, input.value);
  1084.             });
  1085.     
  1086.     $(".dmits-inquiry-sales-form-error").hide();
  1087.     
  1088.             data.append("companyId", companyId);
  1089.             data.append("productName", $("h1.product-detail-name").text());
  1090.             var xhr = new XMLHttpRequest();
  1091.             xhr.open('POST', '{{ path('frontend.action.dmits.send-contactformrequest') }}', true);
  1092.             xhr.onload = function () {
  1093.     
  1094.                 var jsonResponse = JSON.parse(this.responseText);
  1095.                 if(jsonResponse.data=='ok'){
  1096.                      $("#dmits-inquiry-sales-contactform form").hide();
  1097.                      $("#dmits-inquiry-sales-contactform .dmits-inquiry-sales-contactform-headertext").hide();
  1098.                     $("#dmits-inquiry-sales-contactform .dmits-inquiry-sales-contactform-successtext").show();
  1099.                 }else{
  1100.                     refreshGRECaptcha();
  1101.                     $(".dmits-inquiry-sales-form-error").show();
  1102.                     }
  1103.       
  1104.             };
  1105.             xhr.send(data);
  1106.    
  1107.         });
  1108.     
  1109.     </script>
  1110.     
  1111.       {% if config('DmitsInquirySales.config.googlerecaptchaactive')  %}
  1112.             <script src="https://www.google.com/recaptcha/api.js?render={{ config('DmitsInquirySales.config.googlerecaptchatoken')  }}"></script>
  1113.             <script>
  1114.                 function refreshGRECaptcha() {
  1115.                     var rca = document.querySelector('[name="dmits-inquiry-sales-rca"]').value;
  1116.                     if (rca == 1) {
  1117.                         var deftoken = document.querySelector("[name='dmits-inquiry-sales-deftoken']").value;
  1118.                       
  1119.                         grecaptcha.execute(deftoken, {action: 'homepage'}).then(function (token) { 
  1120.                         document.querySelectorAll("[name='dmits-inquiry-sales-token']").forEach(element => {
  1121.                             element.value = token;
  1122.                         });
  1123.                             document.querySelectorAll("[name='dmits-inquiry-sales-token']").value = token;
  1124.                         });
  1125.                     }
  1126.                 };
  1127.                 if (typeof grecaptcha !== 'undefined') {
  1128.                     setInterval(refreshGRECaptcha, 60 * 1000);
  1129.                     grecaptcha.ready(function () {
  1130.                         refreshGRECaptcha();
  1131.                     });
  1132.                 }
  1133.             </script>
  1134.             {% if config('DmitsInquirySales.config.googlerecaptchaalogovisible')  %}
  1135.                 <style>
  1136.                     .grecaptcha-badge {
  1137.                         display: none;
  1138.                     }
  1139.                 </style>
  1140.                 {% else %}
  1141.                 <style>
  1142.                     .grecaptcha-badge {
  1143.                         opacity: 1;
  1144.                         visibility: visible;
  1145.                     }
  1146.                 </style>
  1147.             {% endif %}
  1148.         {% endif %}
  1149.     
  1150.     {% endblock %}
  1151. {% endblock %}