clean up various other RT initialization inconsistancy, RT#18719
[freeside.git] / httemplate / search / report_rt_ticket.html
1 <% include('/elements/header.html', 'Time worked summary report criteria' ) %>
2
3 <FORM ACTION="rt_ticket.html" METHOD="GET">
4
5 <TABLE>
6
7   <% include ( '/elements/tr-input-beginning_ending.html' ) %>
8
9   <& /elements/tr-td-label.html, label => 'Time category:' &>
10   <TD>
11   <& /elements/select-rt-customfield.html,
12       name        => 'cfname',
13       lookuptype  => 'RT::Transaction',
14       valuetype   => 'TimeValue',
15       empty_label => 'Worked',
16   &>
17   </TD></TR>
18
19   <% include ( '/elements/tr-select-otaker.html' ) %>
20
21   <TR>
22     <TD ALIGN="right">Account:</TD>
23     <TD>
24       <SELECT NAME="svcnum">
25         <OPTION VALUE="">(all)
26 %       foreach my $svc_acct (@svc_acct) {
27           <OPTION VALUE="<% $svc_acct->svcnum %>"><% $svc_acct->username %></OPTION>
28 %       }
29       </SELECT>
30     </TD>
31   </TR>
32
33 </TABLE>
34
35 <BR>
36 <INPUT TYPE="submit" VALUE="Search">
37
38 </FORM>
39
40 <% include('/elements/footer.html') %>
41 <%init>
42
43 die "access denied"
44   unless $FS::CurrentUser::CurrentUser->access_right('List rating data');
45
46 my $conf = new FS::Conf;
47
48 my @pkgparts = $conf->config('support_packages');
49
50 my @svc_acct = ();
51 if ( @pkgparts ) {
52   @svc_acct = qsearch({
53     'table'     => 'svc_acct',
54     'addl_from' => ' LEFT JOIN cust_svc USING ( svcnum ) '.
55                    ' LEFT JOIN cust_pkg USING ( pkgnum ) ',
56     'extra_sql' => 'WHERE pkgpart IN ('. join(',', @pkgparts). ')',
57     'order_by'  => 'ORDER BY username',
58   });
59 }
60
61 # get a list of TimeValue-type custom fields
62 my $CurrentUser = RT::CurrentUser->new();
63 $CurrentUser->LoadByName($FS::CurrentUser::CurrentUser->username);
64 die "RT not configured" unless $CurrentUser->id;
65 my $CFs = RT::CustomFields->new($CurrentUser);
66
67 $CFs->Limit(FIELD => 'LookupType',
68             OPERATOR => 'ENDSWITH',
69             VALUE => 'RT::Transaction');
70
71 $CFs->Limit(FIELD => 'Type',
72             VALUE => 'TimeValue');
73
74 my @time_fields = ('', 'Worked');
75 while (my $CF = $CFs->Next) {
76   push @time_fields, $CF->Name, ($CF->Description || $CF->Name);
77 }
78
79
80 </%init>