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