Your IP : 216.73.217.79


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

<?php

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

//
// Table class for cstSubmittedAssign
//
class ccstSubmittedAssign {
	var $TableVar = 'cstSubmittedAssign';
	var $TableName = 'cstSubmittedAssign';
	var $TableType = 'CUSTOMVIEW';
	var $RefNum;
	var $CCEAssignmentID;
	var $AssignmentName;
	var $FirstName;
	var $Surname;
	var $StudentNumber;
	var $CCEStudentAssigID;
	var $CCEStudentID;
	var $Completed;
	var $AssignmentFile1;
	var $AssignmentScore;
	var $ScoredBy;
	var $AssignmentFile2;
	var $AssignmentFile3;
	var $Comments;
	var $DateSubmitted;
	var $Passed;
	var $RulingCode;
	var $Remarks;
	var $FeedbackToSend;
	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 = "";
	var $CurrentAction; // Current action
	var $UpdateConflict; // Update conflict
	var $EventName; // Event name
	var $EventCancelled; // Event cancelled
	var $CancelMessage; // Cancel message

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

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

		// CCEAssignmentID
		$this->CCEAssignmentID = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_CCEAssignmentID', 'CCEAssignmentID', 'CCEStudentAssignments.CCEAssignmentID', 3, -1, FALSE, 'CCEStudentAssignments.CCEAssignmentID', FALSE);
		$this->CCEAssignmentID->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['CCEAssignmentID'] =& $this->CCEAssignmentID;

		// AssignmentName
		$this->AssignmentName = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_AssignmentName', 'AssignmentName', 'CCEAssignments.AssignmentName', 200, -1, FALSE, 'CCEAssignments.AssignmentName', FALSE);
		$this->fields['AssignmentName'] =& $this->AssignmentName;

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

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

		// StudentNumber
		$this->StudentNumber = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_StudentNumber', 'StudentNumber', 'CCEStudents.StudentNumber', 200, -1, FALSE, 'CCEStudents.StudentNumber', FALSE);
		$this->fields['StudentNumber'] =& $this->StudentNumber;

		// CCEStudentAssigID
		$this->CCEStudentAssigID = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_CCEStudentAssigID', 'CCEStudentAssigID', 'CCEStudentAssignments.CCEStudentAssigID', 3, -1, FALSE, 'CCEStudentAssignments.CCEStudentAssigID', FALSE);
		$this->CCEStudentAssigID->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['CCEStudentAssigID'] =& $this->CCEStudentAssigID;

		// CCEStudentID
		$this->CCEStudentID = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_CCEStudentID', 'CCEStudentID', 'CCEStudentAssignments.CCEStudentID', 3, -1, FALSE, 'CCEStudentAssignments.CCEStudentID', FALSE);
		$this->CCEStudentID->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['CCEStudentID'] =& $this->CCEStudentID;

		// Completed
		$this->Completed = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_Completed', 'Completed', 'CCEStudentAssignments.Completed', 16, -1, FALSE, 'CCEStudentAssignments.Completed', FALSE);
		$this->Completed->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['Completed'] =& $this->Completed;

		// AssignmentFile1
		$this->AssignmentFile1 = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_AssignmentFile1', 'AssignmentFile1', 'CCEStudentAssignments.AssignmentFile1', 200, -1, TRUE, 'CCEStudentAssignments.AssignmentFile1', FALSE);
		$this->AssignmentFile1->UploadPath = "assignmentsupload";
		$this->fields['AssignmentFile1'] =& $this->AssignmentFile1;

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

		// ScoredBy
		$this->ScoredBy = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_ScoredBy', 'ScoredBy', 'CCEStudentAssignments.ScoredBy', 3, -1, FALSE, 'CCEStudentAssignments.ScoredBy', FALSE);
		$this->ScoredBy->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['ScoredBy'] =& $this->ScoredBy;

		// AssignmentFile2
		$this->AssignmentFile2 = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_AssignmentFile2', 'AssignmentFile2', 'CCEStudentAssignments.AssignmentFile2', 200, -1, TRUE, 'CCEStudentAssignments.AssignmentFile2', FALSE);
		$this->AssignmentFile2->UploadPath = "assignmentsupload";
		$this->fields['AssignmentFile2'] =& $this->AssignmentFile2;

		// AssignmentFile3
		$this->AssignmentFile3 = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_AssignmentFile3', 'AssignmentFile3', 'CCEStudentAssignments.AssignmentFile3', 200, -1, TRUE, 'CCEStudentAssignments.AssignmentFile3', FALSE);
		$this->AssignmentFile3->UploadPath = "assignmentsupload";
		$this->fields['AssignmentFile3'] =& $this->AssignmentFile3;

		// Comments
		$this->Comments = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_Comments', 'Comments', 'CCEStudentAssignments.Comments', 201, -1, FALSE, 'CCEStudentAssignments.Comments', FALSE);
		$this->fields['Comments'] =& $this->Comments;

		// DateSubmitted
		$this->DateSubmitted = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_DateSubmitted', 'DateSubmitted', 'CCEStudentAssignments.DateSubmitted', 135, 5, FALSE, 'CCEStudentAssignments.DateSubmitted', FALSE);
		$this->DateSubmitted->FldDefaultErrMsg = str_replace("%s", "/", $Language->Phrase("IncorrectDateYMD"));
		$this->fields['DateSubmitted'] =& $this->DateSubmitted;

		// Passed
		$this->Passed = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_Passed', 'Passed', 'CCEStudentAssignments.Passed', 16, -1, FALSE, 'CCEStudentAssignments.Passed', FALSE);
		$this->Passed->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['Passed'] =& $this->Passed;

		// RulingCode
		$this->RulingCode = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_RulingCode', 'RulingCode', 'CCEStudentAssignments.RulingCode', 200, -1, FALSE, 'CCEStudentAssignments.RulingCode', FALSE);
		$this->fields['RulingCode'] =& $this->RulingCode;

		// Remarks
		$this->Remarks = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_Remarks', 'Remarks', 'CCEStudentAssignments.Remarks', 201, -1, FALSE, 'CCEStudentAssignments.Remarks', FALSE);
		$this->fields['Remarks'] =& $this->Remarks;

		// FeedbackToSend
		$this->FeedbackToSend = new cField('cstSubmittedAssign', 'cstSubmittedAssign', 'x_FeedbackToSend', 'FeedbackToSend', 'If(CCEStudentAssignments.LastFeedback Is Not Null And CCEStudentAssignments.LastFeedback <> \'\', 1, 0)', 3, -1, FALSE, 'If(CCEStudentAssignments.LastFeedback Is Not Null And CCEStudentAssignments.LastFeedback <> \'\', 1, 0)', FALSE);
		$this->FeedbackToSend->FldDefaultErrMsg = $Language->Phrase("IncorrectInteger");
		$this->fields['FeedbackToSend'] =& $this->FeedbackToSend;
	}

	// 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;
	}

	// Export return page
	function ExportReturnUrl() {
		$url = @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_EXPORT_RETURN_URL];
		return ($url <> "") ? $url : ew_CurrentPage();
	}

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

	// Records per page
	function getRecordsPerPage() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_REC_PER_PAGE];
	}

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

	// Start record number
	function getStartRecordNumber() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_START_REC];
	}

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

	// Search highlight name
	function HighlightName() {
		return "cstSubmittedAssign_Highlight";
	}

	// Advanced search
	function getAdvancedSearch($fld) {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ADVANCED_SEARCH . "_" . $fld];
	}

	function setAdvancedSearch($fld, $v) {
		if (@$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ADVANCED_SEARCH . "_" . $fld] <> $v) {
			$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ADVANCED_SEARCH . "_" . $fld] = $v;
		}
	}

	// Basic search keyword
	function getSessionBasicSearchKeyword() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_BASIC_SEARCH];
	}

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

	// Basic search type
	function getSessionBasicSearchType() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_BASIC_SEARCH_TYPE];
	}

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

	// Search WHERE clause
	function getSearchWhere() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_SEARCH_WHERE];
	}

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

	// Multiple column sort
	function UpdateSort(&$ofld, $ctrl) {
		if ($this->CurrentOrder == $ofld->FldName) {
			$sSortField = $ofld->FldExpression;
			$sLastSort = $ofld->getSort();
			if ($this->CurrentOrderType == "ASC" || $this->CurrentOrderType == "DESC") {
				$sThisSort = $this->CurrentOrderType;
			} else {
				$sThisSort = ($sLastSort == "ASC") ? "DESC" : "ASC";
			}
			$ofld->setSort($sThisSort);
			if ($ctrl) {
				$sOrderBy = $this->getSessionOrderBy();
				if (strpos($sOrderBy, $sSortField . " " . $sLastSort) !== FALSE) {
					$sOrderBy = str_replace($sSortField . " " . $sLastSort, $sSortField . " " . $sThisSort, $sOrderBy);
				} else {
					if ($sOrderBy <> "") $sOrderBy .= ", ";
					$sOrderBy .= $sSortField . " " . $sThisSort;
				}
				$this->setSessionOrderBy($sOrderBy); // Save to Session
			} else {
				$this->setSessionOrderBy($sSortField . " " . $sThisSort); // Save to Session
			}
		} else {
			if (!$ctrl) $ofld->setSort("");
		}
	}

	// Session WHERE clause
	function getSessionWhere() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_WHERE];
	}

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

	// Session ORDER BY
	function getSessionOrderBy() {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_ORDER_BY];
	}

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

	// Session key
	function getKey($fld) {
		return @$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_KEY . "_" . $fld];
	}

	function setKey($fld, $v) {
		$_SESSION[EW_PROJECT_NAME . "_" . $this->TableVar . "_" . EW_TABLE_KEY . "_" . $fld] = $v;
	}

	// Table level SQL
	function SqlFrom() { // From
		return "CCEAssignments Inner Join CCEStudentAssignments On CCEAssignments.CCEAssignmentID = CCEStudentAssignments.CCEAssignmentID Inner Join CCEStudents On CCEStudents.CCEStudentID = CCEStudentAssignments.CCEStudentID";
	}

	function SqlSelect() { // Select
		return "SELECT CCEAssignments.RefNum, CCEAssignments.AssignmentName, CCEStudents.FirstName, CCEStudents.Surname, CCEStudents.StudentNumber, CCEStudentAssignments.CCEStudentAssigID, CCEStudentAssignments.CCEStudentID, CCEStudentAssignments.CCEAssignmentID, CCEStudentAssignments.Completed, CCEStudentAssignments.Passed, CCEStudentAssignments.AssignmentFile1, CCEStudentAssignments.AssignmentScore, CCEStudentAssignments.ScoredBy, CCEStudentAssignments.AssignmentFile2, CCEStudentAssignments.AssignmentFile3, CCEStudentAssignments.Comments, CCEStudentAssignments.DateSubmitted, CCEStudentAssignments.RulingCode, If(CCEStudentAssignments.LastFeedback Is Not Null And CCEStudentAssignments.LastFeedback <> '', 1, 0) As FeedbackToSend, CCEStudentAssignments.Remarks FROM " . $this->SqlFrom();
	}

	function SqlWhere() { // Where
		$sWhere = "";
		$this->TableFilter = "CCEAssignments.Archived = 0 AND CCEStudents.Archived=0";
		if ($this->TableFilter <> "") {
			if ($sWhere <> "") $sWhere = "(" . $sWhere . ") AND (";
			$sWhere .= "(" . $this->TableFilter . ")";
		}
		return $sWhere;
	}

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

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

	function SqlOrderBy() { // Order By
		return "CCEStudentAssignments.DateSubmitted, CCEStudentAssignments.CCEStudentAssigID Desc";
	}

	// 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;
	}

	// Get SQL
	function GetSQL($where, $orderby) {
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$where, $orderby);
	}

	// Table SQL
	function SQL() {
		$sFilter = $this->CurrentFilter;
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(),
			$this->SqlGroupBy(), $this->SqlHaving(), $this->SqlOrderBy(),
			$sFilter, $sSort);
	}

	// Table SQL with List page filter
	function SelectSQL() {
		$sFilter = $this->getSessionWhere();
		if ($this->CurrentFilter <> "") {
			if ($sFilter <> "") $sFilter = "(" . $sFilter . ") AND ";
			$sFilter .= "(" . $this->CurrentFilter . ")";
		}
		$sFilter = $this->ApplyUserIDFilters($sFilter);
		$sSort = $this->getSessionOrderBy();
		return ew_BuildSelectSql($this->SqlSelect(), $this->SqlWhere(), $this->SqlGroupBy(),
			$this->SqlHaving(), $this->SqlOrderBy(), $sFilter, $sSort);
	}

	// Try to get record count
	function TryGetRecordCount($sSql) {
		global $conn;
		$cnt = -1;
		if ($this->TableType == 'TABLE' || $this->TableType == 'VIEW') {
			$sSql = "SELECT COUNT(*) FROM" . substr($sSql, 13);
		} else {
			$sSql = "SELECT COUNT(*) FROM (" . $sSql . ") EW_COUNT_TABLE";
		}
		if ($rs = $conn->Execute($sSql)) {
			if (!$rs->EOF && $rs->FieldCount() > 0) {
				$cnt = $rs->fields[0];
				$rs->Close();
			}
		}
		return intval($cnt);
	}

	// Get record count based on filter (for detail record count in master table pages)
	function LoadRecordCount($sFilter) {
		$origFilter = $this->CurrentFilter;
		$this->CurrentFilter = $sFilter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$sSql = $this->SQL();
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $this->LoadRs($this->CurrentFilter)) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// Get record count (for current List page)
	function SelectRecordCount() {
		global $conn;
		$origFilter = $this->CurrentFilter;
		$this->Recordset_Selecting($this->CurrentFilter);
		$sSql = $this->SelectSQL();
		$cnt = $this->TryGetRecordCount($sSql);
		if ($cnt == -1) {
			if ($rs = $conn->Execute($this->SelectSQL())) {
				$cnt = $rs->RecordCount();
				$rs->Close();
			}
		}
		$this->CurrentFilter = $origFilter;
		return intval($cnt);
	}

	// INSERT statement
	function InsertSQL(&$rs) {
		global $conn;
		$names = "";
		$values = "";
		foreach ($rs as $name => $value) {
			$names .= $this->fields[$name]->FldExpression . ",";
			$values .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		if (substr($names, -1) == ",") $names = substr($names, 0, strlen($names)-1);
		if (substr($values, -1) == ",") $values = substr($values, 0, strlen($values)-1);
		return "INSERT INTO CCEAssignments Inner Join CCEStudentAssignments On CCEAssignments.CCEAssignmentID = CCEStudentAssignments.CCEAssignmentID Inner Join CCEStudents On CCEStudents.CCEStudentID = CCEStudentAssignments.CCEStudentID ($names) VALUES ($values)";
	}

	// UPDATE statement
	function UpdateSQL(&$rs) {
		global $conn;
		$SQL = "UPDATE CCEAssignments Inner Join CCEStudentAssignments On CCEAssignments.CCEAssignmentID = CCEStudentAssignments.CCEAssignmentID Inner Join CCEStudents On CCEStudents.CCEStudentID = CCEStudentAssignments.CCEStudentID SET ";
		foreach ($rs as $name => $value) {
			$SQL .= $this->fields[$name]->FldExpression . "=";
			$SQL .= ew_QuotedValue($value, $this->fields[$name]->FldDataType) . ",";
		}
		if (substr($SQL, -1) == ",") $SQL = substr($SQL, 0, strlen($SQL)-1);
		if ($this->CurrentFilter <> "")	$SQL .= " WHERE " . $this->CurrentFilter;
		return $SQL;
	}

	// DELETE statement
	function DeleteSQL(&$rs) {
		$SQL = "DELETE FROM CCEAssignments Inner Join CCEStudentAssignments On CCEAssignments.CCEAssignmentID = CCEStudentAssignments.CCEAssignmentID Inner Join CCEStudents On CCEStudents.CCEStudentID = CCEStudentAssignments.CCEStudentID WHERE ";
		if (substr($SQL, -5) == " AND ") $SQL = substr($SQL, 0, strlen($SQL)-5);
		if ($this->CurrentFilter <> "")	$SQL .= " AND " . $this->CurrentFilter;
		return $SQL;
	}

	// Key filter WHERE clause
	function SqlKeyFilter() {
		return "";
	}

	// Key filter
	function KeyFilter() {
		$sKeyFilter = $this->SqlKeyFilter();
		return $sKeyFilter;
	}

	// 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 "cstSubmittedAssignlist.php";
		}
	}

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

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

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

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

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

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

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

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

	// Delete URL
	function DeleteUrl() {
		return $this->KeyUrl("cstSubmittedAssigndelete.php", $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=cstSubmittedAssign" : "";
		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->RefNum->setDbValue($rs->fields('RefNum'));
		$this->CCEAssignmentID->setDbValue($rs->fields('CCEAssignmentID'));
		$this->AssignmentName->setDbValue($rs->fields('AssignmentName'));
		$this->FirstName->setDbValue($rs->fields('FirstName'));
		$this->Surname->setDbValue($rs->fields('Surname'));
		$this->StudentNumber->setDbValue($rs->fields('StudentNumber'));
		$this->CCEStudentAssigID->setDbValue($rs->fields('CCEStudentAssigID'));
		$this->CCEStudentID->setDbValue($rs->fields('CCEStudentID'));
		$this->Completed->setDbValue($rs->fields('Completed'));
		$this->AssignmentFile1->Upload->DbValue = $rs->fields('AssignmentFile1');
		$this->AssignmentScore->setDbValue($rs->fields('AssignmentScore'));
		$this->ScoredBy->setDbValue($rs->fields('ScoredBy'));
		$this->AssignmentFile2->Upload->DbValue = $rs->fields('AssignmentFile2');
		$this->AssignmentFile3->Upload->DbValue = $rs->fields('AssignmentFile3');
		$this->Comments->setDbValue($rs->fields('Comments'));
		$this->DateSubmitted->setDbValue($rs->fields('DateSubmitted'));
		$this->Passed->setDbValue($rs->fields('Passed'));
		$this->RulingCode->setDbValue($rs->fields('RulingCode'));
		$this->Remarks->setDbValue($rs->fields('Remarks'));
		$this->FeedbackToSend->setDbValue($rs->fields('FeedbackToSend'));
	}

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

		// Call Row Rendering event
		$this->Row_Rendering();

   // Common render codes
		// RefNum

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

		// AssignmentName
		$this->AssignmentName->CellCssStyle = ""; $this->AssignmentName->CellCssClass = "";
		$this->AssignmentName->CellAttrs = array(); $this->AssignmentName->ViewAttrs = array(); $this->AssignmentName->EditAttrs = array();

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

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

		// DateSubmitted
		$this->DateSubmitted->CellCssStyle = ""; $this->DateSubmitted->CellCssClass = "";
		$this->DateSubmitted->CellAttrs = array(); $this->DateSubmitted->ViewAttrs = array(); $this->DateSubmitted->EditAttrs = array();

		// Passed
		$this->Passed->CellCssStyle = ""; $this->Passed->CellCssClass = "";
		$this->Passed->CellAttrs = array(); $this->Passed->ViewAttrs = array(); $this->Passed->EditAttrs = array();

		// RulingCode
		$this->RulingCode->CellCssStyle = ""; $this->RulingCode->CellCssClass = "";
		$this->RulingCode->CellAttrs = array(); $this->RulingCode->ViewAttrs = array(); $this->RulingCode->EditAttrs = array();

		// Remarks
		$this->Remarks->CellCssStyle = "white-space: nowrap;"; $this->Remarks->CellCssClass = "";
		$this->Remarks->CellAttrs = array(); $this->Remarks->ViewAttrs = array(); $this->Remarks->EditAttrs = array();

		// FeedbackToSend
		$this->FeedbackToSend->CellCssStyle = ""; $this->FeedbackToSend->CellCssClass = "";
		$this->FeedbackToSend->CellAttrs = array(); $this->FeedbackToSend->ViewAttrs = array(); $this->FeedbackToSend->EditAttrs = array();

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

		// AssignmentName
		$this->AssignmentName->ViewValue = $this->AssignmentName->CurrentValue;
		$this->AssignmentName->CssStyle = "";
		$this->AssignmentName->CssClass = "";
		$this->AssignmentName->ViewCustomAttributes = "";

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

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

		// DateSubmitted
		$this->DateSubmitted->ViewValue = $this->DateSubmitted->CurrentValue;
		$this->DateSubmitted->ViewValue = ew_FormatDateTime($this->DateSubmitted->ViewValue, 5);
		$this->DateSubmitted->CssStyle = "";
		$this->DateSubmitted->CssClass = "";
		$this->DateSubmitted->ViewCustomAttributes = "";

		// Passed
		if (strval($this->Passed->CurrentValue) <> "") {
			switch ($this->Passed->CurrentValue) {
				case "1":
					$this->Passed->ViewValue = "Achieved";
					break;
				case "2":
					$this->Passed->ViewValue = "Not Yet Achieved";
					break;
				case "0":
					$this->Passed->ViewValue = "Not Yet Evaluated";
					break;
				case "3":
					$this->Passed->ViewValue = "Added to PoE";
					break;
				default:
					$this->Passed->ViewValue = $this->Passed->CurrentValue;
			}
		} else {
			$this->Passed->ViewValue = NULL;
		}
		$this->Passed->CssStyle = "";
		$this->Passed->CssClass = "";
		$this->Passed->ViewCustomAttributes = "";

		// RulingCode
		if (strval($this->RulingCode->CurrentValue) <> "") {
			$sFilterWrk = "`RulingCode` = '" . ew_AdjustSql($this->RulingCode->CurrentValue) . "'";
		$sSqlWrk = "SELECT `Ruling` FROM `CCERulingCodes`";
		$sWhereWrk = "";
		if ($sFilterWrk <> "") {
			if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
			$sWhereWrk .= "(" . $sFilterWrk . ")";
		}
		if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$rswrk = $conn->Execute($sSqlWrk);
			if ($rswrk && !$rswrk->EOF) { // Lookup values found
				$this->RulingCode->ViewValue = $rswrk->fields('Ruling');
				$rswrk->Close();
			} else {
				$this->RulingCode->ViewValue = $this->RulingCode->CurrentValue;
			}
		} else {
			$this->RulingCode->ViewValue = NULL;
		}
		$this->RulingCode->CssStyle = "";
		$this->RulingCode->CssClass = "";
		$this->RulingCode->ViewCustomAttributes = "";

		// Remarks
		$this->Remarks->ViewValue = $this->Remarks->CurrentValue;
		$this->Remarks->CssStyle = "";
		$this->Remarks->CssClass = "";
		$this->Remarks->ViewCustomAttributes = "";

		// FeedbackToSend
		$this->FeedbackToSend->ViewValue = $this->FeedbackToSend->CurrentValue;
		$this->FeedbackToSend->CssStyle = "font-weight:bold;";
		$this->FeedbackToSend->CssClass = "";
		$this->FeedbackToSend->ViewCustomAttributes = "";

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

		// AssignmentName
		$this->AssignmentName->HrefValue = "";
		$this->AssignmentName->TooltipValue = "";

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

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

		// DateSubmitted
		$this->DateSubmitted->HrefValue = "";
		$this->DateSubmitted->TooltipValue = "";

		// Passed
		$this->Passed->HrefValue = "";
		$this->Passed->TooltipValue = "";

		// RulingCode
		$this->RulingCode->HrefValue = "";
		$this->RulingCode->TooltipValue = "";

		// Remarks
		$this->Remarks->HrefValue = "";
		$this->Remarks->TooltipValue = "";

		// FeedbackToSend
		$this->FeedbackToSend->HrefValue = "";
		$this->FeedbackToSend->TooltipValue = "";

		// Call Row Rendered event
		$this->Row_Rendered();
	}

	// 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];
	}

	// Table level events
	// Recordset Selecting event
	function Recordset_Selecting(&$filter) {

		// Enter your code here	
	}

	// Recordset Selected event
	function Recordset_Selected(&$rs) {

		//echo "Recordset Selected";
	}

	// Recordset Search Validated event
	function Recordset_SearchValidated() {

		// Example:
		//$this->MyField1->AdvancedSearch->SearchValue = "your search criteria"; // Search value

	}

	// Recordset Searching event
	function Recordset_Searching(&$filter) {

		// Enter your code here	
	}

	// Row_Selecting event
	function Row_Selecting(&$filter) {

		// Enter your code here	
	}

	// Row Selected event
	function Row_Selected(&$rs) {

		//echo "Row Selected";
	}

	// Row Rendering event
	function Row_Rendering() {

		// Enter your code here	
	}

		// Row Rendered event
function Row_Rendered() {
    // To view properties of field class, use:
    //var_dump($this-><FieldName>); 
global $conni;                             
$fontcolor="; color:black";
$this->RowAttrs["style"] = "background-color:#FFFFFF".$fontcolor; 

if ($this->Passed->DbValue==2) { 
     $this->RowAttrs["style"] = "background-color:#FFCC99".$fontcolor; 
} elseif (($this->Passed->DbValue==1) && ($this->RulingCode->DbValue=="NE")) { 
      $this->RowAttrs["style"] = "background-color:#FFFF99".$fontcolor; 
}

$sql = "SELECT * FROM CCEStudentAssignments WHERE CCEStudentID=".$this->CCEStudentID->DbValue." AND CCEAssignmentID=".$this->CCEAssignmentID->DbValue." AND CCEStudentAssigID < ".$this->CCEStudentAssigID->DbValue." ORDER BY CCEStudentAssigID DESC";
$rec=mysqli_query($conni,$sql);
$bResubmission = false;
if ($row=mysqli_fetch_assoc($rec)) $bResubmission = true;
if ($bResubmission) {
    if ($row["Passed"] ==1) {
        $this->RowAttrs["style"] = "background-color: #e0bee0".$fontcolor;
    } else {
        $this->RowAttrs["style"] = "background-color: #99ff99".$fontcolor;
    }
    $this->AssignmentName->DbValue.=" (Resubmission)";     
}                                      
  
}                                                                   

	// Row Inserting event
	function Row_Inserting(&$rs) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Inserted event
	function Row_Inserted(&$rs) {

		//echo "Row Inserted"
	}

	// Row Updating event
	function Row_Updating(&$rsold, &$rsnew) {

		// Enter your code here
		// To cancel, set return value to FALSE

		return TRUE;
	}

	// Row Updated event
	function Row_Updated(&$rsold, &$rsnew) {

		//echo "Row Updated";
	}

	// Row Update Conflict event
	function Row_UpdateConflict(&$rsold, &$rsnew) {

		// Enter your code here
		// To ignore conflict, set return value to FALSE

		return TRUE;
	}

	// Row Deleting event
	function Row_Deleting(&$rs) {

		// Enter your code here
		// To cancel, set return value to False

		return TRUE;
	}

	// Row Deleted event
	function Row_Deleted(&$rs) {

		//echo "Row Deleted";
	}

	// Email Sending event
	function Email_Sending(&$Email, &$Args) {

		//var_dump($Email); var_dump($Args); exit();
		return TRUE;
	}
}
?>