app/Plugin/CustomerSupportPro42/Resource/template/default/Contact/index.twig line 1

Open in your IDE?
  1. {#
  2.  This file is part of the ContactManagement Plugin
  3.  Copyright (C) 2020 Diezon.
  4.  For the full copyright and license information, please view the LICENSE
  5.  file that was distributed with this source code.
  6. #}
  7. {% form_theme form.ContactPurpose 'CustomerSupportPro42/Resource/template/default/Form/custom_checkbox_theme.twig' %}
  8. {% block stylesheet %}
  9.     {{ include('@CustomerSupportPro42/default/Contact/style.twig') }}
  10. {% endblock %}
  11. {% block javascript %}
  12.     <script src="{{ asset('CustomerSupportPro42/assets/fileupload/vendor/jquery.ui.widget.js', 'plugin') }}"></script>
  13.     <script src="{{ asset('CustomerSupportPro42/assets/fileupload/jquery.iframe-transport.js', 'plugin') }}"></script>
  14.     <script src="{{ asset('CustomerSupportPro42/assets/fileupload/jquery.fileupload.js', 'plugin') }}"></script>
  15.     <script src="{{ asset('CustomerSupportPro42/assets/fileupload/jquery.fileupload-process.js', 'plugin') }}"></script>
  16.     <script src="{{ asset('CustomerSupportPro42/assets/fileupload/jquery.fileupload-validate.js', 'plugin') }}"></script>
  17.     <script>
  18.         $(function () {
  19.             $('#contact_purpose').insertAfter('dl:nth-of-type(5)');
  20.             $('#contact_image').appendTo('div.ec-borderedDefs');
  21.             {% if form.ContactComment.image_name_1.vars.value is not empty %}
  22.                 $('#name_contact_comment_1').replaceWith('<div class="imgUpBox--main--name" id="name_contact_comment_1"></div>');
  23.                 $('#name_contact_comment_1').append('{{ form.ContactComment.image_name_1.vars.value }}');
  24.             {% endif %}
  25.             {% if form.ContactComment.image_name_2.vars.value is not empty %}
  26.                 $('#name_contact_comment_2').replaceWith('<div class="imgUpBox--main--name" id="name_contact_comment_2"></div>');
  27.                 $('#name_contact_comment_2').append('{{ form.ContactComment.image_name_2.vars.value }}');
  28.             {% endif %}
  29.             var proto_del = '{{ form_widget(form.ContactComment.delete_images.vars.prototype) }}';
  30.             {% for delete_image in form.ContactComment.delete_images %}
  31.                 $("#contact_image").append('{{ form_widget(delete_image) }}');
  32.             {% endfor %}
  33.             $('#{{ form.ContactComment.image_file_upload_1.vars.id }}').fileupload(getUploadProcess(
  34.                 'contact_comment_1',
  35.                 '{{ form.ContactComment.image_name_1.vars.id }}',
  36.             ));
  37.             $('#{{ form.ContactComment.image_file_upload_2.vars.id }}').fileupload(getUploadProcess(
  38.                 'contact_comment_2',
  39.                 '{{ form.ContactComment.image_name_2.vars.id }}',
  40.             ));
  41.             var count_del = 0;
  42.             $(document).ready(function(){
  43.                 checkVisibleDeleteButton();
  44.                 $('#delete_contact_comment_1').on('click', function() {
  45.                     var $new_delete_image = $(proto_del.replace(/__name__/g, count_del));
  46.                     $new_delete_image.val($('#' + '{{ form.ContactComment.image_name_1.vars.id }}').val());
  47.                     $('#contact_image').append($new_delete_image);
  48.                     $('#' + '{{ form.ContactComment.image_name_1.vars.id }}').val('');
  49.                     $('#name_contact_comment_1').replaceWith('<div class="imgUpBox--main--name" id="name_contact_comment_1"></div>');
  50.                     $('#delete_contact_comment_1').hide();
  51.                     count_del++
  52.                 });
  53.                 $('#delete_contact_comment_2').on('click', function() {
  54.                     var $new_delete_image = $(proto_del.replace(/__name__/g, count_del));
  55.                     $new_delete_image.val($('#' + '{{ form.ContactComment.image_name_2.vars.id }}').val())
  56.                     $('#contact_image').append($new_delete_image);
  57.                     $('#' + '{{ form.ContactComment.image_name_2.vars.id }}').val('');
  58.                     $('#name_contact_comment_2').replaceWith('<div class="imgUpBox--main--name" id="name_contact_comment_2"></div>');
  59.                     $('#delete_contact_comment_2').hide();
  60.                     count_del++
  61.                 });
  62.             });
  63.             function getUploadProcess(key, valueId) {
  64.                 return {
  65.                     url: "{{ url('front_contact_image_add') }}",
  66.                     type: "post",
  67.                     sequentialUploads: true,
  68.                     dataType: 'json',
  69.                     singleFileUploads: true,
  70.                     add: function (e, data) {
  71.                         if (data.files.length > 1) {
  72.                             alert("{{ 'front.contact.contact_image_length'|trans }}");
  73.                             return;
  74.                         } else {
  75.                             if (data.files[0].size > {{ eccube_config.eccube_contact_image_max_file_size }}) {
  76.                                 alert("{{ 'front.contact.contact_image_size'|trans }}");
  77.                                 return;
  78.                             }
  79.                             data.submit();
  80.                         }
  81.                     },
  82.                     done: function(e, data) {
  83.                         var file = data.result.file;
  84.                         $('#name_' + key).replaceWith('<div class="imgUpBox--main--name" id="name_' + key + '"></div>');
  85.                         $('#name_' + key).append(file);
  86.                         if ($('#' + valueId).val() && $('#' + valueId).val().length > 0) {
  87.                             var $new_delete_image = $(proto_del.replace(/__name__/g, count_del));
  88.                             $new_delete_image.val($('#' + valueId).val())
  89.                             $('#contact_image').append($new_delete_image);
  90.                             count_del++
  91.                         }
  92.                         $('#'+ valueId ).val(file);
  93.                         $('#delete_' + key).show();
  94.                     },
  95.                     fail: function(e, data) {
  96.                         alert("{{ 'admin.common.upload_error'|trans }}");
  97.                     },
  98.                     acceptFileTypes: /(\.|\/)(jpe?g|png)$/i,
  99.                     maxFileSize: {{ eccube_config.eccube_contact_image_max_file_size }},
  100.                     maxNumberOfFiles: 1,
  101.                     processalways: function(e, data) {
  102.                         if (data.files.error) {
  103.                             alert("{{ 'admin.common.upload_error'|trans }}");
  104.                         }
  105.                     }
  106.                 }
  107.             }
  108.             function checkVisibleDeleteButton() {
  109.                 {% if form.ContactComment.image_name_1.vars.value %}
  110.                     $("#delete_contact_comment_1").show();
  111.                 {% else %}
  112.                     $("#delete_contact_comment_1").hide();
  113.                 {% endif %}
  114.                 {% if form.ContactComment.image_name_2.vars.value %}
  115.                     $("#delete_contact_comment_2").show();
  116.                 {% else %}
  117.                     $("#delete_contact_comment_2").hide();
  118.                 {% endif %}
  119.             }
  120.         });
  121.     </script>
  122. {% endblock %}
  123. {% block main %}
  124.     <div style="display:none;">
  125.         <dl id="contact_purpose">
  126.             <dt>
  127.                 {{ form_label(form.ContactPurpose, 'front.contact.contact_purpose', { 'label_attr': { 'class': 'ec-label' }}) }}
  128.             </dt>
  129.             <dd>
  130.                 <div class="ec-radio{{ has_errors(form.ContactPurpose) ? ' error' }}">
  131.                     {{ form_widget(form.ContactPurpose) }}
  132.                     {{ form_errors(form.ContactPurpose) }}
  133.                 </div>
  134.             </dd>
  135.         </dl>
  136.         <dl id="contact_image">
  137.             <dt>
  138.                 <strong>{{ 'front.contact.contact_image_file'|trans }}</strong><br>
  139.                 <small>{{ 'front.contact.contact_image_file_description'|trans }}</small>
  140.             </dt>
  141.             <dd>
  142.                 <div class="imgUpBox">
  143.                     <div class="imgUpBox--main">
  144.                         <label class="imgUpBox--main--bt">
  145.                             {{ form_widget(form.ContactComment.image_file_upload_1, { attr : { accept : 'image/*' } }) }}
  146.                             <strong>{{ 'front.contact.contact_select_file'|trans }}</strong>
  147.                             {{ form_widget(form.ContactComment.image_name_1) }}
  148.                         </label>
  149.                         <div class="uploaded show">
  150.                             <div class="imgUpBox--main--name" id="name_contact_comment_1">
  151.                             </div>
  152.                             <button type="button" id="delete_contact_comment_1" class="ec-inlineBtn">
  153.                                 <span>{{ 'common.delete'|trans }}</span>
  154.                             </button>
  155.                         </div>
  156.                     </div>
  157.                     {{ form_errors(form.ContactComment.image_name_1) }}
  158.                     {{ form_errors(form.ContactComment.image_file_upload_1) }}
  159.                 </div>
  160.                 <div class="imgUpBox mt30 mt15sp">
  161.                     <div class="imgUpBox--main">
  162.                         <label class="imgUpBox--main--bt">
  163.                             {{ form_widget(form.ContactComment.image_file_upload_2, { attr : { accept : 'image/*' } }) }}
  164.                             <strong>{{ 'front.contact.contact_select_file'|trans }}</strong>
  165.                             {{ form_widget(form.ContactComment.image_name_2) }}
  166.                         </label>
  167.                         <div class="uploaded show">
  168.                             <div class="imgUpBox--main--name" id="name_contact_comment_2">
  169.                             </div>
  170.                             <button type="button" id="delete_contact_comment_2" class="ec-inlineBtn">
  171.                                 <span>{{ 'common.delete'|trans }}</span>
  172.                             </button>
  173.                         </div>
  174.                     </div>
  175.                     {{ form_errors(form.ContactComment.image_name_2) }}
  176.                     {{ form_errors(form.ContactComment.image_file_upload_2) }}
  177.                 </div>
  178.             </dd>
  179.         </dl>
  180.     </div>
  181. {% endblock %}