app/Plugin/Noshidelivery/Resource/template/front/add_shopping.twig line 1

Open in your IDE?
  1. {% set config = repository('Plugin\\Noshidelivery\\Entity\\NoshideliveryConfig').get %}
  2. {% if config.noshidelivery_enable %}
  3. <style>
  4.     #add_shopping_noshi_area {
  5.         margin:20px 0;
  6.         padding-bottom:20px;
  7.         border-bottom:1px dotted #CCC;
  8.     }
  9.     .shopping_noshi_area .noshi {
  10.         padding-bottom:20px;
  11.     }
  12. </style>
  13. <script>
  14.     {% for shipping in Order.shippings %}
  15.     {% set idx = loop.index0 %}
  16.     $(function() {
  17.         var val{{ idx }} = $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryCheck').val();
  18.         if (val{{ idx }} == "") {
  19.             $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', true);
  20.             $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', true);
  21.             $('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', true);
  22.             $('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', true);
  23.         }
  24.         if (val{{ idx }} == 1) {
  25.             $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', false);
  26.             $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', false);
  27.             $('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', false);
  28.             $('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', false);
  29.         }
  30.         if (val{{ idx }} == 2) {
  31.             $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', true);
  32.             $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', true);
  33.             $('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', true);
  34.             $('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', true);
  35.         }
  36.         
  37.         $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryCheck').change(function() {
  38.             var val{{ idx }} = $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryCheck').val();
  39.             if (val{{ idx }} == 1) {
  40.                 // disabledを解除
  41.                 $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', false);
  42.                 $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', false);
  43.                 $('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', false);
  44.                 $('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', false);
  45.         
  46.             } else {
  47.                 // ボタンのdisabledに設定
  48.                 $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').val("");
  49.                 $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryTie').prop('disabled', true);
  50.                 $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').val("");
  51.                 $('select#shopping_order_Shippings_{{ idx }}_NoshideliveryKind').prop('disabled', true);
  52.                 $('input#shopping_order_Shippings_{{ idx }}_gp_title').val("");
  53.                 $('input#shopping_order_Shippings_{{ idx }}_gp_title').prop('disabled', true);
  54.                 $('input#shopping_order_Shippings_{{ idx }}_gp_name').val("");
  55.                 $('input#shopping_order_Shippings_{{ idx }}_gp_name').prop('disabled', true);
  56.             }
  57.         });
  58.     });
  59.     {% endfor %}
  60. </script>
  61. <script>
  62.     $(function() {
  63.         $('.ec-orderDelivery').after($('#add_shopping_noshi_area'));
  64.     });
  65. </script>
  66. <div id="add_shopping_noshi_area">
  67.     <div class="ec-rectHeading">
  68.         <h2>{{ '熨斗(のし)のご希望'|trans }}</h2>
  69.     </div>
  70.     {% for shipping in Order.shippings %}
  71.         {% if Order.multiple %}
  72.             <h4 class="text-danger">{{ 'お届け先'|trans }}({{ loop.index }})</h4>
  73.         {% endif %}
  74.         {% set idx = loop.index0 %}
  75.         <div id="shopping_noshi_area--{{ idx }}" class="shopping_noshi_area">
  76.             <div id="shopping_gp_check--{{ idx }}" class="noshi"}>
  77.                 <label>{{ 'のしをお付けしますか?'|trans }}</label>
  78.                 {{ form_widget(form.Shippings[idx].NoshideliveryCheck, {'attr': {'class': 'form-control'}}) }}
  79.                 <span class="text-danger">{{ form_errors(form.Shippings[idx].NoshideliveryCheck) }}</span>
  80.             </div>
  81.             {% if config.gift_kind %}
  82.                 <div id="shopping_gp_kind--{{ idx }}" class="noshi">
  83.                     <label>{{ 'のしの種類'|trans }}</label>
  84.                     {{ form_widget(form.Shippings[idx].NoshideliveryKind, {'attr': {'class': 'form-control'}}) }}
  85.                     <span class="text-danger">{{ form_errors(form.Shippings[idx].NoshideliveryKind) }}</span>
  86.                 </div>
  87.             {% endif %}
  88.             {% if config.gift_tie %}
  89.                 <div id="shopping_gp_tie--{{ idx }}" class="noshi">
  90.                     <label>{{ '表書き(上段)'|trans }}</label>
  91.                     {{ form_widget(form.Shippings[idx].NoshideliveryTie, {'attr': {'class': 'form-control'}}) }}
  92.                     <span class="text-danger">{{ form_errors(form.Shippings[idx].NoshideliveryTie) }}</span>
  93.                 </div>
  94.                 <div id="shopping_gp_title--{{ idx }}" class="noshi">
  95.                     <label>{{ '表書き(上段)で、[その他]を選択した場合に入力してください。'|trans }}</label>
  96.                     {{ form_widget(form.Shippings[idx].gp_title, {'attr': {'class': 'form-control', 'placeholder': '全角10文字まで'}}) }}
  97.                     <span class="text-danger">{{ form_errors(form.Shippings[idx].gp_title) }}</span>
  98.                 </div>
  99.             {% endif %}
  100.             {% if config.gift_name %}
  101.                 <div id="shopping_gp_name--{{ idx }}" class="noshi">
  102.                     <label>{{ 'お名前(下段)'|trans }}</label>
  103.                     {{ form_widget(form.Shippings[idx].gp_name, {'attr': {'class': 'form-control', 'placeholder': '全角10文字まで'}}) }}
  104.                     <span class="text-danger">{{ form_errors(form.Shippings[idx].gp_name) }}</span>
  105.                 </div>
  106.             {% endif %}
  107.         </div>
  108.     {% endfor %}
  109.     {% if config.comment %}
  110.         <div>
  111.             {{ config.comment|raw|nl2br }}
  112.         </div>
  113.     {% endif %}
  114. </div>
  115. {% endif %}