app/Plugin/VeriTrans4G2/Resource/template/admin/Order/edit.twig line 1

Open in your IDE?
  1. {#
  2. Copyright (c) 2018 VeriTrans Inc., a Digital Garage company. All rights reserved.
  3. http://www.veritrans.co.jp/
  4. #}
  5. <script>
  6. $(function() {
  7.     {% if vt4g.hasVt4gOrderPayment %}
  8.         // フロント画面と同様のオーバーレイを表示
  9.         var loadingOverlay = function(action) {
  10.             if (action == 'hide') {
  11.                 $('.bg-load-overlay').remove();
  12.             } else {
  13.                 $overlay = $('<div class="bg-load-overlay" style="background:rgba(255,255,255,.4);box-sizing:border-box;position:fixed;top:0;left:0;width:100%;height:100%;opacity:1;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-flow:column nowrap;-ms-flex-flow:column nowrap;flex-flow:column nowrap;-webkit-align-items:center;-ms-flex-align:center;align-items:center;-webkit-justify-content:space-around;-ms-flex-pack:distribute;justify-content:space-around;z-index:2147483647;"></div>');
  14.                 $('body').append($overlay);
  15.             }
  16.         }
  17.         {# ↓EC-CUBE本体側 function.js(L176-)を参考に実装↓ #}
  18.         var createForm = function(action, data) {
  19.             var $form = $('<form action="'+action+'" method="post"></form>');
  20.             for (input in data) {
  21.                 if (data.hasOwnProperty(input)) {
  22.                     $form.append('<input name="'+input+'" value="'+data[input]+'">');
  23.                 }
  24.             }
  25.             return $form;
  26.         }
  27.         var conveniList = [];
  28.         {% if vt4g.conveniList is not empty %}
  29.             {% for conveni in vt4g.conveniList %}
  30.                 conveniList.push('{{ conveni }}');
  31.             {% endfor %}
  32.         {% endif %}
  33.         var operationIdPrefix = 'vt4g_btn_payment_';
  34.         var initPaymentOperationLink = function() {
  35.             $('a[id^="'+operationIdPrefix+'"][token-for-anchor]').click(function(e) {
  36.                 e.preventDefault();
  37.                 var $this = $(this);
  38.                 var selectedCvs = null;
  39.                 var data = $this.data();
  40.                 var operation = $(this).attr('id').replace(operationIdPrefix, '');
  41.                 var selectedAccountCards = null;
  42.                 var selectedReTradeCards = null;
  43.                 var selectedPaymentType = null;
  44.                 var selectedWithCapture = null;
  45.                 var alertMessage = '';
  46.                 {% if vt4g.form.conveni is defined %}
  47.                     selectedCvs = $('#order_edit_cvs_conveni').val();
  48.                     if ((operation === 'newly') && !(selectedCvs && conveniList.indexOf(selectedCvs) !== -1)) {
  49.                         alertMessage += '支払いを行うコンビニを選択してください。\n'
  50.                     }
  51.                 {% endif %}
  52.                 {% if vt4g.form.accountCards is defined and vt4g.form.reTradeCards is defined %}
  53.                     selectedAccountCards = $('#order_edit_credit_accountCards').val();
  54.                     selectedReTradeCards = $('#order_edit_credit_reTradeCards').val();
  55.                     if (!selectedAccountCards && !selectedReTradeCards) {
  56.                         alertMessage += 'ベリトランス会員ID決済かかんたん決済(再取引)のどちらかを選択してください。\n'
  57.                     }
  58.                 {% endif %}
  59.                 {% if vt4g.form.paymentType is defined %}
  60.                     selectedPaymentType = $('#order_edit_credit_paymentType').val();
  61.                     if (!selectedPaymentType) {
  62.                         alertMessage += 'お支払い方法を選択してください。\n'
  63.                     }
  64.                 {% endif %}
  65.                 {% if vt4g.form.withCapture is defined %}
  66.                     selectedWithCapture = $('#order_edit_credit_withCapture').val();
  67.                     if (!selectedWithCapture) {
  68.                         alertMessage += '売上フラグを選択してください。\n'
  69.                     }
  70.                 {% endif %}
  71.                 if(alertMessage) {
  72.                     alert(alertMessage);
  73.                     return false;
  74.                 }
  75.                 // 確認ダイアログ表示
  76.                 if (!confirm(data.message)) {
  77.                     return false;
  78.                 }
  79.                 // 削除時はオーバーレイ処理を入れる
  80.                 loadingOverlay();
  81.                 var $form = createForm($this.attr('href'), {
  82.                     _token: $this.attr('token-for-anchor'),
  83.                     _method: data.method,
  84.                     conveni: selectedCvs,
  85.                     accountCardId: selectedAccountCards,
  86.                     reTradeOrderId: selectedReTradeCards,
  87.                     jpo: selectedPaymentType,
  88.                     withCapture: selectedWithCapture
  89.                 }).hide();
  90.                 $('body').append($form); // Firefox requires form to be on the page to allow submission
  91.                 $form.submit();
  92.             });
  93.             {% if vt4g.form.accountCards is defined and vt4g.form.reTradeCards is defined %}
  94.                 var $accountSelect = $("#order_edit_credit_accountCards");
  95.                 var $reTradeSelect = $("#order_edit_credit_reTradeCards");
  96.                 $accountSelect.change(function(){
  97.                     var val = $(this).val();
  98.                     if(val) {
  99.                         $reTradeSelect.val("");
  100.                     }
  101.                 });
  102.                 $reTradeSelect.change(function(){
  103.                     var val = $(this).val();
  104.                     if(val) {
  105.                         $accountSelect.val("");
  106.                     }
  107.                 });
  108.             {% endif %}
  109.         };
  110.         {# ↓EC-CUBE本体側 function.js(L176-)を参考に実装↓ #}
  111.         // 要素の追加先
  112.         var INFO_INSERT_AFTER_TARGET = '#order-product';
  113.         var ALERT_MESSAGE = '決済操作を行います。\n受注データを編集していない場合は先に保存してください。\nよろしいですか?';
  114.         var PRODUCT_NOTICE_MESSAGE = '※金額の変更は決済情報には反映されません';
  115.         var contents =
  116.             '<div class="card rounded border-0 mb-4" id="vt4g_payment_info_card">'+
  117.             '    <div class="card-header">'+
  118.             '        <div class="row">'+
  119.             '            <div class="col-8">'+
  120.             '                <div class="d-inline-block">'+
  121.             '                    <span class="card-title">{{ vt4g.const.VT4G_SERVICE_NAME }}決済情報</span>'+
  122.             '                </div>'+
  123.             '            </div>'+
  124.             '            <div class="col-4 text-end">'+
  125.             '                <a href="#vt4g_payment_info_accordion" data-bs-toggle="collapse" aria-expanded="false" aria-controls="vt4g_payment_info_card">'+
  126.             '                    <i class="fa fa-angle-up fa-lg"></i>'+
  127.             '                </a>'+
  128.             '            </div>'+
  129.             '        </div>'+
  130.             '    </div>'+
  131.             '    <div class="collapse show ec-cardCollapse" id="vt4g_payment_info_accordion">'+
  132.             '        <div class="card-body">'+
  133.                         {% if vt4g.payName is defined %}
  134.             '               <div class="row form-group">'+
  135.             '                   <div class="col-3">決済種別</div>'+
  136.             '                   <div class="col"><p>{{ vt4g.payName }}</p></div>'+
  137.             '               </div>'+
  138.                         {% endif %}
  139.                         {% if vt4g.operationList is not empty %}
  140.                             {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_NEWLY] is defined %}
  141.                                 {% if vt4g.form.conveni is defined %}
  142.             '                       <div class="row form-group form-inline">'+
  143.             '                           <div class="col-3" style="-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;">コンビニ選択</div>'+
  144.             '                           <div class="col"><p>{{ form_widget(vt4g.form.conveni, {"attr":{"class":"form-select"}}) }}</p></div>'+
  145.             '                       </div>'+
  146.                                 {% endif %}
  147.                                 {% if vt4g.form.accountCards is defined %}
  148.             '                       <div class="row form-group form-inline">'+
  149.             '                           <div class="col-3" style="-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;">ベリトランス会員ID決済利用</div>'+
  150.             '                           <div class="col"><p>{{ form_widget(vt4g.form.accountCards, {"attr":{"class":"form-select"}}) }}</p></div>'+
  151.             '                       </div>'+
  152.                                 {% endif %}
  153.                                 {% if vt4g.form.reTradeCards is defined %}
  154.             '                       <div class="row form-group form-inline">'+
  155.             '                           <div class="col-3" style="-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;">かんたん決済(再取引)利用</div>'+
  156.             '                           <div class="col"><p>{{ form_widget(vt4g.form.reTradeCards, {"attr":{"class":"form-select"}}) }}</p></div>'+
  157.             '                       </div>'+
  158.                                 {% endif %}
  159.                                 {% if vt4g.form.paymentType is defined %}
  160.             '                       <div class="row form-group form-inline">'+
  161.             '                           <div class="col-3" style="-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;">お支払い方法</div>'+
  162.             '                           <div class="col"><p>{{ form_widget(vt4g.form.paymentType, {"attr":{"class":"form-select"}}) }}</p></div>'+
  163.             '                       </div>'+
  164.                                 {% endif %}
  165.                                 {% if vt4g.form.withCapture is defined %}
  166.             '                       <div class="row form-group form-inline">'+
  167.             '                           <div class="col-3" style="-webkit-align-self:flex-start;-ms-flex-item-align:start;align-self:flex-start;">売上フラグ</div>'+
  168.             '                           <div class="col"><p>{{ form_widget(vt4g.form.withCapture, {"attr":{"class":"form-select"}}) }}</p></div>'+
  169.             '                       </div>'+
  170.                                 {% endif %}
  171.                             {% endif %}
  172.             ''+
  173.             '               <div class="row form-group">'+
  174.             '                   <div class="col-3">決済操作</div>'+
  175.             '                   <div class="col">'+
  176.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_CAPTURE] is defined %}
  177.                                         {% if not vt4g.subscFewCreditExists %}
  178.             '                             <a href="{{ url('vt4g_admin_order_edit_capture', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_capture" class="btn btn-success mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  179.                                             {% if vt4g.paymentStatus == vt4g.const.VT4G_PAY_STATUS.CAPTURE.VALUE %}
  180.             '                                   [売上済]再売上(実売上)実行'+
  181.                                             {% else %}
  182.             '                                   売上確定(実売上)実行'+
  183.                                             {% endif %}
  184.             '                             </a>'+
  185.                                         {% endif %}
  186.                                     {% endif %}
  187.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_CANCEL] is defined %}
  188.             '                           <a href="{{ url('vt4g_admin_order_edit_cancel', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_cancel" class="btn btn-danger mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  189.             '                               取消(返品)実行'+
  190.             '                           </a>'+
  191.                                     {% endif %}
  192.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_AUTH] is defined %}
  193.                                         {% if not vt4g.subscFewCreditExists %}
  194.             '                             <a href="{{ url('vt4g_admin_order_edit_auth', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_auth" class="btn btn-info mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  195.             '                                 再オーソリ実行'+
  196.             '                             </a>'+
  197.                                         {% endif %}
  198.                                     {% endif %}
  199.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_UPDATEAUTH_EXTENSION] is defined %}
  200.             '                             <a href="{{ url('vt4g_admin_order_edit_updateauth_extension', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_updateauth_extension" class="btn btn-info mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  201.             '                                 与信変更(与信延長)'+
  202.             '                             </a>'+
  203.                                     {% endif %}
  204.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_UPDATEAUTH_AMOUNT] is defined %}
  205.             '                           <a href="{{ url('vt4g_admin_order_edit_updateauth_amount', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_updateauth_amount" class="btn btn-info mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  206.             '                               与信変更(金額変更)'+
  207.             '                           </a>'+
  208.                                     {% endif %}
  209.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_UPDATEAUTH_AMOUNT_AND_EXTENSION] is defined %}
  210.             '                           <a href="{{ url('vt4g_admin_order_edit_updateauth_amount_and_extension', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_updateauth_amount_and_extension" class="btn btn-info mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  211.             '                               与信変更(与信延長+金額変更)'+
  212.             '                           </a>'+
  213.                                     {% endif %}
  214.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_REFUND] is defined %}
  215.             '                           <a href="{{ url('vt4g_admin_order_edit_refund', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_refund" class="btn btn-success mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  216.             '                               再売上(減額用)'+
  217.             '                           </a>'+
  218.                                     {% endif %}
  219.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_REFUND_ALL] is defined %}
  220.             '                           <a href="{{ url('vt4g_admin_order_edit_refund_all', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_refund" class="btn btn-danger mr-1" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  221.             '                               全額返金'+
  222.             '                           </a>'+
  223.                                     {% endif %}
  224.                                     {% if vt4g.operationList[vt4g.const.VT4G_OPERATION_NEWLY] is defined %}
  225.             '                           <a href="{{ url('vt4g_admin_order_edit_newly', {orderId: vt4g.orderId}) }}" id="vt4g_btn_payment_newly" class="btn btn-success" data-method="post" data-message="'+ALERT_MESSAGE+'" '+"{{ csrf_token_for_anchor() }}"+'>'+
  226.             '                               決済実行'+
  227.             '                           </a>'+
  228.                                     {% endif %}
  229.             '                   </div>'+
  230.             '               </div>'+
  231.                         {% endif %}
  232.                         {% if vt4g.paymentStatusText is defined and vt4g.paymentStatusText is not empty %}
  233.             '               <div class="row form-group">'+
  234.             '                   <div class="col-3">決済状況</div>'+
  235.             '                   <div class="col"><p>{{ vt4g.paymentStatusText }}</p></div>'+
  236.             '               </div>'+
  237.                         {% endif %}
  238.                         {% if vt4g.paymentLogList is defined and vt4g.paymentLogList is not empty %}
  239.             '               <div class="row form-group">'+
  240.             '                   <div class="col-3">決済ログ</div>'+
  241.             '                   <div class="col">'+
  242.             '                       <p>'+
  243.             '                           <a class="d-block collapsed" href="#vt4g_payment_log" data-bs-toggle="collapse" aria-expanded="false" aria-controls="vt4g_payment_log" style="color:inherit;">'+
  244.             '                               <i class="fas fa-plus mr-1"></i>'+
  245.             '                               決済ログ情報 表示・非表示'+
  246.             '                           </a>'+
  247.             '                       </p>'+
  248.             '                       <div id="vt4g_payment_log" class="collapse">'+
  249.             '                           <table class="table table-bordered">'+
  250.             '                               <thead>'+
  251.             '                                   <tr>'+
  252.             '                                       <th>時間</th>'+
  253.             '                                       <th>内容</th>'+
  254.             '                                   </tr>'+
  255.             '                               </thead>'+
  256.             '                               <tbody>'+
  257.                                                 {% for log in vt4g.paymentLogList %}
  258.                                                     {% for time, info in log %}
  259.             '                                          <tr>'+
  260.             '                                               <td style="word-wrap:break-word;">{{ time }}</td>'+
  261.             '                                               <td style="word-wrap:break-word;">'+
  262.                                                                 {% for item in info %}
  263.                                                                     {% if item.title is not empty %}
  264.             '                                                           {{ item.title|nl2br }}'+
  265.                                                                     {% endif %}
  266.             '                                                       {{ item.content|nl2br }}{% if loop.last == false %},<br />{% endif %}'+
  267.                                                                 {% endfor %}
  268.             '                                               </td>'+
  269.             '                                           </tr>'+
  270.                                                     {% endfor %}
  271.                                                 {% endfor %}
  272.             '                               </tbody>'+
  273.             '                           </table>'+
  274.             '                       </div>'+
  275.             '                   </div>'+
  276.             '               </div>'+
  277.                         {% endif %}
  278.                         {% if vt4g.paymentInfo is defined and vt4g.paymentInfo is not empty %}
  279.             '               <div class="row form-group">'+
  280.             '                   <div class="col-3">決済情報</div>'+
  281.             '                   <div class="col">'+
  282.             '                       <p>'+
  283.             '                           <a class="d-block collapsed" href="#vt4g_payment_info" data-bs-toggle="collapse" aria-expanded="false" aria-controls="vt4g_payment_info" style="color:inherit;">'+
  284.             '                               <i class="fas fa-plus mr-1"></i>'+
  285.             '                               {% if vt4g.paymentInfo.title is defined %}{{ vt4g.paymentInfo.title }}{% endif %}情報 表示・非表示'+
  286.             '                           </a>'+
  287.             '                       </p>'+
  288.             '                       <div id="vt4g_payment_info" class="collapse">'+
  289.             '                           <table class="table table-bordered">'+
  290.             '                               <thead>'+
  291.             '                                   <tr>'+
  292.             '                                       <th>項目</th>'+
  293.             '                                       <th>内容</th>'+
  294.             '                                   </tr>'+
  295.             '                               </thead>'+
  296.             '                               <tbody>'+
  297.                                                 {% if vt4g.paymentInfo.message is defined and   vt4g.paymentInfo.message is not empty %}
  298.                                                     {% for item in vt4g.paymentInfo.message %}
  299.             '                                           <tr>'+
  300.                                                             {% if item.title is defined and item.title is not empty %}
  301.             '                                                   <td>{{ item.title }}</td>'+
  302.                                                             {% endif %}
  303.                                                             {% if item.content is defined and item.content is not empty %}
  304.             '                                                   <td {% if item.title is empty %}colspan="2"{% endif %}>'+
  305.             '                                                       {{ item.content }}'.replace(/\r\n|\r|\n/g, '<br />')+
  306.             '                                                   </td>'+
  307.                                                             {% endif %}
  308.             '                                           </tr>'+
  309.                                                     {% endfor %}
  310.                                                 {% endif %}
  311.             '                               </tbody>'+
  312.             '                           </table>'+
  313.             '                       </div>'+
  314.             '                   </div>'+
  315.             '               </div>'+
  316.                         {% endif %}
  317.             '        </div>'+
  318.             '    </div>'+
  319.             '</div>';
  320.         // 決済情報の追加
  321.         $(INFO_INSERT_AFTER_TARGET).after(contents);
  322.         // 商品情報変更時の注意メッセージの追加
  323.         $('#calculate').parents('.row').after('<p class="text-danger">'+PRODUCT_NOTICE_MESSAGE+'</p>');
  324.         var $card = $('#vt4g_payment_info_card');
  325.         // 表示領域 縮小/拡大アイコン 切り替え
  326.         $card.find('[data-bs-toggle="collapse"]').on('click', function(e) {
  327.             var $elm = $(e.currentTarget);
  328.             var isCollapsed = $elm.hasClass('collapsed');
  329.             var $icon = $elm.find('i');
  330.             if ($icon.length) {
  331.                 $icon.toggleClass('fa-times', !isCollapsed).toggleClass('fa-plus', isCollapsed);
  332.             }
  333.         });
  334.         // 決済操作リンク 初期化
  335.         initPaymentOperationLink();
  336.     {% endif %}
  337.     var $paymentMethodSelect = $('#order_Payment');
  338.     // 削除対象の支払方法を削除
  339.     {% if vt4g.removePaymentMethodIdList is not empty %}
  340.         {% for id in vt4g.removePaymentMethodIdList %}
  341.             $paymentMethodSelect.find('option[value="{{ id }}"]').remove();
  342.         {% endfor %}
  343.     {% endif %}
  344.     $('.btn-success, .btn-info').css('color', '#fff');
  345. });
  346. </script>