app/Plugin/CustomerRank42/Resource/template/admin/Product/customer_price.js line 1

Open in your IDE?
  1. {% if has_class == false %}
  2.     <script>
  3.         $(function() {
  4.             $('div.row').each(function(i) {
  5.                 if($(this).text().match(/{{'admin.product.sale_price'|trans}}/)){
  6.                     $elem = $('#customer_price');
  7.                     $(this).after($elem.html());
  8.                     $elem.remove();
  9.                 }
  10.             });
  11.             // 会員価格自動計算(利率マスターを使ってレギュラーランク価格からrank7/8等を自動入力)
  12.             // 参照: docs/会員価格自動反映_V4仕様書.md
  13.             (function() {
  14.                 var priceRateHash = {{ PriceRateHash|json_encode|raw }};
  15.                 var saleTypeJigane = {{ SaleTypeJigane }};
  16.                 var regularRankId = {{ RegularRankId }};
  17.                 var getProductTypeFlg = function() {
  18.                     var saleTypeId = parseInt($('#admin_product_class_sale_type').val(), 10);
  19.                     return (saleTypeId === saleTypeJigane) ? 0 : 1;
  20.                 };
  21.                 var recalcMemberPrice = function() {
  22.                     var regularPrice = parseInt($('#admin_product_class_customer_price_' + regularRankId).val(), 10);
  23.                     if (isNaN(regularPrice)) {
  24.                         return;
  25.                     }
  26.                     var typeFlg = getProductTypeFlg();
  27.                     $.each(priceRateHash, function(rankId, ratesByType) {
  28.                         if (parseInt(rankId, 10) === regularRankId) {
  29.                             return;
  30.                         }
  31.                         if (!(typeFlg in ratesByType)) {
  32.                             return;
  33.                         }
  34.                         var $target = $('#admin_product_class_customer_price_' + rankId);
  35.                         if ($target.length === 0) {
  36.                             return;
  37.                         }
  38.                         var rate = parseFloat(ratesByType[typeFlg]);
  39.                         $target.val(Math.floor(regularPrice * rate));
  40.                     });
  41.                 };
  42.                 $('#admin_product_class_customer_price_' + regularRankId).on('change keyup', recalcMemberPrice);
  43.                 $('#admin_product_class_sale_type').on('change', recalcMemberPrice);
  44.             })();
  45.         });
  46.     </script>
  47. {% endif %}