- if ($user->isClient()) $client_part = "and ts.client_id = $user->client_id";
-
- $sql = "select ts.id, ts.user_id, u.name as user_name, ts.client_id, c.name as client_name,".
- " ts.name, ts.submitter_comment, ts.submit_status, ts.approval_status, ts.manager_comment from tt_timesheets ts".
- " left join tt_users u on (u.id = ts.user_id)".
- " left join tt_clients c on (c.id = ts.client_id)".
- " where ts.id = $timesheet_id and ts.group_id = $group_id and ts.org_id = $org_id $client_part and ts.status is not null";
+ $sql = "select ts.*, u.name as user_name, c.name as client_name,".
+ " p.name as project_name from tt_timesheets ts".
+ " left join tt_users u on (ts.user_id = u.id)".
+ " left join tt_clients c on (ts.client_id = c.id)".
+ " left join tt_projects p on (ts.project_id = p.id)".
+ " where ts.id = $timesheet_id and ts.user_id = $user_id and ts.group_id = $group_id and ts.org_id = $org_id and ts.status is not null";