templates/front/form/contact.html.twig line 1

Open in your IDE?
  1. {% extends "front/_common/_base.html.twig" %}
  2. {% block linkcanonical %}
  3.     <link rel="canonical" href="{{ absolute_url(path('contact')) }}">
  4. {% endblock %}
  5. {% block cssadicional %}
  6. {% if info.captchaShow and info.captchaSite and info.captchaSecret %}
  7. <script src="https://www.google.com/recaptcha/api.js?onload=onloadCallback" async defer></script>
  8. <script type="text/javascript">
  9.   var onloadCallback = function() {
  10.     var element = document.getElementById('g-recaptcha-response');
  11.     element.classList.add('validate[required]');
  12.   };
  13. </script>
  14. {% endif %}
  15. {% endblock %}
  16. {% block classbody %}{% endblock %}
  17. {% block content %}
  18.     <section class="contacto">
  19.         <div class="contacto_banner">
  20.             <div class="contacto_container ww_center">
  21.                 <ul>
  22.                     <li><a href="{{ path('home') }}">Inicio</a></li>
  23.                     <li><span>/</span></li>
  24.                     <li><a class="active">Contacto</a></li>
  25.                 </ul>
  26.                 {% if sd.title %}
  27.                     <h2>{{ sd.title }}</h2>
  28.                 {% endif %}
  29.             </div>
  30.         </div>
  31.         <div class="contacto_wrap ww_center">
  32.             <div class="contacto_left">
  33.                 <div class="contacto_info">
  34.                     {% if forms.contactTitle %}
  35.                         <h2>{{ forms.contactTitle }}</h2>
  36.                     {% endif %}
  37.                     {% if forms.contactText %}
  38.                         <p>{{ forms.contactText|nl2br }}</p>
  39.                     {% endif %}
  40.                 </div>
  41.                 <div class="contacto_form">
  42.                     {{ form_start(form, {'attr': {'id': 'contactoForm'}}) }}
  43.                         {% include 'front/templates/form_utm_fields.html.twig' %}
  44.                         {{ form_widget(form.typeConsultation) }}
  45.                         {{ form_widget(form.typePerson) }}
  46.                         {{ form_widget(form.documentType) }}
  47.                         {{ form_widget(form.documentNumber) }}
  48.                         <div class="contacto_input">
  49.                             <select name="" id="form_contact_type_consultation" class="inputEffect validate[required]">
  50.                                 <option value="" disabled selected></option>
  51.                                 {% for item in forms.contactTypes %}
  52.                                     <option value="{{ item.title }}" data-link="{{ item.link }}">{{ item.title }}</option>
  53.                                 {% endfor %}
  54.                             </select>
  55.                             <label for="form_contact_type_consultation">Seleccione su tipo de consulta<span class="icon-arrow_drop_down"></span></label>
  56.                         </div>
  57.                         <div class="contacto_radius">
  58.                             <div class="contacto_tab_radio">
  59.                                 <input checked type="radio" name="form_type" class="checkedInput" value="Empresa" id="form_contact_legal_person">
  60.                                 <label for="form_contact_legal_person">Soy empresa</label>
  61.                             </div>
  62.                             <div class="contacto_tab_radio">
  63.                                 <input type="radio" name="form_type" class="checkedInput" value="Persona natural" id="form_contact_natural_person">
  64.                                 <label for="form_contact_natural_person">Soy Persona Natural</label>
  65.                             </div>
  66.                         </div>
  67.                         <ul>
  68.                             <li class="noneInputsEmpresa">
  69.                                 <div class="contacto_row_input">
  70.                                     <div class="contacto_input">
  71.                                         <input type="text" placeholder="" id="form_contact_document_number_legal_person" class="inputEffect form_notActive validate[required] form_contact_document_number">
  72.                                         <label for="form_document_number_legal_person">RUC *</label>
  73.                                     </div>
  74.                                     <div class="contacto_input">
  75.                                         {{ form_widget(form.company, {'attr': {'class': 'inputEffect form_notActive validate[required]'}}) }}
  76.                                         <label for="form_contact_company">Empresa</label>
  77.                                     </div>
  78.                                 </div>
  79.                             </li>
  80.                             <li class="noneInputs">
  81.                                 <div class="contacto_row_input">
  82.                                     <div class="contacto_input">
  83.                                         <select id="form_contact_document_types" class="inputEffect">
  84.                                             <option value="" disabled selected></option>
  85.                                             {% for item in forms.documentTypes %}
  86.                                                 <option value="{{ item.title }}">{{ item.title }}</option>
  87.                                             {% endfor %}
  88.                                         </select>
  89.                                         <label class="field_text" for="form_contact_document_types">Tipo de documento* <span class="icon-arrow_drop_down"></span></label>
  90.                                     </div>
  91.                                     <div class="contacto_input">
  92.                                         <input type="text" placeholder="" id="form_contact_document_number_natural_person" class="inputEffect form_isActive validate[required] form_contact_document_number">
  93.                                         <label for="form_document_number_natural_person">Número de documento</label>
  94.                                     </div>
  95.                                 </div>
  96.                             </li>
  97.                             <li class="">
  98.                                 <div class="contacto_row_input">
  99.                                     <div class="contacto_input">
  100.                                         {{ form_widget(form.name, {'attr': {'class': 'inputEffect validate[required]'}}) }}
  101.                                         <label for="form_contact_name">Nombres</label>
  102.                                     </div>
  103.                                     <div class="contacto_input">
  104.                                         {{ form_widget(form.department, {'attr': {'class': 'inputEffect validate[required]'}}) }}
  105.                                         <label for="form_contact_department">Departamento</label>
  106.                                     </div>
  107.                                 </div>
  108.                             </li>
  109.                             <li>
  110.                                 <div class="contacto_row_input">
  111.                                     <div class="contacto_input">
  112.                                         {{ form_widget(form.phone, {'attr': {'class': 'inputEffect validate[required, custom[phone]]'}}) }}
  113.                                         <label for="form_contact_phone">Teléfono</label>
  114.                                     </div>
  115.                                     <div class="contacto_input">
  116.                                         {{ form_widget(form.email, {'attr': {'class': 'inputEffect validate[required, custom[email]]'}}) }}
  117.                                         <label for="form_contact_email">Correo Electrónico</label>
  118.                                     </div>
  119.                                 </div>
  120.                             </li>
  121.                             <li>
  122.                                 <div class="contacto_input contacto_textarea">
  123.                                     {{ form_widget(form.message, {'attr': {'class': 'inputEffect validate[required]'}}) }}
  124.                                     <label for="form_contact_message">Mensaje</label>
  125.                                 </div>
  126.                             </li>
  127.                         </ul>
  128.                         <div class="contacto_obligatorio">
  129.                             <p>* Campos obligatorios</p>
  130.                         </div>
  131.                         <div class="contacto_check">
  132.                             <input type="checkbox" id="inputCheck" class="validate[required]" name="">
  133.                             <label for="inputCheck">
  134.                                 <span class="contacto_check_active"></span>
  135.                                 <p>He leído y acepto las <a href="{{ path('data_protection_policies') }}" target="_blank">Políticas de privacidad</a></p>
  136.                             </label>
  137.                         </div>
  138.                         {% if info.captchaShow and info.captchaSite and info.captchaSecret %}
  139.                         <div style="padding-top:20px">
  140.                             <div class="g-recaptcha" data-sitekey="{{ info.captchaSite }}"></div>
  141.                         </div>
  142.                         {% endif %}
  143.                         <div class="contacto_btn">
  144.                             <button class="btn btn_blue" id="btnForm">Enviar</button>
  145.                         </div>
  146.                     {{ form_end(form) }}
  147.                 </div>
  148.             </div>
  149.             {% if sd.customerServiceShow and sd.customerServiceItems|length > 0 %}
  150.                 <div class="contacto_rigth">
  151.                     <h2>{{ sd.customerServiceTitle ?: 'Atención al cliente' }}</h2>
  152.                     {% for item in sd.customerServiceItems %}
  153.                         <h3>{{ item.city }}</h3>
  154.                         <a href="tel:{{ item.phone|only_numbers }}"><span class="icon-phone_in_talk"></span>{{ item.phone }}</a>
  155.                         <a href="mailto:{{ item.email }}"><span class="icon-mail_outline"></span>{{ item.email }}</a>
  156.                         <a href="{{ item.address|google_maps_search }}" target="_blank"><span class="icon-place-1"></span>{{ item.address }}</a>
  157.                         <p><span class="icon-hour"></span>{{ item.officeHours|nl2br }}</p>
  158.                     {% endfor %}
  159.                 </div>
  160.             {% endif %}
  161.         </div>
  162.     </section>
  163. {% endblock %}
  164. {% block jsfinal %}
  165.     <script src="{{ asset('static/js/validationform/jquery.validationEngine-es.js') }}"></script>
  166.     <script src="{{ asset('static/js/validationform/staff.validationEngine.js') }}"></script>
  167.     <script type="text/javascript">
  168.         var efectInput = function (inputName, efectInput) {
  169.             var inputs = document.getElementsByClassName(inputName)
  170.             for (var i = 0; i < inputs.length; i++) {
  171.                 inputs[i].addEventListener('change', function () {
  172.                     if (this.value) {
  173.                         this.nextElementSibling.classList.add(efectInput)
  174.                     } else {
  175.                         this.nextElementSibling.classList.remove(efectInput)
  176.                     }
  177.                 })
  178.                 inputs[i].addEventListener('keyup', function () {
  179.                     if (this.value === "") {
  180.                         this.nextElementSibling.classList.remove(efectInput)
  181.                     } else {
  182.                         this.nextElementSibling.classList.add(efectInput)
  183.                     }
  184.                 })
  185.             }
  186.         }
  187.         efectInput('inputEffect', 'fijar')
  188.         let InputChecked = document.querySelectorAll('.checkedInput');
  189.         let elementDivHidden = document.querySelectorAll('.form_isActive');
  190.         let elementDivVisible = document.querySelectorAll('.form_notActive');
  191.         InputChecked.forEach((item) => {
  192.             item.addEventListener('change', () => {
  193.                 if (item.value === 'Empresa') {
  194.                     elementDivHidden.forEach((el) => {
  195.                         el.disabled = true
  196.                         el.closest('.noneInputs').style.display = 'none'
  197.                     })
  198.                     elementDivVisible.forEach((el) => {
  199.                         el.disabled = false
  200.                         el.closest('.noneInputsEmpresa').style.display = 'block'
  201.                     })
  202.                 } else {
  203.                     elementDivHidden.forEach((el) => {
  204.                         el.disabled = false
  205.                         el.closest('.noneInputs').style.display = 'block'
  206.                     })
  207.                     elementDivVisible.forEach((el) => {
  208.                         el.disabled = true
  209.                         el.closest('.noneInputsEmpresa').style.display = 'none'
  210.                     })
  211.                 }
  212.             })
  213.         })
  214.         var b2serviceFields = $(".contacto_input input, .contacto_input textarea, .contacto_input select")
  215.         $(b2serviceFields).focusin(function () {
  216.             $(this).addClass('border');
  217.         });
  218.         $(b2serviceFields).focusout(function () {
  219.             if ($(this).val() === "") {
  220.                 $(this).removeClass('border');
  221.             }
  222.         });
  223.         $(b2serviceFields).each(function () {
  224.             if ($(this).val() !== "" && $(this).val() !== null) {
  225.                 $(this).addClass('border');
  226.             } else {
  227.                 $(this).removeClass('border');
  228.             }
  229.         });
  230.         $('#form_contact_legal_person').on('change', function () {
  231.             $('#form_contact_typePerson').val($(this).val());
  232.             $('#form_contact_document_types').val('');
  233.             $('#form_contact_document_number_natural_person').val('');
  234.             $('#form_contact_document_number_legal_person').val('');
  235.             $('#form_contact_documentType').val('RUC');
  236.             $('#form_contact_documentNumber').val('');
  237.             $('#form_contact_company').val('');
  238.         })
  239.         $('#form_contact_natural_person').on('change', function () {
  240.             $('#form_contact_typePerson').val($(this).val());
  241.             $('#form_contact_document_types').val('');
  242.             $('#form_contact_document_number_natural_person').val('');
  243.             $('#form_contact_document_number_legal_person').val('');
  244.             $('#form_contact_documentType').val('');
  245.             $('#form_contact_documentNumber').val('');
  246.         })
  247.         $('#form_contact_legal_person').trigger('change');
  248.         $('.form_contact_document_number').on('keyup', function () {
  249.             $('#form_contact_documentNumber').val($(this).val());
  250.         })
  251.         $('#form_contact_document_types').on('change', function () {
  252.             $('#form_contact_documentType').val($(this).val());
  253.         })
  254.         $('#form_contact_type_consultation').on('change', function () {
  255.             $('#form_contact_typeConsultation').val($(this).val());
  256.         })
  257.         $('#form_contact_type_consultation').change(function(e){
  258.             e.preventDefault();
  259.             let link = $(this).find('option:selected').eq(0).data('link');
  260.             if( link ) {
  261.                 location.href = link;
  262.             }
  263.         })
  264.         const form_contact = $('#contactoForm');
  265.         const form_contact_button = $('#btnForm');
  266.         form_contact.validationEngine('attach', {
  267.             promptPosition: "topLeft",
  268.             autoHidePrompt: true,
  269.             autoHideDelay: 3000,
  270.             binded: false,
  271.             scroll: false
  272.         });
  273.         form_contact_button.on('click', function (event) {
  274.             event.preventDefault();
  275.             const valid = form_contact.validationEngine('validate');
  276.             $(this).attr('disabled', true);
  277.             if (valid) {
  278.                 form_contact.submit();
  279.             } else {
  280.                 $(this).attr('disabled', false);
  281.             }
  282.         });
  283.     </script>
  284. {% endblock %}