function advise_popup_display_summary
Search API
6.x advise.history.inc | advise_popup_display_summary( |
4.x advise.history.inc | advise_popup_display_summary() |
5.x advise.history.inc | advise_popup_display_summary($advising_session_id = NULL, $bool_html = TRUE) |
Displays the printable advising summary.
If the advising_session_id is null, it gets that value from the REQUEST. Otherwise, we expect it to be a csv of the sessions we are interested in.
If bool_html is set to FALSE, then we will return results in plain text, suitable for email. if bool_minimal_text is set to TRUE, then we will return a reduced amount of text.
File
- modules/
advise/ advise.history.inc, line 442
Code
function advise_popup_display_summary($advising_session_id = NULL, $bool_html = TRUE, $bool_show_as_group = FALSE, $bool_minimal_text = TRUE) {
$rtn = "";
$txt = "";
fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
$db = get_global_database_handler();
if ($advising_session_id == NULL) {
$advising_session_id = rtrim(trim($_REQUEST ["advising_session_id"]), ",");
}
if (@$_REQUEST ['show_as_group'] === 'yes') {
$bool_show_as_group = TRUE;
}
$bool_multiple = FALSE;
$bool_show_transaction_details = TRUE;
$terms = $student_id = "";
// If we have commas in our advising_session_id, it means we had more than one that were passed to us! We want to show
// them all.
if (!strstr($advising_session_id, ",")) {
$res = db_query("SELECT * FROM advising_sessions
WHERE advising_session_id = ? ", $advising_session_id);
}
else {
$bool_multiple = TRUE;
$session_array = csv_to_array($advising_session_id);
$where = "";
foreach ($session_array as $sid) {
$where .= " advising_session_id = ? OR";
}
$where = rtrim($where, "OR");
$res = db_query("SELECT * FROM advising_sessions
WHERE $where
ORDER BY `posted` DESC ", $session_array);
}
while ($cur = db_fetch_array($res)) {
$dt = format_date(convert_time($cur ['posted']), "pretty");
$degree_title_line = "";
$ds = "";
$degree_plan = new DegreePlan();
if ($cur ['degree_id'] != DegreePlan::DEGREE_ID_FOR_COMBINED_DEGREE) {
$degree_plan->degree_id = $cur ['degree_id'];
$degree_plan->load_descriptive_data();
$degree_title_line = $degree_plan->get_title(true);
}
else {
// This is a set of combined degrees. We need to load all of the
// degrees in the major_code_csv to get their titles.
$temp = explode(",", $cur ['major_code_csv']);
$ds = "s";
foreach ($temp as $major_code) {
if ($major_code == "") {
continue;
}
$dp = $db->get_degree_plan($major_code, $cur ['catalog_year']);
if ($dp != null) {
$degree_title_line .= $dp->get_title2(TRUE, TRUE) . ", ";
}
}
$degree_title_line = rtrim($degree_title_line, ", ");
}
$student = new Student($cur ['student_id'], $db);
$student_id = $cur ['student_id'];
$school_id = db_get_school_id_for_student_id($student_id);
$term = get_term_description($cur ['term_id'], FALSE, $school_id);
$terms .= "<div class='summary-term-desc-multi'>$term</div>";
$what_if_message = "";
if (intval($cur ['is_whatif']) == 1) {
$official_degree_title = "";
$odsverb = " is";
$c = 0;
$majors = $db->get_student_majors_from_db($student->student_id);
foreach ($majors as $major_code) {
if ($major_code == "") {
continue;
}
$dp = $db->get_degree_plan($major_code, $cur ['catalog_year']);
if ($dp != null) {
$c++;
$official_degree_title .= $dp->get_title2(TRUE, TRUE) . ", ";
}
}
if ($c > 1) {
$odsverb = "s are";
}
$official_degree_title = rtrim($official_degree_title, ", ");
$what_if_message = "<b>" . t("Note:") . "</b>
" . t("This advising was saved using <b>What If</b> mode
for the degree$ds %degree_title. According to @initials records,
the student's official degree$odsverb %official.", array("%degree_title" => $degree_title_line,
"@initials" => variable_get_for_school("school_initials", "DEMO", $school_id),
"%official" => $official_degree_title));
}
if (!$bool_minimal_text) {
$txt .= "\n----- " . t("Advising Summary for") . " $term -----\n";
$txt .= t("Student:") . " " . $db->get_student_name($cur ['student_id'], false) . " ({$cur ['student_id']}) \n";
$txt .= t("Advisor:") . " " . fp_get_faculty_name($cur ['faculty_id'], false) . "\n";
$txt .= t("Term:") . " " . $term . "\n";
}
$rtn .= "<table class='adv-history-table' width='100%'><td valign='top'>";
if ($bool_show_transaction_details) {
$rtn .= "
<table class=' summary-transaction-details' border='0' width='100%' cellpadding='3' cellspacing='0'>
<tr height='7'>
<td> </td>
</tr>
<tr>
<td valign='top' width='15%'>" . t("Student:") . "</td>
<td valign='top' width='40%'>" . $db->get_student_name($cur ['student_id'], false) . " ({$cur ['student_id']})</td>
<td valign='top' rowspan='3'>
<table width='100%' cellpadding='0' cellspacing='0'>
<tr height='20'>
<td width='100%' id='student-signature-line' valign='bottom'><hr noshade size='1' width='100%' color='black' style='margin: 0px;'></td>
</tr>
<tr height='20'>
<td width='100%' id='student-signature-caption' valign='top' align='right'><span style='font-size: 8pt;'>" . t("Student signature") . "</span></td>
</tr>
<tr height='20'>
<td width='100%' id='advisor-signature-line' valign='bottom'><hr noshade size='1' width='100%' color='black' style='margin: 0px;'></td>
</tr>
<tr>
<td width='100%' id='advisor-signature-caption'valign='bottom' align='right'><span style='font-size: 8pt;'>" . t("Advisor signature") . "</span></td>
</tr>
<tr height='7'>
<td> </td>
</tr>
</table>
</td>
</tr>
<tr>
<td valign='top' width='10%'>" . t("Advisor:") . "</td>
<td valign='top'>" . fp_get_faculty_name($cur ['faculty_id'], false) . "</td>
</tr>
<tr>
<td valign='top'>" . t("Term(s):") . "</td>";
$term_disp = $term;
if ($bool_multiple && $bool_show_as_group) {
$term_disp = "<!--group_terms-->";
}
$rtn .= "
<td valign='top'>$term_disp</td>
</tr>
<tr>
<td valign='top' colspan='2' id='summary-alternate-term'>
" . t("Alternate Term(s):") . " ____________________________
</td>
</tr>
<tr>
<td valign='top' colspan='4'>
";
if ($degree_title_line != "")
{
$rtn .= t("Degree$ds:") . " $degree_title_line";
if (!$bool_minimal_text) {
$txt .= "Degree$ds: " . $degree_title_line . "\n";
}
}
$rtn .= "
</tr>
</table>
<div class=' '><i>" . t("Submitted on") . " $dt.</i></div>
<div class=' '>$what_if_message</div>
<br>
";
if ($bool_show_as_group) {
$bool_show_transaction_details = FALSE;
}
} // bool_first_time_through
if (!$bool_minimal_text) {
$txt .= t("Submitted on") . " $dt \n";
if ($what_if_message) {
$txt .= " " . fp_reduce_whitespace(strip_tags($what_if_message)) . "\n";
}
}
$rtn .= fp_render_section_title(t("Advised Courses for @term", array("@term" => $term)));
if (!$bool_minimal_text) {
$txt .= "\n" . t("Advised Courses:") . "\n";
}
else {
$txt .= "" . t("Advised Courses for @term", array("@term" => $term)) . "\n";
}
$fp = new FlightPath($student, $degree_plan, $db);
$fp->load_advising_session_from_database("", "", false, false, $cur ['advising_session_id']);
$rtn .= "<table border='0' cellpadding='3' class='summary-advised-courses'>
<tr>
<td class=' course-si-cn' valign='top' width='25%'>
<b>" . t("Course") . "</b>
</td>
<td class=' course-title' valign='top' width='70%'>
<b>" . t("Title") . "</b>
</td>
<td class=' course-hours' valign='top'>
<b>" . t("Hours") . "</b>
</td>
</tr>";
// Get a courseList of all the courses which are set as advised to take.
$advised_courses_list = $fp->course_list_advised_courses;
$advised_courses_list->load_course_descriptive_data();
$advised_courses_list->sort_alphabetical_order();
$advised_courses_list->reset_counter();
while ($advised_courses_list->has_more()) {
$course = $advised_courses_list->get_next();
// set the catalogYear from the term_id.
$course->term_id = $cur ['term_id'];
$course->set_catalog_year_from_term_id();
$course->load_descriptive_data(false);
$rtn .= "<tr>
<td class=' course-si-cn' valign='top'>
$course->subject_id $course->course_num
</td>
<td class=' course-title' valign='top'>
$course->title
</td>
<td class=' course-hours' valign='top' align='center'>
" . $course->get_hours() . "
</td>
</tr>
";
$txt .= " $course->subject_id $course->course_num - $course->title - " . $course->get_hours() . "hrs \n";
}
$rtn .= "</table>
<div align='right' class=' total-advised-hours' style='padding-top: 10px; padding-right: 15px;'>
<b>" . t("Total advised hours:") . " " . $advised_courses_list->count_hours() . "</b>
</div>
";
$txt .= "Total advised hours: " . $advised_courses_list->count_hours() . "\n\n\n";
$rtn .= "</table>";
if ($bool_show_transaction_details && $bool_multiple) {
$rtn .= "<div class='history-summary-divider'> </div>";
}
} // while, for the query itself!
$rtn .= "<br>";
$rtn .= "<div class='summary-alternate-courses'>";
$rtn .= fp_render_section_title(t("Alternate Courses"));
$rtn .= "<div class=' alt-courses-desc-and-lines'>
" . t("You may use this space to write in alternate courses
the student should enroll in, in the event that an
advised course is full or unavailable.") . "
<br><br>
___________________________________________________________________ <br><br>
___________________________________________________________________
</div> ";
$rtn .= "</div>";
if ($bool_multiple && $bool_show_as_group) {
$rtn = str_replace("<!--group_terms-->", $terms, $rtn);
}
// Are we NOT returning html?
if (!$bool_html) {
return $txt;
}
fp_set_title($db->get_student_name($student_id, FALSE) . " ($student_id) $term " . t("Advising Summary"));
watchdog("advise", "popup_display_summary advising_session_id:$advising_session_id", array(), WATCHDOG_DEBUG);
return $rtn;
}