[% META title = 'Resources » User Workload' %]
<!-- BEGIN [% template.name %] -->
[% # PROCESS dumper.tt dump = detail %]
[% # PROCESS dumper.tt dump = c.stash.vars %]
[%
# USE Math; # int() function not suitable for rounding
actions = data.keys;
cols = ['BMAT' 'BMA' 'PB' 'Tissue' 'Other'];
%]
[% # use instead of Math.int():
MACRO round(n)
GET n + 0.5
FILTER format("%d");
%]
<h3>
Workload by user for [% c.stash.duration | html %]
<!--or enter new: <input type="text" name="duration" size="2" />
[% site.html.go_btn %]-->
</h3>
[% PROCESS site/date_constraints.tt
func_name = 'get_page'
target_url = app_url _ '/audit/user_workload/'
restricted = { # too slow to allow these:
no_constraint = 1,
this_year = 1,
previous_year = 1,
all_since = 1,
}
%]
<div class="indent">
[% FOREACH action IN actions.sort.reverse; # happy co-incidence !!
users = data.item(action); # PROCESS dumper.tt dump = users;
total = 0; # total units in each action
FOREACH user IN users.keys;
count = sum(data.item(action).item(user).values);
total = total + count;
END;
%]
<h3 class="header">[% action | ucfirst %] [[% total %]]</h3>
<table class="indent tbl_header_darken">
<tr>
<th>UserID</th>
[% FOREACH col IN cols %]
<th>[% col %]</th>
[% END %]
<th>Total</th>
<td class="borderless"></td>
</tr>
[% FOREACH user IN users.keys.sort;
results = data.item(action).item(user);
details = detail.item(action).item(user);
class = c.authen.username == user
? 'bkgd_light_yellow' : 'normal';
%]
<tr class="[% class %]">
<td class="label">[% user | upper %]</td>
[% FOREACH col IN cols %]
<td align="center">
[% result = results.item(col); IF result;
str = [];
FOREACH pair IN details.item(col).pairs;
str.push( pair.key _ ' = ' _ pair.value );
END; %]
<span class="acronym" title="[% str.join(', ') %]">
[% result %]
</span>
[% ELSE; site.html.grey_null; END; %]
</td>
[% END %]
<td class="bold" align="center">
[% n = sum(results.values); # PROCESS dumper.tt dump = results.values %]
[% n %] ([% round(100 * n / total) %]%)
</td>
[% IF loop.first; # users.size; # only once per action
# pass query params to chart:
vars = [];
FOREACH v IN c.stash.vars;
vars.push(v.key _ '=' _ v.value);
END;
chart_url = app_url
_ '/chart/process/user_workload/user_workload_stats';
%]
<td rowspan="[% users.size %]" class="borderless" valign="top">
<img src="[% chart_url %]?action=[% action; IF vars.size;
';'; vars.join(';'); END %]" />
</td>
[% END %]
</tr>
[% END %]
</table>
[% END %]
</div>
<p>[% site.html.back_button %]</p>
<!-- END [% template.name %] -->