add a quick start at a "dashboard" customer list, mostly for internal use for starters
authorivan <ivan>
Fri, 15 Dec 2006 12:43:44 +0000 (12:43 +0000)
committerivan <ivan>
Fri, 15 Dec 2006 12:43:44 +0000 (12:43 +0000)
FS/FS/Conf.pm
httemplate/elements/dashboard-toplist.html [new file with mode: 0644]
httemplate/index.html

index 270b61c..f2fda80 100644 (file)
@@ -1995,6 +1995,13 @@ httemplate/docs/config.html
     'select_enum' => \@card_types,
   },
 
+  {
+    'key'         => 'dashboard-toplist',
+    'section'     => 'UI',
+    'description' => 'List of items to display on the top of the front page',
+    'type'        => 'textarea',
+  },
+
 );
 
 1;
diff --git a/httemplate/elements/dashboard-toplist.html b/httemplate/elements/dashboard-toplist.html
new file mode 100644 (file)
index 0000000..6276f9f
--- /dev/null
@@ -0,0 +1,98 @@
+% if ( $conf->exists('dashboard-toplist') ) {
+
+  <% include('/elements/table-grid.html') %>
+
+% my $bgcolor1 = '#eeeeee';
+%     my $bgcolor2 = '#ffffff';
+%     my $bgcolor = $bgcolor2;
+
+% foreach my $line ( $conf->config('dashboard-toplist') ) {
+%
+%   if ( $bgcolor eq $bgcolor1 ) {
+%     $bgcolor = $bgcolor2;
+%   } else {
+%     $bgcolor = $bgcolor1;
+%   }
+
+%   if ( $line =~ /^\s*cust_main:\s*(\d+)\s*$/ ) { #customer line
+%     my $custnum = $1;
+%     my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } );
+%     if ( $cust_main ) {
+     
+        <TR>
+         <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+           <A HREF="view/cust_main.cgi?<% $custnum %>"><% $cust_main->name %></A>
+         </TD>
+%         foreach my $priority ( @custom_priorities, '' ) {
+%           my $num =
+%             FS::TicketSystem->num_customer_tickets($custnum,$priority);
+%           my $ahref = '';
+%           $ahref= '<A HREF="'.
+%                   FS::TicketSystem->href_customer_tickets($custnum,$priority).
+%                   '">'
+%             if $num;
+
+            <TD CLASS="grid" BGCOLOR="<% $bgcolor %>" ALIGN="right">
+             <% $ahref.$num %></A>
+           </TD>
+%         }
+        </TR>
+
+%     } else { 
+
+        <TR>
+          <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+           Unknown customer number <% $custnum %>
+         </TD>
+        </TR>
+
+%     }
+%
+%   } elsif ( $line =~ /^\-\-+$/ ) { #divider
+%     
+      <TR>
+        <TH CLASS="grid" COLSPAN="<% scalar(@custom_priorities) + 2 %>"></TH>
+      </TR>
+
+%     next;
+%     
+%   } elsif ( $line =~ /^\s*$/ ) {
+
+      <TR>
+        <TD CLASS="grid" COLSPAN="<% scalar(@custom_priorities) + 2 %>" BGCOLOR="<% $bgcolor %>">&nbsp;</TD>
+      </TR>
+
+%   } else { #label line
+
+      <TR>
+        <TH CLASS="grid" BGCOLOR="#cccccc"><% $line %></TH>
+%       foreach my $priority ( @custom_priorities, '' ) {
+          <TH CLASS="grid" BGCOLOR="#cccccc">
+           <% $priority || '<i>(none)</i>'%>
+         </TH>
+%       }
+      </TR>
+
+%   }
+
+%    
+% } 
+
+  </TABLE>
+  <BR>
+
+% }
+<%init>
+
+my $conf = new FS::Conf;
+
+#false laziness w/httemplate/search/cust_main.cgi... care if 
+# custom_priority_field becomes anything but a local hack...
+my @custom_priorities = ();
+if ( $conf->config('ticket_system-custom_priority_field')
+     && @{[ $conf->config('ticket_system-custom_priority_field-values') ]} ) {
+  @custom_priorities =
+    $conf->config('ticket_system-custom_priority_field-values');
+}
+
+</%init>
index 57d85a9..60ab26f 100644 (file)
@@ -1,8 +1,9 @@
 % my $conf = new FS::Conf; 
 
 <% include('/elements/header.html', 'Billing Main' ) %>
-%
-%
+
+<% include('/elements/dashboard-toplist.html') %>
+
 %  my $sth = dbh->prepare(
 %    #"SELECT DISTINCT custnum FROM h_cust_main JOIN cust_main USING ( custnum )
 %    "SELECT custnum FROM h_cust_main JOIN cust_main USING ( custnum )
 %  @custnums = splice(@custnums, 0, 10);
 %
 %  if ( @custnums ) {
-%
-%
-
 
   <% include('/elements/table-grid.html') %>
+
 % my $bgcolor1 = '#eeeeee';
 %     my $bgcolor2 = '#ffffff';
-%     my $bgcolor;
-%  
-
+%     my $bgcolor = $bgcolor2;
 
   <TR>
     <TH CLASS="grid" BGCOLOR="#cccccc" COLSPAN=1>Customers I recently added or modified</TH>
   </TR>
+
 % foreach my $custnum ( @custnums ) { 
 % my $cust_main = qsearchs('cust_main', { 'custnum' => $custnum } ); 
 % next unless $cust_main; 
 
-
     <TR>
       <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF="view/cust_main.cgi?<% $custnum %>"><% $custnum %>: <% $cust_main->name %></A></TD>
     </TR>
-%
+
 %       if ( $bgcolor eq $bgcolor1 ) {
 %          $bgcolor = $bgcolor2;
 %        } else {
 %    
 % } 
 
-
   </TABLE>
-% } 
 
+% } 
 
 <% include('/elements/footer.html') %>
-