'."\n".$form."\n".
+ &print_request_status($dom).'');
+ } elsif ($state eq 'details') {
+ my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
+ my $origcnum = $env{'form.cnum'};
+ if ($origcnum eq '') {
+ $origcnum = $env{'form.origcnum'};
+ }
+ if ($env{'form.crstype'} eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ }
+ $r->print('
'.&mt('Course Request Details').'
'."\n".$form."\n".
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
+ \@code_order)."\n".
+ ''."\n");
+ my @excluded = &get_excluded_elements($dom,$states,'new','review');
+ push(@excluded,'origcnum');
+ $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
+ my $other = 'modify';
+ my %navtxt = &Apache::lonlocal::texthash (
+ prev => 'Back',
+ other => 'Modify Request',
+ next => 'Cancel Request',
+ );
+ &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},
+ $state,$other,$navtxt{'other'});
+ $r->print('');
+ } elsif ($state eq 'cancel') {
+ my ($result,$output) = &print_cancel_request($dom,$env{'form.origcnum'});
+ $r->print('
'.&mt('Cancel course request').'
'."\n".$form."\n".
+ $output);
+ my @excluded = &get_excluded_elements($dom,$states,'view','cancel');
+ $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'
');
+ my %navtxt = &Apache::lonlocal::texthash (
+ prev => 'Back',
+ next => 'Confirm Cancellation',
+ );
+ if ($result eq 'ok') {
+ &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,
+ $navtxt{'next'},$state);
+ } else {
+ &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},undef,'',$state);
+ }
+ $r->print('');
+ } elsif ($state eq 'removal') {
+ my $cnum = $env{'form.origcnum'};
+ my $statuskey = 'status:'.$dom.':'.$cnum;
+ my %userreqhash = &Apache::lonnet::get('courserequests',[$statuskey],
+ $env{'user.domain'},$env{'user.name'});
+ my $currstatus = $userreqhash{$statuskey};
+ my ($result,$error);
+ if (($currstatus eq 'approval') || ($currstatus eq 'pending')) {
+ my %status = (
+ $statuskey => 'cancelled',
+ );
+ my $statusresult = &Apache::lonnet::put('courserequests',\%status);
+ if ($statusresult eq 'ok') {
+ my $delresult =
+ &Apache::lonnet::del_dom('courserequestqueue',
+ [$cnum.'_'.$currstatus],$dom);
+ if ($delresult eq 'ok') {
+ $result = 'ok';
+ } else {
+ $error = &mt('An error occurred when updating the pending requests queue: [_1]',$delresult);
+ }
+ } else {
+ $error = &mt("An error occurred when updating the status of this request in the requestor's records: [_1]",$statusresult);
+ }
+ } else {
+ $error = &mt('The current status of this request could not be verified as pending approval/institutional action.');
+ }
+ $r->print('
'.&mt('Request Cancellation').'
'."\n".$form."\n".
+ '
'."\n".
+ '
'."\n".
+ '
'."\n".
+ '
'."\n");
+ if ($result eq 'ok') {
+ $r->print(&mt('Your course request has been cancelled.'));
+ } else {
+ $r->print('
'.
+ &mt('The request cancellation process was not complete.').
+ '
'.$error.'
');
+ }
+ $r->print('');
+ }
+ } elsif ($action eq 'display') {
+ my $formname = 'requestcrs';
+ my (@codetitles,%cat_titles,%cat_order,@code_order,$instcode,$code_chk);
+ if ($env{'form.crstype'} eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ }
+ $r->print(&header('Course Request','','','',{ 'only_body' => 1}).
+ $crumb."\n".'
'.&mt('Course Request Details').'
'.
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,
+ \@code_order,$uname,$udom)."\n".'
'.
+ &close_popup_form());
} elsif ($action eq 'log') {
- $r->print(&coursereq_log());
+ $r->print(&coursereq_log('View request log',$jscript,$loaditems).$crumb);
}
+ $r->print(&Apache::loncommon::end_page());
return;
}
+sub close_popup_form {
+ my $close= &mt('Close Window');
+ return << "END";
+
+END
+}
+
sub print_request_form {
- my ($r,$state,$dom) = @_;
+ my ($r,$action,$state,$page,$states,$dom) = @_;
my $formname = 'requestcrs';
- my ($next,$prev,$message,$output,$codepicker);
- my $prev = 'crstype';
+ my ($next,$prev,$message,$output,$codepicker,$crstype);
+ $prev = $states->{$action}[$page-1];
+ $next = $states->{$action}[$page+1];
+ my %navtxt = &Apache::lonlocal::texthash (
+ prev => 'Back',
+ next => 'Next',
+ );
+ $crstype = $env{'form.crstype'};
$r->print('
';
} else {
$message = ''.
&mt('No course was found matching your choice of institutional course category.');
@@ -324,80 +854,860 @@ sub print_request_form {
}
$message .= '
';
}
+ } else {
+ $message = ''.
+ &mt('No course was found matching your choice of institutional course category.');
}
+ unless ($code_chk eq 'valid') {
+ $prev = 'crstype';
+ }
+ $r->print($message);
+ }
+ }
+ if ($prev eq 'crstype') {
+ if ($crstype eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
}
- unless ($prev eq 'codepick') {
+ if (@code_order > 0) {
$codepicker = &coursecode_form($dom,'instcode',\@codetitles,
\%cat_titles,\%cat_order);
+ if ($codepicker) {
+ $r->print('
'.&Apache::lonhtmlcommon::start_pick_box().$codepicker.
+ &Apache::lonhtmlcommon::end_pick_box().'
');
+ } else {
+ $next = $states->{$action}[$page+2];
+ $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
+ }
+ } else {
+ if ($crstype eq 'official') {
+ $next = $states->{$action}[$page+2];
+ }
+ $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
+ }
+ } elsif ($prev eq 'codepick') {
+ if ($env{'form.instcode'} eq '') {
+ $prev = $states->{$action}[$page-2];
}
+ $r->print(&courseinfo_form($dom,$formname,$crstype,$next));
+ } elsif ($state eq 'enrollment') {
+ if ($crstype eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ }
+ $r->print(&print_enrollment_menu($formname,$instcode,$dom,\@codetitles,
+ \%cat_titles,\%cat_order,\@code_order));
+ } elsif ($state eq 'personnel') {
+ $r->print(&print_personnel_menu($dom,$formname,$crstype));
+ } elsif ($state eq 'review') {
+ my $cnum;
+ if ($env{'form.origcnum'} =~ /^($match_courseid)$/) {
+ $cnum = $env{'form.origcnum'};
+ } else {
+ $cnum = &Apache::lonnet::generate_coursenum($dom);
+ }
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ $r->print('
'.&mt('Review the details of the course request before submission.').'
'.
+ &print_review($dom,\@codetitles,\%cat_titles,\%cat_order,\@code_order).
+ '
');
+ $navtxt{'next'} = &mt('Submit course request');
+ } elsif ($state eq 'process') {
+ if ($crstype eq 'official') {
+ &Apache::lonnet::auto_possible_instcodes($dom,\@codetitles,\%cat_titles,
+ \%cat_order,\@code_order);
+ }
+ my $result = &print_request_outcome($dom,\@codetitles,\@code_order);
+ $r->print($result);
+ }
+ my @excluded = &get_excluded_elements($dom,$states,$action,$state);
+ if ($state eq 'personnel') {
+ push(@excluded,'persontotal');
}
- $r->print($message.'
'.&Apache::lonhtmlcommon::start_pick_box());
- if ($output ne '') {
- $r->print($output);
- }
- if ($codepicker) {
- $r->print($codepicker);
- $state = 'codepick';
- $next = 'courseinfo';
- } else {
- $r->print(&courseinfo_form());
- $state = 'courseinfo';
- $next = 'review';
- }
- $r->print(&Apache::lonhtmlcommon::end_pick_box().'
'."\n");
- unless ($codepicker) {
- $r->print('
'.&clone_form($dom,$formname,$crstype).'
'."\n");
- }
- $r->print('
'.
- &Apache::lonhtmlcommon::echo_form_input(['state']).'');
- &display_navbuttons($r,$formname,$prev,'Previous',$next,'Next');
+ $r->print(&Apache::lonhtmlcommon::echo_form_input(\@excluded).'');
+ &display_navbuttons($r,$formname,$prev,$navtxt{'prev'},$next,$navtxt{'next'},$state);
return;
}
+sub get_excluded_elements {
+ my ($dom,$states,$action,$state) = @_;
+ my @excluded = ('counter');
+ my %elements = &form_elements($dom);
+ if (ref($states) eq 'HASH') {
+ if (ref($states->{$action}) eq 'ARRAY') {
+ my @items = @{$states->{$action}};
+ my $numitems = scalar(@items);
+ if ($numitems) {
+ for (my $i=$numitems-1; $i>=0; $i--) {
+ if (ref($elements{$action}) eq 'HASH') {
+ if (ref($elements{$action}{$items[$i]}) eq 'HASH') {
+ foreach my $key (keys(%{$elements{$action}{$items[$i]}})) {
+ push(@excluded,$key);
+ }
+ }
+ }
+ last if ($items[$i] eq $state);
+ }
+ }
+ }
+ }
+ if (grep(/^instcode_/,@excluded)) {
+ push(@excluded,'instcode');
+ }
+ return @excluded;
+}
+
+sub print_enrollment_menu {
+ my ($formname,$instcode,$dom,$codetitles,$cat_titles,$cat_order,$code_order) =@_;
+ my ($sections,$autoenroll,$access_dates);
+ my $starttime = time;
+ my $endtime = time+(6*30*24*60*60); # 6 months from now, approx
+
+ my %accesstitles = (
+ 'start' => 'Default start access',
+ 'end' => 'Default end access',
+ );
+ my %enrolltitles = (
+ 'start' => 'Start auto-enrollment',
+ 'end' => 'End auto-enrollment',
+ );
+ if ($env{'form.crstype'} eq 'official') {
+ if (&Apache::lonnet::auto_run('',$dom)) {
+ my ($section_form,$crosslist_form,$autoenroll_form);
+ $section_form = &inst_section_selector($dom,$instcode);
+ my $crosslisttotal = $env{'form.crosslisttotal'};
+ if (!$crosslisttotal) {
+ $crosslisttotal = 1;
+ }
+ if ($env{'form.addcrosslist'}) {
+ $crosslisttotal ++;
+ }
+ for (my $i=0; $i<$crosslisttotal; $i++) {
+ $crosslist_form .= &coursecode_form($dom,'crosslist',$codetitles,
+ $cat_titles,$cat_order,$i);
+ }
+ if ($crosslist_form) {
+ $crosslist_form .=
+ &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
+ '
'.
+ '
'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1);
+ }
+ if ($section_form || $crosslist_form) {
+ $sections = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ $section_form.$crosslist_form.
+ &Apache::lonhtmlcommon::end_pick_box().'
'."\n";
+ }
+ $autoenroll_form =
+ &Apache::lonhtmlcommon::row_title(&mt('Add registered students automatically')).
+ '
'.(' 'x3).''.
+ &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title(&mt('Drop unregistered students automatically')).
+ '
'.(' 'x3).''.
+ &Apache::lonhtmlcommon::row_closure().
+ &date_setting_table($starttime,$endtime,$formname,'enroll',%enrolltitles);
+ if ($autoenroll_form) {
+ $autoenroll = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ $autoenroll_form.
+ &Apache::lonhtmlcommon::end_pick_box().'
'."\n";
+ }
+ }
+ }
+ my $access_dates_form =
+ &date_setting_table($starttime,$endtime,$formname,'access',%accesstitles);
+ if ($access_dates_form) {
+ $access_dates = '
'.&Apache::lonhtmlcommon::start_pick_box().
+ $access_dates_form.
+ &Apache::lonhtmlcommon::end_pick_box().'
'."\n";
+ }
+ return $sections.$autoenroll.$access_dates;
+}
+
sub inst_section_selector {
- my ($sections,$selected) = @_;
+ my ($dom,$instcode) = @_;
+ my @sections = &Apache::lonnet::auto_get_sections(undef,$dom,$instcode);
+ my $sectotal = scalar(@sections);
my $output;
- if (ref($sections) eq 'ARRAY') {
- $output = &Apache::lonhtmlcommon::row_title('Sections').
- &Apache::loncommon::start_data_table().
- &Apache::loncommon::start_data_table_row().
- '
'.&mt('Institutional Section').' | '.
- '
'.&mt('LON-CAPA section ID').' | '.
- '
'.&mt('Include in course?').' | '.
- &Apache::loncommon::end_data_table_row();
- for (my $i=0; $i<@{$sections}; $i++) {
+ if ($sectotal) {
+ $output .= &Apache::lonhtmlcommon::row_title('Sections').
+ &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_row().
+ '
'.&mt('Include?').' | '.
+ '
'.&mt('Institutional Section').' | '.
+ '
'.&mt('LON-CAPA section').' | '.
+ &Apache::loncommon::end_data_table_row();
+ for (my $i=0; $i<@sections; $i++) {
my $colflag = $i%2;
+ my $checked = ' checked="checked"';
+ if ($env{'form.origcnum'}) {
+ $checked='';
+ }
$output .= &Apache::loncommon::start_data_table_row().
- '
'.$sections->[$i].
+ ' | | '.
+ '
'.$sections[$i].
' | '.
+ $sections[$i].'" />'.
'
| '.
- '
| '.
+ '" value="'.$sections[$i].'" />'.
&Apache::loncommon::end_data_table_row();
}
- $output .= &Apache::loncommon::end_data_table();
+ $output .= &Apache::loncommon::end_data_table().
+ &Apache::lonhtmlcommon::row_closure();
}
return $output;
}
+sub date_setting_table {
+ my ($starttime,$endtime,$formname,$prefix,%datetitles) = @_;
+ my ($perpetual,$table);
+ my $startform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'start',
+ $starttime,'','','',1,'','','',1);
+ my $endform = &Apache::lonhtmlcommon::date_setter($formname,$prefix.'end',
+ $endtime,'','','',1,'','','',1);
+ if ($prefix eq 'access') {
+ $perpetual = '
';
+ }
+ $table = &Apache::lonhtmlcommon::row_title($datetitles{'start'}).
+ $startform.
+ &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title($datetitles{'end'}).
+ $endform.$perpetual.
+ &Apache::lonhtmlcommon::row_closure(1);
+ return $table;
+}
+
+sub print_personnel_menu {
+ my ($dom,$formname,$crstype) = @_;
+ my $output = '
'.&Apache::lonhtmlcommon::start_pick_box();
+ my $persontotal = $env{'form.persontotal'};
+ if ((!defined($persontotal)) || (!$persontotal)) {
+ $persontotal = 1;
+ }
+ if ($env{'form.addperson'}) {
+ $persontotal ++;
+ }
+ my $userlinktxt = &mt('Set User');
+ my @items = ('uname','dom','lastname','firstname','emailaddr','hidedom');
+
+ my $roleoptions;
+ my @roles = &Apache::lonuserutils::roles_by_context('course');
+ my $type = 'Course';
+ if ($crstype eq 'community') {
+ $type = 'Community';
+ }
+ foreach my $role (@roles) {
+ my $plrole=&Apache::lonnet::plaintext($role,$type);
+ $roleoptions .= '
'."\n";
+ }
+ my %customroles=&Apache::lonuserutils::my_custom_roles();
+ if (keys(%customroles) > 0) {
+ foreach my $cust (sort(keys(%customroles))) {
+ my $custrole='cr_cr_'.$env{'user.domain'}.
+ '_'.$env{'user.name'}.'_'.$cust;
+ $roleoptions .= '
'."\n";
+ }
+ }
+
+ my @currsecs;
+ if ($env{'form.sectotal'}) {
+ for (my $i=0; $i<$env{'form.sectotal'}; $i++) {
+ if (defined($env{'form.loncapasec_'.$i})) {
+ my $lcsec = $env{'form.loncapasec_'.$i};
+ unless (grep(/^\Q$lcsec\E$/,@currsecs)) {
+ push(@currsecs,$lcsec);
+ }
+ }
+ }
+ }
+
+ my ($existtitle,$existops,$existmult,$newtitle,$seccolspan);
+ if (@currsecs) {
+ my $existsize = scalar(@currsecs);
+ if ($existsize > 3) {
+ $existsize = 3;
+ }
+ if ($existsize > 1) {
+ $existmult = ' multiple="multiple" size="'.$existsize.'" ';
+ }
+ @currsecs = sort { $a <=> $b } (@currsecs);
+ $existtitle = &mt('Official').': ';
+ $existops = '
';
+ foreach my $sec (@currsecs) {
+ $existops .= '
'."\n";
+ }
+ $seccolspan = ' colspan="2"';
+ $newtitle = &mt('Other').': ';
+ }
+
+ for (my $i=0; $i<$persontotal; $i++) {
+ my @linkargs = map { 'person_'.$i.'_'.$_ } (@items);
+ my $linkargstr = join("','",@linkargs);
+ my $userlink = &Apache::loncommon::selectuser_link($formname,@linkargs,$dom,$userlinktxt);
+ my $uname_form = '
';
+ my $onchange = 'javascript:fix_domain('."'$formname','person_".$i."_dom',".
+ "'person_".$i."_hidedom'".');'.
+ 'openuserbrowser('."'$formname','$linkargstr','$dom'".');';
+ my $udom_form = &Apache::loncommon::select_dom_form($dom,'person_'.$i.'_dom','',
+ 1,$onchange).
+ '
';
+ my %form_elems;
+ foreach my $item (@items) {
+ next if (($item eq 'dom') || ($item eq 'uname') || ($item eq 'hidedom'));
+ $form_elems{$item} = '
';
+ }
+ my $roleselector = '
';
+ my $sectionselector;
+ if (@currsecs) {
+ $sectionselector = $existtitle.'
'.(' ' x3);
+ }
+ $sectionselector .= $newtitle.
+ '
'."\n";
+ $output .=
+ &Apache::lonhtmlcommon::row_title(&mt('Additional Personnel').'
'.
+ '
'.$userlink.
+ '').
+ '
'.&mt('Username').' '.$uname_form.' | '."\n".
+ ''.&mt('Domain').' '.$udom_form.' |
'."\n".
+ ''.&mt('First Name').' '.$form_elems{'firstname'}.' | '."\n".
+ ''.&mt('Last Name').' '.$form_elems{'lastname'}.' | '."\n".
+ ''.&mt('E-mail').' '.$form_elems{'emailaddr'}.' |
'."\n".
+ ''.&mt('Role').' '.$roleselector.' | '."\n".
+ ''.&mt('Section(s)').' '.$sectionselector.' | '."\n".
+ '
'.&Apache::lonhtmlcommon::row_closure();
+ }
+ $output .= &Apache::lonhtmlcommon::row_title(&mt('Add another?')).
+ '
'.
+ '
'.&mt('Add?').&Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box().'
';
+ return $output;
+}
+
sub print_request_status {
+ my ($dom) = @_;
+ my %statusinfo = &Apache::lonnet::dump('courserequests',$env{'user.domain'},
+ $env{'user.name'},'^status:'.$dom);
+ my ($output,$formname,%queue_by_date,%typenames);
+ if ($env{'form.crstype'} eq 'any') {
+ %typenames = &Apache::lonlocal::texthash (
+ official => 'Official course',
+ unofficial => 'Unofficial course',
+ community => 'Community',
+ );
+ }
+ foreach my $key (keys(%statusinfo)) {
+ if (($statusinfo{$key} eq 'approval') || ($statusinfo{$key} eq 'pending')) {
+ (undef,my($cdom,$cnum)) = split(':',$key);
+ next if ($cdom ne $dom);
+ my $requestkey = $cdom.'_'.$cnum;
+ if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
+ my %history = &Apache::lonnet::restore($requestkey,'courserequests',
+ $env{'user.domain'},$env{'user.name'});
+ my $entry;
+ my $timestamp = $history{'reqtime'};
+ my $crstype = $history{'crstype'};
+ my $disposition = $history{'disposition'};
+ next if ((exists($history{'status'})) && ($history{'status'} eq 'created'));
+ next unless (($env{'form.crstype'} eq 'any') ||
+ ($env{'form.crstype'} eq $crstype));
+ next unless (($disposition eq 'approval') ||
+ ($disposition eq 'pending'));
+ if (ref($history{'details'}) eq 'HASH') {
+ $entry = $requestkey.':'.$crstype.':'.
+ &escape($history{'details'}{'cdescr'});
+ if ($crstype eq 'official') {
+ $entry .= ':'.&escape($history{'details'}{'instcode'});
+ }
+ }
+ if ($entry ne '') {
+ if (exists($queue_by_date{$timestamp})) {
+ if (ref($queue_by_date{$timestamp}) eq 'ARRAY') {
+ push(@{$queue_by_date{$timestamp}},$entry);
+ }
+ } else {
+ @{$queue_by_date{$timestamp}} = ($entry);
+ }
+ }
+ }
+ }
+ }
+ $formname = 'requestcrs';
+ my @sortedtimes = sort {$a <=> $b} (keys(%queue_by_date));
+ $output = '
'."\n".
+
+ '
'."\n".
+ '
'."\n".
+ '
'."\n".
+ '
'."\n";
+ if (@sortedtimes > 0) {
+ $output .= &Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '
'.&mt('Action').' | '.
+ '
'.&mt('Course Description').' | '.
+ '
'.&mt('Domain').' | ';
+ if ($env{'form.crstype'} eq 'any') {
+ $output .= '
'.&mt('Type').' | ';
+ }
+ if (($env{'form.crstype'} eq 'any') || ($env{'form.crstype'} eq 'official')) {
+ $output .= '
'.&mt('Institutional Code').' | ';
+ }
+ $output .= '
'.&mt('Date requested').' | '.
+ &Apache::loncommon::end_data_table_header_row();
+ my $count = 0;
+ foreach my $item (@sortedtimes) {
+ my $showtime = &Apache::lonlocal::locallocaltime($item);
+ if (ref($queue_by_date{$item}) eq 'ARRAY') {
+ foreach my $request (sort(@{$queue_by_date{$item}})) {
+ my ($key,$type,$desc,$instcode) = split(':',$request);
+ my ($cdom,$cnum) = split('_',$key);
+ $output .= &Apache::loncommon::start_data_table_row().
+ '
| '.
+ '
'.&unescape($desc).' | '.
+ '
'.$cdom.' | ';
+ if ($env{'form.crstype'} eq 'any') {
+ my $typename = $typenames{$type};
+ if ($typename eq '') {
+ $typename = &mt('Unknown type');
+ }
+ $output .= '
'.$typename.' | ';
+ }
+ if (($env{'form.crstype'} eq 'any') ||
+ ($env{'form.crstype'} eq 'official')) {
+ my $showinstcode;
+ if ($type eq 'official') {
+ $showinstcode = &unescape($instcode);
+ } else {
+ $showinstcode = &mt('Not applicable');
+ }
+ $output .= '
'.$showinstcode.' | ';
+ }
+ $output .= '
'.$showtime.' | '.
+ &Apache::loncommon::end_data_table_row();
+ }
+ }
+ }
+ $output .= &Apache::loncommon::end_data_table();
+ } else {
+ $output .= '
'.&mt('You have no matching course requests awaiting approval by a Domain Coordinator or held in a queue pending administrative action at your institution.').'
';
+ }
+ $output .= '
+
+
';
+ return $output;
+}
+
+sub print_cancel_request {
+ my ($dom,$cnum) = @_;
+ my $requestkey = $dom.'_'.$cnum;
+ my ($result,$output);
+ if ($requestkey =~ /^($match_domain)_($match_courseid)$/) {
+ my %history = &Apache::lonnet::restore($requestkey,'courserequests',
+ $env{'user.domain'},$env{'user.name'});
+ my $timestamp = $history{'reqtime'};
+ my $crstype = $history{'crstype'};
+ my $status = $history{'status'};
+ if (($status eq 'cancelled') || ($status eq 'created')) {
+ if ($status eq 'cancelled') {
+ $output = &mt('This request has already been cancelled.');
+ } elsif ($status eq 'created') {
+ $output = &mt('This request has already been processed, and a course created.');
+ }
+ $output = &mt('No further action will be taken');
+ } elsif (ref($history{'details'}) eq 'HASH') {
+ my ($types,$typename) = &course_types();
+ my $showtype = $crstype;
+ if (defined($typename->{$crstype})) {
+ $showtype = $typename->{$crstype};
+ }
+ $output = ''.&Apache::loncommon::start_data_table().
+ &Apache::loncommon::start_data_table_header_row().
+ '
'.
+ &mt('Cancelling the request will remove it from the queue of pending course requests').'
';
+ $result = 'ok';
+ } else {
+ $output = ''.&Apache::lonhtmlcommon::start_pick_box().
+ &Apache::lonhtmlcommon::row_title('Course Description').
+ '';
+ my ($home_server_pick,$numlib) =
+ &Apache::loncommon::home_server_form_item($dom,'chome',
+ 'default','hide');
+ if ($numlib > 1) {
+ $output .= &Apache::lonhtmlcommon::row_closure().
+ &Apache::lonhtmlcommon::row_title(&mt('Home Server for Course'));
+ }
+ $output .= $home_server_pick.
+ &Apache::lonhtmlcommon::row_closure(1).
+ &Apache::lonhtmlcommon::end_pick_box().'
'.
+ '