From 7905a1bf102ca6b3cef20dad2d249f415c614eeb Mon Sep 17 00:00:00 2001 From: Nik Okuntseff Date: Sat, 6 Apr 2019 17:24:03 +0000 Subject: [PATCH] Started to use different icons depending on whether a project has attached files. --- WEB-INF/lib/ttGroupHelper.class.php | 52 ++++++++++++++++++++++++++++ WEB-INF/templates/footer.tpl | 2 +- WEB-INF/templates/projects.tpl | 8 +++++ images/icon_file.png | Bin 0 -> 1635 bytes images/icon_files.png | Bin 1635 -> 1539 bytes projects.php | 6 ++-- 6 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 images/icon_file.png 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 0000000000000000000000000000000000000000..264ab6eb9d8b07bfd4e92076567e4ace961162e3 GIT binary patch literal 1635 zcmaJ>dr%a096v;XDCNorTB+MIjAh*I?s2bOIq05o>Ya3)K<0zJ-5;>tV~@Q(?jUv4 zq=`|}CKZ$%Q*?$JbtrWhhQLQY(9x_+8zFnZC`^tqDrQY8{q}goAJxw6{=WO&&*%I8 zZcU!^^@+*PC(C5AiS}HJ3!ZZ6PD+5!+4l!&c+3#3MPfc*B1UKd$c!xS0f^mCmjV}{ z*~;?sAWJ5T@8;Y^Vv%DZ#qfS5En$>Ve-N@|vaFnFkY>Cw3GbrP7s|1i=<#aPuUWR1RoNOd3NJ#=oLN?#dv*Tp+}U z1qSw`ByEHYYxn<-Mu03ciVKDXUo20S!GI6=K|l<_pomyRFmh^MxSmw0$xM^YVj>8VP#g6c61QX$8eDJIOU@(%V~J3sWFc2gS~b>88?LsJ zMuM=CdaVg336)Kc6DD(}l^o&P10j(PFhFuDaXHAf;n0QJWQJVre{w0a0BDgH+&u3a z85O(F7Y>Pnq(;p78YLlha5zRFa20^H3A`VPwSeNrcpgfZ1%%2&dlaln>rvo3HL1`8 zvP8jXNVP|;qdg3xLx;)im|BgbthEw^Nd>1#rNXs(g3#;DT5G0WZPjSa1gW#37>tHx zD3KF=V0bu`NgQ1}_%gbjfNMGHf@zLSHZIj}F}kCj`}2=`r@SG5a;xq7p47>0X~FFd zxw9vwNnTUE`{zAK+|zcZlw)eMuNCa;Tk)|rA!Gc+IdKy-xt0yl#$Uc#Dnwqbz0rL6 zdUMP4Jb6ns9jPd3@2{`C-?3z4`7H3nHJG#Y(ZI<|3wr0&H)mZgJd<*09k%;m__4FM z)9Lvut>eIfuDbeGyjwBf=7?Hu&cM;T0Qp)KJV>uS641} zO?mkav*zxlRc+rT!=dkJNJMZ)tOv?DaBi(!A z%7aC^!x?M9?lp;@&+PkBb*E$7#erVsx9g@ps4iZeRvGyrf%IOP?7+7oT$K?2*Q4Hrw5HRu{j?+0ggXj^w3p6*y0xa3@^u`8s|^%jT7vx^jD# d_pTWCjBMAnPpSO_J517V-)?nU4x5VC{|!*ARt^9F literal 0 HcmV?d00001 diff --git a/images/icon_files.png b/images/icon_files.png index 264ab6eb9d8b07bfd4e92076567e4ace961162e3..2ee53ec5c1f2070480146d11e955449d9fb328bb 100644 GIT binary patch delta 811 zcmV+`1JwNE41)}iNdY9WN+$u6+yN$&ZUJYL;{p{uP-t&-Z*ypGa3DidH7+qAO<`kc zZgg*RXd)nZZE#IZI!SJGbYX5|Wl2OmB6w|ZE@^3GIy5;&HAOQlRb0007YNklJ#W-N5PiFzwb%CDOH(|1_Xuw`UVWq~HDfPKT@BrGS`Z}+&>l(>f@Ejnxkz(J6%#%o0Nkp7?qYfS z^%m8_A;^HDC=nS*DI1V>CN_cPy%#vB1`v|qnL1~M{oy_?&duEQN}I5A+`&)n(0RS~^J`oO_OkV&1002ovPDHLkV1m*bRu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F6*2UngG%ef=U1Y 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(); -- 2.20.1
 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}