function z__student_search_render_advisees

7.x student_search.module z__student_search_render_advisees($adv_array, $title)
6.x student_search.module z__student_search_render_advisees($adv_array, $title)

File

modules/student_search/student_search.module, line 1021

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...  
    $student_id = $adv_array [0]["student_id"];
    $first_name = $adv_array [0]["first_name"];
    $last_name = $adv_array [0]["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_curved_line($title);


  $rtn .= "<table width='100%' align='left'
            border='0' cellpadding='0' cellspacing='0'>
            ";

  // Do not show headers at all if mobile
  if (!fp_screen_is_mobile()) {
    $rtn .= "
     <tr>
      <td width='5%' valign='top'>&nbsp; </td>
      <td width='12%' valign='top' class='tenpt'><b>" . t("CWID") . "</b></td>
      <td width='15%' valign='top' class='tenpt'><b>" . t("First Name") . "</b></td>
      <td width='20%' valign='top' class='tenpt'><b>" . t("Last Name") . "</b></td>
      <td width='15%' valign='top' class='tenpt'><b>" . t("Major Code") . "</b></td>
      <td width='10%' valign='top' class='tenpt'><b>" . t("Rank") . "</b></td>
      <td width='15%' valign='top' class='tenpt'><b>" . t("Catalog Year") . "</b></td>
     </tr> ";
  }

  $rtn .= "
    ";

  $db = get_global_database_handler();

  for ($t = 0; $t < count($adv_array); $t++) 
   {

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

    //fpm($adv_array);

    /*
    $on_mouse = "onmouseover=\"style.backgroundColor='#FFFF99'\"
               onmouseout=\"style.backgroundColor='white'\"
                ";
     */

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

    // Build up the URL we want to go to when we click this row.
    $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 height='19'>
          <td colspan='7'>
          <table border='0' 
            $on_mouse  
            onClick='showUpdate(true); window.location=\"$url\"; '                 
             width='100%' 
             class='student_search_advisee_results'>
                  <tr height='20'>
                    <td width='5%' class='ss-advised-image'>$advised_image</td>  
                    <td width='12%' class='ss-student-id'>$student_id</td>
                    <td width='15%' class='ss-student-fn'>$first_name</td>
                    <td width='20%' class='ss-student-ln'>$last_name</td>    
                    <td width='15%' class='ss-student-major'>$disp_major</td>
                    <td width='10%' class='ss-student-rank'>$rank</td>
                    <td width='15%' class='ss-student-catalog-year'>$catalog_year</td>
                 </tr>
              </table>   
            </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>";

  }




  // Required to make the changeTab function work...
  $rtn .= "<form id='mainform' method='POST'>
      <input type='hidden' id='scrollTop'>
      <input type='hidden' id='performAction' name='performAction'>
      <input type='hidden' id='advisingWhatIf' name='advisingWhatIf'>
      <input type='hidden' id='currentStudentID' name='currentStudentID'>
      <input type='hidden' id='advisingStudentID' name='advisingStudentID'>
      <input type='hidden' id='advisingMajorCode' name='advisingMajorCode'>
      <input type='hidden' id='whatIfMajorCode' name='whatIfMajorCode'>
      <input type='hidden' id='whatIfTrackCode' name='whatIfTrackCode'>
      <input type='hidden' id='advisingLoadActive' name='advisingLoadActive'>
      <input type='hidden' id='clearSession' name='clearSession'>
      </form>";


  ////  IMPORTANT///////////
  $rtn .= "&nbsp;"; // Not sure why, but adding this to the end fixes a display bug in Chrome, so I'm going to leave it here.
  ///////////////////



  return $rtn;
}