4 $slots => $default_slots
7 $timestep => $default_timestep
9 $LengthMin => $default_timestep
13 % foreach my $username ( @username ) {
15 % my %schedule = UserDaySchedule( username => $username,
16 % 'date' => $Date->strftime('%F'),
17 % Tickets => \@Tickets,
20 % my $bgcolor = '666666;border-color:#555555';
23 % my $draggable_ticketid = 0;
24 % my $draggable_length = 0;
28 % #white out available times
29 % foreach my $avail ( @{ $schedule{'avail'} } ) {
30 % my( $start, $end ) = @$avail;
31 % next if $start >= ($tod_row+$timestep) || $end <= $tod_row;
32 % $bgcolor = 'FFFFFF';
34 % if $LengthMin <= $end - $tod_row #the slot is long enough
35 % && ! grep { $_ > $tod_row && $LengthMin > $_ - $tod_row }
36 % map $_->[0], values %{ $schedule{'scheduled'} };
39 % #block out / show / color code existing appointments
41 % foreach my $id ( keys %{ $schedule{'scheduled'} } ) {
43 % my( $starts, $due, $col, $t ) = @{ $schedule{'scheduled'}->{$id} };
45 % next if $starts >= ($tod_row+$timestep) || $due <= $tod_row;
50 % if ( $starts >= $tod_row ) { #first row
51 % $content .= ($content?', ':''). #$id. ': '.
52 % #false laziness w/xmlhttp-ticket-update.html
53 % FS::sched_avail::pretty_time($starts). '-'.
54 % FS::sched_avail::pretty_time($due);
55 % #'install for custname XX miles away'; #XXX placeholder/more
56 % $draggable_ticketid = $id;
57 % $draggable_length = $due - $starts;
59 % $cells = int( ($due-$starts) / $timestep );
60 % $cells++ if ($due-$starts) % $timestep;
63 % # $content .= ($content?', ':''). $id;
67 % my $td_id = 'td_'. $Date->epoch. '_'. $tod_row. '_'. $username;
69 <td style = "background-color:#<%$bgcolor%>"
71 class = "<% ($selectable && $custnum && $LengthMin) ? 'weeklyselectable' : 'weekly' %>"
72 %# <% $is_today ? 'today'
73 %# : $is_yesterday ? 'yesterday'
74 %# : $is_aweekago ? 'aweekago'
77 % if ( $selectable ) {
79 % if ( $custnum && $LengthMin ) {
81 % #XXX for now, construct a ticket creation URL
82 % # eventually, do much the same, but say "appointment made", show time
83 % # and date, have # options to do things with it? etc.
84 % # then redir back to customer/appointment view i guess
86 % #abstraction is leaking like a sieve... linking back to freeside cust
87 % # (XXX and eventually, package)
88 % my $cust_main = qsearchs('cust_main', { custnum=>$custnum } )
89 % or die "unknown custnum $custnum";
91 % my $conf = new FS::Conf;
92 % my $Queue = $conf->config('ticket_system-appointment-queueid')
93 % or die "ticket_system-appointment-queueid configuration not set";
95 % my $member = "freeside://freeside/cust_main/$custnum";
97 %warn my $Starts = int($tod_row/60). ':'. sprintf('%02d',$tod_row%60). ':00';
98 %warn my $Due = int(($tod_row+$LengthMin)/60). ':'.
99 % sprintf('%02d',($tod_row+$LengthMin)%60). ':00';
101 % my $url = $RT::WebPath. '/Ticket/Display.html?id=new'.
103 % "&Owner=$username".
104 % '&Starts='. $Date->strftime('%F').'%20'. $Starts.
105 % '&Due='. $Date->strftime('%F').'%20'. $Due.
106 % '&new-MemberOf='. $member. #XXX uri_escape?
108 % #'&Requestors='. #XXX Freeside customer requestor(s) (package?
110 onmouseover = "boxon(this);"
111 onmouseout = "boxoff(this);"
112 title = "<% 'Make appointment for '.
113 FS::sched_avail::pretty_time($tod_row). '-'.
114 FS::sched_avail::pretty_time($tod_row+$LengthMin)
116 onclick = "window.location.href = '<% $url %>'"
124 <SCRIPT TYPE="text/javascript">
126 $('#<% $td_id %>').data('username', "<% $username %>");
127 $('#<% $td_id %>').data('starts', <% $Date->epoch + $tod_row*60 %>);
128 $('#<% $td_id %>').data('epoch', <% $Date->epoch %>);
129 $('#<% $td_id %>').data('tod_row', <% $tod_row %>);
131 % if ( $droppable ) {
132 $('#<% $td_id %>').droppable({
134 drop: reschedule_appointment,
139 % if ( $draggable_ticketid ) {
140 $('#<% $td_id %>').draggable({
141 containment: '.titlebox-content',
142 %# revert: 'invalid',
146 $('#<% $td_id %>').data('ticketid', <% $draggable_ticketid %>);
147 $('#<% $td_id %>').data('length', <% $draggable_length * 60 %>);
148 $('#<% $td_id %>').data('cells', <% $cells %>);
149 $('#<% $td_id %>').data('bgcolor', "#<% $bgcolor %>");
155 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
156 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
160 use RTx::Schedule qw( UserDaySchedule );
161 use FS::sched_avail; #just for pretty_time
163 #what happened? alas. for constructing the ticket creation links
164 use FS::Record qw( qsearchs );