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";
90 % my $Queue = $cust_main->agent->ticketing_queueid || 1; # || $default_queueid;#XXX really, pick pkg_category queue
91 % my $member = "freeside://freeside/cust_main/$custnum";
93 %warn my $Starts = int($tod_row/60). ':'. sprintf('%02d',$tod_row%60). ':00';
94 %warn my $Due = int(($tod_row+$LengthMin)/60). ':'.
95 % sprintf('%02d',($tod_row+$LengthMin)%60). ':00';
97 % my $url = $RT::WebPath. '/Ticket/Display.html?id=new'.
100 % '&Starts='. $Date->strftime('%F').'%20'. $Starts.
101 % '&Due='. $Date->strftime('%F').'%20'. $Due.
102 % '&new-MemberOf='. $member. #XXX uri_escape?
104 % #'&Requestors='. #XXX Freeside customer requestor(s) (package?
106 onmouseover = "boxon(this);"
107 onmouseout = "boxoff(this);"
108 title = "<% 'Make appointment for '.
109 FS::sched_avail::pretty_time($tod_row). '-'.
110 FS::sched_avail::pretty_time($tod_row+$LengthMin)
112 onclick = "window.location.href = '<% $url %>'"
120 <SCRIPT TYPE="text/javascript">
122 $('#<% $td_id %>').data('username', "<% $username %>");
123 $('#<% $td_id %>').data('starts', <% $Date->epoch + $tod_row*60 %>);
124 $('#<% $td_id %>').data('epoch', <% $Date->epoch %>);
125 $('#<% $td_id %>').data('tod_row', <% $tod_row %>);
127 % if ( $droppable ) {
128 $('#<% $td_id %>').droppable({
130 drop: reschedule_appointment,
135 % if ( $draggable_ticketid ) {
136 $('#<% $td_id %>').draggable({
137 containment: '.titlebox-content',
138 %# revert: 'invalid',
142 $('#<% $td_id %>').data('ticketid', <% $draggable_ticketid %>);
143 $('#<% $td_id %>').data('length', <% $draggable_length * 60 %>);
144 $('#<% $td_id %>').data('cells', <% $cells %>);
145 $('#<% $td_id %>').data('bgcolor', "#<% $bgcolor %>");
151 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
152 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
156 use RTx::Schedule qw( UserDaySchedule );
157 use FS::sched_avail; #just for pretty_time
159 #what happened? alas. for constructing the ticket creation links
160 use FS::Record qw( qsearchs );