contact_times.php 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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_time_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 contact list
  39. $sql = "select ct.*, u.username, u.domain_uuid as user_domain_uuid ";
  40. $sql .= "from v_contact_times as ct, v_users as u ";
  41. $sql .= "where ct.user_uuid = u.user_uuid ";
  42. $sql .= "and ct.domain_uuid = :domain_uuid ";
  43. $sql .= "and ct.contact_uuid = :contact_uuid ";
  44. $sql .= "order by ct.time_start desc ";
  45. $parameters['domain_uuid'] = $domain_uuid;
  46. $parameters['contact_uuid'] = $contact_uuid ?? '';
  47. $database = new database;
  48. $contact_times = $database->select($sql, $parameters, 'all');
  49. unset($sql, $parameters);
  50. //show if exists
  51. if (!empty($contact_times)) {
  52. //show the content
  53. echo "<div class='action_bar sub shrink'>\n";
  54. echo " <div class='heading'><b>".$text['header_contact_times']."</b></div>\n";
  55. echo " <div style='clear: both;'></div>\n";
  56. echo "</div>\n";
  57. echo "<div class='card'>\n";
  58. echo "<table class='list'>\n";
  59. echo "<tr class='list-header'>\n";
  60. if (permission_exists('contact_time_delete')) {
  61. echo " <th class='checkbox'>\n";
  62. echo " <input type='checkbox' id='checkbox_all_times' name='checkbox_all' onclick=\"edit_all_toggle('times');\" ".($contact_times ?: "style='visibility: hidden;'").">\n";
  63. echo " </th>\n";
  64. }
  65. echo "<th class='pct-20'>".$text['label-time_user']."</th>\n";
  66. echo "<th class='pct-20'>".$text['label-time_start']."</th>\n";
  67. echo "<th class='pct-20'>".$text['label-time_duration']."</th>\n";
  68. echo "<th class='pct-40 hide-md-dn'>".$text['label-time_description']."</th>\n";
  69. if (permission_exists('contact_time_edit') && $list_row_edit_button == 'true') {
  70. echo " <td class='action-button'>&nbsp;</td>\n";
  71. }
  72. echo "</tr>\n";
  73. if (!empty($contact_times)) {
  74. $x = 0;
  75. foreach ($contact_times as $row) {
  76. if (!empty($row["time_start"]) && !empty($row['time_stop'])) {
  77. $time_start = strtotime($row["time_start"]);
  78. $time_stop = strtotime($row['time_stop']);
  79. $time = gmdate("H:i:s", ($time_stop - $time_start));
  80. }
  81. else {
  82. unset($time);
  83. }
  84. $tmp = explode(' ', $row['time_start']);
  85. $time_start = $tmp[0];
  86. if (permission_exists('contact_time_edit')) {
  87. $list_row_url = "contact_time_edit.php?contact_uuid=".urlencode($row['contact_uuid'])."&id=".urlencode($row['contact_time_uuid']);
  88. }
  89. echo "<tr class='list-row' href='".$list_row_url."'>\n";
  90. if (permission_exists('contact_time_delete')) {
  91. echo " <td class='checkbox'>\n";
  92. echo " <input type='checkbox' name='contact_times[$x][checked]' id='checkbox_".$x."' class='chk_delete checkbox_times' value='true' onclick=\"edit_delete_action('times');\">\n";
  93. echo " <input type='hidden' name='contact_times[$x][uuid]' value='".escape($row['contact_time_uuid'])."' />\n";
  94. echo " </td>\n";
  95. }
  96. echo " <td><span ".($row['user_domain_uuid'] != $domain_uuid ? "title='".$_SESSION['domains'][escape($row['user_domain_uuid'])]['domain_name']."' style='cursor: help;'" : null).">".escape($row["username"])."</span>&nbsp;</td>\n";
  97. echo " <td>".$time_start."&nbsp;</td>\n";
  98. echo " <td>".$time."&nbsp;</td>\n";
  99. echo " <td class='description overflow hide-md-dn'>".escape($row['time_description'])."&nbsp;</td>\n";
  100. if (permission_exists('contact_time_edit') && $list_row_edit_button == 'true') {
  101. echo " <td class='action-button'>\n";
  102. echo button::create(['type'=>'button','title'=>$text['button-edit'],'icon'=>$_SESSION['theme']['button_icon_edit'],'link'=>$list_row_url]);
  103. echo " </td>\n";
  104. }
  105. echo "</tr>\n";
  106. $x++;
  107. }
  108. unset($contact_times);
  109. }
  110. echo "</table>\n";
  111. echo "</div>\n";
  112. echo "<br />\n";
  113. }
  114. ?>