admin_display_edit_degree

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

This screen displays the form which allows the user to actually edit a degree.

File

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

Code

function admin_display_edit_degree() {
  $de_catalog_year = admin_get_de_catalog_year();
  $rtn = "";

  $major_code = $_REQUEST["major_code"];

  $s_count = 0;

  // Add in our CSS and JS
  fp_add_js(fp_get_module_path("admin") . "/js/admin.js");
  fp_add_css(fp_get_module_path("admin") . "/css/admin.css");

  $button_msg = trim(addslashes(@$_REQUEST["button_msg"]));

  $db = get_global_database_handler();

  $degree_id = intval($db->get_degree_id($major_code, $de_catalog_year, true));
  // The intval says, if it's false, make it = 0.  otherwise keep the number
  // that is returned.
  $degree = new DegreePlan($degree_id, null, false, false, true);
  $degree->load_descriptive_data();


  if (user_has_permission("can_view_advanced")) {
    $rtn .= " <span class='tenpt deg-advanced-msg' style='background-color: yellow; margin-left: 20px;'>
          advanced: degreeID = $degree_id. catalog year: $de_catalog_year
          </span>";
  }

  $url = fp_url("admin/degrees/handle-edit-degree-submit");

  $rtn .= "<form id='mainform' action='" . $url . "' method='POST'>
            <input type='hidden' name='perform_action2' id='perform_action2'>
            <input type='hidden' name='de_catalog_year' value='$de_catalog_year'>
            <input type='hidden' name='scroll_top' id='scroll_top' value=''>
            <input type='hidden' name='major_code' value='$major_code'>                        
            ";

  $rtn .= "<div style='font-size: 16pt; font-weight:bold; padding-top: 20px;'>$degree->degree_type $degree->title<br>$major_code ($de_catalog_year)</div>";
  $rtn .= "
      <table border='0' class='degree-edit-top-part'>
       <tr>
        <td valign='top' class='tenpt td-d-type-lable' width='15%'>" . t("Degree Type:") . "</td>
        <td valign='top' class='tenpt td-d-type' >
              <input type='text' name='degree_type' value='$degree->degree_type' size='5' maxlength='20'>
              <a href='javascript: adminPopupAlertHelp(\"degree_type\");'>?</a>
              
        </td>

        <td valign='top' class='tenpt' width=''>
              " . t("Classification:") . "          
              <select name='degree_class' style='max-width: 120px;'> ";
  //<input type='text' name='degree_class' value='$degree->degree_class' size='10' maxlength='40'>
  // 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 == $degree->degree_class) {
        $sel = "selected";
      }

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

  $rtn .= "</select>              
              
              <a href='javascript: adminPopupAlertHelp(\"degree_class\");'>?</a>
        </td>

        <td valign='top' class='tenpt td-lev-weight' >" . t("Level:") . "
              <input type='text' id='edit-degree-level' name='degree_level' value='$degree->degree_level' size='1' maxlength='1'>
              <a href='javascript: adminPopupAlertHelp(\"degree_level\");'>?</a>
              
          &nbsp; &nbsp;
          
          " . t("Advising Weight:") . "
              <input type='text' id='edit-advising-weight' name='advising_weight' value='$degree->db_advising_weight' size='1' maxlength='5'>
              <a href='javascript: adminPopupAlertHelp(\"advising_weight\");'>?</a>
                        
                        
              
        </td>
        
        <td valign='top'>        
        </td>
        
       </tr>
        
             
       
       
       
       <tr>
        <td valign='top' class='tenpt td-title-lab'>" . t("Title:") . "</td>
        <td valign='top' class='tenpt td-title-field' colspan='4'><input type='text' name='title' value='$degree->title' size='80' maxlength='100'></td>
       </tr>
       
       
             
       
       
       <tr>
        <td valign='top' class='tenpt td-ex-lab'>" . t("Exclude:") . "</td>
        <td valign='top' class='tenpt td-ex'>
              <input type='text' name='exclude' value='$degree->db_exclude' size='2' maxlength='1'>
              <a href='javascript: adminPopupAlertHelp(\"degree_exclude\");'>?</a>
        </td>
        <td valign='top' class='tenpt td-al-dy' >
              " . t("Allow Dynamic:") . "
              &nbsp;
              <input type='text' name='allow_dynamic' value='$degree->db_allow_dynamic' size='2' maxlength='1'>
              <a href='javascript: adminPopupAlertHelp(\"degree_allow_dynamic\");'>?</a>
        </td>       
        
        <td valign='top' class='tenpt td-o-dh' >
              " . t("Override Degree Hours:") . "
              &nbsp;
              <input type='text' name='override_degree_hours' value='$degree->db_override_degree_hours' size='3' maxlength='10'>
              <a href='javascript: adminPopupAlertHelp(\"degree_override_degree_hours\");'>?</a>
        </td>       

        <td>
        </td>
        
       </tr>
       
       
        
      </table> ";

  if (strstr($major_code, "_")) {
    $rtn .= "<b>Edit track information:</b>
      <blockquote style='margin-top: 0px; margin-bottom: 0px;'>
    <font size='2'>Track title: <input type='text' name='track_title' value='$degree->track_title' size='60' maxlength='100'></font><br>
    <font size='2'>Track description: " . fp_get_js_alert_link(t("You may enter simple HTML in this field, like <b>bold</b> or <i>italics</i>."), t("(Help - Formatting)")) . "
            <a href='javascript: adminPopupAlertHelp(\"track_description\");'>(Help - Track Descriptions)</a>
    </font><br>
    <textarea name='track_description' cols='60' rows='3'>" . $degree->track_description . "</textarea>
    </blockquote>
    ";
  }
  $rtn .= "<div class='tenpt' align='center'>(<a href='#bot'>Scroll to the bottom</a> of the page for advanced options)</div>
            <!--PREVIOUS_SEMESTERS-->";

  $first_semester_num = -999;

  $degree->list_semesters->reset_counter();
  while ($degree->list_semesters->has_more()) {
    $semester = $degree->list_semesters->get_next();
    if ($semester->semester_num < 0) {
      continue;
    }

    // Record what is the first semester num we have...
    if ($first_semester_num == -999) {
      $first_semester_num = $semester->semester_num;
    }

    $sem_default_title = admin_get_semester_name($semester->semester_num);
    if ($semester->title == $sem_default_title) {
      $semester->title = "";
    }

    $rtn .= "<div class='elevenpt' style='padding-bottom: 30px;'>
          <b>Block number: " . ($semester->semester_num + 1) . "</b>
          &nbsp; &nbsp; &nbsp; &nbsp;
          Default title: $sem_default_title
          &nbsp; &nbsp;
          Override: <input type='text' name='semester_title_$semester->semester_num' value='$semester->title' size='20'>
          <a href='javascript: adminPopupAlertHelp(\"semester_title\");'>?</a>
          <table border='1' width='100%'>
          ";
    // Get the courses.
    $rtn .= "<tr><td valign='top'>
          <textarea name='courses_$semester->semester_num' rows='10' cols='20'>";
    $semester->list_courses->sort_alphabetical_order();
    $semester->list_courses->reset_counter();
    while ($semester->list_courses->has_more()) {
      $course = $semester->list_courses->get_next();
      $course->load_descriptive_data();
      $rtn .= "$course->subject_id $course->course_num $course->requirement_type";
      if ($course->min_grade != "D" && $course->min_grade != "") {
        $rtn .= " ($course->min_grade)";
      }
      $rtn .= "\n";
    }
    $rtn .= "</textarea>
    <div class='tenpt'>(<a href='javascript: adminPopupAlertHelp(\"degree_entry\");'>Help - entering requirements, min grades, and repeats</a>)</div>
    </td>";

    // Get the groups...
    $rtn .= "<td valign='top' class='tenpt' width='100%'>
          <table width='100%' border='0' cellspacing='5'>
          <tr>
            <td valign='top' class='tenpt' width='1'>&nbsp;</td>
            <td valign='top' class='tenpt'>Group</td>
            <td valign='top' class='tenpt' width='5'>hrs</td>
            <td valign='top' class='tenpt' width='5'>grd</td>
            <td valign='top' class='tenpt' width='5'>type</td>
            </tr>";
    $semester->list_groups->sort_alphabetical_order();
    $semester->list_groups->reset_counter();
    while ($semester->list_groups->has_more()) {
      $group = $semester->list_groups->get_next();
      $group->load_descriptive_data();

      $ghours = $group->hours_required;
      // If min hours are specified, set to MIN-MAX.
      if ($group->has_min_hours_allowed()) {
        $ghours = $group->min_hours_allowed . "-" . $ghours;
      }


      $rtn .= "<tr><td valign='middle'>
      
            <a href='javascript: adminDelGroup(\"" . $group->get_db_group_id() . "\",\"$semester->semester_num\");'><img src='" . fp_theme_location() . "/images/delete.png' border='0'></a>
                  
            <td valign='top' class='tenpt'>
            $group->title<br><i>$group->group_name</i></td>
            <td valign='top' class='tenpt'>$ghours</td>
            <td valign='top' class='tenpt'>$group->min_grade</td>
            <td valign='top' class='tenpt'>$group->requirement_type
            <input type='hidden' name='group_" . $group->get_db_group_id() . "_" . rand(1, 999999) . "' value='" . $group->get_db_group_id() . "" . "_$semester->semester_num" . "_$ghours" . "_$group->requirement_type" . "_$group->min_grade'>
            </td>";
    }

    $url = fp_url("admin/degrees/popup-add-group", "semester_num=$semester->semester_num&de_catalog_year=$de_catalog_year");

    $rtn .= "</table>
        <div style='margin-top: 10px; margin-left: 20px;'>
          <a href='javascript: adminPopupWindow(\"" . $url . "\");'>Add an elective group</a>
        </div>
    </td>";


    $rtn .= "</table><br>
        
    " . fp_render_button(t("Save for @year", array("@year" => $de_catalog_year)), "adminSubmitForm();") . "
      <span class='admin-button-msg'>$button_msg</span>
    
    </div>
    ";
    $s_count = $semester->semester_num + 1;
  }



  // Always add an additional 4 semesters to the bottom.  Also, add in any missing semesters to the top of the degree as well.
  $deltas = array("top", "bottom");
  foreach ($deltas as $delta) {
    $html = "";

    // Set for if delta == bottom.    
    $start_at = $s_count; // s_count was the last semester we created above.
    $less_than = 4;

    if ($delta == "top") {
      // We are creating semesters for the top of the page, if needed.
      if ($first_semester_num == -999) {
        continue; // None were put at the top!  We can skip it.
      }
      else {
        $start_at = 0;
        $less_than = $first_semester_num;
      }

    }


    for ($t = 0; $t < $less_than; $t++) {
      $sem = $t + $start_at;
      if ($sem > 99) {
        // Max number of semesters.  More or less arbitrarily set number.
        $html .= "<br>" . t("Maximum number of semesters created.") . "<br>";
        break;
      }

      $html .= "<div class='elevenpt' style='padding-bottom: 30px;'>
            <b>Block number: " . ($sem + 1) . "</b>
            &nbsp; &nbsp; &nbsp; &nbsp;
            Default title: " . admin_get_semester_name($sem) . "
            &nbsp; &nbsp;
            Override: <input type='text' name='semester_title_$sem' value='' size='20'>
            <a href='javascript: adminPopupAlertHelp(\"semester_title\");'>?</a>
            
            <table border='1' width='100%'>
            ";

      $html .= "<tr><td valign='top'>
            <textarea name='courses_$sem' rows='10' cols='20'>";
      $html .= "</textarea></td>";

      // the groups...
      $html .= "<td valign='top' class='tenpt' width='100%'>
            <table width='100%' border='0' cellspacing='5'>
            <tr>
              <td valign='top' class='tenpt' width='1'>&nbsp;</td>
              <td valign='top' class='tenpt'>Group</td>
              <td valign='top' class='tenpt'>hrs</td>
              <td valign='top' class='tenpt'>grd</td>
              <td valign='top' class='tenpt'>type</td>
              </tr>";

      $url = fp_url("admin/degrees/popup-add-group", "semester_num=$sem&de_catalog_year=$de_catalog_year");

      $html .= "</table>
          <div style='margin-top: 10px; margin-left: 20px;'>
            <a href='javascript: adminPopupWindow(\"" . $url . "\");'>Add an elective group</a>
      </td>";


      $html .= "</table><br>
      
      " . fp_render_button(t("Save for @year", array("@year" => $de_catalog_year)), "adminSubmitForm();") . "
          <span class='admin-button-msg'>$button_msg</span>
      
      </div>";

    } // creating a blank semester block


    // Add $html to wherever it needs to go.
    if ($delta == "bottom") {
      $rtn .= $html;
    }
    else if ($delta == "top") {
      // Place the HTML at the top of the page by replacing our html comment.
      $rtn = str_replace("<!--PREVIOUS_SEMESTERS-->", $html, $rtn);
    }


  } //foreach delta



  $rtn .= "<div class='elevenpt'>If you need more semester boxes, simply save this page, and additional blank
      boxes will appear below.</div>
      
      <a name='bot'></a>
      <br><br>
      ";
  $html = "";
  $html .= "
      <div class='elevenpt'>
      Enter a public note for this degree: 
       <a href='javascript: adminPopupAlertHelp(\"public_note\");'>(Help - Public Note)</a>
       " . fp_get_js_alert_link(t("You may enter simple HTML in this field, like <b>bold</b> or <i>italics</i>."), t("(Help - Formatting)")) . "
      <br>
      <textarea name='public_note' rows='4' cols='80'>" . @$degree->public_notes_array[$degree->degree_id] . "</textarea>
      
      <br><br>
      If this degree has tracks, you may enter rules for track selection below, for each type of level 3 degree (tracks) you might have.
      <b>You may skip classifications which do not pertain to this degree.</b>
      <br><br>

      <table border='0' width='100%'>
      <tr>
        <th>Class:</th>
        <th>Min: <a href='javascript: adminPopupAlertHelp(\"min_tracks\");'>?</a></th>
        <th>Max: <a href='javascript: adminPopupAlertHelp(\"max_tracks\");'>?</a></th>
        <th>Default tracks (CSV): <a href='javascript: adminPopupAlertHelp(\"default_tracks\");'>?</a></th> 
      </tr>
      ";

  $degree_classes = fp_get_degree_classifications();
  foreach ($degree_classes["levels"] as $level => $details) {

    if (intval($level) != 3) {
      continue; // we only care about level 3...
    }

    foreach ($degree_classes["levels"][$level] as $machine_name => $title) {

      $min_tracks = @intval($degree->track_selection_config_array[$machine_name]["min_tracks"]);
      $max_tracks = @intval($degree->track_selection_config_array[$machine_name]["max_tracks"]);
      $default_tracks = @trim($degree->track_selection_config_array[$machine_name]["default_tracks"]);

      $html .= "<tr class='admin-degrees-edit-track-selection-config track-selection-config-$machine_name'>
                      <td valign='top'>
                        
                        <span class='track-selection-config-title'>$title</span>:
                       </td>
                       <td valign='top'>
                          
                          <input type='text' name='tsc_{$machine_name}_min_tracks' size='2' value='$min_tracks'>
                          
                        
                        </td>
                        <td valign='top'>
                        
                        
                          <input type='text' name='tsc_{$machine_name}_max_tracks' size='2' value='$max_tracks'>
                          
                        
                        </td>
                        <td valign='top'>
                        
                        
                          <input type='text' name='tsc_{$machine_name}_default_tracks' size='25' value='$default_tracks' maxlength='255'>
                          
                    </td>    
                    </tr>";
    }
  }


  $html .= "</table>
              </div>";

  /*
      
      Min:
        <input type='text' name='min_tracks' size='2' value='$degree->min_tracks'>
        <a href='javascript: adminPopupAlertHelp(\"min_tracks\");'>?</a>
      
      &nbsp;&nbsp;  
      
      Max:
        <input type='text' name='max_tracks' size='2' value='$degree->max_tracks'>
        <a href='javascript: adminPopupAlertHelp(\"max_tracks\");'>?</a>
      
      &nbsp;&nbsp;
      
      Default tracks: (CSV)
        <input type='text' name='default_tracks' size='15' value='$degree->default_tracks' maxlength='255'>
        <a href='javascript: adminPopupAlertHelp(\"default_tracks\");'>?</a>
      
      
      
      </div>
      
      
      
      ";  */



  $rtn .= fp_render_c_fieldset($html, t("View advanced options"), TRUE);




  $rtn .= "</form>";

  // Only show delete option based on permission  
  if (user_has_permission("can_delete_data_entry")) {

    $rtn .= "        <div align='right' class='degrees-delete-degree-wrapper'>
            Delete this degree? <input type='button' value='X'
                    onClick='adminDeleteDegree(\"$degree_id\");'>
          </div>      
          ";

  }

  //$pC .= get_j_s();


  if (@$_REQUEST["serialize"] != "") {
    print "<br><textarea rows=20 cols=80>" . serialize($degree) . "</textarea>";
  }


  return $rtn;
}