typo
[freeside.git] / httemplate / misc / timeworked.html
1 <% include('/elements/header.html', $title, '' ) %>
2
3 <% include('/elements/error.html') %>
4
5 <FORM NAME="timeworked_form" ACTION="<% popurl(1) %>process/timeworked.html" METHOD=POST>
6
7 <TABLE CELLSPACING="2" CELLPADDING="2" RULES="groups" FRAME="hsides">
8
9   <THEAD>
10     <TR>
11       <TH>Trans</TH>
12       <TH COLSPAN="2">Ticket</TH>
13       <TH>Time</TH>
14       <TH COLSPAN="2">Customer</TH>
15       <TH>Multiplier</TH>
16     </TR>
17
18     <TR>
19       <TH>#</TH>
20       <TH>#</TH>
21       <TH>Subject</TH>
22       <TH>hours</TH>
23       <TH>#</TH>
24       <TH>Name</TH>
25       <TH></TH>
26     </TR>
27   </THEAD>
28
29   <TBODY>
30
31 %   foreach my $tr_id ( keys %ticketmap ) {
32 %     my (@customers) = @{$customers{$ticketmap{$tr_id}}};
33 %     next unless @customers;
34 %     my $default_multiplier = sprintf("%.2f", 1/@customers);
35 %     my ($custnum, $name) = split(':', pop @customers, 2);
36 %     my $link = $p. 'rt/Ticket/Display.html?id='. $ticketmap{$tr_id}.
37 %                    '#txn-'. $tr_id;
38
39       <TR>
40         <TD><a href="<% $link %>"><% $tr_id %></a></TD>
41         <TD><a href="<% $link %>"><% $ticketmap{$tr_id} %></a></TD>
42         <TD><a href="<% $link %>"><% $ticket{$ticketmap{$tr_id}} |h %></a></TD>
43
44 %       my $seconds = 0;
45 %       if ( $cgi->param("seconds$tr_id") =~ /^(\d+)$/ ) {
46 %         $seconds = $1;
47 %       }
48
49         <TD><% sprintf("%0.2f", $seconds/3600) %></TD>
50         <TD ALIGN="right"><% $custnum %></TD>
51         <TD ALIGN="right"><% $name %></TD>
52         <TD>
53           <INPUT TYPE="hidden" NAME="transactionid<%$tr_id%>" VALUE="1" >
54           <INPUT TYPE="hidden" NAME="seconds<%$tr_id%>" VALUE="<% $seconds %>" >
55
56 %         my $multiplier = $default_multiplier;
57 %         my $mult_paramname = "multiplier${tr_id}_$custnum";
58 %         if ( $cgi->param($mult_paramname) =~ /^\s*([\d\.]+)\s*$/ ) {
59 %           $multiplier = $1;
60 %         }
61
62           <INPUT TYPE="text" NAME="<% $mult_paramname %>" SIZE="5" VALUE="<% $multiplier %>" >
63         </TD>
64       </TR>
65
66 %     foreach ( @customers ) {
67 %       ($custnum, $name) = split(':', $_, 2);
68
69         <TR>
70           <TD ALIGN="right" COLSPAN="5" ><% $custnum %></TD>
71           <TD ALIGN="right"><% $name %></TD>
72           <TD>
73
74 %           $multiplier = $default_multiplier;
75 %           $mult_paramname = "multiplier${tr_id}_$custnum";
76 %           if ( $cgi->param($mult_paramname) =~ /^\s*([\d\.]+)\s*$/ ) {
77 %             $multiplier = $1;
78 %           }
79
80             <INPUT TYPE="text" NAME="<% $mult_paramname %>" SIZE="5" VALUE="<% $multiplier %>" >
81
82           </TD>
83
84         </TR>
85
86 %     }
87 %   }
88
89   </TBODY>
90
91 </TABLE>
92
93 <BR>
94
95 <INPUT TYPE="hidden" NAME="begin" VALUE="<% $cgi->param('begin') |h %>">
96 <INPUT TYPE="hidden" NAME="end"   VALUE="<% $cgi->param('end')   |h %>">
97
98 <INPUT TYPE="submit" NAME="submit" VALUE="<% $title %>">
99 </FORM>
100
101 <% include('/elements/footer.html') %>
102
103 <%init>
104
105 die "access denied"
106   unless $FS::CurrentUser::CurrentUser->access_right('Time queue');
107
108 my(%ticketmap, %ticket, %customers); 
109 my $title = 'Assign Time Worked';
110 tie %ticketmap, 'Tie::IxHash';
111
112 RT::Init();
113
114 my $CurrentUser = RT::CurrentUser->new();
115 $CurrentUser->LoadByName($FS::CurrentUser::CurrentUser->username);
116
117 foreach my $id ( map { /^transactionid(\d+)$/; $1; }
118                      grep /^transactionid\d+$/, $cgi->param) {
119   my $transaction = new RT::Transaction($CurrentUser); 
120   $transaction->Load($id);
121   $ticketmap{$id} = $transaction->ObjectId;
122   unless(exists($ticket{$ticketmap{$id}})) {
123     my $ticket = new RT::Ticket($CurrentUser);
124     $ticket->Load($ticketmap{$id});
125     $ticket{$ticketmap{$id}} = $ticket->Subject;
126     $customers{$ticketmap{$id}} =
127                             [ map  { $_->Resolver->AsString }
128                               grep { $_->Resolver->{'fstable'} eq 'cust_main' }
129                               grep { $_->Scheme eq 'freeside' } 
130                               map  { $_->TargetURI } 
131                                 @{ $ticket->_Links('Base')->ItemsArrayRef } 
132                             ];
133                             
134   }
135 }
136
137 </%init>
138