function audit_display_audit
Search API
7.x audit.module | audit_display_audit() |
6.x audit.module | audit_display_audit() |
File
- modules/
audit/ audit.module, line 323 - This is the Audit module, which provides functionality relating to degree audits.
Code
function audit_display_audit() {
global $current_student_id, $user, $fp, $degree_plan, $screen;
fp_set_title('');
$rtn = "";
fp_add_css(fp_get_module_path("comments") . "/css/comments.css");
fp_add_css(fp_get_module_path("audit") . "/css/audit.css");
fp_add_js(fp_get_module_path("audit") . "/js/audit.js");
// We will re-use code from the advise module, to pre-initialize all of our information for the student.
$temp = advise_display_view();
// We will get rid of the sub tabs and other values we've added.
fp_set_page_sub_tabs(array());
$screen->screen_mode = "not_advising"; // do this so the mini profile doesn't get any options added to it from the advise module.
$student = $fp->student;
$school_id = $student->school_id;
// Get this from settings
$audit_requirement_types = array();
$tlines = explode("\n", variable_get_for_school("audit_requirement_types", "g ~ General Requirements\nc ~ Core\nm ~ Major\ndegree ~ Degree", '', $school_id));
foreach ($tlines as $tline) {
$temp = explode("~", trim($tline));
if (trim($temp [0]) != "") {
$audit_requirement_types [trim($temp [0])] = trim($temp [1]);
}
}
$pol = "";
$rtn .= " <table class='audit-table'> ";
$degree_plan->calculate_progress_hours(TRUE);
$degree_plan->calculate_progress_quality_points(TRUE);
foreach ($degree_plan->gpa_calculations as $gpa_degree_id => $gpa_details) {
if ($gpa_degree_id == 0) {
// This is "overall"
$rtn .= "<tr class='audit-req audit-req-new-degree-title audit-row-$pol audit-req-degree-title-OVERALL'>
<td colspan='3'>" . t("Overall:") . "</td>
</tr>";
$pol = ""; // start over after a blank row
}
else {
// This is a degree.
$dtitle = fp_get_degree_title($gpa_degree_id, TRUE, TRUE);
$rtn .= "<tr class='audit-req audit-req-new-degree-title audit-row-$pol audit-req-degree-title-member-degree'>
<td colspan='3'>$dtitle:</td>
</tr>";
$pol = ""; // start over after a blank row
}
foreach ($audit_requirement_types as $type => $desc) {
$gpa = "";
if ($pol != "even") {
$pol = "even";
}
else {
$pol = "odd";
}
if (@$degree_plan->gpa_calculations [$gpa_degree_id][$type]["qpts_hours"] > 0) {
$gpa = fp_truncate_decimals($degree_plan->gpa_calculations [$gpa_degree_id][$type]["qpts"] / $degree_plan->gpa_calculations [$gpa_degree_id][$type]["qpts_hours"], 3);
}
$percent = "0";
if (@$degree_plan->gpa_calculations [$gpa_degree_id][$type]["total_hours"] > 0) {
$percent = fp_truncate_decimals(($degree_plan->gpa_calculations [$gpa_degree_id][$type]["fulfilled_hours"] / $degree_plan->gpa_calculations [$gpa_degree_id][$type]["total_hours"]) * 100, 2);
}
// Are we trying to judt have a blank row?
if ($desc == "BLANK") { // if description is BLANK, then yes, make this row blank.
$rtn .= "<tr class='audit-req audit-req-BLANK audit-row-$pol audit-row-blank'>
<td colspan='3'> </td>
</tr>";
$pol = ""; // start over after a blank row
continue;
}
// Okay, let's display our row normally now:
$rtn .= "
<tr class='audit-req audit-req-$type audit-row-$pol'>
<td width='25%'>$desc:</td>
<td class='audit-req-hours-percent'><span class='audit-hours'><span class='audit-completed-hours'>{$degree_plan->gpa_calculations [$gpa_degree_id][$type]["fulfilled_hours"]}</span>
/ <span class='audit-total-hours'>{$degree_plan->gpa_calculations [$gpa_degree_id][$type]["total_hours"]} hrs</span>
</span>
<span class='audit-percent-completed'>($percent%)</span>
</td>
<td class='audit-req-gpa'>GPA: $gpa ({$degree_plan->gpa_calculations [$gpa_degree_id][$type]["qpts"]} qpts
/ {$degree_plan->gpa_calculations [$gpa_degree_id][$type]["qpts_hours"]} qhrs)</td>
</tr>";
} // foreach audit_requirements
} // foreach degreeplan->gpa_calculations
// invoke hook to check for more "overall" / calculations information for audit tab
$res = invoke_hook('audit_get_additional_overall_calculations', array($student, $school_id));
if (is_array($res) && count($res) > 0) {
$pol = "";
$rtn .= "<tr class='audit-req audit-req-new-degree-title audit-row-$pol audit-req-degree-title-OVERALL'>
<td colspan='3'>" . t("Additional:") . "</td>
</tr>";
foreach ($res as $module_name => $thow_away) {
if (isset($res [$module_name]) && is_array($res [$module_name])) {
foreach ($res [$module_name] as $c => $calcs) {
if ($pol != "even") {
$pol = "even";
}
else {
$pol = "odd";
}
$title = $calcs ['title'];
$sec_1 = $calcs ['section_1_html'];
$sec_2 = $calcs ['section_2_html'];
$rtn .= "
<tr class='audit-req audit-req-additional-from-hook audit-row-$pol'>
<td width='25%'>$title</td>
<td class='audit-req-hours-percent'>$sec_1</td>
<td class='audit-req-gpa'>$sec_2</td>
</tr>";
}
}
}
// Add a blank row at the end to make it easier to read.
$rtn .= "<tr class='audit-req audit-req-BLANK audit-row-$pol '>
<td colspan='3'> </td>
</tr>";
$pol = ""; // start over after a blank row
}
$rtn .= "
<tr>
<td valign='top'>Footnotes & Messages:</td>
<td colspan='2'><table border='0' width='100%'>
" . $screen->build_footnotes(FALSE) . "
</table>
</td>
</tr>
";
$rtn .= "
<tr>
<td valign='top'>Approvals:</td>
<td colspan='2'>
<table border='0' class='approvals' width='100%'>
";
// Get approval types from our setting
$types = audit_get_approval_types($school_id);
$options = audit_get_approval_options();
// Go through our types, displaying completed or not completed lines...
foreach ($types as $approval_type => $approval_details) {
$approval_title = $approval_details ["title"];
$approval_description = $approval_details ["description"];
$approval_value = '';
$faculty_id = '';
$posted = 0;
$cur = audit_get_approval_record($student->student_id, $approval_type);
if ($cur) {
$posted = $cur ['posted'];
$faculty_id = $cur ['faculty_id'];
$approval_value = $cur ['approval_value'];
}
$dt = date("m/d/Y", $posted);
$faculty_name = fp_get_faculty_name($faculty_id);
if ($approval_value == "") {
$approval_value = "not_complete";
$dt = $faculty_name = " -- ";
}
$approval_value_desc = $options [$approval_value];
if ($approval_value_desc == "") {
@$approval_value_desc = $approval_value;
}
$rtn .= "<tr class='audit-approval-row audit-approval-row-" . $approval_value . "'>";
$rtn .= "
<td><div class='audit-approval-title audit-approval-" . $approval_value . "'>$approval_title</div>
<td class='audit-approval-value audit-approval-desc-" . $approval_value . "'>" . $approval_value_desc . "</td>
<td class='audit-approval-datetime'>" . $dt . "</td>
<td class='audit-approval-faculty'>" . $faculty_name . "</td>";
$rtn .= "
<td>
<a class='approval-edit' href='javascript:popupSmallIframeDialog(\"" . fp_url("audit/popup-edit-approval/$approval_type/$student->student_id") . "\",\"" . t("Edit Approval") . "\",\"\");'><i class='fa fa-pencil'></i> Edit</a>
</td>
";
$rtn .= "</tr>";
// If the is an approval_description, show it in a new row....
if ($approval_description != "") {
$rtn .= "<tr>
<td colspan='5' class='audit-approval-description audit-approval-description=" . $approval_value . "'><div>$approval_description</div></td>
</tr>";
}
} // foreach types => approval_type
$rtn .= "
</table> <!-- class approvals -->
</td>
</tr>
</table> <!-- class audit-table -->";
$rtn .= "
<hr>
<h2>" . t("Audit Comments") . "</h2>
" . t("These comments will be visible to individuals with access to this tab.") . "
";
// Add our audit comments form in the page. The extra code is about not making the title show
// up twice.
$temp_title = $GLOBALS ["fp_set_title"];
$GLOBALS ["fp_set_title"] = ""; // prevent page title from showing up here
$form = fp_render_form("audit_comment_form", "normal", $student->student_id, $user->cwid);
$GLOBALS ["fp_set_title"] = $temp_title;
$rtn .= fp_render_c_fieldset($form, t("Click to enter audit comment"), TRUE, 'enter-audit-comment-fs');
$comments = comments_get_comments($student->student_id, FALSE, array("audit private"));
foreach ($comments as $comment) {
$delete_link = "";
// Should we present a "delete link" to the user for this comment?
if (user_has_permission("can_delete_own_comments_3_months")) {
// See if this comment is younger than 3 months.
$del_range = strtotime("-3 month");
$then = $comment ["posted"];
if ($then > $del_range) {
// We will use the comment module's delete function for this, and tell it to
// redirect back here by setting the destination=audit.
$js_action = 'window.location=FlightPath.settings.basePath + "/comments/delete-comment¤t_student_id=' . $student->student_id . '&comment_id=' . $comment ['id'] . '&destination=audit";';
$delete_link = fp_get_js_confirm_link(t("Are you sure you wish to delete this comment?\nThis action cannot be undone."), $js_action, "Delete?");
}
}
$rtn .= comments_render_comment($comment, $delete_link);
}
// We wish to add our hidden form, so the approval popup can write its values to this page,
// and then submit them.
$temp_title = $GLOBALS ["fp_set_title"];
$GLOBALS ["fp_set_title"] = ""; // prevent page title from showing up here
$rtn .= fp_render_form("audit_hidden_approval_form");
$GLOBALS ["fp_set_title"] = $temp_title;
watchdog("audit", "display_audit $student->student_id", array());
return $rtn;
}