advise.history.inc

  1. 7.x modules/advise/advise.history.inc
  2. 6.x modules/advise/advise.history.inc
  3. 4.x modules/advise/advise.history.inc
  4. 5.x modules/advise/advise.history.inc

File

modules/advise/advise.history.inc
View source
  1. <?php
  2. /*
  3. * This file is responsible for the contents / functionality of the History tab.
  4. */
  5. /**
  6. * Displays the history tab on screen.
  7. */
  8. function advise_display_history() {
  9. global $current_student_id;
  10. $student_id = $current_student_id;
  11. $db = get_global_database_handler();
  12. $extra_style = $ast = "";
  13. $rtn = "";
  14. fp_add_css(fp_get_module_path("advise") . "/css/advise.css");
  15. fp_add_js(fp_get_module_path("advise") . "/js/advise.js");
  16. $rtn .= "<table class='fp-semester-table'>";
  17. // If coming here from a save, display info here.
  18. if (@$_REQUEST["adv_id_array_serialized"] != "") {
  19. $click_links = "";
  20. $advising_session_id_array = unserialize($_REQUEST["adv_id_array_serialized"]);
  21. foreach($advising_session_id_array as $term_id=>$value) {
  22. $term_id = (string) $term_id; // Make sure term_id is a standard string
  23. $aid = $advising_session_id_array[$term_id];
  24. if ($aid != "")
  25. {
  26. $term_name = get_term_description($term_id);
  27. $turl = fp_url("advise/popup-display-summary", "advising_session_id=$aid");
  28. $click_links .= "<li>
  29. <a href='javascript: popupPrintWindow(\"" . $turl . "\");'>
  30. <img src='" . fp_theme_location() . "/images/popup.gif' border='0'>
  31. $term_name</a>";
  32. }
  33. }
  34. $rtn .= "
  35. <tr>
  36. <td colspan='2' width='100%'>
  37. <div class='hypo'
  38. align='left' style='border: 1px solid black;
  39. margin: 10px 0px 10px 0px; padding: 10px;
  40. font-size: 12pt; font-weight: bold;'>
  41. " . t("You have successfully advised") . " " . $db->get_student_name($student_id) . " ($student_id).
  42. <br><span style='color: blue;'>" . t("Click
  43. to view a pop-up printable summary for:") . "
  44. <ul style='margin-top: 5px; margin-bottom: 5px;'>
  45. $click_links
  46. </ul></span></div>
  47. </td>
  48. </tr>
  49. ";
  50. }
  51. $rtn .= "<tr><td width='50%' valign='top' style='padding-right: 10px;'>
  52. ";
  53. ///////////////////////////////////////////////////
  54. //////////////////////////////////////////////////
  55. ///////// Advising History
  56. ///////////////////////////////////////////////////
  57. $rtn .= fp_render_curved_line(t("Advising History"));
  58. $render_left = array(); // creating a new render array.
  59. $render_left["#id"] = "advise_history_left_column";
  60. $render_left["#student_id"] = $student_id;
  61. //$rtn .= "<table border='0' cellspacing='0'>";
  62. $old_session_d_t = 0;
  63. $a_count = 0;
  64. $c = 0;
  65. $is_empty = true;
  66. $first_style = "color: maroon; font-weight:bold;";
  67. $advising_session_id_array = array();
  68. $on_mouse_over = "
  69. onmouseover='$(this).addClass(\"selection_highlight\");'
  70. onmouseout='$(this).removeClass(\"selection_highlight\");'
  71. ";
  72. $html = "";
  73. $res = db_query("SELECT * FROM advising_sessions
  74. WHERE student_id = '?'
  75. AND is_draft = '0'
  76. AND is_empty = '0'
  77. ORDER BY `posted` DESC, `term_id` DESC ", $student_id);
  78. while($cur = db_fetch_array($res)) {
  79. extract($cur, 3, "db");
  80. $dt = date("n/j/y g:ia",$db_posted);
  81. $html = "";
  82. // Is this datetime within 5 seconds of the previous datetime?
  83. // If so, they were likely saved together, and are part
  84. // of the same advising session. Otherwise, this is a NEW
  85. // advising session. The if statement below is testing is this
  86. // a new advising session.
  87. $test_d_t = $db_posted;
  88. if ($old_session_d_t < ($test_d_t - 5) || $old_session_d_t > ($test_d_t + 5))
  89. {
  90. $p = "20px;";
  91. if ($a_count == 0)
  92. {
  93. $p = "10px;";
  94. }
  95. $old_session_d_t = $test_d_t;
  96. $advised_by = "<div style='padding-top: $p'>
  97. <b>" . t("Advised by") . " " . fp_get_faculty_name($db_faculty_id, false) . "</b>
  98. </div>";
  99. /*
  100. $rtn .= "<tr><td colspan='2' class='tenpt'>
  101. $advised_by
  102. </td>
  103. </tr>";
  104. */
  105. $html .= "<div class='tenpt'>$advised_by</div>";
  106. $a_count++;
  107. }
  108. $is_empty = false;
  109. if ($a_count > 1) {
  110. $first_style = "";
  111. }
  112. $turl = fp_url("advise/popup-display-summary", "advising_session_id=$db_advising_session_id");
  113. $advising_session_id_array[] = $db_advising_session_id;
  114. $on_click = "popupPrintWindow(\"" . $turl . "\");";
  115. $term = get_term_description($db_term_id);
  116. /*
  117. $rtn .= "<tr $on_mouse_over style='cursor: pointer; $first_style'
  118. onClick='$on_click'>
  119. <td valign='top' class='tenpt'
  120. style='padding-left:20px;'
  121. width='165'>
  122. $term
  123. </td>
  124. <td valign='top' class='tenpt'>
  125. $dt
  126. </td>
  127. </tr>";
  128. */
  129. $html .= "<div $on_mouse_over style='cursor: pointer; $first_style' onClick='$on_click'>
  130. <div class='tenpt' style='display: inline-block; padding-left:20px; width:165px;'>$term</div>
  131. <div class='tenpt' style='display: inline-block;'>$dt</div>
  132. </div>";
  133. // If this is more than X number, let's hide the rest in a collapsible fieldset.
  134. if ($c < 5) {
  135. $render_left["advising_history_$c"] = array(
  136. "value" => $html,
  137. "weight" => $c,
  138. );
  139. }
  140. else {
  141. // Let's place in a collapsible fieldset!
  142. if (!isset($render_left["advising_history_fs"])) {
  143. $render_left["advising_history_fs"] = array(
  144. "type" => "cfieldset",
  145. "label" => t("View complete advising history"),
  146. "start_closed" => TRUE,
  147. "elements" => array(),
  148. "weight" => $c,
  149. );
  150. }
  151. $render_left["advising_history_fs"]["elements"][] = array("advising_history_$c" => array(
  152. "value" => $html,
  153. ));
  154. }
  155. $c++;
  156. }
  157. //$rtn .= "</table>";
  158. if ($is_empty == true) {
  159. //$rtn .= "<div class='tenpt'>No advising history available.</div>";
  160. $render_left["markup_no_adv_history"] = array(
  161. "value" => t("No advising history available."),
  162. );
  163. }
  164. else {
  165. $print_all_url = fp_url("advise/popup-display-summary", "advising_session_id=" . join(",", $advising_session_id_array));
  166. $render_left["markup_print_all"] = array(
  167. "value" => "<a href='javascript: popupPrintWindow(\"" . $print_all_url . "\");'
  168. class='nounderline tenpt'><img src='" . fp_theme_location() . "/images/popup.gif' border='0'>view/print all</a>
  169. ",
  170. "weight" => -1,
  171. );
  172. }
  173. // Okay, we can render the left-hand side now.
  174. $rtn .= fp_render_content($render_left);
  175. //----------------------------------------------------------------------------------------
  176. //------------------------------ COMMENT HISTORY -----------------------------------------
  177. //----------------------------------------------------------------------------------------
  178. $rtn .= "</td><td width='50%' valign='top'>";
  179. $rtn .= fp_render_curved_line(t("Comment History"));
  180. //$rtn .= "<table border='0' cellspacing='0'>";
  181. // Prepare a render array for the right-hand side.
  182. $render_right = array();
  183. $render_right["#id"] = "advise_history_right_column";
  184. $render_right["#student_id"] = $student_id;
  185. $html = "";
  186. $old_term_id = "";
  187. $first_style = "first";
  188. $is_empty = true;
  189. $has_admin_category = false;
  190. $access_line = "";
  191. //if (!user_has_permission("view_faculty_comments")) {
  192. // $access_line = "and `access_type`='public' ";
  193. //}
  194. $access_types = (user_has_permission("view_faculty_comments")) ? array("faculty", "public") : array("public");
  195. $turl = fp_url("comments/popup-display-all-comments");
  196. /*
  197. $rtn .= "<tr><td colspan='3' class='tenpt'>
  198. <!--STARTCOM--><div style='padding-top: 10px;'>
  199. <b>" . t("Advising Comments") . "</b>
  200. &nbsp;
  201. <a href='javascript: popupPrintWindow(\"" . $turl . "\");'
  202. class='nounderline'><img src='" . fp_theme_location() . "/images/popup.gif' border='0'>view/print all</a>
  203. </div><!--ENDCOM-->
  204. </td></tr>";
  205. */
  206. $html .= "<div colspan='3' class='tenpt'>
  207. <!--STARTCOM--><div style='padding-top: 10px;'>
  208. <b>" . t("Advising Comments") . "</b>
  209. &nbsp;
  210. <a href='javascript: popupPrintWindow(\"" . $turl . "\");'
  211. class='nounderline'><img src='" . fp_theme_location() . "/images/popup.gif' border='0'>view/print all</a>
  212. </div><!--ENDCOM-->
  213. </div>";
  214. // Use the function comments_get_comments instead of a direct query.
  215. $res = comments_get_comments($student_id, FALSE, $access_types);
  216. /*
  217. $res = db_query("SELECT * FROM advising_comments
  218. WHERE student_id = '?'
  219. AND delete_flag = '0'
  220. $access_line
  221. $cat_line
  222. order by `posted` desc ", $student_id);
  223. */
  224. //while ($cur = db_fetch_array($res))
  225. foreach ($res as $cur)
  226. {
  227. extract($cur, 3, "db");
  228. $dt = format_date($db_posted);
  229. if ($first_style == "first")
  230. {
  231. $first_style = "color: maroon; font-weight:bold;
  232. ";
  233. }
  234. $turl = fp_url("comments/popup-display-comment", "id=$db_id");
  235. $on_click = "popupPrintWindow(\"" . $turl . "\");";
  236. /*
  237. $rtn .= "<tr $on_mouse_over style='cursor:pointer; $first_style $extra_style'
  238. onClick='$on_click'>
  239. <td valign='top' width='165' class='tenpt'
  240. style='padding-left: 20px;'>
  241. " . fp_get_faculty_name($db_faculty_id, false) . "
  242. </td>
  243. <td valign='top' class='tenpt'>
  244. $dt$ast
  245. </td>
  246. </tr>";
  247. *
  248. */
  249. $html .= "<div $on_mouse_over style='cursor:pointer; $first_style $extra_style'
  250. onClick='$on_click'>
  251. <div class='tenpt' style='padding-left: 20px; width:165px; display:inline-block;'>
  252. " . fp_get_faculty_name($db_faculty_id, false) . "
  253. </div>
  254. <div class='tenpt' style='display: inline-block;'>
  255. $dt$ast
  256. </div>
  257. </div>";
  258. $is_empty = false;
  259. $first_style = "";
  260. }
  261. if ($is_empty == true) {
  262. /*
  263. $rtn .= "<tr><td colspan='4' class='tenpt'>
  264. <div style='padding-left: 20px;'>
  265. " . t("No comment history available.") . "</div></td></tr>";
  266. */
  267. $render_right["markup_no_comment_history"] = array(
  268. "value" => t("No comment history available."),
  269. );
  270. }
  271. $render_right["comment_history"] = array(
  272. "value" => $html,
  273. "weight" => 0,
  274. );
  275. //$rtn .= "</table>";
  276. // Render our render array now...
  277. $rtn .= fp_render_content($render_right);
  278. $rtn .= "</td></tr>";
  279. $rtn .= "</table>";
  280. return $rtn;
  281. }
  282. /**
  283. * Displays the printable advising summary.
  284. *
  285. * If the advising_session_id is null, it gets that value from the REQUEST. Otherwise, we expect it to be a csv of the
  286. * sessions we are interested in.
  287. *
  288. * If bool_html is set to FALSE, then we will return results in plain text, suitable for email.
  289. *
  290. */
  291. function advise_popup_display_summary($advising_session_id = NULL, $bool_html = TRUE) {
  292. $rtn = "";
  293. $txt = "";
  294. $db = get_global_database_handler();
  295. if ($advising_session_id == NULL) {
  296. $advising_session_id = rtrim(trim($_REQUEST["advising_session_id"]), ",");
  297. }
  298. $bool_multiple = FALSE;
  299. // 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
  300. // them all.
  301. if (!strstr($advising_session_id, ",")) {
  302. $res = db_query("SELECT * FROM advising_sessions
  303. WHERE advising_session_id = ? ", $advising_session_id);
  304. }
  305. else {
  306. $bool_multiple = TRUE;
  307. $session_array = csv_to_array($advising_session_id);
  308. $where = "";
  309. foreach ($session_array as $sid) {
  310. $where .= " advising_session_id = ? OR";
  311. }
  312. $where = rtrim($where, "OR");
  313. $res = db_query("SELECT * FROM advising_sessions
  314. WHERE $where
  315. ORDER BY `posted` DESC ", $session_array);
  316. }
  317. while ($cur = db_fetch_array($res)) {
  318. extract($cur, 3, "db");
  319. $dt = format_date($db_posted, "pretty");
  320. $term = get_term_description($db_term_id);
  321. $degree_title_line = "";
  322. $ds = "";
  323. $degree_plan = new DegreePlan();
  324. if ($db_degree_id != _DegreePlan::DEGREE_ID_FOR_COMBINED_DEGREE) {
  325. $degree_plan->degree_id = $db_degree_id;
  326. $degree_plan->load_descriptive_data();
  327. $degree_title_line = $degree_plan->get_title(true);
  328. }
  329. else {
  330. // This is a set of combined degrees. We need to load all of the
  331. // degrees in the major_code_csv to get their titles.
  332. $temp = explode(",", $db_major_code_csv);
  333. $ds = "s";
  334. foreach ($temp as $major_code) {
  335. if ($major_code == "") continue;
  336. $dp = $db->get_degree_plan($major_code, $db_catalog_year);
  337. if ($dp != null) {
  338. $degree_title_line .= $dp->get_title2(TRUE, TRUE) . ", ";
  339. }
  340. }
  341. $degree_title_line = rtrim($degree_title_line, ", ");
  342. }
  343. $student = new Student($db_student_id, $db);
  344. $what_if_message = "";
  345. if ($db_is_whatif == 1) {
  346. $official_degree_title = "";
  347. $odsverb = " is";
  348. $c = 0;
  349. $majors = $db->get_student_majors_from_db($student->student_id);
  350. foreach ($majors as $major_code) {
  351. if ($major_code == "") continue;
  352. $dp = $db->get_degree_plan($major_code, $db_catalog_year);
  353. if ($dp != null) {
  354. $c++;
  355. $official_degree_title .= $dp->get_title2(TRUE, TRUE) . ", ";
  356. }
  357. }
  358. if ($c > 1) $odsverb = "s are";
  359. $official_degree_title = rtrim($official_degree_title, ", ");
  360. $what_if_message = "<b>" . t("Note:") . "</b>
  361. " . t("This advising was saved using <b>What If</b> mode
  362. for the degree$ds %degree_title. According to @initials records,
  363. the student's official degree$odsverb %official.", array("%degree_title" => $degree_title_line,
  364. "@initials" => $GLOBALS["fp_system_settings"]["school_initials"],
  365. "%official" => $official_degree_title));
  366. }
  367. $page_is_mobile = fp_screen_is_mobile();
  368. $w = ($page_is_mobile) ? "100%" : "500";
  369. $rtn .= "<table width='$w'><td valign='top'>";
  370. if ($page_is_mobile) {
  371. }
  372. else {
  373. $rtn .= "
  374. <table class='tenpt summary-transaction-details' border='0' width='100%' cellpadding='3' cellspacing='0' style='border-width: 2px; border-style: solid; border-color: black;'>
  375. <tr height='7'>
  376. <td> </td>
  377. </tr>
  378. <tr>
  379. <td valign='top' width='15%'>" . t("Student:") . "</td>
  380. <td valign='top' width='40%'>" . $db->get_student_name($db_student_id, false) . " ($db_student_id)</td>
  381. <td valign='top' rowspan='3'>
  382. <table width='100%' cellpadding='0' cellspacing='0'>
  383. <tr height='20'>
  384. <td width='100%' id='student-signature-line' valign='bottom'><hr noshade size='1' width='100%' color='black' style='margin: 0px;'></td>
  385. </tr>
  386. <tr height='20'>
  387. <td width='100%' id='student-signature-caption' valign='top' align='right'><span style='font-size: 8pt;'>" . t("Student signature") . "</span></td>
  388. </tr>
  389. <tr height='20'>
  390. <td width='100%' id='advisor-signature-line' valign='bottom'><hr noshade size='1' width='100%' color='black' style='margin: 0px;'></td>
  391. </tr>
  392. <tr>
  393. <td width='100%' id='advisor-signature-caption'valign='bottom' align='right'><span style='font-size: 8pt;'>" . t("Advisor signature") . "</span></td>
  394. </tr>
  395. <tr height='7'>
  396. <td> </td>
  397. </tr>
  398. </table> ";
  399. $txt .= "\n----- Advising Summary for $term -----\n";
  400. $txt .= "Student: " . $db->get_student_name($db_student_id, false) . " ($db_student_id) \n";
  401. } // else
  402. $rtn .= "
  403. </td>
  404. </tr>
  405. <tr>
  406. <td valign='top' width='10%'>" . t("Advisor:") . "</td>
  407. <td valign='top'>" . fp_get_faculty_name($db_faculty_id, false) . "</td>
  408. </tr>
  409. <tr>
  410. <td valign='top'>" . t("Term:") . "</td>
  411. <td valign='top'>$term</td>
  412. </tr>
  413. ";
  414. $txt .= "Advisor: " . fp_get_faculty_name($db_faculty_id, false) . "\n";
  415. $txt .= "Term: " . $term . "\n";
  416. if (!$page_is_mobile) {
  417. $rtn .= "
  418. <tr>
  419. <td valign='top' colspan='2' id='summary-alternate-term'>
  420. " . t("Alternate Term:") . " _____________________
  421. </td>
  422. </tr>";
  423. }
  424. $rtn .= "
  425. <tr>
  426. <td valign='top' colspan='4'>
  427. ";
  428. if ($degree_title_line != "")
  429. {
  430. $rtn .= t("Degree$ds:") . " $degree_title_line";
  431. $txt .= "Degree$ds: " . $degree_title_line . "\n";
  432. }
  433. $rtn .= "
  434. </tr>
  435. </table>
  436. <div class='tenpt'><i>" . t("Submitted on") . " $dt.</i></div>
  437. <div class='tenpt'>$what_if_message</div>
  438. <br>
  439. ";
  440. $txt .= "Submitted on $dt \n";
  441. if ($what_if_message) {
  442. $txt .= " " . fp_reduce_whitespace(strip_tags($what_if_message)) . "\n";
  443. }
  444. $rtn .= fp_render_curved_line(t("Advised Courses"));
  445. $txt .= "\nAdvised Courses:\n";
  446. $fp = new FlightPath($student,$degree_plan, $db);
  447. $fp->load_advising_session_from_database("","",false,false,$db_advising_session_id);
  448. $rtn .= "<table border='0' cellpadding='3' class='summary-advised-courses'>
  449. <tr>
  450. <td class='tenpt course-si-cn' valign='top' width='25%'>
  451. <b>" . t("Course") . "</b>
  452. </td>
  453. <td class='tenpt course-title' valign='top' width='70%'>
  454. <b>" . t("Title") . "</b>
  455. </td>
  456. <td class='tenpt course-hours' valign='top'>
  457. <b>" . t("Hours") . "</b>
  458. </td>
  459. </tr>";
  460. // Get a courseList of all the courses which are set as advised to take.
  461. $advised_courses_list = $fp->course_list_advised_courses;
  462. $advised_courses_list->load_course_descriptive_data();
  463. $advised_courses_list->sort_alphabetical_order();
  464. $advised_courses_list->reset_counter();
  465. while ($advised_courses_list->has_more()) {
  466. $course = $advised_courses_list->get_next();
  467. // set the catalogYear from the term_id.
  468. $course->term_id = $db_term_id;
  469. $course->set_catalog_year_from_term_id();
  470. $course->load_descriptive_data(false);
  471. $rtn .= "<tr>
  472. <td class='tenpt course-si-cn' valign='top'>
  473. $course->subject_id $course->course_num
  474. </td>
  475. <td class='tenpt course-title' valign='top'>
  476. $course->title
  477. </td>
  478. <td class='tenpt course-hours' valign='top' align='center'>
  479. " . $course->get_hours() . "
  480. </td>
  481. </tr>
  482. ";
  483. $txt .= " $course->subject_id $course->course_num - $course->title - " . $course->get_hours() . "hrs \n";
  484. }
  485. $rtn .= "</table>
  486. <div align='right' class='tenpt total-advised-hours' style='padding-top: 10px; padding-right: 15px;'>
  487. <b>" . t("Total advised hours:") . " &nbsp; " . $advised_courses_list->count_hours() . "</b>
  488. </div>
  489. ";
  490. $txt .= "Total advised hours: " . $advised_courses_list->count_hours() . "\n";
  491. $txt .= "\n\n";
  492. if (!$page_is_mobile) {
  493. $rtn .= "<br>";
  494. $rtn .= "<div class='summary-alternate-courses'>";
  495. $rtn .= fp_render_curved_line(t("Alternate Courses"));
  496. $rtn .= "<div class='tenpt alt-courses-desc-and-lines'>
  497. " . t("You may use this space to write in alternate courses
  498. the student should enroll in, in the event that an
  499. advised course is full or unavailable.") . "
  500. <br><br>
  501. ___________________________________________________________________ <br><br>
  502. ___________________________________________________________________
  503. </div> ";
  504. $rtn .= "</div>";
  505. }
  506. $rtn .= "</table>";
  507. } // while, for the query itself!
  508. // Are we NOT returning html?
  509. if (!$bool_html) {
  510. return $txt;
  511. }
  512. fp_set_title($db->get_student_name($db_student_id, FALSE) . " ($db_student_id) $term " . t("Advising Summary"));
  513. return $rtn;
  514. }

Functions

Namesort descending Description
advise_display_history Displays the history tab on screen.
advise_popup_display_summary Displays the printable advising summary.