templates/business_contacts/index.html.twig line 1

  1. {% extends 'base.html.twig' %}
  2. {% block title %}Business Contacts{% endblock %}
  3. {% block body %}
  4.     {% include 'business_contacts/parts/import_and_export.html.twig' %}
  5.     {% for business_type in business_types %}
  6.         {% set business_contacts_count = CountBusinessContactsService.count(business_type) %}
  7.         {% set business_contacts_count_with_map_locations = CountBusinessContactsService.countWithMapLocations(business_type) %}
  8.         {% if business_type.mapicon is not null %}
  9.             {% set file = asset( 'administration/ATSSharedFiles/BusinessContactsMapIcons/' ~ business_type.mapIcon.iconFile) %}
  10.         {% endif %}
  11.         {% if business_contacts_count >0 %}
  12.             <div class="row">
  13.                 <div class="col-10">
  14.                     <h2 style="color: red">
  15.                         {% if business_contacts_count_with_map_locations> 0 %}
  16.                             <a class="btn btn-danger btn-sm"
  17.                                href="{{ path('business_contacts_map',{subset: business_type.businessType}) }}">
  18.                                 <i class="fa fa-map-marker"></i>
  19.                             </a>
  20.                         {% endif %}
  21.                         {% if business_type.mapIcon is not empty %}
  22.                             <img height="40" width="40" src="{{ file }}">
  23.                         {% endif %}
  24.                         {% if is_granted('ROLE_ADMIN') %}
  25.                             <a target="_blank" href="{{ path('business_types_edit',{id:business_type.id}) }}">
  26.                                 {{ business_type.businessType }}
  27.                             </a>
  28.                         {% else %}
  29.                             {{ business_type.businessType }}
  30.                         {% endif %}
  31.                         {% if app.user %}
  32.                             <a href="{{ path('business_contacts_new', {business_type: business_type.id}) }}">+</a>
  33.                         {% endif %}
  34.                     </h2>
  35.                 </div>
  36.             </div>
  37.             <table class="table table-responsive custom-table">
  38.                 <thead>
  39.                 <tr>
  40.                     {#                    <---- Start of Body 1 ----> #}
  41.                     <th>Photo</th>
  42.                     {#                    <---- End of Body 1 ----> #}
  43.                     {#                    <---- Start of Body 2 ----> #}
  44.                     <th style="width: 350px; text-align: left">Company</th>
  45.                     {% if list_or_map=='map' %}
  46.                         <th></th>{% endif %}
  47.                     <th style="width: 100px; text-align: left">
  48.                         <i class="fa fa-user"></i>
  49.                     </th>
  50.                     {#                    <---- End of Body 2 ----> #}
  51.                     {#                    <---- Start of Body 3 ----> #}
  52.                     <th class="desktop" title="Website" style="width: 10px; text-align: center">
  53.                         <i class="fa fa-link"></i>
  54.                     </th>
  55.                     <th class="desktop" title="Email" style="width: 10px; text-align: center">
  56.                         <i class="fa fa-envelope"></i>
  57.                     </th>
  58.                     <th class="desktop" title="Mobile" style="width: 10px; text-align: center; border-left: 1px dotted;">
  59.                         <i class="fab fa-whatsapp"></i>
  60.                     </th>
  61.                     {% for type in ['mobile'] %}
  62.                         {% include 'business_contacts/parts/telephone_numbers_header.html.twig' %}
  63.                     {% endfor %}
  64.                     <th class="desktop" title="Phone" style="width: 10px; text-align: center">
  65.                         <i class="fa fa-phone"></i>
  66.                     </th>
  67.                     {% for type in ['landline'] %}
  68.                         {% include 'business_contacts/parts/telephone_numbers_header.html.twig' %}
  69.                     {% endfor %}
  70.                     {#                    <---- End of Body 3 ----> #}
  71.                     {#                    <---- Start of Body 4 ----> #}
  72.                     <th class="mobile">' '</th>
  73.                     <th class="desktop" title="Address" style="width: 400px; text-align: left">
  74.                         <i class="fa fa-building"></i>
  75.                     </th>
  76.                     {#                    <---- End of Body 4 ----> #}
  77.                     {#                    <---- Start of Body 5 ----> #}
  78.                     <th class="desktop" title="Notes" style="width: 100px; text-align: left"><i class="fa fa-pen"></i>
  79.                     </th>
  80.                     <th style="width: 10px; text-align: center" title="Business card"><i class="fa fa-address-card"></i>
  81.                     </th>
  82.                     <th class="desktop" title="Files" style="width: 10px; text-align: center"><i
  83.                                 class="fa fa-file-pdf"></i></th>
  84.                     {% include 'business_contacts/parts/access_count_headers.html.twig' %}
  85.                 </tr>
  86.                 </thead>
  87.                 <tbody>
  88.                 {% for business_contact in business_contacts %}
  89.                     {% set phoneAnalysisMobile = phoneAnalysisMobile[business_contact.id] ?? null %}
  90.                     {% set phoneAnalysisLandline = phoneAnalysisLandline[business_contact.id] ?? null %}
  91.                     {% if business_type == business_contact.businessType %}
  92.                         {% set business_contact_website =[] %}
  93.                         {% if business_contact.website is not empty %}
  94.                             {% if business_contact.website starts with 'http' %}
  95.                                 {% set business_contact_website = business_contact.website %}
  96.                             {% else %}
  97.                                 {% set business_contact_website = 'https://'~ business_contact.website %}
  98.                             {% endif %}
  99.                         {% endif %}
  100.                         <tr>
  101.                             {% include 'business_contacts/parts/1 photo.html.twig' %}
  102.                             {% include 'business_contacts/parts/2 company_and_user.html.twig' %}
  103.                             {% include 'business_contacts/parts/3 website_email_tels.html.twig' %}
  104.                             {% include 'business_contacts/parts/4 map marker.html.twig' %}
  105.                             {% include 'business_contacts/parts/5 notes buttons files.html.twig' %}
  106.                             {% include 'business_contacts/parts/access_count_body.html.twig' %}
  107.                         </tr>
  108.                     {% endif %}
  109.                 {% endfor %}
  110.                 </tbody>
  111.             </table>
  112.             <br><br>
  113.         {% endif %}
  114.     {% endfor %}
  115. {% endblock %}
  116. {% block datatable %}
  117.     <script>
  118.         {% if is_granted('ROLE_ADMIN') %}
  119.         $(document).ready(function () {
  120.             $('.table').DataTable({
  121.                 'pageLength': 100,
  122.                 "order": [[12, 'asc'], [1, 'asc']],
  123.                 "paging": false,
  124.                 "searching": false,
  125.                 "bInfo": false
  126.             });
  127.         });
  128.         {% else %}
  129.         $(document).ready(function () {
  130.             $('.table').DataTable({
  131.                 'pageLength': 100,
  132.                 "order": [[1, 'asc']],
  133.                 "paging": false,
  134.                 "searching": false,
  135.                 "bInfo": false
  136.             });
  137.         });
  138.         {% endif %}
  139.     </script>
  140. {% endblock datatable %}
  141. {% block additionaljs %}
  142.     <script>
  143.         var businessContactId = '';
  144.         function getLocation(id) {
  145.             businessContactId = id;
  146.             if (navigator.geolocation) {
  147.                 navigator.geolocation.getCurrentPosition(showLocation);
  148.             } else {
  149.                 $('#location').html('Geolocation is not supported by this browser.');
  150.             }
  151.         }
  152.         function showLocation(position) {
  153.             var latitude = position.coords.latitude;
  154.             var longitude = position.coords.longitude;
  155.             var pin = latitude + "," + longitude;
  156.             $.ajax({
  157.                 type: 'POST',
  158.                 url: 'update/location',
  159.                 data: 'latitude=' + latitude + '&longitude=' + longitude + '&id=' + businessContactId,
  160.                 success: function (msg) {
  161.                     location.reload();
  162.                 }
  163.             });
  164.         }
  165.     </script>
  166.     <script>
  167.         $('.action').click(function (e) {
  168.             e.preventDefault();
  169.             let elem = $(this);
  170.             let id = $(this).attr('data-id');
  171.             let action = $(this).attr('data-action');
  172.             let url = '/referrals/new_from_businesscontacts/' + id + '/' + action;
  173.             $.ajax({
  174.                 type: 'GET',
  175.                 url: url,
  176.                 success: function (msg) {
  177.                     //window.location.href()
  178.                     //alert('success');
  179.                     let goTo = elem.attr('href');
  180.                     window.open(goTo, '_blank');
  181.                 }
  182.             });
  183.         })
  184.     </script>
  185. {% endblock %}