function stats_draw_majors_pulldown

6.x stats.module stats_draw_majors_pulldown($smajor = "", $display_submit = FALSE, $bool_only_majors_with_tracks = FALSE, $label = "Please select a major", $bool_exclude_tracks = FALSE, $bool_only_current_catalog_year = TRUE, $bool_return_options_array = FALSE, $school_id = 0)
5.x stats.module stats_draw_majors_pulldown($smajor = "", $display_submit = FALSE, $bool_only_majors_with_tracks = FALSE, $label = "Please select a major", $bool_exclude_tracks = FALSE, $bool_only_current_catalog_year = TRUE, $bool_return_options_array = FALSE)

Display a major selection pulldown, used by other reports.

If bool_only_majors_with_tracks == TRUE, then we will only display the majors which have tracks associated with them.

If bool_exclude_tracks == TRUE, then we will skip over any major_code with a "_" in it, meaning, this code describes a track and not the base major.

If bool_only_current_catalog_year == TRUE, then only degrees from the current catalog year will be displayed.

2 calls to stats_draw_majors_pulldown()
stats_report_major_students_progress_form in modules/stats/reports.major-students-progress.inc
Simply display a form letting the user select an available major.
z__stats_report_selected_degree_options in modules/stats/stats.module
This report will show which degree options are being selected for degrees which offer options.

File

modules/stats/stats.module, line 615
This module displays statistics and reports for FlightPath

Code

function stats_draw_majors_pulldown($smajor = "", $display_submit = FALSE, $bool_only_majors_with_tracks = FALSE, $label = "Please select a major", $bool_exclude_tracks = FALSE, $bool_only_current_catalog_year = TRUE, $bool_return_options_array = FALSE, $school_id = 0) 
 {

  $rtn = "";
  $db = get_global_database_handler();
  $major_array = array();

  $options_array = array();


  $current_catalog_year = variable_get_for_school("current_catalog_year", "", $school_id);

  $m_a_count = 0;
  if ($bool_only_current_catalog_year) {
    $query = "SELECT * FROM degrees
          WHERE  catalog_year = ?
          AND school_id = ?
          AND `exclude`='0'
          ORDER BY major_code  ";
    $result = db_query($query, $current_catalog_year, $school_id);
  }
  else { // current catalog year not important.
    $query = "SELECT * FROM degrees
          WHERE  `exclude`='0'
          AND school_id = ?
          GROUP BY major_code
          ORDER BY major_code  ";
    $result = db_query($query, $school_id);
  }
  while ($cur_row = $db->db_fetch_array($result)) {
    $major = trim($cur_row ["major_code"]);

    if ($bool_exclude_tracks && strpos($major, "_")) {
      continue;
    }

    if ($bool_only_majors_with_tracks && !$db->get_degree_tracks($major, $current_catalog_year)) 
     { // only get majors that also have tracks!
      continue;
    }

    $description = trim($cur_row ["title"]);
    $type = trim($cur_row ["degree_type"]);
    $school_id = intval($cur_row ['school_id']);

    $major_array [$m_a_count]["description"] = $description;
    $major_array [$m_a_count]["major"] = $major;
    $major_array [$m_a_count]["type"] = $type;
    $major_array [$m_a_count]["school_id"] = $school_id;
    if (module_enabled("schools")) {
      $major_array [$m_a_count]["school_name"] = t("School: ") . schools_get_school_name_for_id($school_id);
    }

    $m_a_count++;


  }


  $rtn .= "
      <table border='0'>
      
          <td valign='middle'>
          
         <select name='major' id='major'>
         <option value=''>" . $label . "</option>
                      <option value=''>-----------------------------------</option>";

  for ($t = 0; $t < $m_a_count; $t++) 
   {
    $sel = "";
    if ($major_array [$t]["major"] == $smajor && $smajor != "") 
     {
      $sel = "selected";
    }
    $hyph = "-";
    if ($major_array [$t]["type"] == "" || $major_array [$t]["type"] == "NA") 
     {
      $hyph = "";
      $major_array [$t]["type"] = "";
    }

    $rtn .= "<option value='" . $major_array [$t]["major"] . "' $sel>(" . $major_array [$t]["major"] . ")
          " . $major_array [$t]["description"] . " $hyph " . $major_array [$t]["type"] . "
          </option>";

    if (module_enabled("schools")) {
      // Create an options array multi-dimentional, organized by school name.
      $options_array [$major_array [$t]["school_name"]][$major_array [$t]["major"]] = "(" . $major_array [$t]["major"] . ") " . $major_array [$t]["description"] . " $hyph " . $major_array [$t]["type"];
    }
    else {
      // Just create a "flat" options array
      $options_array [$major_array [$t]["major"]] = "(" . $major_array [$t]["major"] . ") " . $major_array [$t]["description"] . " $hyph " . $major_array [$t]["type"];
    }

  }


  $rtn .= "                </select> </td>";
  if ($display_submit == true) 
   {
    $rtn .= "<td valign='middle'><input type='submit' value='" . t("Select") . "'></td>";
  }

  $rtn .= "</table>";

  if ($bool_return_options_array) {
    return $options_array;
  }



  return $rtn;

}