if (!EvaluatedSubject::exists($id, $student_id)) {
        $grade = Grade::get_by_subj_stud($pre_subject->id, $student_id);
        $gradepre = Grade::get_by_subj_stud($pre_subject->prereq_subject_id, $student_id);
        if (has_prerequisite($pre_subject->prereq_subject_id, $student_subjects)) {
            if ($gradepre != null) {
                if (Grade::get_by_subj_stud($pre_subject->prereq_subject_id, $student_id)->grade <= 74) {
                    $warnings .= "Cannot add " . $pre_subject->code . " because it's previous subject:" . Subject::get_by_id($pre_subject->prereq_subject_id)->code . " is failed\n\n";
                } else {
                    $eval_subject = new EvaluatedSubject();
                    $eval_subject->student_id = $student_id;
                    $eval_subject->subject_id = $id;
                    $eval_subject->create();
                }
            }
        } else {
            $eval_subject = new EvaluatedSubject();
            $eval_subject->student_id = $student_id;
            $eval_subject->subject_id = $id;
            $eval_subject->create();
        }
    }
}
if ($warnings != "") {
    echo $warnings;
} else {
    if (!EvaluatedStudent::exists($student_id)) {
        $evaluatedstudent = new EvaluatedStudent();
        $evaluatedstudent->student_id = $student_id;
        $evaluatedstudent->create();
    }
    echo "success";
<?php

require_once "../includes/initialize.php";
$student_id = $_GET['student_id'];
$subject_ids2 = $_POST['subject_ids2'];
$message = "success";
foreach ($subject_ids2 as $id) {
    $subject_id = EvaluatedSubject::get_by_id($id)->subject_id;
    $newgrade = Grade::get_by_subj_stud($subject_id, $student_id);
    if ($newgrade != null) {
        $newgrade->delete();
    }
    $object = EvaluatedSubject::get_by_id($id);
    if ($object != null) {
        $object->delete();
    }
}
echo $message;
&first=2nd';
  jQuery("#grid_evaluated_grades_subjects").jqGrid('setGridParam',{url:theurl,page:1}).trigger("reloadGrid");
});

</script>

<table id="grid_evaluated_grades_subjects2"><tr><td/></tr></table> 
<div id="nav_evaluated_grades_subjects2"></div>
<a href="javascript:void(0)" id="btn_remove">Remove</a>
<a class="btnPrint" href="print/evaluated_subjects.php?student_id=<?php 
echo $student_id;
?>
&date=">Print Evaluated Subjects</a>
<select id="thedate">
  <?php 
$theevaluatedsubjects = EvaluatedSubject::get_by_sql("SELECT DISTINCT date FROM " . T_EVALUATED_SUBJECTS . " WHERE " . C_EVALUATED_STUDENT_ID . "=" . $student->id);
foreach ($theevaluatedsubjects as $object) {
    echo "<option value='" . $object->date . "'>" . $object->date . "</option>";
}
?>
</select>

<script>

  var printURL = "print/evaluated_subjects.php?student_id=<?php 
echo $student_id;
?>
&date=";

  setDate();
    table{
        width: 100%;
    }

    td{
        border-bottom: 1px solid black;
    }

</style>

<?php 
require_once "../../includes/initialize.php";
$student_id = $_GET['student_id'];
$date = $_GET['date'];
$eval_subjects = EvaluatedSubject::get_by_sql("SELECT * FROM " . T_EVALUATED_SUBJECTS . " WHERE " . C_EVALUATED_STUDENT_ID . "=" . $student_id . " AND date = '" . $date . "'");
$s = "<table>";
$s .= "<tr>";
$s .= "<td>CODE</td>";
$s .= "<td>DESCRIPTION</td>";
$s .= "<td>UNITS</td>";
$s .= "<td>PREREQUISITE</td>";
$s .= "<td>COURSE</td>";
$s .= "<td>YEAR</td>";
$s .= "<td>SEMESTER</td>";
$s .= "<td>DATE EVALUATED</td>";
$s .= "</tr>";
foreach ($eval_subjects as $eval_subject) {
    $subject = Subject::get_by_id($eval_subject->subject_id);
    $s .= "<tr>";
    $s .= "<td>" . $subject->code . "</td>";
<?php

require_once "../includes/initialize.php";
global $session;
if (!$session->is_logged_in()) {
    redirect_to("index.php");
}
$page = $_GET['page'];
$limit = $_GET['rows'];
$sidx = $_GET['sidx'];
$sord = $_GET['sord'];
$count = count(EvaluatedSubject::get_by_sql("SELECT * FROM " . T_EVALUATED_SUBJECTS));
if ($count > 0 && $limit > 0) {
    $total_pages = ceil($count / $limit);
} else {
    $total_pages = 0;
}
if ($page > $total_pages) {
    $page = $total_pages;
}
$start = $limit * $page - $limit;
if ($start < 0) {
    $start = 0;
}
if (!$sidx) {
    $sidx = 1;
}
$result = mysql_query("SELECT DISTINCT " . C_EVALUATED_STUDENT_ID . " FROM " . T_EVALUATED_SUBJECTS);
$distinct_ids = array();
while ($row = mysql_fetch_array($result)) {
    array_push($distinct_ids, $row['student_id']);
if ($count > 0 && $limit > 0) {
    $total_pages = ceil($count / $limit);
} else {
    $total_pages = 0;
}
if ($page > $total_pages) {
    $page = $total_pages;
}
$start = $limit * $page - $limit;
if ($start < 0) {
    $start = 0;
}
if (!$sidx) {
    $sidx = 1;
}
$eval_subjects = EvaluatedSubject::get_by_sql("SELECT * FROM " . T_EVALUATED_SUBJECTS . " WHERE " . C_EVALUATED_STUDENT_ID . "=" . $student->id . " ORDER BY {$sidx} {$sord} LIMIT {$start} , {$limit}");
header("Content-type: text/xml;charset=utf-8");
$s = "<?xml version='1.0' encoding='utf-8'?>";
$s .= "<rows>";
$s .= "<page>" . $page . "</page>";
$s .= "<total>" . $total_pages . "</total>";
$s .= "<records>" . $count . "</records>";
foreach ($eval_subjects as $eval_subject) {
    $final_subject = Subject::get_by_id($eval_subject->subject_id);
    $s .= "<row id='" . $eval_subject->id . "'>";
    $s .= "<cell>" . $final_subject->id . "</cell>";
    $s .= "<cell>" . $final_subject->code . "</cell>";
    $s .= "<cell>" . $final_subject->description . "</cell>";
    $s .= "<cell>" . $final_subject->units . "</cell>";
    $subject_code = $final_subject->prereq_subject_id == 0 ? "NONE" : Subject::get_by_id($final_subject->prereq_subject_id)->code;
    $s .= "<cell>" . $subject_code . "</cell>";