@@ -154,6 +154,9 @@ static function getItems($options) {
154154 global $ user ;
155155 $ mdb2 = getConnection ();
156156
157+ $ group_id = $ user ->getGroup ();
158+ $ org_id = $ user ->org_id ;
159+
157160 // Determine these once as they are used in multiple places in this function.
158161 $ canViewReports = $ user ->can ('view_reports ' ) || $ user ->can ('view_all_reports ' );
159162 $ isClient = $ user ->isClient ();
@@ -251,6 +254,9 @@ static function getItems($options) {
251254 // Add timesheet name if it is selected.
252255 if ($ options ['show_timesheet ' ])
253256 array_push ($ fields , 'ts.name as timesheet_name ' );
257+ // Add has_files.
258+ if ($ options ['show_files ' ])
259+ array_push ($ fields , 'if(Sub1.entity_id is null, 0, 1) as has_files ' );
254260
255261 // Prepare sql query part for left joins.
256262 $ left_joins = null ;
@@ -274,6 +280,11 @@ static function getItems($options) {
274280 }
275281 if ($ includeCost && MODE_TIME != $ trackingMode )
276282 $ left_joins .= " left join tt_user_project_binds upb on (l.user_id = upb.user_id and l.project_id = upb.project_id) " ;
283+ if ($ options ['show_files ' ]) {
284+ $ left_joins .= " left join (select distinct entity_id from tt_files " .
285+ " where entity_type = 'time' and group_id = $ group_id and org_id = $ org_id and status = 1) Sub1 " .
286+ " on (l.id = Sub1.entity_id) " ;
287+ }
277288
278289 // Prepare sql query part for inner joins.
279290 $ inner_joins = null ;
@@ -1143,6 +1154,7 @@ static function getReportOptions($bean) {
11431154 $ options ['show_custom_field_1 ' ] = $ bean ->getAttribute ('chcf_1 ' );
11441155 $ options ['show_work_units ' ] = $ bean ->getAttribute ('chunits ' );
11451156 $ options ['show_timesheet ' ] = $ bean ->getAttribute ('chtimesheet ' );
1157+ $ options ['show_files ' ] = $ bean ->getAttribute ('chfiles ' );
11461158 $ options ['show_totals_only ' ] = $ bean ->getAttribute ('chtotalsonly ' );
11471159 $ options ['group_by1 ' ] = $ bean ->getAttribute ('group_by1 ' );
11481160 $ options ['group_by2 ' ] = $ bean ->getAttribute ('group_by2 ' );
0 commit comments