{% set config = repository('Plugin\\Noshidelivery\\Entity\\NoshideliveryConfig').get %}
{% if config.noshidelivery_enable %}
<style>
#add_shopping_noshi_area {
margin:20px 0;
padding-bottom:20px;
border-bottom:1px dotted #CCC;
}
.shopping_noshi_area .noshi {
padding-bottom:20px;
}
</style>
<script>
{% for shipping in Order.shippings %}
{% set idx = loop.index0 %}
$(function() {
var val{{ idx }} = $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryCheck').val();
if (val{{ idx }} == "") {
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', true);
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', true);
$('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', true);
$('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', true);
}
if (val{{ idx }} == 1) {
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', false);
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', false);
$('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', false);
$('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', false);
}
if (val{{ idx }} == 2) {
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', true);
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', true);
$('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', true);
$('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', true);
}
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryCheck').change(function() {
var val{{ idx }} = $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryCheck').val();
if (val{{ idx }} == 1) {
// disabledを解除
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', false);
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', false);
$('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', false);
$('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', false);
} else {
// ボタンのdisabledに設定
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').val("");
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', true);
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').val("");
$('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', true);
$('input#shopping_order_Shippings_{{ idx }}_gp_title').val("");
$('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', true);
$('input#shopping_order_Shippings_{{ idx }}_gp_name').val("");
$('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', true);
}
});
});
{% endfor %}
</script>
<script>
$(function() {
$('.ec-orderDelivery').after($('#add_shopping_noshi_area'));
});
</script>
<div id="add_shopping_noshi_area">
<div class="ec-rectHeading">
<h2>{{ '熨斗(のし)のご希望'|trans }}</h2>
</div>
{% for shipping in Order.shippings %}
{% if Order.multiple %}
<h4 class="text-danger">{{ 'お届け先'|trans }}({{ loop.index }})</h4>
{% endif %}
{% set idx = loop.index0 %}
<div id="shopping_noshi_area--{{ idx }}" class="shopping_noshi_area">
<div id="shopping_gp_check--{{ idx }}" class="noshi"}>
<label>{{ 'のしをお付けしますか?'|trans }}</label>
{{ form_widget(form.Shippings[idx].NoshideliveryCheck, {'attr': {'class': 'form-control'}}) }}
<span class="text-danger">{{ form_errors(form.Shippings[idx].NoshideliveryCheck) }}</span>
</div>
{% if config.gift_kind %}
<div id="shopping_gp_kind--{{ idx }}" class="noshi">
<label>{{ 'のしの種類'|trans }}</label>
{{ form_widget(form.Shippings[idx].NoshideliveryKind, {'attr': {'class': 'form-control'}}) }}
<span class="text-danger">{{ form_errors(form.Shippings[idx].NoshideliveryKind) }}</span>
</div>
{% endif %}
{% if config.gift_tie %}
<div id="shopping_gp_tie--{{ idx }}" class="noshi">
<label>{{ '表書き(上段)'|trans }}</label>
{{ form_widget(form.Shippings[idx].NoshideliveryTie, {'attr': {'class': 'form-control'}}) }}
<span class="text-danger">{{ form_errors(form.Shippings[idx].NoshideliveryTie) }}</span>
</div>
<div id="shopping_gp_title--{{ idx }}" class="noshi">
<label>{{ '表書き(上段)で、[その他]を選択した場合に入力してください。'|trans }}</label>
{{ form_widget(form.Shippings[idx].gp_title, {'attr': {'class': 'form-control', 'placeholder': '全角10文字まで'}}) }}
<span class="text-danger">{{ form_errors(form.Shippings[idx].gp_title) }}</span>
</div>
{% endif %}
{% if config.gift_name %}
<div id="shopping_gp_name--{{ idx }}" class="noshi">
<label>{{ 'お名前(下段)'|trans }}</label>
{{ form_widget(form.Shippings[idx].gp_name, {'attr': {'class': 'form-control', 'placeholder': '全角10文字まで'}}) }}
<span class="text-danger">{{ form_errors(form.Shippings[idx].gp_name) }}</span>
</div>
{% endif %}
</div>
{% endfor %}
{% if config.comment %}
<div>
{{ config.comment|raw|nl2br }}
</div>
{% endif %}
</div>
{% endif %}