function AdvisingScreen::build_footnotes

6.x AdvisingScreen.php AdvisingScreen::build_footnotes($bool_include_box_top = TRUE)

Constructs the HTML which will show footnotes for substitutions and transfer credits.

1 call to AdvisingScreen::build_footnotes()
AdvisingScreen::build_screen_elements in classes/AdvisingScreen.php
This function calls the other "build" functions to assemble the View or What If tabs in FlightPath.

File

classes/AdvisingScreen.php, line 805

Class

AdvisingScreen

Code

function build_footnotes($bool_include_box_top = TRUE) 
 {
  // Display the footnotes & messages.

  $student_id = $this->student->student_id;


  $render = array();
  $render ['#id'] = 'AdvisingScreen_build_footnotes';
  $render ['#student_id'] = $student_id;
  $render ['#degree_plan'] = $this->degree_plan;
  $render ['#degree_id'] = $this->degree_plan->degree_id;
  $render ['#footnote_array'] = $this->footnote_array;



  $school_id = db_get_school_id_for_student_id($student_id);

  //$pC = "";
  $is_empty = true;
  if ($bool_include_box_top) {
    //$pC .= $this->draw_semester_box_top(t("Footnotes & Messages"), true);

    $render ['box_top'] = array(
      'value' => $this->draw_semester_box_top(t("Footnotes & Messages"), true),
      'weight' => 100,
    );

  }

  //$pC .= "<tr><td colspan='8' class=' '>";

  $render ['tr_td_start'] = array(
    'value' => "<tr><td colspan='8' class=' '>",
    'weight' => 110,
  );


  $weight = 200;

  $fn_type_array = array("substitution", "transfer");
  $fn_char = array("substitution" => "S", "transfer" => "T");
  $fn_name = array("substitution" => t("Substitutions"),
    "transfer" => t("Transfer Equivalency Footnotes"));
  $fn_between = array("substitution" => t("for"),
    "transfer" => t("for") . " " . variable_get_for_school("school_initials", "DEMO", $school_id) . "'s");
  for ($xx = 0; $xx <= 1; $xx++) 
   {
    $fn_type = $fn_type_array [$xx];
    if (isset($this->footnote_array [$fn_type]) && @count($this->footnote_array [$fn_type]) < 1) 
     {
      continue;
    }

    //$pC .= "<div style='padding-bottom: 10px;'><b>{$fn_name[$fn_type]}</b>";


    $render ['section_' . $fn_name [$fn_type] . '_start'] = array(
      'value' => "<div style='padding-bottom: 10px;'><b>{$fn_name [$fn_type]}</b>",
      'weight' => $weight,
    );

    $weight = $weight + 10;

    $is_empty = false;
    $ccount = 0;
    if (isset($this->footnote_array) && is_array($this->footnote_array) && isset($this->footnote_array [$fn_type])) {
      $ccount = count($this->footnote_array [$fn_type]);
    }

    for ($t = 1; $t <= $ccount; $t++) 
     {
      $line = @$this->footnote_array [$fn_type][$t];

      if ($line == "") 
       {
        continue;
      }

      $extra = ".";

      $temp = explode(" ~~ ", $line);
      $o_course = trim(@$temp [0]);
      $new_course = trim(@$temp [1]);
      $using_hours = trim(@$temp [2]);
      if ($using_hours != "") 
       {
        $using_hours = "($using_hours " . t("hrs") . ")";
      }
      $in_group = trim(@$temp [3]);
      $sub_id = trim(@$temp [4]);


      $fbetween = $fn_between [$fn_type];

      $sub_details = $this->db->get_substitution_details($sub_id);

      $remarks = @trim($sub_details ["remarks"]);
      $sub_faculty_id = @$sub_details ["faculty_id"];

      $sub_degree_plan = new DegreePlan();
      $sub_degree_plan->degree_id = @$sub_details ["required_degree_id"];

      $sub_required_group_id = @$sub_details ["required_group_id"];


      //if ($in_group > 0 && $fn_type=="substitution")
      if ($sub_required_group_id != "" && $fn_type == "substitution") 
       {
        $new_group = new Group();
        $new_group->group_id = $sub_required_group_id;
        $new_group->load_descriptive_data();

        $extra = "<div style='padding-left: 45px;'><i>" . t("in") . " $new_group->title.</i></div>";
        if ($new_course == $o_course || $o_course == "") 
         {
          $o_course = t("was added");
          $fbetween = "";
          $extra = str_replace("<i>" . t("in"), "<i>" . t("to"), $extra);
        }



      }

      // Clean this up, as far as the remarks and such.  Make it look similar (new function?) as popup text for a substitution.
      if ($remarks) {
        $remarks = " ($remarks) ";
      }

      // Build a "theme" array, so we can pass it to other modules in a hook.
      $theme = array();
      $theme ["footnote"] = array(
        "fn_char" => $fn_char,
        "fn_type" => $fn_type,
        "fn_num" => $t,
        "css_class" => "",
        "new_course" => $new_course,
        "using_hours" => $using_hours,
        "fbetween" => $fbetween,
        "o_course" => $o_course,
        "extra" => $extra,
        "remarks" => $remarks,
        "for_degree" => $sub_degree_plan->get_title2(FALSE, TRUE),
        "overwrite_with_html" => "",
      );


      // Invoke a hook on our theme array, so other modules have a chance to change it up.   
      invoke_hook("theme_advise_footnote", array(&$theme));

      $sup = $theme ["footnote"]["fn_char"][$theme ["footnote"]["fn_type"]] . $theme ["footnote"]["fn_num"];

      // Actually gather the output for the footnote:
      $html = "";

      if ($theme ["footnote"]["overwrite_with_html"] != "") {
        $html = $theme ["footnote"]["overwrite_with_html"];
      }
      else {

        $html = "<div class='  advise-footnote {$theme ["footnote"]["css_class"]}'>
            <sup>$sup</sup>
            <span class='advise-footnote-body'>
               {$theme ["footnote"]["new_course"]} 
               {$theme ["footnote"]["using_hours"]} 
               {$theme ["footnote"]["fbetween"]} 
               {$theme ["footnote"]["o_course"]}{$theme ["footnote"]["extra"]}{$theme ["footnote"]["remarks"]} 
               <span class='footnote-for-degree'>(Degree {$theme ["footnote"]["for_degree"]})</span>
            </span>
            </div>";
      }


      $render ['section_' . $fn_name [$fn_type] . '_item_' . $t] = array(
        'value' => $html,
        'weight' => $weight,
      );

      $weight = $weight + 10;

      //$pC .= $html;


    }
    //$pC .= "</div>";
    $render ['section_' . $fn_name [$fn_type] . '_end'] = array(
      'value' => "</div>",
      'weight' => $weight,
    );
  }


  //////////////////////////////
  /// Unassigned transfer eqv's
  $this->student->list_transfer_eqvs_unassigned->load_descriptive_transfer_data();
  $this->student->list_transfer_eqvs_unassigned->sort_alphabetical_order();
  $this->student->list_transfer_eqvs_unassigned->reset_counter();
  $ut_is_empty = TRUE;
  $html = "<!--TRANS_UN_COURSES-->";
  while ($this->student->list_transfer_eqvs_unassigned->has_more()) {

    $c = $this->student->list_transfer_eqvs_unassigned->get_next();

    $l_si = $c->subject_id;
    $l_cn = $c->course_num;
    $l_term = $c->get_term_description(true);

    $html .= "<div class=' ' style='padding-left: 10px; padding-bottom: 5px;
                                       margin-left: 1.5em; text-indent: -1.5em;'>
              $l_si $l_cn (" . $c->get_hours() . " " . t("hrs") . ") from <em>$c->institution_name</em>.
                ";


    $html .= "</div>";

    $ut_is_empty = false;
    $is_empty = false;
  }


  if ($ut_is_empty == false) 
   {
    $mtitle = "<div style='padding-bottom: 10px;'>
            <div style='padding-bottom: 5px;'>
            <b>" . t("Transfer Equivalency Removed Courses") . "</b><br>
        " . t("These courses have had their default transfer equivalencies removed.
                ") . "</div>";
    $html = str_replace("<!--TRANS_UN_COURSES-->", $mtitle, $html);
    $html .= "</div>";

    $render ['section_trans_un_courses'] = array(
      'value' => $html,
      'weight' => 400,
    );

  }



  ////////////////////////////////////
  ////  Moved Courses...
  $m_is_empty = TRUE;
  $html = "<!--MOVEDCOURSES-->";
  $this->student->list_courses_taken->sort_alphabetical_order();
  $this->student->list_courses_taken->reset_counter();
  while ($this->student->list_courses_taken->has_more()) 
   {
    $c = $this->student->list_courses_taken->get_next();
    // Skip courses which haven't had anything moved.
    if ($c->group_list_unassigned->is_empty == true) {
      continue;
    }


    if ($c->course_id > 0) 
     {
      $c->load_descriptive_data();
    }

    $l_s_i = $c->subject_id;
    $l_c_n = $c->course_num;
    $l_term = $c->get_term_description(true);


    $c->group_list_unassigned->reset_counter();
    while ($c->group_list_unassigned->has_more()) {

      $html .= "<div class=' ' style='padding-left: 10px; padding-bottom: 5px;
                                       margin-left: 1.5em; text-indent: -1.5em;'>
                      $l_s_i $l_c_n (" . $c->get_hours_awarded() . " " . t("hrs") . ") - $c->grade - $l_term
                    ";

      $group = $c->group_list_unassigned->get_next();
      $group->load_descriptive_data();
      $group_title = "";
      $degree_title = "";
      if ($group->req_by_degree_id != 0) {
        $tdeg = new DegreePlan();
        $tdeg->degree_id = $group->req_by_degree_id;
        $degree_title = " (" . $tdeg->get_title2(FALSE, TRUE) . ")";
      }
      if ($group->group_id > 0) 
       {
        $group_title = "<i>$group->title</i>";
      }
      else {
        $group_title = t("the degree plan");
      }
      $html .= t("was removed from") . " $group_title$degree_title.";

      $html .= "</div>";

    }

    $m_is_empty = false;
    $is_empty = false;
  }

  if ($m_is_empty == false) 
   {
    $mtitle = "<div style='padding-bottom: 10px;'>
            <div style='padding-bottom: 5px;' class='moved-courses'>
            <b>" . t("Moved Courses") . "</b><br>
        " . t("These courses have been moved out of their 
        original positions on your degree plan.") . "</div>";
    $html = str_replace("<!--MOVEDCOURSES-->", $mtitle, $html);
    $html .= "</div>";

    $render ['section_moved_courses'] = array(
      'value' => $html,
      'weight' => 410,
    );
  }



  // For admins only....
  if (user_has_permission("can_substitute") && $bool_include_box_top) {
    if ($this->bool_print != true) 
     { // Don't display in print view.
      $purl = fp_url("advise/popup-toolbox/transfers");
      $html = "<div class='admin-toolbox-link-wrapper'>         
          <a href='javascript: popupSmallIframeDialog(\"" . $purl . "\",\"" . t("Administrator&#39;s Toolbox") . "\",\"\");'><img src='" . fp_theme_location() . "/images/toolbox.gif' border='0'>" . t("Administrator's Toolbox") . "</a>
        </div>";
      $is_empty = false;

      $render ['section_administrator_toolbox_link'] = array(
        'value' => $html,
        'weight' => 700,
      );

    }
  }


  //$pC .= "</td></tr>";

  $render ['tr_td_end'] = array(
    'value' => "</td></tr>",
    'weight' => 800,
  );


  if ($bool_include_box_top) {
    //$pC .= $this->draw_semester_box_bottom();
    $render ['box_bottom'] = array(
      'value' => $this->draw_semester_box_bottom(),
      'weight' => 810,
    );

  }

  $output = fp_render_content($render, FALSE);

  if (!$is_empty) 
   {
    $this->add_to_screen($output, "FOOTNOTES");
  }

  // Return so other functions can use this output, if needed.
  return $output;
}