Started to use different icons depending on whether a project has attached files.
authorNik Okuntseff <support@anuko.com>
Sat, 6 Apr 2019 17:24:03 +0000 (17:24 +0000)
committerNik Okuntseff <support@anuko.com>
Sat, 6 Apr 2019 17:24:03 +0000 (17:24 +0000)
WEB-INF/lib/ttGroupHelper.class.php
WEB-INF/templates/footer.tpl
WEB-INF/templates/projects.tpl
images/icon_file.png [new file with mode: 0644]
images/icon_files.png
projects.php

index ffa1e04..83f607a 100644 (file)
@@ -344,6 +344,32 @@ class ttGroupHelper {
     return $result;
   }
 
+  // getActiveProjectsWithFiles - returns an array of active projects for a group
+  // with information whether they have attached files (has_files property).
+  // A separate fiunction from getActiveProjects because sql here is more complex.
+  static function getActiveProjectsWithFiles()
+  {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "select p.id, p.name, if(Sub1.entity_id is null, 0, 1) as has_files from tt_projects p".
+      " left join (select distinct entity_id from tt_files".
+      " where entity_type = 'project' and group_id = $group_id and org_id = $org_id and status = 1) Sub1".
+      " on (p.id = Sub1.entity_id)".
+      " where p.group_id = $group_id and p.org_id = $org_id and p.status = 1 order by upper(p.name)";
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
+
   // getInactiveProjects - returns an array of inactive projects for a group.
   static function getInactiveProjects()
   {
@@ -365,6 +391,32 @@ class ttGroupHelper {
     return $result;
   }
 
+  // getInactiveProjectsWithFiles - returns an array of inactive projects for a group
+  // with information whether they have attached files (has_files property).
+  // A separate fiunction from getInactiveProjects because sql here is more complex.
+  static function getInactiveProjectsWithFiles()
+  {
+    global $user;
+    $mdb2 = getConnection();
+
+    $group_id = $user->getGroup();
+    $org_id = $user->org_id;
+
+    $sql = "select p.id, p.name, if(Sub1.entity_id is null, 0, 1) as has_files from tt_projects p".
+      " left join (select distinct entity_id from tt_files".
+      " where entity_type = 'project' and group_id = $group_id and org_id = $org_id and status = 1) Sub1".
+      " on (p.id = Sub1.entity_id)".
+      " where p.group_id = $group_id and p.org_id = $org_id and p.status = 0 order by upper(p.name)";
+    $res = $mdb2->query($sql);
+    $result = array();
+    if (!is_a($res, 'PEAR_Error')) {
+      while ($val = $res->fetchRow()) {
+        $result[] = $val;
+      }
+    }
+    return $result;
+  }
+
   // getPredefinedExpenses - obtains predefined expenses for a group.
   static function getPredefinedExpenses() {
     global $user;
index 39cbf6d..da88e07 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.64.4914 | 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.64.4915 | 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 0d5eae5..e21a8f2 100644 (file)
           <td>{$project.name|escape}</td>
           <td>{$project.description|escape}</td>
       {if $show_files}
+        {if $project.has_files}
           <td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_files.png"></a></td>
+        {else}
+          <td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_file.png"></a></td>
+        {/if}
       {/if}
           <td><a href="project_edit.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.edit}" src="images/icon_edit.png"></a></td>
           <td><a href="project_delete.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.delete}" src="images/icon_delete.png"></a></td>
           <td>{$project.name|escape}</td>
           <td>{$project.description|escape}</td>
       {if $show_files}
+        {if $project.has_files}
           <td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_files.png"></a></td>
+        {else}
+          <td><a href="project_files.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.files}" src="images/icon_file.png"></a></td>
+        {/if}
       {/if}
           <td><a href="project_edit.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.edit}" src="images/icon_edit.png"></a></td>
           <td><a href="project_delete.php?id={$project.id}"><img class="table_icon" alt="{$i18n.label.delete}" src="images/icon_delete.png"></a></td>
diff --git a/images/icon_file.png b/images/icon_file.png
new file mode 100644 (file)
index 0000000..264ab6e
Binary files /dev/null and b/images/icon_file.png differ
index 264ab6e..2ee53ec 100644 (file)
Binary files a/images/icon_files.png and b/images/icon_files.png differ
index 236291c..49a59a6 100644 (file)
@@ -40,9 +40,11 @@ if (MODE_PROJECTS != $user->getTrackingMode() && MODE_PROJECTS_AND_TASKS != $use
 }
 // End of access checks.
 
+$showFiles = $user->isPluginEnabled('at');
+
 if($user->can('manage_projects')) {
-  $active_projects = ttGroupHelper::getActiveProjects();
-  $inactive_projects = ttGroupHelper::getInactiveProjects();
+  $active_projects = $showFiles ? ttGroupHelper::getActiveProjectsWithFiles() : ttGroupHelper::getActiveProjects();
+  $inactive_projects = $showFiles ? ttGroupHelper::getInactiveProjectsWithFiles() : ttGroupHelper::getInactiveProjects();
 } else
   $active_projects = $user->getAssignedProjects();