| Current Path : /var/www/cesa.co.za/cceadmin/ |
| Current File : /var/www/cesa.co.za/cceadmin/CCECourseSchedulesadd.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 "CCECourseSchedulesinfo.php" ?>
<?php include "CCECoursesinfo.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
$CCECourseSchedules_add = new cCCECourseSchedules_add();
$Page =& $CCECourseSchedules_add;
// Page init
$CCECourseSchedules_add->Page_Init();
// Page main
$CCECourseSchedules_add->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var CCECourseSchedules_add = new ew_Page("CCECourseSchedules_add");
// page properties
CCECourseSchedules_add.PageID = "add"; // page ID
CCECourseSchedules_add.FormID = "fCCECourseSchedulesadd"; // form ID
var EW_PAGE_ID = CCECourseSchedules_add.PageID; // for backward compatibility
// extend page with ValidateForm function
CCECourseSchedules_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 + "_StartDate"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CCECourseSchedules->StartDate->FldCaption()) ?>");
elm = fobj.elements["x" + infix + "_StartDate"];
if (elm && !ew_CheckDate(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCECourseSchedules->StartDate->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_EndDate"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CCECourseSchedules->EndDate->FldCaption()) ?>");
elm = fobj.elements["x" + infix + "_EndDate"];
if (elm && !ew_CheckDate(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCECourseSchedules->EndDate->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_ReleaseDate"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CCECourseSchedules->ReleaseDate->FldCaption()) ?>");
elm = fobj.elements["x" + infix + "_ReleaseDate"];
if (elm && !ew_CheckDate(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCECourseSchedules->ReleaseDate->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_RegistrationDeadline"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($CCECourseSchedules->RegistrationDeadline->FldCaption()) ?>");
elm = fobj.elements["x" + infix + "_RegistrationDeadline"];
if (elm && !ew_CheckDate(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCECourseSchedules->RegistrationDeadline->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_MaxStudents"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCECourseSchedules->MaxStudents->FldErrMsg()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
CCECourseSchedules_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) { ?>
CCECourseSchedules_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCECourseSchedules_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") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCECourseSchedules->TableCaption() ?><br><br>
<a href="<?php echo $CCECourseSchedules->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$CCECourseSchedules_add->ShowMessage();
?>
<form name="fCCECourseSchedulesadd" id="fCCECourseSchedulesadd" action="<?php echo ew_CurrentPage() ?>" method="post" onsubmit="return CCECourseSchedules_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CCECourseSchedules">
<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 ($CCECourseSchedules->CCECourseID->Visible) { // CCECourseID ?>
<tr<?php echo $CCECourseSchedules->CCECourseID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCECourseSchedules->CCECourseID->FldCaption() ?></td>
<td<?php echo $CCECourseSchedules->CCECourseID->CellAttributes() ?>><span id="el_CCECourseID">
<?php if ($CCECourseSchedules->CCECourseID->getSessionValue() <> "") { ?>
<div<?php echo $CCECourseSchedules->CCECourseID->ViewAttributes() ?>><?php echo $CCECourseSchedules->CCECourseID->ViewValue ?></div>
<input type="hidden" id="x_CCECourseID" name="x_CCECourseID" value="<?php echo ew_HtmlEncode($CCECourseSchedules->CCECourseID->CurrentValue) ?>">
<?php } else { ?>
<select id="x_CCECourseID" name="x_CCECourseID" title="<?php echo $CCECourseSchedules->CCECourseID->FldTitle() ?>"<?php echo $CCECourseSchedules->CCECourseID->EditAttributes() ?>>
<?php
if (is_array($CCECourseSchedules->CCECourseID->EditValue)) {
$arwrk = $CCECourseSchedules->CCECourseID->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($CCECourseSchedules->CCECourseID->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] ?>
</option>
<?php
}
}
?>
</select>
<?php } ?>
</span><?php echo $CCECourseSchedules->CCECourseID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCECourseSchedules->StartDate->Visible) { // StartDate ?>
<tr<?php echo $CCECourseSchedules->StartDate->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCECourseSchedules->StartDate->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CCECourseSchedules->StartDate->CellAttributes() ?>><span id="el_StartDate">
<input type="text" name="x_StartDate" id="x_StartDate" title="<?php echo $CCECourseSchedules->StartDate->FldTitle() ?>" value="<?php echo $CCECourseSchedules->StartDate->EditValue ?>"<?php echo $CCECourseSchedules->StartDate->EditAttributes() ?>>
<img src="images/calendar.png" id="cal_x_StartDate" name="cal_x_StartDate" 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_StartDate", // input field id
ifFormat: "%Y/%m/%d", // date format
button: "cal_x_StartDate" // button id
});
</script>
</span><?php echo $CCECourseSchedules->StartDate->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCECourseSchedules->EndDate->Visible) { // EndDate ?>
<tr<?php echo $CCECourseSchedules->EndDate->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCECourseSchedules->EndDate->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CCECourseSchedules->EndDate->CellAttributes() ?>><span id="el_EndDate">
<input type="text" name="x_EndDate" id="x_EndDate" title="<?php echo $CCECourseSchedules->EndDate->FldTitle() ?>" value="<?php echo $CCECourseSchedules->EndDate->EditValue ?>"<?php echo $CCECourseSchedules->EndDate->EditAttributes() ?>>
<img src="images/calendar.png" id="cal_x_EndDate" name="cal_x_EndDate" 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_EndDate", // input field id
ifFormat: "%Y/%m/%d", // date format
button: "cal_x_EndDate" // button id
});
</script>
</span><?php echo $CCECourseSchedules->EndDate->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCECourseSchedules->ReleaseDate->Visible) { // ReleaseDate ?>
<tr<?php echo $CCECourseSchedules->ReleaseDate->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCECourseSchedules->ReleaseDate->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CCECourseSchedules->ReleaseDate->CellAttributes() ?>><span id="el_ReleaseDate">
<input type="text" name="x_ReleaseDate" id="x_ReleaseDate" title="<?php echo $CCECourseSchedules->ReleaseDate->FldTitle() ?>" value="<?php echo $CCECourseSchedules->ReleaseDate->EditValue ?>"<?php echo $CCECourseSchedules->ReleaseDate->EditAttributes() ?>>
<img src="images/calendar.png" id="cal_x_ReleaseDate" name="cal_x_ReleaseDate" 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_ReleaseDate", // input field id
ifFormat: "%Y/%m/%d", // date format
button: "cal_x_ReleaseDate" // button id
});
</script>
</span><?php echo $CCECourseSchedules->ReleaseDate->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCECourseSchedules->RegistrationDeadline->Visible) { // RegistrationDeadline ?>
<tr<?php echo $CCECourseSchedules->RegistrationDeadline->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCECourseSchedules->RegistrationDeadline->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $CCECourseSchedules->RegistrationDeadline->CellAttributes() ?>><span id="el_RegistrationDeadline">
<input type="text" name="x_RegistrationDeadline" id="x_RegistrationDeadline" title="<?php echo $CCECourseSchedules->RegistrationDeadline->FldTitle() ?>" value="<?php echo $CCECourseSchedules->RegistrationDeadline->EditValue ?>"<?php echo $CCECourseSchedules->RegistrationDeadline->EditAttributes() ?>>
<img src="images/calendar.png" id="cal_x_RegistrationDeadline" name="cal_x_RegistrationDeadline" 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_RegistrationDeadline", // input field id
ifFormat: "%Y/%m/%d", // date format
button: "cal_x_RegistrationDeadline" // button id
});
</script>
</span><?php echo $CCECourseSchedules->RegistrationDeadline->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCECourseSchedules->MaxStudents->Visible) { // MaxStudents ?>
<tr<?php echo $CCECourseSchedules->MaxStudents->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCECourseSchedules->MaxStudents->FldCaption() ?></td>
<td<?php echo $CCECourseSchedules->MaxStudents->CellAttributes() ?>><span id="el_MaxStudents">
<input type="text" name="x_MaxStudents" id="x_MaxStudents" title="<?php echo $CCECourseSchedules->MaxStudents->FldTitle() ?>" size="30" value="<?php echo $CCECourseSchedules->MaxStudents->EditValue ?>"<?php echo $CCECourseSchedules->MaxStudents->EditAttributes() ?>>
</span><?php echo $CCECourseSchedules->MaxStudents->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
$CCECourseSchedules_add->Page_Terminate();
?>
<?php
//
// Page class
//
class cCCECourseSchedules_add {
// Page ID
var $PageID = 'add';
// Table name
var $TableName = 'CCECourseSchedules';
// Page object name
var $PageObjName = 'CCECourseSchedules_add';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $CCECourseSchedules;
if ($CCECourseSchedules->UseTokenInUrl) $PageUrl .= "t=" . $CCECourseSchedules->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, $CCECourseSchedules;
if ($CCECourseSchedules->UseTokenInUrl) {
if ($objForm)
return ($CCECourseSchedules->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($CCECourseSchedules->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function cCCECourseSchedules_add() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (CCECourseSchedules)
$GLOBALS["CCECourseSchedules"] = new cCCECourseSchedules();
// Table object (CCECourses)
$GLOBALS['CCECourses'] = new cCCECourses();
// 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", 'CCECourseSchedules', 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 $CCECourseSchedules;
// 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("CCECourseScheduleslist.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, $CCECourseSchedules;
// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["CCECourseScheduleID"] != "") {
$CCECourseSchedules->CCECourseScheduleID->setQueryStringValue($_GET["CCECourseScheduleID"]);
} else {
$bCopy = FALSE;
}
// Set up master/detail parameters
$this->SetUpMasterDetail();
// Process form if post back
if (@$_POST["a_add"] <> "") {
$CCECourseSchedules->CurrentAction = $_POST["a_add"]; // Get form action
$this->LoadFormValues(); // Load form values
// Validate form
if (!$this->ValidateForm()) {
$CCECourseSchedules->CurrentAction = "I"; // Form error, reset action
$this->setMessage($gsFormError);
}
} else { // Not post back
if ($bCopy) {
$CCECourseSchedules->CurrentAction = "C"; // Copy record
} else {
$CCECourseSchedules->CurrentAction = "I"; // Display blank record
$this->LoadDefaultValues(); // Load default values
}
}
// Perform action based on action code
switch ($CCECourseSchedules->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("CCECourseScheduleslist.php"); // No matching record, return to list
}
break;
case "A": // ' Add new record
$CCECourseSchedules->SendEmail = TRUE; // Send email on add success
if ($this->AddRow()) { // Add successful
$this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
$sReturnUrl = $CCECourseSchedules->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "CCECourseSchedulesview.php")
$sReturnUrl = $CCECourseSchedules->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
$CCECourseSchedules->RowType = EW_ROWTYPE_ADD; // Render add type
// Render row
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $CCECourseSchedules;
// Get upload data
}
// Load default values
function LoadDefaultValues() {
global $CCECourseSchedules;
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $CCECourseSchedules;
$CCECourseSchedules->CCECourseID->setFormValue($objForm->GetValue("x_CCECourseID"));
$CCECourseSchedules->StartDate->setFormValue($objForm->GetValue("x_StartDate"));
$CCECourseSchedules->StartDate->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->StartDate->CurrentValue, 5);
$CCECourseSchedules->EndDate->setFormValue($objForm->GetValue("x_EndDate"));
$CCECourseSchedules->EndDate->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->EndDate->CurrentValue, 5);
$CCECourseSchedules->ReleaseDate->setFormValue($objForm->GetValue("x_ReleaseDate"));
$CCECourseSchedules->ReleaseDate->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->ReleaseDate->CurrentValue, 5);
$CCECourseSchedules->RegistrationDeadline->setFormValue($objForm->GetValue("x_RegistrationDeadline"));
$CCECourseSchedules->RegistrationDeadline->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->RegistrationDeadline->CurrentValue, 5);
$CCECourseSchedules->MaxStudents->setFormValue($objForm->GetValue("x_MaxStudents"));
$CCECourseSchedules->CCECourseScheduleID->setFormValue($objForm->GetValue("x_CCECourseScheduleID"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $CCECourseSchedules;
$CCECourseSchedules->CCECourseScheduleID->CurrentValue = $CCECourseSchedules->CCECourseScheduleID->FormValue;
$CCECourseSchedules->CCECourseID->CurrentValue = $CCECourseSchedules->CCECourseID->FormValue;
$CCECourseSchedules->StartDate->CurrentValue = $CCECourseSchedules->StartDate->FormValue;
$CCECourseSchedules->StartDate->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->StartDate->CurrentValue, 5);
$CCECourseSchedules->EndDate->CurrentValue = $CCECourseSchedules->EndDate->FormValue;
$CCECourseSchedules->EndDate->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->EndDate->CurrentValue, 5);
$CCECourseSchedules->ReleaseDate->CurrentValue = $CCECourseSchedules->ReleaseDate->FormValue;
$CCECourseSchedules->ReleaseDate->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->ReleaseDate->CurrentValue, 5);
$CCECourseSchedules->RegistrationDeadline->CurrentValue = $CCECourseSchedules->RegistrationDeadline->FormValue;
$CCECourseSchedules->RegistrationDeadline->CurrentValue = ew_UnFormatDateTime($CCECourseSchedules->RegistrationDeadline->CurrentValue, 5);
$CCECourseSchedules->MaxStudents->CurrentValue = $CCECourseSchedules->MaxStudents->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $CCECourseSchedules;
$sFilter = $CCECourseSchedules->KeyFilter();
// Call Row Selecting event
$CCECourseSchedules->Row_Selecting($sFilter);
// Load SQL based on filter
$CCECourseSchedules->CurrentFilter = $sFilter;
$sSql = $CCECourseSchedules->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$CCECourseSchedules->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $CCECourseSchedules;
$CCECourseSchedules->CCECourseScheduleID->setDbValue($rs->fields('CCECourseScheduleID'));
$CCECourseSchedules->CCECourseID->setDbValue($rs->fields('CCECourseID'));
$CCECourseSchedules->StartDate->setDbValue($rs->fields('StartDate'));
$CCECourseSchedules->EndDate->setDbValue($rs->fields('EndDate'));
$CCECourseSchedules->ReleaseDate->setDbValue($rs->fields('ReleaseDate'));
$CCECourseSchedules->RegistrationDeadline->setDbValue($rs->fields('RegistrationDeadline'));
$CCECourseSchedules->MaxStudents->setDbValue($rs->fields('MaxStudents'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $CCECourseSchedules;
// Initialize URLs
// Call Row_Rendering event
$CCECourseSchedules->Row_Rendering();
// Common render codes for all row types
// CCECourseID
$CCECourseSchedules->CCECourseID->CellCssStyle = ""; $CCECourseSchedules->CCECourseID->CellCssClass = "";
$CCECourseSchedules->CCECourseID->CellAttrs = array(); $CCECourseSchedules->CCECourseID->ViewAttrs = array(); $CCECourseSchedules->CCECourseID->EditAttrs = array();
// StartDate
$CCECourseSchedules->StartDate->CellCssStyle = ""; $CCECourseSchedules->StartDate->CellCssClass = "";
$CCECourseSchedules->StartDate->CellAttrs = array(); $CCECourseSchedules->StartDate->ViewAttrs = array(); $CCECourseSchedules->StartDate->EditAttrs = array();
// EndDate
$CCECourseSchedules->EndDate->CellCssStyle = ""; $CCECourseSchedules->EndDate->CellCssClass = "";
$CCECourseSchedules->EndDate->CellAttrs = array(); $CCECourseSchedules->EndDate->ViewAttrs = array(); $CCECourseSchedules->EndDate->EditAttrs = array();
// ReleaseDate
$CCECourseSchedules->ReleaseDate->CellCssStyle = ""; $CCECourseSchedules->ReleaseDate->CellCssClass = "";
$CCECourseSchedules->ReleaseDate->CellAttrs = array(); $CCECourseSchedules->ReleaseDate->ViewAttrs = array(); $CCECourseSchedules->ReleaseDate->EditAttrs = array();
// RegistrationDeadline
$CCECourseSchedules->RegistrationDeadline->CellCssStyle = ""; $CCECourseSchedules->RegistrationDeadline->CellCssClass = "";
$CCECourseSchedules->RegistrationDeadline->CellAttrs = array(); $CCECourseSchedules->RegistrationDeadline->ViewAttrs = array(); $CCECourseSchedules->RegistrationDeadline->EditAttrs = array();
// MaxStudents
$CCECourseSchedules->MaxStudents->CellCssStyle = ""; $CCECourseSchedules->MaxStudents->CellCssClass = "";
$CCECourseSchedules->MaxStudents->CellAttrs = array(); $CCECourseSchedules->MaxStudents->ViewAttrs = array(); $CCECourseSchedules->MaxStudents->EditAttrs = array();
if ($CCECourseSchedules->RowType == EW_ROWTYPE_VIEW) { // View row
// CCECourseScheduleID
$CCECourseSchedules->CCECourseScheduleID->ViewValue = $CCECourseSchedules->CCECourseScheduleID->CurrentValue;
$CCECourseSchedules->CCECourseScheduleID->CssStyle = "";
$CCECourseSchedules->CCECourseScheduleID->CssClass = "";
$CCECourseSchedules->CCECourseScheduleID->ViewCustomAttributes = "";
// CCECourseID
if (strval($CCECourseSchedules->CCECourseID->CurrentValue) <> "") {
$sFilterWrk = "`CCECourseID` = " . ew_AdjustSql($CCECourseSchedules->CCECourseID->CurrentValue) . "";
$sSqlWrk = "SELECT `CCECourseName` FROM `CCECourses`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CCECourseName`";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$CCECourseSchedules->CCECourseID->ViewValue = $rswrk->fields('CCECourseName');
$rswrk->Close();
} else {
$CCECourseSchedules->CCECourseID->ViewValue = $CCECourseSchedules->CCECourseID->CurrentValue;
}
} else {
$CCECourseSchedules->CCECourseID->ViewValue = NULL;
}
$CCECourseSchedules->CCECourseID->CssStyle = "";
$CCECourseSchedules->CCECourseID->CssClass = "";
$CCECourseSchedules->CCECourseID->ViewCustomAttributes = "";
// StartDate
$CCECourseSchedules->StartDate->ViewValue = $CCECourseSchedules->StartDate->CurrentValue;
$CCECourseSchedules->StartDate->ViewValue = ew_FormatDateTime($CCECourseSchedules->StartDate->ViewValue, 5);
$CCECourseSchedules->StartDate->CssStyle = "";
$CCECourseSchedules->StartDate->CssClass = "";
$CCECourseSchedules->StartDate->ViewCustomAttributes = "";
// EndDate
$CCECourseSchedules->EndDate->ViewValue = $CCECourseSchedules->EndDate->CurrentValue;
$CCECourseSchedules->EndDate->ViewValue = ew_FormatDateTime($CCECourseSchedules->EndDate->ViewValue, 5);
$CCECourseSchedules->EndDate->CssStyle = "";
$CCECourseSchedules->EndDate->CssClass = "";
$CCECourseSchedules->EndDate->ViewCustomAttributes = "";
// ReleaseDate
$CCECourseSchedules->ReleaseDate->ViewValue = $CCECourseSchedules->ReleaseDate->CurrentValue;
$CCECourseSchedules->ReleaseDate->ViewValue = ew_FormatDateTime($CCECourseSchedules->ReleaseDate->ViewValue, 5);
$CCECourseSchedules->ReleaseDate->CssStyle = "";
$CCECourseSchedules->ReleaseDate->CssClass = "";
$CCECourseSchedules->ReleaseDate->ViewCustomAttributes = "";
// RegistrationDeadline
$CCECourseSchedules->RegistrationDeadline->ViewValue = $CCECourseSchedules->RegistrationDeadline->CurrentValue;
$CCECourseSchedules->RegistrationDeadline->ViewValue = ew_FormatDateTime($CCECourseSchedules->RegistrationDeadline->ViewValue, 5);
$CCECourseSchedules->RegistrationDeadline->CssStyle = "";
$CCECourseSchedules->RegistrationDeadline->CssClass = "";
$CCECourseSchedules->RegistrationDeadline->ViewCustomAttributes = "";
// MaxStudents
$CCECourseSchedules->MaxStudents->ViewValue = $CCECourseSchedules->MaxStudents->CurrentValue;
$CCECourseSchedules->MaxStudents->CssStyle = "";
$CCECourseSchedules->MaxStudents->CssClass = "";
$CCECourseSchedules->MaxStudents->ViewCustomAttributes = "";
// CCECourseID
$CCECourseSchedules->CCECourseID->HrefValue = "";
$CCECourseSchedules->CCECourseID->TooltipValue = "";
// StartDate
$CCECourseSchedules->StartDate->HrefValue = "";
$CCECourseSchedules->StartDate->TooltipValue = "";
// EndDate
$CCECourseSchedules->EndDate->HrefValue = "";
$CCECourseSchedules->EndDate->TooltipValue = "";
// ReleaseDate
$CCECourseSchedules->ReleaseDate->HrefValue = "";
$CCECourseSchedules->ReleaseDate->TooltipValue = "";
// RegistrationDeadline
$CCECourseSchedules->RegistrationDeadline->HrefValue = "";
$CCECourseSchedules->RegistrationDeadline->TooltipValue = "";
// MaxStudents
$CCECourseSchedules->MaxStudents->HrefValue = "";
$CCECourseSchedules->MaxStudents->TooltipValue = "";
} elseif ($CCECourseSchedules->RowType == EW_ROWTYPE_ADD) { // Add row
// CCECourseID
$CCECourseSchedules->CCECourseID->EditCustomAttributes = "";
if ($CCECourseSchedules->CCECourseID->getSessionValue() <> "") {
$CCECourseSchedules->CCECourseID->CurrentValue = $CCECourseSchedules->CCECourseID->getSessionValue();
if (strval($CCECourseSchedules->CCECourseID->CurrentValue) <> "") {
$sFilterWrk = "`CCECourseID` = " . ew_AdjustSql($CCECourseSchedules->CCECourseID->CurrentValue) . "";
$sSqlWrk = "SELECT `CCECourseName` FROM `CCECourses`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CCECourseName`";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$CCECourseSchedules->CCECourseID->ViewValue = $rswrk->fields('CCECourseName');
$rswrk->Close();
} else {
$CCECourseSchedules->CCECourseID->ViewValue = $CCECourseSchedules->CCECourseID->CurrentValue;
}
} else {
$CCECourseSchedules->CCECourseID->ViewValue = NULL;
}
$CCECourseSchedules->CCECourseID->CssStyle = "";
$CCECourseSchedules->CCECourseID->CssClass = "";
$CCECourseSchedules->CCECourseID->ViewCustomAttributes = "";
} else {
$sFilterWrk = "";
$sSqlWrk = "SELECT `CCECourseID`, `CCECourseName`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCECourses`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CCECourseName`";
$rswrk = $conn->Execute($sSqlWrk);
$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
if ($rswrk) $rswrk->Close();
array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
$CCECourseSchedules->CCECourseID->EditValue = $arwrk;
}
// StartDate
$CCECourseSchedules->StartDate->EditCustomAttributes = "";
$CCECourseSchedules->StartDate->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCECourseSchedules->StartDate->CurrentValue, 5));
// EndDate
$CCECourseSchedules->EndDate->EditCustomAttributes = "";
$CCECourseSchedules->EndDate->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCECourseSchedules->EndDate->CurrentValue, 5));
// ReleaseDate
$CCECourseSchedules->ReleaseDate->EditCustomAttributes = "";
$CCECourseSchedules->ReleaseDate->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCECourseSchedules->ReleaseDate->CurrentValue, 5));
// RegistrationDeadline
$CCECourseSchedules->RegistrationDeadline->EditCustomAttributes = "";
$CCECourseSchedules->RegistrationDeadline->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCECourseSchedules->RegistrationDeadline->CurrentValue, 5));
// MaxStudents
$CCECourseSchedules->MaxStudents->EditCustomAttributes = "";
$CCECourseSchedules->MaxStudents->EditValue = ew_HtmlEncode($CCECourseSchedules->MaxStudents->CurrentValue);
}
// Call Row Rendered event
if ($CCECourseSchedules->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$CCECourseSchedules->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $CCECourseSchedules;
// Initialize form error message
$gsFormError = "";
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!is_null($CCECourseSchedules->StartDate->FormValue) && $CCECourseSchedules->StartDate->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CCECourseSchedules->StartDate->FldCaption();
}
if (!ew_CheckDate($CCECourseSchedules->StartDate->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCECourseSchedules->StartDate->FldErrMsg();
}
if (!is_null($CCECourseSchedules->EndDate->FormValue) && $CCECourseSchedules->EndDate->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CCECourseSchedules->EndDate->FldCaption();
}
if (!ew_CheckDate($CCECourseSchedules->EndDate->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCECourseSchedules->EndDate->FldErrMsg();
}
if (!is_null($CCECourseSchedules->ReleaseDate->FormValue) && $CCECourseSchedules->ReleaseDate->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CCECourseSchedules->ReleaseDate->FldCaption();
}
if (!ew_CheckDate($CCECourseSchedules->ReleaseDate->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCECourseSchedules->ReleaseDate->FldErrMsg();
}
if (!is_null($CCECourseSchedules->RegistrationDeadline->FormValue) && $CCECourseSchedules->RegistrationDeadline->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $CCECourseSchedules->RegistrationDeadline->FldCaption();
}
if (!ew_CheckDate($CCECourseSchedules->RegistrationDeadline->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCECourseSchedules->RegistrationDeadline->FldErrMsg();
}
if (!ew_CheckInteger($CCECourseSchedules->MaxStudents->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCECourseSchedules->MaxStudents->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, $CCECourseSchedules;
$rsnew = array();
// CCECourseID
$CCECourseSchedules->CCECourseID->SetDbValueDef($rsnew, $CCECourseSchedules->CCECourseID->CurrentValue, NULL, FALSE);
// StartDate
$CCECourseSchedules->StartDate->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCECourseSchedules->StartDate->CurrentValue, 5, FALSE), NULL);
// EndDate
$CCECourseSchedules->EndDate->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCECourseSchedules->EndDate->CurrentValue, 5, FALSE), NULL);
// ReleaseDate
$CCECourseSchedules->ReleaseDate->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCECourseSchedules->ReleaseDate->CurrentValue, 5, FALSE), NULL);
// RegistrationDeadline
$CCECourseSchedules->RegistrationDeadline->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCECourseSchedules->RegistrationDeadline->CurrentValue, 5, FALSE), NULL);
// MaxStudents
$CCECourseSchedules->MaxStudents->SetDbValueDef($rsnew, $CCECourseSchedules->MaxStudents->CurrentValue, NULL, FALSE);
// Call Row Inserting event
$bInsertRow = $CCECourseSchedules->Row_Inserting($rsnew);
if ($bInsertRow) {
$conn->raiseErrorFn = 'ew_ErrorFn';
$AddRow = $conn->Execute($CCECourseSchedules->InsertSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($CCECourseSchedules->CancelMessage <> "") {
$this->setMessage($CCECourseSchedules->CancelMessage);
$CCECourseSchedules->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("InsertCancelled"));
}
$AddRow = FALSE;
}
if ($AddRow) {
$CCECourseSchedules->CCECourseScheduleID->setDbValue($conn->Insert_ID());
$rsnew['CCECourseScheduleID'] = $CCECourseSchedules->CCECourseScheduleID->DbValue;
// Call Row Inserted event
$CCECourseSchedules->Row_Inserted($rsnew);
}
return $AddRow;
}
// Set up master/detail based on QueryString
function SetUpMasterDetail() {
global $CCECourseSchedules;
$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 == "CCECourses") {
$bValidMaster = TRUE;
$this->sDbMasterFilter = $CCECourseSchedules->SqlMasterFilter_CCECourses();
$this->sDbDetailFilter = $CCECourseSchedules->SqlDetailFilter_CCECourses();
if (@$_GET["CCECourseID"] <> "") {
$GLOBALS["CCECourses"]->CCECourseID->setQueryStringValue($_GET["CCECourseID"]);
$CCECourseSchedules->CCECourseID->setQueryStringValue($GLOBALS["CCECourses"]->CCECourseID->QueryStringValue);
$CCECourseSchedules->CCECourseID->setSessionValue($CCECourseSchedules->CCECourseID->QueryStringValue);
if (!is_numeric($GLOBALS["CCECourses"]->CCECourseID->QueryStringValue)) $bValidMaster = FALSE;
$this->sDbMasterFilter = str_replace("@CCECourseID@", ew_AdjustSql($GLOBALS["CCECourses"]->CCECourseID->QueryStringValue), $this->sDbMasterFilter);
$this->sDbDetailFilter = str_replace("@CCECourseID@", ew_AdjustSql($GLOBALS["CCECourses"]->CCECourseID->QueryStringValue), $this->sDbDetailFilter);
} else {
$bValidMaster = FALSE;
}
}
}
if ($bValidMaster) {
// Save current master table
$CCECourseSchedules->setCurrentMasterTable($sMasterTblVar);
// Reset start record counter (new master key)
$this->lStartRec = 1;
$CCECourseSchedules->setStartRecordNumber($this->lStartRec);
$CCECourseSchedules->setMasterFilter($this->sDbMasterFilter); // Set up master filter
$CCECourseSchedules->setDetailFilter($this->sDbDetailFilter); // Set up detail filter
// Clear previous master key from Session
if ($sMasterTblVar <> "CCECourses") {
if ($CCECourseSchedules->CCECourseID->QueryStringValue == "") $CCECourseSchedules->CCECourseID->setSessionValue("");
}
} else {
$this->sDbMasterFilter = $CCECourseSchedules->getMasterFilter(); // Restore master filter
$this->sDbDetailFilter = $CCECourseSchedules->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;
}
}
?>