| Current Path : /var/www/cesa.co.za/cceadmin/ |
| Current File : /var/www/cesa.co.za/cceadmin/cstArchivedDocumentsedit.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 "cstArchivedDocumentsinfo.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
$cstArchivedDocuments_edit = new ccstArchivedDocuments_edit();
$Page =& $cstArchivedDocuments_edit;
// Page init
$cstArchivedDocuments_edit->Page_Init();
// Page main
$cstArchivedDocuments_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var cstArchivedDocuments_edit = new ew_Page("cstArchivedDocuments_edit");
// page properties
cstArchivedDocuments_edit.PageID = "edit"; // page ID
cstArchivedDocuments_edit.FormID = "fcstArchivedDocumentsedit"; // form ID
var EW_PAGE_ID = cstArchivedDocuments_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
cstArchivedDocuments_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) : "";
elm = fobj.elements["x" + infix + "_DocumentCategory"];
if (elm && !ew_HasValue(elm))
return ew_OnError(this, elm, ewLanguage.Phrase("EnterRequiredField") + " - <?php echo ew_JsEncode2($cstArchivedDocuments->DocumentCategory->FldCaption()) ?>");
elm = fobj.elements["x" + infix + "_DocumentFile"];
if (elm && !ew_CheckFileType(elm.value))
return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
elm = fobj.elements["x" + infix + "_Archived"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($cstArchivedDocuments->Archived->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_ArchiveYear"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($cstArchivedDocuments->ArchiveYear->FldErrMsg()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
cstArchivedDocuments_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) { ?>
cstArchivedDocuments_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
cstArchivedDocuments_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("TblTypeCUSTOMVIEW") ?><?php echo $cstArchivedDocuments->TableCaption() ?><br><br>
<a href="<?php echo $cstArchivedDocuments->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$cstArchivedDocuments_edit->ShowMessage();
?>
<form name="fcstArchivedDocumentsedit" id="fcstArchivedDocumentsedit" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return cstArchivedDocuments_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="cstArchivedDocuments">
<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">
<input type="hidden" name="x_CCEDocumentID" id="x_CCEDocumentID" value="<?php echo ew_HtmlEncode($cstArchivedDocuments->CCEDocumentID->CurrentValue) ?>">
<?php if ($cstArchivedDocuments->CCEModuleID->Visible) { // CCEModuleID ?>
<tr<?php echo $cstArchivedDocuments->CCEModuleID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->CCEModuleID->FldCaption() ?></td>
<td<?php echo $cstArchivedDocuments->CCEModuleID->CellAttributes() ?>><span id="el_CCEModuleID">
<select id="x_CCEModuleID" name="x_CCEModuleID" title="<?php echo $cstArchivedDocuments->CCEModuleID->FldTitle() ?>"<?php echo $cstArchivedDocuments->CCEModuleID->EditAttributes() ?>>
<?php
if (is_array($cstArchivedDocuments->CCEModuleID->EditValue)) {
$arwrk = $cstArchivedDocuments->CCEModuleID->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($cstArchivedDocuments->CCEModuleID->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>
</span><?php echo $cstArchivedDocuments->CCEModuleID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->DocumentCategory->Visible) { // DocumentCategory ?>
<tr<?php echo $cstArchivedDocuments->DocumentCategory->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->DocumentCategory->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $cstArchivedDocuments->DocumentCategory->CellAttributes() ?>><span id="el_DocumentCategory">
<select id="x_DocumentCategory" name="x_DocumentCategory" title="<?php echo $cstArchivedDocuments->DocumentCategory->FldTitle() ?>"<?php echo $cstArchivedDocuments->DocumentCategory->EditAttributes() ?>>
<?php
if (is_array($cstArchivedDocuments->DocumentCategory->EditValue)) {
$arwrk = $cstArchivedDocuments->DocumentCategory->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($cstArchivedDocuments->DocumentCategory->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>
</span><?php echo $cstArchivedDocuments->DocumentCategory->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->DocumentName->Visible) { // DocumentName ?>
<tr<?php echo $cstArchivedDocuments->DocumentName->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->DocumentName->FldCaption() ?></td>
<td<?php echo $cstArchivedDocuments->DocumentName->CellAttributes() ?>><span id="el_DocumentName">
<input type="text" name="x_DocumentName" id="x_DocumentName" title="<?php echo $cstArchivedDocuments->DocumentName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $cstArchivedDocuments->DocumentName->EditValue ?>"<?php echo $cstArchivedDocuments->DocumentName->EditAttributes() ?>>
</span><?php echo $cstArchivedDocuments->DocumentName->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->DocumentFile->Visible) { // DocumentFile ?>
<tr<?php echo $cstArchivedDocuments->DocumentFile->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->DocumentFile->FldCaption() ?></td>
<td<?php echo $cstArchivedDocuments->DocumentFile->CellAttributes() ?>><span id="el_DocumentFile">
<div id="old_x_DocumentFile">
<?php if ($cstArchivedDocuments->DocumentFile->HrefValue <> "" || $cstArchivedDocuments->DocumentFile->TooltipValue <> "") { ?>
<?php if (!empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) { ?>
<a href="<?php echo $cstArchivedDocuments->DocumentFile->HrefValue ?>"><?php echo $cstArchivedDocuments->DocumentFile->EditValue ?></a>
<?php } elseif (!in_array($cstArchivedDocuments->CurrentAction, array("I", "edit", "gridedit"))) { ?>
<?php } ?>
<?php } else { ?>
<?php if (!empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) { ?>
<?php echo $cstArchivedDocuments->DocumentFile->EditValue ?>
<?php } elseif (!in_array($cstArchivedDocuments->CurrentAction, array("I", "edit", "gridedit"))) { ?>
<?php } ?>
<?php } ?>
</div>
<div id="new_x_DocumentFile">
<?php if (!empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) { ?>
<label><input type="radio" name="a_DocumentFile" id="a_DocumentFile" value="1" checked="checked"><?php echo $Language->Phrase("Keep") ?></label>
<label><input type="radio" name="a_DocumentFile" id="a_DocumentFile" value="2"><?php echo $Language->Phrase("Remove") ?></label>
<label><input type="radio" name="a_DocumentFile" id="a_DocumentFile" value="3"><?php echo $Language->Phrase("Replace") ?><br></label>
<?php $cstArchivedDocuments->DocumentFile->EditAttrs["onchange"] = "this.form.a_DocumentFile[2].checked=true;" . @$cstArchivedDocuments->DocumentFile->EditAttrs["onchange"]; ?>
<?php } else { ?>
<input type="hidden" name="a_DocumentFile" id="a_DocumentFile" value="3">
<?php } ?>
<input type="file" name="x_DocumentFile" id="x_DocumentFile" title="<?php echo $cstArchivedDocuments->DocumentFile->FldTitle() ?>" size="30"<?php echo $cstArchivedDocuments->DocumentFile->EditAttributes() ?>>
</div>
</span><?php echo $cstArchivedDocuments->DocumentFile->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->DocumentURL->Visible) { // DocumentURL ?>
<tr<?php echo $cstArchivedDocuments->DocumentURL->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->DocumentURL->FldCaption() ?></td>
<td<?php echo $cstArchivedDocuments->DocumentURL->CellAttributes() ?>><span id="el_DocumentURL">
<input type="text" name="x_DocumentURL" id="x_DocumentURL" title="<?php echo $cstArchivedDocuments->DocumentURL->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $cstArchivedDocuments->DocumentURL->EditValue ?>"<?php echo $cstArchivedDocuments->DocumentURL->EditAttributes() ?>>
</span><?php echo $cstArchivedDocuments->DocumentURL->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->UploadedBy->Visible) { // UploadedBy ?>
<tr<?php echo $cstArchivedDocuments->UploadedBy->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->UploadedBy->FldCaption() ?></td>
<td<?php echo $cstArchivedDocuments->UploadedBy->CellAttributes() ?>><span id="el_UploadedBy">
<select id="x_UploadedBy" name="x_UploadedBy" title="<?php echo $cstArchivedDocuments->UploadedBy->FldTitle() ?>"<?php echo $cstArchivedDocuments->UploadedBy->EditAttributes() ?>>
<?php
if (is_array($cstArchivedDocuments->UploadedBy->EditValue)) {
$arwrk = $cstArchivedDocuments->UploadedBy->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($cstArchivedDocuments->UploadedBy->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>
</span><?php echo $cstArchivedDocuments->UploadedBy->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->Archived->Visible) { // Archived ?>
<tr<?php echo $cstArchivedDocuments->Archived->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->Archived->FldCaption() ?><?php echo $Language->Phrase("FieldRequiredIndicator") ?></td>
<td<?php echo $cstArchivedDocuments->Archived->CellAttributes() ?>><span id="el_Archived">
<input type="text" name="x_Archived" id="x_Archived" title="<?php echo $cstArchivedDocuments->Archived->FldTitle() ?>" size="30" value="<?php echo $cstArchivedDocuments->Archived->EditValue ?>"<?php echo $cstArchivedDocuments->Archived->EditAttributes() ?>>
</span><?php echo $cstArchivedDocuments->Archived->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($cstArchivedDocuments->ArchiveYear->Visible) { // ArchiveYear ?>
<tr<?php echo $cstArchivedDocuments->ArchiveYear->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $cstArchivedDocuments->ArchiveYear->FldCaption() ?></td>
<td<?php echo $cstArchivedDocuments->ArchiveYear->CellAttributes() ?>><span id="el_ArchiveYear">
<input type="text" name="x_ArchiveYear" id="x_ArchiveYear" title="<?php echo $cstArchivedDocuments->ArchiveYear->FldTitle() ?>" size="30" value="<?php echo $cstArchivedDocuments->ArchiveYear->EditValue ?>"<?php echo $cstArchivedDocuments->ArchiveYear->EditAttributes() ?>>
</span><?php echo $cstArchivedDocuments->ArchiveYear->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
$cstArchivedDocuments_edit->Page_Terminate();
?>
<?php
//
// Page class
//
class ccstArchivedDocuments_edit {
// Page ID
var $PageID = 'edit';
// Table name
var $TableName = 'cstArchivedDocuments';
// Page object name
var $PageObjName = 'cstArchivedDocuments_edit';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $cstArchivedDocuments;
if ($cstArchivedDocuments->UseTokenInUrl) $PageUrl .= "t=" . $cstArchivedDocuments->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, $cstArchivedDocuments;
if ($cstArchivedDocuments->UseTokenInUrl) {
if ($objForm)
return ($cstArchivedDocuments->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($cstArchivedDocuments->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function __construct() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (cstArchivedDocuments)
$GLOBALS["cstArchivedDocuments"] = new ccstArchivedDocuments();
// Table object (CCEUsers)
$GLOBALS['CCEUsers'] = new cCCEUsers();
// 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", 'cstArchivedDocuments', 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 $cstArchivedDocuments;
// 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("cstArchivedDocumentslist.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, $cstArchivedDocuments;
// Load key from QueryString
if (@$_GET["CCEDocumentID"] <> "")
$cstArchivedDocuments->CCEDocumentID->setQueryStringValue($_GET["CCEDocumentID"]);
if (@$_POST["a_edit"] <> "") {
$cstArchivedDocuments->CurrentAction = $_POST["a_edit"]; // Get action code
$this->GetUploadFiles(); // Get upload files
$this->LoadFormValues(); // Get form values
// Validate form
if (!$this->ValidateForm()) {
$cstArchivedDocuments->CurrentAction = ""; // Form error, reset action
$this->setMessage($gsFormError);
$cstArchivedDocuments->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues();
}
} else {
$cstArchivedDocuments->CurrentAction = "I"; // Default action is display
}
// Check if valid key
if ($cstArchivedDocuments->CCEDocumentID->CurrentValue == "")
$this->Page_Terminate("cstArchivedDocumentslist.php"); // Invalid key, return to list
switch ($cstArchivedDocuments->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("cstArchivedDocumentslist.php"); // No matching record, return to list
}
break;
Case "U": // Update
$cstArchivedDocuments->SendEmail = TRUE; // Send email on update success
if ($this->EditRow()) { // Update record based on key
$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
$sReturnUrl = $cstArchivedDocuments->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "cstArchivedDocumentsview.php")
$sReturnUrl = $cstArchivedDocuments->ViewUrl(); // View paging, return to View page directly
$this->Page_Terminate($sReturnUrl); // Return to caller
} else {
$cstArchivedDocuments->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues(); // Restore form values if update failed
}
}
// Render the record
$cstArchivedDocuments->RowType = EW_ROWTYPE_EDIT; // Render as Edit
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $cstArchivedDocuments;
// Get upload data
if ($cstArchivedDocuments->DocumentFile->Upload->UploadFile()) {
// No action required
} else {
echo $cstArchivedDocuments->DocumentFile->Upload->Message;
$this->Page_Terminate();
exit();
}
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $cstArchivedDocuments;
$cstArchivedDocuments->CCEDocumentID->setFormValue($objForm->GetValue("x_CCEDocumentID"));
$cstArchivedDocuments->CCEModuleID->setFormValue($objForm->GetValue("x_CCEModuleID"));
$cstArchivedDocuments->DocumentCategory->setFormValue($objForm->GetValue("x_DocumentCategory"));
$cstArchivedDocuments->DocumentName->setFormValue($objForm->GetValue("x_DocumentName"));
$cstArchivedDocuments->DocumentURL->setFormValue($objForm->GetValue("x_DocumentURL"));
$cstArchivedDocuments->UploadedBy->setFormValue($objForm->GetValue("x_UploadedBy"));
$cstArchivedDocuments->Archived->setFormValue($objForm->GetValue("x_Archived"));
$cstArchivedDocuments->ArchiveYear->setFormValue($objForm->GetValue("x_ArchiveYear"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $cstArchivedDocuments;
$this->LoadRow();
$cstArchivedDocuments->CCEDocumentID->CurrentValue = $cstArchivedDocuments->CCEDocumentID->FormValue;
$cstArchivedDocuments->CCEModuleID->CurrentValue = $cstArchivedDocuments->CCEModuleID->FormValue;
$cstArchivedDocuments->DocumentCategory->CurrentValue = $cstArchivedDocuments->DocumentCategory->FormValue;
$cstArchivedDocuments->DocumentName->CurrentValue = $cstArchivedDocuments->DocumentName->FormValue;
$cstArchivedDocuments->DocumentURL->CurrentValue = $cstArchivedDocuments->DocumentURL->FormValue;
$cstArchivedDocuments->UploadedBy->CurrentValue = $cstArchivedDocuments->UploadedBy->FormValue;
$cstArchivedDocuments->Archived->CurrentValue = $cstArchivedDocuments->Archived->FormValue;
$cstArchivedDocuments->ArchiveYear->CurrentValue = $cstArchivedDocuments->ArchiveYear->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $cstArchivedDocuments;
$sFilter = $cstArchivedDocuments->KeyFilter();
// Call Row Selecting event
$cstArchivedDocuments->Row_Selecting($sFilter);
// Load SQL based on filter
$cstArchivedDocuments->CurrentFilter = $sFilter;
$sSql = $cstArchivedDocuments->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$cstArchivedDocuments->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $cstArchivedDocuments;
$cstArchivedDocuments->CCEDocumentID->setDbValue($rs->fields('CCEDocumentID'));
$cstArchivedDocuments->CCEModuleID->setDbValue($rs->fields('CCEModuleID'));
$cstArchivedDocuments->DocumentCategory->setDbValue($rs->fields('DocumentCategory'));
$cstArchivedDocuments->DocumentName->setDbValue($rs->fields('DocumentName'));
$cstArchivedDocuments->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile');
$cstArchivedDocuments->DocumentURL->setDbValue($rs->fields('DocumentURL'));
$cstArchivedDocuments->DocumentThumb->setDbValue($rs->fields('DocumentThumb'));
$cstArchivedDocuments->UploadedBy->setDbValue($rs->fields('UploadedBy'));
$cstArchivedDocuments->Archived->setDbValue($rs->fields('Archived'));
$cstArchivedDocuments->ArchiveYear->setDbValue($rs->fields('ArchiveYear'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $cstArchivedDocuments;
// Initialize URLs
// Call Row_Rendering event
$cstArchivedDocuments->Row_Rendering();
// Common render codes for all row types
// CCEDocumentID
$cstArchivedDocuments->CCEDocumentID->CellCssStyle = ""; $cstArchivedDocuments->CCEDocumentID->CellCssClass = "";
$cstArchivedDocuments->CCEDocumentID->CellAttrs = array(); $cstArchivedDocuments->CCEDocumentID->ViewAttrs = array(); $cstArchivedDocuments->CCEDocumentID->EditAttrs = array();
// CCEModuleID
$cstArchivedDocuments->CCEModuleID->CellCssStyle = ""; $cstArchivedDocuments->CCEModuleID->CellCssClass = "";
$cstArchivedDocuments->CCEModuleID->CellAttrs = array(); $cstArchivedDocuments->CCEModuleID->ViewAttrs = array(); $cstArchivedDocuments->CCEModuleID->EditAttrs = array();
// DocumentCategory
$cstArchivedDocuments->DocumentCategory->CellCssStyle = ""; $cstArchivedDocuments->DocumentCategory->CellCssClass = "";
$cstArchivedDocuments->DocumentCategory->CellAttrs = array(); $cstArchivedDocuments->DocumentCategory->ViewAttrs = array(); $cstArchivedDocuments->DocumentCategory->EditAttrs = array();
// DocumentName
$cstArchivedDocuments->DocumentName->CellCssStyle = ""; $cstArchivedDocuments->DocumentName->CellCssClass = "";
$cstArchivedDocuments->DocumentName->CellAttrs = array(); $cstArchivedDocuments->DocumentName->ViewAttrs = array(); $cstArchivedDocuments->DocumentName->EditAttrs = array();
// DocumentFile
$cstArchivedDocuments->DocumentFile->CellCssStyle = ""; $cstArchivedDocuments->DocumentFile->CellCssClass = "";
$cstArchivedDocuments->DocumentFile->CellAttrs = array(); $cstArchivedDocuments->DocumentFile->ViewAttrs = array(); $cstArchivedDocuments->DocumentFile->EditAttrs = array();
// DocumentURL
$cstArchivedDocuments->DocumentURL->CellCssStyle = ""; $cstArchivedDocuments->DocumentURL->CellCssClass = "";
$cstArchivedDocuments->DocumentURL->CellAttrs = array(); $cstArchivedDocuments->DocumentURL->ViewAttrs = array(); $cstArchivedDocuments->DocumentURL->EditAttrs = array();
// UploadedBy
$cstArchivedDocuments->UploadedBy->CellCssStyle = ""; $cstArchivedDocuments->UploadedBy->CellCssClass = "";
$cstArchivedDocuments->UploadedBy->CellAttrs = array(); $cstArchivedDocuments->UploadedBy->ViewAttrs = array(); $cstArchivedDocuments->UploadedBy->EditAttrs = array();
// Archived
$cstArchivedDocuments->Archived->CellCssStyle = ""; $cstArchivedDocuments->Archived->CellCssClass = "";
$cstArchivedDocuments->Archived->CellAttrs = array(); $cstArchivedDocuments->Archived->ViewAttrs = array(); $cstArchivedDocuments->Archived->EditAttrs = array();
// ArchiveYear
$cstArchivedDocuments->ArchiveYear->CellCssStyle = ""; $cstArchivedDocuments->ArchiveYear->CellCssClass = "";
$cstArchivedDocuments->ArchiveYear->CellAttrs = array(); $cstArchivedDocuments->ArchiveYear->ViewAttrs = array(); $cstArchivedDocuments->ArchiveYear->EditAttrs = array();
if ($cstArchivedDocuments->RowType == EW_ROWTYPE_VIEW) { // View row
// CCEDocumentID
$cstArchivedDocuments->CCEDocumentID->ViewValue = $cstArchivedDocuments->CCEDocumentID->CurrentValue;
$cstArchivedDocuments->CCEDocumentID->CssStyle = "";
$cstArchivedDocuments->CCEDocumentID->CssClass = "";
$cstArchivedDocuments->CCEDocumentID->ViewCustomAttributes = "";
// CCEModuleID
if (strval($cstArchivedDocuments->CCEModuleID->CurrentValue) <> "") {
$sFilterWrk = "CCEModules.CCEModuleID = " . ew_AdjustSql($cstArchivedDocuments->CCEModuleID->CurrentValue) . "";
$sSqlWrk = "SELECT CCEModules.ModuleNum AS `ModuleNum`, CCEModules.ModuleName AS `ModuleName` FROM CCECourses Inner Join CCEModules On CCECourses.CCECourseID = CCEModules.CCECourseID";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY CCECourses.CCECourseID, CCEModules.ModuleNum";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$cstArchivedDocuments->CCEModuleID->ViewValue = $rswrk->fields('ModuleNum');
$cstArchivedDocuments->CCEModuleID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('ModuleName');
$rswrk->Close();
} else {
$cstArchivedDocuments->CCEModuleID->ViewValue = $cstArchivedDocuments->CCEModuleID->CurrentValue;
}
} else {
$cstArchivedDocuments->CCEModuleID->ViewValue = NULL;
}
$cstArchivedDocuments->CCEModuleID->CssStyle = "";
$cstArchivedDocuments->CCEModuleID->CssClass = "";
$cstArchivedDocuments->CCEModuleID->ViewCustomAttributes = "";
// DocumentCategory
if (strval($cstArchivedDocuments->DocumentCategory->CurrentValue) <> "") {
$sFilterWrk = "`CCEDocCategoryID` = " . ew_AdjustSql($cstArchivedDocuments->DocumentCategory->CurrentValue) . "";
$sSqlWrk = "SELECT `CategoryName` FROM `CCEDocCategories`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CategoryName`";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$cstArchivedDocuments->DocumentCategory->ViewValue = $rswrk->fields('CategoryName');
$rswrk->Close();
} else {
$cstArchivedDocuments->DocumentCategory->ViewValue = $cstArchivedDocuments->DocumentCategory->CurrentValue;
}
} else {
$cstArchivedDocuments->DocumentCategory->ViewValue = NULL;
}
$cstArchivedDocuments->DocumentCategory->CssStyle = "";
$cstArchivedDocuments->DocumentCategory->CssClass = "";
$cstArchivedDocuments->DocumentCategory->ViewCustomAttributes = "";
// DocumentName
$cstArchivedDocuments->DocumentName->ViewValue = $cstArchivedDocuments->DocumentName->CurrentValue;
$cstArchivedDocuments->DocumentName->CssStyle = "";
$cstArchivedDocuments->DocumentName->CssClass = "";
$cstArchivedDocuments->DocumentName->ViewCustomAttributes = "";
// DocumentFile
if (!ew_Empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) {
$cstArchivedDocuments->DocumentFile->ViewValue = $cstArchivedDocuments->DocumentFile->Upload->DbValue;
} else {
$cstArchivedDocuments->DocumentFile->ViewValue = "";
}
$cstArchivedDocuments->DocumentFile->CssStyle = "";
$cstArchivedDocuments->DocumentFile->CssClass = "";
$cstArchivedDocuments->DocumentFile->ViewCustomAttributes = "";
// DocumentURL
$cstArchivedDocuments->DocumentURL->ViewValue = $cstArchivedDocuments->DocumentURL->CurrentValue;
$cstArchivedDocuments->DocumentURL->CssStyle = "";
$cstArchivedDocuments->DocumentURL->CssClass = "";
$cstArchivedDocuments->DocumentURL->ViewCustomAttributes = "";
// UploadedBy
if (strval($cstArchivedDocuments->UploadedBy->CurrentValue) <> "") {
$sFilterWrk = "`FacilitatorID` = " . ew_AdjustSql($cstArchivedDocuments->UploadedBy->CurrentValue) . "";
$sSqlWrk = "SELECT `FacilitatorName` FROM `CCEFacilitators`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `FacilitatorName`";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$cstArchivedDocuments->UploadedBy->ViewValue = $rswrk->fields('FacilitatorName');
$rswrk->Close();
} else {
$cstArchivedDocuments->UploadedBy->ViewValue = $cstArchivedDocuments->UploadedBy->CurrentValue;
}
} else {
$cstArchivedDocuments->UploadedBy->ViewValue = NULL;
}
$cstArchivedDocuments->UploadedBy->CssStyle = "";
$cstArchivedDocuments->UploadedBy->CssClass = "";
$cstArchivedDocuments->UploadedBy->ViewCustomAttributes = "";
// Archived
$cstArchivedDocuments->Archived->ViewValue = $cstArchivedDocuments->Archived->CurrentValue;
$cstArchivedDocuments->Archived->CssStyle = "";
$cstArchivedDocuments->Archived->CssClass = "";
$cstArchivedDocuments->Archived->ViewCustomAttributes = "";
// ArchiveYear
$cstArchivedDocuments->ArchiveYear->ViewValue = $cstArchivedDocuments->ArchiveYear->CurrentValue;
$cstArchivedDocuments->ArchiveYear->CssStyle = "";
$cstArchivedDocuments->ArchiveYear->CssClass = "";
$cstArchivedDocuments->ArchiveYear->ViewCustomAttributes = "";
// CCEDocumentID
$cstArchivedDocuments->CCEDocumentID->HrefValue = "";
$cstArchivedDocuments->CCEDocumentID->TooltipValue = "";
// CCEModuleID
$cstArchivedDocuments->CCEModuleID->HrefValue = "";
$cstArchivedDocuments->CCEModuleID->TooltipValue = "";
// DocumentCategory
$cstArchivedDocuments->DocumentCategory->HrefValue = "";
$cstArchivedDocuments->DocumentCategory->TooltipValue = "";
// DocumentName
$cstArchivedDocuments->DocumentName->HrefValue = "";
$cstArchivedDocuments->DocumentName->TooltipValue = "";
// DocumentFile
if (!ew_Empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) {
$cstArchivedDocuments->DocumentFile->HrefValue = ew_UploadPathEx(FALSE, $cstArchivedDocuments->DocumentFile->UploadPath) . ((!empty($cstArchivedDocuments->DocumentFile->ViewValue)) ? $cstArchivedDocuments->DocumentFile->ViewValue : $cstArchivedDocuments->DocumentFile->CurrentValue);
if ($cstArchivedDocuments->Export <> "") $cstArchivedDocuments->DocumentFile->HrefValue = ew_ConvertFullUrl($cstArchivedDocuments->DocumentFile->HrefValue);
} else {
$cstArchivedDocuments->DocumentFile->HrefValue = "";
}
$cstArchivedDocuments->DocumentFile->TooltipValue = "";
// DocumentURL
$cstArchivedDocuments->DocumentURL->HrefValue = "";
$cstArchivedDocuments->DocumentURL->TooltipValue = "";
// UploadedBy
$cstArchivedDocuments->UploadedBy->HrefValue = "";
$cstArchivedDocuments->UploadedBy->TooltipValue = "";
// Archived
$cstArchivedDocuments->Archived->HrefValue = "";
$cstArchivedDocuments->Archived->TooltipValue = "";
// ArchiveYear
$cstArchivedDocuments->ArchiveYear->HrefValue = "";
$cstArchivedDocuments->ArchiveYear->TooltipValue = "";
} elseif ($cstArchivedDocuments->RowType == EW_ROWTYPE_EDIT) { // Edit row
// CCEDocumentID
$cstArchivedDocuments->CCEDocumentID->EditCustomAttributes = "";
// CCEModuleID
$cstArchivedDocuments->CCEModuleID->EditCustomAttributes = "";
$sFilterWrk = "";
$sSqlWrk = "SELECT CCEModules.CCEModuleID, CCEModules.ModuleNum, CCEModules.ModuleName, '' AS SelectFilterFld FROM CCECourses Inner Join CCEModules On CCECourses.CCECourseID = CCEModules.CCECourseID";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY CCECourses.CCECourseID, CCEModules.ModuleNum";
$rswrk = $conn->Execute($sSqlWrk);
$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
if ($rswrk) $rswrk->Close();
array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect"), ""));
$cstArchivedDocuments->CCEModuleID->EditValue = $arwrk;
// DocumentCategory
$cstArchivedDocuments->DocumentCategory->EditCustomAttributes = "";
$sFilterWrk = "";
$sSqlWrk = "SELECT `CCEDocCategoryID`, `CategoryName`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCEDocCategories`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CategoryName`";
$rswrk = $conn->Execute($sSqlWrk);
$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
if ($rswrk) $rswrk->Close();
array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
$cstArchivedDocuments->DocumentCategory->EditValue = $arwrk;
// DocumentName
$cstArchivedDocuments->DocumentName->EditCustomAttributes = "";
$cstArchivedDocuments->DocumentName->EditValue = ew_HtmlEncode($cstArchivedDocuments->DocumentName->CurrentValue);
// DocumentFile
$cstArchivedDocuments->DocumentFile->EditCustomAttributes = "";
if (!ew_Empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) {
$cstArchivedDocuments->DocumentFile->EditValue = $cstArchivedDocuments->DocumentFile->Upload->DbValue;
} else {
$cstArchivedDocuments->DocumentFile->EditValue = "";
}
// DocumentURL
$cstArchivedDocuments->DocumentURL->EditCustomAttributes = "";
$cstArchivedDocuments->DocumentURL->EditValue = ew_HtmlEncode($cstArchivedDocuments->DocumentURL->CurrentValue);
// UploadedBy
$cstArchivedDocuments->UploadedBy->EditCustomAttributes = "";
$sFilterWrk = "";
$sSqlWrk = "SELECT `FacilitatorID`, `FacilitatorName`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `CCEFacilitators`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `FacilitatorName`";
$rswrk = $conn->Execute($sSqlWrk);
$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
if ($rswrk) $rswrk->Close();
array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
$cstArchivedDocuments->UploadedBy->EditValue = $arwrk;
// Archived
$cstArchivedDocuments->Archived->EditCustomAttributes = "";
$cstArchivedDocuments->Archived->EditValue = ew_HtmlEncode($cstArchivedDocuments->Archived->CurrentValue);
// ArchiveYear
$cstArchivedDocuments->ArchiveYear->EditCustomAttributes = "";
$cstArchivedDocuments->ArchiveYear->EditValue = ew_HtmlEncode($cstArchivedDocuments->ArchiveYear->CurrentValue);
// Edit refer script
// CCEDocumentID
$cstArchivedDocuments->CCEDocumentID->HrefValue = "";
// CCEModuleID
$cstArchivedDocuments->CCEModuleID->HrefValue = "";
// DocumentCategory
$cstArchivedDocuments->DocumentCategory->HrefValue = "";
// DocumentName
$cstArchivedDocuments->DocumentName->HrefValue = "";
// DocumentFile
if (!ew_Empty($cstArchivedDocuments->DocumentFile->Upload->DbValue)) {
$cstArchivedDocuments->DocumentFile->HrefValue = ew_UploadPathEx(FALSE, $cstArchivedDocuments->DocumentFile->UploadPath) . ((!empty($cstArchivedDocuments->DocumentFile->EditValue)) ? $cstArchivedDocuments->DocumentFile->EditValue : $cstArchivedDocuments->DocumentFile->CurrentValue);
if ($cstArchivedDocuments->Export <> "") $cstArchivedDocuments->DocumentFile->HrefValue = ew_ConvertFullUrl($cstArchivedDocuments->DocumentFile->HrefValue);
} else {
$cstArchivedDocuments->DocumentFile->HrefValue = "";
}
// DocumentURL
$cstArchivedDocuments->DocumentURL->HrefValue = "";
// UploadedBy
$cstArchivedDocuments->UploadedBy->HrefValue = "";
// Archived
$cstArchivedDocuments->Archived->HrefValue = "";
// ArchiveYear
$cstArchivedDocuments->ArchiveYear->HrefValue = "";
}
// Call Row Rendered event
if ($cstArchivedDocuments->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$cstArchivedDocuments->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $cstArchivedDocuments;
// Initialize form error message
$gsFormError = "";
if (!ew_CheckFileType($cstArchivedDocuments->DocumentFile->Upload->FileName)) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("WrongFileType");
}
if ($cstArchivedDocuments->DocumentFile->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $cstArchivedDocuments->DocumentFile->Upload->FileSize > EW_MAX_FILE_SIZE) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
}
if (in_array($cstArchivedDocuments->DocumentFile->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("PhpUploadErr" . $cstArchivedDocuments->DocumentFile->Upload->Error);
}
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!is_null($cstArchivedDocuments->DocumentCategory->FormValue) && $cstArchivedDocuments->DocumentCategory->FormValue == "") {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("EnterRequiredField") . " - " . $cstArchivedDocuments->DocumentCategory->FldCaption();
}
if (!ew_CheckInteger($cstArchivedDocuments->Archived->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $cstArchivedDocuments->Archived->FldErrMsg();
}
if (!ew_CheckInteger($cstArchivedDocuments->ArchiveYear->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $cstArchivedDocuments->ArchiveYear->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;
}
// Update record based on key values
function EditRow() {
global $conn, $Security, $Language, $cstArchivedDocuments;
$sFilter = $cstArchivedDocuments->KeyFilter();
$cstArchivedDocuments->CurrentFilter = $sFilter;
$sSql = $cstArchivedDocuments->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();
// CCEModuleID
$cstArchivedDocuments->CCEModuleID->SetDbValueDef($rsnew, $cstArchivedDocuments->CCEModuleID->CurrentValue, NULL, FALSE);
// DocumentCategory
$cstArchivedDocuments->DocumentCategory->SetDbValueDef($rsnew, $cstArchivedDocuments->DocumentCategory->CurrentValue, NULL, FALSE);
// DocumentName
$cstArchivedDocuments->DocumentName->SetDbValueDef($rsnew, $cstArchivedDocuments->DocumentName->CurrentValue, NULL, FALSE);
// DocumentFile
$cstArchivedDocuments->DocumentFile->Upload->SaveToSession(); // Save file value to Session
if ($cstArchivedDocuments->DocumentFile->Upload->Action == "2" || $cstArchivedDocuments->DocumentFile->Upload->Action == "3") { // Update/Remove
$cstArchivedDocuments->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile'); // Get original value
if (is_null($cstArchivedDocuments->DocumentFile->Upload->Value)) {
$rsnew['DocumentFile'] = NULL;
} else {
$rsnew['DocumentFile'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $cstArchivedDocuments->DocumentFile->UploadPath), $cstArchivedDocuments->DocumentFile->Upload->FileName);
}
}
// DocumentURL
$cstArchivedDocuments->DocumentURL->SetDbValueDef($rsnew, $cstArchivedDocuments->DocumentURL->CurrentValue, NULL, FALSE);
// UploadedBy
$cstArchivedDocuments->UploadedBy->SetDbValueDef($rsnew, $cstArchivedDocuments->UploadedBy->CurrentValue, NULL, FALSE);
// Archived
$cstArchivedDocuments->Archived->SetDbValueDef($rsnew, $cstArchivedDocuments->Archived->CurrentValue, 0, FALSE);
// ArchiveYear
$cstArchivedDocuments->ArchiveYear->SetDbValueDef($rsnew, $cstArchivedDocuments->ArchiveYear->CurrentValue, NULL, FALSE);
// Call Row Updating event
$bUpdateRow = $cstArchivedDocuments->Row_Updating($rsold, $rsnew);
if ($bUpdateRow) {
if (!ew_Empty($cstArchivedDocuments->DocumentFile->Upload->Value)) {
$cstArchivedDocuments->DocumentFile->Upload->SaveToFile($cstArchivedDocuments->DocumentFile->UploadPath, $rsnew['DocumentFile'], FALSE);
}
$conn->raiseErrorFn = 'ew_ErrorFn';
$EditRow = $conn->Execute($cstArchivedDocuments->UpdateSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($cstArchivedDocuments->CancelMessage <> "") {
$this->setMessage($cstArchivedDocuments->CancelMessage);
$cstArchivedDocuments->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("UpdateCancelled"));
}
$EditRow = FALSE;
}
}
// Call Row_Updated event
if ($EditRow)
$cstArchivedDocuments->Row_Updated($rsold, $rsnew);
$rs->Close();
// DocumentFile
$cstArchivedDocuments->DocumentFile->Upload->RemoveFromSession(); // Remove file value from Session
return $EditRow;
}
// 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;
}
}
?>