c907b25bbd9ff9de00dc3c917f941b72d6190fd6
[freeside.git] / httemplate / view / cust_main / appointments.html
1 %# <& /elements/form-create_ticket.html, object => $object &>
2 <A NAME="appointments"><FONT CLASS="fsinnerbox-title">Appointments</FONT></A>
3
4 % if ( $FS::CurrentUser::CurrentUser->access_right('Make appointment') ) { 
5   <& /elements/popup_link-make_appointment.html, custnum=>$cust_main->custnum &>
6 % }
7
8 %#  |
9 %# View
10 %# <A HREF="<% $open_link %>"><% mt($openlabel) |h %></A> |
11 %# <A HREF="<% $res_link  %>"><% mt('resolved') |h %></A>
12  <BR>
13
14 %if ( @tickets ) {
15 <& /elements/table-grid.html &>
16 % my $bgcolor1 = '#eeeeee';
17 %   my $bgcolor2 = '#ffffff';
18 %   my $bgcolor = '';
19
20 <THEAD>
21 <TR>
22   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
23   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
24   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
25   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
26 </TR>
27 </THEAD>
28
29 % foreach my $ticket ( @tickets ) {
30 %     my $href = FS::TicketSystem->href_ticket($ticket->{id});
31 %     if ( $bgcolor eq $bgcolor1 ) {
32 %       $bgcolor = $bgcolor2;
33 %     } else {
34 %       $bgcolor = $bgcolor1;
35 %     }
36 %
37 %     use Date::Parse qw( str2time );
38 %     my $starts = str2time( $ticket->{starts} ); #default format here sucks
39 %     my $starts_pretty = '';
40 %     $starts_pretty = time2str('%a %h %o %Y %l:%M%P', $starts)
41 %       if $starts > 86400;
42
43   <TR>
44   
45     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
46       <A HREF=<%$href%>><% 'custom field magic type' %></A>
47     </TD>
48   
49     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
50       <A HREF=<%$href%>><% $starts_pretty %></A>
51     </TD>
52   
53     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
54       <% $ticket->{status} %>
55     </TD>
56   
57     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
58       <% $ticket->{owner} %>
59     </TD>
60
61   </TR>
62
63 % } 
64
65 </TABLE>
66 %}
67 <%init>
68
69 my $cust_main = shift;
70 my $object = $cust_main;
71
72 #total false laziness & just copied from elements/table-tickets.html
73
74 my %opt = @_;
75 my $conf = new FS::Conf;
76
77 return '' unless $conf->config('ticket_system');
78
79 #my $object = $opt{'object'};
80 #$object = $object->cust_svc if $object->isa('FS::svc_Common');
81 my( @tickets )  = $object->tickets; #XXX but actually appointments... filter by presense of the necessary CF?  RT::Appointment instead of RT::Ticket ?
82
83 my ($openlabel, $open_link, $res_link, $thing);
84 $openlabel = join('/', FS::TicketSystem->statuses );
85
86 # not the nicest way to do this--FS::has_tickets_Common?
87 #if ( $object->isa('FS::cust_main') ) {
88   $thing  = 'customer';
89   $open_link = FS::TicketSystem->href_customer_tickets($object->custnum);
90
91   $res_link  = FS::TicketSystem->href_customer_tickets(
92                     $object->custnum,
93                     { 'statuses' => [ 'resolved' ] }
94                   );
95 #} elsif ( $object->isa('FS::cust_svc') ) {
96 #
97 #  return '' unless $object->pkgnum;
98 #
99 #  $thing = 'service';
100 #  $open_link = FS::TicketSystem->href_service_tickets($object->svcnum);
101 #
102 #  $res_link  = FS::TicketSystem->href_service_tickets(
103 #                    $object->svcnum,
104 #                    { 'statuses' => [ 'resolved' ] }
105 #                  );
106 #}
107
108 #not actually used, appointments are all about what day this week and the time,
109 # so formatting them with that in mind
110 #my $format = $conf->config('date_format') || '%Y-%m-%d';
111 #
112 #my $date_formatter = sub {
113 #  my $time = parse_datetime($_[0], 'GMT');
114 #  # exclude times within 24 hours of zero
115 #  ($time > 86400) ? time2str($format, $time) : '';
116 #};
117
118 </%init>