option to override requestor in new tickets, #7777
[freeside.git] / httemplate / view / cust_main / tickets.html
index 84cc902..064f511 100644 (file)
@@ -1,53 +1,54 @@
-%
-%  my( $cust_main ) = @_;
-%
-%  my $conf = new FS::Conf;
-%  my $num = $conf->config('cust_main-max_tickets') || 10;
-%
-%  my @tickets = ();
-%  unless ( $conf->config('ticket_system-custom_priority_field') ) {
-%
-%    @tickets =
-%      @{ FS::TicketSystem->customer_tickets($cust_main->custnum, $num) };
-%
-%  } else {
-%
-%    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,
-%                                             )
-%         };
-%    }
-%
-%  }
-%
-%
-
-<A NAME="tickets"><FONT SIZE="+2">Tickets</FONT></A>
+<FORM METHOD="GET" NAME="CreateTicketForm" STYLE="display:inline">
+<SCRIPT TYPE="text/javascript">
+function updateTicketLink() {
+  var link = document.getElementById('CreateTicketLink');
+  var selector = document.getElementById('Queue')
+  link.href = "<% $new_base.'?'.
+    join(';', map(
+      { ($_ eq 'Queue') ? () : "$_=$new_param{$_}"} 
+    keys %new_param),'Queue=') %>" + selector.options[selector.selectedIndex].value;
+}
+</SCRIPT>
+<A id="CreateTicketLink" HREF="<% $new_link %>">Create new ticket</A>
+ in queue
+%# fetch list of queues in which the user can create tickets
+% my $session = FS::TicketSystem->session();
+% my %queues = FS::TicketSystem->queues($session, 'CreateTicket');
+% if( $conf->exists('ticket_system-force_default_queueid') ) {
+<B><% $queues{$new_param{'Queue'}} %></B>
+<INPUT TYPE="hidden" NAME="Queue" VALUE="<% $new_param{'Queue'} %>">
+% }
+% else {
+<SELECT NAME="Queue" id="Queue" onchange="updateTicketLink()">
+% foreach my $queueid ( sort { $queues{$a} cmp $queues{$b} } keys %queues ) {
+    <OPTION VALUE="<% $queueid %>"
+            <% $queueid == $new_param{'Queue'} ? 'SELECTED' : '' %>
+    ><% $queues{$queueid} |h %>
+% }
+</SELECT>
+<SCRIPT DEFER TYPE="text/javascript">updateTicketLink();</SCRIPT>
+% }
+</FORM>
 <BR>
 
-(<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>)
+(<A HREF="<% $open_link %>">View <% $openlabel %> tickets for this customer</A>)
+(<A HREF="<% $res_link  %>">View resolved tickets for this customer</A>)
+<BR><BR>
 
 <% include("/elements/table-grid.html") %>
 % my $bgcolor1 = '#eeeeee';
 %   my $bgcolor2 = '#ffffff';
 %   my $bgcolor = '';
-%
-
 
 <TR>
   <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
   <TH CLASS="grid" BGCOLOR="#cccccc">Subject</TH>
-  <TH CLASS="grid" BGCOLOR="#cccccc">Priority</TH>
-  <TH CLASS="grid" BGCOLOR="#cccccc">Queue</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 $ticket ( @tickets ) {
 %     my $href = FS::TicketSystem->href_ticket($ticket->{id});
 %     if ( $bgcolor eq $bgcolor1 ) {
 %     } 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>
 
-<TR>
+% } 
 
-  <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF=<%$href%>><% $ticket->{id} %></A></TD>
+</TABLE>
 
-  <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><A HREF=<%$href%>><% $ticket->{subject} %></A></TD>
+<%init>
 
-  <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $ticket->{content} || $ticket->{priority} %></TD>
+my( $conf ) = new FS::Conf;
+my( $cust_main ) = @_;
+my( @tickets )  = $cust_main->tickets;
 
-  <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $ticket->{name} %></TD>
+my $open_link = FS::TicketSystem->href_customer_tickets($cust_main->custnum);
+my $openlabel = join('/', FS::TicketSystem->statuses );
 
-  <TD CLASS="grid" BGCOLOR="<% $bgcolor %>"><% $ticket->{status} %></TD>
-
-</TR>
-% } 
+my $res_link  = FS::TicketSystem->href_customer_tickets(
+                  $cust_main->custnum,
+                  { 'statuses' => [ 'resolved' ] }
+                );
 
+my( $new_base, %new_param ) = 
+  FS::TicketSystem->href_params_new_ticket( $cust_main );
 
-</TABLE>
+my $new_link = FS::TicketSystem->href_new_ticket( $cust_main );
 
+</%init>