Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/rptAssignmentScoresreport.php

<?php
session_start(); // Initialize Session data
ob_start(); // Turn on output buffering
?>
<?php include "ewcfg7.php" ?>
<?php include "ewmysql7.php" ?>
<?php include "phpfn7.php" ?>
<?php

// Global variable for table object
$rptAssignmentScores = NULL;

//
// Table class for rptAssignmentScores
//
class crptAssignmentScores {
	var $TableVar = 'rptAssignmentScores';
	var $TableName = 'rptAssignmentScores';
	var $TableType = 'REPORT';
	var $FirstName;
	var $Surname;
	var $RefNum;
	var $AssignmentScore;
	var $fields = array();
	var $UseTokenInUrl = EW_USE_TOKEN_IN_URL;
	var $Export; // Export
	var $ExportOriginalValue = EW_EXPORT_ORIGINAL_VALUE;
	var $ExportAll = TRUE;
	var $SendEmail; // Send email
	var $TableCustomInnerHtml; // Custom inner HTML
	var $BasicSearchKeyword; // Basic search keyword
	var $BasicSearchType; // Basic search type
	var $CurrentFilter; // Current filter
	var $CurrentOrder; // Current order
	var $CurrentOrderType; // Current order type
	var $RowType; // Row type
	var $CssClass; // CSS class
	var $CssStyle; // CSS style
	var $RowAttrs = array(); // Row custom attributes
	var $TableFilter = "";

	//
	// Table class constructor
	//
	function crptAssignmentScores() {
		global $Language;

		// FirstName
		$this->FirstName = new cField('rptAssignmentScores', 'rptAssignmentScores', 'x_FirstName', 'FirstName', 'CCEStudents.FirstName', 200, -1, FALSE, 'CCEStudents.FirstName', FALSE);
		$this->fields['FirstName'] =& $this->FirstName;

		// Surname
		$this->Surname = new cField('rptAssignmentScores', 'rptAssignmentScores', 'x_Surname', 'Surname', 'CCEStudents.Surname', 200, -1, FALSE, 'CCEStudents.Surname', FALSE);
		$this->fields['Surname'] =& $this->Surname;

		// RefNum
		$this->RefNum = new cField('rptAssignmentScores', 'rptAssignmentScores', 'x_RefNum', 'RefNum', 'CCEAssignments.RefNum', 200, -1, FALSE, 'CCEAssignments.RefNum', FALSE);
		$this->fields['RefNum'] =& $this->RefNum;

		// AssignmentScore
		$this->AssignmentScore = new cField('rptAssignmentScores', 'rptAssignmentScores', 'x_AssignmentScore', 'AssignmentScore', 'CCEStudentAssignments.AssignmentScore', 5, -1, FALSE, 'CCEStudentAssignments.AssignmentScore', FALSE);
		$this->AssignmentScore->FldDefaultErrMsg = $Language->Phrase("IncorrectFloat");
		$this->fields['AssignmentScore'] =& $this->AssignmentScore;
	}

	// Table caption
	function TableCaption() {
		global $Language;
		return $Language->TablePhrase($this->TableVar, "TblCaption");
	}

	// Page caption
	function PageCaption($Page) {
		global $Language;
		$Caption = $Language->TablePhrase($this->TableVar, "TblPageCaption" . $Page);
		if ($Caption == "") $Caption = "Page " . $Page;
		return $Caption;
	}

	// Report group level SQL
	function SqlGroupSelect() { // Select
		return "SELECT DISTINCT CCEStudents.Surname,CCEStudents.FirstName FROM CCEStudents Inner Join CCEStudentAssignments On CCEStudents.CCEStudentID = CCEStudentAssignments.CCEStudentID Inner Join CCEAssignments On CCEAssignments.CCEAssignmentID = CCEStudentAssignments.CCEAssignmentID";
	}

	function SqlGroupWhere() { // Where
		return "CCEStudentAssignments.AssignmentScore IS NOT NULL AND CCEStudentAssignments.RulingCode IS NOT NULL And CCEStudents.Archived = 0 And CCEAssignments.Archived = 0";
	}

	function SqlGroupGroupBy() { // Group By
		return "";
	}

	function SqlGroupHaving() { // Having
		return "";
	}

	function SqlGroupOrderBy() { // Order By
		return "CCEStudents.Surname ASC,CCEStudents.FirstName ASC";
	}

	// Report detail level SQL
	function SqlDetailSelect() { // Select
		return "SELECT CCEStudents.FirstName, CCEStudents.Surname, CCEAssignments.RefNum, CCEStudentAssignments.AssignmentScore FROM CCEStudents Inner Join CCEStudentAssignments On CCEStudents.CCEStudentID = CCEStudentAssignments.CCEStudentID Inner Join CCEAssignments On CCEAssignments.CCEAssignmentID = CCEStudentAssignments.CCEAssignmentID";
	}

	function SqlDetailWhere() { // Where
		return "CCEStudentAssignments.AssignmentScore IS NOT NULL AND CCEStudentAssignments.RulingCode IS NOT NULL And CCEStudents.Archived = 0 And CCEAssignments.Archived = 0";
	}

	function SqlDetailGroupBy() { // Group By
		return "";
	}

	function SqlDetailHaving() { // Having
		return "";
	}

	function SqlDetailOrderBy() { // Order By
		return "CCEAssignments.RefNum ASC, CCEStudents.Surname, CCEStudents.FirstName, CCEAssignments.RefNum";
	}

	// Check if Anonymous User is allowed
	function AllowAnonymousUser() {
		switch (EW_PAGE_ID) {
			case "add":
			case "register":
			case "addopt":
				return FALSE;
			case "edit":
			case "update":
				return FALSE;
			case "delete":
				return FALSE;
			case "view":
				return FALSE;
			case "search":
				return FALSE;
			default:
				return FALSE;
		}
	}

	// Apply User ID filters
	function ApplyUserIDFilters($sFilter) {
		return $sFilter;
	}

	// Report group SQL
	function GroupSQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = "";
		return ew_BuildSelectSql($this->SqlGroupSelect(), $this->SqlGroupWhere(),
			 $this->SqlGroupGroupBy(), $this->SqlGroupHaving(),
			 $this->SqlGroupOrderBy(), $sFilter, $sSort);
	}

	// Report detail SQL
	function DetailSQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = "";
		return ew_BuildSelectSql($this->SqlDetailSelect(), $this->SqlDetailWhere(),
			$this->SqlDetailGroupBy(), $this->SqlDetailHaving(),
			$this->SqlDetailOrderBy(), $sFilter, $sSort);
	}

	// Return page URL
	function getReturnUrl() {
		$name = EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL;

		// Get referer URL automatically
		if (ew_ServerVar("HTTP_REFERER") <> "" && ew_ReferPage() <> ew_CurrentPage() && ew_ReferPage() <> "login.php") // Referer not same page or login page
			$_SESSION[$name] = ew_ServerVar("HTTP_REFERER"); // Save to Session
		if (@$_SESSION[$name] <> "") {
			return $_SESSION[$name];
		} else {
			return "rptAssignmentScoresreport.php";
		}
	}

	function setReturnUrl($v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_RETURN_URL] = $v;
	}

	// List URL
	function ListUrl() {
		return "rptAssignmentScoresreport.php";
	}

	// View URL
	function ViewUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Add URL
	function AddUrl() {
		$AddUrl = "";
		$sUrlParm = $this->UrlParm();
		if ($sUrlParm <> "")
			$AddUrl .= "?" . $sUrlParm;
		return $AddUrl;
	}

	// Edit URL
	function EditUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Inline edit URL
	function InlineEditUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=edit"));
	}

	// Copy URL
	function CopyUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Inline copy URL
	function InlineCopyUrl() {
		return $this->KeyUrl(ew_CurrentPage(), $this->UrlParm("a=copy"));
	}

	// Delete URL
	function DeleteUrl() {
		return $this->KeyUrl("", $this->UrlParm());
	}

	// Add key value to URL
	function KeyUrl($url, $parm = "") {
		$sUrl = $url . "?";
		if ($parm <> "") $sUrl .= $parm . "&";
		return $sUrl;
	}

	// Sort URL
	function SortUrl(&$fld) {
		if ($this->CurrentAction <> "" || $this->Export <> "" ||
			in_array($fld->FldType, array(128, 204, 205))) { // Unsortable data type
				return "";
		} elseif ($fld->Sortable) {
			$sUrlParm = $this->UrlParm("order=" . urlencode($fld->FldName) . "&ordertype=" . $fld->ReverseSort());
			return ew_CurrentPage() . "?" . $sUrlParm;
		} else {
			return "";
		}
	}

	// Add URL parameter
	function UrlParm($parm = "") {
		$UrlParm = ($this->UseTokenInUrl) ? "t=rptAssignmentScores" : "";
		if ($parm <> "") {
			if ($UrlParm <> "")
				$UrlParm .= "&";
			$UrlParm .= $parm;
		}
		return $UrlParm;
	}

	// Load rows based on filter
	function &LoadRs($sFilter) {
		global $conn;

		// Set up filter (SQL WHERE clause) and get return SQL
		$this->CurrentFilter = $sFilter;
		$sSql = $this->SQL();
		return $conn->Execute($sSql);
	}

	// Load row values from recordset
	function LoadListRowValues(&$rs) {
		$this->FirstName->setDbValue($rs->fields('FirstName'));
		$this->Surname->setDbValue($rs->fields('Surname'));
		$this->RefNum->setDbValue($rs->fields('RefNum'));
		$this->AssignmentScore->setDbValue($rs->fields('AssignmentScore'));
	}

	// Render list row values
	function RenderListRow() {
		global $conn, $Security;

   // Common render codes
		// FirstName

		$rptAssignmentScores->FirstName->CellCssStyle = ""; $rptAssignmentScores->FirstName->CellCssClass = "";
		$rptAssignmentScores->FirstName->CellAttrs = array(); $rptAssignmentScores->FirstName->ViewAttrs = array(); $rptAssignmentScores->FirstName->EditAttrs = array();

		// Surname
		$rptAssignmentScores->Surname->CellCssStyle = ""; $rptAssignmentScores->Surname->CellCssClass = "";
		$rptAssignmentScores->Surname->CellAttrs = array(); $rptAssignmentScores->Surname->ViewAttrs = array(); $rptAssignmentScores->Surname->EditAttrs = array();

		// RefNum
		$rptAssignmentScores->RefNum->CellCssStyle = ""; $rptAssignmentScores->RefNum->CellCssClass = "";
		$rptAssignmentScores->RefNum->CellAttrs = array(); $rptAssignmentScores->RefNum->ViewAttrs = array(); $rptAssignmentScores->RefNum->EditAttrs = array();

		// AssignmentScore
		$rptAssignmentScores->AssignmentScore->CellCssStyle = ""; $rptAssignmentScores->AssignmentScore->CellCssClass = "";
		$rptAssignmentScores->AssignmentScore->CellAttrs = array(); $rptAssignmentScores->AssignmentScore->ViewAttrs = array(); $rptAssignmentScores->AssignmentScore->EditAttrs = array();

		// FirstName
		$rptAssignmentScores->FirstName->ViewValue = $rptAssignmentScores->FirstName->CurrentValue;
		$rptAssignmentScores->FirstName->CssStyle = "";
		$rptAssignmentScores->FirstName->CssClass = "";
		$rptAssignmentScores->FirstName->ViewCustomAttributes = "";

		// Surname
		$rptAssignmentScores->Surname->ViewValue = $rptAssignmentScores->Surname->CurrentValue;
		$rptAssignmentScores->Surname->CssStyle = "";
		$rptAssignmentScores->Surname->CssClass = "";
		$rptAssignmentScores->Surname->ViewCustomAttributes = "";

		// RefNum
		$rptAssignmentScores->RefNum->ViewValue = $rptAssignmentScores->RefNum->CurrentValue;
		$rptAssignmentScores->RefNum->CssStyle = "";
		$rptAssignmentScores->RefNum->CssClass = "";
		$rptAssignmentScores->RefNum->ViewCustomAttributes = "";

		// AssignmentScore
		$rptAssignmentScores->AssignmentScore->ViewValue = $rptAssignmentScores->AssignmentScore->CurrentValue;
		$rptAssignmentScores->AssignmentScore->CssStyle = "";
		$rptAssignmentScores->AssignmentScore->CssClass = "";
		$rptAssignmentScores->AssignmentScore->ViewCustomAttributes = "";

		// FirstName
		$rptAssignmentScores->FirstName->HrefValue = "";
		$rptAssignmentScores->FirstName->TooltipValue = "";

		// Surname
		$rptAssignmentScores->Surname->HrefValue = "";
		$rptAssignmentScores->Surname->TooltipValue = "";

		// RefNum
		$rptAssignmentScores->RefNum->HrefValue = "";
		$rptAssignmentScores->RefNum->TooltipValue = "";

		// AssignmentScore
		$rptAssignmentScores->AssignmentScore->HrefValue = "";
		$rptAssignmentScores->AssignmentScore->TooltipValue = "";
	}

	// Aggregate list row values
	function AggregateListRowValues() {
	}

	// Aggregate list row (for rendering)
	function AggregateListRow() {
	}

	// Row styles
	function RowStyles() {
		$sAtt = "";
		$sStyle = trim($this->CssStyle);
		if (@$this->RowAttrs["style"] <> "")
			$sStyle .= " " . $this->RowAttrs["style"];
		$sClass = trim($this->CssClass);
		if (@$this->RowAttrs["class"] <> "")
			$sClass .= " " . $this->RowAttrs["class"];
		if (trim($sStyle) <> "")
			$sAtt .= " style=\"" . trim($sStyle) . "\"";
		if (trim($sClass) <> "")
			$sAtt .= " class=\"" . trim($sClass) . "\"";
		return $sAtt;
	}

	// Row attributes
	function RowAttributes() {
		$sAtt = $this->RowStyles();
		if ($this->Export == "") {
			foreach ($this->RowAttrs as $k => $v) {
				if ($k <> "class" && $k <> "style" && trim($v) <> "")
					$sAtt .= " " . $k . "=\"" . trim($v) . "\"";
			}
		}
		return $sAtt;
	}

	// Field object by name
	function fields($fldname) {
		return $this->fields[$fldname];
	}
}
?>
<?php include "CCEFacilitatorUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1 
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php

// Create page object
$rptAssignmentScores_report = new crptAssignmentScores_report();
$Page =& $rptAssignmentScores_report;

// Page init
$rptAssignmentScores_report->Page_Init();

// Page main
$rptAssignmentScores_report->Page_Main();
?>
<?php include "header.php" ?>
<?php if ($rptAssignmentScores->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js"); 
//-->

</script>
<?php } ?>
<?php if ($rptAssignmentScores->Export == "") { ?>
<?php } ?>
<p><span class="phpmaker"><?php echo $Language->Phrase("TblTypeReport") ?><?php echo $rptAssignmentScores->TableCaption() ?>
<?php if ($rptAssignmentScores->Export == "") { ?>
&nbsp;&nbsp;<a href="<?php echo $rptAssignmentScores_report->ExportPrintUrl ?>"><img src="images/print.gif" alt="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" title="<?php echo ew_HtmlEncode($Language->Phrase("PrinterFriendly")) ?>" width="16" height="16" border="0"></a>
&nbsp;&nbsp;<a href="<?php echo $rptAssignmentScores_report->ExportExcelUrl ?>"><img src='images/exportxls.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToExcel")) ?>' width='16' height='16' border='0'></a>
&nbsp;&nbsp;<a href="<?php echo $rptAssignmentScores_report->ExportWordUrl ?>"><img src='images/exportdoc.gif' alt='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' title='<?php echo ew_HtmlEncode($Language->Phrase("ExportToWord")) ?>' width='16' height='16' border='0'></a>
<?php } ?>
</span></p>
<form method="post">
<table class="ewReportTable" cellspacing="-1">
<?php
$rptAssignmentScores_report->sTblDefaultFilter = "";
$rptAssignmentScores_report->sFilter = $rptAssignmentScores_report->sTblDefaultFilter;
if ($rptAssignmentScores_report->sDbDetailFilter <> "") {
	if ($rptAssignmentScores_report->sFilter <> "") $rptAssignmentScores_report->sFilter .= " AND ";
	$rptAssignmentScores_report->sFilter .= "(" . $rptAssignmentScores_report->sDbDetailFilter . ")";
}

// Set up filter and load Group level sql
$rptAssignmentScores->CurrentFilter = $rptAssignmentScores_report->sFilter;
$rptAssignmentScores_report->sSql = $rptAssignmentScores->GroupSQL();

// Load recordset
$rs = $conn->Execute($rptAssignmentScores_report->sSql);

// Get First Row
if (!$rs->EOF) {
	$rptAssignmentScores->Surname->setDbValue($rs->fields('Surname'));
	$rptAssignmentScores_report->vGrps[0] = $rptAssignmentScores->Surname->DbValue;
	$rptAssignmentScores->FirstName->setDbValue($rs->fields('FirstName'));
	$rptAssignmentScores_report->vGrps[1] = $rptAssignmentScores->FirstName->DbValue;
}
$rptAssignmentScores_report->lRecCnt = 0;
$rptAssignmentScores_report->nCntRecs[0] = 0;
$rptAssignmentScores_report->ChkLvlBreak();
while (!$rs->EOF) {

	// Render for view
	$rptAssignmentScores->RowType = EW_ROWTYPE_VIEW;
	$rptAssignmentScores_report->RenderRow();

	// Show group headers
	if ($rptAssignmentScores_report->bLvlBreak[1]) { // Reset counter and aggregation
?>
	<tr><td class="ewGroupField"><span class="phpmaker"><?php echo $rptAssignmentScores->Surname->FldCaption() ?></span></td>
	<td colspan=2 class="ewGroupName"><span class="phpmaker">
<div<?php echo $rptAssignmentScores->Surname->ViewAttributes() ?>><?php echo $rptAssignmentScores->Surname->ViewValue ?></div></span></td></tr>
<?php
	}
	if ($rptAssignmentScores_report->bLvlBreak[2]) { // Reset counter and aggregation
?>
	<tr><td class="ewGroupField"><span class="phpmaker"><?php echo $rptAssignmentScores->FirstName->FldCaption() ?></span></td>
	<td colspan=2 class="ewGroupName"><span class="phpmaker">
<div<?php echo $rptAssignmentScores->FirstName->ViewAttributes() ?>><?php echo $rptAssignmentScores->FirstName->ViewValue ?></div></span></td></tr>
<?php
	}

	// Get detail records
	$rptAssignmentScores_report->sFilter = $rptAssignmentScores_report->sTblDefaultFilter;
	if ($rptAssignmentScores_report->sFilter <> "") $rptAssignmentScores_report->sFilter .= " AND ";
	if (is_null($rptAssignmentScores->Surname->CurrentValue)) {
		$rptAssignmentScores_report->sFilter .= "(CCEStudents.Surname IS NULL)";
	} else {
		$rptAssignmentScores_report->sFilter .= "(CCEStudents.Surname = '" . ew_AdjustSql($rptAssignmentScores->Surname->CurrentValue) . "')";
	}
	if ($rptAssignmentScores_report->sFilter <> "") $rptAssignmentScores_report->sFilter .= " AND ";
	if (is_null($rptAssignmentScores->FirstName->CurrentValue)) {
		$rptAssignmentScores_report->sFilter .= "(CCEStudents.FirstName IS NULL)";
	} else {
		$rptAssignmentScores_report->sFilter .= "(CCEStudents.FirstName = '" . ew_AdjustSql($rptAssignmentScores->FirstName->CurrentValue) . "')";
	}
	if ($rptAssignmentScores_report->sDbDetailFilter <> "") {
		if ($rptAssignmentScores_report->sFilter <> "")
			$rptAssignmentScores_report->sFilter .= " AND ";
		$rptAssignmentScores_report->sFilter .= "(" . $rptAssignmentScores_report->sDbDetailFilter . ")";
	}

	// Set up detail SQL
	$rptAssignmentScores->CurrentFilter = $rptAssignmentScores_report->sFilter;
	$rptAssignmentScores_report->sSql = $rptAssignmentScores->DetailSQL();

	// Load detail records
	$rsdtl = $conn->Execute($rptAssignmentScores_report->sSql);
	$rptAssignmentScores_report->nDtlRecs = $rsdtl->RecordCount();

	// Initialize aggregates
	if (!$rsdtl->EOF) {
		$rptAssignmentScores_report->lRecCnt++;
		$rptAssignmentScores->AssignmentScore->setDbValue($rsdtl->fields('AssignmentScore'));
	}
	if ($rptAssignmentScores_report->lRecCnt == 1) {
		$rptAssignmentScores_report->nCntRecs[0] = 0;
		$rptAssignmentScores_report->nTotals[0][1] = 0;
	}
	for ($i = 1; $i <= 2; $i++) {
		if ($rptAssignmentScores_report->bLvlBreak[$i]) { // Reset counter and aggregation
			$rptAssignmentScores_report->nCntRecs[$i] = 0;
			$rptAssignmentScores_report->nTotals[$i][1] = 0;
		}
	}
	$rptAssignmentScores_report->nCntRecs[0] += $rptAssignmentScores_report->nDtlRecs;
	$rptAssignmentScores_report->nCntRecs[1] += $rptAssignmentScores_report->nDtlRecs;
	$rptAssignmentScores_report->nCntRecs[2] += $rptAssignmentScores_report->nDtlRecs;
?>
	<tr>
		<td></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $rptAssignmentScores->RefNum->FldCaption() ?></span></td>
		<td valign="top" class="ewGroupHeader"><span class="phpmaker"><?php echo $rptAssignmentScores->AssignmentScore->FldCaption() ?></span></td>
	</tr>
<?php
	while (!$rsdtl->EOF) {
		$rptAssignmentScores->RefNum->setDbValue($rsdtl->fields('RefNum'));
		$rptAssignmentScores->AssignmentScore->setDbValue($rsdtl->fields('AssignmentScore'));
		$rptAssignmentScores_report->nTotals[0][1] += $rptAssignmentScores->AssignmentScore->CurrentValue;
		$rptAssignmentScores_report->nTotals[1][1] += $rptAssignmentScores->AssignmentScore->CurrentValue;
		$rptAssignmentScores_report->nTotals[2][1] += $rptAssignmentScores->AssignmentScore->CurrentValue;

		// Render for view
		$rptAssignmentScores->RowType = EW_ROWTYPE_VIEW;
		$rptAssignmentScores_report->RenderRow();
?>
	<tr>
		<td></td>
		<td><span class="phpmaker">
<div<?php echo $rptAssignmentScores->RefNum->ViewAttributes() ?>><?php echo $rptAssignmentScores->RefNum->ViewValue ?></div></span></td>
		<td><span class="phpmaker">
<div<?php echo $rptAssignmentScores->AssignmentScore->ViewAttributes() ?>><?php echo $rptAssignmentScores->AssignmentScore->ViewValue ?></div></span></td>
	</tr>
<?php
		$rsdtl->MoveNext();
	}
	$rsdtl->Close();

	// Save old group data
	$rptAssignmentScores_report->vGrps[0] = $rptAssignmentScores->Surname->CurrentValue;
	$rptAssignmentScores_report->vGrps[1] = $rptAssignmentScores->FirstName->CurrentValue;

	// Get next record
	$rs->MoveNext();
	if ($rs->EOF) {
		$rptAssignmentScores_report->lRecCnt = 0; // EOF, force all level breaks
	} else {
		$rptAssignmentScores->Surname->setDbValue($rs->fields('Surname'));
		$rptAssignmentScores->FirstName->setDbValue($rs->fields('FirstName'));
	}
	$rptAssignmentScores_report->ChkLvlBreak();

	// Show footers
	if ($rptAssignmentScores_report->bLvlBreak[2]) {
		$rptAssignmentScores->FirstName->CurrentValue = $rptAssignmentScores_report->vGrps[1];

		// Render row for view
		$rptAssignmentScores->RowType = EW_ROWTYPE_VIEW;
		$rptAssignmentScores_report->RenderRow();
		$rptAssignmentScores->FirstName->CurrentValue = $rptAssignmentScores->FirstName->DbValue;
?>
<?php
}
	if ($rptAssignmentScores_report->bLvlBreak[1]) {
		$rptAssignmentScores->Surname->CurrentValue = $rptAssignmentScores_report->vGrps[0];

		// Render row for view
		$rptAssignmentScores->RowType = EW_ROWTYPE_VIEW;
		$rptAssignmentScores_report->RenderRow();
		$rptAssignmentScores->Surname->CurrentValue = $rptAssignmentScores->Surname->DbValue;
?>
	<tr><td colspan=3 class="ewGroupSummary"><span class="phpmaker"><?php echo $Language->Phrase("RptSumHead") ?>&nbsp;<?php echo $rptAssignmentScores->Surname->FldCaption() ?>:&nbsp;<?php echo $rptAssignmentScores->Surname->ViewValue ?> (<?php echo ew_FormatNumber($rptAssignmentScores_report->nCntRecs[1],0) ?> <?php echo $Language->Phrase("RptDtlRec") ?>)</span></td></tr>
<?php
	if ($rptAssignmentScores_report->nCntRecs[1] > 0) {
		$rptAssignmentScores->AssignmentScore->CurrentValue = round($rptAssignmentScores_report->nTotals[1][1] / $rptAssignmentScores_report->nCntRecs[1],1);
	} else {
		$rptAssignmentScores->AssignmentScore->CurrentValue = 0;
	}

	// Render row for view
	$rptAssignmentScores->RowType = EW_ROWTYPE_VIEW;
	$rptAssignmentScores_report->RenderRow();
?>
	<tr>
		<td class="ewGroupAggregate"><span class="phpmaker"><?php echo $Language->Phrase("RptAvg") ?></span></td>
		<td><span class="phpmaker">&nbsp;</span></td>
		<td><span class="phpmaker">
<div<?php echo $rptAssignmentScores->AssignmentScore->ViewAttributes() ?>><?php echo $rptAssignmentScores->AssignmentScore->ViewValue ?></div></span></td>
	</tr>
	<tr><td colspan=4><span class="phpmaker">&nbsp;<br></span></td></tr>
<?php
}
}

// Close recordset
$rs->Close();
?>
	<tr><td colspan=3><span class="phpmaker">&nbsp;<br></span></td></tr>
	<tr><td colspan=3 class="ewGrandSummary"><span class="phpmaker"><?php echo $Language->Phrase("RptGrandTotal") ?>&nbsp;(<?php echo ew_FormatNumber($rptAssignmentScores_report->nCntRecs[0], 0) ?>&nbsp;<?php echo $Language->Phrase("RptDtlRec") ?>)</span></td></tr>
<?php
	if ($rptAssignmentScores_report->nCntRecs[1] > 0) {
		$rptAssignmentScores->AssignmentScore->CurrentValue = round($rptAssignmentScores_report->nTotals[0][1] / $rptAssignmentScores_report->nCntRecs[0],1);
	} else {
		$rptAssignmentScores->AssignmentScore->CurrentValue = 0;
	}

	// Render row for view
	$rptAssignmentScores->RowType = EW_ROWTYPE_VIEW;
	$rptAssignmentScores_report->RenderRow();
?>
	<tr>
		<td class="ewGroupAggregate"><span class="phpmaker"><?php echo $Language->Phrase("RptAvg") ?></span></td>
		<td><span class="phpmaker">&nbsp;</span></td>
		<td><span class="phpmaker">
<div<?php echo $rptAssignmentScores->AssignmentScore->ViewAttributes() ?>><?php echo $rptAssignmentScores->AssignmentScore->ViewValue ?></div></span></td>
	</tr>
	<tr><td colspan=3><span class="phpmaker">&nbsp;<br></span></td></tr>
</table>
</form>
<?php if ($rptAssignmentScores->Export == "") { ?>
<script language="JavaScript" type="text/javascript">
<!--

// Write your table-specific startup script here
// document.write("page loaded");
//-->

</script>
<?php } ?>
<?php include "footer.php" ?>
<?php
$rptAssignmentScores_report->Page_Terminate();
?>
<?php

//
// Page class
//
class crptAssignmentScores_report {

	// Page ID
	var $PageID = 'report';

	// Table name
	var $TableName = 'rptAssignmentScores';

	// Page object name
	var $PageObjName = 'rptAssignmentScores_report';

	// Page name
	function PageName() {
		return ew_CurrentPage();
	}

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		return $PageUrl;
	}

	// Page URLs
	var $AddUrl;
	var $EditUrl;
	var $CopyUrl;
	var $DeleteUrl;
	var $ViewUrl;
	var $ListUrl;

	// Export URLs
	var $ExportPrintUrl;
	var $ExportHtmlUrl;
	var $ExportExcelUrl;
	var $ExportWordUrl;
	var $ExportXmlUrl;
	var $ExportCsvUrl;

	// Update URLs
	var $InlineAddUrl;
	var $InlineCopyUrl;
	var $InlineEditUrl;
	var $GridAddUrl;
	var $GridEditUrl;
	var $MultiDeleteUrl;
	var $MultiUpdateUrl;

	// Message
	function getMessage() {
		return @$_SESSION[EW_SESSION_MESSAGE];
	}

	function setMessage($v) {
		if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Append
			$_SESSION[EW_SESSION_MESSAGE] .= "<br>" . $v;
		} else {
			$_SESSION[EW_SESSION_MESSAGE] = $v;
		}
	}

	// Show message
	function ShowMessage() {
		$sMessage = $this->getMessage();
		$this->Message_Showing($sMessage);
		if ($sMessage <> "") { // Message in Session, display
			echo "<p><span class=\"ewMessage\">" . $sMessage . "</span></p>";
			$_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
		}
	}

	// Validate page request
	function IsPageRequest() {
		return TRUE;
	}

	//
	// Page class constructor
	//
	function crptAssignmentScores_report() {
		global $conn, $Language;

		// Language object
		$Language = new cLanguage();

		// Table object (rptAssignmentScores)
		$GLOBALS["rptAssignmentScores"] = new crptAssignmentScores();

		// Initialize URLs
		$this->ExportPrintUrl = $this->PageUrl() . "export=print";
		$this->ExportExcelUrl = $this->PageUrl() . "export=excel";
		$this->ExportWordUrl = $this->PageUrl() . "export=word";

		// Table object (CCEFacilitatorUsers)
		$GLOBALS['CCEFacilitatorUsers'] = new cCCEFacilitatorUsers();

		// Page ID
		if (!defined("EW_PAGE_ID"))
			define("EW_PAGE_ID", 'report', TRUE);

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'rptAssignmentScores', TRUE);

		// Start timer
		$GLOBALS["gsTimer"] = new cTimer();

		// Open connection
		$conn = ew_Connect();
	}

	// 
	//  Page_Init
	//
	function Page_Init() {
		global $gsExport, $gsExportFile, $UserProfile, $Language, $Security, $objForm;
		global $rptAssignmentScores;

		// Security
		$Security = new cAdvancedSecurity();
		if (!$Security->IsLoggedIn()) $Security->AutoLogin();
		if (!$Security->IsLoggedIn()) {
			$Security->SaveLastUrl();
			$this->Page_Terminate("login.php");
		}

		// Get export parameters
		if (@$_GET["export"] <> "") {
			$rptAssignmentScores->Export = $_GET["export"];
		}
		$gsExport = $rptAssignmentScores->Export; // Get export parameter, used in header
		$gsExportFile = $rptAssignmentScores->TableVar; // Get export file, used in header
		if ($rptAssignmentScores->Export == "excel") {
			header('Content-Type: application/vnd.ms-excel');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.xls');
		}
		if ($rptAssignmentScores->Export == "word") {
			header('Content-Type: application/vnd.ms-word');
			header('Content-Disposition: attachment; filename=' . $gsExportFile .'.doc');
		}

		// Global Page Loading event (in userfn*.php)
		Page_Loading();

		// Page Load event
		$this->Page_Load();
	}

	//
	// Page_Terminate
	//
	function Page_Terminate($url = "") {
		global $conn;

		// Page Unload event
		$this->Page_Unload();

		// Global Page Unloaded event (in userfn*.php)
		Page_Unloaded();

		 // Close connection
		$conn->Close();

		// Go to URL if specified
		$this->Page_Redirecting($url);
		if ($url <> "") {
			if (!EW_DEBUG_ENABLED && ob_get_length())
				ob_end_clean();
			header("Location: " . $url);
		}
		exit();
	}
	var $lRecCnt = 0;
	var $sSql = "";
	var $sFilter = "";
	var $sTblDefaultFilter = "";
	var $sDbMasterFilter = "";
	var $sDbDetailFilter = "";
	var $bMasterRecordExists;
	var $sCmd = "";
	var $lDtlRecs;
	var $vGrps;
	var $nCntRecs;
	var $bLvlBreak;
	var $nTotals;
	var $nMaxs;
	var $nMins;

	//
	// Page main
	//
	function Page_Main() {
		global $Language, $rptAssignmentScores;
		$this->vGrps =& ew_InitArray(3, NULL);
		$this->nCntRecs =& ew_InitArray(3, 0);
		$this->bLvlBreak =& ew_InitArray(3, FALSE);
		$this->nTotals =& ew_Init2DArray(3, 3, 0);
		$this->nMaxs =& ew_Init2DArray(3, 3, 0);
		$this->nMins =& ew_Init2DArray(3, 3, 0);
	}

	// Check level break
	function ChkLvlBreak() {
		global $rptAssignmentScores;
		$this->bLvlBreak[1] = FALSE;
		$this->bLvlBreak[2] = FALSE;
		if ($this->lRecCnt == 0) { // Start Or End of Recordset
			$this->bLvlBreak[1] = TRUE;
			$this->bLvlBreak[2] = TRUE;
		} else {
			if (!ew_CompareValue($rptAssignmentScores->Surname->CurrentValue, $this->vGrps[0])) {
				$this->bLvlBreak[1] = TRUE;
				$this->bLvlBreak[2] = TRUE;
			}
			if (!ew_CompareValue($rptAssignmentScores->FirstName->CurrentValue, $this->vGrps[1])) {
				$this->bLvlBreak[2] = TRUE;
			}
		}
	}

	// Render row values based on field settings
	function RenderRow() {
		global $conn, $Security, $Language, $rptAssignmentScores;

		// Initialize URLs
		// Common render codes for all row types
		// FirstName

		$rptAssignmentScores->FirstName->CellCssStyle = ""; $rptAssignmentScores->FirstName->CellCssClass = "";
		$rptAssignmentScores->FirstName->CellAttrs = array(); $rptAssignmentScores->FirstName->ViewAttrs = array(); $rptAssignmentScores->FirstName->EditAttrs = array();

		// Surname
		$rptAssignmentScores->Surname->CellCssStyle = ""; $rptAssignmentScores->Surname->CellCssClass = "";
		$rptAssignmentScores->Surname->CellAttrs = array(); $rptAssignmentScores->Surname->ViewAttrs = array(); $rptAssignmentScores->Surname->EditAttrs = array();

		// RefNum
		$rptAssignmentScores->RefNum->CellCssStyle = ""; $rptAssignmentScores->RefNum->CellCssClass = "";
		$rptAssignmentScores->RefNum->CellAttrs = array(); $rptAssignmentScores->RefNum->ViewAttrs = array(); $rptAssignmentScores->RefNum->EditAttrs = array();

		// AssignmentScore
		$rptAssignmentScores->AssignmentScore->CellCssStyle = ""; $rptAssignmentScores->AssignmentScore->CellCssClass = "";
		$rptAssignmentScores->AssignmentScore->CellAttrs = array(); $rptAssignmentScores->AssignmentScore->ViewAttrs = array(); $rptAssignmentScores->AssignmentScore->EditAttrs = array();
		if ($rptAssignmentScores->RowType == EW_ROWTYPE_VIEW) { // View row

			// FirstName
			$rptAssignmentScores->FirstName->ViewValue = $rptAssignmentScores->FirstName->CurrentValue;
			$rptAssignmentScores->FirstName->CssStyle = "";
			$rptAssignmentScores->FirstName->CssClass = "";
			$rptAssignmentScores->FirstName->ViewCustomAttributes = "";

			// Surname
			$rptAssignmentScores->Surname->ViewValue = $rptAssignmentScores->Surname->CurrentValue;
			$rptAssignmentScores->Surname->CssStyle = "";
			$rptAssignmentScores->Surname->CssClass = "";
			$rptAssignmentScores->Surname->ViewCustomAttributes = "";

			// RefNum
			$rptAssignmentScores->RefNum->ViewValue = $rptAssignmentScores->RefNum->CurrentValue;
			$rptAssignmentScores->RefNum->CssStyle = "";
			$rptAssignmentScores->RefNum->CssClass = "";
			$rptAssignmentScores->RefNum->ViewCustomAttributes = "";

			// AssignmentScore
			$rptAssignmentScores->AssignmentScore->ViewValue = $rptAssignmentScores->AssignmentScore->CurrentValue;
			$rptAssignmentScores->AssignmentScore->CssStyle = "";
			$rptAssignmentScores->AssignmentScore->CssClass = "";
			$rptAssignmentScores->AssignmentScore->ViewCustomAttributes = "";

			// FirstName
			$rptAssignmentScores->FirstName->HrefValue = "";
			$rptAssignmentScores->FirstName->TooltipValue = "";

			// Surname
			$rptAssignmentScores->Surname->HrefValue = "";
			$rptAssignmentScores->Surname->TooltipValue = "";

			// RefNum
			$rptAssignmentScores->RefNum->HrefValue = "";
			$rptAssignmentScores->RefNum->TooltipValue = "";

			// AssignmentScore
			$rptAssignmentScores->AssignmentScore->HrefValue = "";
			$rptAssignmentScores->AssignmentScore->TooltipValue = "";
		}
	}

	// Page Load event
	function Page_Load() {

		//echo "Page Load";
	}

	// Page Unload event
	function Page_Unload() {

		//echo "Page Unload";
	}

	// Page Redirecting event
	function Page_Redirecting(&$url) {

		// Example:
		//$url = "your URL";

	}

	// Message Showing event
	function Message_Showing(&$msg) {

		// Example:
		//$msg = "your new message";

	}
}
?>