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