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';
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 % $link = qq( <A HREF="$RT::WebPath/Ticket/Display.html?id=$id" target="_blank">view</A> ).
64 % include('/elements/popup_link.html',
65 % action=>$RT::WebPath.'/Ticket/ModifyCustomFieldsPopup.html?id='.$id,
67 % actionlabel => 'Edit appointment',
68 % height => 436, # better: A + B * (num_custom_fields)
70 % $draggable_ticketid = $id;
71 % $draggable_length = $due - $starts;
73 % $cells = int( ($due-$starts) / $timestep );
74 % $cells++ if ($due-$starts) % $timestep;
77 % # $content .= ($content?', ':''). $id;
81 % my $td_id = 'td_'. $Date->epoch. '_'. $tod_row. '_'. $username;
83 <td style = "background-color:#<%$bgcolor%>"
85 class = "<% ($selectable && $custnum && $LengthMin) ? 'weeklyselectable' : 'weekly' %>"
86 %# <% $is_today ? 'today'
87 %# : $is_yesterday ? 'yesterday'
88 %# : $is_aweekago ? 'aweekago'
91 % if ( $selectable ) {
93 % if ( $custnum && $LengthMin ) {
95 % #XXX for now, construct a ticket creation URL
96 % # eventually, do much the same, but say "appointment made", show time
97 % # and date, have # options to do things with it? etc.
98 % # then redir back to customer/appointment view i guess
100 % #abstraction is leaking like a sieve... linking back to freeside cust
101 % # (XXX and eventually, package)
102 % my $cust_main = qsearchs('cust_main', { custnum=>$custnum } )
103 % or die "unknown custnum $custnum";
105 % my $conf = new FS::Conf;
106 % my $Queue = $conf->config('ticket_system-appointment-queueid')
107 % or die "ticket_system-appointment-queueid configuration not set";
109 % my $member = "freeside://freeside/cust_main/$custnum";
111 %warn my $Starts = int($tod_row/60). ':'. sprintf('%02d',$tod_row%60). ':00';
112 %warn my $Due = int(($tod_row+$LengthMin)/60). ':'.
113 % sprintf('%02d',($tod_row+$LengthMin)%60). ':00';
115 % my $url = $RT::WebPath. '/Ticket/Display.html?id=new'.
117 % "&Owner=$username".
118 % '&Starts='. $Date->strftime('%F').'%20'. $Starts.
119 % '&Due='. $Date->strftime('%F').'%20'. $Due.
120 % '&new-MemberOf='. $member. #XXX uri_escape?
122 % #'&Requestors='. #XXX Freeside customer requestor(s) (package?
124 onmouseover = "boxon(this);"
125 onmouseout = "boxoff(this);"
126 title = "<% 'Make appointment for '.
127 FS::sched_avail::pretty_time($tod_row). '-'.
128 FS::sched_avail::pretty_time($tod_row+$LengthMin)
130 onclick = "window.location.href = '<% $url %>'"
137 ><% $content |h %><% $link |n %></td>
138 <SCRIPT TYPE="text/javascript">
140 $('#<% $td_id %>').data('username', "<% $username %>");
141 $('#<% $td_id %>').data('starts', <% $Date->epoch + $tod_row*60 %>);
142 $('#<% $td_id %>').data('epoch', <% $Date->epoch %>);
143 $('#<% $td_id %>').data('tod_row', <% $tod_row %>);
145 % if ( $droppable ) {
146 $('#<% $td_id %>').droppable({
148 drop: reschedule_appointment,
153 % if ( $draggable_ticketid ) {
154 $('#<% $td_id %>').draggable({
155 containment: '.titlebox-content',
156 %# revert: 'invalid',
160 $('#<% $td_id %>').data('ticketid', <% $draggable_ticketid %>);
161 $('#<% $td_id %>').data('length', <% $draggable_length * 60 %>);
162 $('#<% $td_id %>').data('cells', <% $cells %>);
163 $('#<% $td_id %>').data('bgcolor', "#<% $bgcolor %>");
169 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
170 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
174 use RTx::Schedule qw( UserDaySchedule );
175 use FS::sched_avail; #just for pretty_time
177 #what happened? alas. for constructing the ticket creation links
178 use FS::Record qw( qsearchs );