9bec7b9ae0e802bcbc8ca19afd92f89187644254
[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 <& /elements/table-grid.html &>
24 % my $bgcolor1 = '#eeeeee';
25 %   my $bgcolor2 = '#ffffff';
26 %   my $bgcolor = '';
27
28 <TR>
29   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Type') |h %></TH>
30   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Date') |h %></TH>
31   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Status') |h %></TH>
32   <TH CLASS="grid" BGCOLOR="#cccccc"><% mt('Owner') |h %></TH>
33 </TR>
34
35 % foreach my $ticket ( @tickets ) {
36 %     my $href = FS::TicketSystem->href_ticket($ticket->{id});
37 %     if ( $bgcolor eq $bgcolor1 ) {
38 %       $bgcolor = $bgcolor2;
39 %     } else {
40 %       $bgcolor = $bgcolor1;
41 %     }
42 %
43 %     use Date::Parse qw( str2time );
44 %     my $starts = str2time( $ticket->{starts} ); #default format here sucks
45 %     my $starts_pretty = '';
46 %     $starts_pretty = time2str('%a %h %o %Y %l:%M%P', $starts)
47 %       if $starts > 86400;
48
49   <TR>
50   
51     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
52       <A HREF=<%$href%>><% 'custom field magic type' %></A>
53     </TD>
54   
55     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
56       <A HREF=<%$href%>><% $starts_pretty %></A>
57     </TD>
58   
59     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
60       <% $ticket->{status} %>
61     </TD>
62   
63     <TD CLASS="grid" BGCOLOR="<% $bgcolor %>">
64       <% $ticket->{owner} %>
65     </TD>
66
67   </TR>
68
69 % } 
70
71 </TABLE>
72
73 <%init>
74
75 my $cust_main = shift;
76 my $object = $cust_main;
77
78 #total false laziness & just copied from elements/table-tickets.html
79
80 my %opt = @_;
81 my $conf = new FS::Conf;
82
83 return '' unless $conf->config('ticket_system');
84
85 #my $object = $opt{'object'};
86 #$object = $object->cust_svc if $object->isa('FS::svc_Common');
87 my( @tickets )  = $object->tickets; #XXX but actually appointments... filter by presense of the necessary CF?  RT::Appointment instead of RT::Ticket ?
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>