From: Nik Okuntseff Date: Fri, 21 Dec 2018 22:09:59 +0000 (+0000) Subject: Added quota column on the users page. X-Git-Tag: timetracker_1.19-1~387 X-Git-Url: http://wagnertech.de/git?a=commitdiff_plain;h=30634c0b3869d459552df1da06ec264fb1e6b086;p=timetracker.git Added quota column on the users page. --- diff --git a/WEB-INF/lib/common.lib.php b/WEB-INF/lib/common.lib.php index 0e9ff9e4..f483b3d4 100644 --- a/WEB-INF/lib/common.lib.php +++ b/WEB-INF/lib/common.lib.php @@ -391,6 +391,14 @@ function ttStartsWith($string, $startString) return (substr($string, 0, $len) === $startString); } +// ttEndsWith functions checks if a string ends with a given substring. +function ttEndsWith($string, $endString) +{ + $len = strlen($endString); + if ($len == 0) return true; + return (substr($string, -$len) === $endString); +} + // ttDateToUserFormat converts a date from database format to user format. function ttDateToUserFormat($date) { diff --git a/WEB-INF/lib/ttUser.class.php b/WEB-INF/lib/ttUser.class.php index f163e581..73ec7a1e 100644 --- a/WEB-INF/lib/ttUser.class.php +++ b/WEB-INF/lib/ttUser.class.php @@ -395,7 +395,16 @@ class ttUser { $includeSelf = isset($options['include_self']); $select_part = 'select u.id, u.group_id, u.name'; - if (isset($options['include_login'])) $select_part .= ', u.login'; + if (isset($options['include_login'])) { + $select_part .= ', u.login'; + // Piggy-back on include_login to see if we must also include quota_percent. + $include_quota = $this->isPluginEnabled('mq'); + if ($include_quota) { + $decimal_mark = $this->getDecimalMark(); + $replaceDecimalMark = ('.' != $decimal_mark); + $select_part .= ', u.quota_percent'; + } + } if (!isset($options['include_clients'])) $select_part .= ', r.rights'; if (isset($options['include_role'])) $select_part .= ', r.name as role_name, r.rank'; @@ -430,6 +439,16 @@ class ttUser { if ($isClient) continue; // Skip adding clients. } + if ($include_quota) { + $quota = $val['quota_percent']; + if (null == $quota) + $quota = '100'; // Null means 100%. Perhaps enforce not NULLs in db and eliminate this check. + elseif (ttEndsWith($quota, '.00')) + $quota = substr($quota, 0, strlen($quota)-3); // Trim trailing ".00"; + elseif ($replaceDecimalMark) + $quota = str_replace('.', $decimal_mark, $quota); + $val['quota_percent'] = $quota.'%'; + } $user_list[] = $val; } diff --git a/WEB-INF/templates/footer.tpl b/WEB-INF/templates/footer.tpl index aaf04fa0..19832de8 100644 --- a/WEB-INF/templates/footer.tpl +++ b/WEB-INF/templates/footer.tpl @@ -12,7 +12,7 @@
- - - + {if $show_quota} + + {/if} + + {if $active_users} {foreach $active_users as $u} @@ -28,6 +31,9 @@ + {if $show_quota} + + {/if} {if $u.group_id != $user->group_id || $u.rank < $user->rank || ($u.rank == $user->rank && $u.id == $user->id)} {if $u.id != $user->id}{else}{/if} @@ -55,14 +61,20 @@ - - + {if $show_quota} + + {/if} + + {foreach $inactive_users as $u} + {if $show_quota} + + {/if} {if $u.group_id != $user->group_id || $u.rank < $user->rank} diff --git a/users.php b/users.php index fd9e7593..aa7f4440 100644 --- a/users.php +++ b/users.php @@ -63,6 +63,7 @@ if ($uncompleted_indicators) { $smarty->assign('active_users', $active_users); $smarty->assign('inactive_users', $inactive_users); +$smarty->assign('show_quota', $user->isPluginEnabled('mq')); $smarty->assign('title', $i18n->get('title.users')); $smarty->assign('content_page_name', 'users.tpl'); $smarty->display('index.tpl');
 Anuko Time Tracker 1.18.34.4678 | Copyright © Anuko | +  Anuko Time Tracker 1.18.34.4679 | Copyright © Anuko | {$i18n.footer.credits} | {$i18n.footer.license} | {$i18n.footer.improve} diff --git a/WEB-INF/templates/users.tpl b/WEB-INF/templates/users.tpl index 236475c1..d3fadad9 100644 --- a/WEB-INF/templates/users.tpl +++ b/WEB-INF/templates/users.tpl @@ -14,8 +14,11 @@ {$i18n.label.person_name} {$i18n.label.login} {$i18n.form.users.role}{$i18n.label.edit}{$i18n.label.delete}{$i18n.label.quota}{$i18n.label.edit}{$i18n.label.delete}
{$u.login|escape} {$u.role_name|escape}{$u.quota_percent}{$i18n.label.edit}{$i18n.label.delete}{$i18n.label.person_name} {$i18n.label.login} {$i18n.form.users.role}{$i18n.label.edit}{$i18n.label.delete}{$i18n.label.quota}{$i18n.label.edit}{$i18n.label.delete}
{$u.name|escape} {$u.login|escape} {$u.role_name|escape}{$u.quota_percent}{$i18n.label.edit} {$i18n.label.delete}