X-Git-Url: http://git.freeside.biz/gitweb/?a=blobdiff_plain;f=httemplate%2Fview%2Fcust_main%2Ftickets.html;h=adfaead6ea1cc9f90e657a0d0b3a6df7c2e07166;hb=e6f70733037e9295be95cd27791356ba94177968;hp=d6ddfa64c9cb679233e2e09b9fc2473db9bd23b4;hpb=57323a695e58b58cc8892784d356995f6e41bfcd;p=freeside.git
diff --git a/httemplate/view/cust_main/tickets.html b/httemplate/view/cust_main/tickets.html
index d6ddfa64c..adfaead6e 100644
--- a/httemplate/view/cust_main/tickets.html
+++ b/httemplate/view/cust_main/tickets.html
@@ -1,54 +1,163 @@
-<%
- my( $cust_main ) = @_;
+
+
- my $conf = new FS::Conf;
- my $num = 10;
+(<% mt("View $openlabel tickets for this customer") |h %>)
+(<% mt('View resolved tickets for this customer') |h %>)
+
- my @tickets = ();
- unless ( $conf->config('ticket_system-custom_priority_field') ) {
+<& /elements/table-grid.html &>
+% my $bgcolor1 = '#eeeeee';
+% my $bgcolor2 = '#ffffff';
+% my $bgcolor = '';
- @tickets =
- @{ FS::TicketSystem->customer_tickets($cust_main->custnum, $num) };
+
+ <% mt('#') |h %> |
+ <% mt('Subject') |h %> |
+ <% mt('Status') |h %> |
+ <% mt('Queue') |h %> |
+ <% mt('Owner') |h %> |
+ <% mt('Due') |h %> |
+ <% mt('Estimated Time') |h %> |
+ <% mt('Priority') |h %> |
+% if ( $ss_priority ) {
+ <% mt('Customer Priority') |h %> |
+% }
+
- } else {
+% foreach my $ticket ( @tickets ) {
+% my $href = FS::TicketSystem->href_ticket($ticket->{id});
+% if ( $bgcolor eq $bgcolor1 ) {
+% $bgcolor = $bgcolor2;
+% } else {
+% $bgcolor = $bgcolor1;
+% }
- 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,
- )
- };
- }
+
+
+
+ ><% $ticket->{id} %>
+ |
+
+
+ ><% $ticket->{subject} %>
+ |
+
+
+ <% $ticket->{status} %>
+ |
+
+
+ <% $ticket->{queue} %>
+ |
+
+
+ <% $ticket->{owner} %>
+ |
- }
+
+ <% $date_formatter->($ticket->{due}) %>
+ |
-%>
+
+ <% $ticket->{timeestimated} %>
+ |
+
+
+ <% $ticket->{content}
+ ? $ticket->{content}.' ('.$ticket->{priority}.')'
+ : $ticket->{priority}
+ %>
+ |
+
+% if ( $ss_priority ) {
+
+ <% $ticket->{"CF.{$ss_priority}"} %>
+ |
+% }
+
+
+
+% }
-Highest priority tickets
-(View all tickets for this customer)
-(New ticket for this customer)
-<%= table() %>
-
- # |
- Subject |
- Priority |
- Queue |
- Status |
-
-<% foreach my $ticket ( @tickets ) {
- my $href = FS::TicketSystem->href_ticket($ticket->{id});
-%>
-
- ><%= $ticket->{id} %> |
- ><%= $ticket->{subject} %> |
- <%= $ticket->{content} || $ticket->{priority} %> |
- <%= $ticket->{name} %> |
- <%= $ticket->{status} %> |
-
-<% } %>
+<%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 ) {
+ my $dir = $conf->exists('ticket_system-priority_reverse') ? -1 : 1;
+ use sort 'stable';
+ # sort in the following way:
+ @tickets = sort {
+ # within a severity level...
+ ( $a->{'content'} eq $b->{'content'} ) ? (
+ # no-priority tickets sort last
+ (
+ ($a->{'_selfservice_priority'} eq '') <=>
+ ($b->{'_selfservice_priority'} eq '')
+ ) ||
+ # otherwise obey ticket_system-priority_reverse
+ ( $dir *
+ ($b->{'_selfservice_priority'} <=> $a->{'_selfservice_priority'})
+ )
+ ) : 0; # but don't rearrange between severity levels
+ } @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>