contact_times.php 4.7 KB

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