4 $slots => $default_slots
7 $timestep => $default_timestep
9 $LengthMin => $default_timestep
12 $RedirectToBasics => 0
14 % foreach my $username ( @username ) {
16 % my %schedule = UserDaySchedule( username => $username,
17 % 'date' => $Date->strftime('%F'),
18 % Tickets => \@Tickets,
21 % my $bgcolor = '666666;border-color:#555555';
25 % my $draggable_ticketid = 0;
26 % my $draggable_length = 0;
30 % #white out available times
31 % foreach my $avail ( @{ $schedule{'avail'} } ) {
32 % my( $start, $end ) = @$avail;
33 % next if $start >= ($tod_row+$timestep) || $end <= $tod_row;
34 % $bgcolor = 'FFFFFF';
36 % if $LengthMin <= $end - $tod_row #the slot is long enough
37 % && ! grep { $_ > $tod_row && $LengthMin > $_ - $tod_row }
38 % map $_->[0], values %{ $schedule{'scheduled'} };
41 % #block out / show / color code existing appointments
43 % foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
45 % my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
47 % next if $starts >= ($tod_row+$timestep) || $due <= $tod_row;
52 % if ( $starts >= $tod_row ) { #first row
54 % #false laziness w/misc/xmlhttp-ticket-update.html & CalendarDaySchedule
55 % my %hash = $m->comp('/Ticket/Elements/Customers', Ticket => $t);
56 % my @cust_main = values( %{$hash{cust_main}} );
58 % $content .= ($content?', ':''). #$id. ': '.
59 % #false laziness w/xmlhttp-ticket-update.html
60 % FS::sched_avail::pretty_time($starts). '-'.
61 % FS::sched_avail::pretty_time($due).
62 % ': '. $cust_main[0]->_FreesideURILabel;
63 % #'install for custname XX miles away'; #XXX placeholder/more
64 % $link = qq( <A HREF="$RT::WebPath/Ticket/Display.html?id=$id" target="_blank">view</A> );
65 %#needs higher version of rt
66 %# . include('/elements/popup_link.html',
67 %# action=>$RT::WebPath.'/Ticket/ModifyCustomFieldsPopup.html?id='.$id,
69 %# actionlabel => 'Edit appointment',
70 %# height => 436, # better: A + B * (num_custom_fields)
72 % $draggable_ticketid = $id;
73 % $draggable_length = $due - $starts;
75 % $cells = int( ($due-$starts) / $timestep );
76 % $cells++ if ($due-$starts) % $timestep;
79 % # $content .= ($content?', ':''). $id;
83 % my $td_id = 'td_'. $Date->epoch. '_'. $tod_row. '_'. $username;
85 <td style = "background-color:#<%$bgcolor%>"
87 class = "<% ($selectable && $custnum && $LengthMin) ? 'weeklyselectable' : 'weekly' %>"
88 %# <% $is_today ? 'today'
89 %# : $is_yesterday ? 'yesterday'
90 %# : $is_aweekago ? 'aweekago'
93 % if ( $selectable ) {
95 % if ( $custnum && $LengthMin ) {
97 % #XXX for now, construct a ticket creation URL
98 % # eventually, do much the same, but say "appointment made", show time
99 % # and date, have # options to do things with it? etc.
100 % # then redir back to customer/appointment view i guess
102 % #abstraction is leaking like a sieve... linking back to freeside cust
103 % # (XXX and eventually, package)
104 % my $cust_main = qsearchs('cust_main', { custnum=>$custnum } )
105 % or die "unknown custnum $custnum";
107 % my $conf = new FS::Conf;
108 % my $Queue = $conf->config('ticket_system-appointment-queueid')
109 % or die "ticket_system-appointment-queueid configuration not set";
111 % my $member = "freeside://freeside/cust_main/$custnum";
113 % my $Starts = int($tod_row/60). ':'. sprintf('%02d',$tod_row%60). ':00';
114 % my $Due = int(($tod_row+$LengthMin)/60). ':'.
115 % sprintf('%02d',($tod_row+$LengthMin)%60). ':00';
117 % my $url = $RT::WebPath. '/Ticket/Display.html?id=new'.
119 % "&Owner=$username".
120 % '&Starts='. $Date->strftime('%F').'%20'. $Starts.
121 % '&Due='. $Date->strftime('%F').'%20'. $Due.
122 % '&new-MemberOf='. $member. #XXX uri_escape?
124 % '&RedirectToBasics='.$RedirectToBasics;
125 % #'&Requestors='. #XXX Freeside customer requestor(s) (package?
127 onmouseover = "boxon(this);"
128 onmouseout = "boxoff(this);"
129 title = "<% 'Make appointment for '.
130 FS::sched_avail::pretty_time($tod_row). '-'.
131 FS::sched_avail::pretty_time($tod_row+$LengthMin)
133 onclick = "window.location.href = '<% $url %>'"
140 ><% $content |h %><% $link |n %></td>
141 <SCRIPT TYPE="text/javascript">
143 $('#<% $td_id %>').data('username', "<% $username %>");
144 $('#<% $td_id %>').data('starts', <% $Date->epoch + $tod_row*60 %>);
145 $('#<% $td_id %>').data('epoch', <% $Date->epoch %>);
146 $('#<% $td_id %>').data('tod_row', <% $tod_row %>);
148 % if ( $droppable ) {
149 $('#<% $td_id %>').droppable({
151 drop: reschedule_appointment,
156 % if ( $draggable_ticketid ) {
157 $('#<% $td_id %>').draggable({
158 containment: '.titlebox-content',
159 %# revert: 'invalid',
164 $('#<% $td_id %>').data('ticketid', <% $draggable_ticketid %>);
165 $('#<% $td_id %>').data('length', <% $draggable_length * 60 %>);
166 $('#<% $td_id %>').data('cells', <% $cells %>);
167 $('#<% $td_id %>').data('bgcolor', "#<% $bgcolor %>");
173 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
174 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
178 use RTx::Schedule qw( UserDaySchedule );
179 use FS::sched_avail; #just for pretty_time
181 #what happened? alas. for constructing the ticket creation links
182 use FS::Record qw( qsearchs );