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 469

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 = "";

  $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);
  }

  $settings = fp_get_system_settings();


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

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

  if ($GLOBALS ["fp_advising"]["advising_term_id"] != "" && ($screen_mode != "not_advising" && $screen_mode != "detailed")
     && user_has_permission("can_advise_students")) 
   {
    $t_term_id = $GLOBALS ["fp_advising"]["advising_term_id"];
    $for_term = " " . t("for") . " " . get_term_description($t_term_id);

    // If this is an advisor or above
    $for_term .= "<span style='font-size: 8pt; font-weight:normal;'>
             - <a href='javascript: popupWindow2(\"" . base_path() . "/advise/popup-change-term\",\"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";
    // latest cat year because its what if.
    $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&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;

    }
  }

  $db = get_global_database_handler();

  if ($degree_plan != NULL) {
    $degree_title = $degree_plan->get_title2();
  }
  if ($degree_title == "") {
    // Attempt to load the degree from the student's information.     
    $degree_plan = $db->get_degree_plan($student->major_code, $student->catalog_year, true);
    $degree_title = $degree_plan->get_title2();
  }

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

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

  array_push($display_array, t("Major:") . " ~~ " . $degree_title);
  // If this degree has tracks, we must display something about it here.

  if ($degree_plan->bool_has_tracks) 
   {
    $extra_vars = "";

    /*if ($GLOBALS["advising_what_if"] == "yes")
      {
      $extra_vars .= "what_if_major_code={$GLOBALS["what_if_major_code"]}";
      $extra_vars .= "&what_if_track_code={$GLOBALS["what_if_track_code"]}";
      $extra_vars .= "&advising_what_if=yes";
      }*/

    $op_link = "<a href='javascript: popupWindow2(\"" . base_path() . "/advise/popup-change-track\",\"$extra_vars\");'><img
              src='" . fp_theme_location() . "/images/popup.gif' border='0' 
              title='" . t("Click to change degree options.") . "'></a>";
    $op_text = t("Click to select:") . " $op_link";

    if ($screen_mode == "not_advising" || $screen_mode == "detailed") 
     {
      $op_text = t("None selected");
      $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 = "";
        $op_text = t("None selected");

      }
    }


    // Did has the student already selected an option?
    if ($degree_plan->track_code != "") 
     {
      // Display the track code in detailed mode.
      $tc = ($screen_mode == "detailed") ? "($degree_plan->track_code)" : "";

      $op_text = $degree_plan->track_title . " $tc $op_link";
    }


    array_push($display_array, t("Option:") . " ~~ " . $op_text);
  }
  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, 1) . " " . t("GPA"));
  }

  if ($student->student_id > 1 || $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'> 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>Important Notice: </b>
        FlightPath cannot display degree plans from 
        catalogs earlier than " . $settings ["earliest_catalog_year"] . "-" . ($settings ["earliest_catalog_year"] + 1) . ".  
        The above student's catalog year is $cat_year, which means 
        that the degree plan below may not accurately 
        display this student's degree requirements.
      </td>
      </table>
      </div>
      
    ";
  }

  if ($bool_future_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>Important Notice: </b>
        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 {$settings ["current_catalog_year"]}-" . ($settings ["current_catalog_year"] + 1) . "
        requirements, select the student's major using What If.
      </td>
      </table>
      </div>
      
    ";
  }




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


  $rtn .= "</table>";

  return $rtn;
}