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