user pref for # of customers on dashboard, RT#29794
[freeside.git] / httemplate / index.html
1 <%init>my $debug = $cgi->param('debug');</%init>
2 % warn time.": header.html\n" if $debug;
3 %
4 <& /elements/header.html, mt('Billing Main') &>
5
6 % warn time.": dashboard-install_welcome.html\n" if $debug;
7 %
8 <& /elements/dashboard-install_welcome.html &>
9
10 % warn time.": dashboard-toplist.html\n" if $debug;
11 %
12 <& /elements/dashboard-toplist.html &>
13
14 % my $curuser = $FS::CurrentUser::CurrentUser;
15 % my $numcust = $curuser->option('dashboard_customers');
16 % $numcust ||= 10 unless $numcust =~ /^\s*0+\s*$/;
17 % if ( $numcust ) {
18 %
19 %   warn time.": fetching recently changed customers\n" if $debug;
20 %
21 %   my $sth = dbh->prepare(
22 %     #"SELECT DISTINCT custnum FROM h_cust_main JOIN cust_main USING ( custnum )
23 %     "SELECT custnum FROM h_cust_main JOIN cust_main USING ( custnum )
24 %        WHERE ( history_action = 'insert' OR history_action = 'replace_new' ) 
25 %          AND history_user = ?
26 %        ORDER BY history_date desc LIMIT 1000" # LIMIT 10
27 %     ) or die dbh->errstr;
28 %
29 %   $sth->execute( getotaker() ) or die $sth->errstr;
30 %
31 %   my %saw = ();
32 %   my @custnums = grep { !$saw{$_}++ } map $_->[0], @{ $sth->fetchall_arrayref };
33 %
34 %   @custnums = splice(@custnums, 0, $numcust);
35 %
36 %   if ( @custnums ) {
37 %     warn time.": displaying recently changed customers\n" if $debug;
38
39       <& /elements/table-grid.html &>
40
41 %     my $bgcolor1 = '#eeeeee';
42 %     my $bgcolor2 = '#ffffff';
43 %     my $bgcolor = $bgcolor2;
44
45         <TR>
46           <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=1><% mt('Customers I recently added or modified') |h %></TH>
47         </TR>
48
49 %     foreach my $custnum ( @custnums ) { 
50 %     my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); 
51 %     next unless $cust_main; 
52
53         <TR>
54           <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="view/cust_main.cgi?<% $custnum %>"><% $cust_main->display_custnum %>: <% $cust_main->name |h %></A></TD>
55         </TR>
56
57 %       if ( $bgcolor eq $bgcolor1 ) {
58 %          $bgcolor = $bgcolor2;
59 %        } else {
60 %          $bgcolor = $bgcolor1;
61 %        }
62 %    
63 %     } 
64
65       </TABLE>
66
67 %   } 
68 % }
69
70 <& /elements/footer.html &>