adjust "Create Ticket" link, RT#7656
[freeside.git] / httemplate / view / cust_main / tickets.html
1 <FORM METHOD="GET" NAME="CreateTicketForm" STYLE="display:inline">
2 <SCRIPT TYPE="text/javascript">
3 function updateTicketLink() {
4   var link = document.getElementById('CreateTicketLink');
5   var selector = document.getElementById('Queue')
6   link.href = "<% $new_base.'?'.
7     join(';', map(
8       { ($_ eq 'Queue') ? () : "$_=$new_param{$_}"} 
9     keys %new_param),'Queue=') %>" + selector.options[selector.selectedIndex].value;
10 }
11 </SCRIPT>
12 <A id="CreateTicketLink" HREF="">Create new ticket</A>
13  in queue
14 <SELECT NAME="Queue" id="Queue" onchange="updateTicketLink()">
15 % my %queues = FS::TicketSystem->queues();
16 % foreach my $queueid ( sort { $queues{$a} cmp $queues{$b} } keys %queues ) {
17 %   #should consider whether the user has ACL to create ticket in each queue
18     <OPTION VALUE="<% $queueid %>"
19             <% $queueid == $new_param{'Queue'} ? 'SELECTED' : '' %>
20     ><% $queues{$queueid} |h %>
21 % }
22 </SELECT>
23 </FORM>
24 <SCRIPT DEFER TYPE="text/javascript">updateTicketLink();</SCRIPT>
25 <BR>
26
27 (<A HREF="<% $open_link %>">View <% $openlabel %> tickets for this customer</A>)
28 (<A HREF="<% $res_link  %>">View resolved tickets for this customer</A>)
29 <BR><BR>
30
31 <% include("/elements/table-grid.html") %>
32 % my $bgcolor1 = '#eeeeee';
33 %   my $bgcolor2 = '#ffffff';
34 %   my $bgcolor = '';
35
36 <TR>
37   <TH CLASS="grid" BGCOLOR="#cccccc">#</TH>
38   <TH CLASS="grid" BGCOLOR="#cccccc">Subject</TH>
39   <TH CLASS="grid" BGCOLOR="#cccccc">Status</TH>
40   <TH CLASS="grid" BGCOLOR="#cccccc">Queue</TH>
41   <TH CLASS="grid" BGCOLOR="#cccccc">Owner</TH>
42   <TH CLASS="grid" BGCOLOR="#cccccc">Priority</TH>
43 </TR>
44
45 % foreach my $ticket ( @tickets ) {
46 %     my $href = FS::TicketSystem->href_ticket($ticket->{id});
47 %     if ( $bgcolor eq $bgcolor1 ) {
48 %       $bgcolor = $bgcolor2;
49 %     } else {
50 %       $bgcolor = $bgcolor1;
51 %     }
52
53   <TR>
54   
55     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
56       <A HREF=<%$href%>><% $ticket->{id} %></A>
57     </TD>
58   
59     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
60       <A HREF=<%$href%>><% $ticket->{subject} %></A>
61     </TD>
62   
63     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
64       <% $ticket->{status} %>
65     </TD>
66   
67     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
68       <% $ticket->{queue} %>
69     </TD>
70   
71     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
72       <% $ticket->{owner} %>
73     </TD>
74   
75     <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
76       <% $ticket->{content}
77            ? $ticket->{content}.' ('.$ticket->{priority}.')'
78            : $ticket->{priority}
79       %>
80     </TD>
81   
82   </TR>
83
84 % } 
85
86 </TABLE>
87
88 <%init>
89
90 my( $cust_main ) = @_;
91 my( @tickets )  = $cust_main->tickets;
92
93 my $open_link = FS::TicketSystem->href_customer_tickets($cust_main->custnum);
94 my $openlabel = join('/', FS::TicketSystem->statuses );
95
96 my $res_link  = FS::TicketSystem->href_customer_tickets(
97                   $cust_main->custnum,
98                   { 'statuses' => [ 'resolved' ] }
99                 );
100
101 my( $new_base, %new_param ) = FS::TicketSystem->href_params_new_ticket(
102                  $cust_main,
103                  join(', ', $cust_main->invoicing_list_emailonly )               );
104
105 my $new_link = FS::TicketSystem->href_new_ticket(
106                  $cust_main,
107                  join(', ', $cust_main->invoicing_list_emailonly )
108                );
109
110 </%init>