function _AdvisingScreen::draw_progress_boxes

4.x _AdvisingScreen.php _AdvisingScreen::draw_progress_boxes()
5.x _AdvisingScreen.php _AdvisingScreen::draw_progress_boxes()

This function calls drawPieChart to construct the student's 3 progress pie charts.

Return value

string

1 call to _AdvisingScreen::draw_progress_boxes()
_AdvisingScreen::display_screen in classes/_AdvisingScreen.php
This function generates the HTML to display the screen. Should be used in conjunction with output_to_browser()

File

classes/_AdvisingScreen.php, line 1610

Class

_AdvisingScreen

Code

function draw_progress_boxes() 
 {
  global $user;
  // Draw the boxes for student progress (where
  // the pie charts go!)
  $rtn = "";

  if (!$this->db) {
    $this->db = get_global_database_handler();
  }

  $user->settings = $this->db->get_user_settings($user->id);

  $bool_charts_are_hidden = FALSE;



  // have we already calculated this degree's data?
  if (@$this->degree_plan->bool_calculated_progess_hours != TRUE) 
   {

    // Only bother to get the types calculations needed for the piecharts
    // Get the requested piecharts from our config...
    $types = array();
    $temp = variable_get("pie_chart_config", "c ~ Core Requirements\nm ~ Major Requirements\ndegree ~ Degree Progress");
    $lines = explode("\n", $temp);
    foreach ($lines as $line) {
      if (trim($line) == "") {
        continue;
      }
      $temp = explode("~", $line);
      $requirement_type = trim($temp [0]);
      $types [$requirement_type] = trim($temp [1]);
    }


    $this->degree_plan->calculate_progress_hours(FALSE, $types);

    $this->degree_plan->calculate_progress_quality_points(FALSE, $types);

  }

  // Create a "theme" array for later use.		
  $pie_chart_theme_array = array();
  $pie_chart_theme_array ["screen"] = $this;
  $pie_chart_theme_array ["student"] = $this->student;
  $pie_chart_theme_array ["degree_plan"] = $this->degree_plan;


  // Get the requested piecharts from our config...
  $temp = variable_get("pie_chart_config", "c ~ Core Requirements\nm ~ Major Requirements\ndegree ~ Degree Progress");
  $config_lines = explode("\n", $temp);

  // Go through each of the degrees we have piecharts for
  foreach ($this->degree_plan->gpa_calculations as $degree_id => $val) {


    $dp = new DegreePlan();
    $dp->degree_id = $degree_id;
    if ($degree_id > 0) {
      $dp->load_descriptive_data();
      $d_title = $dp->get_title2(FALSE, TRUE);
      $d_code = fp_get_machine_readable($dp->major_code);
    }
    else {
      // Degree_id == 0, so this is the "overall" degree.
      $d_title = t("Overall Progress");
      $d_code = "PIE_OVERALL_PROGRESS";
    }

    // Add to our theme array.
    $pie_chart_theme_array ["degree_rows"][$degree_id] = array(
      "degree_id" => $degree_id,
      "row_label" => $d_title,
      "row_classes" => "",
      "degree_plan" => $dp,
      "degree_major_code_machine" => $d_code,
      "bool_display" => TRUE,
    );


    foreach ($config_lines as $line) {
      if (trim($line) == "") {
        continue;
      }

      $temp = explode("~", $line);
      $requirement_type = trim($temp [0]);
      $label = trim($temp [1]);
      $unfinished_col = @trim($temp [2]);
      $progress_col = @trim($temp [3]);

      if ($unfinished_col == "") {
        $unfinished_col = "660000";
      }
      if ($progress_col == "") {
        $progress_col = "FFCC33";
      }


      // Okay, let's see if this degreeplan even has any data on this requirement type.
      $total_hours = $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["total_hours"] * 1;
      $fulfilled_hours = $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["fulfilled_hours"] * 1;
      $qpts = $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["qpts"] * 1;

      if ($total_hours < 1) {
        continue; // no hours for this requirement type!
      }

      // Setting to display GPA
      $gpa = $extra_gpa = "";
      if (variable_get("pie_chart_gpa", "no") == "yes") {
        if ($this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["qpts_hours"] > 0) {
          $gpa = fp_truncate_decimals($qpts / $this->degree_plan->gpa_calculations [$degree_id][$requirement_type]["qpts_hours"], 3);
        }
        if ($gpa) {
          $extra_gpa = "<div class='view-extra-gpa tenpt' style='text-align: right; color: gray;'>GPA: $gpa</div>";
        }
      }

      // If we are here, then there is indeed enough data to create a piechart!
      // Generate the pie chart and add to our array, for later display.
      $html = $this->draw_pie_chart_box($label, $fulfilled_hours, $total_hours, "", $unfinished_col, $progress_col, $extra_gpa);
      $hide_pie_html = "$label: $fulfilled_hours / $total_hours";

      // Will only display if we've set it above.
      if ($gpa) {
        $hide_pie_html .= " ($gpa)";
      }

      $pie_chart_html_array [] = array(
        "pie" => $html,
        "hide_pie" => $hide_pie_html,
      );

      // Add to our theme array
      $pie_chart_theme_array ["degree_rows"][$degree_id]["data"][$requirement_type] = array(
        "full_html" => $html,
        "hide_pie_html" => $hide_pie_html,
        "requirement_type" => $requirement_type,
        "label" => $label,
        "unfinished_col" => $unfinished_col,
        "progress_col" => $progress_col,
        "total_hours" => $total_hours,
        "fulfilled_hours" => $fulfilled_hours,
        "qpts" => $qpts,
        "bool_display" => TRUE,
        "pie_classes" => '',
      );



    } // foreach $line  (for piechart by type)

  } //foreach $degree_id


  //////////////////
  // Send the pie_chart_theme_array to a hook for possible extra processing.
  invoke_hook("theme_pie_charts", array(&$pie_chart_theme_array));
  //////////////////


  // Now, cycle through all of the 'rows' of degrees we need to draw. 
  foreach ($pie_chart_theme_array ["degree_rows"] as $degree_id => $details) {

    if ($details ["bool_display"] === FALSE) {
      continue; // hide the entire row  
    }


    $rtn .= "<tr class='pie-degree-row pie-degree-row-$degree_id {$details ['row_classes']}'><td colspan='2'>
  				      <div class='pie-row-label'>{$details ["row_label"]}</div>";


    $td_width = "";
    if (@count($pie_chart_html_array) > 0) {
      $td_width = round(100 / count($pie_chart_html_array));
    }

    if (!isset($user->settings ["hide_charts"])) {
      $user->settings ["hide_charts"] = "";
    }

    if ($this->bool_force_pie_charts || ($user->settings ["hide_charts"] != "hide" && $this->bool_print == false && $this->bool_blank == false && $this->page_is_mobile == false)) 
     { // Display the pie charts

      $bool_charts_are_hidden = FALSE;

      $rtn .= "
          				<div style='margin-bottom: 10px;' class='pies-wrapper'>
            				<table class='pie-chart-table' width='100%' cellspacing='0' cellpadding='0' border='0'>
              				<tr>
          				";

      $c = 0;
      if (@isset($pie_chart_theme_array ['degree_rows'][$degree_id]["data"])) {
        foreach ($pie_chart_theme_array ['degree_rows'][$degree_id]["data"] as $requirement_type => $val) {
          $html = $val ["full_html"];
          if (@$val ["bool_display"] === FALSE) {
            continue; // this particular chart shouldn't be shown.
          }

          $style = @($c == count($pie_chart_html_array) - 1) ? "" : "padding-right:5px;";
          $rtn .= "<td width='$td_width%' style='$style' class='td_full_pie td_full_pie_$requirement_type " . @$val ["pie_classes"] . "'>
    					         " . $html . "
    				         </td>";
          $c++;
        }
      }


      $rtn .= "  </table>";

      $rtn .= "</div>"; // class pies-wrapper

    }
    else {
      // Hide the charts!
      $bool_charts_are_hidden = TRUE;

      $rtn .= "
   			<table border='0' width='100%'  class='pie-chart-table-hide-charts 
   			                                elevenpt blueBorder' cellpadding='0' cellspacing='0' >
   			<tr class='pie-hidden-charts-label-row'>
    				<td colspan='10' class='blueTitle' align='center' height='20'>
      			" . fp_render_square_line(t("Progress")) . "
    				</td>
   			</tr>
   			<tr class='pie-hidden-charts-row'>";

      $c = 0;
      if (isset($pie_chart_theme_array ['degree_rows'][$degree_id]["data"])) {
        foreach ($pie_chart_theme_array ['degree_rows'][$degree_id]["data"] as $requirement_type => $val) {
          $html = $val ["hide_pie_html"];
          if ($val ["bool_display"] === FALSE) {
            continue; // this particular chart shouldn't be shown.
          }

          $rtn .= "<td width='$td_width%' align='center' class='td_hidden_pie td_hidden_pie_$requirement_type {$val ["pie_classes"]} '>
    					         " . $html . "
    				         </td>";
          $c++;
        }
      }

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





    }



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


  } // foreach degree_rows



  ///////////////////////////////////
  // Show the show/hide link
  $rtn .= "<tr class='pie-show-hide-links'><td colspan='2'>";

  if ($bool_charts_are_hidden) {
    // Charts are hidden, so show the "Show" link.
    if ($this->bool_print != true && $this->bool_blank != true && $this->page_is_mobile != true) 
     {

      $rtn .= "<div style='font-size: 8pt; text-align:right;' class='pie-show-charts-link'>
                     <a href='javascript:hideShowCharts(\"show\");'>" . t("show charts") . "</a>
                  </div>
          ";
    }
    else {
      $rtn .= "<div> &nbsp; </div>";
    }

  }
  else {
    // Charts are visible, so display the "Hide" link
    if (!$this->bool_force_pie_charts) {
      $rtn .= "       
          <div style='font-size: 8pt; text-align:right;' class='pie-hide-charts-link'>
            <a href='javascript:hideShowCharts(\"hide\");'>" . t("hide charts") . "</a>
          </div>";
    }

  }

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





  return $rtn;
}