function z______student_search_render_advisees

6.x student_search.module z______student_search_render_advisees($adv_array, $title)

File

modules/student_search/student_search.module, line 1420

Code

function z______student_search_render_advisees($adv_array, $title) {
  $rtn = "";

  fp_add_css(fp_get_module_path("student_search") . "/css/student_search.css");

  $bool_redirect_one = FALSE;

  if (count($adv_array) == 1 && @$_REQUEST ["did_search"] == "true") 
   {
    // Since there was only 1 result, we want to redirect this person directly.
    // Draw this person's name...  
    $details = reset($adv_array);
    $student_id = $details ["student_id"];
    $first_name = $details ["first_name"];
    $last_name = $details ["last_name"];

    $rtn .= "<div class='hypo' style='border: 1px solid black;
              margin: 10px 0px 10px 0px; padding: 10px; 
              font-size: 12pt; font-weight: bold;'>
        " . t("Loading") . " <span style='color:blue;'>$first_name $last_name</span> ($student_id).  
          &nbsp; " . t("Please wait...") . "
        </div>";
    $bool_redirect_one = TRUE;
  }


  $rtn .= fp_render_section_title($title, "search-results");


  $rtn .= "<table width='100%' align='left'
            border='0' cellpadding='0' cellspacing='0'>
   <tr class='headers'>
    <th width='5%' valign='top'>&nbsp; </td>
    <th width='12%' >" . t("CWID") . "</th>
    <th width='15%' >" . t("First Name") . "</th>
    <th width='20%' >" . t("Last Name") . "</th>
    <th width='15%' >" . t("Major Code") . "</th>
    <th width='10%' >" . t("Rank") . "</th>
    <th width='15%' >" . t("Catalog Year") . "</th>
   </tr> ";


  $rtn .= "
    ";

  $db = get_global_database_handler();

  foreach ($adv_array as $t => $details) {

    $student_id = $adv_array [$t]["student_id"];
    $first_name = $adv_array [$t]["first_name"];
    $last_name = $adv_array [$t]["last_name"];
    $major = $adv_array [$t]["major"];

    $advising_what_if = @$adv_array [$t]["advising_what_if"];
    $what_if_major_code = @$adv_array [$t]["what_if_major_code"];
    $what_if_track_code = @$adv_array [$t]["what_if_track_code"];
    $what_if_catalog_year = @$adv_array [$t]["what_if_catalog_year"];
    $degree_id = @$adv_array [$t]["degree_id"];
    $rank = @$adv_array [$t]["rank"];
    $catalog_year = @$adv_array [$t]["catalog_year"];

    // There is no $screen variable-- old code?
    //if ($screen->page_is_mobile) {
    //  $catalog_year = get_shorter_catalog_year_range($catalog_year, false, true);
    //}

    $advising_session_id = $adv_array [$t]["advising_session_id"];
    $advised_image = $adv_array [$t]["advised_image"];



    $on_mouse = "
            onmouseover='$(this).addClass(\"selection_highlight\");'
            onmouseout='$(this).removeClass(\"selection_highlight\");'
    ";
    // No screen var defined. Old code?
    //if ($screen->page_is_mobile) $on_mouse = ""; // Causes problems on mobile devices.


    // TODO:  The path could be the student profile instead, depending on the user's settings.    
    // Build up the URL we want to go to when we click this row.

    $path = 'student-select';

    /*
    $path = "view";
    $advising_what_if = "no";
    if ($what_if_major_code != "") {
      $path = "what-if";
      $advising_what_if = "yes";            
    }
    */

    // Add in the query part.
    $query = "";
    $query .= "advising_student_id=$student_id&current_student_id=$student_id&advising_major_code=$major&advising_what_if=$advising_what_if";
    $query .= "&what_if_major_code=$what_if_major_code&what_if_track_code=$what_if_track_code&what_if_catalog_year=$what_if_catalog_year&advising_load_active=yes&clear_session=yes";

    $url = fp_url($path, $query);

    // old onCLick:
    //<!-- onClick='selectStudent(\"$student_id\",\"$major\",\"$what_if_major_code\",\"$what_if_track_code\")' -->

    $disp_major = "";
    $temp = csv_to_array($major);
    foreach ($temp as $code) {
      $csscode = fp_get_machine_readable($code);
      // Was this a track code or not?  Meaning, did it contain |_
      $is_track = "no";
      if (strstr($code, "|_")) {
        $is_track = "yes";
      }

      $disp_major .= "<div class='ss-major-code ss-major-code-$csscode ss-major-code-is-track-$is_track'>$code</div>";
    }



    $rtn .= "
      <tr class='search-result-row' $on_mouse  onClick='showUpdate(true); window.location=\"$url\"; '>
          
            <td class='ss-advised-image'>$advised_image</td>  
            <td class='ss-student-id'>$student_id</td>
            <td class='ss-student-fn'>$first_name</td>
            <td class='ss-student-ln'>$last_name</td>    
            <td class='ss-student-major'>$disp_major</td>
            <td class='ss-student-rank'>$rank</td>
            <td class='ss-student-catalog-year'>$catalog_year</td>
           
         </tr>
         ";

  } // for t advisee array


  $rtn .= "</table>";



  if ($bool_redirect_one) {
    // There was only one result, and it was a search, so we want to redirect
    // this person.
    // We will use the URL we created in the foreach loop above.  It will still contain exactly
    // what we need.
    $rtn .= "<script type='text/javascript'>
        
        $(document).ready(function() {
          setTimeout('window.location=\"$url\";', 0);
        });

        </script>";

  }





  return $rtn;
}