contact_phones.php 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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_phone_view')) {
  26. //access granted
  27. }
  28. else {
  29. echo "access denied";
  30. exit;
  31. }
  32. //get the contact list
  33. $sql = "select * from v_contact_phones ";
  34. $sql .= "where domain_uuid = :domain_uuid ";
  35. $sql .= "and contact_uuid = :contact_uuid ";
  36. $sql .= "order by phone_primary desc, phone_label asc ";
  37. $parameters['domain_uuid'] = $domain_uuid;
  38. $parameters['contact_uuid'] = $contact_uuid ?? '';
  39. $database = new database;
  40. $contact_phones = $database->select($sql, $parameters, 'all');
  41. unset($sql, $parameters);
  42. //show if exists
  43. if (!empty($contact_phones)) {
  44. //javascript function: send_cmd
  45. echo "<script type=\"text/javascript\">\n";
  46. echo "function send_cmd(url) {\n";
  47. echo " if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari\n";
  48. echo " xmlhttp=new XMLHttpRequest();\n";
  49. echo " }\n";
  50. echo " else {// code for IE6, IE5\n";
  51. echo " xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");\n";
  52. echo " }\n";
  53. echo " xmlhttp.open(\"GET\",url,true);\n";
  54. echo " xmlhttp.send(null);\n";
  55. echo " document.getElementById('cmd_reponse').innerHTML=xmlhttp.responseText;\n";
  56. echo "}\n";
  57. echo "</script>\n";
  58. //show the content
  59. echo "<div class='action_bar sub shrink'>\n";
  60. echo " <div class='heading'><b>".$text['label-phone_numbers']."</b></div>\n";
  61. echo " <div style='clear: both;'></div>\n";
  62. echo "</div>\n";
  63. echo "<div class='card'>\n";
  64. echo "<table class='list'>\n";
  65. echo "<tr class='list-header'>\n";
  66. if (permission_exists('contact_phone_delete')) {
  67. echo " <th class='checkbox'>\n";
  68. echo " <input type='checkbox' id='checkbox_all_phones' name='checkbox_all' onclick=\"edit_all_toggle('phones');\" ".($contact_phones ?: "style='visibility: hidden;'").">\n";
  69. echo " </th>\n";
  70. }
  71. echo "<th class='pct-15'>".$text['label-phone_label']."</th>\n";
  72. echo "<th>".$text['label-phone_number']."</th>\n";
  73. echo "<th>".$text['label-phone_type']."</th>\n";
  74. echo "<th>".$text['label-phone_tools']."</th>\n";
  75. echo "<th class='hide-md-dn'>".$text['label-phone_description']."</th>\n";
  76. if (permission_exists('contact_phone_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  77. echo " <td class='action-button'>&nbsp;</td>\n";
  78. }
  79. echo "</tr>\n";
  80. if (!empty($contact_phones)) {
  81. $x = 0;
  82. foreach ($contact_phones as $row) {
  83. if (permission_exists('contact_phone_edit')) {
  84. $list_row_url = "contact_phone_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_phone_uuid']);
  85. }
  86. echo "<tr class='list-row' href='".$list_row_url."'>\n";
  87. if (permission_exists('contact_phone_delete')) {
  88. echo " <td class='checkbox'>\n";
  89. echo " <input type='checkbox' name='contact_phones[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_phones' value='true' onclick=\"edit_delete_action('phones');\">\n";
  90. echo " <input type='hidden' name='contact_phones[$x][uuid]' value='".escape($row['contact_phone_uuid'])."' />\n";
  91. echo " </td>\n";
  92. }
  93. echo " <td>".($row['phone_label'] == strtolower($row['phone_label']) ? ucwords($row['phone_label']) : $row['phone_label'])." ".($row['phone_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";
  94. echo " <td class='no-link'>\n";
  95. echo button::create(['type'=>'button','class'=>'link','label'=>escape(format_phone($row['phone_number'])),'title'=>$text['label-click_to_call'],'onclick'=>"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($row['phone_number'])."&src_cid_number=".urlencode($row['phone_number'])."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'])."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'])."&src=".urlencode($_SESSION['user']['extension'][0]['user'])."&dest=".urlencode($row['phone_number'])."&rec=false&ringback=us-ring&auto_answer=true');"]);
  96. echo " </td>\n";
  97. echo " <td class='no-wrap'>\n";
  98. if ($row['phone_type_voice']) { $phone_types[] = "<i class='fas fa-phone fa-fw' style='margin-right: 3px;' title=\"".$text['label-voice']."\"></i>"; }
  99. if ($row['phone_type_fax']) { $phone_types[] = "<i class='fas fa-fax fa-fw' style='margin-right: 3px;' title=\"".$text['label-fax']."\"></i>"; }
  100. if ($row['phone_type_video']) { $phone_types[] = "<i class='fas fa-video fa-fw' style='margin-right: 3px;' title=\"".$text['label-video']."\"></i>"; }
  101. if ($row['phone_type_text']) { $phone_types[] = "<i class='fas fa-sms fa-fw' style='margin-right: 3px;' title=\"".$text['label-text']."\"></i>"; }
  102. if (is_array($phone_types)) {
  103. echo " ".implode(" ", $phone_types)."\n";
  104. }
  105. unset($phone_types);
  106. echo " </td>\n";
  107. echo " <td class='no-link no-wrap'>\n";
  108. echo " <a href='../xml_cdr/xml_cdr.php?caller_id_number=".urlencode($row['phone_number'])."'>".$text['button-cdr']."</a>";
  109. if ($row['phone_type_voice']) {
  110. echo "&nbsp;<span class='hide-sm-dn'>\n";
  111. echo button::create(['type'=>'button','class'=>'link','label'=>$text['label-phone_call'],'title'=>$text['label-click_to_call'],'onclick'=>"send_cmd('".PROJECT_PATH."/app/click_to_call/click_to_call.php?src_cid_name=".urlencode($row['phone_number'])."&src_cid_number=".urlencode($row['phone_number'])."&dest_cid_name=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_name'])."&dest_cid_number=".urlencode($_SESSION['user']['extension'][0]['outbound_caller_id_number'])."&src=".urlencode($_SESSION['user']['extension'][0]['user'])."&dest=".urlencode($row['phone_number'])."&rec=false&ringback=us-ring&auto_answer=true');"]);
  112. echo "</span>";
  113. }
  114. echo " </td>\n";
  115. echo " <td class='description overflow hide-md-dn'>".escape($row['phone_description'])."&nbsp;</td>\n";
  116. if (permission_exists('contact_phone_edit') && $_SESSION['theme']['list_row_edit_button']['boolean'] == 'true') {
  117. echo " <td class='action-button'>\n";
  118. echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
  119. echo " </td>\n";
  120. }
  121. echo "</tr>\n";
  122. $x++;
  123. }
  124. unset($contact_phones);
  125. }
  126. echo "</table>\n";
  127. echo "</div>\n";
  128. echo "<br />\n";
  129. }
  130. ?>