function advise_display_popup_group_select

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

File

modules/advise/advise.module, line 496

Code

function advise_display_popup_group_select() {
  global $current_student_id, $fp, $screen, $degree_plan;
  $rtn = "";

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

  $settings = fp_get_system_settings();

  $blank_degree_id = trim($_GET ["blank_degree_id"]);
  $course_id = trim($_GET ["course_id"]);
  $group_id = trim(addslashes($_GET ["group_id"]));
  $group_hours_remaining = trim(addslashes($_GET ["group_hours_remaining"]));
  $semester_num = trim(addslashes($_GET ["semester_num"]));
  $perform_action2 = $_REQUEST ["perform_action2"];

  // If this is a "blank" degree, make sure we set the degree_id correctly.
  if ($blank_degree_id != "") {
    $degree_plan = new DegreePlan($blank_degree_id);
    $fp->degree_plan = $degree_plan;
    $screen->degree_plan = $degree_plan;
    $screen->bool_blank = TRUE;
  }

  if (!$group = $degree_plan->find_placeholder_group($group_id, $semester_num)) {
    fpm("Could not find group $group_id in semester $semester_num.");
  }

  if ($group_id == -88) {
    // This is the Add a Course group.  We must initialize it, as it
    // does not exist yet.
    // We need to populate this group now.
    $group->list_courses = $fp->get_all_courses_in_catalog_year($settings ["current_catalog_year"]);
    $group->title = "Add an Additional Course";
    $group->list_courses->assign_group_id($group_id);
    $group->list_courses->load_course_descriptive_data();
  }


  if ($course_id != "") {
    // Meaning, a course_id was specified, so make sure
    // it is "selected" inside the group and branches.

    $course = new Course();
    $course->course_id = $course_id;

    $temp_course_list = $group->find_courses($course);
    if (!$temp_course_list) {
      $temp_course_list = $degree_plan->find_courses($course_id, $group_id, $semester_num);
    }

    if ($temp_course_list) {
      $temp_course_list->reset_counter();
      while ($temp_course_list->has_more()) {
        $temp_course = $temp_course_list->get_next();
        $temp_course->bool_selected = true;
        //$temp_course->assigned_to_semester_num = $semester_num;
      }
    }
  }

  if ($perform_action2 == "" || $perform_action2 == "select") {
    if ($group) {
      $rtn .= $screen->display_popup_group_select($group, $group_hours_remaining);
    }
    // Create the tabs for the page...
    $tab_array = array();
    $tab_array [0]["title"] = "Description";
    $tab_array [0]["on_click"] = "popupDescribeSelected(\"$group_id\",\"$semester_num\",\"0\",\"\",\"group_hours_remaining=$group_hours_remaining&blank_degree_id=$blank_degree_id\");";
    $tab_array [1]["title"] = "Select";
    $tab_array [1]["active"] = true;

    // If we are allowed to substitute....
    if (user_has_permission("can_substitute") && $group_id != -88 && !$screen->bool_blank) {
      $tab_array [2]["title"] = "Substitute";
      $tab_array [2]["on_click"] = "popupSubstituteSelected(\"0\",\"$group_id\",\"$semester_num\",\"group_hours_remaining=$group_hours_remaining\");";
    }

  }

  if ($perform_action2 == "describe_course") {
    $rtn .= $screen->display_popup_course_description($course_id, null, $group, true);
    // Create the tabs for the page...
    $tab_array = array();
    $tab_array [0]["title"] = "Description";
    $tab_array [0]["active"] = true;
    $tab_array [1]["title"] = "Select";
    $subject = trim($_GET ["selected_subject"]);

    $tab_array [1]["on_click"] = "popupBackToGroupSelect(\"$course_id\",\"$group_id\",\"$semester_num\",\"selected_subject=$subject&group_hours_remaining=$group_hours_remaining&blank_degree_id=$blank_degree_id\");";

    // If we are allowed to substitute....
    if (user_has_permission("can_substitute") && $group_id != -88 && !$screen->bool_blank) {
      $tab_array [2]["title"] = "Substitute";
      $tab_array [2]["on_click"] = "popupSubstituteSelected(\"$course_id\",\"$group_id\",\"$semester_num\",\"group_hours_remaining=$group_hours_remaining\");";
    }


  }

  if ($tab_array) {
    fp_set_page_tabs($tab_array);
  }


  return $rtn;
}