<body>
<center>
<?php 
include_once "{$_SERVER['DOCUMENT_ROOT']}/php-bin/libquery.php";
if (!isset($_GET) || !array_key_exists('noBackLink', $_GET) || $_GET['noBackLink'] == 'false') {
    echo "<a style= \"margin-top:10px;margin-left:10px;\" class=\"pure-button pure-button-primary\" href=\"/index.html\">Banner Main</a></div>";
}
if (!isset($_GET) || !array_key_exists('bannerid', $_GET)) {
    echo "<p><strong>Bad request</strong></p>\n";
} else {
    $bannerid = $_GET['bannerid'];
    if (!is_numeric($bannerid)) {
        echo "<p>{$bannerid} is not a valid Banner ID</p>";
        exit(0);
    }
    $student = new DBQuery("SELECT last_name, first_name FROM banner.student WHERE banner.student.id = {$bannerid};");
    if ($student->get_row_cnt() == 0) {
        echo "<p>No results for Banner ID={$bannerid}</p>";
        exit(0);
    }
    $row = $student->get_next_row();
    echo "<h1>Schedule listing for {$row[0]}, {$row[1]} [{$bannerid}]</h1>";
    $schedule = new DBQuery("SELECT crn, subject_code, number, title, begin_time, end_time, dow FROM banner.student_section INNER JOIN\nbanner.section ON banner.section.id = banner.student_section.section_id INNER JOIN banner.course ON\nbanner.section.course_id = banner.course.id INNER JOIN banner.student ON\nbanner.student_section.student_id = banner.student.id\nWHERE banner.student_section.student_id = {$bannerid}\nORDER BY course.title;");
    echo $schedule->htmlitize();
}
?>

 </center> </body>
</html>
 protected final function find_conflicts_impl()
 {
     $section_id = $this->desc->get_section_id();
     // grab all the students in the section
     $q = new DBQuery("SELECT id FROM banner.student_section INNER JOIN banner.student ON id = student_id WHERE section_id = {$section_id};");
     $students = array();
     while (($row = $q->get_next_row()) !== false) {
         $students[] = $row[0];
     }
     // grab all simple conflicts for the section change description
     $this->q = new DBQuery("SELECT student.id, student.first_name, student.last_name, section.crn, course.subject_code, course.number, course.title, section.begin_time, section.end_time, section.dow\nFROM banner.student_section\nINNER JOIN banner.section ON banner.student_section.section_id = section.id\nAND banner.student_section.section_id <> {$section_id}\nAND " . $this->desc->generate_sql_where_time_overlap("banner.section.begin_time", "banner.section.end_time") . "\nAND " . $this->desc->generate_sql_where_dow_overlap("banner.section.dow") . "\nINNER JOIN banner.student ON banner.student_section.student_id = student.id\nINNER JOIN banner.course ON banner.course.id = banner.section.course_id\nWHERE banner.student.id = " . implode(" OR banner.student.id = ", $students) . ";");
 }
if (!isset($_GET) || !array_key_exists('noBackLink', $_GET) || $_GET['noBackLink'] == 'false') {
    echo "<a style= \"margin-top:10px;margin-left:10px;\" class=\"pure-button pure-button-primary\" href=\"/index.html\">Banner Main</a></div>";
}
if (!isset($_GET) || !array_key_exists('crn', $_GET)) {
    echo "<p><strong>Bad request</strong></p>\n";
    exit(0);
}
$crn = $_GET['crn'];
if (!is_numeric($crn)) {
    echo "<p>{$crn} is not a valid CRN value</p>";
    exit(0);
}
// get the course title information
$q1 = new DBQuery("SELECT subject_code, number, title, begin_time, end_time, dow, first_name, last_name FROM banner.course\nINNER JOIN banner.section ON section.course_id = course.id AND crn={$crn}\nINNER JOIN banner.professor ON professor.id = professor_id;");
if ($q1->is_empty()) {
    echo "<p>No results for CRN={$crn}</p>";
    exit(0);
}
$heading = $q1->get_next_row();
$q2 = new DBQuery("SELECT student.id, first_name, middle_name, last_name, classification FROM banner.section\nINNER JOIN banner.student_section ON crn={$crn} AND section.id = section_id\nINNER JOIN banner.student ON student_id = student.id\nORDER BY student.classification, last_name;");
if ($q2->is_empty()) {
    // section shouldn't be empty
    echo "<p>No students where associated with the specified section</p>";
    exit(0);
}
echo "<h1>Section listing for {$heading[0]} {$heading[1]} {$heading[2]} [CRN={$crn}]</h1>" . "<h2>Start Time: {$heading[3]}<br />End Time: {$heading[4]}<br />Meeting Days: {$heading[5]}<br />Professor: {$heading[6]} {$heading[7]}</h2>" . $q2->htmlitize();
?>

  </center></body>
</html>
        echo "<p> No sections found for course with id={$id} </p>";
        exit(1);
    }
    while (true) {
        $row = $q->get_next_row();
        if ($row === false) {
            break;
        }
        $sects[] = $row[0];
    }
}
$results = array();
foreach ($sects as $id) {
    $q = new DBQuery("SELECT student_id FROM banner.student_section WHERE banner.student_section.section_id = {$id};");
    while (true) {
        $row = $q->get_next_row();
        if ($row === false) {
            break;
        }
        if (!array_key_exists($row[0], $results)) {
            $results[$row[0]] = 1;
        } else {
            ++$results[$row[0]];
        }
    }
}
foreach (array_keys($results) as $k) {
    if ($results[$k] != count($cids)) {
        unset($results[$k]);
    }
}