+# pass multi-dimensional hash arr[client_id][status].
+# status strings: 'finished_untested', 'finished_unpaid', 'queue'
+function totals_summary($arr) {
+ if($arr) {
+ $total_finished_untested = 0;
+ $total_finished_unpaid = 0;
+ $total_queue = 0;
+ $total_working = 0;
+ foreach($arr as $client_id => $t) {
+ $finished_untested = 0;
+ $finished_unpaid = 0;
+ $queue = 0;
+ $working = 0;
+ if(isset($t['finished_untested'])) {
+ $finished_untested = $t['finished_untested'];
+ }
+ if(isset($t['finished_unpaid'])) {
+ $finished_unpaid = $t['finished_unpaid'];
+ }
+ if(isset($t['queue'])) {
+ $queue = $t['queue'];
+ }
+ if(isset($t['needs_approval'])) { # administrator page re-uses this for TASK_WORKING
+ $working = $t['needs_approval'];
+ }
+ tem_set('tested_total', $finished_unpaid);
+ tem_set('done_total', $finished_unpaid + $finished_untested);
+ tem_set('not_tested_total', $finished_untested);
+ tem_set('queued_total', $queue + $working);
+ tem_set('client', db_get_value('people', 'username', 'where id=%i', $client_id));
+ tem_show('unpaid_totals_row');
+ $total_finished_untested += $finished_untested;
+ $total_finished_unpaid += $finished_unpaid;
+ $total_queue += $queue;
+ $total_working += $working;
+ }
+
+ tem_set('tested_total', $total_finished_unpaid);
+ tem_set('done_total', $total_finished_unpaid + $total_finished_untested);
+ tem_set('not_tested_total', $total_finished_untested);
+ tem_set('queued_total', $total_queue + $total_working);
+ tem_set('client', 'all');
+ tem_show('unpaid_totals_row');
+
+ tem_show('unpaid_totals');
+ }
+}
+