/includes/ajax_timeclock_sync.php
PHP | 31 lines | 28 code | 1 blank | 2 comment | 1 complexity | b83350514fa6c6a4bc15cb6a2844d602 MD5 | raw file
- <?php
- $task_id = $_GET['taskid'];
- $durationstr = $_POST['duration'];
- $durationparts = explode(".", $durationstr);
- $duration = $durationparts[0];
- include("../mysql.php");
- $link = mysql_connect($mysqlhost, $mysqluser, $mysqlpass) or die("Could not connect to server");
- mysql_select_db($mysqldb) or die("Could not select database");
-
- // determine if most recent timeclock entry was in or out
- $select_sql = "SELECT id,
- taskid,
- clock_in,
- clock_out,
- userid
- FROM hours
- WHERE taskid='$task_id'
- AND clock_out='0000-00-00 00:00:00'
- AND userid='" . $_SESSION['userid_auth'] . "'
- ORDER BY clock_in DESC
- LIMIT 1";
- $select_query = mysql_query($select_sql) or die(mysql_error());
- $num_rows = mysql_num_rows($select_query);
- if($num_rows):
- while(list($hour_id, $task_id, $clock_in, $clock_out, $userid) = mysql_fetch_row($select_query)):
- // determine duration since clock-in time
- $interval = date_diff(date_create($clock_in), date_create(date('H:i:s')));
- echo $interval->format('%H:%M:%S');
- endwhile;
- endif;
- ?>