function course_search_display_search

7.x course_search.module course_search_display_search()
6.x course_search.module course_search_display_search()
4.x course_search.module course_search_display_search()
5.x course_search.module course_search_display_search()

Displays the search pulldown for the user to use to find courses.

File

modules/course_search/course_search.module, line 823
This module allows users to search for courses, descriptions, and, if supported, rotation schedules and sample syllabi.

Code

function course_search_display_search() {

  $rtn = "";

  fp_add_css(fp_get_module_path("course_search") . "/css/course_search_style.css");

  if (fp_screen_is_mobile()) {
    fp_add_css(fp_get_module_path("course_search") . "/css/course_search_mobile_style.css");
  }


  $rtn .= "";

  if (user_has_permission("can_update_course_info_details")) {
    $rtn .= "<div>" . t("Administrators:") . " " . l(t("Edit course schedules and syllabi"), "tools/course-search/edit-list") . "</div>";
  }

  $rtn .= fp_render_curved_line("Course Search");


  $settings = fp_get_system_settings();
  $current_catalog_year = $settings ["current_catalog_year"];
  // catalog_year is always just whatever the current year is.
  $catalog_year = $current_catalog_year;

  if ($catalog_year == "") 
   {

    $rtn .= "Please select an available catalog year from the
      list below.<br><br>
      <form action='" . $GLOBALS ["fp_system_settings"]["base_path"] . "/tools/course-search' method='GET' name='mainform' id='myform'>
      <table align='center'>
      <td width='150' valign='bottom'>
        <select name='catalog_year'>";
    for ($t = $current_catalog_year; $t >= $GLOBALS ["fp_system_settings"]["earliest_catalog_year"]; $t--) 
     {
      $rtn .= "<option value='$t'>$t - " . ($t + 1) . "</option> \n";

    }
    $rtn .= "</select>
      </td>
      <td valign='bottom'>
        <input type='submit' value='Select ->'>
      </td>
      </table>
      </form>";

  }
  else {
    // Catalog year has been selected.

    $rtn .= "Current catalog year: <b>$catalog_year-" . ($catalog_year + 1) . "</b>
        
        <br><br>
      Please select an available subject from the list below.<br>       
      <br>
      <form action='" . $GLOBALS ["fp_system_settings"]["base_path"] . "/tools/course-search/courses' method='GET' name='mainform' id='myform'>";

    if (!fp_screen_is_mobile()) {
      $rtn .= "
        <div align='center'>
          <select name='subject_id' style='width: 80%;'>
        ";
    }


    // We want to make a pull-down list of all available subjects.
    // Keep in mind with this join-- we may have courses who have
    // a subject_id, for which we don't have that subject in the subjects
    // table.


    $query = "SELECT DISTINCT b.subject_id, a.title FROM courses b LEFT JOIN subjects a
              ON (a.subject_id = b.subject_id)
              WHERE exclude = 0
              AND catalog_year = '?'
              ";

    $subjects = array();
    $result = db_query($query, $catalog_year);
    while ($cur = db_fetch_array($result)) 
     {
      //fpm($cur);
      $title = trim($cur ["title"]);
      $subject_id = trim($cur ["subject_id"]);

      if ($title == "") {
        $title = $subject_id;
      }

      $subjects [$subject_id] = $title;
    }

    asort($subjects);

    foreach ($subjects as $subject_id => $title) {
      if (!fp_screen_is_mobile()) {
        $rtn .= "<option value='$subject_id'>$title ($subject_id)</option>";
      }
      else {
        $rtn .= "<a class='course-search-subject-select-line'
                  href='" . fp_url("tools/course-search/courses", "subject_id=$subject_id") . "'>
                    <div class='course-search-dept-name'>$title ($subject_id)</div>
                  </a>";
      }


    }

    if (!fp_screen_is_mobile()) {
      $rtn .= "
          </select>       
          <input type='hidden' name='mode' value='$mode'>
          </div><br><br><br>
          <div align='right'>
          <input type='submit' value='Select ->'>
        </div>";
    }

    $rtn .= "</form>";

  }


  return $rtn;
}