customer view UI
[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 %# just a link for now,  should probably be FS::TicketSystem->href_schedule
6 %# maybe need to add a dropdown for type (install etc.) from a custom field
7 %# or maybe change to a popup and get that info there
8 % my @sched_item = qsearch('sched_item', { 'disabled' => '', });
9 % my @username = map $_->access_user->username, @sched_item;
10 % my $query = join('&', map "username=$_", @username).
11 %             '&LengthMin=180'. #XXX appointment length
12 %             '&custnum='. $cust_main->custnum; #.
13 %             #XXX '&pkgnum=$pkgnum";need to be for specific package/location, not just for a customer... default to active(/ordered) package in a pkg_class w/ticketing_queueid, otherwise, a popup?  we're getting complicated like form-creat_ticket.html
14 <A HREF="<%$p%>rt/Search/Schedule.html?<% $query %>">Make appointment</A>
15 % }
16
17 %#  |
18 %# View
19 %# <A HREF="<% $open_link %>"><% mt($openlabel) |h %></A> |
20 %# <A HREF="<% $res_link  %>"><% mt('resolved') |h %></A>
21  <BR>
22
23 %if ( @tickets ) {
24 <& /elements/table-grid.html &>
25 % my $bgcolor1 = '#eeeeee';
26 %   my $bgcolor2 = '#ffffff';
27 %   my $bgcolor = '';
28
29 <THEAD>
30 <TR>
31   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
32   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
33   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
34   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
35 </TR>
36 </THEAD>
37
38 % foreach my $ticket ( @tickets ) {
39 %     my $href = FS::TicketSystem->href_ticket($ticket->{id});
40 %     if ( $bgcolor eq $bgcolor1 ) {
41 %       $bgcolor = $bgcolor2;
42 %     } else {
43 %       $bgcolor = $bgcolor1;
44 %     }
45 %
46 %     use Date::Parse qw( str2time );
47 %     my $starts = str2time( $ticket->{starts} ); #default format here sucks
48 %     my $starts_pretty = '';
49 %     $starts_pretty = time2str('%a %h %o %Y %l:%M%P', $starts)
50 %       if $starts > 86400;
51
52   <TR>
53   
54     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
55       <A HREF=<%$href%>><% 'custom field magic type' %></A>
56     </TD>
57   
58     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
59       <A HREF=<%$href%>><% $starts_pretty %></A>
60     </TD>
61   
62     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
63       <% $ticket->{status} %>
64     </TD>
65   
66     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
67       <% $ticket->{owner} %>
68     </TD>
69
70   </TR>
71
72 % } 
73
74 </TABLE>
75 %}
76 <%init>
77
78 my $cust_main = shift;
79 my $object = $cust_main;
80
81 #total false laziness & just copied from elements/table-tickets.html
82
83 my %opt = @_;
84 my $conf = new FS::Conf;
85
86 return '' unless $conf->config('ticket_system');
87
88 #my $object = $opt{'object'};
89 #$object = $object->cust_svc if $object->isa('FS::svc_Common');
90 my( @tickets )  = $object->tickets; #XXX but actually appointments... filter by presense of the necessary CF?  RT::Appointment instead of RT::Ticket ?
91
92 my ($openlabel, $open_link, $res_link, $thing);
93 $openlabel = join('/', FS::TicketSystem->statuses );
94
95 # not the nicest way to do this--FS::has_tickets_Common?
96 #if ( $object->isa('FS::cust_main') ) {
97   $thing  = 'customer';
98   $open_link = FS::TicketSystem->href_customer_tickets($object->custnum);
99
100   $res_link  = FS::TicketSystem->href_customer_tickets(
101                     $object->custnum,
102                     { 'statuses' => [ 'resolved' ] }
103                   );
104 #} elsif ( $object->isa('FS::cust_svc') ) {
105 #
106 #  return '' unless $object->pkgnum;
107 #
108 #  $thing = 'service';
109 #  $open_link = FS::TicketSystem->href_service_tickets($object->svcnum);
110 #
111 #  $res_link  = FS::TicketSystem->href_service_tickets(
112 #                    $object->svcnum,
113 #                    { 'statuses' => [ 'resolved' ] }
114 #                  );
115 #}
116
117 #not actually used, appointments are all about what day this week and the time,
118 # so formatting them with that in mind
119 #my $format = $conf->config('date_format') || '%Y-%m-%d';
120 #
121 #my $date_formatter = sub {
122 #  my $time = parse_datetime($_[0], 'GMT');
123 #  # exclude times within 24 hours of zero
124 #  ($time > 86400) ? time2str($format, $time) : '';
125 #};
126
127 </%init>