contact_addresses.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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_address_view')) {
  27. //access granted
  28. }
  29. else {
  30. echo "access denied";
  31. exit;
  32. }
  33. //set the uuid
  34. if (is_uuid($_GET['id'])) {
  35. $contact_uuid = $_GET['id'];
  36. }
  37. //get the address list
  38. $sql = "select * from v_contact_addresses ";
  39. $sql .= "where domain_uuid = :domain_uuid ";
  40. $sql .= "and contact_uuid = :contact_uuid ";
  41. $sql .= "order by address_primary desc, address_label asc ";
  42. $parameters['domain_uuid'] = $_SESSION['domain_uuid'];
  43. $parameters['contact_uuid'] = $contact_uuid;
  44. $database = new database;
  45. $contact_addresses = $database->select($sql, $parameters, 'all');
  46. unset($sql, $parameters);
  47. //show if exists
  48. if (is_array($contact_addresses) && @sizeof($contact_addresses) != 0) {
  49. //show the content
  50. echo "<div class='action_bar sub shrink'>\n";
  51. echo " <div class='heading'><b>".$text['label-addresses']."</b></div>\n";
  52. echo " <div style='clear: both;'></div>\n";
  53. echo "</div>\n";
  54. echo "<table class='list'>\n";
  55. echo "<tr class='list-header'>\n";
  56. if (permission_exists('contact_address_delete')) {
  57. echo " <th class='checkbox'>\n";
  58. echo " <input type='checkbox' id='checkbox_all_addresses' name='checkbox_all' onclick=\"edit_all_toggle('addresses');\" ".($contact_addresses ?: "style='visibility: hidden;'").">\n";
  59. echo " </th>\n";
  60. }
  61. echo "<th class='pct-15'>".$text['label-address_label']."</th>\n";
  62. echo "<th>".$text['label-address_address']."</th>\n";
  63. echo "<th>".$text['label-address_locality'].", ".$text['label-address_region']."</th>\n";
  64. echo "<th class='center'>".$text['label-address_country']."</th>\n";
  65. echo "<th class='shrink'>&nbsp;</th>\n";
  66. echo "<th class='hide-md-dn'>".$text['label-address_description']."</th>\n";
  67. if (permission_exists('contact_address_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  68. echo " <td class='action-button'>&nbsp;</td>\n";
  69. }
  70. echo "</tr>\n";
  71. if (is_array($contact_addresses) && @sizeof($contact_addresses) != 0) {
  72. $x = 0;
  73. foreach ($contact_addresses as $row) {
  74. $map_query = $row['address_street']." ".$row['address_extended'].", ".$row['address_locality'].", ".$row['address_region'].", ".$row['address_region'].", ".$row['address_postal_code'];
  75. if (permission_exists('contact_address_edit')) {
  76. $list_row_url = "contact_address_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_address_uuid']);
  77. }
  78. echo "<tr class='list-row' href='".$list_row_url."'>\n";
  79. if (permission_exists('contact_address_delete')) {
  80. echo " <td class='checkbox'>\n";
  81. 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";
  82. echo " <input type='hidden' name='contact_addresses[$x][uuid]' value='".escape($row['contact_address_uuid'])."' />\n";
  83. echo " </td>\n";
  84. }
  85. 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";
  86. $address = escape($row['address_street']).($row['address_extended'] != '' ? " ".escape($row['address_extended']) : null);
  87. echo " <td class='pct-25 overflow no-wrap'><a href='".$list_row_url."'>".$address."</a>&nbsp;</td>\n";
  88. echo " <td class='no-wrap'>".escape($row['address_locality']).(($row['address_locality'] != '' && $row['address_region'] != '') ? ", " : null).escape($row['address_region'])."&nbsp;</td>\n";
  89. echo " <td class='center'>".escape($row['address_country'])."&nbsp;</td>\n";
  90. 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='".$text['label-google_map']."' title='".$text['label-google_map']."'></a></td>\n";
  91. echo " <td class='description overflow hide-md-dn'>".escape($row['address_description'])."&nbsp;</td>\n";
  92. if (permission_exists('contact_address_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  93. echo " <td class='action-button'>\n";
  94. echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
  95. echo " </td>\n";
  96. }
  97. echo "</tr>\n";
  98. $x++;
  99. }
  100. unset($contact_addresses);
  101. }
  102. echo "</table>\n";
  103. echo "<br />\n";
  104. }
  105. ?>