Your IP : 216.73.217.79


Current Path : /var/www/cesa.co.za/cceadmin/
Upload File :
Current File : /var/www/cesa.co.za/cceadmin/CCEPaymentsadd.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 include "CCEPaymentsinfo.php" ?>
<?php include "CCECourseSchedulesinfo.php" ?>
<?php include "CCEStudentsinfo.php" ?>
<?php include "CCEUsersinfo.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
$CCEPayments_add = new cCCEPayments_add();
$Page =& $CCEPayments_add;

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

// Page main
$CCEPayments_add->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--

// Create page object
var CCEPayments_add = new ew_Page("CCEPayments_add");

// page properties
CCEPayments_add.PageID = "add"; // page ID
CCEPayments_add.FormID = "fCCEPaymentsadd"; // form ID
var EW_PAGE_ID = CCEPayments_add.PageID; // for backward compatibility

// extend page with ValidateForm function
CCEPayments_add.ValidateForm = function(fobj) {
	ew_PostAutoSuggest(fobj);
	if (!this.ValidateRequired)
		return true; // ignore validation
	if (fobj.a_confirm && fobj.a_confirm.value == "F")
		return true;
	var i, elm, aelm, infix;
	var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
	for (i=0; i<rowcnt; i++) {
		infix = (fobj.key_count) ? String(i+1) : "";
		elm = fobj.elements["x" + infix + "_StudentID"];
		if (elm && !ew_HasValue(elm))
			return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CCEPayments->StudentID->FldCaption()) ?>");
		elm = fobj.elements["x" + infix + "_AmountDue"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->AmountDue->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_AmountPaid"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->AmountPaid->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_Refund"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->Refund->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_AmountOStd"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->AmountOStd->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_DatePaid"];
		if (elm && !ew_CheckDate(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->DatePaid->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_InvoiceDate"];
		if (elm && !ew_CheckDate(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->InvoiceDate->FldErrMsg()) ?>");
		elm = fobj.elements["x" + infix + "_AmountDep"];
		if (elm && !ew_CheckNumber(elm.value))
			return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEPayments->AmountDep->FldErrMsg()) ?>");

		// Call Form Custom Validate event
		if (!this.Form_CustomValidate(fobj)) return false;
	}
	return true;
}

// extend page with Form_CustomValidate function
CCEPayments_add.Form_CustomValidate =  
 function(fobj) { // DO NOT CHANGE THIS LINE!

 	// Your custom validation code here, return false if invalid. 
 	return true;
 }
<?php if (EW_CLIENT_VALIDATE) { ?>
CCEPayments_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEPayments_add.ValidateRequired = false; // no JavaScript validation
<?php } ?>

//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];

//-->
</script>
<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>
<p><span class="phpmaker"><?php echo $Language->Phrase("Add") ?>&nbsp;<?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCEPayments->TableCaption() ?><br><br>
<a href="<?php echo $CCEPayments->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
	echo ew_DebugMsg();
$CCEPayments_add->ShowMessage();
?>
<form name="fCCEPaymentsadd" id="fCCEPaymentsadd" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCEPayments_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CCEPayments">
<input type="hidden" name="a_add" id="a_add" value="A">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($CCEPayments->CourseID->Visible) { // CourseID ?>
	<tr<?php echo $CCEPayments->CourseID->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->CourseID->FldCaption() ?></td>
		<td<?php echo $CCEPayments->CourseID->CellAttributes() ?>><span id="el_CourseID">
<?php if ($CCEPayments->CourseID->getSessionValue() <> "") { ?>
<div<?php echo $CCEPayments->CourseID->ViewAttributes() ?>><?php echo $CCEPayments->CourseID->ViewValue ?></div>
<input type="hidden" id="x_CourseID" name="x_CourseID" value="<?php echo ew_HtmlEncode($CCEPayments->CourseID->CurrentValue) ?>">
<?php } else { ?>
<select id="x_CourseID" name="x_CourseID" title="<?php echo $CCEPayments->CourseID->FldTitle() ?>"<?php echo $CCEPayments->CourseID->EditAttributes() ?>>
<?php
if (is_array($CCEPayments->CourseID->EditValue)) {
	$arwrk = $CCEPayments->CourseID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEPayments->CourseID->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php if ($arwrk[$rowcntwrk][2] <> "") { ?>
<?php echo ew_ValueSeparator($rowcntwrk) ?><?php echo $arwrk[$rowcntwrk][2] ?>
<?php } ?>
</option>
<?php
	}
}
?>
</select>
<?php } ?>
</span><?php echo $CCEPayments->CourseID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->StudentID->Visible) { // StudentID ?>
	<tr<?php echo $CCEPayments->StudentID->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->StudentID->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
		<td<?php echo $CCEPayments->StudentID->CellAttributes() ?>><span id="el_StudentID">
<?php if ($CCEPayments->StudentID->getSessionValue() <> "") { ?>
<div<?php echo $CCEPayments->StudentID->ViewAttributes() ?>><?php echo $CCEPayments->StudentID->ViewValue ?></div>
<input type="hidden" id="x_StudentID" name="x_StudentID" value="<?php echo ew_HtmlEncode($CCEPayments->StudentID->CurrentValue) ?>">
<?php } else { ?>
<select id="x_StudentID" name="x_StudentID" title="<?php echo $CCEPayments->StudentID->FldTitle() ?>"<?php echo $CCEPayments->StudentID->EditAttributes() ?>>
<?php
if (is_array($CCEPayments->StudentID->EditValue)) {
	$arwrk = $CCEPayments->StudentID->EditValue;
	$rowswrk = count($arwrk);
	$emptywrk = TRUE;
	for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
		$selwrk = (strval($CCEPayments->StudentID->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected=\"selected\"" : "";
		if ($selwrk <> "") $emptywrk = FALSE;
?>
<option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
<?php echo $arwrk[$rowcntwrk][1] ?>
<?php if ($arwrk[$rowcntwrk][2] <> "") { ?>
<?php echo ew_ValueSeparator($rowcntwrk) ?><?php echo $arwrk[$rowcntwrk][2] ?>
<?php } ?>
</option>
<?php
	}
}
?>
</select>
<?php } ?>
</span><?php echo $CCEPayments->StudentID->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->AmountDue->Visible) { // AmountDue ?>
	<tr<?php echo $CCEPayments->AmountDue->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->AmountDue->FldCaption() ?></td>
		<td<?php echo $CCEPayments->AmountDue->CellAttributes() ?>><span id="el_AmountDue">
<input type="text" name="x_AmountDue" id="x_AmountDue" title="<?php echo $CCEPayments->AmountDue->FldTitle() ?>" size="30" value="<?php echo $CCEPayments->AmountDue->EditValue ?>"<?php echo $CCEPayments->AmountDue->EditAttributes() ?>>
</span><?php echo $CCEPayments->AmountDue->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->AmountPaid->Visible) { // AmountPaid ?>
	<tr<?php echo $CCEPayments->AmountPaid->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->AmountPaid->FldCaption() ?></td>
		<td<?php echo $CCEPayments->AmountPaid->CellAttributes() ?>><span id="el_AmountPaid">
<input type="text" name="x_AmountPaid" id="x_AmountPaid" title="<?php echo $CCEPayments->AmountPaid->FldTitle() ?>" size="30" value="<?php echo $CCEPayments->AmountPaid->EditValue ?>"<?php echo $CCEPayments->AmountPaid->EditAttributes() ?>>
</span><?php echo $CCEPayments->AmountPaid->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->Refund->Visible) { // Refund ?>
	<tr<?php echo $CCEPayments->Refund->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->Refund->FldCaption() ?></td>
		<td<?php echo $CCEPayments->Refund->CellAttributes() ?>><span id="el_Refund">
<input type="text" name="x_Refund" id="x_Refund" title="<?php echo $CCEPayments->Refund->FldTitle() ?>" size="30" value="<?php echo $CCEPayments->Refund->EditValue ?>"<?php echo $CCEPayments->Refund->EditAttributes() ?>>
</span><?php echo $CCEPayments->Refund->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->AmountOStd->Visible) { // AmountOStd ?>
	<tr<?php echo $CCEPayments->AmountOStd->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->AmountOStd->FldCaption() ?></td>
		<td<?php echo $CCEPayments->AmountOStd->CellAttributes() ?>><span id="el_AmountOStd">
<input type="text" name="x_AmountOStd" id="x_AmountOStd" title="<?php echo $CCEPayments->AmountOStd->FldTitle() ?>" size="30" value="<?php echo $CCEPayments->AmountOStd->EditValue ?>"<?php echo $CCEPayments->AmountOStd->EditAttributes() ?>>
</span><?php echo $CCEPayments->AmountOStd->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->DatePaid->Visible) { // DatePaid ?>
	<tr<?php echo $CCEPayments->DatePaid->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->DatePaid->FldCaption() ?></td>
		<td<?php echo $CCEPayments->DatePaid->CellAttributes() ?>><span id="el_DatePaid">
<input type="text" name="x_DatePaid" id="x_DatePaid" title="<?php echo $CCEPayments->DatePaid->FldTitle() ?>" value="<?php echo $CCEPayments->DatePaid->EditValue ?>"<?php echo $CCEPayments->DatePaid->EditAttributes() ?>>
&nbsp;<img src="images/calendar.png" id="cal_x_DatePaid" name="cal_x_DatePaid" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "x_DatePaid", // input field id
	ifFormat: "%Y/%m/%d", // date format
	button: "cal_x_DatePaid" // button id
});
</script>
</span><?php echo $CCEPayments->DatePaid->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->Method->Visible) { // Method ?>
	<tr<?php echo $CCEPayments->Method->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->Method->FldCaption() ?></td>
		<td<?php echo $CCEPayments->Method->CellAttributes() ?>><span id="el_Method">
<input type="text" name="x_Method" id="x_Method" title="<?php echo $CCEPayments->Method->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEPayments->Method->EditValue ?>"<?php echo $CCEPayments->Method->EditAttributes() ?>>
</span><?php echo $CCEPayments->Method->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->Reference->Visible) { // Reference ?>
	<tr<?php echo $CCEPayments->Reference->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->Reference->FldCaption() ?></td>
		<td<?php echo $CCEPayments->Reference->CellAttributes() ?>><span id="el_Reference">
<input type="text" name="x_Reference" id="x_Reference" title="<?php echo $CCEPayments->Reference->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEPayments->Reference->EditValue ?>"<?php echo $CCEPayments->Reference->EditAttributes() ?>>
</span><?php echo $CCEPayments->Reference->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->AccountNo->Visible) { // AccountNo ?>
	<tr<?php echo $CCEPayments->AccountNo->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->AccountNo->FldCaption() ?></td>
		<td<?php echo $CCEPayments->AccountNo->CellAttributes() ?>><span id="el_AccountNo">
<input type="text" name="x_AccountNo" id="x_AccountNo" title="<?php echo $CCEPayments->AccountNo->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $CCEPayments->AccountNo->EditValue ?>"<?php echo $CCEPayments->AccountNo->EditAttributes() ?>>
</span><?php echo $CCEPayments->AccountNo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->InvoiceDate->Visible) { // InvoiceDate ?>
	<tr<?php echo $CCEPayments->InvoiceDate->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->InvoiceDate->FldCaption() ?></td>
		<td<?php echo $CCEPayments->InvoiceDate->CellAttributes() ?>><span id="el_InvoiceDate">
<input type="text" name="x_InvoiceDate" id="x_InvoiceDate" title="<?php echo $CCEPayments->InvoiceDate->FldTitle() ?>" value="<?php echo $CCEPayments->InvoiceDate->EditValue ?>"<?php echo $CCEPayments->InvoiceDate->EditAttributes() ?>>
&nbsp;<img src="images/calendar.png" id="cal_x_InvoiceDate" name="cal_x_InvoiceDate" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
	inputField: "x_InvoiceDate", // input field id
	ifFormat: "%Y/%m/%d", // date format
	button: "cal_x_InvoiceDate" // button id
});
</script>
</span><?php echo $CCEPayments->InvoiceDate->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->InvoiceNo->Visible) { // InvoiceNo ?>
	<tr<?php echo $CCEPayments->InvoiceNo->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->InvoiceNo->FldCaption() ?></td>
		<td<?php echo $CCEPayments->InvoiceNo->CellAttributes() ?>><span id="el_InvoiceNo">
<input type="text" name="x_InvoiceNo" id="x_InvoiceNo" title="<?php echo $CCEPayments->InvoiceNo->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $CCEPayments->InvoiceNo->EditValue ?>"<?php echo $CCEPayments->InvoiceNo->EditAttributes() ?>>
</span><?php echo $CCEPayments->InvoiceNo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->StockCode->Visible) { // StockCode ?>
	<tr<?php echo $CCEPayments->StockCode->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->StockCode->FldCaption() ?></td>
		<td<?php echo $CCEPayments->StockCode->CellAttributes() ?>><span id="el_StockCode">
<input type="text" name="x_StockCode" id="x_StockCode" title="<?php echo $CCEPayments->StockCode->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $CCEPayments->StockCode->EditValue ?>"<?php echo $CCEPayments->StockCode->EditAttributes() ?>>
</span><?php echo $CCEPayments->StockCode->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->ReceiptNo->Visible) { // ReceiptNo ?>
	<tr<?php echo $CCEPayments->ReceiptNo->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->ReceiptNo->FldCaption() ?></td>
		<td<?php echo $CCEPayments->ReceiptNo->CellAttributes() ?>><span id="el_ReceiptNo">
<input type="text" name="x_ReceiptNo" id="x_ReceiptNo" title="<?php echo $CCEPayments->ReceiptNo->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $CCEPayments->ReceiptNo->EditValue ?>"<?php echo $CCEPayments->ReceiptNo->EditAttributes() ?>>
</span><?php echo $CCEPayments->ReceiptNo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->CreditNoteNo->Visible) { // CreditNoteNo ?>
	<tr<?php echo $CCEPayments->CreditNoteNo->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->CreditNoteNo->FldCaption() ?></td>
		<td<?php echo $CCEPayments->CreditNoteNo->CellAttributes() ?>><span id="el_CreditNoteNo">
<input type="text" name="x_CreditNoteNo" id="x_CreditNoteNo" title="<?php echo $CCEPayments->CreditNoteNo->FldTitle() ?>" size="30" maxlength="50" value="<?php echo $CCEPayments->CreditNoteNo->EditValue ?>"<?php echo $CCEPayments->CreditNoteNo->EditAttributes() ?>>
</span><?php echo $CCEPayments->CreditNoteNo->CustomMsg ?></td>
	</tr>
<?php } ?>
<?php if ($CCEPayments->AmountDep->Visible) { // AmountDep ?>
	<tr<?php echo $CCEPayments->AmountDep->RowAttributes ?>>
		<td class="ewTableHeader"><?php echo $CCEPayments->AmountDep->FldCaption() ?></td>
		<td<?php echo $CCEPayments->AmountDep->CellAttributes() ?>><span id="el_AmountDep">
<input type="text" name="x_AmountDep" id="x_AmountDep" title="<?php echo $CCEPayments->AmountDep->FldTitle() ?>" size="30" value="<?php echo $CCEPayments->AmountDep->EditValue ?>"<?php echo $CCEPayments->AmountDep->EditAttributes() ?>>
</span><?php echo $CCEPayments->AmountDep->CustomMsg ?></td>
	</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("AddBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--

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

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

//
// Page class
//
class cCCEPayments_add {

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

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

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

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

	// Page URL
	function PageUrl() {
		$PageUrl = ew_CurrentPage() . "?";
		global $CCEPayments;
		if ($CCEPayments->UseTokenInUrl) $PageUrl .= "t=" . $CCEPayments->TableVar . "&"; // Add page token
		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() {
		global $objForm, $CCEPayments;
		if ($CCEPayments->UseTokenInUrl) {
			if ($objForm)
				return ($CCEPayments->TableVar == $objForm->GetValue("t"));
			if (@$_GET["t"] <> "")
				return ($CCEPayments->TableVar == $_GET["t"]);
		} else {
			return TRUE;
		}
	}

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

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

		// Table object (CCEPayments)
		$GLOBALS["CCEPayments"] = new cCCEPayments();

		// Table object (CCECourseSchedules)
		$GLOBALS['CCECourseSchedules'] = new cCCECourseSchedules();

		// Table object (CCEStudents)
		$GLOBALS['CCEStudents'] = new cCCEStudents();

		// Table object (CCEUsers)
		$GLOBALS['CCEUsers'] = new cCCEUsers();

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

		// Table name (for backward compatibility)
		if (!defined("EW_TABLE_NAME"))
			define("EW_TABLE_NAME", 'CCEPayments', 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 $CCEPayments;

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

		// Create form object
		$objForm = new cFormObj();

		// 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 $sDbMasterFilter = "";
	var $sDbDetailFilter = "";
	var $lPriv = 0;

	// 
	// Page main
	//
	function Page_Main() {
		global $objForm, $Language, $gsFormError, $CCEPayments;

		// Load key values from QueryString
		$bCopy = TRUE;
		if (@$_GET["PaymentID"] != "") {
		  $CCEPayments->PaymentID->setQueryStringValue($_GET["PaymentID"]);
		} else {
		  $bCopy = FALSE;
		}

		// Set up master/detail parameters
		$this->SetUpMasterDetail();

		// Process form if post back
		if (@$_POST["a_add"] <> "") {
		   $CCEPayments->CurrentAction = $_POST["a_add"]; // Get form action
		  $this->LoadFormValues(); // Load form values

			// Validate form
			if (!$this->ValidateForm()) {
				$CCEPayments->CurrentAction = "I"; // Form error, reset action
				$this->setMessage($gsFormError);
			}
		} else { // Not post back
		  if ($bCopy) {
		    $CCEPayments->CurrentAction = "C"; // Copy record
		  } else {
		    $CCEPayments->CurrentAction = "I"; // Display blank record
		    $this->LoadDefaultValues(); // Load default values
		  }
		}

		// Perform action based on action code
		switch ($CCEPayments->CurrentAction) {
		  case "I": // Blank record, no action required
				break;
		  case "C": // Copy an existing record
		   if (!$this->LoadRow()) { // Load record based on key
		      $this->setMessage($Language->Phrase("NoRecord")); // No record found
		      $this->Page_Terminate("CCEPaymentslist.php"); // No matching record, return to list
		    }
				break;
		  case "A": // ' Add new record
				$CCEPayments->SendEmail = TRUE; // Send email on add success
		    if ($this->AddRow()) { // Add successful
		      $this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
					$sReturnUrl = $CCEPayments->getReturnUrl();
					if (ew_GetPageName($sReturnUrl) == "CCEPaymentsview.php")
						$sReturnUrl = $CCEPayments->ViewUrl(); // View paging, return to view page with keyurl directly
					$this->Page_Terminate($sReturnUrl); // Clean up and return
		    } else {
		      $this->RestoreFormValues(); // Add failed, restore form values
		    }
		}

		// Render row based on row type
		$CCEPayments->RowType = EW_ROWTYPE_ADD;  // Render add type

		// Render row
		$this->RenderRow();
	}

	// Get upload files
	function GetUploadFiles() {
		global $objForm, $CCEPayments;

		// Get upload data
	}

	// Load default values
	function LoadDefaultValues() {
		global $CCEPayments;
	}

	// Load form values
	function LoadFormValues() {

		// Load from form
		global $objForm, $CCEPayments;
		$CCEPayments->CourseID->setFormValue($objForm->GetValue("x_CourseID"));
		$CCEPayments->StudentID->setFormValue($objForm->GetValue("x_StudentID"));
		$CCEPayments->AmountDue->setFormValue($objForm->GetValue("x_AmountDue"));
		$CCEPayments->AmountPaid->setFormValue($objForm->GetValue("x_AmountPaid"));
		$CCEPayments->Refund->setFormValue($objForm->GetValue("x_Refund"));
		$CCEPayments->AmountOStd->setFormValue($objForm->GetValue("x_AmountOStd"));
		$CCEPayments->DatePaid->setFormValue($objForm->GetValue("x_DatePaid"));
		$CCEPayments->DatePaid->CurrentValue = ew_UnFormatDateTime($CCEPayments->DatePaid->CurrentValue, 5);
		$CCEPayments->Method->setFormValue($objForm->GetValue("x_Method"));
		$CCEPayments->Reference->setFormValue($objForm->GetValue("x_Reference"));
		$CCEPayments->AccountNo->setFormValue($objForm->GetValue("x_AccountNo"));
		$CCEPayments->InvoiceDate->setFormValue($objForm->GetValue("x_InvoiceDate"));
		$CCEPayments->InvoiceDate->CurrentValue = ew_UnFormatDateTime($CCEPayments->InvoiceDate->CurrentValue, 5);
		$CCEPayments->InvoiceNo->setFormValue($objForm->GetValue("x_InvoiceNo"));
		$CCEPayments->StockCode->setFormValue($objForm->GetValue("x_StockCode"));
		$CCEPayments->ReceiptNo->setFormValue($objForm->GetValue("x_ReceiptNo"));
		$CCEPayments->CreditNoteNo->setFormValue($objForm->GetValue("x_CreditNoteNo"));
		$CCEPayments->AmountDep->setFormValue($objForm->GetValue("x_AmountDep"));
		$CCEPayments->PaymentID->setFormValue($objForm->GetValue("x_PaymentID"));
	}

	// Restore form values
	function RestoreFormValues() {
		global $objForm, $CCEPayments;
		$CCEPayments->PaymentID->CurrentValue = $CCEPayments->PaymentID->FormValue;
		$CCEPayments->CourseID->CurrentValue = $CCEPayments->CourseID->FormValue;
		$CCEPayments->StudentID->CurrentValue = $CCEPayments->StudentID->FormValue;
		$CCEPayments->AmountDue->CurrentValue = $CCEPayments->AmountDue->FormValue;
		$CCEPayments->AmountPaid->CurrentValue = $CCEPayments->AmountPaid->FormValue;
		$CCEPayments->Refund->CurrentValue = $CCEPayments->Refund->FormValue;
		$CCEPayments->AmountOStd->CurrentValue = $CCEPayments->AmountOStd->FormValue;
		$CCEPayments->DatePaid->CurrentValue = $CCEPayments->DatePaid->FormValue;
		$CCEPayments->DatePaid->CurrentValue = ew_UnFormatDateTime($CCEPayments->DatePaid->CurrentValue, 5);
		$CCEPayments->Method->CurrentValue = $CCEPayments->Method->FormValue;
		$CCEPayments->Reference->CurrentValue = $CCEPayments->Reference->FormValue;
		$CCEPayments->AccountNo->CurrentValue = $CCEPayments->AccountNo->FormValue;
		$CCEPayments->InvoiceDate->CurrentValue = $CCEPayments->InvoiceDate->FormValue;
		$CCEPayments->InvoiceDate->CurrentValue = ew_UnFormatDateTime($CCEPayments->InvoiceDate->CurrentValue, 5);
		$CCEPayments->InvoiceNo->CurrentValue = $CCEPayments->InvoiceNo->FormValue;
		$CCEPayments->StockCode->CurrentValue = $CCEPayments->StockCode->FormValue;
		$CCEPayments->ReceiptNo->CurrentValue = $CCEPayments->ReceiptNo->FormValue;
		$CCEPayments->CreditNoteNo->CurrentValue = $CCEPayments->CreditNoteNo->FormValue;
		$CCEPayments->AmountDep->CurrentValue = $CCEPayments->AmountDep->FormValue;
	}

	// Load row based on key values
	function LoadRow() {
		global $conn, $Security, $CCEPayments;
		$sFilter = $CCEPayments->KeyFilter();

		// Call Row Selecting event
		$CCEPayments->Row_Selecting($sFilter);

		// Load SQL based on filter
		$CCEPayments->CurrentFilter = $sFilter;
		$sSql = $CCEPayments->SQL();
		$res = FALSE;
		$rs = ew_LoadRecordset($sSql);
		if ($rs && !$rs->EOF) {
			$res = TRUE;
			$this->LoadRowValues($rs); // Load row values

			// Call Row Selected event
			$CCEPayments->Row_Selected($rs);
			$rs->Close();
		}
		return $res;
	}

	// Load row values from recordset
	function LoadRowValues(&$rs) {
		global $conn, $CCEPayments;
		$CCEPayments->PaymentID->setDbValue($rs->fields('PaymentID'));
		$CCEPayments->CourseID->setDbValue($rs->fields('CourseID'));
		$CCEPayments->StudentID->setDbValue($rs->fields('StudentID'));
		$CCEPayments->AmountDue->setDbValue($rs->fields('AmountDue'));
		$CCEPayments->AmountPaid->setDbValue($rs->fields('AmountPaid'));
		$CCEPayments->Refund->setDbValue($rs->fields('Refund'));
		$CCEPayments->AmountOStd->setDbValue($rs->fields('AmountOStd'));
		$CCEPayments->DatePaid->setDbValue($rs->fields('DatePaid'));
		$CCEPayments->Method->setDbValue($rs->fields('Method'));
		$CCEPayments->Reference->setDbValue($rs->fields('Reference'));
		$CCEPayments->AccountNo->setDbValue($rs->fields('AccountNo'));
		$CCEPayments->InvoiceDate->setDbValue($rs->fields('InvoiceDate'));
		$CCEPayments->InvoiceNo->setDbValue($rs->fields('InvoiceNo'));
		$CCEPayments->StockCode->setDbValue($rs->fields('StockCode'));
		$CCEPayments->ReceiptNo->setDbValue($rs->fields('ReceiptNo'));
		$CCEPayments->CreditNoteNo->setDbValue($rs->fields('CreditNoteNo'));
		$CCEPayments->CESADiscount->setDbValue($rs->fields('CESADiscount'));
		$CCEPayments->EBDiscount->setDbValue($rs->fields('EBDiscount'));
		$CCEPayments->AmountDep->setDbValue($rs->fields('AmountDep'));
	}

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

		// Initialize URLs
		// Call Row_Rendering event

		$CCEPayments->Row_Rendering();

		// Common render codes for all row types
		// CourseID

		$CCEPayments->CourseID->CellCssStyle = ""; $CCEPayments->CourseID->CellCssClass = "";
		$CCEPayments->CourseID->CellAttrs = array(); $CCEPayments->CourseID->ViewAttrs = array(); $CCEPayments->CourseID->EditAttrs = array();

		// StudentID
		$CCEPayments->StudentID->CellCssStyle = ""; $CCEPayments->StudentID->CellCssClass = "";
		$CCEPayments->StudentID->CellAttrs = array(); $CCEPayments->StudentID->ViewAttrs = array(); $CCEPayments->StudentID->EditAttrs = array();

		// AmountDue
		$CCEPayments->AmountDue->CellCssStyle = ""; $CCEPayments->AmountDue->CellCssClass = "";
		$CCEPayments->AmountDue->CellAttrs = array(); $CCEPayments->AmountDue->ViewAttrs = array(); $CCEPayments->AmountDue->EditAttrs = array();

		// AmountPaid
		$CCEPayments->AmountPaid->CellCssStyle = ""; $CCEPayments->AmountPaid->CellCssClass = "";
		$CCEPayments->AmountPaid->CellAttrs = array(); $CCEPayments->AmountPaid->ViewAttrs = array(); $CCEPayments->AmountPaid->EditAttrs = array();

		// Refund
		$CCEPayments->Refund->CellCssStyle = ""; $CCEPayments->Refund->CellCssClass = "";
		$CCEPayments->Refund->CellAttrs = array(); $CCEPayments->Refund->ViewAttrs = array(); $CCEPayments->Refund->EditAttrs = array();

		// AmountOStd
		$CCEPayments->AmountOStd->CellCssStyle = ""; $CCEPayments->AmountOStd->CellCssClass = "";
		$CCEPayments->AmountOStd->CellAttrs = array(); $CCEPayments->AmountOStd->ViewAttrs = array(); $CCEPayments->AmountOStd->EditAttrs = array();

		// DatePaid
		$CCEPayments->DatePaid->CellCssStyle = ""; $CCEPayments->DatePaid->CellCssClass = "";
		$CCEPayments->DatePaid->CellAttrs = array(); $CCEPayments->DatePaid->ViewAttrs = array(); $CCEPayments->DatePaid->EditAttrs = array();

		// Method
		$CCEPayments->Method->CellCssStyle = ""; $CCEPayments->Method->CellCssClass = "";
		$CCEPayments->Method->CellAttrs = array(); $CCEPayments->Method->ViewAttrs = array(); $CCEPayments->Method->EditAttrs = array();

		// Reference
		$CCEPayments->Reference->CellCssStyle = ""; $CCEPayments->Reference->CellCssClass = "";
		$CCEPayments->Reference->CellAttrs = array(); $CCEPayments->Reference->ViewAttrs = array(); $CCEPayments->Reference->EditAttrs = array();

		// AccountNo
		$CCEPayments->AccountNo->CellCssStyle = ""; $CCEPayments->AccountNo->CellCssClass = "";
		$CCEPayments->AccountNo->CellAttrs = array(); $CCEPayments->AccountNo->ViewAttrs = array(); $CCEPayments->AccountNo->EditAttrs = array();

		// InvoiceDate
		$CCEPayments->InvoiceDate->CellCssStyle = ""; $CCEPayments->InvoiceDate->CellCssClass = "";
		$CCEPayments->InvoiceDate->CellAttrs = array(); $CCEPayments->InvoiceDate->ViewAttrs = array(); $CCEPayments->InvoiceDate->EditAttrs = array();

		// InvoiceNo
		$CCEPayments->InvoiceNo->CellCssStyle = ""; $CCEPayments->InvoiceNo->CellCssClass = "";
		$CCEPayments->InvoiceNo->CellAttrs = array(); $CCEPayments->InvoiceNo->ViewAttrs = array(); $CCEPayments->InvoiceNo->EditAttrs = array();

		// StockCode
		$CCEPayments->StockCode->CellCssStyle = ""; $CCEPayments->StockCode->CellCssClass = "";
		$CCEPayments->StockCode->CellAttrs = array(); $CCEPayments->StockCode->ViewAttrs = array(); $CCEPayments->StockCode->EditAttrs = array();

		// ReceiptNo
		$CCEPayments->ReceiptNo->CellCssStyle = ""; $CCEPayments->ReceiptNo->CellCssClass = "";
		$CCEPayments->ReceiptNo->CellAttrs = array(); $CCEPayments->ReceiptNo->ViewAttrs = array(); $CCEPayments->ReceiptNo->EditAttrs = array();

		// CreditNoteNo
		$CCEPayments->CreditNoteNo->CellCssStyle = ""; $CCEPayments->CreditNoteNo->CellCssClass = "";
		$CCEPayments->CreditNoteNo->CellAttrs = array(); $CCEPayments->CreditNoteNo->ViewAttrs = array(); $CCEPayments->CreditNoteNo->EditAttrs = array();

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

			// PaymentID
			$CCEPayments->PaymentID->ViewValue = $CCEPayments->PaymentID->CurrentValue;
			$CCEPayments->PaymentID->CssStyle = "";
			$CCEPayments->PaymentID->CssClass = "";
			$CCEPayments->PaymentID->ViewCustomAttributes = "";

			// CourseID
			if (strval($CCEPayments->CourseID->CurrentValue) <> "") {
				$sFilterWrk = "CCECourseSchedules.CCECourseScheduleID = " . ew_AdjustSql($CCEPayments->CourseID->CurrentValue) . "";
			$sSqlWrk = "SELECT CCECourses.CCECourseName AS `CCECourseName`, CCECourseSchedules.StartDate AS `StartDate` FROM CCECourses Inner Join CCECourseSchedules On CCECourseSchedules.CCECourseID = CCECourses.CCECourseID";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY CCECourses.CCECourseName, CCECourseSchedules.StartDate";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEPayments->CourseID->ViewValue = $rswrk->fields('CCECourseName');
					$CCEPayments->CourseID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('StartDate');
					$rswrk->Close();
				} else {
					$CCEPayments->CourseID->ViewValue = $CCEPayments->CourseID->CurrentValue;
				}
			} else {
				$CCEPayments->CourseID->ViewValue = NULL;
			}
			$CCEPayments->CourseID->CssStyle = "";
			$CCEPayments->CourseID->CssClass = "";
			$CCEPayments->CourseID->ViewCustomAttributes = "";

			// StudentID
			if (strval($CCEPayments->StudentID->CurrentValue) <> "") {
				$sFilterWrk = "`CCEStudentID` = " . ew_AdjustSql($CCEPayments->StudentID->CurrentValue) . "";
			$sSqlWrk = "SELECT `FirstName`, `Surname` FROM `CCEStudents`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Surname`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEPayments->StudentID->ViewValue = $rswrk->fields('FirstName');
					$CCEPayments->StudentID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('Surname');
					$rswrk->Close();
				} else {
					$CCEPayments->StudentID->ViewValue = $CCEPayments->StudentID->CurrentValue;
				}
			} else {
				$CCEPayments->StudentID->ViewValue = NULL;
			}
			$CCEPayments->StudentID->CssStyle = "";
			$CCEPayments->StudentID->CssClass = "";
			$CCEPayments->StudentID->ViewCustomAttributes = "";

			// AmountDue
			$CCEPayments->AmountDue->ViewValue = $CCEPayments->AmountDue->CurrentValue;
			$CCEPayments->AmountDue->CssStyle = "";
			$CCEPayments->AmountDue->CssClass = "";
			$CCEPayments->AmountDue->ViewCustomAttributes = "";

			// AmountPaid
			$CCEPayments->AmountPaid->ViewValue = $CCEPayments->AmountPaid->CurrentValue;
			$CCEPayments->AmountPaid->CssStyle = "";
			$CCEPayments->AmountPaid->CssClass = "";
			$CCEPayments->AmountPaid->ViewCustomAttributes = "";

			// Refund
			$CCEPayments->Refund->ViewValue = $CCEPayments->Refund->CurrentValue;
			$CCEPayments->Refund->CssStyle = "";
			$CCEPayments->Refund->CssClass = "";
			$CCEPayments->Refund->ViewCustomAttributes = "";

			// AmountOStd
			$CCEPayments->AmountOStd->ViewValue = $CCEPayments->AmountOStd->CurrentValue;
			$CCEPayments->AmountOStd->CssStyle = "";
			$CCEPayments->AmountOStd->CssClass = "";
			$CCEPayments->AmountOStd->ViewCustomAttributes = "";

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

			// Method
			$CCEPayments->Method->ViewValue = $CCEPayments->Method->CurrentValue;
			$CCEPayments->Method->CssStyle = "";
			$CCEPayments->Method->CssClass = "";
			$CCEPayments->Method->ViewCustomAttributes = "";

			// Reference
			$CCEPayments->Reference->ViewValue = $CCEPayments->Reference->CurrentValue;
			$CCEPayments->Reference->CssStyle = "";
			$CCEPayments->Reference->CssClass = "";
			$CCEPayments->Reference->ViewCustomAttributes = "";

			// AccountNo
			$CCEPayments->AccountNo->ViewValue = $CCEPayments->AccountNo->CurrentValue;
			$CCEPayments->AccountNo->CssStyle = "";
			$CCEPayments->AccountNo->CssClass = "";
			$CCEPayments->AccountNo->ViewCustomAttributes = "";

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

			// InvoiceNo
			$CCEPayments->InvoiceNo->ViewValue = $CCEPayments->InvoiceNo->CurrentValue;
			$CCEPayments->InvoiceNo->CssStyle = "";
			$CCEPayments->InvoiceNo->CssClass = "";
			$CCEPayments->InvoiceNo->ViewCustomAttributes = "";

			// StockCode
			$CCEPayments->StockCode->ViewValue = $CCEPayments->StockCode->CurrentValue;
			$CCEPayments->StockCode->CssStyle = "";
			$CCEPayments->StockCode->CssClass = "";
			$CCEPayments->StockCode->ViewCustomAttributes = "";

			// ReceiptNo
			$CCEPayments->ReceiptNo->ViewValue = $CCEPayments->ReceiptNo->CurrentValue;
			$CCEPayments->ReceiptNo->CssStyle = "";
			$CCEPayments->ReceiptNo->CssClass = "";
			$CCEPayments->ReceiptNo->ViewCustomAttributes = "";

			// CreditNoteNo
			$CCEPayments->CreditNoteNo->ViewValue = $CCEPayments->CreditNoteNo->CurrentValue;
			$CCEPayments->CreditNoteNo->CssStyle = "";
			$CCEPayments->CreditNoteNo->CssClass = "";
			$CCEPayments->CreditNoteNo->ViewCustomAttributes = "";

			// CESADiscount
			$CCEPayments->CESADiscount->ViewValue = $CCEPayments->CESADiscount->CurrentValue;
			$CCEPayments->CESADiscount->CssStyle = "";
			$CCEPayments->CESADiscount->CssClass = "";
			$CCEPayments->CESADiscount->ViewCustomAttributes = "";

			// EBDiscount
			$CCEPayments->EBDiscount->ViewValue = $CCEPayments->EBDiscount->CurrentValue;
			$CCEPayments->EBDiscount->CssStyle = "";
			$CCEPayments->EBDiscount->CssClass = "";
			$CCEPayments->EBDiscount->ViewCustomAttributes = "";

			// AmountDep
			$CCEPayments->AmountDep->ViewValue = $CCEPayments->AmountDep->CurrentValue;
			$CCEPayments->AmountDep->CssStyle = "";
			$CCEPayments->AmountDep->CssClass = "";
			$CCEPayments->AmountDep->ViewCustomAttributes = "";

			// CourseID
			$CCEPayments->CourseID->HrefValue = "";
			$CCEPayments->CourseID->TooltipValue = "";

			// StudentID
			$CCEPayments->StudentID->HrefValue = "";
			$CCEPayments->StudentID->TooltipValue = "";

			// AmountDue
			$CCEPayments->AmountDue->HrefValue = "";
			$CCEPayments->AmountDue->TooltipValue = "";

			// AmountPaid
			$CCEPayments->AmountPaid->HrefValue = "";
			$CCEPayments->AmountPaid->TooltipValue = "";

			// Refund
			$CCEPayments->Refund->HrefValue = "";
			$CCEPayments->Refund->TooltipValue = "";

			// AmountOStd
			$CCEPayments->AmountOStd->HrefValue = "";
			$CCEPayments->AmountOStd->TooltipValue = "";

			// DatePaid
			$CCEPayments->DatePaid->HrefValue = "";
			$CCEPayments->DatePaid->TooltipValue = "";

			// Method
			$CCEPayments->Method->HrefValue = "";
			$CCEPayments->Method->TooltipValue = "";

			// Reference
			$CCEPayments->Reference->HrefValue = "";
			$CCEPayments->Reference->TooltipValue = "";

			// AccountNo
			$CCEPayments->AccountNo->HrefValue = "";
			$CCEPayments->AccountNo->TooltipValue = "";

			// InvoiceDate
			$CCEPayments->InvoiceDate->HrefValue = "";
			$CCEPayments->InvoiceDate->TooltipValue = "";

			// InvoiceNo
			$CCEPayments->InvoiceNo->HrefValue = "";
			$CCEPayments->InvoiceNo->TooltipValue = "";

			// StockCode
			$CCEPayments->StockCode->HrefValue = "";
			$CCEPayments->StockCode->TooltipValue = "";

			// ReceiptNo
			$CCEPayments->ReceiptNo->HrefValue = "";
			$CCEPayments->ReceiptNo->TooltipValue = "";

			// CreditNoteNo
			$CCEPayments->CreditNoteNo->HrefValue = "";
			$CCEPayments->CreditNoteNo->TooltipValue = "";

			// AmountDep
			$CCEPayments->AmountDep->HrefValue = "";
			$CCEPayments->AmountDep->TooltipValue = "";
		} elseif ($CCEPayments->RowType == EW_ROWTYPE_ADD) { // Add row

			// CourseID
			$CCEPayments->CourseID->EditCustomAttributes = "";
			if ($CCEPayments->CourseID->getSessionValue() <> "") {
				$CCEPayments->CourseID->CurrentValue = $CCEPayments->CourseID->getSessionValue();
			if (strval($CCEPayments->CourseID->CurrentValue) <> "") {
				$sFilterWrk = "CCECourseSchedules.CCECourseScheduleID = " . ew_AdjustSql($CCEPayments->CourseID->CurrentValue) . "";
			$sSqlWrk = "SELECT CCECourses.CCECourseName AS `CCECourseName`, CCECourseSchedules.StartDate AS `StartDate` FROM CCECourses Inner Join CCECourseSchedules On CCECourseSchedules.CCECourseID = CCECourses.CCECourseID";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY CCECourses.CCECourseName, CCECourseSchedules.StartDate";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEPayments->CourseID->ViewValue = $rswrk->fields('CCECourseName');
					$CCEPayments->CourseID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('StartDate');
					$rswrk->Close();
				} else {
					$CCEPayments->CourseID->ViewValue = $CCEPayments->CourseID->CurrentValue;
				}
			} else {
				$CCEPayments->CourseID->ViewValue = NULL;
			}
			$CCEPayments->CourseID->CssStyle = "";
			$CCEPayments->CourseID->CssClass = "";
			$CCEPayments->CourseID->ViewCustomAttributes = "";
			} else {
				$sFilterWrk = "";
			$sSqlWrk = "SELECT CCECourseSchedules.CCECourseScheduleID, CCECourses.CCECourseName, CCECourseSchedules.StartDate, '' AS SelectFilterFld FROM CCECourses Inner Join CCECourseSchedules On CCECourseSchedules.CCECourseID = CCECourses.CCECourseID";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY CCECourses.CCECourseName, CCECourseSchedules.StartDate";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$CCEPayments->CourseID->EditValue = $arwrk;
			}

			// StudentID
			$CCEPayments->StudentID->EditCustomAttributes = "";
			if ($CCEPayments->StudentID->getSessionValue() <> "") {
				$CCEPayments->StudentID->CurrentValue = $CCEPayments->StudentID->getSessionValue();
			if (strval($CCEPayments->StudentID->CurrentValue) <> "") {
				$sFilterWrk = "`CCEStudentID` = " . ew_AdjustSql($CCEPayments->StudentID->CurrentValue) . "";
			$sSqlWrk = "SELECT `FirstName`, `Surname` FROM `CCEStudents`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Surname`";
				$rswrk = $conn->Execute($sSqlWrk);
				if ($rswrk && !$rswrk->EOF) { // Lookup values found
					$CCEPayments->StudentID->ViewValue = $rswrk->fields('FirstName');
					$CCEPayments->StudentID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('Surname');
					$rswrk->Close();
				} else {
					$CCEPayments->StudentID->ViewValue = $CCEPayments->StudentID->CurrentValue;
				}
			} else {
				$CCEPayments->StudentID->ViewValue = NULL;
			}
			$CCEPayments->StudentID->CssStyle = "";
			$CCEPayments->StudentID->CssClass = "";
			$CCEPayments->StudentID->ViewCustomAttributes = "";
			} else {
				$sFilterWrk = "";
			$sSqlWrk = "SELECT `CCEStudentID`, `FirstName`, `Surname`, '' AS SelectFilterFld FROM `CCEStudents`";
			$sWhereWrk = "";
			if ($sFilterWrk <> "") {
				if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
				$sWhereWrk .= "(" . $sFilterWrk . ")";
			}
			if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
			$sSqlWrk .= " ORDER BY `Surname`";
			$rswrk = $conn->Execute($sSqlWrk);
			$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
			if ($rswrk) $rswrk->Close();
			array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
			$CCEPayments->StudentID->EditValue = $arwrk;
			}

			// AmountDue
			$CCEPayments->AmountDue->EditCustomAttributes = "";
			$CCEPayments->AmountDue->EditValue = ew_HtmlEncode($CCEPayments->AmountDue->CurrentValue);

			// AmountPaid
			$CCEPayments->AmountPaid->EditCustomAttributes = "";
			$CCEPayments->AmountPaid->EditValue = ew_HtmlEncode($CCEPayments->AmountPaid->CurrentValue);

			// Refund
			$CCEPayments->Refund->EditCustomAttributes = "";
			$CCEPayments->Refund->EditValue = ew_HtmlEncode($CCEPayments->Refund->CurrentValue);

			// AmountOStd
			$CCEPayments->AmountOStd->EditCustomAttributes = "";
			$CCEPayments->AmountOStd->EditValue = ew_HtmlEncode($CCEPayments->AmountOStd->CurrentValue);

			// DatePaid
			$CCEPayments->DatePaid->EditCustomAttributes = "";
			$CCEPayments->DatePaid->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCEPayments->DatePaid->CurrentValue, 5));

			// Method
			$CCEPayments->Method->EditCustomAttributes = "";
			$CCEPayments->Method->EditValue = ew_HtmlEncode($CCEPayments->Method->CurrentValue);

			// Reference
			$CCEPayments->Reference->EditCustomAttributes = "";
			$CCEPayments->Reference->EditValue = ew_HtmlEncode($CCEPayments->Reference->CurrentValue);

			// AccountNo
			$CCEPayments->AccountNo->EditCustomAttributes = "";
			$CCEPayments->AccountNo->EditValue = ew_HtmlEncode($CCEPayments->AccountNo->CurrentValue);

			// InvoiceDate
			$CCEPayments->InvoiceDate->EditCustomAttributes = "";
			$CCEPayments->InvoiceDate->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCEPayments->InvoiceDate->CurrentValue, 5));

			// InvoiceNo
			$CCEPayments->InvoiceNo->EditCustomAttributes = "";
			$CCEPayments->InvoiceNo->EditValue = ew_HtmlEncode($CCEPayments->InvoiceNo->CurrentValue);

			// StockCode
			$CCEPayments->StockCode->EditCustomAttributes = "";
			$CCEPayments->StockCode->EditValue = ew_HtmlEncode($CCEPayments->StockCode->CurrentValue);

			// ReceiptNo
			$CCEPayments->ReceiptNo->EditCustomAttributes = "";
			$CCEPayments->ReceiptNo->EditValue = ew_HtmlEncode($CCEPayments->ReceiptNo->CurrentValue);

			// CreditNoteNo
			$CCEPayments->CreditNoteNo->EditCustomAttributes = "";
			$CCEPayments->CreditNoteNo->EditValue = ew_HtmlEncode($CCEPayments->CreditNoteNo->CurrentValue);

			// AmountDep
			$CCEPayments->AmountDep->EditCustomAttributes = "";
			$CCEPayments->AmountDep->EditValue = ew_HtmlEncode($CCEPayments->AmountDep->CurrentValue);
		}

		// Call Row Rendered event
		if ($CCEPayments->RowType <> EW_ROWTYPE_AGGREGATEINIT)
			$CCEPayments->Row_Rendered();
	}

	// Validate form
	function ValidateForm() {
		global $Language, $gsFormError, $CCEPayments;

		// Initialize form error message
		$gsFormError = "";

		// Check if validation required
		if (!EW_SERVER_VALIDATE)
			return ($gsFormError == "");
		if (!is_null($CCEPayments->StudentID->FormValue) && $CCEPayments->StudentID->FormValue == "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CCEPayments->StudentID->FldCaption();
		}
		if (!ew_CheckNumber($CCEPayments->AmountDue->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->AmountDue->FldErrMsg();
		}
		if (!ew_CheckNumber($CCEPayments->AmountPaid->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->AmountPaid->FldErrMsg();
		}
		if (!ew_CheckNumber($CCEPayments->Refund->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->Refund->FldErrMsg();
		}
		if (!ew_CheckNumber($CCEPayments->AmountOStd->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->AmountOStd->FldErrMsg();
		}
		if (!ew_CheckDate($CCEPayments->DatePaid->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->DatePaid->FldErrMsg();
		}
		if (!ew_CheckDate($CCEPayments->InvoiceDate->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->InvoiceDate->FldErrMsg();
		}
		if (!ew_CheckNumber($CCEPayments->AmountDep->FormValue)) {
			if ($gsFormError <> "") $gsFormError .= "<br>";
			$gsFormError .= $CCEPayments->AmountDep->FldErrMsg();
		}

		// Return validate result
		$ValidateForm = ($gsFormError == "");

		// Call Form_CustomValidate event
		$sFormCustomError = "";
		$ValidateForm = $ValidateForm && $this->Form_CustomValidate($sFormCustomError);
		if ($sFormCustomError <> "") {
			$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
			$gsFormError .= $sFormCustomError;
		}
		return $ValidateForm;
	}

	// Add record
	function AddRow() {
		global $conn, $Language, $Security, $CCEPayments;
		$rsnew = array();

		// CourseID
		$CCEPayments->CourseID->SetDbValueDef($rsnew, $CCEPayments->CourseID->CurrentValue, NULL, FALSE);

		// StudentID
		$CCEPayments->StudentID->SetDbValueDef($rsnew, $CCEPayments->StudentID->CurrentValue, 0, FALSE);

		// AmountDue
		$CCEPayments->AmountDue->SetDbValueDef($rsnew, $CCEPayments->AmountDue->CurrentValue, NULL, FALSE);

		// AmountPaid
		$CCEPayments->AmountPaid->SetDbValueDef($rsnew, $CCEPayments->AmountPaid->CurrentValue, NULL, FALSE);

		// Refund
		$CCEPayments->Refund->SetDbValueDef($rsnew, $CCEPayments->Refund->CurrentValue, NULL, FALSE);

		// AmountOStd
		$CCEPayments->AmountOStd->SetDbValueDef($rsnew, $CCEPayments->AmountOStd->CurrentValue, NULL, FALSE);

		// DatePaid
		$CCEPayments->DatePaid->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCEPayments->DatePaid->CurrentValue, 5, FALSE), NULL);

		// Method
		$CCEPayments->Method->SetDbValueDef($rsnew, $CCEPayments->Method->CurrentValue, NULL, FALSE);

		// Reference
		$CCEPayments->Reference->SetDbValueDef($rsnew, $CCEPayments->Reference->CurrentValue, NULL, FALSE);

		// AccountNo
		$CCEPayments->AccountNo->SetDbValueDef($rsnew, $CCEPayments->AccountNo->CurrentValue, NULL, FALSE);

		// InvoiceDate
		$CCEPayments->InvoiceDate->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCEPayments->InvoiceDate->CurrentValue, 5, FALSE), NULL);

		// InvoiceNo
		$CCEPayments->InvoiceNo->SetDbValueDef($rsnew, $CCEPayments->InvoiceNo->CurrentValue, NULL, FALSE);

		// StockCode
		$CCEPayments->StockCode->SetDbValueDef($rsnew, $CCEPayments->StockCode->CurrentValue, NULL, FALSE);

		// ReceiptNo
		$CCEPayments->ReceiptNo->SetDbValueDef($rsnew, $CCEPayments->ReceiptNo->CurrentValue, NULL, FALSE);

		// CreditNoteNo
		$CCEPayments->CreditNoteNo->SetDbValueDef($rsnew, $CCEPayments->CreditNoteNo->CurrentValue, NULL, FALSE);

		// AmountDep
		$CCEPayments->AmountDep->SetDbValueDef($rsnew, $CCEPayments->AmountDep->CurrentValue, NULL, FALSE);

		// Call Row Inserting event
		$bInsertRow = $CCEPayments->Row_Inserting($rsnew);
		if ($bInsertRow) {
			$conn->raiseErrorFn = 'ew_ErrorFn';
			$AddRow = $conn->Execute($CCEPayments->InsertSQL($rsnew));
			$conn->raiseErrorFn = '';
		} else {
			if ($CCEPayments->CancelMessage <> "") {
				$this->setMessage($CCEPayments->CancelMessage);
				$CCEPayments->CancelMessage = "";
			} else {
				$this->setMessage($Language->Phrase("InsertCancelled"));
			}
			$AddRow = FALSE;
		}
		if ($AddRow) {
			$CCEPayments->PaymentID->setDbValue($conn->Insert_ID());
			$rsnew['PaymentID'] = $CCEPayments->PaymentID->DbValue;

			// Call Row Inserted event
			$CCEPayments->Row_Inserted($rsnew);
		}
		return $AddRow;
	}

	// Set up master/detail based on QueryString
	function SetUpMasterDetail() {
		global $CCEPayments;
		$bValidMaster = FALSE;

		// Get the keys for master table
		if (@$_GET[EW_TABLE_SHOW_MASTER] <> "") {
			$sMasterTblVar = $_GET[EW_TABLE_SHOW_MASTER];
			if ($sMasterTblVar == "") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = "";
				$this->sDbDetailFilter = "";
			}
			if ($sMasterTblVar == "CCECourseSchedules") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $CCEPayments->SqlMasterFilter_CCECourseSchedules();
				$this->sDbDetailFilter = $CCEPayments->SqlDetailFilter_CCECourseSchedules();
				if (@$_GET["CCECourseScheduleID"] <> "") {
					$GLOBALS["CCECourseSchedules"]->CCECourseScheduleID->setQueryStringValue($_GET["CCECourseScheduleID"]);
					$CCEPayments->CourseID->setQueryStringValue($GLOBALS["CCECourseSchedules"]->CCECourseScheduleID->QueryStringValue);
					$CCEPayments->CourseID->setSessionValue($CCEPayments->CourseID->QueryStringValue);
					if (!is_numeric($GLOBALS["CCECourseSchedules"]->CCECourseScheduleID->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@CCECourseScheduleID@", ew_AdjustSql($GLOBALS["CCECourseSchedules"]->CCECourseScheduleID->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@CourseID@", ew_AdjustSql($GLOBALS["CCECourseSchedules"]->CCECourseScheduleID->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
			if ($sMasterTblVar == "CCEStudents") {
				$bValidMaster = TRUE;
				$this->sDbMasterFilter = $CCEPayments->SqlMasterFilter_CCEStudents();
				$this->sDbDetailFilter = $CCEPayments->SqlDetailFilter_CCEStudents();
				if (@$_GET["CCEStudentID"] <> "") {
					$GLOBALS["CCEStudents"]->CCEStudentID->setQueryStringValue($_GET["CCEStudentID"]);
					$CCEPayments->StudentID->setQueryStringValue($GLOBALS["CCEStudents"]->CCEStudentID->QueryStringValue);
					$CCEPayments->StudentID->setSessionValue($CCEPayments->StudentID->QueryStringValue);
					if (!is_numeric($GLOBALS["CCEStudents"]->CCEStudentID->QueryStringValue)) $bValidMaster = FALSE;
					$this->sDbMasterFilter = str_replace("@CCEStudentID@", ew_AdjustSql($GLOBALS["CCEStudents"]->CCEStudentID->QueryStringValue), $this->sDbMasterFilter);
					$this->sDbDetailFilter = str_replace("@StudentID@", ew_AdjustSql($GLOBALS["CCEStudents"]->CCEStudentID->QueryStringValue), $this->sDbDetailFilter);
				} else {
					$bValidMaster = FALSE;
				}
			}
		}
		if ($bValidMaster) {

			// Save current master table
			$CCEPayments->setCurrentMasterTable($sMasterTblVar);

			// Reset start record counter (new master key)
			$this->lStartRec = 1;
			$CCEPayments->setStartRecordNumber($this->lStartRec);
			$CCEPayments->setMasterFilter($this->sDbMasterFilter); // Set up master filter
			$CCEPayments->setDetailFilter($this->sDbDetailFilter); // Set up detail filter

			// Clear previous master key from Session
			if ($sMasterTblVar <> "CCECourseSchedules") {
				if ($CCEPayments->CourseID->QueryStringValue == "") $CCEPayments->CourseID->setSessionValue("");
			}
			if ($sMasterTblVar <> "CCEStudents") {
				if ($CCEPayments->StudentID->QueryStringValue == "") $CCEPayments->StudentID->setSessionValue("");
			}
		} else {
			$this->sDbMasterFilter = $CCEPayments->getMasterFilter(); //  Restore master filter
			$this->sDbDetailFilter = $CCEPayments->getDetailFilter(); // Restore detail filter
		}
	}

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

	}

	// Form Custom Validate event
	function Form_CustomValidate(&$CustomError) {

		// Return error message in CustomError
		return TRUE;
	}
}
?>