7ee6f2d43715d2a2b037e41e7ebaeac405189494
[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 %>" ALIGN="right">
27             <FONT SIZE="-1"><A HREF="<% FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">(new ticket)</A></FONT>
28           </TD>
29
30 %         foreach my $priority ( @custom_priorities, '' ) {
31 %           my $num =
32 %             FS::TicketSystem->num_customer_tickets($custnum,$priority);
33 %           my $ahref = '';
34 %           $ahref= '<A HREF="'.
35 %                   FS::TicketSystem->href_customer_tickets($custnum,$priority).
36 %                   '">'
37 %             if $num;
38
39             <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right">
40               <% $ahref.$num %></A>
41             </TD>
42 %         }
43         </TR>
44
45 %     } else { 
46
47         <TR>
48           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
49             Unknown customer number <% $custnum %>
50           </TD>
51         </TR>
52
53 %     }
54 %
55 %   } elsif ( $line =~ /^\-\-+$/ ) { #divider
56 %     
57       <TR>
58         <TH CLASS="grid" COLSPAN="<% scalar(@custom_priorities) + 3 %>"></TH>
59       </TR>
60
61 %     next;
62 %     
63 %   } elsif ( $line =~ /^\s*$/ ) {
64
65       <TR>
66         <TD CLASS="grid" COLSPAN="<% scalar(@custom_priorities) + 3 %>" BGCOLOR="<% $bgcolor %>">&nbsp;</TD>
67       </TR>
68
69 %   } elsif ( $line =~ /^\S/ ) { #label line
70
71       <TR>
72         <TH CLASS="grid" BGCOLOR="#cccccc"><% $line %></TH>
73         <TH CLASS="grid" BGCOLOR="#cccccc"></TH>
74 %       foreach my $priority ( @custom_priorities, '' ) {
75           <TH CLASS="grid" BGCOLOR="#cccccc">
76             <% $priority || '<i>(none)</i>'%>
77           </TH>
78 %       }
79       </TR>
80
81 %   } else { #regular line
82
83       <TR>
84         <TD CLASS="grid"  COLSPAN="<% scalar(@custom_priorities) + 3 %>" BGCOLOR="<% $bgcolor %>"><% $line %></TD>
85       </TR>
86
87 %   }
88
89 %    
90 % } 
91
92   </TABLE>
93   <BR>
94
95 % }
96 <%init>
97
98 my $conf = new FS::Conf;
99
100 #false laziness w/httemplate/search/cust_main.cgi... care if 
101 # custom_priority_field becomes anything but a local hack...
102 my @custom_priorities = ();
103 if ( $conf->config('ticket_system-custom_priority_field')
104      && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
105   @custom_priorities =
106     $conf->config('ticket_system-custom_priority_field-values');
107 }
108
109 </%init>