custom/apps/DmitsInquiry/Resources/views/storefront/base.html.twig line 1

Open in your IDE?
  1. {% sw_extends '@Storefront/storefront/base.html.twig' %}
  2. {% block base_script_hmr_mode %}
  3.     {{ parent() }}
  4.     
  5.     {% if config('DmitsInquiry.config.customcss') %}
  6.         <style>
  7.             {{config('DmitsInquiry.config.customcss')}}
  8.         </style>
  9.     {% endif %}
  10.     {% if controllerName|lower=='product' or (config('DmitsInquiry.config.cartinquiry')==1 and controllerName|lower=='checkout') %}
  11.         <script>
  12.         var printinquiry_template="{{"dmits.inquiry.custom.printinquiry"|trans|raw|e("js")}}";
  13.         var printinquiry_filename="{{"dmits.inquiry.custom.printinquiryfilename"|trans}}";
  14.         {% if controllerName|lower=='product'%}
  15.             var pageIs="detail";
  16.                     {%else %}
  17.                     var pageIs="cart"; 
  18.             {% endif %}
  19.         
  20.             window.addEventListener('load', function() {
  21.                 
  22.                    $(document).on('click', ".inquiry-button", function() {
  23.                     $("#productinquiry-message").html('');
  24.                     {% if config('DmitsInquiry.config.position')=="popup" %}
  25.                         $("#productinquirymodal").modal();
  26.                     {% endif %}
  27.     
  28.                     $("#productinquiry").toggle();
  29.                     
  30.                 });
  31.                 $(document).on('submit', "#productinquiry", function(e) {
  32.                 e.preventDefault(); 
  33.                 $("#productinquiry").hide();
  34.                 $("#productinquiry-message").html('<div class="loader" role="status"><span class="sr-only"></span></div>');
  35.                 var me = e.currentTarget;
  36.                 var firstnameca ;
  37.                 if(typeof me.firstnameca!== "undefined"){
  38.                     var firstnameca = me.firstnameca.value;
  39.                 }
  40.                 
  41.     
  42.                 if(firstnameca){
  43.                     $("#productinquiry").show();
  44.                     $("#productinquiry-message").html('<div class="alert alert-danger" role="alert"><div class="alert-content-container"><div class="alert-content">Error</div></div></div>');
  45.                     
  46.                     return;
  47.                  }
  48.     
  49.                 var data = new FormData();
  50.                 data.append('shop-id', '{{appShopId}}');
  51.                 data.append('salesChannelId', '{{context.salesChannelId}}');
  52.                 data.append('salesChannelName', '{{context.salesChannel.translated.name}}');
  53.                 data.append('externalmail', '{{config('DmitsInquiry.config.sendexternalshop')}}');
  54.                 data.append('receipter', '{{config('DmitsInquiry.config.receipterinternal')}}');
  55.                 data.append('customermail', '{{config('DmitsInquiry.config.sendmailcustomer')}}');
  56.                 if(typeof me.salutation!== "undefined"){
  57.                     var salutation = me.salutation.value;
  58.                     data.append('salutation', salutation);
  59.                 }
  60.                 if(typeof me.firstname!== "undefined"){
  61.                     var firstname = me.firstname.value;
  62.                     data.append('firstname', firstname);
  63.                 }
  64.                 if(typeof me.lastname!== "undefined"){
  65.                     var lastname = me.lastname.value;
  66.                     data.append('lastname', lastname);
  67.                 }
  68.                 if(typeof me.company!== "undefined"){
  69.                     var company = me.company.value;
  70.                     data.append('company', company);
  71.                 }
  72.                 if(typeof me.phone!== "undefined"){
  73.                     var phone = me.phone.value;
  74.                     data.append('phone', phone);
  75.                 }
  76.                 if(typeof me.country!== "undefined"){
  77.                     var country = me.country.value;
  78.                     data.append('country', country);
  79.                 }
  80.                 if(typeof me.street!== "undefined"){
  81.                     var street = me.street.value;
  82.                     data.append('street', street);
  83.                 }
  84.                 if(typeof me.zip!== "undefined"){
  85.                     var zip = me.zip.value;
  86.                     data.append('zip', zip);
  87.                 }
  88.                 if(typeof me.city!== "undefined"){
  89.                     var city = me.city.value;
  90.                     data.append('city', city);
  91.                 }
  92.                 if(typeof me.note!== "undefined"){
  93.                     var note = me.note.value;
  94.                     data.append('note', note);
  95.                 }
  96.                 if(typeof me.email!== "undefined"){
  97.                     var email = me.email.value;
  98.                     data.append('email', email);
  99.                 }
  100.                 if(typeof me.file!== "undefined"){
  101.                     var file = me.file.files[0];
  102.                     console.log(file);
  103.                     data.append('file', file);
  104.                 }
  105.                 {% if controllerName|lower=='product'%}
  106.                     data.append('type', 'product');
  107.                     data.append('qty', $(".product-detail-quantity-select").val());
  108.                     data.append('article-id', '{{page.product.productNumber}}');
  109.                     data.append('article-name', '{{page.product.translated.name}}');
  110.                     {% endif %}
  111.                 {% if (config('DmitsInquiry.config.cartinquiry')==1 and controllerName|lower=='checkout')%}
  112.                 data.append('type', 'cart');
  113.                 {% for lineItem in page.cart.lineItems %}
  114.                     data.append('qty[]', '{{ lineItem.quantity }}');
  115.                     data.append('article-id[]', ' {{ lineItem.payload.productNumber }}');
  116.                     data.append('article-name[]', '{{ lineItem.label }}');
  117.                 
  118.                
  119.                 
  120.                      {% endfor %}
  121.                  {% endif %}
  122.                 data.append('subject', '{{  "dmits.inquiry.custom.subject"|trans }}');
  123.                 data.append('content', '{{  ("dmits.inquiry.custom.content"|trans)|replace({"\n": "<br>", "\r": "<br>", "\t": "<br>"}) }}');
  124.                 data.append('subjectcustomer', '{{  "dmits.inquiry.custom.subjectcustomer"|trans }}');
  125.                  data.append('contentcustomer', '{{  ("dmits.inquiry.custom.contentcustomer"|trans)|replace({"\n": "<br>", "\r": "<br>", "\t": "<br>"}) }}');
  126.                 var xhr = new XMLHttpRequest();
  127.                 xhr.open('POST', 'https://sw6appsinquiry.d-mit-s.de/inquiry', true);
  128.                 xhr.onload = function () {
  129.                     var jsonResponse = JSON.parse(this.responseText);
  130.                    if(jsonResponse.code==200){
  131.                        
  132.                        {% if config('DmitsInquiry.config.disableinquiryaftersend')==1 %}
  133.                        $(".inquiry-button").hide();
  134.                        $("#productinquiry").remove();
  135.                        {% endif %}
  136.                        
  137.                        $("#productinquiry-message").html('<div class="alert alert-success" role="alert"><div class="alert-content-container"><div class="alert-content">{{"dmits.inquiry.custom.success"|trans }}</div></div></div>');
  138.                    }else{
  139.                        $("#productinquiry-message").html('<div class="alert alert-danger" role="alert"><div class="alert-content-container"><div class="alert-content">{{"dmits.inquiry.custom.error"|trans }}</div></div></div>');
  140.                        $("#productinquiry").show();
  141.                        }
  142.                 };
  143.                 xhr.send(data);
  144.             });
  145.                 {% if config('DmitsInquiry.config.customjs') %}
  146.     
  147.                     {{config('DmitsInquiry.config.customjs')|raw}}
  148.            
  149.             {% endif %}
  150.             });    
  151.         </script>
  152.     {% endif %}
  153. {% endblock %}