print "" if $today
print $weekday; if (!$mode_static) { print " "; print $month_day
print "" if $today
print "
"
# a row for each resource ...
for $resource @$resources
resource_vars()
print $sep_h;
# a cell for each period ...
for $period @periods
period_vars()
booking_vars()
if param("reload")
param($cell_name, $booker)
# display the cell
display_cell()
# resource column, optional
resource_column()
print "
\n
\n"
sub display_periods_header
for $period @periods
period_vars()
if $class
print qq{
}
else
print qq{
}
print $period
if $class
print qq{
}
else
print qq{}
if defined $category
print $sep_h1
print qq{
}
print $category
print qq{
}
print $sep_v
sub resource_column
# XXX change to a variable, $multiple_resources ?
if defined $category
print $sep_h1
my $r = $resource
my $tt = "$description_of->{$resource}"
$r = nbspify($r)
$tt = nbspify("$r $tt")
print qq{
}.with_popup($r, $tt, "overlay_left").qq{
}
# print qq{
$resource
}
sub date_browser
if $mode_static
space(1)
elsif $mode_admin_any
# allow to book up to 52 weeks ahead, for now ...
# XXX maybe should allow to view the past too?
# highlight current week?
my $options = []
my $day = $monday1
for my $i 0..52
push @$options, $i
if $week_desc[$i]
push @$options, $week_desc[$i]
$day->forward_days(7)
else
my $week_desc = $day->mon_day()
$day->forward_days(4)
$week_desc .= " - ".$day->mon_day()
push @$options, $week_desc
$day->forward_days(3)
print left_right(
dropdown({no_prompt=>1, abbrev=>1, autosubmit=>1, selected=>$week}, 'week', $options),
# submit({name=>"go"})
)
else
# mode_normal
print left_mid_right(
submit({name=>"<<", (($week <= $week_min) ? (disabled => 1) : ())}),
week_desc($week),
submit({name=>">>", (($week >= $week_max) ? (disabled => 1) : ())}),
)
if !$mode_admin_any
print hidden("week")
# in admin mode, this is a dropdown, see above
sub selector
print qq{} if $fgcolor ne "black"
if $mode_normal
user_selector()
else
admin_selector()
print qq{} if $fgcolor ne "black"
sub info_selector
if $mode_normal && $my_cancelled
# a cancelled booking of mine
show_static_info_greyed()
elsif ($available || $info_editable)
# normal selector
my $ix = $mode_static ? $static_info_x->{$weekday} : $info_x->{$ymd2
my @o
for my $type @{$resource_info->{__order}}
my $info = $ix->{$period}{$resource_full}{$type
my @selected = defined $info ? (selected => $info) : ()
my $name = "$cell_name : $type" # XXX
if exists $conf->{types}{$type}
my $range = $conf->{types}{$type}{__order
push @o, dropdown({prompt=>"$type", @selected}, $name, $range)
else
push @o, qq{
print join " ", @o
elsif ($booker)
my $ix = $is_static ? $static_info_x->{$weekday} : $info_x->{$ymd2
show_info($ix)
sub show_static_info_greyed
print q{
show_info($static_info_x->{$weekday})
print q{
sub show_info
my ($ix) = @_
my @o
for my $type @{$resource_info->{__order}}
my $info = $ix->{$period}{$resource_full}{$type
if defined $info
push @o, $info
print join " ", @o
sub user_selector
checkbox_selector()
sub checkbox_selector
if $booker
if $cancellable
print checkbox($cell_name, 1, $booker, '')
# print qq{
print " "; # doesn't work. html should have a container or CSS property
else
param($cell_name, $booker)
print hidden($cell_name)
display_booker($booker)
elsif ($available)
print checkbox($cell_name, 0, $id, '')
# print qq{
else
if $editable_day
die "logic problem!"
sub admin_selector
if $available
# if $mode_admin_any
# print "
}
print dropdown($dropdown_opts, $cell_name, $options)." "
else
checkbox_selector()
sub display_booker
my $booker_name = $teacher_names->{$booker
# print with_popup($booker, "$booker_name $booker", "overlay_right")
print with_popup($booker, "$booker_name", "overlay_left")
sub display_resource_name
print qq{} if $fgcolor ne "black"
my $r = nbspify(encode_entities($resource))
if defined $description_of->{$resource}
my $tt = encode_entities($description_of->{$resource})
my $popup
$popup = with_tooltip($r, "$r $tt")
# if $mode_admin_any
# $popup = with_popup($r, "$r $tt", "overlay_left")
## $popup =~ s/(onMouseover=")/$1hide_if_exists('hideme_$cell_count'); /; # XXX HACK to hide the dropdown next to it
## $popup =~ s/(onMouseout=")/$1show_if_exists('hideme_$cell_count'); /
# else
# $popup = with_popup($r, "$r $tt", "overlay_left")
#
print $popup
else
print $r
print qq{} if $fgcolor ne "black"
# TODO make these generic?
sub clean_table
my ($rows, $ymd2_week_start) = @_
my $out = []
for @$rows
my ($ymd, $period, $resource, $who) = @$_
if $ymd ge $ymd2_week_start
push @$out, $_
return $out
sub is_holiday
my ($ymd2) = @_
# !inefficient!
# need binary lookup
for my $h @$holidays
my ($start, $end, $desc) = @$h
if $ymd2 ge $start and $ymd2 le $end
return $desc
return 0
#sub calendar_header
# # heading: category and resources
# print "
"
# print qq{
# print "
"
# if $category
## print "$category: " . join", ",@$resources
# print "$category"
# if exists $conf->{unlimited}{$category}
# print " (unlimited)"
#
# else
# print "@$resources"; # just one I hope!
# if exists $conf->{unlimited}{"@$resources"}
# print " (unlimited)"
#
#
#
## print " — "
##
## # week selector
## my $d = $monday1->dup
## print qq{\n\n"
## print qq{\n
#
# print "
\n"
# print qq{
#
# calendar_legend()
# print "
"
#
sub calendar_status
print qq{
my $firstname = $id
if $teacher_names->{$id}
$firstname = $teacher_names->{$id
$firstname =~ s/ .*//
print "$firstname,"
space(1)
if $mode_admin
print qq{you have admin powers.
elsif ($mode_static)
print qq{this is the timetable.
else
my $plural = $n_bookings == 0 ? "no bookings" : $n_bookings == 1 ? "one booking" : "$N{$n_bookings} bookings"
my $bookings_link = $n_bookings ? a({href=>"#my"}, $plural) : $plural
my $bookings_left = $n_bookings_left == 0 ? "none" : $N{$n_bookings_left
if $too_many_bookings
print "you have requested $plural."
else
print qq{you have made $bookings_link – $bookings_left left{
print qq{ }
if $too_many_bookings
nl()
msg("You are limited to $N{$max_bookings} bookings in any $N{$n_weeks} week period.")
msg("Please contact $conf->{administrator} if you need a higher limit.")
my $unlimited = $conf->{unlimited}{__order
if @$unlimited
my $x = join ", ", @$unlimited
msg("There is no limit for $x.")
sub calendar_controller
# save button
print q{ }; #save };