head);
unset($table->align);
unset($table->size);
unset($table->wrap);
if ($order=='ASC') $order = 'DESC';
else $order = 'ASC';
$linkurl = $wwwBaseUrl.'&action=crslist&slctyear='.$slctyear;
$dateurl = $linkurl.'&sort=date';
$crsurl = $linkurl.'&sort=fullname';
// Header
$table->head [] = '#';
$table->align[] = 'right';
$table->size [] = '20px';
$table->wrap [] = 'nowrap';
if ($sort=='date') $dateurl.= '&order='.$order;
$table->head [] = ''.get_string('startdate','homeroom').'';
$table->align[] = 'center';
$table->size [] = '80px';
$table->wrap [] = 'nowrap';
if ($sort=='fullname') $crsurl.= '&order='.$order;
$table->head [] = ''.get_string('course', 'homeroom').'';
$table->align[] = 'left';
$table->size [] = '100px';
$table->wrap [] = 'nowrap';
return;
}
function homeroom_print_course_list($slctyear=0, $sort='', $order='')
{
global $CFG, $DB, $OUTPUT, $wwwBaseUrl, $TIME_OFFSET;
if ($sort=='') {
$sort = 'date';
$order = 'DESC';
}
else {
if ($sort!='courseid' and $sort!='fullname') $sort = 'date';
}
if ($order=='') $order = 'DESC';
$table = new html_table();
$datas = array();
$crsurl = $wwwBaseUrl.'&action=crsreport';
$courses = homeroom_get_courses($slctyear);
$i = 0;
foreach($courses as $course) {
$datas[$i]['date'] = $course->sdate + $TIME_OFFSET;
$datas[$i]['courseid'] = $course->id;
$datas[$i]['fullname'] = $course->fullname;
$i++;
}
//
// sorted by 'date', 'courseid', 'fullname'
$keys = array();
foreach ($datas as $key=>$data) {
$keys[$key] = $data[$sort];
}
if ($order=='ASC') array_multisort($keys, SORT_ASC, $datas);
else array_multisort($keys, SORT_DESC, $datas);
//
include('html/course_list_header.html');
$i = 0;
foreach($datas as $data) {
$table->data[$i][] = $i + 1;
$table->data[$i][] = strftime(get_string('strftimedmy', 'homeroom'), $data['date']);
$table->data[$i][] = ''.$data['fullname'].'';
$i++;
}
homeroom_course_list_header($table, $slctyear, $sort, $order);
echo '
';
echo html_writer::table($table);
echo '
';
echo '';
echo '';
echo '';
//
echo '';
return;
}