function stats_draw_majors_pulldown

7.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)
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.

1 call to stats_draw_majors_pulldown()
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 689
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) 
 {

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

  $options_array = array();


  $current_catalog_year = variable_get("current_catalog_year", "");

  $m_a_count = 0;
  if ($bool_only_current_catalog_year) {
    $query = "SELECT * FROM degrees
  				WHERE  catalog_year = '?'
  				AND `exclude`='0'
  				ORDER BY `title`  ";
    $result = db_query($query, $current_catalog_year);
  }
  else { // current catalog year not important.
    $query = "SELECT * FROM degrees
  				WHERE  `exclude`='0'
  				GROUP BY major_code
  				ORDER BY `title`  ";
    $result = db_query($query);
  }
  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"]);
    $major_array [$m_a_count]["description"] = $description;
    $major_array [$m_a_count]["major"] = $major;
    $major_array [$m_a_count]["type"] = $type;

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

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

}