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 % include('/elements/popup_link.html',
66 % action=>$RT::WebPath.'/Ticket/ModifyCustomFieldsPopup.html?id='.$id,
68 % actionlabel => 'Edit appointment',
69 % height => 436, # better: A + B * (num_custom_fields)
71 % $draggable_ticketid = $id;
72 % $draggable_length = $due - $starts;
74 % $cells = int( ($due-$starts) / $timestep );
75 % $cells++ if ($due-$starts) % $timestep;
78 % # $content .= ($content?', ':''). $id;
82 % my $td_id = 'td_'. $Date->epoch. '_'. $tod_row. '_'. $username;
84 <td style = "background-color:#<%$bgcolor%>"
86 class = "<% ($selectable && $custnum && $LengthMin) ? 'weeklyselectable' : 'weekly' %>"
87 %# <% $is_today ? 'today'
88 %# : $is_yesterday ? 'yesterday'
89 %# : $is_aweekago ? 'aweekago'
92 % if ( $selectable ) {
94 % if ( $custnum && $LengthMin ) {
96 % #XXX for now, construct a ticket creation URL
97 % # eventually, do much the same, but say "appointment made", show time
98 % # and date, have # options to do things with it? etc.
99 % # then redir back to customer/appointment view i guess
101 % #abstraction is leaking like a sieve... linking back to freeside cust
102 % # (XXX and eventually, package)
103 % my $cust_main = qsearchs('cust_main', { custnum=>$custnum } )
104 % or die "unknown custnum $custnum";
106 % my $conf = new FS::Conf;
107 % my $Queue = $conf->config('ticket_system-appointment-queueid')
108 % or die "ticket_system-appointment-queueid configuration not set";
110 % my $member = "freeside://freeside/cust_main/$custnum";
112 % my $Starts = int($tod_row/60). ':'. sprintf('%02d',$tod_row%60). ':00';
113 % my $Due = int(($tod_row+$LengthMin)/60). ':'.
114 % sprintf('%02d',($tod_row+$LengthMin)%60). ':00';
116 % my $url = $RT::WebPath. '/Ticket/Display.html?id=new'.
118 % "&Owner=$username".
119 % '&Starts='. $Date->strftime('%F').'%20'. $Starts.
120 % '&Due='. $Date->strftime('%F').'%20'. $Due.
121 % '&new-MemberOf='. $member. #XXX uri_escape?
123 % '&RedirectToBasics='.$RedirectToBasics;
124 % #'&Requestors='. #XXX Freeside customer requestor(s) (package?
126 onmouseover = "boxon(this);"
127 onmouseout = "boxoff(this);"
128 title = "<% 'Make appointment for '.
129 FS::sched_avail::pretty_time($tod_row). '-'.
130 FS::sched_avail::pretty_time($tod_row+$LengthMin)
132 onclick = "window.location.href = '<% $url %>'"
139 ><% $content |h %><% $link |n %></td>
140 <SCRIPT TYPE="text/javascript">
142 $('#<% $td_id %>').data('username', "<% $username %>");
143 $('#<% $td_id %>').data('starts', <% $Date->epoch + $tod_row*60 %>);
144 $('#<% $td_id %>').data('epoch', <% $Date->epoch %>);
145 $('#<% $td_id %>').data('tod_row', <% $tod_row %>);
147 % if ( $droppable ) {
148 $('#<% $td_id %>').droppable({
150 drop: reschedule_appointment,
155 % if ( $draggable_ticketid ) {
156 $('#<% $td_id %>').draggable({
157 containment: '.titlebox-content',
158 %# revert: 'invalid',
162 $('#<% $td_id %>').data('ticketid', <% $draggable_ticketid %>);
163 $('#<% $td_id %>').data('length', <% $draggable_length * 60 %>);
164 $('#<% $td_id %>').data('cells', <% $cells %>);
165 $('#<% $td_id %>').data('bgcolor', "#<% $bgcolor %>");
171 my $default_slots = RT->Config->Get('CalendarWeeklySlots') || 5;
172 my $default_timestep = RT->Config->Get('CalendarWeeklySizeMin') || 30; #1/2h
176 use RTx::Schedule qw( UserDaySchedule );
177 use FS::sched_avail; #just for pretty_time
179 #what happened? alas. for constructing the ticket creation links
180 use FS::Record qw( qsearchs );