2 <% $cgi->redirect(popurl(2). "timeworked.html?". $cgi->query_string) %>
4 <% $cgi->redirect(popurl(3). "search/timeworked.html") %>
9 unless $FS::CurrentUser::CurrentUser->access_right('Time queue');
11 my @acct_rt_transaction;
12 foreach my $transaction (
13 map { /^transactionid(\d+)$/; $1; } grep /^transactionid\d+$/, $cgi->param
15 my $s = "multiplier${transaction}_";
16 my %multipliers = map { /^$s(\d+)$/; $1 => $cgi->param("$s$1"); }
17 grep /^$s\d+$/, $cgi->param;
19 foreach(values %multipliers) {$msum += $_};
21 my $seconds = $cgi->param("seconds$transaction");
23 map { $_ => sprintf("%.0f", $seconds * $multipliers{$_} / $msum) }
27 foreach (values %seconds) {
32 #fudge in some time if we're close
33 if (abs($seconds-$sum) <= $count) {
34 my $adjustment = $seconds-$sum;
35 foreach (keys %seconds) { # explicitly choose one?
36 $seconds{$_} += $adjustment;
40 die "unexpectedly cannot apportion time";
43 foreach my $customer ( grep {$seconds{$_}} keys %seconds ) {
44 push @acct_rt_transaction, new FS::acct_rt_transaction {
45 'custnum' => $customer,
46 'transaction_id' => $transaction,
47 'seconds' => $seconds{$customer},
48 'support' => $seconds{$customer} * $msum,
54 my $error = FS::acct_rt_transaction->batch_insert(@acct_rt_transaction);
55 $cgi->param('error', $error) if $error;