{% if has_class == false %}
<script>
$(function() {
$('div.row').each(function(i) {
if($(this).text().match(/{{'admin.product.sale_price'|trans}}/)){
$elem = $('#customer_price');
$(this).after($elem.html());
$elem.remove();
}
});
// 会員価格自動計算(利率マスターを使ってレギュラーランク価格からrank7/8等を自動入力)
// 参照: docs/会員価格自動反映_V4仕様書.md
(function() {
var priceRateHash = {{ PriceRateHash|json_encode|raw }};
var saleTypeJigane = {{ SaleTypeJigane }};
var regularRankId = {{ RegularRankId }};
var getProductTypeFlg = function() {
var saleTypeId = parseInt($('#admin_product_class_sale_type').val(), 10);
return (saleTypeId === saleTypeJigane) ? 0 : 1;
};
var recalcMemberPrice = function() {
var regularPrice = parseInt($('#admin_product_class_customer_price_' + regularRankId).val(), 10);
if (isNaN(regularPrice)) {
return;
}
var typeFlg = getProductTypeFlg();
$.each(priceRateHash, function(rankId, ratesByType) {
if (parseInt(rankId, 10) === regularRankId) {
return;
}
if (!(typeFlg in ratesByType)) {
return;
}
var $target = $('#admin_product_class_customer_price_' + rankId);
if ($target.length === 0) {
return;
}
var rate = parseFloat(ratesByType[typeFlg]);
$target.val(Math.floor(regularPrice * rate));
});
};
$('#admin_product_class_customer_price_' + regularRankId).on('change keyup', recalcMemberPrice);
$('#admin_product_class_sale_type').on('change', recalcMemberPrice);
})();
});
</script>
{% endif %}