app/Plugin/Recommend42/Resource/template/admin/search_product.twig line 1

Open in your IDE?
  1. {#
  2.  * This file is part of the Recommend Product plugin
  3.  *
  4.  * Copyright (C) EC-CUBE CO.,LTD. All Rights Reserved.
  5.  *
  6.  * For the full copyright and license information, please view the LICENSE
  7.  * file that was distributed with this source code.
  8. #}
  9. <script type="text/javascript">
  10.     function fnSelectProduct($row, product_id, product_name, product_image_link, product_image_img, product_code_min, product_code_max) {
  11.         // Add product argument
  12.         var productName = $('#product_name');
  13.         var productImageLink = $('#product_image_link');
  14.         var productImageImg = $('#product_image_img');
  15.         var productCode = $('#product_code');
  16.         productName.text(product_name);
  17.         $('#recommend_product_Product').val(product_id);
  18.         productImageLink.removeAttr('href');
  19.         productImageLink.attr('href', product_image_link);
  20.         productImageImg.removeAttr('src');
  21.         productImageImg.attr('src', product_image_img);
  22.         if (product_code_min != product_code_max) {
  23.             product_code_min += ' ~ ' + product_code_max;
  24.         }
  25.         productCode.text(product_code_min);
  26.         // Display new product
  27.         $('#product_image').removeClass('d-none');
  28.         productName.removeClass('d-none');
  29.         productCode.removeClass('d-none');
  30.         // Check product exist
  31.         var warning = $('#warning');
  32.         warning.text('');
  33.         if (recommend.indexOf(product_id) != -1) {
  34.             warning.text("{{ 'plugin_recommend.admin.edit.existed'|trans }}");
  35.         }
  36.         // モーダル閉じる.
  37.         $('#searchProductModal').modal('hide');
  38.         return false;
  39.     }
  40.     // 商品検索
  41.     $('div.box-footer a').on('click', function(event) {
  42.         var list = $('#searchProductModalList');
  43.         list.children().remove();
  44.         $.ajax({
  45.             type: 'GET',
  46.             dataType: 'html',
  47.             url: $(this).attr('href'),
  48.             success: function(data) {
  49.                 $('#searchProductModalList').html(data);
  50.             },
  51.             error: function() {
  52.                 alert('paginator failed.');
  53.             }
  54.         });
  55.         event.preventDefault();
  56.     });
  57. </script>
  58. <div class="table-responsive">
  59.     <table class="table">
  60.         <tbody>
  61.         {% for Product in pagination %}
  62.             <form name="product_form{{ Product.id }}">
  63.                 <tr>
  64.                     <td>
  65.                         {{ Product.name }}
  66.                         <br>
  67.                         <span>{{ Product.code_min }}
  68.                             {% if Product.code_min != Product.code_max %} ~ {{ Product.code_max }}
  69.                             {% endif %}
  70.                         </span>
  71.                     </td>
  72.                     <td class="text-end">
  73.                         <button onclick="fnSelectProduct($(this).parent().parent(), '{{ Product.id }}', '{{ Product.name|escape('js') }}', '{{ url('admin_product_product_edit', { id : Product.id }) }}', '{{ asset(Product.mainFileName|no_image_product, 'save_image') }}', '{{ Product.code_min }}', '{{ Product.code_max }}')" type="button" class="btn btn-default btn-sm">
  74.                             決定
  75.                         </button>
  76.                     </td>
  77.                 </tr>
  78.             </form>
  79.         {% endfor %}
  80.         </tbody>
  81.     </table>
  82.     {% if pagination.totalItemCount > 0 %}
  83.     <div class="col box-footer">
  84.         <div class="row justify-content-md-center mb-4">
  85.             {% include "@admin/pager.twig" with {'pages': pagination.paginationData, 'routes': 'plugin_recommend_search_product_page'} %}
  86.         </div>
  87.     </div>
  88.     {% endif %}
  89. </div>