app/template/default/Purchase/index.twig line 1

Open in your IDE?
  1. {#
  2. This file is part of EC-CUBE
  3. Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
  4. http://www.ec-cube.co.jp/
  5. For the full copyright and license information, please view the LICENSE
  6. file that was distributed with this source code.
  7. #}
  8. {% extends 'default_frame.twig' %}
  9. {% form_theme form 'Form/form_div_layout.twig' %}
  10. {% block javascript %}
  11.     <script src="//yubinbango.github.io/yubinbango/yubinbango.js" charset="UTF-8"></script>
  12. <script>
  13. $(document).ready(function() {
  14.   var dropArea = $('#drop-area');
  15.   var fileInput = $('#contact_attachment');
  16.   var filePreview = $('#file-preview');
  17.   var uploadButton = $('#upload-button');
  18.   dropArea.on('dragenter', function(e) {
  19.     e.preventDefault();
  20.     dropArea.addClass('active');
  21.   });
  22.   dropArea.on('dragover', function(e) {
  23.     e.preventDefault();
  24.   });
  25.   dropArea.on('dragleave', function() {
  26.     dropArea.removeClass('active');
  27.   });
  28.   dropArea.on('drop', function(e) {
  29.     e.preventDefault();
  30.     dropArea.removeClass('active');
  31.     var files = e.originalEvent.dataTransfer.files;
  32.     handleFiles(files);
  33.   });
  34.   fileInput.on('change', function() {
  35.     alert("変更");
  36.     var files = fileInput[0].files;
  37.     handleFiles(files);
  38.   });
  39.   function handleFiles(files) {
  40.     // contact_attachmentにファイルを設定
  41.     fileInput.prop('files', files);
  42.     filePreview.empty(); // プレビュー領域をクリア
  43.     for (var i = 0; i < files.length; i++) {
  44.       var file = files[i];
  45.       var reader = new FileReader();
  46.       reader.onload = function(e) {
  47.         var image = $('<div class="preview-item">')
  48.           .append($('<img>').attr('src', e.target.result))
  49.           .data('file', file); // ファイルをデータ属性に保存
  50.         filePreview.append(image);
  51.       };
  52.       reader.readAsDataURL(file);
  53.     }
  54.     if (files.length > 0) {
  55.       uploadButton.prop('disabled', false);
  56.     } else {
  57.       uploadButton.prop('disabled', true);
  58.     }
  59.   }
  60.   // プレビュー画像のバツボタンがクリックされたとき
  61.   filePreview.on('click', '.close-button', function() {
  62.     var previewItem = ('.preview-item');
  63.     previewItem.remove();
  64.     // アップロードボタンを無効にするかチェック
  65.     if (filePreview.children().length === 0) {
  66.       uploadButton.prop('disabled', true);
  67.     }
  68.     // contact_attachmentから画像を削除
  69.     var removedFile = previewItem.data('file');
  70.     var currentFiles = fileInput[0].files;
  71.     var newFiles = Array.from(currentFiles).filter(function(file) {
  72.       return file !== removedFile;
  73.     });
  74.     fileInput[0].files = newFiles;
  75.   });
  76.   uploadButton.on('click', function() {
  77.     // フォームを送信するか、アップロード処理を実行する
  78.     // ここにアップロード処理を追加
  79.   });
  80. });
  81. </script>
  82. {% endblock javascript %}
  83. {% block main %}
  84.     <div class="ec-contactRole">
  85.         <div class="ec-pageHeader">
  86.             <h1>{{ 'まとめて買い取り査定フォーム'|trans }}</h1>
  87.         </div>
  88.         <div class="ec-off1Grid">
  89.             <div class="ec-off1Grid__cell">
  90.                 <form method="post" action="{{ url('purchase') }}" class="h-adr"  enctype="multipart/form-data" novalidate>
  91.                     <span class="p-country-name" style="display:none;">Japan</span>
  92.                     {{ form_widget(form._token) }}
  93.                     <p class="ec-para-normal">{{ 'こちらは「まとめて買い取り査定フォーム」となります。個別に査定していただきたいカードは画像の添付をしいただけますと幸いです。
  94. 内容によっては回答をさしあげるのにお時間をいただくこともございます。
  95. また、休業日は翌営業日以降の対応となりますのでご了承ください。'|trans|nl2br }}</p>
  96.                     <div class="ec-borderedDefs">
  97.                         <dl>
  98.                             <dt>
  99.                                 {{ form_label(form.name, 'お名前', { 'label_attr': { 'class': 'ec-label' }}) }}
  100.                             </dt>
  101.                             <dd>
  102.                                 <div class="ec-halfInput{{ has_errors(form.name.name01, form.name.name02) ? ' error' }}">
  103.                                     {{ form_widget(form.name.name01, {'attr': { 'placeholder': '姓' }}) }}
  104.                                     {{ form_widget(form.name.name02, {'attr': { 'placeholder': '名' }}) }}
  105.                                     {{ form_errors(form.name.name01) }}
  106.                                     {{ form_errors(form.name.name02) }}
  107.                                 </div>
  108.                             </dd>
  109.                         </dl>
  110.                         <dl>
  111.                             <dt>
  112.                                 {{ form_label(form.kana, 'お名前(カナ)', {'label_attr': {'class': 'ec-label'}}) }}
  113.                             </dt>
  114.                             <dd>
  115.                                 <div class="ec-halfInput{{ has_errors(form.kana.kana01, form.kana.kana02) ? ' error' }}">
  116.                                     {{ form_widget(form.kana.kana01, {'attr': { 'placeholder': 'セイ' }}) }}
  117.                                     {{ form_widget(form.kana.kana02, {'attr': { 'placeholder': 'メイ' }}) }}
  118.                                     {{ form_errors(form.kana.kana01) }}
  119.                                     {{ form_errors(form.kana.kana02) }}
  120.                                 </div>
  121.                             </dd>
  122.                         </dl>
  123.                         <dl>
  124.                             <dt>
  125.                                 {{ form_label(form.address, '住所', { 'label_attr': { 'class': 'ec-label' }}) }}
  126.                             </dt>
  127.                             <dd>
  128.                                 <div class="ec-zipInput{{ has_errors(form.postal_code) ? ' error' }}">
  129.                                     <span>{{ '〒'|trans }}</span>
  130.                                     {{ form_widget(form.postal_code) }}
  131.                                     <div class="ec-zipInputHelp">
  132.                                         <div class="ec-zipInputHelp__icon">
  133.                                             <div class="ec-icon"><img
  134.                                                     src="{{ asset('assets/icon/question-white.svg') }}" alt="">
  135.                                             </div>
  136.                                         </div><a href="https://www.post.japanpost.jp/zipcode/" target="_blank"><span>{{ '郵便番号検索'|trans }}</span></a>
  137.                                     </div>
  138.                                     {{ form_errors(form.postal_code) }}
  139.                                 </div>
  140.                                 <div class="ec-select{{ has_errors(form.address.pref) ? ' error' }}">
  141.                                     {{ form_widget(form.address.pref) }}
  142.                                     {{ form_errors(form.address.pref) }}
  143.                                 </div>
  144.                                 <div class="ec-input{{ has_errors(form.address.addr01) ? ' error' }}">
  145.                                     {{ form_widget(form.address.addr01, { 'attr': { 'placeholder': '市区町村名(例:大阪市北区)' }}) }}
  146.                                     {{ form_errors(form.address.addr01) }}
  147.                                 </div>
  148.                                 <div class="ec-input{{ has_errors(form.address.addr02) ? ' error' }}">
  149.                                     {{ form_widget(form.address.addr02,  { 'attr': { 'placeholder': '番地・ビル名(例:西梅田1丁目6-8)' }}) }}
  150.                                     {{ form_errors(form.address.addr02) }}
  151.                                 </div>
  152.                             </dd>
  153.                         </dl>
  154.                         <dl>
  155.                             <dt>
  156.                                 {{ form_label(form.phone_number, '電話番号', { 'label_attr': { 'class': 'ec-label' }}) }}
  157.                             </dt>
  158.                             <dd>
  159.                                 <div class="ec-telInput{{ has_errors(form.phone_number) ? ' error' }}">
  160.                                     {{ form_widget(form.phone_number) }}
  161.                                     {{ form_errors(form.phone_number) }}
  162.                                 </div>
  163.                             </dd>
  164.                         </dl>
  165.                         <dl>
  166.                             <dt>
  167.                                 {{ form_label(form.email, 'メールアドレス', { 'label_attr': { 'class': 'ec-label' }}) }}
  168.                             </dt>
  169.                             <dd>
  170.                                 <div class="ec-input{{ has_errors(form.email) ? ' error' }}">
  171.                                     {{ form_widget(form.email) }}
  172.                                     {{ form_errors(form.email) }}
  173.                                 </div>
  174.                             </dd>
  175.                         </dl>
  176.                         <!--  添付ファイル項目を追加 -->
  177.                        <dl>
  178.                          <dt>
  179.                             
  180.                            {{ form_label(form.attachment, '添付ファイル', { 'label_attr': { 'class': 'ec-label' }}) }}
  181.                            
  182.                          </dt>
  183.                          <dd>
  184.                          <div id="file-input-container">
  185.                            <div class="ec-input{{ has_errors(form.attachment) ? ' error' }}">
  186.                              {{ form_widget(form.attachment) }}
  187.                              {{ form_errors(form.attachment) }}
  188.                              {{ form_widget(form.filename) }}
  189.                            </div>
  190.                            </div>
  191.                            <div id="drop-area">
  192.                             <p class="fs12">ファイルをここにドラッグアンドドロップしてください。<br />複数アップロードする場合は一度にまとめてドラッグアンドドロップしてください。<br />アップロードする画像を選択し直す事が可能です。</p>
  193.                             
  194.                             
  195.                             </div>
  196.                             <div id="file-preview"></div>
  197.                            {% if form.filename.vars.data != '' %}
  198.                             {% for key, imgurl in form.filename.vars.data %}
  199.                              <img src="/html/upload/save_image{{ asset(imgurl, 'save_image') }}" style="width: 150px !important;" />
  200.                             {% endfor %}
  201.                            {% endif %}
  202.                          </dd>
  203.                        </dl>
  204.                         <dl>
  205.                             <dt>
  206.                                 {{ form_label(form.contents, '備考欄', { 'label_attr': { 'class': 'ec-label' }}) }}
  207.                             </dt>
  208.                             <dd>
  209.                                 <div class="ec-input{{ has_errors(form.contents) ? ' error' }}">
  210.                                     {{ form_widget(form.contents) }}
  211.                                     {{ form_errors(form.contents) }}
  212.                                 </div>
  213.                                 <!--<p>{{ 'ご注文に関するお問い合わせには、必ず「ご注文番号」をご記入くださいますようお願いいたします。'|trans }}</p>-->
  214.                             </dd>
  215.                         </dl>
  216.                         {# エンティティ拡張の自動出力 #}
  217.                         {% for f in form|filter(f => f.vars.eccube_form_options.auto_render) %}
  218.                             {% if f.vars.eccube_form_options.form_theme %}
  219.                                 {% form_theme f f.vars.eccube_form_options.form_theme %}
  220.                                 {{ form_row(f) }}
  221.                             {% else %}
  222.                                 <dl>
  223.                                     <dt>
  224.                                         {% set label_class =  f.vars.label_attr.class is defined ? f.vars.label_attr.class : '' %}
  225.                                         {{ form_label(f, f.vars.label, { 'label_attr': {'class': label_class ~ ' ec-label' }}) }}
  226.                                     </dt>
  227.                                     <dd>
  228.                                         <div class="{{ f.vars.eccube_form_options.style_class }}{{ has_errors(f) ? ' error' }}">
  229.                                             {{ form_widget(f) }}
  230.                                             {{ form_errors(f) }}
  231.                                         </div>
  232.                                     </dd>
  233.                                 </dl>
  234.                             {% endif %}
  235.                         {% endfor %}
  236.                     </div>
  237.                     <div class="ec-RegisterRole__actions">
  238.                         <div class="ec-off4Grid">
  239.                             <div class="ec-off4Grid__cell">
  240.                                 <button type="submit" class="ec-blockBtn--action" name="mode" value="confirm">{{ '確認ページへ'|trans }}
  241.                                 </button>
  242.                             </div>
  243.                         </div>
  244.                     </div>
  245.                 </form>
  246.             </div>
  247.         </div>
  248.     </div>
  249. {% endblock %}