slightly more sane names for customer tickets hash, display ticket owners on customer...
[freeside.git] / httemplate / view / cust_main / tickets.html
index 5c1d94e..b5d581d 100644 (file)
@@ -1,54 +1,84 @@
-<%
-  my( $cust_main ) = @_;
+<A NAME="tickets"><FONT SIZE="+2">Tickets</FONT></A>
+<BR>
 
-  my $conf = new FS::Conf;
-  my $num = 10;
+(<A HREF="<% $open_link %>">View <% $openlabel %> tickets for this customer</A>)
+(<A HREF="<% $res_link  %>">View resolved tickets for this customer</A>)
+<BR>
+(<A HREF="<% $new_link  %>">Create new ticket for this customer</A>)
 
-  my @tickets = ();
-  unless ( $conf->config('ticket_system-custom_priority_field') ) {
+<% include("/elements/table-grid.html") %>
+% my $bgcolor1 = '#eeeeee';
+%   my $bgcolor2 = '#ffffff';
+%   my $bgcolor = '';
 
-    @tickets =
-      @{ FS::TicketSystem->customer_tickets($cust_main->custnum, $num) };
-
-  } else {
+<TR>
+  <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Subject</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Queue</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Owner</TH>
+  <TH CLASS="grid" BGCOLOR="#cccccc">Priority</TH>
+</TR>
 
-    foreach my $priority (
-      $conf->config('ticket_system-custom_priority_field-values'), ''
-    ) {
-      last if scalar(@tickets) >= $num;
-      push @tickets, 
-        @{ FS::TicketSystem->customer_tickets( $cust_main->custnum,
-                                               $num - scalar(@tickets),
-                                               $priority,
-                                             )
-         };
-    }
+% foreach my $ticket ( @tickets ) {
+%     my $href = FS::TicketSystem->href_ticket($ticket->{id});
+%     if ( $bgcolor eq $bgcolor1 ) {
+%       $bgcolor = $bgcolor2;
+%     } else {
+%       $bgcolor = $bgcolor1;
+%     }
 
-  }
+  <TR>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <A HREF=<%$href%>><% $ticket->{id} %></A>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <A HREF=<%$href%>><% $ticket->{subject} %></A>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <% $ticket->{status} %>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <% $ticket->{queue} %>
+    </TD>
+  
+    <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <% $ticket->{owner} %>
+    </TD>
+  
+    <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
+      <% $ticket->{content}
+           ? $ticket->{content}.' ('.$ticket->{priority}.')'
+           : $ticket->{priority}
+      %>
+    </TD>
+  
+  </TR>
 
-%>
+% } 
 
-Highest priority tickets
-(<A HREF="<%= FS::TicketSystem->href_customer_tickets($cust_main->custnum) %>">View all tickets for this customer</A>)
-(<A HREF="<%= FS::TicketSystem->href_new_ticket($cust_main, join(', ', grep { $_ !~ /^(POST|FAX)$/ } $cust_main->invoicing_list ) ) %>">New ticket for this customer</A>)
-<%= include("/elements/table.html") %>
-<TR>
-  <TH>#</TH>
-  <TH>Subject</TH>
-  <TH>Priority</TH>
-  <TH>Queue</TH>
-  <TH>Status</TH>
-</TR>
-<% foreach my $ticket ( @tickets ) {
-     my $href = FS::TicketSystem->href_ticket($ticket->{id});
-%>
-<TR>
-  <TD><A HREF=<%=$href%>><%= $ticket->{id} %></A></TD>
-  <TD><A HREF=<%=$href%>><%= $ticket->{subject} %></A></TD>
-  <TD ALIGN="right"><%= $ticket->{content} || $ticket->{priority} %></TD>
-  <TD><%= $ticket->{name} %></TD>
-  <TD><%= $ticket->{status} %></TD>
-</TR>
-<% } %>
 </TABLE>
 
+<%init>
+
+my( $cust_main ) = @_;
+my( @tickets )  = $cust_main->tickets;
+
+my $open_link = FS::TicketSystem->href_customer_tickets($cust_main->custnum);
+my $openlabel = join('/', FS::TicketSystem->statuses );
+
+my $res_link  = FS::TicketSystem->href_customer_tickets(
+                  $cust_main->custnum,
+                  { 'statuses' => [ 'resolved' ] }
+                );
+
+my $new_link = FS::TicketSystem->href_new_ticket(
+                 $cust_main,
+                 join(', ', $cust_main->invoicing_list_emailonly )
+               );
+
+</%init>