app/Plugin/RelatedProduct42/Resource/template/admin/related_product.twig line 1

Open in your IDE?
  1. {#
  2.  This file is part of the Related Product plugin
  3.  Copyright(c) 2000-2016 EC-CUBE CO.,LTD. All Rights Reserved.
  4.  http://www.ec-cube.co.jp/
  5.  For the full copyright and license information, please view the LICENSE
  6.  file that was distributed with this source code.
  7. #}
  8. <script>
  9. $(function() {
  10.     $('#plugin_related_product_related_product').appendTo('.c-contentsArea__primaryCol');
  11.     $('#plugin_related_product_related_product').removeClass('d-none');
  12.     var dataId = null;
  13.     $(document).on('click', 'button[id^="RelatedProduct-delete"]', function() {
  14.         var data = $(this).data();
  15.         $('.RelatedProduct-view' + data.id ).addClass('d-none');
  16.         $('#admin_product_RelatedProducts_' + data.id + '_ChildProduct').val('');
  17.         $('#admin_product_RelatedProducts_' + data.id + '_content' ).val('');
  18.         $('#RelatedProductSearchResult').children().remove();
  19.     });
  20.     $(document).on("click", 'button[id^="RelatedProduct-search"]', function () {
  21.         dataId = $(this).attr("data-id");
  22.         $("#RelatedProductDataId").val(dataId);
  23.         $("#RelatedProductSearchResult").children().remove();
  24.     });
  25.     $("#RelatedProductSearchButton").on("click", function () {
  26.         var formIdVal = $("#{{ searchForm.id.vars.id }}").val();
  27.         var formCatIdVal = $("#{{ searchForm.category_id.vars.id }}").val();
  28.         var data = {
  29.             id: formIdVal,
  30.             category_id: formCatIdVal,
  31.             product_id: {{ Product.id ? Product.id : 0 }}
  32.         };
  33.         $("#RelatedProductSearchResult")
  34.                 .children()
  35.                 .remove();
  36.         $.ajax({
  37.             type: "POST",
  38.             url: "{{ url('admin_related_product_search') }}",
  39.             data: data,
  40.             success: function(data){
  41.                 $("#RelatedProductSearchResult").append(data);
  42.             },
  43.             error: function() {
  44.                 alert('product search failed.');
  45.             }
  46.         });
  47.     });
  48. });
  49. </script>
  50. <div id="plugin_related_product_related_product" class="d-none">
  51.     <div class="card rounded border-0 mb-4">
  52.         <div class="card-header">
  53.             <span class="card-title">{{ form.RelatedProducts.vars.label|trans }}</span>
  54.         </div>
  55.         <div class="card-body">
  56.             {% for RelatedProductForm in form.RelatedProducts %}
  57.             {% set RelatedProduct = RelatedProductForm.vars.value %}
  58.             {% set ChildProduct = RelatedProduct.ChildProduct %}
  59.             <div class="row mb-2">
  60.                 <div class="col-3">
  61.                     <label>
  62.                         {{ RelatedProductForm.ChildProduct.vars.label }}
  63.                     </label>
  64.                 </div>
  65.                 <div class="col-9">
  66.                     {% if ChildProduct %}
  67.                         <div>
  68.                             <a href="{{ url('admin_product_product_edit', { id : ChildProduct.id }) }}" id="RelatedProduct-product_image_link{{ loop.index0 }}" class="RelatedProduct-view{{ loop.index0 }}" >
  69.                                 <img src="{{ asset(ChildProduct.mainFileName|no_image_product, 'save_image') }}" id="RelatedProduct-product_image_img{{ loop.index0 }}" style="max-width: 100px;margin-right: 10px;" />
  70.                             </a>
  71.                             <span id="RelatedProduct-product_name{{ loop.index0 }}" class="RelatedProduct-view{{ loop.index0 }}" style="margin-right: 10px;">{{ ChildProduct.name }}</span>
  72.                             {{ form_widget(RelatedProductForm.ChildProduct, { attr: { style: 'display: none', class: 'child-product' } }) }}
  73.                             <br>
  74.                             <span class="RelatedProduct-view{{ loop.index0 }}" id="RelatedProduct-product_code{{ loop.index0 }}">
  75.                         {{ ChildProduct.code_min }}
  76.                                 {% if ChildProduct.code_min != ChildProduct.code_max %} ~ {{ ChildProduct.code_max }}
  77.                                 {% endif %}
  78.                             </span>
  79.                         </div>
  80.                         <div>
  81.                             <button type="button" id="RelatedProduct-search{{ loop.index0 }}" class="btn btn-ec-regular" data-bs-toggle="modal" data-bs-target="#RelatedProductSearchProductModal" data-id="{{ loop.index0 }}">
  82.                                 {{ 'related_product.select_product'|trans }}
  83.                             </button>
  84.                             <button type="button" id="RelatedProduct-delete{{ loop.index0 }}" class="btn text-end RelatedProduct-view{{ loop.index0 }}" data-id="{{ loop.index0 }}">
  85.                                 {{ 'related_product.remove_product'|trans }}
  86.                             </button>
  87.                         </div>
  88.                     {% else %}
  89.                         <div>
  90.                             <a href="" id="RelatedProduct-product_image_link{{ loop.index0 }}" class="RelatedProduct-view{{ loop.index0 }} d-none" >
  91.                                 <img src="" id="RelatedProduct-product_image_img{{ loop.index0 }}" style="max-width: 100px;margin-right: 10px;" />
  92.                             </a>
  93.                             <span id="RelatedProduct-product_name{{ loop.index0 }}" class="RelatedProduct-view{{ loop.index0 }} d-none" ></span>
  94.                             {{ form_widget(RelatedProductForm.ChildProduct, { attr: { style: 'display: none' , class: 'child-product' } }) }}
  95.                             <br>
  96.                             <span id="RelatedProduct-product_code{{ loop.index0 }}" class="RelatedProduct-view{{ loop.index0 }} d-none"></span>
  97.                         </div>
  98.                         <div>
  99.                             <button type="button" id="RelatedProduct-search{{ loop.index0 }}" class="btn btn-ec-regular" data-bs-toggle="modal" data-bs-target="#RelatedProductSearchProductModal" data-id="{{ loop.index0 }}">
  100.                                 {{ 'related_product.select_product'|trans }}
  101.                             </button>
  102.                             <button  type="button" id="RelatedProduct-delete{{ loop.index0 }}" class="btn text-end RelatedProduct-view{{ loop.index0 }} d-none" data-id="{{ loop.index0 }}">
  103.                                 {{ 'related_product.remove_product'|trans }}
  104.                             </button>
  105.                         </div>
  106.                     {% endif %}
  107.                 </div>
  108.             </div>
  109.             <div class="row">
  110.                 <div class="col-3">
  111.                     <label>
  112.                         {{ RelatedProductForm.content.vars.label }}
  113.                     </label>
  114.                 </div>
  115.                 <div class="col-9">
  116.                     <div>
  117.                         {{ form_widget(RelatedProductForm.content, { 'attr': { 'rows': 8 }}) }}
  118.                         {{ form_errors(RelatedProductForm.content) }}
  119.                     </div>
  120.                 </div>
  121.             </div>
  122.             <hr>
  123.             {% endfor %}
  124.             <input type="hidden" id="RelatedProductDataId" value="">
  125.         </div>
  126.     </div>
  127. </div>
  128. {% form_theme searchForm '@admin/Form/bootstrap_4_horizontal_layout.html.twig' %}
  129. <div class="modal fade" id="RelatedProductSearchProductModal" tabindex="-1" role="dialog"
  130.      aria-labelledby="RelatedProductSearchProductModal" aria-hidden="true">
  131.     <div class="modal-dialog" role="document">
  132.         <div class="modal-content">
  133.             <div class="modal-header">
  134.                 <h5 class="modal-title">{{ 'related_product.modal.product_search.title'|trans }}</h5>
  135.                 <button class="btn-close" type="button" data-bs-dismiss="modal" aria-label="Close"></button>
  136.             </div>
  137.             <div class="modal-body">
  138.                 <div class="mb-3">
  139.                     {{ form_widget(searchForm.id, { attr : { placeholder : 'related_product.modal.product_search.input_name' } } ) }}
  140.                 </div>
  141.                 <div class="mb-3">
  142.                     {{ form_widget(searchForm.category_id) }}
  143.                 </div>
  144.                 <div class="mb-3">
  145.                     <button type="button" id="RelatedProductSearchButton" class="btn btn-ec-conversion" >
  146.                         {{ 'admin.common.execute'|trans }}
  147.                     </button>
  148.                 </div>
  149.                 <div id="RelatedProductSearchResult">
  150.                 </div>
  151.             </div>
  152.         </div>
  153.     </div>
  154. </div>