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';
24 % my $draggable_ticketid = 0;
25 % my $draggable_length = 0;
29 % #white out available times
30 % foreach my $avail ( @{ $schedule{'avail'} } ) {
31 % my( $start, $end ) = @$avail;
32 % next if $start >= ($tod_row+$timestep) || $end <= $tod_row;
33 % $bgcolor = 'FFFFFF';
35 % if $LengthMin <= $end - $tod_row #the slot is long enough
36 % && ! grep { $_ > $tod_row && $LengthMin > $_ - $tod_row }
37 % map $_->[0], values %{ $schedule{'scheduled'} };
40 % #block out / show / color code existing appointments
42 % foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
44 % my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
46 % next if $starts >= ($tod_row+$timestep) || $due <= $tod_row;
51 % if ( $starts >= $tod_row ) { #first row
53 % #false laziness w/misc/xmlhttp-ticket-update.html & CalendarDaySchedule
54 % my %hash = $m->comp('/Ticket/Elements/Customers', Ticket => $t);
55 % my @cust_main = values( %{$hash{cust_main}} );
57 % $content .= ($content?', ':''). #$id. ': '.
58 % #false laziness w/xmlhttp-ticket-update.html
59 % FS::sched_avail::pretty_time($starts). '-'.
60 % FS::sched_avail::pretty_time($due).
61 % ': '. $cust_main[0]->_FreesideURILabel;
62 % #'install for custname XX miles away'; #XXX placeholder/more
63 % $draggable_ticketid = $id;
64 % $draggable_length = $due - $starts;
66 % $cells = int( ($due-$starts) / $timestep );
67 % $cells++ if ($due-$starts) % $timestep;
70 % # $content .= ($content?', ':''). $id;
74 % my $td_id = 'td_'. $Date->epoch. '_'. $tod_row. '_'. $username;
76 <td style = "background-color:#<%$bgcolor%>"
78 class = "<% ($selectable && $custnum && $LengthMin) ? 'weeklyselectable' : 'weekly' %>"
79 %# <% $is_today ? 'today'
80 %# : $is_yesterday ? 'yesterday'
81 %# : $is_aweekago ? 'aweekago'
84 % if ( $selectable ) {
86 % if ( $custnum && $LengthMin ) {
88 % #XXX for now, construct a ticket creation URL
89 % # eventually, do much the same, but say "appointment made", show time
90 % # and date, have # options to do things with it? etc.
91 % # then redir back to customer/appointment view i guess
93 % #abstraction is leaking like a sieve... linking back to freeside cust
94 % # (XXX and eventually, package)
95 % my $cust_main = qsearchs('cust_main', { custnum=>$custnum } )
96 % or die "unknown custnum $custnum";
98 % my $conf = new FS::Conf;
99 % my $Queue = $conf->config('ticket_system-appointment-queueid')
100 % or die "ticket_system-appointment-queueid configuration not set";
102 % my $member = "freeside://freeside/cust_main/$custnum";
104 %warn my $Starts = int($tod_row/60). ':'. sprintf('%02d',$tod_row%60). ':00';
105 %warn my $Due = int(($tod_row+$LengthMin)/60). ':'.
106 % sprintf('%02d',($tod_row+$LengthMin)%60). ':00';
108 % my $url = $RT::WebPath. '/Ticket/Display.html?id=new'.
110 % "&Owner=$username".
111 % '&Starts='. $Date->strftime('%F').'%20'. $Starts.
112 % '&Due='. $Date->strftime('%F').'%20'. $Due.
113 % '&new-MemberOf='. $member. #XXX uri_escape?
115 % '&RedirectToBasics='.$RedirectToBasics;
116 % #'&Requestors='. #XXX Freeside customer requestor(s) (package?
118 onmouseover = "boxon(this);"
119 onmouseout = "boxoff(this);"
120 title = "<% 'Make appointment for '.
121 FS::sched_avail::pretty_time($tod_row). '-'.
122 FS::sched_avail::pretty_time($tod_row+$LengthMin)
124 onclick = "window.location.href = '<% $url %>'"
131 ><% $content |h %></td>
132 <SCRIPT TYPE="text/javascript">
134 $('#<% $td_id %>').data('username', "<% $username %>");
135 $('#<% $td_id %>').data('starts', <% $Date->epoch + $tod_row*60 %>);
136 $('#<% $td_id %>').data('epoch', <% $Date->epoch %>);
137 $('#<% $td_id %>').data('tod_row', <% $tod_row %>);
139 % if ( $droppable ) {
140 $('#<% $td_id %>').droppable({
142 drop: reschedule_appointment,
147 % if ( $draggable_ticketid ) {
148 $('#<% $td_id %>').draggable({
149 containment: '.titlebox-content',
150 %# revert: 'invalid',
154 $('#<% $td_id %>').data('ticketid', <% $draggable_ticketid %>);
155 $('#<% $td_id %>').data('length', <% $draggable_length * 60 %>);
156 $('#<% $td_id %>').data('cells', <% $cells %>);
157 $('#<% $td_id %>').data('bgcolor', "#<% $bgcolor %>");
163 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
164 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
168 use RTx::Schedule qw( UserDaySchedule );
169 use FS::sched_avail; #just for pretty_time
171 #what happened? alas. for constructing the ticket creation links
172 use FS::Record qw( qsearchs );