d8cd7f306dc1ec096dd002fd94fd0981cf57cf4d
[freeside.git] / httemplate / elements / dashboard-toplist.html
1 % if ( $conf->exists('dashboard-toplist') ) {
2
3   <% include('/elements/table-grid.html') %>
4
5 % my $bgcolor1 = '#eeeeee';
6 %     my $bgcolor2 = '#ffffff';
7 %     my $bgcolor = $bgcolor2;
8
9 % foreach my $line ( $conf->config('dashboard-toplist') ) {
10 %
11 %   if ( $bgcolor eq $bgcolor1 ) {
12 %     $bgcolor = $bgcolor2;
13 %   } else {
14 %     $bgcolor = $bgcolor1;
15 %   }
16
17 %   if ( $line =~ /^\s*cust_main:\s*(\d+)\s*$/ ) { #customer line
18 %     my $custnum = $1;
19 %     my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
20 %     if ( $cust_main ) {
21      
22         <TR>
23           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
24             <A HREF="view/cust_main.cgi?<% $custnum %>"><% $cust_main->name %></A>
25           </TD>
26           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
27             <% include('/elements/mcp_lint.html', 'cust_main'=>$cust_main) %>
28           </TD>
29           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right">
30             <FONT SIZE="-1"><A HREF="<% FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">(new ticket)</A></FONT>
31           </TD>
32
33 %         foreach my $priority ( @custom_priorities, '' ) {
34 %           my $num =
35 %             FS::TicketSystem->num_customer_tickets($custnum,$priority);
36 %           my $ahref = '';
37 %           $ahref= '<A HREF="'.
38 %                   FS::TicketSystem->href_customer_tickets($custnum,$priority).
39 %                   '">'
40 %             if $num;
41
42             <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right">
43               <% $ahref.$num %></A>
44             </TD>
45 %         }
46         </TR>
47
48 %     } else { 
49
50         <TR>
51           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
52             Unknown customer number <% $custnum %>
53           </TD>
54         </TR>
55
56 %     }
57 %
58 %   } elsif ( $line =~ /^\-\-+$/ ) { #divider
59 %     
60       <TR>
61         <TH CLASS="grid" COLSPAN="<% scalar(@custom_priorities) + 4 %>"></TH>
62       </TR>
63
64 %     next;
65 %     
66 %   } elsif ( $line =~ /^\s*$/ ) {
67
68       <TR>
69         <TD CLASS="grid" COLSPAN="<% scalar(@custom_priorities) + 4 %>" BGCOLOR="<% $bgcolor %>">&nbsp;</TD>
70       </TR>
71
72 %   } elsif ( $line =~ /^\S/ ) { #label line
73
74       <TR>
75         <TH CLASS="grid" BGCOLOR="#cccccc"><% $line %></TH>
76         <TH CLASS="grid" BGCOLOR="#cccccc">Lint</TH>
77         <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
78 %       foreach my $priority ( @custom_priorities, '' ) {
79           <TH CLASS="grid" BGCOLOR="#cccccc">
80             <% $priority || '<i>(none)</i>'%>
81           </TH>
82 %       }
83       </TR>
84
85 %   } else { #regular line
86
87       <TR>
88         <TD CLASS="grid"  COLSPAN="<% scalar(@custom_priorities) + 4 %>" BGCOLOR="<% $bgcolor %>"><% $line %></TD>
89       </TR>
90
91 %   }
92
93 %    
94 % } 
95
96   </TABLE>
97   <BR>
98
99 % }
100 <%init>
101
102 my $conf = new FS::Conf;
103
104 #false laziness w/httemplate/search/cust_main.cgi... care if 
105 # custom_priority_field becomes anything but a local hack...
106 my @custom_priorities = ();
107 if ( $conf->config('ticket_system-custom_priority_field')
108      && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
109   @custom_priorities =
110     $conf->config('ticket_system-custom_priority_field-values');
111 }
112
113 </%init>