function _AdvisingScreen::display_popup_substitute

4.x _AdvisingScreen.php _AdvisingScreen::display_popup_substitute($course_id = 0, $group_id, $semester_num, $hours_avail = "")
5.x _AdvisingScreen.php _AdvisingScreen::display_popup_substitute($course_id = 0, $group_id, $semester_num, $hours_avail = "", $req_by_degree_id = 0)

This is used to display the substitution popup to a user, to let them actually make a substitution.

Parameters

int $course_id:

int $group_id:

int $semester_num:

int $hours_avail:

Return value

string

File

classes/_AdvisingScreen.php, line 3402

Class

_AdvisingScreen

Code

function display_popup_substitute($course_id = 0, $group_id, $semester_num, $hours_avail = "") 
 {
  // This lets the user make a substitution for a course.
  $pC = "";

  $course = new Course($course_id);
  $bool_sub_add = false;

  $c_title = t("Substitute for") . " $course->subject_id $course->course_num";
  if ($course_id == 0) 
   {
    $c_title = t("Substitute an additional course");
    $bool_sub_add = true;
  }
  $pC .= fp_render_curved_line($c_title);

  $extra = ".<input type='checkbox' id='cbAddition' value='true' style='display:none;'>";
  if ($group_id > 0) 
   {
    $new_group = new Group($group_id);
    $checked = "";
    if ($bool_sub_add == true) {
      $checked = "checked disabled";
    }
    $extra = " " . t("in the group %newg.", array("%newg" => $new_group->title)) . "
			" . t("Addition only:") . " <input type='checkbox' id='cbAddition' value='true' $checked> 
			   <a href='javascript: alertSubAddition();'>?</a>";
  }

  $c_hours = $course->max_hours * 1;
  $c_ghost_hour = "";
  if ($course->bool_ghost_hour == TRUE) {
    $c_ghost_hour = t("ghost") . "<a href='javascript: alertSubGhost();'>?</a>";
  }

  if (($hours_avail * 1 > 0 && $hours_avail < $c_hours) || ($c_hours < 1)) 
   {

    // Use the remaining hours if we have fewer hours left in
    // the group than the course we are subbing for.
    $c_hours = $hours_avail;
  }

  if ($hours_avail == "" || $hours_avail * 1 < 1) 
   {
    $hours_avail = $c_hours;
  }

  $pC .= "<div class='tenpt'>
					" . t("Please select a course to substitute
				for %course", array("%course" => "$course->subject_id $course->course_num ($c_hours $c_ghost_hour " . t("hrs") . ")")) . "$extra
				</div>
				
				<div class='tenpt' 
					style='height: 175px; overflow: auto; border:1px inset black; padding: 5px;'>
					<table border='0' cellpadding='0' cellspacing='0' width='100%'>
					
					";

  $this->student->list_courses_taken->sort_alphabetical_order(false, true);

  for ($t = 0; $t <= 1; $t++) 
   {
    if ($t == 0) {
      $the_title = "{$GLOBALS ["fp_system_settings"]["school_initials"]} " . t("Credits");
      $bool_transferTest = true;
    }
    if ($t == 1) {
      $the_title = t("Transfer Credits");
      $bool_transferTest = false;
    }

    $pC .= "<tr><td colspan='3' valign='top' class='tenpt' style='padding-bottom: 10px;'>
				$the_title
				</td>
				<td class='tenpt' valign='top' >" . t("Hrs") . "</td>
				<td class='tenpt' valign='top' >" . t("Grd") . "</td>
				<td class='tenpt' valign='top' >" . t("Term") . "</td>
				</tr>";

    $is_empty = true;
    $this->student->list_courses_taken->reset_counter();
    while ($this->student->list_courses_taken->has_more()) 
     {
      $c = $this->student->list_courses_taken->get_next();

      if ($c->bool_transfer == $bool_transferTest) 
       {
        continue;
      }


      if (!$c->meets_min_grade_requirement_of(null, "D")) 
       { // Make sure the grade is OK.
        continue;
      }

      $t_flag = 0;
      if ($c->bool_transfer == true) 
       {
        $t_flag = 1;
      }
      $is_empty = false;

      $subject_id = $c->subject_id;
      $course_num = $c->course_num;
      $tcourse_id = $c->course_id;

      if ($bool_transferTest == false) 
       {
        // Meaning, we are looking at transfers now.
        // Does the transfer course have an eqv set up?  If so,
        // we want *that* course to appear.
        if (is_object($c->course_transfer)) 
         {
          $subject_id = $c->course_transfer->subject_id;
          $course_num = $c->course_transfer->course_num;
          $tcourse_id = $c->course_transfer->course_id;
          $t_flag = 1;
        }
      }

      $m_hours = $c->hours_awarded * 1;

      if ($c->max_hours * 1 < $m_hours) 
       {
        $m_hours = $c->max_hours * 1;

      }

      if (($hours_avail * 1 > 0 && $hours_avail < $m_hours) || ($m_hours < 1)) 
       {
        $m_hours = $hours_avail;
      }

      // is max_hours more than the original course's hours?
      if ($m_hours > $c_hours) 
       {
        $m_hours = $c_hours;
      }

      if ($m_hours > $c->hours_awarded) 
       {
        $m_hours = $c->hours_awarded;
      }

      if ($c->bool_substitution != true && $c->bool_outdated_sub != true) 
       {
        $h = $c->hours_awarded;
        if ($c->bool_ghost_hour == TRUE) {
          $h .= "(ghost<a href='javascript: alertSubGhost();'>?</a>)";
        }

        $pC .= "<tr>
						<td valign='top' class='tenpt' width='15%'>
							<input type='radio' name='subCourse' id='subCourse' value='$tcourse_id'
							 onClick='popupUpdateSubData(\"$m_hours\",\"$c->term_id\",\"$t_flag\",\"$hours_avail\",\"$c->hours_awarded\");'>
						</td>
						<td valign='top' class='tenpt underline' width='13%'>
							$subject_id
						</td>
						<td valign='top' class='tenpt underline' width='15%'>
							$course_num
						</td>
						

						<td valign='top' class='tenpt underline' width='10%'>
							$h
						</td>
						<td valign='top' class='tenpt underline' width='10%'>
							$c->grade
						</td>
						<td valign='top' class='tenpt underline'>
							" . $c->get_term_description(true) . "
						</td>

						
					</tr>
					";
      }
      else {



        if (is_object($c->course_substitution) && $c->course_substitution->subject_id == "") 
         { // Load subject_id and course_num of the original
          // requirement.
          $c->course_substitution->load_descriptive_data();
        }

        $extra = "";
        if ($c->assigned_to_group_id > 0) 
         {
          $new_group = new Group($c->assigned_to_group_id);
          $extra = " in $new_group->title";
        }
        if ($c->bool_outdated_sub == true) 
         {
          $help_link = "<a href='javascript: popupHelpWindow(\"help.php?i=9\");' class='nounderline'>(?)</a>";
          $extra .= " <span style='color:red;'>[" . t("Outdated") . "$help_link]</span>";
        }

        // It has already been substituted!
        $pC .= "<tr style='background-color: beige;'>
						<td valign='top' class='tenpt' width='15%'>
						 " . t("Sub:") . "
						</td>
						<td valign='top' class='tenpt' colspan='5'>
							$subject_id 
						
							$course_num ($c->substitution_hours)
							 -> " . $c->course_substitution->subject_id . "
							 " . $c->course_substitution->course_num . "$extra
						</td>

						
					</tr>
					";

      }

    }

    if ($is_empty == true) 
     {
      // Meaning, there were no credits (may be the case with
      // transfer credits)
      $pC .= "<tr><td colspan='8' class='tenpt'>
							- " . t("No substitutable credits available.") . "
						</td></tr>";
    }

    $pC .= "<tr><td colspan='4'>&nbsp;</td></tr>";
  }


  $pC .= "</table></div>
		<div class='tenpt' style='margin-top: 5px;'>
			" . t("Select number of hrs to use:") . "
			<select name='subHours' id='subHours' onChange='popupOnChangeSubHours()'>
				<option value=''>" . t("None Selected") . "</option>
			</select>
			";

  // If we have entered manual hours (like for decimals), they go here:
  // The subManual span will *display* them, the hidden field keeps them so they can be transmitted.		
  $pC .= "
			<span id='subManual' style='font-style:italic; display:none;'></span>			  
			<input type='hidden' id='subManualHours' value=''>

			
		</div>
		<input type='hidden' name='subTransferFlag' id='subTransferFlag' value=''>
		<input type='hidden' name='subTermID' id='subTermID' value=''>
		<input type='button' value='Save Substitution' onClick='popupSaveSubstitution(\"$course_id\",\"$group_id\",\"$semester_num\");'>
		
		<div class='tenpt' style='padding-top: 5px;'><b>" . t("Optional") . "</b> - " . t("Enter remarks:") . " 
		<input type='text' name='subRemarks' id='subRemarks' value='' size='30' maxlength='254'>
		
		</div>
		";


  return $pC;
}