summaryrefslogtreecommitdiff
path: root/httemplate/view/cust_main/tickets.html
blob: 863c66be454f544a11be30e6dcb99419bd6f2094 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
<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 %>"><% mt('Create new ticket') |h %></A>
 <% mt('in queue') |h %> 
%# fetch list of queues in which the user can create tickets
% my %queues = FS::TicketSystem->queues('', '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="<% $open_link %>"><% mt("View $openlabel tickets for this customer") |h %></A>)
(<A HREF="<% $res_link  %>"><% mt('View resolved tickets for this customer') |h %></A>)
<BR><BR>

<& /elements/table-grid.html &>
% my $bgcolor1 = '#eeeeee';
%   my $bgcolor2 = '#ffffff';
%   my $bgcolor = '';

<TR>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('#') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Subject') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Queue') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Due') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Estimated Time') |h %></TH>
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Priority') |h %></TH>
% if ( $ss_priority ) {
  <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Customer Priority') |h %></TH>
% }
</TR>

% 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 CLASS="grid" BGCOLOR="<% $bgcolor %>">
      <% $date_formatter->($ticket->{due}) %>
    </TD>

    <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
      <% $ticket->{timeestimated} %>
    </TD>
  
    <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
      <% $ticket->{content}
           ? $ticket->{content}.' ('.$ticket->{priority}.')'
           : $ticket->{priority}
      %>
    </TD>

%   if ( $ss_priority ) {
    <TD ALIGN="right" CLASS="grid" BGCOLOR="<% $bgcolor %>">
      <% $ticket->{"CF.{$ss_priority}"} %>
    </TD>
%   }

  </TR>

% } 

</TABLE>

<%init>
use Date::Format 'time2str';
use Date::Parse 'str2time';

my( $conf ) = new FS::Conf;
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_base, %new_param ) = 
  FS::TicketSystem->href_params_new_ticket( $cust_main );

my $new_link = FS::TicketSystem->href_new_ticket( $cust_main );

my $ss_priority = FS::TicketSystem->selfservice_priority;
if ( $ss_priority ) {
  use sort 'stable';
  no warnings 'uninitialized';
  @tickets = sort { 
    ($b->{'content'} eq $a->{'content'}) &&
    $b->{'_selfservice_priority'} <=> $a->{'_selfservice_priority'}
  } @tickets;
}

my $format = $conf->config('date_format') || '%Y-%m-%d';

my $date_formatter = sub {
  my $time = str2time($_[0], 'GMT');
  # exclude times within 24 hours of zero
  ($time > 86400) ? time2str($format, $time) : '';
};

</%init>