]> wagnertech.de Git - timetracker.git/commitdiff
Added capability to attach files to timesheets.
authorNik Okuntseff <support@anuko.com>
Wed, 17 Apr 2019 14:01:04 +0000 (14:01 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 17 Apr 2019 14:01:04 +0000 (14:01 +0000)
36 files changed:
WEB-INF/lib/ttTimesheetHelper.class.php
WEB-INF/resources/ca.lang.php
WEB-INF/resources/cs.lang.php
WEB-INF/resources/da.lang.php
WEB-INF/resources/de.lang.php
WEB-INF/resources/en.lang.php
WEB-INF/resources/es.lang.php
WEB-INF/resources/et.lang.php
WEB-INF/resources/fa.lang.php
WEB-INF/resources/fi.lang.php
WEB-INF/resources/fr.lang.php
WEB-INF/resources/gr.lang.php
WEB-INF/resources/he.lang.php
WEB-INF/resources/hu.lang.php
WEB-INF/resources/it.lang.php
WEB-INF/resources/ja.lang.php
WEB-INF/resources/ko.lang.php
WEB-INF/resources/nl.lang.php
WEB-INF/resources/no.lang.php
WEB-INF/resources/pl.lang.php
WEB-INF/resources/pt-br.lang.php
WEB-INF/resources/pt.lang.php
WEB-INF/resources/ro.lang.php
WEB-INF/resources/ru.lang.php
WEB-INF/resources/sk.lang.php
WEB-INF/resources/sl.lang.php
WEB-INF/resources/sr.lang.php
WEB-INF/resources/sv.lang.php
WEB-INF/resources/tr.lang.php
WEB-INF/resources/zh-cn.lang.php
WEB-INF/resources/zh-tw.lang.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/timesheets.tpl
projects.php
timesheet_files.php [new file with mode: 0644]
timesheets.php

index a00b4b7a86dbffdf99ddeef5834918cba13a6dfc..0afefa8048fe2205fe406d539032aa043ad8f2ef 100644 (file)
@@ -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;
index c858ed08790cb4e5641c391d5ed35a82c906eedf..25b094a27e258dce73458963e7f184d07f2b0506 100644 (file)
@@ -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',
index b0057d582d8015633015344c70db48476d533aa0..eb2465b59d90b4ed456964698507988eae767db5 100644 (file)
@@ -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',
index d7049a918d9316b60277f9b89e3e893fa03a6e11..98ef4d0a3694f78f2f6d0f7d03aa474c32532bd3 100644 (file)
@@ -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',
index a8ac7fab525525aab60d8f045c15e1cdeaf3a764..a6269e649254db3f8011bb6f08b4e1758a88d901 100644 (file)
@@ -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',
index ff5405f271222562b1ede3eb5869d97a579852da..08aea1a3545c874b9124246e79651fd5ccb9c0d7 100644 (file)
@@ -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',
index 75860309865a4580179bb2a158a87ca48257f95e..46ed38b21e315c3a15a88d8227e466ec12d661d0 100644 (file)
@@ -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',
index 1a408cebde90828287c43a5e4af4107bc826c47a..1da5dcd10e0d68d59932b63b0de7093ecf6dcc3a 100644 (file)
@@ -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',
index a002915fa988a328f6b48c37428251dec2b8b569..5c53fd80e9e97710f941234e2e5bbf2885b0e3a8 100644 (file)
@@ -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' => 'نمودارها',
index 9758fe7f198cf0e593c05df29a1d6b52fac9f2ca..d6bcfdc6a21ccbfe8edb76bccc20e2fa89548bb8 100644 (file)
@@ -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',
index 6832973c209cc250d1ad305e50e3cfec00730eb6..836c755cf49ff8be4f63e61042f0ee4fd8d0b0c8 100644 (file)
@@ -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',
index b15c2813d7541d7c5d8ae53be11008f271378ca6..ecd69abb08c4624ead0640a5a0e188f5c4369ff2 100644 (file)
@@ -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' => 'Γραφήματα',
index 7fe7b7086c145dea70112d9318a5908ebf558284..4acb1d9bdb655a09823a5d9d96d4250da837ffa3 100644 (file)
@@ -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' => 'תרשימים',
index f4ae2047225fc2997e510add798b165e534f5ee1..14598f1ee8e2a5e83acb0dec8dee0c1e365064ed 100644 (file)
@@ -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',
index 58c305005cb7685a56b387db8a00f56d34a132c6..d69206bf7e7e6b40579530fdf8d1fb4e343a2cb4 100644 (file)
@@ -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',
index 9055afeca21599067d8058d06dfeabbb81d4a010..231d2cdddae1ff7edd9d8121841f4d7e01b9f30a 100644 (file)
@@ -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',
index 31e674e31033818d028f87a079b361f12f08c397..5ae002145f7913f9be185d20108e7adcfc8b2f93 100644 (file)
@@ -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',
index ac2312369d08793962f4caf9017a66e0ee19ae7e..c2806f40f7fecd5b5f81c9c5962df14ea7426bbf 100644 (file)
@@ -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',
index e657ea75568afc1838a6267b596e497000f4a6db..a9f7a3ed59e47be27074736d406b6ce9b24c9210 100644 (file)
@@ -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',
index e1573f7319e739a0cb1b3b4fd5293b7d7f58a958..e1a654e837bc6071a823efa24e631c951f038501 100644 (file)
@@ -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',
index 30e3c5230e4646cc2abdadf9b07c137ee5963a0b..6f754888a33a1791e2a76d6e327104fcc9ad06f7 100644 (file)
@@ -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',
index 0fbca55ede2d73de8afc587853909ed5a837edd4..f52558753999d7ee5a0fe3bf5ec4a4d05b48040b 100644 (file)
@@ -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',
index dc77d1d179a159c7371393746a80aefd00c87b41..01d017b838da46744d4f37ffb3473b594cca72c4 100644 (file)
@@ -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',
index ee928deedd9c685d5480e874e86aeb03e6945dd5..c418e40aecb050691157c8a8755b7f8185572da9 100644 (file)
@@ -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' => 'Диаграммы',
index 8ef40592832cd405f704f4a53f29b5c970c3af55..3caead3226dbbd54d222d0fe9e112dfc3dd6bab2 100644 (file)
@@ -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',
index bf56127d03b4eb8aa79b2fae6eb64dac3ea2a28e..15cf694567e56557a0c04d2e58da6d2d3d7ccbc0 100644 (file)
@@ -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',
index 7981682eee335ee67e202d3b3d6cb6c9a875f5d7..293756c8685e43e3d38e3589c59038b11f588de5 100644 (file)
@@ -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',
index c1ca4de3ff5b3738758db824360693933229a051..53e3cbf19f038e033ad11f5f92997fb9775dd194 100644 (file)
@@ -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',
index a3b2fc9b64046a9fb9070130077ea3e79694b710..f909c77acdb413b168798f88f2a4c7b458c57538 100644 (file)
@@ -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',
index bbeab419259ce3610c618055cf1e245ea1b11b9e..40f03773c4637cf1016158e61e24e1aac8b88c62 100644 (file)
@@ -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',
index 9f8bbd4a49f9662a7e4798939fd25b445bf55d68..a507336c252d93045f098f90195e777a3625a9c7 100644 (file)
@@ -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',
index 4338c51c10d2087bfaeb01b589057884bdacca38..a1159b3c96ff6f13a356ed1ed28c7b9d34b9290e 100644 (file)
@@ -12,7 +12,7 @@
       <br>
       <table cellspacing="0" cellpadding="4" width="100%" border="0">
         <tr>
-          <td align="center">&nbsp;Anuko Time Tracker 1.18.65.4951 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
+          <td align="center">&nbsp;Anuko Time Tracker 1.18.65.4952 | Copyright &copy; <a href="https://www.anuko.com/lp/tt_3.htm" target="_blank">Anuko</a> |
             <a href="https://www.anuko.com/lp/tt_4.htm" target="_blank">{$i18n.footer.credits}</a> |
             <a href="https://www.anuko.com/lp/tt_5.htm" target="_blank">{$i18n.footer.license}</a> |
             <a href="https://www.anuko.com/lp/tt_7.htm" target="_blank">{$i18n.footer.improve}</a>
index fd26588d78b8650ab568f323724242f4b21ea1c6..a5e893e59a4994c95323c833827cdd999aa33b25 100644 (file)
@@ -20,6 +20,9 @@
 {/if}
           <td class="tableHeader">{$i18n.label.submitted}</td>
           <td class="tableHeader">{$i18n.label.approved}</td>
+{if $show_files}
+          <td></td>
+{/if}
           <td></td>
           <td></td>
         </tr>
           <td></td>
   {else}
           <td>{if $timesheet.approve_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td>
+  {/if}
+  {if $show_files}
+        {if $timesheet.has_files}
+          <td><a href="timesheet_files.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_files.png"></a></td>
+        {else}
+          <td><a href="timesheet_files.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_file.png"></a></td>
+        {/if}
   {/if}
           <td><a href="timesheet_edit.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.edit}" src="images/icon_edit.png"></a></td>
           <td><a href="timesheet_delete.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.delete}" src="images/icon_delete.png"></a></td>
   {/if}
           <td class="tableHeader">{$i18n.label.submitted}</td>
           <td class="tableHeader">{$i18n.label.approved}</td>
-          <td class="tableHeader">{$i18n.label.view}</td>
+  {if $show_files}
+          <td></td>
+  {/if}
           <td></td>
           <td></td>
         </tr>
   {foreach $inactive_timesheets as $timesheet}
         <tr valign="top" bgcolor="{cycle values="#f5f5f5,#ffffff"}">
-          <td>{$timesheet.name|escape}</td>
+            <td><a href="timesheet_view.php?id={$timesheet.id}">{$timesheet.name|escape}</a></td>
     {if $show_client}
           <td>{$timesheet.client_name|escape}</td>
     {/if}
     {else}
           <td>{if $timesheet.approve_status}{$i18n.label.yes}{else}{$i18n.label.no}{/if}</td>
     {/if}
-          <td><a href="timesheet_view.php?id={$timesheet.id}">{$i18n.label.view}</a></td>
+    {if $show_files}
+      {if $timesheet.has_files}
+          <td><a href="timesheet_files.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_files.png"></a></td>
+      {else}
+          <td><a href="timesheet_files.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_file.png"></a></td>
+      {/if}
+    {/if}
           <td><a href="timesheet_edit.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.edit}" src="images/icon_edit.png"></a></td>
           <td><a href="timesheet_delete.php?id={$timesheet.id}"><img class="table_icon" alt="{$i18n.label.delete}" src="images/icon_delete.png"></a></td>
         </tr>
index 49a59a64df49883e1fd871d6d2a67dba3cdacb1b..6088af495ee3d1aaa58e575d62febc2d5bd11cc2 100644 (file)
@@ -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 (file)
index 0000000..d32b2c9
--- /dev/null
@@ -0,0 +1,89 @@
+<?php
+// +----------------------------------------------------------------------+
+// | Anuko Time Tracker
+// +----------------------------------------------------------------------+
+// | Copyright (c) Anuko International Ltd. (https://www.anuko.com)
+// +----------------------------------------------------------------------+
+// | LIBERAL FREEWARE LICENSE: This source code document may be used
+// | by anyone for any purpose, and freely redistributed alone or in
+// | combination with other software, provided that the license is obeyed.
+// |
+// | There are only two ways to violate the license:
+// |
+// | 1. To redistribute this code in source form, with the copyright
+// |    notice or license removed or altered. (Distributing in compiled
+// |    forms without embedded copyright notices is permitted).
+// |
+// | 2. To redistribute modified versions of this code in *any* form
+// |    that bears insufficient indications that the modifications are
+// |    not the work of the original author(s).
+// |
+// | This license applies to this document only, not any other software
+// | that it may be combined with.
+// |
+// +----------------------------------------------------------------------+
+// | Contributors:
+// | https://www.anuko.com/time_tracker/credits.htm
+// +----------------------------------------------------------------------+
+
+require_once('initialize.php');
+import('form.Form');
+import('ttTimesheetHelper');
+import('ttFileHelper');
+
+// Access checks.
+if (!(ttAccessAllowed('track_own_time') || ttAccessAllowed('track_time'))) {
+  header('Location: access_denied.php');
+  exit();
+}
+if (!$user->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');
index b3b47772f9ef152db107e723d8ec0d1035aac896..b7ce44b8489d1bb0893623d0f1a07d2b8bbf8aa8 100644 (file)
@@ -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');