contact_addresses.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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-2024
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. //includes files
  22. require_once dirname(__DIR__, 2) . "/resources/require.php";
  23. require_once "resources/check_auth.php";
  24. //check permissions
  25. if (permission_exists('contact_address_view')) {
  26. //access granted
  27. }
  28. else {
  29. echo "access denied";
  30. exit;
  31. }
  32. //set from session variables
  33. $list_row_edit_button = !empty($_SESSION['theme']['list_row_edit_button']['boolean']) ? $_SESSION['theme']['list_row_edit_button']['boolean'] : 'false';
  34. //set the uuid
  35. if (!empty($_GET['id']) && is_uuid($_GET['id'])) {
  36. $contact_uuid = $_GET['id'];
  37. }
  38. //get the address list
  39. $sql = "select * from v_contact_addresses ";
  40. $sql .= "where domain_uuid = :domain_uuid ";
  41. $sql .= "and contact_uuid = :contact_uuid ";
  42. $sql .= "order by address_primary desc, address_label asc ";
  43. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  44. $parameters['contact_uuid'] = $contact_uuid ?? '';
  45. $database = new database;
  46. $contact_addresses = $database->select($sql, $parameters, 'all');
  47. unset($sql, $parameters);
  48. //show if exists
  49. if (!empty($contact_addresses)) {
  50. //show the content
  51. echo "<div class='action_bar sub shrink'>\n";
  52. echo " <div class='heading'><b>".!empty($text['label-addresses'])."</b></div>\n";
  53. echo " <div style='clear: both;'></div>\n";
  54. echo "</div>\n";
  55. echo "<div class='card'>\n";
  56. echo "<table class='list'>\n";
  57. echo "<tr class='list-header'>\n";
  58. if (permission_exists('contact_address_delete')) {
  59. echo " <th class='checkbox'>\n";
  60. echo " <input type='checkbox' id='checkbox_all_addresses' name='checkbox_all' onclick=\"edit_all_toggle('addresses');\" ".(!empty($contact_addresses) ?: "style='visibility: hidden;'").">\n";
  61. echo " </th>\n";
  62. }
  63. echo "<th class='pct-15'>".!empty($text['label-address_label'])."</th>\n";
  64. echo "<th>".!empty($text['label-address_address'])."</th>\n";
  65. echo "<th>".!empty($text['label-address_locality']).", ".!empty($text['label-address_region'])."</th>\n";
  66. echo "<th class='center'>".!empty($text['label-address_country'])."</th>\n";
  67. echo "<th class='shrink'>&nbsp;</th>\n";
  68. echo "<th class='hide-md-dn'>".!empty($text['label-address_description'])."</th>\n";
  69. if (permission_exists('contact_address_edit') && $list_row_edit_button == 'true') {
  70. echo " <td class='action-button'>&nbsp;</td>\n";
  71. }
  72. echo "</tr>\n";
  73. if (!empty($contact_addresses)) {
  74. $x = 0;
  75. foreach ($contact_addresses as $row) {
  76. $map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code'];
  77. if (permission_exists('contact_address_edit')) {
  78. $list_row_url = "contact_address_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_address_uuid']);
  79. }
  80. echo "<tr class='list-row' href='".$list_row_url."'>\n";
  81. if (permission_exists('contact_address_delete')) {
  82. echo " <td class='checkbox'>\n";
  83. echo " <input type='checkbox' name='contact_addresses[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_addresses' value='true' onclick=\"edit_delete_action('addresses');\">\n";
  84. echo " <input type='hidden' name='contact_addresses[$x][uuid]' value='".escape($row['contact_address_uuid'])."' />\n";
  85. echo " </td>\n";
  86. }
  87. echo " <td>".escape($row['address_label'])." ".($row['address_primary'] ? "&nbsp;<i class='fas fa-star fa-xs' style='float: right; margin-top: 0.5em; margin-right: -0.5em;' title=\"".$text['label-primary']."\"></i>" : null)."</td>\n";
  88. $address = escape($row['address_street']).(!empty($row['address_extended']) ? " ".escape($row['address_extended']) : null);
  89. echo " <td class='pct-25 overflow no-wrap'><a href='".$list_row_url."'>".$address."</a>&nbsp;</td>\n";
  90. echo " <td class='no-wrap'>".escape($row['address_locality']).((!empty($row['address_locality']) && !empty($row['address_region'])) ? ", " : null).escape($row['address_region'])."&nbsp;</td>\n";
  91. echo " <td class='center'>".escape($row['address_country'])."&nbsp;</td>\n";
  92. echo " <td class='button no-link'><a href=\"http://maps.google.com/maps?q=".urlencode($map_query)."&hl=en\" target=\"_blank\"><img src='resources/images/icon_gmaps.png' style='width: 21px; height: 21px; alt='".!empty($text['label-google_map'])."' title='".!empty($text['label-google_map'])."'></a></td>\n";
  93. echo " <td class='description overflow hide-md-dn'>".escape($row['address_description'])."&nbsp;</td>\n";
  94. if (permission_exists('contact_address_edit') && $list_row_edit_button == 'true') {
  95. echo " <td class='action-button'>\n";
  96. echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
  97. echo " </td>\n";
  98. }
  99. echo "</tr>\n";
  100. $x++;
  101. }
  102. unset($contact_addresses);
  103. }
  104. echo "</table>\n";
  105. echo "</div>\n";
  106. echo "<br />\n";
  107. }
  108. ?>