+ $sql = "select l.id as id, TIME_FORMAT(l.start, $sql_time_format) as start,".
+ " TIME_FORMAT(sec_to_time(time_to_sec(l.start) + time_to_sec(l.duration)), $sql_time_format) as finish,".
+ " TIME_FORMAT(l.duration, '%k:%i') as duration, p.name as project, t.name as task, l.comment,".
+ " l.billable, l.approved, l.timesheet_id, l.invoice_id $client_field from tt_log l $left_joins".
+ " where l.date = '$date' and l.user_id = $user_id and l.group_id = $group_id and l.org_id = $org_id and l.status = 1".
+ " order by l.start, l.id";
+ $res = $mdb2->query($sql);
+ if (!is_a($res, 'PEAR_Error')) {
+ while ($val = $res->fetchRow()) {
+ if($val['duration']=='0:00')
+ $val['finish'] = '';
+ $result[] = $val;
+ }
+ } else return false;
+
+ return $result;
+ }
+
+ // getRecordsWithFiles - returns time records for a user for a given date
+ // with information whether they have attached files (has_files property).
+ // A separate fiunction from getRecords because sql here is more complex.
+ static function getRecordsWithFiles($user_id, $date) {
+ global $user;