| Current Path : /var/www/cesa.co.za/ccmadmin/ |
| Current File : /var/www/cesa.co.za/ccmadmin/CCMStudentProgressedit.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 "CCMStudentProgressinfo.php" ?>
<?php include "CCMStudentsinfo.php" ?>
<?php include "CCMUsersinfo.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
$CCMStudentProgress_edit = new cCCMStudentProgress_edit();
$Page =& $CCMStudentProgress_edit;
// Page init
$CCMStudentProgress_edit->Page_Init();
// Page main
$CCMStudentProgress_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var CCMStudentProgress_edit = new ew_Page("CCMStudentProgress_edit");
// page properties
CCMStudentProgress_edit.PageID = "edit"; // page ID
CCMStudentProgress_edit.FormID = "fCCMStudentProgressedit"; // form ID
var EW_PAGE_ID = CCMStudentProgress_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
CCMStudentProgress_edit.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) : "";
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
CCMStudentProgress_edit.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) { ?>
CCMStudentProgress_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCMStudentProgress_edit.ValidateRequired = false; // no JavaScript validation
<?php } ?>
//-->
</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("Edit") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCMStudentProgress->TableCaption() ?><br><br>
<a href="<?php echo $CCMStudentProgress->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$CCMStudentProgress_edit->ShowMessage();
?>
<form name="fCCMStudentProgressedit" id="fCCMStudentProgressedit" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCMStudentProgress_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="CCMStudentProgress">
<input type="hidden" name="a_edit" id="a_edit" value="U">
<table cellspacing="0" class="ewGrid"><tr><td class="ewGridContent">
<div class="ewGridMiddlePanel">
<table cellspacing="0" class="ewTable">
<?php if ($CCMStudentProgress->CCMStudentProgressID->Visible) { // CCMStudentProgressID ?>
<tr<?php echo $CCMStudentProgress->CCMStudentProgressID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMStudentProgress->CCMStudentProgressID->FldCaption() ?></td>
<td<?php echo $CCMStudentProgress->CCMStudentProgressID->CellAttributes() ?>><span id="el_CCMStudentProgressID">
<div<?php echo $CCMStudentProgress->CCMStudentProgressID->ViewAttributes() ?>><?php echo $CCMStudentProgress->CCMStudentProgressID->EditValue ?></div><input type="hidden" name="x_CCMStudentProgressID" id="x_CCMStudentProgressID" value="<?php echo ew_HtmlEncode($CCMStudentProgress->CCMStudentProgressID->CurrentValue) ?>">
</span><?php echo $CCMStudentProgress->CCMStudentProgressID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMStudentProgress->CCMStudentID->Visible) { // CCMStudentID ?>
<tr<?php echo $CCMStudentProgress->CCMStudentID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMStudentProgress->CCMStudentID->FldCaption() ?></td>
<td<?php echo $CCMStudentProgress->CCMStudentID->CellAttributes() ?>><span id="el_CCMStudentID">
<div<?php echo $CCMStudentProgress->CCMStudentID->ViewAttributes() ?>><?php echo $CCMStudentProgress->CCMStudentID->EditValue ?></div><input type="hidden" name="x_CCMStudentID" id="x_CCMStudentID" value="<?php echo ew_HtmlEncode($CCMStudentProgress->CCMStudentID->CurrentValue) ?>">
</span><?php echo $CCMStudentProgress->CCMStudentID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMStudentProgress->CCMMilestoneNum->Visible) { // CCMMilestoneNum ?>
<tr<?php echo $CCMStudentProgress->CCMMilestoneNum->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMStudentProgress->CCMMilestoneNum->FldCaption() ?></td>
<td<?php echo $CCMStudentProgress->CCMMilestoneNum->CellAttributes() ?>><span id="el_CCMMilestoneNum">
<div<?php echo $CCMStudentProgress->CCMMilestoneNum->ViewAttributes() ?>><?php echo $CCMStudentProgress->CCMMilestoneNum->EditValue ?></div><input type="hidden" name="x_CCMMilestoneNum" id="x_CCMMilestoneNum" value="<?php echo ew_HtmlEncode($CCMStudentProgress->CCMMilestoneNum->CurrentValue) ?>">
</span><?php echo $CCMStudentProgress->CCMMilestoneNum->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMStudentProgress->CCMMilestonePaid->Visible) { // CCMMilestonePaid ?>
<tr<?php echo $CCMStudentProgress->CCMMilestonePaid->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMStudentProgress->CCMMilestonePaid->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CCMStudentProgress->CCMMilestonePaid->CellAttributes() ?>><span id="el_CCMMilestonePaid">
<div id="tp_x_CCMMilestonePaid" class="<?php echo EW_ITEM_TEMPLATE_CLASSNAME ?>"><label><input type="radio" name="x_CCMMilestonePaid" id="x_CCMMilestonePaid" title="<?php echo $CCMStudentProgress->CCMMilestonePaid->FldTitle() ?>" value="{value}"<?php echo $CCMStudentProgress->CCMMilestonePaid->EditAttributes() ?>></label></div>
<div id="dsl_x_CCMMilestonePaid" repeatcolumn="5">
<?php
$arwrk = $CCMStudentProgress->CCMMilestonePaid->EditValue;
if (is_array($arwrk)) {
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($CCMStudentProgress->CCMMilestonePaid->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " checked=\"checked\"" : "";
if ($selwrk <> "") $emptywrk = FALSE;
// Note: No spacing within the LABEL tag
?>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 1) ?>
<label><input type="radio" name="x_CCMMilestonePaid" id="x_CCMMilestonePaid" title="<?php echo $CCMStudentProgress->CCMMilestonePaid->FldTitle() ?>" value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?><?php echo $CCMStudentProgress->CCMMilestonePaid->EditAttributes() ?>><?php echo $arwrk[$rowcntwrk][1] ?></label>
<?php echo ew_RepeatColumnTable($rowswrk, $rowcntwrk, 5, 2) ?>
<?php
}
}
?>
</div>
</span><?php echo $CCMStudentProgress->CCMMilestonePaid->CustomMsg ?></td>
</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<p>
<input type="submit" name="btnAction" id="btnAction" value="<?php echo ew_BtnCaption($Language->Phrase("EditBtn")) ?>">
</form>
<script language="JavaScript" type="text/javascript">
<!--
// Write your table-specific startup script here
// document.write("page loaded");
//-->
</script>
<?php include "footer.php" ?>
<?php
$CCMStudentProgress_edit->Page_Terminate();
?>
<?php
//
// Page class
//
class cCCMStudentProgress_edit {
// Page ID
var $PageID = 'edit';
// Table name
var $TableName = 'CCMStudentProgress';
// Page object name
var $PageObjName = 'CCMStudentProgress_edit';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $CCMStudentProgress;
if ($CCMStudentProgress->UseTokenInUrl) $PageUrl .= "t=" . $CCMStudentProgress->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, $CCMStudentProgress;
if ($CCMStudentProgress->UseTokenInUrl) {
if ($objForm)
return ($CCMStudentProgress->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($CCMStudentProgress->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function cCCMStudentProgress_edit() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (CCMStudentProgress)
$GLOBALS["CCMStudentProgress"] = new cCCMStudentProgress();
// Table object (CCMStudents)
$GLOBALS['CCMStudents'] = new cCCMStudents();
// Table object (CCMUsers)
$GLOBALS['CCMUsers'] = new cCCMUsers();
// Page ID
if (!defined("EW_PAGE_ID"))
define("EW_PAGE_ID", 'edit', TRUE);
// Table name (for backward compatibility)
if (!defined("EW_TABLE_NAME"))
define("EW_TABLE_NAME", 'CCMStudentProgress', 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 $CCMStudentProgress;
// 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->CanEdit()) {
$Security->SaveLastUrl();
$this->Page_Terminate("CCMStudentProgresslist.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;
//
// Page main
//
function Page_Main() {
global $objForm, $Language, $gsFormError, $CCMStudentProgress;
// Load key from QueryString
if (@$_GET["CCMStudentProgressID"] <> "")
$CCMStudentProgress->CCMStudentProgressID->setQueryStringValue($_GET["CCMStudentProgressID"]);
// Set up master detail parameters
$this->SetUpMasterDetail();
if (@$_POST["a_edit"] <> "") {
$CCMStudentProgress->CurrentAction = $_POST["a_edit"]; // Get action code
$this->LoadFormValues(); // Get form values
// Validate form
if (!$this->ValidateForm()) {
$CCMStudentProgress->CurrentAction = ""; // Form error, reset action
$this->setMessage($gsFormError);
$CCMStudentProgress->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues();
}
} else {
$CCMStudentProgress->CurrentAction = "I"; // Default action is display
}
// Check if valid key
if ($CCMStudentProgress->CCMStudentProgressID->CurrentValue == "")
$this->Page_Terminate("CCMStudentProgresslist.php"); // Invalid key, return to list
switch ($CCMStudentProgress->CurrentAction) {
case "I": // Get a record to display
if (!$this->LoadRow()) { // Load record based on key
$this->setMessage($Language->Phrase("NoRecord")); // No record found
$this->Page_Terminate("CCMStudentProgresslist.php"); // No matching record, return to list
}
break;
Case "U": // Update
$CCMStudentProgress->SendEmail = TRUE; // Send email on update success
if ($this->EditRow()) { // Update record based on key
$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
$sReturnUrl = $CCMStudentProgress->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "CCMStudentProgressview.php")
$sReturnUrl = $CCMStudentProgress->ViewUrl(); // View paging, return to View page directly
$this->Page_Terminate($sReturnUrl); // Return to caller
} else {
$CCMStudentProgress->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues(); // Restore form values if update failed
}
}
// Render the record
$CCMStudentProgress->RowType = EW_ROWTYPE_EDIT; // Render as Edit
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $CCMStudentProgress;
// Get upload data
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $CCMStudentProgress;
$CCMStudentProgress->CCMStudentProgressID->setFormValue($objForm->GetValue("x_CCMStudentProgressID"));
$CCMStudentProgress->CCMStudentID->setFormValue($objForm->GetValue("x_CCMStudentID"));
$CCMStudentProgress->CCMMilestoneNum->setFormValue($objForm->GetValue("x_CCMMilestoneNum"));
$CCMStudentProgress->CCMMilestonePaid->setFormValue($objForm->GetValue("x_CCMMilestonePaid"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $CCMStudentProgress;
$this->LoadRow();
$CCMStudentProgress->CCMStudentProgressID->CurrentValue = $CCMStudentProgress->CCMStudentProgressID->FormValue;
$CCMStudentProgress->CCMStudentID->CurrentValue = $CCMStudentProgress->CCMStudentID->FormValue;
$CCMStudentProgress->CCMMilestoneNum->CurrentValue = $CCMStudentProgress->CCMMilestoneNum->FormValue;
$CCMStudentProgress->CCMMilestonePaid->CurrentValue = $CCMStudentProgress->CCMMilestonePaid->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $CCMStudentProgress;
$sFilter = $CCMStudentProgress->KeyFilter();
// Call Row Selecting event
$CCMStudentProgress->Row_Selecting($sFilter);
// Load SQL based on filter
$CCMStudentProgress->CurrentFilter = $sFilter;
$sSql = $CCMStudentProgress->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$CCMStudentProgress->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $CCMStudentProgress;
$CCMStudentProgress->CCMStudentProgressID->setDbValue($rs->fields('CCMStudentProgressID'));
$CCMStudentProgress->CCMStudentID->setDbValue($rs->fields('CCMStudentID'));
$CCMStudentProgress->CCMMilestoneNum->setDbValue($rs->fields('CCMMilestoneNum'));
$CCMStudentProgress->CCMMilestonePaid->setDbValue($rs->fields('CCMMilestonePaid'));
$CCMStudentProgress->CCMMilestoneDate->setDbValue($rs->fields('CCMMilestoneDate'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $CCMStudentProgress;
// Initialize URLs
// Call Row_Rendering event
$CCMStudentProgress->Row_Rendering();
// Common render codes for all row types
// CCMStudentProgressID
$CCMStudentProgress->CCMStudentProgressID->CellCssStyle = ""; $CCMStudentProgress->CCMStudentProgressID->CellCssClass = "";
$CCMStudentProgress->CCMStudentProgressID->CellAttrs = array(); $CCMStudentProgress->CCMStudentProgressID->ViewAttrs = array(); $CCMStudentProgress->CCMStudentProgressID->EditAttrs = array();
// CCMStudentID
$CCMStudentProgress->CCMStudentID->CellCssStyle = ""; $CCMStudentProgress->CCMStudentID->CellCssClass = "";
$CCMStudentProgress->CCMStudentID->CellAttrs = array(); $CCMStudentProgress->CCMStudentID->ViewAttrs = array(); $CCMStudentProgress->CCMStudentID->EditAttrs = array();
// CCMMilestoneNum
$CCMStudentProgress->CCMMilestoneNum->CellCssStyle = ""; $CCMStudentProgress->CCMMilestoneNum->CellCssClass = "";
$CCMStudentProgress->CCMMilestoneNum->CellAttrs = array(); $CCMStudentProgress->CCMMilestoneNum->ViewAttrs = array(); $CCMStudentProgress->CCMMilestoneNum->EditAttrs = array();
// CCMMilestonePaid
$CCMStudentProgress->CCMMilestonePaid->CellCssStyle = ""; $CCMStudentProgress->CCMMilestonePaid->CellCssClass = "";
$CCMStudentProgress->CCMMilestonePaid->CellAttrs = array(); $CCMStudentProgress->CCMMilestonePaid->ViewAttrs = array(); $CCMStudentProgress->CCMMilestonePaid->EditAttrs = array();
if ($CCMStudentProgress->RowType == EW_ROWTYPE_VIEW) { // View row
// CCMStudentProgressID
$CCMStudentProgress->CCMStudentProgressID->ViewValue = $CCMStudentProgress->CCMStudentProgressID->CurrentValue;
$CCMStudentProgress->CCMStudentProgressID->CssStyle = "";
$CCMStudentProgress->CCMStudentProgressID->CssClass = "";
$CCMStudentProgress->CCMStudentProgressID->ViewCustomAttributes = "";
// CCMStudentID
if (strval($CCMStudentProgress->CCMStudentID->CurrentValue) <> "") {
$sFilterWrk = "`CCMStudentID` = " . ew_AdjustSql($CCMStudentProgress->CCMStudentID->CurrentValue) . "";
$sSqlWrk = "SELECT `Surname`, `FirstName` FROM `CCMStudents`";
$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
$CCMStudentProgress->CCMStudentID->ViewValue = $rswrk->fields('Surname');
$CCMStudentProgress->CCMStudentID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('FirstName');
$rswrk->Close();
} else {
$CCMStudentProgress->CCMStudentID->ViewValue = $CCMStudentProgress->CCMStudentID->CurrentValue;
}
} else {
$CCMStudentProgress->CCMStudentID->ViewValue = NULL;
}
$CCMStudentProgress->CCMStudentID->CssStyle = "";
$CCMStudentProgress->CCMStudentID->CssClass = "";
$CCMStudentProgress->CCMStudentID->ViewCustomAttributes = "";
// CCMMilestoneNum
$CCMStudentProgress->CCMMilestoneNum->ViewValue = $CCMStudentProgress->CCMMilestoneNum->CurrentValue;
$CCMStudentProgress->CCMMilestoneNum->CssStyle = "";
$CCMStudentProgress->CCMMilestoneNum->CssClass = "";
$CCMStudentProgress->CCMMilestoneNum->ViewCustomAttributes = "";
// CCMMilestonePaid
if (strval($CCMStudentProgress->CCMMilestonePaid->CurrentValue) <> "") {
switch ($CCMStudentProgress->CCMMilestonePaid->CurrentValue) {
case "1":
$CCMStudentProgress->CCMMilestonePaid->ViewValue = "Yes";
break;
case "0":
$CCMStudentProgress->CCMMilestonePaid->ViewValue = "No";
break;
default:
$CCMStudentProgress->CCMMilestonePaid->ViewValue = $CCMStudentProgress->CCMMilestonePaid->CurrentValue;
}
} else {
$CCMStudentProgress->CCMMilestonePaid->ViewValue = NULL;
}
$CCMStudentProgress->CCMMilestonePaid->CssStyle = "";
$CCMStudentProgress->CCMMilestonePaid->CssClass = "";
$CCMStudentProgress->CCMMilestonePaid->ViewCustomAttributes = "";
// CCMMilestoneDate
$CCMStudentProgress->CCMMilestoneDate->ViewValue = $CCMStudentProgress->CCMMilestoneDate->CurrentValue;
$CCMStudentProgress->CCMMilestoneDate->ViewValue = ew_FormatDateTime($CCMStudentProgress->CCMMilestoneDate->ViewValue, 5);
$CCMStudentProgress->CCMMilestoneDate->CssStyle = "";
$CCMStudentProgress->CCMMilestoneDate->CssClass = "";
$CCMStudentProgress->CCMMilestoneDate->ViewCustomAttributes = "";
// CCMStudentProgressID
$CCMStudentProgress->CCMStudentProgressID->HrefValue = "";
$CCMStudentProgress->CCMStudentProgressID->TooltipValue = "";
// CCMStudentID
$CCMStudentProgress->CCMStudentID->HrefValue = "";
$CCMStudentProgress->CCMStudentID->TooltipValue = "";
// CCMMilestoneNum
$CCMStudentProgress->CCMMilestoneNum->HrefValue = "";
$CCMStudentProgress->CCMMilestoneNum->TooltipValue = "";
// CCMMilestonePaid
$CCMStudentProgress->CCMMilestonePaid->HrefValue = "";
$CCMStudentProgress->CCMMilestonePaid->TooltipValue = "";
} elseif ($CCMStudentProgress->RowType == EW_ROWTYPE_EDIT) { // Edit row
// CCMStudentProgressID
$CCMStudentProgress->CCMStudentProgressID->EditCustomAttributes = "";
$CCMStudentProgress->CCMStudentProgressID->EditValue = $CCMStudentProgress->CCMStudentProgressID->CurrentValue;
$CCMStudentProgress->CCMStudentProgressID->CssStyle = "";
$CCMStudentProgress->CCMStudentProgressID->CssClass = "";
$CCMStudentProgress->CCMStudentProgressID->ViewCustomAttributes = "";
// CCMStudentID
$CCMStudentProgress->CCMStudentID->EditCustomAttributes = "";
if (strval($CCMStudentProgress->CCMStudentID->CurrentValue) <> "") {
$sFilterWrk = "`CCMStudentID` = " . ew_AdjustSql($CCMStudentProgress->CCMStudentID->CurrentValue) . "";
$sSqlWrk = "SELECT `Surname`, `FirstName` FROM `CCMStudents`";
$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
$CCMStudentProgress->CCMStudentID->EditValue = $rswrk->fields('Surname');
$CCMStudentProgress->CCMStudentID->EditValue .= ew_ValueSeparator(0) . $rswrk->fields('FirstName');
$rswrk->Close();
} else {
$CCMStudentProgress->CCMStudentID->EditValue = $CCMStudentProgress->CCMStudentID->CurrentValue;
}
} else {
$CCMStudentProgress->CCMStudentID->EditValue = NULL;
}
$CCMStudentProgress->CCMStudentID->CssStyle = "";
$CCMStudentProgress->CCMStudentID->CssClass = "";
$CCMStudentProgress->CCMStudentID->ViewCustomAttributes = "";
// CCMMilestoneNum
$CCMStudentProgress->CCMMilestoneNum->EditCustomAttributes = "";
$CCMStudentProgress->CCMMilestoneNum->EditValue = $CCMStudentProgress->CCMMilestoneNum->CurrentValue;
$CCMStudentProgress->CCMMilestoneNum->CssStyle = "";
$CCMStudentProgress->CCMMilestoneNum->CssClass = "";
$CCMStudentProgress->CCMMilestoneNum->ViewCustomAttributes = "";
// CCMMilestonePaid
$CCMStudentProgress->CCMMilestonePaid->EditCustomAttributes = "";
$arwrk = array();
$arwrk[] = array("1", "Yes");
$arwrk[] = array("0", "No");
$CCMStudentProgress->CCMMilestonePaid->EditValue = $arwrk;
// Edit refer script
// CCMStudentProgressID
$CCMStudentProgress->CCMStudentProgressID->HrefValue = "";
// CCMStudentID
$CCMStudentProgress->CCMStudentID->HrefValue = "";
// CCMMilestoneNum
$CCMStudentProgress->CCMMilestoneNum->HrefValue = "";
// CCMMilestonePaid
$CCMStudentProgress->CCMMilestonePaid->HrefValue = "";
}
// Call Row Rendered event
if ($CCMStudentProgress->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$CCMStudentProgress->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $CCMStudentProgress;
// Initialize form error message
$gsFormError = "";
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
// 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;
}
// Update record based on key values
function EditRow() {
global $conn, $Security, $Language, $CCMStudentProgress;
$sFilter = $CCMStudentProgress->KeyFilter();
$CCMStudentProgress->CurrentFilter = $sFilter;
$sSql = $CCMStudentProgress->SQL();
$conn->raiseErrorFn = 'ew_ErrorFn';
$rs = $conn->Execute($sSql);
$conn->raiseErrorFn = '';
if ($rs === FALSE)
return FALSE;
if ($rs->EOF) {
$EditRow = FALSE; // Update Failed
} else {
// Save old values
$rsold =& $rs->fields;
$rsnew = array();
// CCMMilestonePaid
$CCMStudentProgress->CCMMilestonePaid->SetDbValueDef($rsnew, $CCMStudentProgress->CCMMilestonePaid->CurrentValue, 0, FALSE);
// Call Row Updating event
$bUpdateRow = $CCMStudentProgress->Row_Updating($rsold, $rsnew);
if ($bUpdateRow) {
$conn->raiseErrorFn = 'ew_ErrorFn';
$EditRow = $conn->Execute($CCMStudentProgress->UpdateSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($CCMStudentProgress->CancelMessage <> "") {
$this->setMessage($CCMStudentProgress->CancelMessage);
$CCMStudentProgress->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("UpdateCancelled"));
}
$EditRow = FALSE;
}
}
// Call Row_Updated event
if ($EditRow)
$CCMStudentProgress->Row_Updated($rsold, $rsnew);
$rs->Close();
return $EditRow;
}
// Set up master/detail based on QueryString
function SetUpMasterDetail() {
global $CCMStudentProgress;
$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 == "CCMStudents") {
$bValidMaster = TRUE;
$this->sDbMasterFilter = $CCMStudentProgress->SqlMasterFilter_CCMStudents();
$this->sDbDetailFilter = $CCMStudentProgress->SqlDetailFilter_CCMStudents();
if (@$_GET["CCMStudentID"] <> "") {
$GLOBALS["CCMStudents"]->CCMStudentID->setQueryStringValue($_GET["CCMStudentID"]);
$CCMStudentProgress->CCMStudentID->setQueryStringValue($GLOBALS["CCMStudents"]->CCMStudentID->QueryStringValue);
$CCMStudentProgress->CCMStudentID->setSessionValue($CCMStudentProgress->CCMStudentID->QueryStringValue);
if (!is_numeric($GLOBALS["CCMStudents"]->CCMStudentID->QueryStringValue)) $bValidMaster = FALSE;
$this->sDbMasterFilter = str_replace("@CCMStudentID@", ew_AdjustSql($GLOBALS["CCMStudents"]->CCMStudentID->QueryStringValue), $this->sDbMasterFilter);
$this->sDbDetailFilter = str_replace("@CCMStudentID@", ew_AdjustSql($GLOBALS["CCMStudents"]->CCMStudentID->QueryStringValue), $this->sDbDetailFilter);
} else {
$bValidMaster = FALSE;
}
}
}
if ($bValidMaster) {
// Save current master table
$CCMStudentProgress->setCurrentMasterTable($sMasterTblVar);
// Reset start record counter (new master key)
$this->lStartRec = 1;
$CCMStudentProgress->setStartRecordNumber($this->lStartRec);
$CCMStudentProgress->setMasterFilter($this->sDbMasterFilter); // Set up master filter
$CCMStudentProgress->setDetailFilter($this->sDbDetailFilter); // Set up detail filter
// Clear previous master key from Session
if ($sMasterTblVar <> "CCMStudents") {
if ($CCMStudentProgress->CCMStudentID->QueryStringValue == "") $CCMStudentProgress->CCMStudentID->setSessionValue("");
}
} else {
$this->sDbMasterFilter = $CCMStudentProgress->getMasterFilter(); // Restore master filter
$this->sDbDetailFilter = $CCMStudentProgress->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;
}
}
?>