function fp_render_currently_advising_box

4.x theme.inc fp_render_currently_advising_box($bool_hide_catalog_warning = false, $bool_blank = FALSE, $bool_print = FALSE, $degree_plan = NULL, $screen_mode = "")
5.x theme.inc fp_render_currently_advising_box($bool_hide_catalog_warning = false, $bool_blank = FALSE, $bool_print = FALSE, $degree_plan = NULL, $screen_mode = "")

Draws the CurrentlyAdvisingBox which appears at the top of the screen, containing the student's information like name, major, etc.

Parameters

bool $bool_hide_catalog_warning:

  • If set to TRUE, FP will not display a warning which tells the user that they are working under an outdated catalog year.

Return value

string

1 call to fp_render_currently_advising_box()
fp_display_page in includes/theme.inc
Output the contents of the $page variable to the screen. $page is an array containing details about the page, as well as its original menu item (router_item) definition.

File

includes/theme.inc, line 515

Code

function fp_render_currently_advising_box($bool_hide_catalog_warning = false, $bool_blank = FALSE, $bool_print = FALSE, $degree_plan = NULL, $screen_mode = "") {
  global $current_student_id, $screen, $user, $student;

  $rtn = "";
  $bool_catalog_warning = FALSE;
  $bool_future_catalog_warning = FALSE;

  $csid = $current_student_id;

  if (is_object($screen) && is_object($screen->degree_plan)) {
    $degree_plan = $screen->degree_plan;
  }

  if (!isset($student) || $student == null || !is_object($student)) {
    $student = new Student($csid);
  }

  if ($degree_plan == null) {
    // Degree plan is still null.  This probably means we are NOT on an advising screen, so, let's
    // use a FlightPath object to init our degree plan, which might actually be a combination of degrees.


    // First, we can cheat by seeing if we have anything cached for this student the last time their degree plan
    // was loaded.  Using this,
    // its much faster & memory-friendly than trying to re-init a whole new FlightPath object and DegreePlan object(s).
    $bool_got_from_simple_cache = FALSE;
    // TODO:  Check for _what_if if we are in what if mode?

    if (isset($_SESSION ["fp_simple_degree_plan_cache_for_student"])) {
      if ($_SESSION ["fp_simple_degree_plan_cache_for_student"]["cwid"] == $csid) {
        // Yes, it's for this student.  Load her up.
        $degree_plan = new DegreePlan();
        $degree_plan->degree_id = $_SESSION ["fp_simple_degree_plan_cache_for_student"]["degree_id"];
        $degree_plan->combined_degree_ids_array = $_SESSION ["fp_simple_degree_plan_cache_for_student"]["combined_degree_ids_array"];
        $degree_plan->is_combined_dynamic_degree_plan = $_SESSION ["fp_simple_degree_plan_cache_for_student"]["is_combined_dynamic_degree_plan"];


        $bool_got_from_simple_cache = TRUE;
      }
    }

    if (!$bool_got_from_simple_cache) {
      // didn't get it from the simple cache, so load it all fresh.
      $fp = new FlightPath($student);
      $fp->init(TRUE);
      $degree_plan = $fp->degree_plan;
    }
  }



  $settings = fp_get_system_settings();


  $rtn .= "<table class='fp-currently-advising'>";

  $for_term = $whatif = $what_if_select = $hypoclass = "";

  $advising_term_id = @$GLOBALS ["fp_advising"]["advising_term_id"];

  if ($advising_term_id != "" && ($screen_mode != "not_advising" && $screen_mode != "detailed")
     && user_has_permission("can_advise_students")) 
   {
    // If this is someone who is allowed to change terms. (advisor or above)

    $t_term_id = $advising_term_id;
    $for_term = " " . t("for") . " ";
    $termdesc = get_term_description($t_term_id);


    $furl = fp_url("advise/popup-change-term");

    // Let's make the change-term link a little more intuitive.
    $for_term .= "<span class='currently-advising-box-change-term'><a href='javascript: popupWindow2(\"" . $furl . "\",\"advising_term_id=$t_term_id\");'>$termdesc</a></span>";



    /*
      $for_term .= "<span style='font-size: 8pt; font-weight:normal;'>
             - <a href='javascript: popupWindow2(\"" . $furl . "\",\"advising_term_id=$t_term_id\");' style='color:blue; background-color: white; border: 1px solid black; padding-left: 3px; padding-right: 3px;'>" . t("change") . "<img src='" . fp_theme_location() . "/images/calendar1.jpg' height='13' border='0' style='vertical-align: bottom;'></a>
            </span>";
      */

  }

  // TODO:  bool_blank? bool_print?
  if (@$GLOBALS ["fp_advising"]["advising_what_if"] == "yes" && !$bool_blank) 
   {
    $whatif = " (" . t("in \"What If\" mode") . ") ";
    $hypoclass = "hypo";

    // Set the cat year to whatever our What If cat year was, current if we can't find it.
    $what_if_catalog_year = @$GLOBALS ["fp_advising"]["what_if_catalog_year"];
    if ($what_if_catalog_year != 0 && $what_if_catalog_year != "") {
      $student->catalog_year = $what_if_catalog_year;
    }
    else {

      // Only change to current if that is how our settings are set...
      if (variable_get("what_if_catalog_year", "current") == "current") {
        $student->catalog_year = $settings ["current_catalog_year"];
      }
    }


    if ($bool_print != true) {
      $what_if_select = "<div class='tenpt'><b>
          " . l(t("Change What If Settings"), "what-if", "advising_what_if=yes&what_if_major_code=none&what_if_track_code=none&what_if_track_degree_ids=none&current_student_id=$current_student_id") . "
          </b></div>";
    }
  }

  $ca = t("Currently Advising");

  if (!user_has_permission("can_advise_students") || $screen_mode == "detailed") {
    $ca = t("Student Details");
  }

  if ($bool_blank == true) {
    $ca = t("Viewing Blank Degree Plan");
  }


  $rtn .= "<tr><td colspan='2' style='padding-bottom: 10px;'>
        $what_if_select
      <table border='0' width='100%'  class='elevenpt blueBorder' cellpadding='0' cellspacing='0' >
      <tr>
          <td colspan='4' class='blueTitle' align='center' height='20'>
          " . fp_render_square_line("$ca$whatif$for_term") . "
          </td>                    
      </tr>
      ";

  // Okay, let's build up the display array.
  $display_array = array();

  // How to display the catalog_year...
  $cat_year = $student->catalog_year . "-" . ($student->catalog_year + 1);

  // Should we display a catalog year warning?  This is
  // something that can be part of a settings table.
  if ($student->catalog_year < $settings ["earliest_catalog_year"]) {
    $cat_year = "<b>$cat_year</b>";
    $bool_catalog_warning = true;
  }

  if ($settings ["current_catalog_year"] > $settings ["earliest_catalog_year"]) {
    // Is the student's catalog set beyond the range that
    // FP has data for?  If so, show a warning.
    if ($student->catalog_year > $settings ["current_catalog_year"]) 
     {
      $cat_year = "<b>$cat_year</b>";
      $bool_future_catalog_warning = true;

    }
  }


  if (!$bool_blank) {
    array_push($display_array, t("Name:") . " ~~ " . $student->name);
    array_push($display_array, t("CWID:") . " ~~ " . $student->student_id);
  }


  $db = get_global_database_handler();


  ///////////////////////////
  $degree_title_div = "";
  $s = ""; // plural degrees?
  $bool_show_track_selection_link = FALSE;
  // We are trying to figure out what to display for the Degree field.  If there is only ONE degree plan
  // to worry about, then we will display it.
  if ($degree_plan == null || $degree_plan->is_combined_dynamic_degree_plan != TRUE) {
    // This is an ordinary degree plan.

    $use_degree_plan = $degree_plan;

    $degree_title = "";
    if ($degree_plan != NULL) {
      $degree_title = $degree_plan->get_title2(TRUE);
    }

    /**
     * This degree is in fact a track.
     */
    if (strstr($degree_plan->major_code, "_")) {
      $degree_title = $degree_plan->get_title2(TRUE, TRUE);

      if ($degree_plan->db_allow_dynamic == 0) {
        // This degree is NON-dynamic.  Meaning, if we change tracks, we should do it from the perspective
        // of the original major code, and how FP 4.x did things.
        $temp = explode("_", $degree_plan->major_code);
        $m = trim($temp [0]);
        // Remove trailing | if its there.
        $m = rtrim($m, "|");

        $use_degree_plan = $db->get_degree_plan($m, $degree_plan->catalog_year, TRUE); // the original degree plan!          
      }
    }


    if ($screen_mode == "detailed") {
      $degree_title .= " ($degree_plan->major_code)";
    }

    if ($use_degree_plan != null && $use_degree_plan->get_available_tracks()) {
      $bool_show_track_selection_link = TRUE;

    }

    $degree_title_div = "<div class='degree-title'>$degree_title</div>";

    //array_push($display_array, t("Degree:") . " ~~ " . $degree_title);

  }
  else {
    // This degree plan is made from combining several other degrees.  let's trot them out and display them as well.
    $t_degree_plan_titles = "";
    foreach ($degree_plan->combined_degree_ids_array as $t_degree_id) {
      $t_degree_plan = new DegreePlan();
      $t_degree_plan->degree_id = $t_degree_id;

      $t_degree_plan->load_descriptive_data();

      if ($t_degree_plan->get_available_tracks()) {
        $bool_show_track_selection_link = TRUE;
      }


      // Add it to our box...
      // If more than one major/minor, etc, combine them into one div
      $t_title = $t_degree_plan->get_title2(TRUE);
      $t_class = $t_degree_plan->degree_class;
      $t_class_details = fp_get_degree_classification_details($t_class);
      // If this is actually a track, let's get the track's title instead.
      if ($x = $t_degree_plan->get_track_title(TRUE)) {
        $t_title = $x;
      }

      if ($t_class_details ["level_num"] == 3) {
        $t_title = "<span class='level-3-raquo'>&raquo;</span>" . $t_title;
      }

      $machine_major_code = fp_get_machine_readable($t_degree_plan->major_code);
      if ($t_degree_plan->track_code != "") {
        $machine_major_code .= "-" . fp_get_machine_readable($t_degree_plan->track_code);
      }


      $t_degree_plan_titles .= "<div class='multi-degree-title multi-degree-class-" . $t_class . "
                                      multi-degree-class-level-" . $t_class_details ["level_num"] . "
                                      multi-degree-code-$machine_major_code '> 
                                      " . $t_title . "</div>";
      $s = "s";
    }
    $degree_title_div = $t_degree_plan_titles;

  }

  // Now, do we want to add an option to select a track to the degree_title_div?
  if ($bool_show_track_selection_link) {
    // Are we in what_if mode?
    $advising_what_if = @$GLOBALS ["fp_advising"]["advising_what_if"];
    // We want to add a link to the popup to let the user select other degree tracks.
    $op_link = "<a class='degree-op-link-change-degree-options' href='javascript: popupWindow2(\"" . fp_url("advise/popup-change-track", "advising_what_if=$advising_what_if") . "\",\"\");'
                    style='background: url(" . fp_theme_location() . "/images/popup.gif) no-repeat top left;
                            padding-left: 20px; text-decoration: none; font-size: 0.8em;'
                    >Change degree options</a>";

    if ($screen_mode == "not_advising" || $screen_mode == "detailed") {
      $op_link = "";
    }

    if (!user_has_permission("can_advise_students")) {

      if (@$GLOBALS ["fp_advising"]["advising_what_if"] != "yes") 
       {
        // In other words, we do not have permission to advise,
        // and we are not in whatIf, so take out the link.
        $op_link = "";
      }
    }

    if ($op_link) {
      $degree_title_div .= "<div class='degree-op-link' style='text-align: right;'>$op_link</div>";
    }
  }

  // Add our "degrees" section....
  array_push($display_array, t("Degree$s:") . " ~~ " . $degree_title_div);






  if (!$bool_blank) {
    array_push($display_array, t("Rank:") . " ~~ " . $student->rank);
  }

  array_push($display_array, t("Catalog Year:") . " ~~ " . $cat_year);

  if (!$bool_blank) {
    array_push($display_array, t("Cumulative:") . " ~~ " . $student->cumulative_hours . " " . t("hrs") . ". &nbsp;" . fp_truncate_decimals($student->gpa, 3) . " " . t("GPA"));
  }


  // Invoke a hook, letting other modules act on the "display array".
  invoke_hook('alter_currently_advising_box', array(&$display_array));




  if ($student->student_id != "" || $bool_blank == true) 
   { // Make sure we have selected a student! (or are viewing a blank plan)
    // Now, go through the array and display it.
    for ($t = 0; $t < count($display_array); $t = $t + 2) 
     {
      $temp = explode(" ~~ ", $display_array [$t]);
      $name1 = trim($temp [0]);
      $value1 = trim($temp [1]);


      $temp = @explode(" ~~ ", $display_array [$t + 1]);
      $name2 = @trim($temp [0]);
      $value2 = @trim($temp [1]);


      if (fp_screen_is_mobile()) {
        // Mobile screen.  Needs to be more condensed.
        $rtn .= "<tr class='$hypoclass'>
                  <td valign='top'>$value1</td>
                  <td valign='top'>$value2</td>
                  </tr>";
      }
      else {
        // Regular desktop screen. 

        $rtn .= "
        
            <tr class='$hypoclass' >
              <td valign='top' width='20%' class='side_padding' style='padding-top: 5px;'>
                 $name1
              </td>
              <td width='30%' valign='top' class='side_padding elevenpt' style='padding-top: 5px;'>
                $value1
              </td>
              <td valign='top' align='left' width='20%' class='side_padding elevenpt' style='padding-top: 5px;'>
                   $name2
              </td>
               <td align='right' width='30%' valign='top' class='side_padding elevenpt' style='padding-top: 5px;'>
                   $value2
                </td>
            </tr>  ";

      }

    }
  }
  else {
    // No student has been selected yet!
    $rtn .= "<tr height='60'>
        <td align='center' class='no-advisee-selected'> " . t("No advisee selected.") . " </td>
      </tr>";
    $bool_hide_catalog_warning = true;
  }


  $rtn .= "</table>";

  if ($bool_catalog_warning == true && !$bool_hide_catalog_warning) 
   {
    $rtn .= "
      
      <div class='tenpt hypo' style='margin-top: 4px; padding: 2px;'>
      <table border='0' cellspacing='0' cellpadding='0'>
      <td valign='top'>
        <img src='" . fp_theme_location() . "/images/alert_lg.gif' >  
      </td>
      <td valign='middle' class='tenpt' style='padding-left: 8px;'>
        <b>" . t("Important Notice:") . " </b>
        " . t("FlightPath cannot display degree plans from 
        catalogs earlier than @earliest.
        The above student's catalog year is @current, which means 
        that the degree plan below may not accurately 
        display this student's degree requirements.", array("@earliest" => $settings ["earliest_catalog_year"] . "-" . ($settings ["earliest_catalog_year"] + 1), "@current" => $cat_year)) . "
      </td>
      </table>
      </div>
      
    ";
  }

  if ($bool_future_catalog_warning == true && !$bool_hide_catalog_warning) 
   {


    $msg = t("This student's catalog year is @cat_year, 
        and specific curriculum requirements are not yet 
        available for this year.  
        To advise this student according to @new_cat
        requirements, select the student's major using What If.", array("@cat_year" => $cat_year, "@new_cat" => "{$settings ["current_catalog_year"]}-" . ($settings ["current_catalog_year"] + 1)));

    // If the what_if catalog year is in "student" mode, we can't tell them to use What If, cause it won't work.
    if (variable_get("what_if_catalog_year", "current") == "student") {
      $msg = t("This student's catalog year is @cat_year, 
          and specific curriculum requirements are not yet 
          available for this year.", array("@cat_year" => $cat_year));

    }



    $rtn .= "
      
      <div class='tenpt hypo' style='margin-top: 4px; padding: 2px;'>
      <table border='0' cellspacing='0' cellpadding='0'>
      <td valign='top'>
        <img src='" . fp_theme_location() . "/images/alert_lg.gif' >  
      </td>
      <td valign='middle' class='tenpt' style='padding-left: 8px;'>
        <b>" . t("Important Notice:") . " </b>
        $msg
      </td>
      </table>
      </div>
      
    ";
  }




  $rtn .= "</td></tr>";


  $rtn .= "</table>";

  return $rtn;
}