From: Nik Okuntseff Date: Sat, 6 Apr 2019 17:24:03 +0000 (+0000) Subject: Started to use different icons depending on whether a project has attached files. X-Git-Tag: timetracker_1.19-1~121 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=7905a1bf102ca6b3cef20dad2d249f415c614eeb;p=timetracker.git Started to use different icons depending on whether a project has attached files. --- diff --git a/WEB-INF/lib/ttGroupHelper.class.php b/WEB-INF/lib/ttGroupHelper.class.php index ffa1e048..83f607a1 100644 --- a/WEB-INF/lib/ttGroupHelper.class.php +++ b/WEB-INF/lib/ttGroupHelper.class.php @@ -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; diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index 39cbf6da..da88e071 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- {if $show_files} + {if $project.has_files} + {else} + + {/if} {/if} @@ -59,7 +63,11 @@ {if $show_files} + {if $project.has_files} + {else} + + {/if} {/if} diff --git a/images/icon_file.png b/images/icon_file.png new file mode 100644 index 00000000..264ab6eb Binary files /dev/null and b/images/icon_file.png differ diff --git a/images/icon_files.png b/images/icon_files.png index 264ab6eb..2ee53ec5 100644 Binary files a/images/icon_files.png and b/images/icon_files.png differ diff --git a/projects.php b/projects.php index 236291cd..49a59a64 100644 --- a/projects.php +++ b/projects.php @@ -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();
 Anuko Time Tracker 1.18.64.4914 | Copyright © Anuko | +  Anuko Time Tracker 1.18.64.4915 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/projects.tpl b/WEB-INF/templates/projects.tpl index 0d5eae58..e21a8f22 100644 --- a/WEB-INF/templates/projects.tpl +++ b/WEB-INF/templates/projects.tpl @@ -25,7 +25,11 @@ {$project.name|escape} {$project.description|escape}{$i18n.label.files}{$i18n.label.files}{$i18n.label.edit} {$i18n.label.delete}{$project.name|escape} {$project.description|escape}{$i18n.label.files}{$i18n.label.files}{$i18n.label.edit} {$i18n.label.delete}