templates/business_contacts/index.html.twig line 1

Open in your IDE?
  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.         <h2 style="color: red">{{ business_type }} </h2><br>
  7.         <table class="table table-responsive-sm">
  8.             <thead>
  9.             <tr>
  10.                 <th>Photo</th>
  11.                 {% if is_granted('ROLE_ADMIN') %}
  12.                     <th style="width: 10px; text-align: left; color: red">Status</th>
  13.                 {% endif %}
  14.                 <th style="width: 150px; text-align: left">Company</th>
  15.                 <th style="width: 150px; text-align: left">Name</th>
  16.                 <th class="desktop" style="width: 10px; text-align: center">Website</th>
  17.                 <th class="desktop" style="width: 10px; text-align: center">Email</th>
  18.                 <th class="desktop" style="width: 10px; text-align: center">Mobile</th>
  19.                 <th class="desktop" style="width: 10px; text-align: center">Landline</th>
  20.                 <th class="desktop" style="width: 10px; text-align: center">Address</th>
  21.                 {% if is_granted('ROLE_ADMIN') %}
  22.                     <th class="desktop" style="width: 10px; text-align: center">Location</th>
  23.                 {% endif %}
  24.                 <th style="width: 10px; text-align: center">
  25.                     VCF
  26.                 </th>
  27.                 <th class="desktop" style="width: 10px; text-align: center">Files</th>
  28.                 {% include 'business_contacts/parts/access_count_headers.html.twig' %}
  29.             </tr>
  30.             </thead>
  31.             <tbody>
  32.             {% for business_contact in business_contacts %}
  33.                 {% if business_type == business_contact.businessType.businessType %}
  34.                     <tr>
  35.                         <td>
  36.                             {% if business_contact.photo is not null or 1==1 %}
  37.                                 {% set photo = asset('administration/attachments/Business_contacts/Photos/')~business_contact.photo %}
  38.                                 <a class="btn btn-outline-danger btn-sm" target="_blank"
  39.                                    href="">
  40.                                     <img height="50" width="50" src="{{ photo }}" class="rounded-circle"></a>
  41.                                 {{ business_contact.photo }}
  42.                             {% endif %}
  43.                         </td>
  44.                         {% if is_granted('ROLE_ADMIN') %}
  45.                             <td style="width: 10px; text-align: center">
  46.                                 {% if business_contact.status == "Approved" %}
  47.                                     <i title="{{ business_contact.status }}" style="color: green"
  48.                                        class="fa fa-check"></i>
  49.                                 {% elseif business_contact.status == "Pending" %}
  50.                                     <i title="{{ business_contact.status }}" style="color: grey"
  51.                                        class="fa fa-question-circle"></i>
  52.                                 {% elseif business_contact.status == "Not Approved" %}
  53.                                     <i title="{{ business_contact.status }}" style="color: red"
  54.                                        class="fa fa-remove"></i>
  55.                                 {% endif %}
  56.                             </td>
  57.                         {% endif %}
  58.                         <td>
  59.                             {{ business_contact.company }}
  60.                         </td>
  61.                         <td>{{ business_contact.firstName }} {{ business_contact.LastName }}</td>
  62.                         <td class="desktop" style="text-align: center">
  63.                             {% if business_contact.website  is not null %}
  64.                                 <a data-title="{{ business_contact.website }}" target="_blank"
  65.                                    title="{{ business_contact.website }}"
  66.                                    href="{{ business_contact.website }}" class="action"
  67.                                    data-id="{{ business_contact.id }}" data-action="Website">
  68.                                     <i class="fas fa-link"> </i></a>
  69.                             {% endif %}
  70.                         </td>
  71.                         <td class="desktop" style="text-align: center">
  72.                             {% if business_contact.email is not null %}
  73.                                 <a title="{{ business_contact.email }}" href="mailto:{{ business_contact.email }}"
  74.                                    class="action" data-id="{{ business_contact.id }}"
  75.                                    data-action="Email"><i
  76.                                             class="fas fa-envelope"> </i>
  77.                                 </a>
  78.                             {% endif %}
  79.                         </td>
  80.                         <td class="desktop" style="text-align: center">
  81.                             {% if business_contact.mobile is not null %}
  82.                                 <a title="{{ business_contact.mobile }}" target="_blank"
  83.                                    href="https://wa.me/{{ business_contact.mobile|replace({' ': ''}) }}"
  84.                                    class="action"
  85.                                    data-id="{{ business_contact.id }}"
  86.                                    data-action="WhatsApp">
  87.                                     <i class="fab fa-whatsapp" style="color:green; text-align: center"></i></a>
  88.                             {% endif %}
  89.                         </td>
  90.                         <td class="desktop" style="text-align: center">
  91.                             {% if business_contact.landline is not null %}
  92.                                 <a title="{{ business_contact.landline }}"
  93.                                    href="tel:{{ business_contact.landline|replace({' ': ''}) }}" class="action"
  94.                                    data-id="{{ business_contact.id }}"
  95.                                    data-action="Phone">
  96.                                     <i class="fa fa-phone" style="color:green; text-align: center"></i></a>
  97.                             {% endif %}
  98.                         </td>
  99.                         <td class="desktop">
  100.                             {% if business_contact.addressStreet is not empty %}
  101.                                 {% if is_granted('ROLE') %}
  102.                                 {% else %}
  103.                                     {% if business_contact.locationLongitude is not empty %}
  104.                                         <a target="_blank"
  105.                                            href="{{ path('show_location_google_maps',{id: business_contact.id}) }}"
  106.                                            class="action" data-id="{{ business_contact.id }}"
  107.                                            data-action="Map">
  108.                                             <i class='fas fa-map-marker-alt text-danger'></i></a>
  109.                                     {% endif %}
  110.                                 {% endif %}
  111.                                 {{ business_contact.addressStreet }},
  112.                                 {{ business_contact.addressCity }},
  113.                                 {{ business_contact.addressPostCode }}
  114.                             {% endif %}
  115.                         </td>
  116.                         {% if is_granted('ROLE_ADMIN') %}
  117.                             <td class="desktop" style="text-align: center">
  118.                                 {% if business_contact.locationLongitude is empty %}
  119.                                     {% if is_granted('ROLE_ADMIN') %}
  120.                                         <button class="btn btn-primary btn-sm"
  121.                                                 onclick="getLocation('{{ business_contact.id }}')">
  122.                                             <i class="fa fa-arrow-down"></i>
  123.                                         </button>
  124.                                     {% else %}
  125.                                         -
  126.                                     {% endif %}
  127.                                 {% else %}
  128.                                     <a target="_blank"
  129.                                        href="{{ path('show_location_google_maps',{id: business_contact.id}) }}"
  130.                                        class="action" data-id="{{ business_contact.id }}"
  131.                                        data-action="Map">
  132.                                         <i class='fas fa-map-marker-alt text-danger'></i></a>
  133.                                 {% endif %}
  134.                             </td>
  135.                         {% endif %}
  136.                         <td style="text-align: center">
  137.                             <div class="mobile">
  138.                                 <a class="btn btn-success btn-sm"
  139.                                    href="{{ path('business_contacts_show',{id: business_contact.id}) }}">Show</a>
  140.                             </div>
  141.                             <div class="desktop" style="text-align: center">
  142.                                 <a href="{{ path('create_vcard', {id: business_contact.id} ) }}" class="action"
  143.                                    data-id="{{ business_contact.id }}"
  144.                                    data-action="VCF"> <i style="color: blue" class="fas fa-address-card mr-0"></i></a>
  145.                             </div>
  146.                         </td>
  147.                         <td class="desktop">
  148.                             {% if business_contact.files is not empty %}
  149.                                 <i title="{{ business_contact.files }}" class="fa fa-paperclip"></i>
  150.                             {% endif %}
  151.                         </td>
  152.                         {% include 'business_contacts/parts/access_count_body.html.twig' %}
  153.                     </tr>
  154.                 {% endif %}
  155.             {% else %}
  156.             {% endfor %}
  157.             </tbody>
  158.         </table>
  159.         <br>
  160.         <br>
  161.     {% endfor %}
  162. {% endblock %}
  163. {% block datatable %}
  164.     <script>
  165.         {% if is_granted('ROLE_ADMIN') %}
  166.         $(document).ready(function () {
  167.             $('.table').DataTable({
  168.                 'pageLength': 100,
  169.                 "order": [[1, 'asc'], [2, 'asc']],
  170.                 "paging": false,
  171.                 "searching": false,
  172.                 "bInfo": false
  173.             });
  174.         });
  175.         {% else %}
  176.         $(document).ready(function () {
  177.             $('.table').DataTable({
  178.                 'pageLength': 100,
  179.                 "order": [[1, 'asc']],
  180.                 "paging": false,
  181.                 "searching": false,
  182.                 "bInfo": false
  183.             });
  184.         });
  185.         {% endif %}
  186.     </script>
  187. {% endblock datatable %}
  188. {% block additionaljs %}
  189.     <script>
  190.         var businessContactId = '';
  191.         function getLocation(id) {
  192.             businessContactId = id;
  193.             if (navigator.geolocation) {
  194.                 navigator.geolocation.getCurrentPosition(showLocation);
  195.             } else {
  196.                 $('#location').html('Geolocation is not supported by this browser.');
  197.             }
  198.         }
  199.         function showLocation(position) {
  200.             var latitude = position.coords.latitude;
  201.             var longitude = position.coords.longitude;
  202.             var pin = latitude + "," + longitude;
  203.             $.ajax({
  204.                 type: 'POST',
  205.                 url: 'update/user/location',
  206.                 data: 'latitude=' + latitude + '&longitude=' + longitude + '&id=' + businessContactId,
  207.                 success: function (msg) {
  208.                     location.reload();
  209.                 }
  210.             });
  211.         }
  212.     </script>
  213.     <script>
  214.         $('.action').click(function (e) {
  215.             e.preventDefault();
  216.             let elem = $(this);
  217.             let id = $(this).attr('data-id');
  218.             let action = $(this).attr('data-action');
  219.             let url = '/referrals/new_from_businesscontacts/' + id + '/' + action;
  220.             $.ajax({
  221.                 type: 'GET',
  222.                 url: url,
  223.                 success: function (msg) {
  224.                     //window.location.href()
  225.                     //alert('success');
  226.                     let goTo = elem.attr('href');
  227.                     window.open(goTo, '_blank');
  228.                 }
  229.             });
  230.         })
  231.     </script>
  232. {% endblock %}