function print_mgmt_table($id, $a, $show, $showstatus) { global $CFG; $courses = array(); $categories = get_child_course_categories($show); foreach ($categories as $cat) { if ($showstatus > 0) { $cat_courses = $DB->get_records_sql("SELECT c.id, c.fullname FROM {$CFG->prefix}course c\n\t\t\t\t\tINNER JOIN {$CFG->prefix}diplome_diploma d\n\t\t\t\t\t\tON c.id = d.courseid\n\t\t\t\t\t\tAND c.category = '" . $cat . "'\n\t\t\t\t\t\tAND d.status >= '" . $showstatus . "'\n\t\t\t\t\tORDER BY c.fullname\n\t\t\t\t\t"); } else { $cat_courses = get_records('course', 'category', $cat); } if ($cat_courses != false) { foreach ($cat_courses as $cc) { $courses[] = $cc; } } } if (!$courses) { echo '<p class="error">' . get_string('nocoursesinthiscategory', 'diplome') . '</p>'; } else { $validinfofound = false; if ($id) { echo '<form action="view.php?id=' . $id . '&show=' . $show . '&showstatus=' . $showstatus . '" method="post">'; } else { if ($a) { echo '<form action="view.php?a=' . $a . '&show=' . $show . '&showstatus=' . $showstatus . '" method="post">'; } } $counter = 0; foreach ($courses as $course) { echo '<h2><a href="' . $CFG->wwwroot . '/course/view.php?id=' . $course->id . '">' . $course->fullname . '</a></h2>'; $instructors = get_instructors($course->id); if ($instructors != false) { echo '<p>'; $first = true; foreach ($instructors as $instruct) { if ($first) { $first = false; } else { echo ' ; '; } echo '<a href="mailto:' . $instruct->email . '">' . $instruct->firstname . ' ' . $instruct->lastname . '</a>'; } echo '</p>'; } $newc = print_course_diplomas_table($showstatus, $course->id, $counter); if ($newc > $counter) { $validinfofound = true; $counter = $newc; } } if ($validinfofound) { echo '<input type="hidden" name="action" value="1" />'; echo '<input type="submit" name="submit" value="' . get_string('confirmcertificateaction', 'diplome') . '" />'; } echo '</form>'; } }
function print_select_instructors() { $instructors = get_instructors(); echo '<select class="inssel" name="ins">'; $i = 0; foreach ($instructors as $ins) { if ($i == 0) { echo build_option($ins->id, $ins->firstname . ' ' . $ins->lastname, 1); $i++; } else { echo build_option($ins->id, $ins->firstname . ' ' . $ins->lastname, 0); } } echo '</select>'; }