From 3b73ad719677dcb639befd1788f8f9d1ee6485cf Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Mon, 8 Apr 2019 14:02:01 +0000 Subject: [PATCH] Fixed union sql for reports with attachments. --- WEB-INF/lib/ttReportHelper.class.php | 8 ++++++++ WEB-INF/templates/footer.tpl | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/WEB-INF/lib/ttReportHelper.class.php b/WEB-INF/lib/ttReportHelper.class.php index 74f2537f..40b6a047 100644 --- a/WEB-INF/lib/ttReportHelper.class.php +++ b/WEB-INF/lib/ttReportHelper.class.php @@ -360,6 +360,9 @@ class ttReportHelper { array_push($fields, 'i.name as invoice'); if ($options['show_timesheet']) array_push($fields, 'null as timesheet_name'); + // Add has_files. + if ($options['show_files']) + array_push($fields, 'if(Sub1.entity_id is null, 0, 1) as has_files'); // Prepare sql query part for left joins. $left_joins = null; @@ -371,6 +374,11 @@ class ttReportHelper { $left_joins .= " left join tt_projects p on (p.id = ei.project_id)"; if (($canViewReports || $isClient) && $options['show_invoice']) $left_joins .= " left join tt_invoices i on (i.id = ei.invoice_id and i.status = 1)"; + if ($options['show_files']) { + $left_joins .= " left join (select distinct entity_id from tt_files". + " where entity_type = 'expense' and group_id = $group_id and org_id = $org_id and status = 1) Sub1". + " on (ei.id = Sub1.entity_id)"; + } $where = ttReportHelper::getExpenseWhere($options); diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 65f8389e..9e50a852 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
-
 Anuko Time Tracker 1.18.64.4927 | Copyright © Anuko | +  Anuko Time Tracker 1.18.64.4928 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} -- 2.20.1