contact_timer_inc.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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-2015
  17. the Initial Developer. All Rights Reserved.
  18. Contributor(s):
  19. Mark J Crane <[email protected]>
  20. */
  21. require_once "root.php";
  22. require_once "resources/require.php";
  23. require_once "resources/check_auth.php";
  24. if (!permission_exists('contact_time_add')) { echo "access denied"; exit; }
  25. //get contact and time uuids
  26. $domain_uuid = $_REQUEST['domain_uuid'];
  27. $contact_uuid = $_REQUEST['contact_uuid'];
  28. $contact_time_uuid = $_REQUEST['contact_time_uuid'];
  29. //get time quantity
  30. $sql = "select ";
  31. $sql .= "time_start ";
  32. $sql .= "from v_contact_times ";
  33. $sql .= "where domain_uuid = :domain_uuid ";
  34. $sql .= "and contact_time_uuid = :contact_time_uuid ";
  35. $sql .= "and user_uuid = :user_uuid ";
  36. $sql .= "and contact_uuid = :contact_uuid ";
  37. $sql .= "and time_start is not null ";
  38. $sql .= "and time_stop is null ";
  39. $parameters['domain_uuid'] = $domain_uuid;
  40. $parameters['contact_uuid'] = $contact_uuid;
  41. $parameters['user_uuid'] = $_SESSION['user']['user_uuid'];
  42. $parameters['contact_time_uuid'] = $contact_time_uuid;
  43. $database = new database;
  44. $row = $database->select($sql, $parameters, 'row');
  45. if (is_array($row) && @sizeof($row) != 0) {
  46. $time_start = strtotime($row["time_start"]);
  47. $time_now = strtotime(date("Y-m-d H:i:s"));
  48. $time_diff = gmdate("H:i:s", ($time_now - $time_start));
  49. echo $time_diff;
  50. echo "<script id='title_script'>set_title('".$time_diff."');</script>";
  51. }
  52. unset ($sql, $parameters, $row);
  53. ?>