X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fmisc%2Fprocess%2Ftimeworked.html;h=01752e1b70daab25469fc93fb014d0adbede98ac;hb=e9b2a0d4a388aeb876560aa243d4b9d90ba8c84b;hp=8e1a66336b33dcadba0a4bfc5d6945de5501e4cf;hpb=db18a813b59b8254ff19f77770750a781613d79e;p=freeside.git diff --git a/httemplate/misc/process/timeworked.html b/httemplate/misc/process/timeworked.html index 8e1a66336..01752e1b7 100644 --- a/httemplate/misc/process/timeworked.html +++ b/httemplate/misc/process/timeworked.html @@ -1,23 +1,32 @@ % if ($error) { <% $cgi->redirect(popurl(2). "timeworked.html?". $cgi->query_string) %> % } else { -<% $cgi->redirect(popurl(3). "search/timeworked.html") %> +<% $cgi->redirect(popurl(3). "search/timeworked.html?begin=$begin;end=$end;category=$category") %> % } <%init> die "access denied" unless $FS::CurrentUser::CurrentUser->access_right('Time queue'); -my %multipliers = map { /^custnum(\d+)$/; ($cgi->param("custnum$1") => $cgi->param("multiplier$1")); } - grep /^custnum\d+$/, $cgi->param; +my($begin, $end) = FS::UI::Web::parse_beginning_ending($cgi); + +( my $category = $cgi->param('category') ) =~ /^\w*$/ + or die 'illegal category';#no need for nice error messages for XSS, just avoid my @acct_rt_transaction; foreach my $transaction ( map { /^transactionid(\d+)$/; $1; } grep /^transactionid\d+$/, $cgi->param ) { + my $s = "multiplier${transaction}_"; + my %multipliers = map { /^$s(\d+)$/; $1 => $cgi->param("$s$1"); } + grep /^$s\d+$/, $cgi->param; + my $msum = 0; + foreach(values %multipliers) {$msum += $_}; + my $seconds = $cgi->param("seconds$transaction"); - my %seconds = map { $_ => sprintf("%.0f", $seconds * $multipliers{$_}) } - (keys %multipliers); + my %seconds = + map { $_ => sprintf("%.0f", $seconds * $multipliers{$_} / $msum) } + (keys %multipliers); my $sum = 0; my $count = 0; foreach (values %seconds) { @@ -32,6 +41,8 @@ foreach my $transaction ( $seconds{$_} += $adjustment; last; } + } else { + die "unexpectedly cannot apportion time"; } foreach my $customer ( grep {$seconds{$_}} keys %seconds ) { @@ -39,6 +50,7 @@ foreach my $transaction ( 'custnum' => $customer, 'transaction_id' => $transaction, 'seconds' => $seconds{$customer}, + 'support' => int( $seconds{$customer} * $msum ), }; }