PageRenderTime 47ms CodeModel.GetById 24ms RepoModel.GetById 0ms app.codeStats 0ms

/includes/ajax_timeclock_sync.php

https://bitbucket.org/websightdesigns/project-manager
PHP | 31 lines | 28 code | 1 blank | 2 comment | 1 complexity | b83350514fa6c6a4bc15cb6a2844d602 MD5 | raw file
  1. <?php
  2. $task_id = $_GET['taskid'];
  3. $durationstr = $_POST['duration'];
  4. $durationparts = explode(".", $durationstr);
  5. $duration = $durationparts[0];
  6. include("../mysql.php");
  7. $link = mysql_connect($mysqlhost, $mysqluser, $mysqlpass) or die("Could not connect to server");
  8. mysql_select_db($mysqldb) or die("Could not select database");
  9. // determine if most recent timeclock entry was in or out
  10. $select_sql = "SELECT id,
  11. taskid,
  12. clock_in,
  13. clock_out,
  14. userid
  15. FROM hours
  16. WHERE taskid='$task_id'
  17. AND clock_out='0000-00-00 00:00:00'
  18. AND userid='" . $_SESSION['userid_auth'] . "'
  19. ORDER BY clock_in DESC
  20. LIMIT 1";
  21. $select_query = mysql_query($select_sql) or die(mysql_error());
  22. $num_rows = mysql_num_rows($select_query);
  23. if($num_rows):
  24. while(list($hour_id, $task_id, $clock_in, $clock_out, $userid) = mysql_fetch_row($select_query)):
  25. // determine duration since clock-in time
  26. $interval = date_diff(date_create($clock_in), date_create(date('H:i:s')));
  27. echo $interval->format('%H:%M:%S');
  28. endwhile;
  29. endif;
  30. ?>