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