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
|
%# <& /elements/form-create_ticket.html, object => $object &>
<A NAME="appointments"><FONT CLASS="fsinnerbox-title">Appointments</FONT></A>
% if ( $FS::CurrentUser::CurrentUser->access_right('Make appointment') ) {
<& /elements/popup_link-make_appointment.html, custnum=>$cust_main->custnum &>
% }
%# |
%# View
%# <A HREF="<% $open_link %>"><% mt($openlabel) |h %></A> |
%# <A HREF="<% $res_link %>"><% mt('resolved') |h %></A>
<BR>
%if ( @tickets ) {
<& /elements/table-grid.html &>
% my $bgcolor1 = '#eeeeee';
% my $bgcolor2 = '#ffffff';
% my $bgcolor = '';
<THEAD>
<TR>
% if ( $custom_field ) {
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
% }
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
<TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
</TR>
</THEAD>
% foreach my $ticket ( @tickets ) {
% my $href = FS::TicketSystem->href_ticket($ticket->{id});
% if ( $bgcolor eq $bgcolor1 ) {
% $bgcolor = $bgcolor2;
% } else {
% $bgcolor = $bgcolor1;
% }
%
% use Date::Parse qw( str2time );
% my $starts = str2time( $ticket->{starts}, 'UTC' ); #default format here sucks
% my $starts_pretty = '';
% $starts_pretty = time2str('%a %h %o %Y %l:%M%P', $starts)
% if $starts > 86400;
<TR>
% if ( $custom_field ) {
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
<A HREF=<%$href%>><% $ticket->{"CF.{$custom_field}"} |h %></A>
</TD>
% }
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
<A HREF=<%$href%>><% $starts_pretty %></A>
</TD>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
<% $ticket->{status} %>
</TD>
<TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
<% $ticket->{owner} %>
</TD>
</TR>
% }
</TABLE>
%}
<%init>
my $cust_main = shift;
my $object = $cust_main;
#total false laziness & just copied from elements/table-tickets.html
my %opt = @_;
my $conf = new FS::Conf;
return '' unless $conf->config('ticket_system');
#my $object = $opt{'object'};
#$object = $object->cust_svc if $object->isa('FS::svc_Common');
my @tickets = $object->appointments;
my $custom_field = $conf->config('ticket_system-appointment-custom_field');
# my ($openlabel, $open_link, $res_link, $thing);
# $openlabel = join('/', FS::TicketSystem->statuses );
# not the nicest way to do this--FS::has_tickets_Common?
#if ( $object->isa('FS::cust_main') ) {
# $thing = 'customer';
# $open_link = FS::TicketSystem->href_customer_tickets($object->custnum);
#
# $res_link = FS::TicketSystem->href_customer_tickets(
# $object->custnum,
# { 'statuses' => [ 'resolved' ] }
# );
#} elsif ( $object->isa('FS::cust_svc') ) {
#
# return '' unless $object->pkgnum;
#
# $thing = 'service';
# $open_link = FS::TicketSystem->href_service_tickets($object->svcnum);
#
# $res_link = FS::TicketSystem->href_service_tickets(
# $object->svcnum,
# { 'statuses' => [ 'resolved' ] }
# );
#}
#not actually used, appointments are all about what day this week and the time,
# so formatting them with that in mind
#my $format = $conf->config('date_format') || '%Y-%m-%d';
#
#my $date_formatter = sub {
# my $time = parse_datetime($_[0], 'GMT');
# # exclude times within 24 hours of zero
# ($time > 86400) ? time2str($format, $time) : '';
#};
</%init>
|