version 1.126, 2015/09/23 23:04:53
|
version 1.128, 2015/09/25 16:13:00
|
Line 162 $js
|
Line 162 $js
|
var startdate = startm+"/"+startd+"/"+starty; |
var startdate = startm+"/"+startd+"/"+starty; |
var starttime = new Date(startdate).getTime(); |
var starttime = new Date(startdate).getTime(); |
starttime = starttime/1000; |
starttime = starttime/1000; |
|
var starth = form.start_hour.options[form.start_hour.selectedIndex].value; |
|
if (numberRegExp.test(starth)) { |
|
starth = parseInt(starth); |
|
if (starth > 0 && starth <= 23) { |
|
starttime += 3600 * starth; |
|
} |
|
} |
var enddate = endm+"/"+endd+"/"+endy; |
var enddate = endm+"/"+endd+"/"+endy; |
var endtime = new Date(enddate).getTime(); |
var endtime = new Date(enddate).getTime(); |
endtime = endtime/1000; |
endtime = endtime/1000; |
|
var endh = form.end_hour.options[form.end_hour.selectedIndex].value; |
|
if (numberRegExp.test(endh)) { |
|
endh = parseInt(endh); |
|
if (endh > 0 && endh <= 23) { |
|
endtime += 3600 * endh; |
|
} |
|
} |
|
|
var shown = 0; |
var shown = 0; |
for (var i=0; i<$i; i++) { |
for (var i=0; i<$i; i++) { |
if ((slotstart[i] >= starttime) && (slotend[i] <= endtime)) { |
if ((slotstart[i] >= starttime) && (slotend[i] <= endtime)) { |
Line 245 function uncheckSlotRadio() {
|
Line 260 function uncheckSlotRadio() {
|
} |
} |
} |
} |
} |
} |
|
|
|
function toggleSlotMap(maprownum) { |
|
if (document.getElementById('arrow'+maprownum)) { |
|
var img = document.getElementById('arrow'+maprownum); |
|
var rowdisplay; |
|
var celldisplay = ''; |
|
if (img.src.indexOf('arrow.open.gif')!=-1) { |
|
img.src = '/adm/lonIcons/arrow.closed.gif'; |
|
rowdisplay = 'none'; |
|
} |
|
else { |
|
img.src = '/adm/lonIcons/arrow.open.gif'; |
|
rowdisplay = 'table-row'; |
|
celldisplay = 'none'; |
|
} |
|
var resrows; |
|
var maptext; |
|
if (document.getElementsByClassName) { |
|
resrows = document.getElementsByClassName('LC_slotmaprow_'+maprownum); |
|
maptext = document.getElementsByClassName('LC_slotmaptext_'+maprownum); |
|
} else { |
|
resrows = getElementsByClassName(document.body,'LC_slotmaprow_'+maprownum); |
|
maptext = getElementsByClassName(document.body,'LC_slotmaptext_'+maprownum); |
|
} |
|
if (resrows.length) { |
|
for (var i=0; i<resrows.length; i++) { |
|
resrows[i].style.display = rowdisplay; |
|
} |
|
} |
|
if (maptext.length) { |
|
for (var i=0; i<maptext.length; i++) { |
|
maptext[i].style.display = celldisplay; |
|
} |
|
} |
|
} |
|
} |
// ]]> |
// ]]> |
</script> |
</script> |
ENDSCRIPT |
ENDSCRIPT |
Line 1043 sub get_description {
|
Line 1094 sub get_description {
|
} |
} |
|
|
sub show_choices { |
sub show_choices { |
my ($r,$symb,$formname,$num,$slots,$consumed_uniqueperiods,$available,$got_slots)=@_; |
my ($symb,$formname,$num,$class,$slots,$consumed_uniqueperiods,$available,$got_slots)=@_; |
my $output; |
my $output; |
&Apache::lonxml::debug("Checking Slots"); |
&Apache::lonxml::debug("Checking Slots"); |
if (!ref($available) eq 'ARRAY') { |
if (!ref($available) eq 'ARRAY') { |
Line 1055 sub show_choices {
|
Line 1106 sub show_choices {
|
$output .= ' <a href="/adm/flip?postdata=return:">'. |
$output .= ' <a href="/adm/flip?postdata=return:">'. |
&mt('Return to last resource').'</a>'; |
&mt('Return to last resource').'</a>'; |
} |
} |
$r->print($output); |
if ($class) { |
return; |
return '<div class="'.$class.'">'.$output.'</div>'; |
|
} else { |
|
return $output; |
|
} |
} |
} |
if (@{$available} > 1) { |
if (@{$available} > 1) { |
my $numavailable = scalar(@{$available}); |
my $numavailable = scalar(@{$available}); |
Line 1204 STUFF
|
Line 1258 STUFF
|
if (@{$available} > 1) { |
if (@{$available} > 1) { |
$output .= '</div></fieldset>'; |
$output .= '</div></fieldset>'; |
} |
} |
$r->print($output); |
if ($class) { |
return; |
return '<div class="'.$class.'">'.$output.'</div>'; |
|
} else { |
|
return $output; |
|
} |
} |
} |
|
|
sub to_show { |
sub to_show { |
Line 1769 sub manage_reservations {
|
Line 1826 sub manage_reservations {
|
'<table class="LC_data_table LC_tableOfContent">'."\n"; |
'<table class="LC_data_table LC_tableOfContent">'."\n"; |
my $shownheader = 0; |
my $shownheader = 0; |
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); |
my $it=$navmap->getIterator(undef,undef,undef,1,undef,undef); |
|
my (@ordered,%output,$mapitem,$got_map_slot,$currmapoutput,$mapnum); |
|
$mapnum = 0; |
while (my $resource = $it->next()) { |
while (my $resource = $it->next()) { |
if ($resource == $it->BEGIN_MAP()) { |
if ($resource == $it->BEGIN_MAP()) { |
|
@ordered=(); |
|
undef(%output); |
|
$currmapoutput = ''; |
|
$got_map_slot = ''; |
|
$mapitem = ''; |
$depth++; |
$depth++; |
$parent{$depth} = $lastcontainer; |
$parent{$depth} = $lastcontainer; |
} |
} |
if ($resource == $it->END_MAP()) { |
if ($resource == $it->END_MAP()) { |
$depth--; |
$depth--; |
$lastcontainer = $parent{$depth}; |
$lastcontainer = $parent{$depth}; |
|
my %allstatuses; |
|
foreach my $symb (@ordered) { |
|
if (ref($output{$symb}) eq 'HASH') { |
|
if (($output{$symb}{'type'} eq 'map_map') || ($output{$symb}{'type'} eq 'map')) { |
|
if ($output{$symb}{'slotstatus'} ne '') { |
|
if (ref($allstatuses{$output{$symb}{'slotstatus'}}) eq 'ARRAY') { |
|
push(@{$allstatuses{$output{$symb}{'slotstatus'}}},$symb); |
|
} else { |
|
$allstatuses{$output{$symb}{'slotstatus'}} = [$symb]; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (keys(%allstatuses) == 1) { |
|
$got_map_slot = 1; |
|
my $repsymb; |
|
my @values = values(%allstatuses); |
|
if (ref($values[0]) eq 'ARRAY') { |
|
if (ref($output{$values[0][0]}) eq 'HASH') { |
|
$repsymb = $values[0][0]; |
|
} |
|
} |
|
if (($mapitem) && ($repsymb)) { |
|
my $formnum = $mapnum.'_'.$output{$repsymb}{'reservable'}; |
|
my $class = 'LC_slotmaptext_'.$mapnum; |
|
if ($output{$repsymb}{'hasaction'}) { |
|
$mapitem .= '<td valign="top"><span class="'.$class.'">'. |
|
$output{$repsymb}{'msg'}. |
|
'</span></td><td valign="top">'. |
|
&slot_chooser($repsymb,$class,$formnum,$allavailable,$slots, |
|
$consumed_uniqueperiods). |
|
'</td>'; |
|
|
|
} else { |
|
$mapitem .= '<td colspan="2" valign="middle"><span class="'.$class.'">'. |
|
$output{$repsymb}{'msg'}. |
|
'</span></td>'; |
|
} |
|
} |
|
foreach my $symb (@ordered) { |
|
if (ref($output{$symb}) eq 'HASH') { |
|
my $bgcolor = $backgrounds[$output{$symb}{'rownum'} % $numcolors]; |
|
$currmapoutput .= $output{$symb}{'header'}. |
|
'<tr class="'.$bgcolor.' LC_slotmaprow_'.$output{$symb}{'mapnum'}.'"'. |
|
' style="display:none">'.$output{$symb}{'info'}. |
|
$output{$symb}{'data'}.'</tr>'."\n"; |
|
} |
|
} |
|
} else { |
|
foreach my $symb (@ordered) { |
|
if (ref($output{$symb}) eq 'HASH') { |
|
my $bgcolor = $backgrounds[$output{$symb}{'rownum'} % $numcolors]; |
|
$currmapoutput .= $output{$symb}{'header'}. |
|
'<tr class="'.$bgcolor.' LC_slotmaprow_'.$output{$symb}{'mapnum'}.'"'. |
|
' style="display:table-row">'.$output{$symb}{'info'}. |
|
$output{$symb}{'data'}.'</tr>'."\n"; |
|
} |
|
} |
|
} |
|
if ($mapitem) { |
|
if ($got_map_slot) { |
|
$mapitem =~ s{(<img src=\"/adm/lonIcons/arrow\.)open(\.gif\")}{$1closed$2}; |
|
$mapitem .= '</tr>'."\n"; |
|
} else { |
|
$mapitem .= '<td colspan="2"> </td></tr>'."\n"; |
|
} |
|
} |
|
$r->print($mapitem.$currmapoutput); |
} |
} |
if (ref($resource)) { |
if (ref($resource)) { |
my $symb = $resource->symb(); |
my $symb = $resource->symb(); |
my $ressymb = $symb; |
|
$contents{$lastcontainer} ++; |
$contents{$lastcontainer} ++; |
next if (!$resource->is_problem() && !$resource->is_sequence() && |
next if (!$resource->is_problem() && !$resource->is_sequence() && |
!$resource->is_page()); |
!$resource->is_page()); |
Line 1793 sub manage_reservations {
|
Line 1925 sub manage_reservations {
|
if ($resource->is_problem()) { |
if ($resource->is_problem()) { |
my ($useslots) = $resource->slot_control(); |
my ($useslots) = $resource->slot_control(); |
next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i)); |
next if (($useslots eq '') || ($useslots =~ /^\s*no\s*$/i)); |
|
push(@ordered,$symb); |
|
$output{$symb}{type} = $useslots; |
my ($msg,$get_choices,$slotdescription); |
my ($msg,$get_choices,$slotdescription); |
my $title = $resource->compTitle(); |
my $title = $resource->compTitle(); |
my $status = $resource->simpleStatus('0'); |
my $status = $resource->simpleStatus('0'); |
my ($slot_status,$date,$slot_name) = $resource->check_for_slot('0'); |
my ($slot_status,$date,$slot_name) = $resource->check_for_slot('0'); |
|
|
|
$output{$symb}{'slotstatus'} = $slot_status; |
|
$output{$symb}{'slotname'} = $slot_name; |
if ($slot_name ne '') { |
if ($slot_name ne '') { |
my %slot=&Apache::lonnet::get_slot($slot_name); |
my %slot=&Apache::lonnet::get_slot($slot_name); |
$slotdescription=&get_description($slot_name,\%slot); |
$slotdescription=&get_description($slot_name,\%slot); |
Line 1840 sub manage_reservations {
|
Line 1977 sub manage_reservations {
|
$msg = &Apache::lonnavmaps::getDescription($resource,'0'); |
$msg = &Apache::lonnavmaps::getDescription($resource,'0'); |
} |
} |
} |
} |
|
$output{$symb}{'msg'} = $msg; |
$reservable ++; |
$reservable ++; |
|
$output{$symb}{'reservable'} = $reservable; |
my $treelevel = $depth; |
my $treelevel = $depth; |
my $higherup = $lastcontainer; |
my $higherup = $lastcontainer; |
if ($depth > 1) { |
if ($depth > 1) { |
Line 1861 sub manage_reservations {
|
Line 2000 sub manage_reservations {
|
$treelevel --; |
$treelevel --; |
$higherup = $parent{$treelevel}; |
$higherup = $parent{$treelevel}; |
} |
} |
foreach my $item (@maprows) { |
for (my $i=0; $i<@maprows; $i++) { |
|
$mapnum ++; |
$rownum ++; |
$rownum ++; |
my $bgcolor = $backgrounds[$rownum % $numcolors]; |
my $bgcolor = $backgrounds[$rownum % $numcolors]; |
if (!$shownheader) { |
if (!$shownheader) { |
$r->print($slotheader); |
$mapitem .= $slotheader; |
$shownheader = 1; |
$shownheader = 1; |
} |
} |
$r->print('<tr class="'.$bgcolor.'">'.$item.'</tr>'."\n"); |
if (ref($maprows[$i]) eq 'ARRAY') { |
|
if ($i < scalar(@maprows)-1) { |
|
$mapitem .= '<tr class="'.$bgcolor.'"><td>'.join('',@{$maprows[$i]}).'</td>'. |
|
'<td colspan="2"> </td></tr>'."\n"; |
|
} else { |
|
$mapitem .= |
|
'<tr class="'.$bgcolor.'"><td>'.$maprows[$i][0]. |
|
'<img src="/adm/lonIcons/arrow.open.gif" id="arrow'.$mapnum.'" '. |
|
'alt="arrow" onmouseover="this.style.cursor=\'pointer\'" '. |
|
'onclick="'."toggleSlotMap('$mapnum');".'" />'. |
|
$maprows[$i][1].(' ' x6).'</td>'."\n"; |
|
} |
|
} |
} |
} |
|
$output{$symb}{'mapnum'} = $mapnum; |
} |
} |
$rownum ++; |
$rownum ++; |
my $bgcolor = $backgrounds[$rownum % $numcolors]; |
$output{$symb}{'rownum'} = $rownum; |
if (!$shownheader) { |
if (!$shownheader) { |
$r->print($slotheader); |
$output{$symb}{'header'} = $slotheader; |
$shownheader = 1; |
$shownheader = 1; |
} |
} |
$r->print('<tr class="'.$bgcolor.'"><td>'."\n"); |
$output{$symb}{'info'} = '<td>'; |
for (my $i=0; $i<$depth; $i++) { |
for (my $i=0; $i<$depth; $i++) { |
$r->print('<img src="'.$location.'" alt="" />'); |
$output{$symb}{'info'} .= '<img src="'.$location.'" alt="" />'; |
} |
} |
my $result = '<a href="'.$resource->src().'?symb='.$symb.'">'. |
$output{$symb}{'info'} .= '<a href="'.$resource->src().'?symb='.$symb.'">'. |
'<img class="LC_contentImage" src="/adm/lonIcons/'; |
'<img class="LC_contentImage" src="/adm/lonIcons/'; |
if ($resource->is_task()) { |
if ($resource->is_task()) { |
$result .= 'task.gif" alt="'.&mt('Task'); |
$output{$symb}{'info'} .= 'task.gif" alt="'.&mt('Task'); |
} else { |
} else { |
$result .= 'problem.gif" alt="'.&mt('Problem'); |
$output{$symb}{'info'} .= 'problem.gif" alt="'.&mt('Problem'); |
} |
} |
$result .= '" /><b>'.$title.'</b></a>'.(' ' x6).'</td>'; |
$output{$symb}{'info'} .= '" /><b>'.$title.'</b></a>'.(' ' x6).'</td>'; |
|
|
my $hasaction; |
my $hasaction; |
if ($status == $resource->OPEN) { |
if ($status == $resource->OPEN) { |
if ($get_choices) { |
if ($get_choices) { |
$hasaction = 1; |
$hasaction = 1; |
|
$output{$symb}{'hasaction'} = $hasaction; |
} |
} |
} |
} |
|
my $class = 'LC_slottext_'.$mapnum; |
if ($hasaction) { |
if ($hasaction) { |
$result .= '<td valign="top">'.$msg.'</td>'. |
$output{$symb}{'data'} = '<td valign="top"><span class="'.$class.'">'.$msg.'</span></td>'. |
'<td valign="top">'; |
'<td valign="top">'. |
|
&slot_chooser($symb,$class,$reservable,$allavailable,$slots, |
|
$consumed_uniqueperiods).'</td>'; |
} else { |
} else { |
$result .= '<td colspan="2" valign="middle">'.$msg.'</td>'; |
$output{$symb}{'data'} = '<td colspan="2" valign="middle">'. |
} |
'<span class="'.$class.'">'.$msg.'</span>'. |
$r->print($result); |
'</td>'; |
if ($hasaction) { |
|
my @got_slots=&check_for_reservation($symb,'allslots'); |
|
if ($got_slots[0] =~ /^error: /) { |
|
$r->print('<span class="LC_error">'. |
|
&mt('An error occurred determining slot availability.'). |
|
'</span>'); |
|
} else { |
|
my $formname = 'manageres_'.$reservable; |
|
if (ref($allavailable) eq 'ARRAY') { |
|
my @available; |
|
if (ref($slots) eq 'HASH') { |
|
foreach my $slot (@{$allavailable}) { |
|
# not allowed for this resource |
|
if (ref($slots->{$slot}) eq 'HASH') { |
|
if ((defined($slots->{$slot}->{'symb'})) && |
|
($slots->{$slot}->{'symb'} ne $symb)) { |
|
next; |
|
} |
|
} |
|
push(@available,$slot); |
|
} |
|
} |
|
&show_choices($r,$symb,$formname,$reservable,$slots,$consumed_uniqueperiods, |
|
\@available,\@got_slots); |
|
} |
|
} |
|
$r->print('</td>'); |
|
} |
} |
$r->print('</tr>'); |
|
} |
} |
} |
} |
} |
} |
Line 1952 sub manage_reservations {
|
Line 2082 sub manage_reservations {
|
|
|
sub show_map_row { |
sub show_map_row { |
my ($depth,$location,$type,$title,$maprows) = @_; |
my ($depth,$location,$type,$title,$maprows) = @_; |
my $output = '<td>'; |
my $spacers; |
for (my $i=0; $i<$depth-1; $i++) { |
for (my $i=0; $i<$depth-2; $i++) { |
$output .= '<img src="'.$location.'" alt="" />'; |
$spacers .= '<img src="'.$location.'" alt="" />'; |
} |
} |
|
my $icon; |
if ($type eq 'page') { |
if ($type eq 'page') { |
$output .= '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n"; |
$icon = '<img src="/adm/lonIcons/navmap.page.open.gif" alt="" /> '."\n"; |
} else { |
} else { |
$output .= '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n"; |
$icon = '<img src="/adm/lonIcons/navmap.folder.open.gif" alt="" /> '."\n"; |
} |
} |
$output .= $title.'</td><td colspan="2"> </td>'."\n"; |
$icon .= $title; |
unshift (@{$maprows},$output); |
unshift (@{$maprows},[$spacers,$icon]); |
return; |
return; |
} |
} |
|
|
|
sub slot_chooser { |
|
my ($symb,$class,$formnum,$allavailable,$slots,$consumed_uniqueperiods) = @_; |
|
my $output; |
|
my @got_slots=&check_for_reservation($symb,'allslots'); |
|
if ($got_slots[0] =~ /^error: /) { |
|
$output = '<span class="'.$class.'"><span class="LC_error">'. |
|
&mt('An error occurred determining slot availability.'). |
|
'</span></span>'; |
|
} else { |
|
my $formname = 'manageres_'.$formnum; |
|
if (ref($allavailable) eq 'ARRAY') { |
|
my @available; |
|
if (ref($slots) eq 'HASH') { |
|
foreach my $slot (@{$allavailable}) { |
|
# not allowed for this resource |
|
if (ref($slots->{$slot}) eq 'HASH') { |
|
if ((defined($slots->{$slot}->{'symb'})) && |
|
($slots->{$slot}->{'symb'} ne $symb)) { |
|
next; |
|
} |
|
} |
|
push(@available,$slot); |
|
} |
|
} |
|
$output .= &show_choices($symb,$formname,$formnum,$class, |
|
$slots,$consumed_uniqueperiods, |
|
\@available,\@got_slots); |
|
} |
|
} |
|
return $output; |
|
} |
|
|
sub show_reservations { |
sub show_reservations { |
my ($r,$uname,$udom) = @_; |
my ($r,$uname,$udom) = @_; |
if (!defined($uname)) { |
if (!defined($uname)) { |
Line 3018 sub handler {
|
Line 3181 sub handler {
|
} |
} |
if ($env{'form.requestattempt'}) { |
if ($env{'form.requestattempt'}) { |
$r->print('<div class="LC_left_float">'); |
$r->print('<div class="LC_left_float">'); |
&show_choices($r,$symb,undef,undef,\%slots,$consumed_uniqueperiods,$available,$got_slots); |
$r->print(&show_choices($symb,undef,undef,undef,\%slots,$consumed_uniqueperiods,$available,$got_slots)); |
$r->print('</div><div style="padding:0;clear:both;margin:0;border:0"></div>'); |
$r->print('</div><div style="padding:0;clear:both;margin:0;border:0"></div>'); |
} elsif ($env{'form.command'} eq 'release') { |
} elsif ($env{'form.command'} eq 'release') { |
&release_slot($r,$symb); |
&release_slot($r,$symb); |