contact_relations_view.php 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. <?php
  2. /*
  3. FusionPBX
  4. Version: MPL 1.1
  5. The contents of this file are subject to the Mozilla Public License Version
  6. 1.1 (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.mozilla.org/MPL/
  9. Software distributed under the License is distributed on an "AS IS" basis,
  10. WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
  11. for the specific language governing rights and limitations under the
  12. License.
  13. The Original Code is FusionPBX
  14. The Initial Developer of the Original Code is
  15. Mark J Crane <[email protected]>
  16. Portions created by the Initial Developer are Copyright (C) 2008-2020
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes
  22. require_once "root.php";
  23. require_once "resources/require.php";
  24. require_once "resources/check_auth.php";
  25. //check permissions
  26. if (permission_exists('contact_relation_view')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //get the related contacts
  34. $sql = "select ";
  35. $sql .= "cr.contact_relation_uuid, ";
  36. $sql .= "cr.relation_label, ";
  37. $sql .= "c.contact_uuid, ";
  38. $sql .= "c.contact_organization, ";
  39. $sql .= "c.contact_name_given, ";
  40. $sql .= "c.contact_name_family ";
  41. $sql .= "from ";
  42. $sql .= "v_contact_relations as cr, ";
  43. $sql .= "v_contacts as c ";
  44. $sql .= "where ";
  45. $sql .= "cr.relation_contact_uuid = c.contact_uuid ";
  46. $sql .= "and cr.domain_uuid = :domain_uuid ";
  47. $sql .= "and cr.contact_uuid = :contact_uuid ";
  48. $sql .= "order by ";
  49. $sql .= "c.contact_organization desc, ";
  50. $sql .= "c.contact_name_given asc, ";
  51. $sql .= "c.contact_name_family asc ";
  52. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  53. $parameters['contact_uuid'] = $contact_uuid;
  54. $database = new database;
  55. $contact_relations = $database->select($sql, $parameters, 'all');
  56. unset($sql, $parameters);
  57. //show if exists
  58. if (is_array($contact_relations) && @sizeof($contact_relations) != 0) {
  59. //show the content
  60. echo "<div class='grid' style='grid-template-columns: 70px auto auto;'>\n";
  61. $x = 0;
  62. foreach ($contact_relations as $row) {
  63. echo "<div class='box contact-details-label'>".escape($row['relation_label'])."</div>\n";
  64. echo "<div class='box'><a href='contact_view.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_organization'])."</a></div>\n";
  65. echo "<div class='box'><a href='contact_view.php?id=".urlencode($row['contact_uuid'])."'>".escape($row['contact_name_given']).(($row['contact_name_given'] && $row['contact_name_family']) ? ' ' : null).escape($row['contact_name_family'])."</a></div>\n";
  66. $x++;
  67. }
  68. echo "</div>\n";
  69. unset($contact_relations);
  70. }
  71. ?>