admin_display_degrees

5.x admin.degrees.inc admin_display_degrees()
4.x admin.degrees.inc admin_display_degrees()

File

modules/admin/admin.degrees.inc, line 712

Code

function admin_display_degrees() {

  // Do this using $render array, so it can be altered
  // by hook_content_alter

  $render = array();
  $render['#id'] = 'admin_display_degrees';


  $de_catalog_year = admin_get_de_catalog_year();
  $rtn = "";

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


  //$rtn .= "<h2 class='title'>" . t("Degrees for @year", array("@year" => $de_catalog_year)) . "</h2>";  

  $render['title_top'] = array(
    'value' => "<h2 class='title'>" . t("Degrees for @year", array("@year" => $de_catalog_year)) . "</h2>",
  );

  /*
  $rtn .= "<div class='admin-degrees-upper-links'>";  
  $rtn .= l("Add new degree plan (major, degree plan, or track)", "admin/degrees/add-degree", "de_catalog_year=$de_catalog_year");
  $rtn .= " &nbsp; &nbsp; | &nbsp; &nbsp; ";
  $rtn .= l("Copy a degree plan", "admin/degrees/copy-degree", "de_catalog_year=$de_catalog_year");
  $rtn .= "</div>";
  */

  $render['upper_links'] = array(
    'value' => "<div class='admin-degrees-upper-links'>  
                " . l("Add new degree plan (major, degree plan, or track)", "admin/degrees/add-degree", "de_catalog_year=$de_catalog_year") . "
                &nbsp; &nbsp; | &nbsp; &nbsp;
                " . l("Copy a degree plan", "admin/degrees/copy-degree", "de_catalog_year=$de_catalog_year") . "</div>",
  );


  $filter_class = @$_REQUEST["filter_class"];

  $html = "";
  $html .= "<div class='degrees-filter'>
              <form id='filter-form' action='" . fp_url("admin/degrees") . "' method='GET'>
              <input type='hidden' name='de_catalog_year' value='$de_catalog_year'>
          ";

  if (!variable_get("clean_urls", FALSE)) {
    // Clean URLs is not enabled, so add in the q=admin/degrees, to make this form work.
    $html .= "<input type='hidden' name='q' value='admin/degrees'>";
  }

  $html .= "
              <b>Filter list by...</b>
              <br>Class: &nbsp; 
           
              <select name='filter_class' onChange='showUpdate(true);$(\"#filter-form\").submit();'> 
              <option value=''>- Show all -</option>";

  // Display degree_class pulldown.
  $degree_classes = fp_get_degree_classifications();
  foreach ($degree_classes["levels"] as $level => $details) {
    foreach ($degree_classes["levels"][$level] as $machine_name => $title) {
      $sel = "";
      if ($machine_name == $filter_class) {
        $sel = "selected";
      }

      $html .= "<option value='$machine_name' $sel>$level - $title</option>";
    }
  }

  $html .= " </select>            
            </form>
               
           </div>";


  $render['degrees_filter'] = array(
    'value' => $html,
  );

  /*
  $rtn .= "<table class='degrees-table' border='0' width='100%' cellpadding='5' cellspacing='0'>
            <tr>
              <th width='8%'>Type</th>
              <th width='15%'>Class</th>
              <th width='60%'>Title</th>
              <th>Code</th>
            </tr>";
  */

  $render['degrees_table_top'] = array(
    'value' => "<table class='degrees-table' border='0' width='100%' cellpadding='5' cellspacing='0'>
                  <tr>
                    <th width='8%'>Type</th>
                    <th width='15%'>Class</th>
                    <th width='60%'>Title</th>
                    <th>Code</th>
                  </tr>",
  );


  $res = db_query("SELECT * FROM draft_degrees
              WHERE catalog_year = ?
             ORDER BY degree_type, major_code, title ", $de_catalog_year);

  while ($cur = db_fetch_array($res)) {

    $db_exclude = 0;
    extract($cur, 3, "db");

    // We filtered for a particular class, and we didn't find it, so skip.
    if ($filter_class != "" && $db_degree_class != $filter_class) {
      continue;
    }


    if ($db_degree_type == "NA" && strstr($db_major_code, "|")) {
      $db_degree_type = " -- ";
    }

    $extra_class = "";
    if ($db_exclude == "1") {
      $extra_class = "list-degree-row-excluded";
    }
    $degree_title = $db_title;

    // get JUST the major code...
    $temp = explode("|", $db_major_code);
    $just_major = trim(@$temp[0]);
    $just_conc = trim(@$temp[1]);
    $outside = "";

    //if ($just_conc != "" && strstr($just_conc, "_"))
    if (strstr($just_conc, "_")) {
      // If the concentration has an underscore, it's actually
      // a track.  Let's get the track title...
      $temp2 = explode("_", $just_conc);
      $just_track = trim($temp2[1]);
      // Might need to add the first part BACK onto the major...
      if (trim($temp2[0]) != "") {
        $just_major .= "|" . trim($temp2[0]);
      }


      $res2 = db_query("SELECT * FROM draft_degree_tracks
                WHERE catalog_year = '?'
                AND major_code = '?'
                AND track_code = '?' ", $de_catalog_year, $just_major, $just_track);
      if (db_num_rows($res2) > 0) {
        $cur2 = db_fetch_array($res2);

        $db_title = trim($cur2["track_title"]);
        $outside = "$degree_title &raquo; ";
        if (strstr($just_major, "|")) {
          // both a conc AND a track. Denote it special.
          $outside = ">>" . $outside;
        }
        $db_degree_type = "";
      }
    }
    else if ($just_conc != "") {
      // Meaning, this is a concentration, NOT a track.
      $db_degree_type = "";
      $outside = "&gt;&gt;";
    }


    //$base_path = $GLOBALS['system_settings']['base_path'];
    //$url = $base_path . "/index.php?q=admin/degrees/edit-degree/$db_major_code/$de_catalog_year&de_catalog_year=$de_catalog_year";

    $url = fp_url("admin/degrees/edit-degree/$db_major_code/$de_catalog_year", "de_catalog_year=$de_catalog_year", array("class" => "degree-$db_degree_class"));


    $class_details = fp_get_degree_classification_details($db_degree_class);
    $disp_class = $class_details["title"];

    $on_mouse_over = "
            onmouseover='$(this).addClass(\"selection_highlight\");'
            onmouseout='$(this).removeClass(\"selection_highlight\");'
          ";




    /*       
    $rtn .= "<tr
                  
                  $on_mouse_over
                  
                  style='cursor:pointer;'
                  onClick='window.location=\"$url\"'
                  class='$extra_class class-$db_degree_class class-level-" . $class_details["level_num"] . " '
             >
              <td valign='top' class='degree-type'>$db_degree_type</td>
              <td valign='top' class='degreee-class'>$disp_class</td>
              <td valign='top' class='degree-title'>$outside$db_title</td>
              <td valign='top' class='degree-major-code'>$db_major_code</td>    
            </tr>";        
      */

    $render['degree_row_' . $db_degree_id] = array(
      'value' => "<tr
                  
                  $on_mouse_over
                  
                  style='cursor:pointer;'
                  onClick='window.location=\"$url\"'
                  class='$extra_class class-$db_degree_class class-level-" . $class_details["level_num"] . " '
             >
              <td valign='top' class='degree-type'>$db_degree_type</td>
              <td valign='top' class='degreee-class'>$disp_class</td>
              <td valign='top' class='degree-title'>$outside$db_title</td>
              <td valign='top' class='degree-major-code'>$db_major_code</td>    
            </tr>
                ",
      'data' => array(
        'degree_id' => $db_degree_id,
        'major_code' => $db_major_code,
        'title' => $db_title,
        'catalog_year' => $db_catalog_year,
        'degree_type' => $db_degree_type,
        'degree_class' => $db_degree_class,
        'db_row' => $cur,
      ),
    );


  }



  //$rtn .= "</table>";

  $render['degrees_table_bottom'] = array(
    'value' => "</table>",
  );




  $rtn .= fp_render_content($render);


  return $rtn;

}