From b53f880dcd61797fd2e6609477add03ca757d813 Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Wed, 17 Apr 2019 14:01:04 +0000 Subject: [PATCH] Added capability to attach files to timesheets. --- WEB-INF/lib/ttTimesheetHelper.class.php | 34 ++++++++-- WEB-INF/resources/ca.lang.php | 1 + WEB-INF/resources/cs.lang.php | 1 + WEB-INF/resources/da.lang.php | 1 + WEB-INF/resources/de.lang.php | 1 + WEB-INF/resources/en.lang.php | 3 +- WEB-INF/resources/es.lang.php | 1 + WEB-INF/resources/et.lang.php | 1 + WEB-INF/resources/fa.lang.php | 1 + WEB-INF/resources/fi.lang.php | 1 + WEB-INF/resources/fr.lang.php | 1 + WEB-INF/resources/gr.lang.php | 1 + WEB-INF/resources/he.lang.php | 1 + WEB-INF/resources/hu.lang.php | 1 + WEB-INF/resources/it.lang.php | 1 + WEB-INF/resources/ja.lang.php | 1 + WEB-INF/resources/ko.lang.php | 1 + WEB-INF/resources/nl.lang.php | 2 + WEB-INF/resources/no.lang.php | 1 + WEB-INF/resources/pl.lang.php | 1 + WEB-INF/resources/pt-br.lang.php | 1 + WEB-INF/resources/pt.lang.php | 1 + WEB-INF/resources/ro.lang.php | 1 + WEB-INF/resources/ru.lang.php | 1 + WEB-INF/resources/sk.lang.php | 1 + WEB-INF/resources/sl.lang.php | 1 + WEB-INF/resources/sr.lang.php | 1 + WEB-INF/resources/sv.lang.php | 1 + WEB-INF/resources/tr.lang.php | 1 + WEB-INF/resources/zh-cn.lang.php | 1 + WEB-INF/resources/zh-tw.lang.php | 1 + WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/timesheets.tpl | 24 ++++++- projects.php | 2 +- timesheet_files.php | 89 +++++++++++++++++++++++++ timesheets.php | 5 +- 36 files changed, 178 insertions(+), 11 deletions(-) create mode 100644 timesheet_files.php diff --git a/WEB-INF/lib/ttTimesheetHelper.class.php b/WEB-INF/lib/ttTimesheetHelper.class.php index a00b4b7a..0afefa80 100644 --- a/WEB-INF/lib/ttTimesheetHelper.class.php +++ b/WEB-INF/lib/ttTimesheetHelper.class.php @@ -27,6 +27,7 @@ // +----------------------------------------------------------------------+ import('ttUserHelper'); +import('ttFileHelper'); // Class ttTimesheetHelper is used to help with project related tasks. class ttTimesheetHelper { @@ -114,10 +115,18 @@ class ttTimesheetHelper { $group_id = $user->getGroup(); $org_id = $user->org_id; + $includeFiles = $user->isPluginEnabled('at'); + if ($includeFiles) { + $filePart = ', if(Sub1.entity_id is null, 0, 1) as has_files'; + $fileJoin = " left join (select distinct entity_id from tt_files". + " where entity_type = 'timesheet' and group_id = $group_id and org_id = $org_id and status = 1) Sub1". + " on (ts.id = Sub1.entity_id)"; + } + $result = array(); $sql = "select ts.id, ts.name, ts.client_id, c.name as client_name,". - " ts.submit_status, ts.approve_status from tt_timesheets ts". - " left join tt_clients c on (c.id = ts.client_id)". + " ts.submit_status, ts.approve_status $filePart from tt_timesheets ts". + " left join tt_clients c on (c.id = ts.client_id) $fileJoin". " where ts.status = 1 and ts.group_id = $group_id and ts.org_id = $org_id and ts.user_id = $user_id". " order by ts.name"; $res = $mdb2->query($sql); @@ -140,10 +149,18 @@ class ttTimesheetHelper { $group_id = $user->getGroup(); $org_id = $user->org_id; + $includeFiles = $user->isPluginEnabled('at'); + if ($includeFiles) { + $filePart = ', if(Sub1.entity_id is null, 0, 1) as has_files'; + $fileJoin = " left join (select distinct entity_id from tt_files". + " where entity_type = 'timesheet' and group_id = $group_id and org_id = $org_id and status = 1) Sub1". + " on (ts.id = Sub1.entity_id)"; + } + $result = array(); $sql = "select ts.id, ts.name, ts.client_id, c.name as client_name,". - " ts.submit_status, ts.approve_status from tt_timesheets ts". - " left join tt_clients c on (c.id = ts.client_id)". + " ts.submit_status, ts.approve_status $filePart from tt_timesheets ts". + " left join tt_clients c on (c.id = ts.client_id) $fileJoin". " where ts.status = 0 and ts.group_id = $group_id and ts.org_id = $org_id and ts.user_id = $user_id". " order by ts.name"; $res = $mdb2->query($sql); @@ -184,6 +201,15 @@ class ttTimesheetHelper { global $user; $mdb2 = getConnection(); + // Delete associated files. + if ($user->isPluginEnabled('at')) { + import('ttFileHelper'); + global $err; + $fileHelper = new ttFileHelper($err); + if (!$fileHelper->deleteEntityFiles($timesheet_id, 'timesheet')) + return false; + } + $user_id = $user->getUser(); $group_id = $user->getGroup(); $org_id = $user->org_id; diff --git a/WEB-INF/resources/ca.lang.php b/WEB-INF/resources/ca.lang.php index c858ed08..25b094a2 100644 --- a/WEB-INF/resources/ca.lang.php +++ b/WEB-INF/resources/ca.lang.php @@ -315,6 +315,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Factura', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/cs.lang.php b/WEB-INF/resources/cs.lang.php index b0057d58..eb2465b5 100644 --- a/WEB-INF/resources/cs.lang.php +++ b/WEB-INF/resources/cs.lang.php @@ -325,6 +325,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Faktura', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/da.lang.php b/WEB-INF/resources/da.lang.php index d7049a91..98ef4d0a 100644 --- a/WEB-INF/resources/da.lang.php +++ b/WEB-INF/resources/da.lang.php @@ -298,6 +298,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Faktura', 'title.send_invoice' => 'Sender Faktura', 'title.charts' => 'Diagrammer', diff --git a/WEB-INF/resources/de.lang.php b/WEB-INF/resources/de.lang.php index a8ac7fab..a6269e64 100644 --- a/WEB-INF/resources/de.lang.php +++ b/WEB-INF/resources/de.lang.php @@ -282,6 +282,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Rechnung', 'title.send_invoice' => 'Rechnung senden', 'title.charts' => 'Diagramme', diff --git a/WEB-INF/resources/en.lang.php b/WEB-INF/resources/en.lang.php index ff5405f2..08aea1a3 100644 --- a/WEB-INF/resources/en.lang.php +++ b/WEB-INF/resources/en.lang.php @@ -271,7 +271,8 @@ $i18n_key_words = array( 'title.report' => 'Report', 'title.send_report' => 'Sending Report', 'title.timesheets' => 'Timesheets', -'title.timesheet' => 'Timesheet', +'title.timesheet' => 'Timesheet', +'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Invoice', 'title.send_invoice' => 'Sending Invoice', 'title.charts' => 'Charts', diff --git a/WEB-INF/resources/es.lang.php b/WEB-INF/resources/es.lang.php index 75860309..46ed38b2 100644 --- a/WEB-INF/resources/es.lang.php +++ b/WEB-INF/resources/es.lang.php @@ -314,6 +314,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Factura', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/et.lang.php b/WEB-INF/resources/et.lang.php index 1a408ceb..1da5dcd1 100644 --- a/WEB-INF/resources/et.lang.php +++ b/WEB-INF/resources/et.lang.php @@ -304,6 +304,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Arve', 'title.send_invoice' => 'Saada arve', 'title.charts' => 'Diagrammid', diff --git a/WEB-INF/resources/fa.lang.php b/WEB-INF/resources/fa.lang.php index a002915f..5c53fd80 100644 --- a/WEB-INF/resources/fa.lang.php +++ b/WEB-INF/resources/fa.lang.php @@ -305,6 +305,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'فاکتور', 'title.send_invoice' => 'ارسال فاکتور', 'title.charts' => 'نمودارها', diff --git a/WEB-INF/resources/fi.lang.php b/WEB-INF/resources/fi.lang.php index 9758fe7f..d6bcfdc6 100644 --- a/WEB-INF/resources/fi.lang.php +++ b/WEB-INF/resources/fi.lang.php @@ -298,6 +298,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Lasku', 'title.send_invoice' => 'Laskun lähetys', 'title.charts' => 'Kaaviot', diff --git a/WEB-INF/resources/fr.lang.php b/WEB-INF/resources/fr.lang.php index 6832973c..836c755c 100644 --- a/WEB-INF/resources/fr.lang.php +++ b/WEB-INF/resources/fr.lang.php @@ -292,6 +292,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Facture', 'title.send_invoice' => 'Envoi de la facture', 'title.charts' => 'Graphiques', diff --git a/WEB-INF/resources/gr.lang.php b/WEB-INF/resources/gr.lang.php index b15c2813..ecd69abb 100644 --- a/WEB-INF/resources/gr.lang.php +++ b/WEB-INF/resources/gr.lang.php @@ -289,6 +289,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Τιμολόγιο', 'title.send_invoice' => 'Αποστολή τιμολόγιου', 'title.charts' => 'Γραφήματα', diff --git a/WEB-INF/resources/he.lang.php b/WEB-INF/resources/he.lang.php index 7fe7b708..4acb1d9b 100644 --- a/WEB-INF/resources/he.lang.php +++ b/WEB-INF/resources/he.lang.php @@ -315,6 +315,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'חשבונית', 'title.send_invoice' => 'שליחת חשבונית', 'title.charts' => 'תרשימים', diff --git a/WEB-INF/resources/hu.lang.php b/WEB-INF/resources/hu.lang.php index f4ae2047..14598f1e 100644 --- a/WEB-INF/resources/hu.lang.php +++ b/WEB-INF/resources/hu.lang.php @@ -315,6 +315,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Számla', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/it.lang.php b/WEB-INF/resources/it.lang.php index 58c30500..d69206bf 100644 --- a/WEB-INF/resources/it.lang.php +++ b/WEB-INF/resources/it.lang.php @@ -297,6 +297,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Fattura', 'title.send_invoice' => 'Invia fattura', 'title.charts' => 'Grafici', diff --git a/WEB-INF/resources/ja.lang.php b/WEB-INF/resources/ja.lang.php index 9055afec..231d2cdd 100644 --- a/WEB-INF/resources/ja.lang.php +++ b/WEB-INF/resources/ja.lang.php @@ -321,6 +321,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => '送り状', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/ko.lang.php b/WEB-INF/resources/ko.lang.php index 31e674e3..5ae00214 100644 --- a/WEB-INF/resources/ko.lang.php +++ b/WEB-INF/resources/ko.lang.php @@ -321,6 +321,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => '송장', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/nl.lang.php b/WEB-INF/resources/nl.lang.php index ac231236..c2806f40 100644 --- a/WEB-INF/resources/nl.lang.php +++ b/WEB-INF/resources/nl.lang.php @@ -274,6 +274,8 @@ $i18n_key_words = array( 'title.send_report' => 'Rapport aan het versturen', 'title.timesheets' => 'Tijdenoverzichten', 'title.timesheet' => 'Tijdenoverzicht', +// TODO: Translate the following. +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Factuur', 'title.send_invoice' => 'Factuur verzenden', 'title.charts' => 'Grafieken', diff --git a/WEB-INF/resources/no.lang.php b/WEB-INF/resources/no.lang.php index e657ea75..a9f7a3ed 100644 --- a/WEB-INF/resources/no.lang.php +++ b/WEB-INF/resources/no.lang.php @@ -318,6 +318,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Faktura', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/pl.lang.php b/WEB-INF/resources/pl.lang.php index e1573f73..e1a654e8 100644 --- a/WEB-INF/resources/pl.lang.php +++ b/WEB-INF/resources/pl.lang.php @@ -299,6 +299,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Faktura', 'title.send_invoice' => 'Wysyłanie faktury', 'title.charts' => 'Statystyki', diff --git a/WEB-INF/resources/pt-br.lang.php b/WEB-INF/resources/pt-br.lang.php index 30e3c523..6f754888 100644 --- a/WEB-INF/resources/pt-br.lang.php +++ b/WEB-INF/resources/pt-br.lang.php @@ -296,6 +296,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Fatura', 'title.send_invoice' => 'Enviando fatura', 'title.charts' => 'Gráficos', diff --git a/WEB-INF/resources/pt.lang.php b/WEB-INF/resources/pt.lang.php index 0fbca55e..f5255875 100644 --- a/WEB-INF/resources/pt.lang.php +++ b/WEB-INF/resources/pt.lang.php @@ -304,6 +304,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', // 'title.invoice' => 'Invoice', // 'title.send_invoice' => 'Sending Invoice', // 'title.charts' => 'Charts', diff --git a/WEB-INF/resources/ro.lang.php b/WEB-INF/resources/ro.lang.php index dc77d1d1..01d017b8 100644 --- a/WEB-INF/resources/ro.lang.php +++ b/WEB-INF/resources/ro.lang.php @@ -321,6 +321,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Factura', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/ru.lang.php b/WEB-INF/resources/ru.lang.php index ee928dee..c418e40a 100644 --- a/WEB-INF/resources/ru.lang.php +++ b/WEB-INF/resources/ru.lang.php @@ -271,6 +271,7 @@ $i18n_key_words = array( 'title.send_report' => 'Отсылка отчёта', 'title.timesheets' => 'Табели учёта', 'title.timesheet' => 'Табель учёта', +'title.timesheet_files' => 'Файлы табеля учёта', 'title.invoice' => 'Счёт', 'title.send_invoice' => 'Отсылка счёта', 'title.charts' => 'Диаграммы', diff --git a/WEB-INF/resources/sk.lang.php b/WEB-INF/resources/sk.lang.php index 8ef40592..3caead32 100644 --- a/WEB-INF/resources/sk.lang.php +++ b/WEB-INF/resources/sk.lang.php @@ -304,6 +304,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Faktúra', 'title.send_invoice' => 'Odosielanie faktúry', 'title.charts' => 'Grafy', diff --git a/WEB-INF/resources/sl.lang.php b/WEB-INF/resources/sl.lang.php index bf56127d..15cf6945 100644 --- a/WEB-INF/resources/sl.lang.php +++ b/WEB-INF/resources/sl.lang.php @@ -299,6 +299,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', // 'title.invoice' => 'Invoice', // 'title.send_invoice' => 'Sending Invoice', // 'title.charts' => 'Charts', diff --git a/WEB-INF/resources/sr.lang.php b/WEB-INF/resources/sr.lang.php index 7981682e..293756c8 100644 --- a/WEB-INF/resources/sr.lang.php +++ b/WEB-INF/resources/sr.lang.php @@ -297,6 +297,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Račun', 'title.send_invoice' => 'Slanje računa', 'title.charts' => 'Grafikoni', diff --git a/WEB-INF/resources/sv.lang.php b/WEB-INF/resources/sv.lang.php index c1ca4de3..53e3cbf1 100644 --- a/WEB-INF/resources/sv.lang.php +++ b/WEB-INF/resources/sv.lang.php @@ -297,6 +297,7 @@ $i18n_key_words = array( // TODO: Translate the following. // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Faktura', 'title.send_invoice' => 'Skicka faktura', 'title.charts' => 'Diagram', diff --git a/WEB-INF/resources/tr.lang.php b/WEB-INF/resources/tr.lang.php index a3b2fc9b..f909c77a 100644 --- a/WEB-INF/resources/tr.lang.php +++ b/WEB-INF/resources/tr.lang.php @@ -330,6 +330,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => 'Fatura', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/zh-cn.lang.php b/WEB-INF/resources/zh-cn.lang.php index bbeab419..40f03773 100644 --- a/WEB-INF/resources/zh-cn.lang.php +++ b/WEB-INF/resources/zh-cn.lang.php @@ -309,6 +309,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => '发票', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/resources/zh-tw.lang.php b/WEB-INF/resources/zh-tw.lang.php index 9f8bbd4a..a507336c 100644 --- a/WEB-INF/resources/zh-tw.lang.php +++ b/WEB-INF/resources/zh-tw.lang.php @@ -316,6 +316,7 @@ $i18n_key_words = array( // 'title.send_report' => 'Sending Report', // 'title.timesheets' => 'Timesheets', // 'title.timesheet' => 'Timesheet', +// 'title.timesheet_files' => 'Timesheet Files', 'title.invoice' => '發票', // TODO: translate the following. // 'title.send_invoice' => 'Sending Invoice', diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 4338c51c..a1159b3c 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- +{if $show_files} + +{/if} @@ -34,6 +37,13 @@ {else} + {/if} + {if $show_files} + {if $timesheet.has_files} + + {else} + + {/if} {/if} @@ -56,13 +66,15 @@ {/if} - + {if $show_files} + + {/if} {foreach $inactive_timesheets as $timesheet} - + {if $show_client} {/if} @@ -72,7 +84,13 @@ {else} {/if} - + {if $show_files} + {if $timesheet.has_files} + + {else} + + {/if} + {/if} diff --git a/projects.php b/projects.php index 49a59a64..6088af49 100644 --- a/projects.php +++ b/projects.php @@ -50,7 +50,7 @@ if($user->can('manage_projects')) { $smarty->assign('active_projects', $active_projects); $smarty->assign('inactive_projects', $inactive_projects); -$smarty->assign('show_files', $user->isPluginEnabled('at')); +$smarty->assign('show_files', $showFiles); $smarty->assign('title', $i18n->get('title.projects')); $smarty->assign('content_page_name', 'projects.tpl'); $smarty->display('index.tpl'); diff --git a/timesheet_files.php b/timesheet_files.php new file mode 100644 index 00000000..d32b2c99 --- /dev/null +++ b/timesheet_files.php @@ -0,0 +1,89 @@ +isPluginEnabled('ts')) { + header('Location: feature_disabled.php'); + exit(); +} +$cl_timesheet_id = (int)$request->getParameter('id'); +$timesheet = ttTimesheetHelper::getTimesheet($cl_timesheet_id); +if (!$timesheet) { + header('Location: access_denied.php'); + exit(); +} +// End of access checks. + +if ($request->isPost()) { + $cl_description = trim($request->getParameter('description')); +} + +$fileHelper = new ttFileHelper($err); +$files = $fileHelper::getEntityFiles($cl_timesheet_id, 'timesheet'); + +$form = new Form('fileUploadForm'); +$form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_timesheet_id)); +$form->addInput(array('type'=>'upload','name'=>'newfile','value'=>$i18n->get('button.submit'))); +$form->addInput(array('type'=>'textarea','name'=>'description','style'=>'width: 250px; height: 40px;','value'=>$cl_description)); +$form->addInput(array('type'=>'submit','name'=>'btn_submit','value'=>$i18n->get('button.add'))); + +if ($request->isPost()) { + // We are adding a new file. + + // Validate user input. + if (!$_FILES['newfile']['name']) $err->add($i18n->get('error.upload')); + if (!ttValidString($cl_description, true)) $err->add($i18n->get('error.field'), $i18n->get('label.description')); + // Finished validating user input. + + if ($err->no()) { + $fields = array('entity_type'=>'timesheet', + 'entity_id' => $cl_timesheet_id, + 'file_name' => $_FILES['newfile']['name'], + 'description'=>$cl_description); + if ($fileHelper->putFile($fields)) { + header('Location: timesheet_files.php?id='.$cl_timesheet_id); + exit(); + } + } +} // isPost + +$smarty->assign('can_edit', true); // Relying on access checks above. +$smarty->assign('forms', array($form->getName()=>$form->toArray())); +$smarty->assign('files', $files); +$smarty->assign('title', $i18n->get('title.timesheet_files').': '.$timesheet['name']); +$smarty->assign('content_page_name', 'entity_files.tpl'); +$smarty->display('index.tpl'); diff --git a/timesheets.php b/timesheets.php index b3b47772..b7ce44b8 100644 --- a/timesheets.php +++ b/timesheets.php @@ -57,7 +57,7 @@ if ($request->isPost()) { } // End of access checks. -// Determine user for which we display this page. +// Determine user for whom we display this page. if ($request->isPost() && $userChanged) { $user_id = $request->getParameter('user'); $user->setOnBehalfUser($user_id); @@ -67,6 +67,8 @@ if ($request->isPost() && $userChanged) { $group_id = $user->getGroup(); +$showFiles = $user->isPluginEnabled('at'); + // Elements of timesheetsForm. $form = new Form('timesheetsForm'); @@ -98,6 +100,7 @@ $showClient = $user->isPluginEnabled('cl'); $smarty->assign('active_timesheets', $active_timesheets); $smarty->assign('inactive_timesheets', $inactive_timesheets); $smarty->assign('show_client', $showClient); +$smarty->assign('show_files', $showFiles); $smarty->assign('forms', array($form->getName()=>$form->toArray())); $smarty->assign('title', $i18n->get('title.timesheets')); $smarty->assign('content_page_name', 'timesheets.tpl'); -- 2.20.1
 Anuko Time Tracker 1.18.65.4951 | Copyright © Anuko | +  Anuko Time Tracker 1.18.65.4952 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/timesheets.tpl b/WEB-INF/templates/timesheets.tpl index fd26588d..a5e893e5 100644 --- a/WEB-INF/templates/timesheets.tpl +++ b/WEB-INF/templates/timesheets.tpl @@ -20,6 +20,9 @@ {/if} {$i18n.label.submitted} {$i18n.label.approved}
{if $timesheet.approve_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}{$i18n.label.files}{$i18n.label.files}{$i18n.label.edit} {$i18n.label.delete}{$i18n.label.submitted} {$i18n.label.approved}{$i18n.label.view}
{$timesheet.name|escape}{$timesheet.name|escape}{$timesheet.client_name|escape}{if $timesheet.approve_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}{$i18n.label.view}{$i18n.label.files}{$i18n.label.files}{$i18n.label.edit} {$i18n.label.delete}