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 888

Code

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

  $major_code = $_REQUEST["major_code"];

  // 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' style='background-color: yellow; margin-left: 20px;'>
          advanced: degreeID = $degree_id.
          </span>";
  }

  $rtn .= "<form id='mainform' action='" . base_path() . "/admin/degrees/handle-edit-degree-submit' 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>
       <tr>
        <td valign='top' class='tenpt' width='15%'>Degree Type:</td>
        <td valign='top' class='tenpt' width='15%'><input type='text' name='degree_type' value='$degree->degree_type' size='5' maxlength='20'></td>

        <td valign='top' class='tenpt' width='15%'>Degree Class:</td>
        <td valign='top' class='tenpt'><input type='text' name='degree_class' value='$degree->degree_class' size='2' maxlength='1'>
        <a href='javascript: adminPopupAlertHelp(\"degree_class\");'>?</a></td>
       </tr>
        
       </tr>
       <tr>
        <td valign='top' class='tenpt'>Degree Title:</td>
        <td valign='top' class='tenpt' colspan='3'><input type='text' name='title' value='$degree->title' size='80' maxlength='100'></td>
       </tr>
       <tr>
        <td valign='top' class='tenpt'>Exclude:</td>
        <td valign='top' class='tenpt' colspan='3'><input type='text' name='exclude' value='$degree->db_exclude' size='2' maxlength='1'>
        <a href='javascript: adminPopupAlertHelp(\"degree_exclude\");'>?</a></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: <a href='javascript: adminPopupAlertHelp(\"edit_formatting\");'>(Help - Formatting)</a>
            <a href='javascript: adminPopupAlertHelp(\"track_description\");'>(Help - Track Descriptions)</a>
    </font><br>
    <textarea name='track_description' cols='60' rows='3'>" . filter_markup($degree->track_description) . "</textarea>
    </blockquote>
    ";
  }
  $rtn .= "<div class='tenpt' align='center'>(Scroll to the bottom of the page for more options)</div>";

  $degree->list_semesters->reset_counter();
  while ($degree->list_semesters->has_more()) {
    $semester = $degree->list_semesters->get_next();
    if ($semester->semester_num < 0) {
      continue;
    }
    $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();
      $rtn .= "<tr><td valign='middle'>
      
            <a href='javascript: adminDelGroup(\"$group->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'>$group->hours_required</td>
            <td valign='top' class='tenpt'>$group->min_grade</td>
            <td valign='top' class='tenpt'>$group->requirement_type
            <input type='hidden' name='group_" . $group->group_id . "_" . rand(1, 999999) . "' value='$group->group_id" . "_$semester->semester_num" . "_$group->hours_required" . "_$group->requirement_type" . "_$group->min_grade'>
            </td>";
    }
    $rtn .= "</table>
        <div style='margin-top: 10px; margin-left: 20px;'>
          <a href='javascript: adminPopupWindow(\"" . base_path() . "/admin/degrees/popup-add-group&semester_num=$semester->semester_num&de_catalog_year=$de_catalog_year\");'>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.
  for ($t = 0; $t < 4; $t++) {
    $sem = $t + $s_count;
    if ($sem > 99) {
      // Max number of semesters.  More or less arbitrarily set number.
      $rtn .= "<br>" . t("Maximum number of semesters created.") . "<br>";
      break;
    }

    $rtn .= "<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%'>
          ";

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

    // 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'>hrs</td>
            <td valign='top' class='tenpt'>grd</td>
            <td valign='top' class='tenpt'>type</td>
            </tr>";
    $rtn .= "</table>
        <div style='margin-top: 10px; margin-left: 20px;'>
          <a href='javascript: adminPopupWindow(\"" . base_path() . "/admin/degrees/popup-add-group&semester_num=$sem&de_catalog_year=$de_catalog_year\");'>Add an elective group</a>
    </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>";

  }
  $rtn .= "<div class='elevenpt'>If you need more semester boxes, simply save this page, and additional blank
      boxes will appear below.</div>
      
      <br><br>
      <div class='elevenpt'><b>More Options:</b><br>
      Enter a public note for this degree: 
       <a href='javascript: adminPopupAlertHelp(\"public_note\");'>(Help - Public Note)</a>
       <a href='javascript: adminPopupAlertHelp(\"edit_formatting\");'>(Help - Formatting)</a>
      <br>
      <textarea name='public_note' rows='4' cols='80'>$degree->public_note</textarea>
      
      
      </div>
      
      
      
      ";




  $rtn .= "</form>";

  $rtn .= "        <div align='right'>
          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;
}