function advise_display_popup_change_track

6.x advise.module advise_display_popup_change_track()
4.x advise.module advise_display_popup_change_track()
5.x advise.module advise_display_popup_change_track()

Lets the user change the track for this major.

File

modules/advise/advise.module, line 314

Code

function advise_display_popup_change_track() {
  global $degree_plan, $student;
  $rtn = "";

  advise_init_screen();

  fp_add_js(fp_get_module_path("advise") . "/js/advise.js");



  $degree_plan->load_descriptive_data();
  $rtn .= fp_render_curved_line(t("Select a Degree Option"));
  $rtn .= "<div class='tenpt'>
      " . t("This major has one or more degree options, which affects which courses are required. 
      Please select a degree option (or track) from the list below.") . "
      <br><br>
      " . t("If you are unsure of what to do, simply close this window.");

  $rtn .= "<br><br><b>" . $degree_plan->title . "</b> " . t("degree options:") . "</div><!--DEFAULT-->
      <ul>";

  // Get the list of available tracks for this student.
  if (!$tracks = $degree_plan->get_available_tracks()) 
   {
    $rtn .= "<li>" . t("This major has no degree options.") . "</li>";
  }

  // Is there a "default" message for all tracks, which will override
  // any other track descriptions?
  // We need to look through all the tracks for the
  // characters:  "DEFAULT:"
  // If we find this, then this is the default description
  // which applies to all the tracks, and it should be displayed
  // at the top.
  $bool_default_description = false;
  for ($t = 0; $t < count($tracks); $t++) 
   {
    $temp = explode(" ~~ ", $tracks [$t]);
    $track_code = trim($temp [0]);
    $track_title = trim($temp [1]);
    $track_description = trim($temp [2]);

    if (strstr($track_description, "DEFAULT:")) {
      // Yes!  We found a default message.
      $bool_default_description = true;
      $track_description = filter_markup(trim(str_replace("DEFAULT:", "", $track_description)));
      $track_description = "<div style='padding-top: 10px;' class='tenpt'>$track_description</div>";
      $rtn = str_replace("<!--DEFAULT-->", $track_description, $rtn);
      break;
    }

  }


  for ($t = 0; $t < count($tracks); $t++) 
   {
    $temp = explode(" ~~ ", $tracks [$t]);
    $track_code = trim($temp [0]);
    $track_title = trim($temp [1]);
    $track_description = "";

    // If this is the current track_code, mark it as such.
    if ($student->array_settings ["track_code"] == $track_code
     && $student->array_settings ["major_code"] == $degree_plan->major_code) 
     {
      $track_title .= " <b>(" . t("current") . ")</b>";
    }

    if ($bool_default_description == false) 
     {
      $track_description = filter_markup(trim($temp [2]));
      if ($track_description != "") 
       {
        $track_description = " - $track_description";
      }
    }

    $temp_tc = $track_code;
    if ($temp_tc == "") 
     {
      $temp_tc = "none";
    }


    $link = fp_get_js_confirm_link(t("Are you sure you wish to change degree options?"), "opener.changeTrack(\"$temp_tc\"); window.close(); ", $track_title);

    if ($GLOBALS ["fp_advising"]["advising_what_if"] == "yes") {
      $link = "<a href='javascript: popupChangeWhatIfTrack(\"$temp_tc\", \"" . t("Are you sure you wish to change degree options?") . "\");'>$track_title</a>";
    }

    $rtn .= "<li class='tenpt' style='padding:3px;'>
        $link $track_description</li>";

  }

  $rtn .= "</ul>";



  return $rtn;
}