Work in progress on project attachment list view.
authorNik Okuntseff <support@anuko.com>
Wed, 27 Mar 2019 20:18:33 +0000 (20:18 +0000)
committerNik Okuntseff <support@anuko.com>
Wed, 27 Mar 2019 20:18:33 +0000 (20:18 +0000)
WEB-INF/lib/ttFileHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/project_files.tpl
project_files.php

index 7c8324b..f74e77a 100644 (file)
@@ -125,7 +125,7 @@ class ttFileHelper {
     $group_id = $user->getGroup();
     $org_id = $user->org_id;
 
-    $fields = array('site_id' => urlencode($this->site_id),
+    $curl_fields = array('site_id' => urlencode($this->site_id),
       'site_key' => urlencode($this->site_key),
       'org_id' => urlencode($org_id),
       'org_key' => urlencode($this->getOrgKey()),
@@ -139,7 +139,7 @@ class ttFileHelper {
     );
 
     // url-ify the data for the POST.
-    foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
+    foreach($curl_fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; }
     $fields_string = rtrim($fields_string, '&');
 
     // Open connection.
@@ -216,4 +216,25 @@ class ttFileHelper {
     $val = $res->fetchRow();
     return $val['group_key'];
   }
+
+  // getProjectFiles obtains a list of files for a project.
+  function getProjectFiles($project_id) {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $result = array();
+    $sql = "select id, remote_id, file_name as name, description from tt_files".
+      " where entity_type = 'project' and entity_id = $project_id".
+      " and group_id = $group_id and org_id = $org_id and status = 1 order by id";
+    $res = $mdb2->query($sql);
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
 }
index f73aa05..d5c62e9 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.61.4888 | 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.61.4889 | 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 d092e3c..a542c6b 100644 (file)
@@ -3,7 +3,7 @@
     <td valign="top">
       <table cellspacing="1" cellpadding="3" border="0" width="100%">
         <tr>
-          <td width="35%" class="tableHeader">{$i18n.label.image}</td>
+          <td width="35%" class="tableHeader">{$i18n.label.thing_name}</td>
           <td width="35%" class="tableHeader">{$i18n.label.description}</td>
 {if $can_manage}
           <td class="tableHeader">{$i18n.label.edit}</td>
index cc91746..6abd0af 100644 (file)
@@ -52,8 +52,8 @@ if ($request->isPost()) {
   $cl_description = trim($request->getParameter('description'));
 }
 
-$files = null;
-// $files = ttAttachmentHelper::getProjectFiles();
+$fileHelper = new ttFileHelper($err);
+$files = $fileHelper::getProjectFiles($cl_project_id);
 
 $form = new Form('fileUploadForm');
 $form->addInput(array('type'=>'hidden','name'=>'id','value'=>$cl_project_id));
@@ -71,14 +71,15 @@ if ($request->isPost()) {
   // Finished validating user input.
 
   if ($err->no()) {
-    $fileHelper = new ttFileHelper($err);
     $fields = array('entity_type'=>'project',
       'entity_id' => $cl_project_id,
       'file_name' => $_FILES['newfile']['name'],
       'description'=>$cl_description);
-    if (!$fileHelper->putFile($fields)) {
+    if ($fileHelper->putFile($fields)) {
+      header('Location: project_files.php?id='.$cl_project_id);
+      exit();
+    } else
       $err->add($i18n->get('error.file_storage'));
-    }
   }
 } // isPost