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