| Current Path : /var/www/cesa.co.za/cceconvenors/ |
| Current File : /var/www/cesa.co.za/cceconvenors/CCEBooksedit.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 "CCEBooksinfo.php" ?>
<?php include "CCEFacilitatorUsersinfo.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
$CCEBooks_edit = new cCCEBooks_edit();
$Page =& $CCEBooks_edit;
// Page init
$CCEBooks_edit->Page_Init();
// Page main
$CCEBooks_edit->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var CCEBooks_edit = new ew_Page("CCEBooks_edit");
// page properties
CCEBooks_edit.PageID = "edit"; // page ID
CCEBooks_edit.FormID = "fCCEBooksedit"; // form ID
var EW_PAGE_ID = CCEBooks_edit.PageID; // for backward compatibility
// extend page with ValidateForm function
CCEBooks_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 + "_DocumentFile"];
if (elm && !ew_CheckFileType(elm.value))
return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
elm = fobj.elements["x" + infix + "_UploadedBy"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCEBooks->UploadedBy->FldErrMsg()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
CCEBooks_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) { ?>
CCEBooks_edit.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCEBooks_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 $CCEBooks->TableCaption() ?><br><br>
<a href="<?php echo $CCEBooks->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$CCEBooks_edit->ShowMessage();
?>
<form name="fCCEBooksedit" id="fCCEBooksedit" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CCEBooks_edit.ValidateForm(this);">
<p>
<input type="hidden" name="a_table" id="a_table" value="CCEBooks">
<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 ($CCEBooks->CCEModuleID->Visible) { // CCEModuleID ?>
<tr<?php echo $CCEBooks->CCEModuleID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->CCEModuleID->FldCaption() ?></td>
<td<?php echo $CCEBooks->CCEModuleID->CellAttributes() ?>><span id="el_CCEModuleID">
<select id="x_CCEModuleID" name="x_CCEModuleID" title="<?php echo $CCEBooks->CCEModuleID->FldTitle() ?>"<?php echo $CCEBooks->CCEModuleID->EditAttributes() ?>>
<?php
if (is_array($CCEBooks->CCEModuleID->EditValue)) {
$arwrk = $CCEBooks->CCEModuleID->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($CCEBooks->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 $CCEBooks->CCEModuleID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->DocumentName->Visible) { // DocumentName ?>
<tr<?php echo $CCEBooks->DocumentName->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->DocumentName->FldCaption() ?></td>
<td<?php echo $CCEBooks->DocumentName->CellAttributes() ?>><span id="el_DocumentName">
<input type="text" name="x_DocumentName" id="x_DocumentName" title="<?php echo $CCEBooks->DocumentName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->DocumentName->EditValue ?>"<?php echo $CCEBooks->DocumentName->EditAttributes() ?>>
</span><?php echo $CCEBooks->DocumentName->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->Publisher->Visible) { // Publisher ?>
<tr<?php echo $CCEBooks->Publisher->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->Publisher->FldCaption() ?></td>
<td<?php echo $CCEBooks->Publisher->CellAttributes() ?>><span id="el_Publisher">
<input type="text" name="x_Publisher" id="x_Publisher" title="<?php echo $CCEBooks->Publisher->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->Publisher->EditValue ?>"<?php echo $CCEBooks->Publisher->EditAttributes() ?>>
</span><?php echo $CCEBooks->Publisher->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->Authors->Visible) { // Authors ?>
<tr<?php echo $CCEBooks->Authors->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->Authors->FldCaption() ?></td>
<td<?php echo $CCEBooks->Authors->CellAttributes() ?>><span id="el_Authors">
<input type="text" name="x_Authors" id="x_Authors" title="<?php echo $CCEBooks->Authors->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->Authors->EditValue ?>"<?php echo $CCEBooks->Authors->EditAttributes() ?>>
</span><?php echo $CCEBooks->Authors->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->ISBN->Visible) { // ISBN ?>
<tr<?php echo $CCEBooks->ISBN->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->ISBN->FldCaption() ?></td>
<td<?php echo $CCEBooks->ISBN->CellAttributes() ?>><span id="el_ISBN">
<input type="text" name="x_ISBN" id="x_ISBN" title="<?php echo $CCEBooks->ISBN->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->ISBN->EditValue ?>"<?php echo $CCEBooks->ISBN->EditAttributes() ?>>
</span><?php echo $CCEBooks->ISBN->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->Edition->Visible) { // Edition ?>
<tr<?php echo $CCEBooks->Edition->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->Edition->FldCaption() ?></td>
<td<?php echo $CCEBooks->Edition->CellAttributes() ?>><span id="el_Edition">
<input type="text" name="x_Edition" id="x_Edition" title="<?php echo $CCEBooks->Edition->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->Edition->EditValue ?>"<?php echo $CCEBooks->Edition->EditAttributes() ?>>
</span><?php echo $CCEBooks->Edition->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->DocumentFile->Visible) { // DocumentFile ?>
<tr<?php echo $CCEBooks->DocumentFile->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->DocumentFile->FldCaption() ?></td>
<td<?php echo $CCEBooks->DocumentFile->CellAttributes() ?>><span id="el_DocumentFile">
<div id="old_x_DocumentFile">
<?php if ($CCEBooks->DocumentFile->HrefValue <> "" || $CCEBooks->DocumentFile->TooltipValue <> "") { ?>
<?php if (!empty($CCEBooks->DocumentFile->Upload->DbValue)) { ?>
<a href="<?php echo $CCEBooks->DocumentFile->HrefValue ?>"><?php echo $CCEBooks->DocumentFile->EditValue ?></a>
<?php } elseif (!in_array($CCEBooks->CurrentAction, array("I", "edit", "gridedit"))) { ?>
<?php } ?>
<?php } else { ?>
<?php if (!empty($CCEBooks->DocumentFile->Upload->DbValue)) { ?>
<?php echo $CCEBooks->DocumentFile->EditValue ?>
<?php } elseif (!in_array($CCEBooks->CurrentAction, array("I", "edit", "gridedit"))) { ?>
<?php } ?>
<?php } ?>
</div>
<div id="new_x_DocumentFile">
<?php if (!empty($CCEBooks->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 $CCEBooks->DocumentFile->EditAttrs["onchange"] = "this.form.a_DocumentFile[2].checked=true;" . @$CCEBooks->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 $CCEBooks->DocumentFile->FldTitle() ?>" size="30"<?php echo $CCEBooks->DocumentFile->EditAttributes() ?>>
</div>
</span><?php echo $CCEBooks->DocumentFile->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->UploadedBy->Visible) { // UploadedBy ?>
<tr<?php echo $CCEBooks->UploadedBy->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->UploadedBy->FldCaption() ?></td>
<td<?php echo $CCEBooks->UploadedBy->CellAttributes() ?>><span id="el_UploadedBy">
<input type="text" name="x_UploadedBy" id="x_UploadedBy" title="<?php echo $CCEBooks->UploadedBy->FldTitle() ?>" size="30" value="<?php echo $CCEBooks->UploadedBy->EditValue ?>"<?php echo $CCEBooks->UploadedBy->EditAttributes() ?>>
</span><?php echo $CCEBooks->UploadedBy->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->PurchaseFrom->Visible) { // PurchaseFrom ?>
<tr<?php echo $CCEBooks->PurchaseFrom->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->PurchaseFrom->FldCaption() ?></td>
<td<?php echo $CCEBooks->PurchaseFrom->CellAttributes() ?>><span id="el_PurchaseFrom">
<input type="text" name="x_PurchaseFrom" id="x_PurchaseFrom" title="<?php echo $CCEBooks->PurchaseFrom->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->PurchaseFrom->EditValue ?>"<?php echo $CCEBooks->PurchaseFrom->EditAttributes() ?>>
</span><?php echo $CCEBooks->PurchaseFrom->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->TelNumber->Visible) { // TelNumber ?>
<tr<?php echo $CCEBooks->TelNumber->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->TelNumber->FldCaption() ?></td>
<td<?php echo $CCEBooks->TelNumber->CellAttributes() ?>><span id="el_TelNumber">
<input type="text" name="x_TelNumber" id="x_TelNumber" title="<?php echo $CCEBooks->TelNumber->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->TelNumber->EditValue ?>"<?php echo $CCEBooks->TelNumber->EditAttributes() ?>>
</span><?php echo $CCEBooks->TelNumber->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCEBooks->Website->Visible) { // Website ?>
<tr<?php echo $CCEBooks->Website->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCEBooks->Website->FldCaption() ?></td>
<td<?php echo $CCEBooks->Website->CellAttributes() ?>><span id="el_Website">
<input type="text" name="x_Website" id="x_Website" title="<?php echo $CCEBooks->Website->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCEBooks->Website->EditValue ?>"<?php echo $CCEBooks->Website->EditAttributes() ?>>
</span><?php echo $CCEBooks->Website->CustomMsg ?></td>
</tr>
<?php } ?>
</table>
</div>
</td></tr></table>
<input type="hidden" name="x_CCEDocumentID" id="x_CCEDocumentID" value="<?php echo ew_HtmlEncode($CCEBooks->CCEDocumentID->CurrentValue) ?>">
<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
$CCEBooks_edit->Page_Terminate();
?>
<?php
//
// Page class
//
class cCCEBooks_edit {
// Page ID
var $PageID = 'edit';
// Table name
var $TableName = 'CCEBooks';
// Page object name
var $PageObjName = 'CCEBooks_edit';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $CCEBooks;
if ($CCEBooks->UseTokenInUrl) $PageUrl .= "t=" . $CCEBooks->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, $CCEBooks;
if ($CCEBooks->UseTokenInUrl) {
if ($objForm)
return ($CCEBooks->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($CCEBooks->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function __construct() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (CCEBooks)
$GLOBALS["CCEBooks"] = new cCCEBooks();
// Table object (CCEFacilitatorUsers)
$GLOBALS['CCEFacilitatorUsers'] = new cCCEFacilitatorUsers();
// 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", 'CCEBooks', 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 $CCEBooks;
// Security
$Security = new cAdvancedSecurity();
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.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, $CCEBooks;
// Load key from QueryString
if (@$_GET["CCEDocumentID"] <> "")
$CCEBooks->CCEDocumentID->setQueryStringValue($_GET["CCEDocumentID"]);
if (@$_POST["a_edit"] <> "") {
$CCEBooks->CurrentAction = $_POST["a_edit"]; // Get action code
$this->GetUploadFiles(); // Get upload files
$this->LoadFormValues(); // Get form values
// Validate form
if (!$this->ValidateForm()) {
$CCEBooks->CurrentAction = ""; // Form error, reset action
$this->setMessage($gsFormError);
$CCEBooks->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues();
}
} else {
$CCEBooks->CurrentAction = "I"; // Default action is display
}
// Check if valid key
if ($CCEBooks->CCEDocumentID->CurrentValue == "")
$this->Page_Terminate("CCEBookslist.php"); // Invalid key, return to list
switch ($CCEBooks->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("CCEBookslist.php"); // No matching record, return to list
}
break;
Case "U": // Update
$CCEBooks->SendEmail = TRUE; // Send email on update success
if ($this->EditRow()) { // Update record based on key
$this->setMessage($Language->Phrase("UpdateSuccess")); // Update success
$sReturnUrl = $CCEBooks->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "CCEBooksview.php")
$sReturnUrl = $CCEBooks->ViewUrl(); // View paging, return to View page directly
$this->Page_Terminate($sReturnUrl); // Return to caller
} else {
$CCEBooks->EventCancelled = TRUE; // Event cancelled
$this->RestoreFormValues(); // Restore form values if update failed
}
}
// Render the record
$CCEBooks->RowType = EW_ROWTYPE_EDIT; // Render as Edit
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $CCEBooks;
// Get upload data
if ($CCEBooks->DocumentFile->Upload->UploadFile()) {
// No action required
} else {
echo $CCEBooks->DocumentFile->Upload->Message;
$this->Page_Terminate();
exit();
}
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $CCEBooks;
$CCEBooks->CCEModuleID->setFormValue($objForm->GetValue("x_CCEModuleID"));
$CCEBooks->DocumentName->setFormValue($objForm->GetValue("x_DocumentName"));
$CCEBooks->Publisher->setFormValue($objForm->GetValue("x_Publisher"));
$CCEBooks->Authors->setFormValue($objForm->GetValue("x_Authors"));
$CCEBooks->ISBN->setFormValue($objForm->GetValue("x_ISBN"));
$CCEBooks->Edition->setFormValue($objForm->GetValue("x_Edition"));
$CCEBooks->UploadedBy->setFormValue($objForm->GetValue("x_UploadedBy"));
$CCEBooks->PurchaseFrom->setFormValue($objForm->GetValue("x_PurchaseFrom"));
$CCEBooks->TelNumber->setFormValue($objForm->GetValue("x_TelNumber"));
$CCEBooks->Website->setFormValue($objForm->GetValue("x_Website"));
$CCEBooks->CCEDocumentID->setFormValue($objForm->GetValue("x_CCEDocumentID"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $CCEBooks;
$CCEBooks->CCEDocumentID->CurrentValue = $CCEBooks->CCEDocumentID->FormValue;
$this->LoadRow();
$CCEBooks->CCEModuleID->CurrentValue = $CCEBooks->CCEModuleID->FormValue;
$CCEBooks->DocumentName->CurrentValue = $CCEBooks->DocumentName->FormValue;
$CCEBooks->Publisher->CurrentValue = $CCEBooks->Publisher->FormValue;
$CCEBooks->Authors->CurrentValue = $CCEBooks->Authors->FormValue;
$CCEBooks->ISBN->CurrentValue = $CCEBooks->ISBN->FormValue;
$CCEBooks->Edition->CurrentValue = $CCEBooks->Edition->FormValue;
$CCEBooks->UploadedBy->CurrentValue = $CCEBooks->UploadedBy->FormValue;
$CCEBooks->PurchaseFrom->CurrentValue = $CCEBooks->PurchaseFrom->FormValue;
$CCEBooks->TelNumber->CurrentValue = $CCEBooks->TelNumber->FormValue;
$CCEBooks->Website->CurrentValue = $CCEBooks->Website->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $CCEBooks;
$sFilter = $CCEBooks->KeyFilter();
// Call Row Selecting event
$CCEBooks->Row_Selecting($sFilter);
// Load SQL based on filter
$CCEBooks->CurrentFilter = $sFilter;
$sSql = $CCEBooks->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$CCEBooks->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $CCEBooks;
$CCEBooks->CCEDocumentID->setDbValue($rs->fields('CCEDocumentID'));
$CCEBooks->CCEModuleID->setDbValue($rs->fields('CCEModuleID'));
$CCEBooks->DocumentName->setDbValue($rs->fields('DocumentName'));
$CCEBooks->Publisher->setDbValue($rs->fields('Publisher'));
$CCEBooks->Authors->setDbValue($rs->fields('Authors'));
$CCEBooks->ISBN->setDbValue($rs->fields('ISBN'));
$CCEBooks->Edition->setDbValue($rs->fields('Edition'));
$CCEBooks->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile');
$CCEBooks->UploadedBy->setDbValue($rs->fields('UploadedBy'));
$CCEBooks->DocumentThumb->setDbValue($rs->fields('DocumentThumb'));
$CCEBooks->PurchaseFrom->setDbValue($rs->fields('PurchaseFrom'));
$CCEBooks->TelNumber->setDbValue($rs->fields('TelNumber'));
$CCEBooks->Website->setDbValue($rs->fields('Website'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $CCEBooks;
// Initialize URLs
// Call Row_Rendering event
$CCEBooks->Row_Rendering();
// Common render codes for all row types
// CCEModuleID
$CCEBooks->CCEModuleID->CellCssStyle = ""; $CCEBooks->CCEModuleID->CellCssClass = "";
$CCEBooks->CCEModuleID->CellAttrs = array(); $CCEBooks->CCEModuleID->ViewAttrs = array(); $CCEBooks->CCEModuleID->EditAttrs = array();
// DocumentName
$CCEBooks->DocumentName->CellCssStyle = ""; $CCEBooks->DocumentName->CellCssClass = "";
$CCEBooks->DocumentName->CellAttrs = array(); $CCEBooks->DocumentName->ViewAttrs = array(); $CCEBooks->DocumentName->EditAttrs = array();
// Publisher
$CCEBooks->Publisher->CellCssStyle = ""; $CCEBooks->Publisher->CellCssClass = "";
$CCEBooks->Publisher->CellAttrs = array(); $CCEBooks->Publisher->ViewAttrs = array(); $CCEBooks->Publisher->EditAttrs = array();
// Authors
$CCEBooks->Authors->CellCssStyle = ""; $CCEBooks->Authors->CellCssClass = "";
$CCEBooks->Authors->CellAttrs = array(); $CCEBooks->Authors->ViewAttrs = array(); $CCEBooks->Authors->EditAttrs = array();
// ISBN
$CCEBooks->ISBN->CellCssStyle = ""; $CCEBooks->ISBN->CellCssClass = "";
$CCEBooks->ISBN->CellAttrs = array(); $CCEBooks->ISBN->ViewAttrs = array(); $CCEBooks->ISBN->EditAttrs = array();
// Edition
$CCEBooks->Edition->CellCssStyle = ""; $CCEBooks->Edition->CellCssClass = "";
$CCEBooks->Edition->CellAttrs = array(); $CCEBooks->Edition->ViewAttrs = array(); $CCEBooks->Edition->EditAttrs = array();
// DocumentFile
$CCEBooks->DocumentFile->CellCssStyle = ""; $CCEBooks->DocumentFile->CellCssClass = "";
$CCEBooks->DocumentFile->CellAttrs = array(); $CCEBooks->DocumentFile->ViewAttrs = array(); $CCEBooks->DocumentFile->EditAttrs = array();
// UploadedBy
$CCEBooks->UploadedBy->CellCssStyle = ""; $CCEBooks->UploadedBy->CellCssClass = "";
$CCEBooks->UploadedBy->CellAttrs = array(); $CCEBooks->UploadedBy->ViewAttrs = array(); $CCEBooks->UploadedBy->EditAttrs = array();
// PurchaseFrom
$CCEBooks->PurchaseFrom->CellCssStyle = ""; $CCEBooks->PurchaseFrom->CellCssClass = "";
$CCEBooks->PurchaseFrom->CellAttrs = array(); $CCEBooks->PurchaseFrom->ViewAttrs = array(); $CCEBooks->PurchaseFrom->EditAttrs = array();
// TelNumber
$CCEBooks->TelNumber->CellCssStyle = ""; $CCEBooks->TelNumber->CellCssClass = "";
$CCEBooks->TelNumber->CellAttrs = array(); $CCEBooks->TelNumber->ViewAttrs = array(); $CCEBooks->TelNumber->EditAttrs = array();
// Website
$CCEBooks->Website->CellCssStyle = ""; $CCEBooks->Website->CellCssClass = "";
$CCEBooks->Website->CellAttrs = array(); $CCEBooks->Website->ViewAttrs = array(); $CCEBooks->Website->EditAttrs = array();
if ($CCEBooks->RowType == EW_ROWTYPE_VIEW) { // View row
// CCEDocumentID
$CCEBooks->CCEDocumentID->ViewValue = $CCEBooks->CCEDocumentID->CurrentValue;
$CCEBooks->CCEDocumentID->CssStyle = "";
$CCEBooks->CCEDocumentID->CssClass = "";
$CCEBooks->CCEDocumentID->ViewCustomAttributes = "";
// CCEModuleID
if (strval($CCEBooks->CCEModuleID->CurrentValue) <> "") {
$sFilterWrk = "CCEModules.CCEModuleID = " . ew_AdjustSql($CCEBooks->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
$CCEBooks->CCEModuleID->ViewValue = $rswrk->fields('ModuleNum');
$CCEBooks->CCEModuleID->ViewValue .= ew_ValueSeparator(0) . $rswrk->fields('ModuleName');
$rswrk->Close();
} else {
$CCEBooks->CCEModuleID->ViewValue = $CCEBooks->CCEModuleID->CurrentValue;
}
} else {
$CCEBooks->CCEModuleID->ViewValue = NULL;
}
$CCEBooks->CCEModuleID->CssStyle = "";
$CCEBooks->CCEModuleID->CssClass = "";
$CCEBooks->CCEModuleID->ViewCustomAttributes = "";
// DocumentName
$CCEBooks->DocumentName->ViewValue = $CCEBooks->DocumentName->CurrentValue;
$CCEBooks->DocumentName->CssStyle = "";
$CCEBooks->DocumentName->CssClass = "";
$CCEBooks->DocumentName->ViewCustomAttributes = "";
// Publisher
$CCEBooks->Publisher->ViewValue = $CCEBooks->Publisher->CurrentValue;
$CCEBooks->Publisher->CssStyle = "";
$CCEBooks->Publisher->CssClass = "";
$CCEBooks->Publisher->ViewCustomAttributes = "";
// Authors
$CCEBooks->Authors->ViewValue = $CCEBooks->Authors->CurrentValue;
$CCEBooks->Authors->CssStyle = "";
$CCEBooks->Authors->CssClass = "";
$CCEBooks->Authors->ViewCustomAttributes = "";
// ISBN
$CCEBooks->ISBN->ViewValue = $CCEBooks->ISBN->CurrentValue;
$CCEBooks->ISBN->CssStyle = "";
$CCEBooks->ISBN->CssClass = "";
$CCEBooks->ISBN->ViewCustomAttributes = "";
// Edition
$CCEBooks->Edition->ViewValue = $CCEBooks->Edition->CurrentValue;
$CCEBooks->Edition->CssStyle = "";
$CCEBooks->Edition->CssClass = "";
$CCEBooks->Edition->ViewCustomAttributes = "";
// DocumentFile
if (!ew_Empty($CCEBooks->DocumentFile->Upload->DbValue)) {
$CCEBooks->DocumentFile->ViewValue = $CCEBooks->DocumentFile->Upload->DbValue;
} else {
$CCEBooks->DocumentFile->ViewValue = "";
}
$CCEBooks->DocumentFile->CssStyle = "";
$CCEBooks->DocumentFile->CssClass = "";
$CCEBooks->DocumentFile->ViewCustomAttributes = "";
// UploadedBy
$CCEBooks->UploadedBy->ViewValue = $CCEBooks->UploadedBy->CurrentValue;
$CCEBooks->UploadedBy->CssStyle = "";
$CCEBooks->UploadedBy->CssClass = "";
$CCEBooks->UploadedBy->ViewCustomAttributes = "";
// PurchaseFrom
$CCEBooks->PurchaseFrom->ViewValue = $CCEBooks->PurchaseFrom->CurrentValue;
$CCEBooks->PurchaseFrom->CssStyle = "";
$CCEBooks->PurchaseFrom->CssClass = "";
$CCEBooks->PurchaseFrom->ViewCustomAttributes = "";
// TelNumber
$CCEBooks->TelNumber->ViewValue = $CCEBooks->TelNumber->CurrentValue;
$CCEBooks->TelNumber->CssStyle = "";
$CCEBooks->TelNumber->CssClass = "";
$CCEBooks->TelNumber->ViewCustomAttributes = "";
// Website
$CCEBooks->Website->ViewValue = $CCEBooks->Website->CurrentValue;
$CCEBooks->Website->CssStyle = "";
$CCEBooks->Website->CssClass = "";
$CCEBooks->Website->ViewCustomAttributes = "";
// CCEModuleID
$CCEBooks->CCEModuleID->HrefValue = "";
$CCEBooks->CCEModuleID->TooltipValue = "";
// DocumentName
$CCEBooks->DocumentName->HrefValue = "";
$CCEBooks->DocumentName->TooltipValue = "";
// Publisher
$CCEBooks->Publisher->HrefValue = "";
$CCEBooks->Publisher->TooltipValue = "";
// Authors
$CCEBooks->Authors->HrefValue = "";
$CCEBooks->Authors->TooltipValue = "";
// ISBN
$CCEBooks->ISBN->HrefValue = "";
$CCEBooks->ISBN->TooltipValue = "";
// Edition
$CCEBooks->Edition->HrefValue = "";
$CCEBooks->Edition->TooltipValue = "";
// DocumentFile
if (!ew_Empty($CCEBooks->DocumentFile->Upload->DbValue)) {
$CCEBooks->DocumentFile->HrefValue = ew_UploadPathEx(FALSE, $CCEBooks->DocumentFile->UploadPath) . ((!empty($CCEBooks->DocumentFile->ViewValue)) ? $CCEBooks->DocumentFile->ViewValue : $CCEBooks->DocumentFile->CurrentValue);
if ($CCEBooks->Export <> "") $CCEBooks->DocumentFile->HrefValue = ew_ConvertFullUrl($CCEBooks->DocumentFile->HrefValue);
} else {
$CCEBooks->DocumentFile->HrefValue = "";
}
$CCEBooks->DocumentFile->TooltipValue = "";
// UploadedBy
$CCEBooks->UploadedBy->HrefValue = "";
$CCEBooks->UploadedBy->TooltipValue = "";
// PurchaseFrom
$CCEBooks->PurchaseFrom->HrefValue = "";
$CCEBooks->PurchaseFrom->TooltipValue = "";
// TelNumber
$CCEBooks->TelNumber->HrefValue = "";
$CCEBooks->TelNumber->TooltipValue = "";
// Website
$CCEBooks->Website->HrefValue = "";
$CCEBooks->Website->TooltipValue = "";
} elseif ($CCEBooks->RowType == EW_ROWTYPE_EDIT) { // Edit row
// CCEModuleID
$CCEBooks->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"), ""));
$CCEBooks->CCEModuleID->EditValue = $arwrk;
// DocumentName
$CCEBooks->DocumentName->EditCustomAttributes = "";
$CCEBooks->DocumentName->EditValue = ew_HtmlEncode($CCEBooks->DocumentName->CurrentValue);
// Publisher
$CCEBooks->Publisher->EditCustomAttributes = "";
$CCEBooks->Publisher->EditValue = ew_HtmlEncode($CCEBooks->Publisher->CurrentValue);
// Authors
$CCEBooks->Authors->EditCustomAttributes = "";
$CCEBooks->Authors->EditValue = ew_HtmlEncode($CCEBooks->Authors->CurrentValue);
// ISBN
$CCEBooks->ISBN->EditCustomAttributes = "";
$CCEBooks->ISBN->EditValue = ew_HtmlEncode($CCEBooks->ISBN->CurrentValue);
// Edition
$CCEBooks->Edition->EditCustomAttributes = "";
$CCEBooks->Edition->EditValue = ew_HtmlEncode($CCEBooks->Edition->CurrentValue);
// DocumentFile
$CCEBooks->DocumentFile->EditCustomAttributes = "";
if (!ew_Empty($CCEBooks->DocumentFile->Upload->DbValue)) {
$CCEBooks->DocumentFile->EditValue = $CCEBooks->DocumentFile->Upload->DbValue;
} else {
$CCEBooks->DocumentFile->EditValue = "";
}
// UploadedBy
$CCEBooks->UploadedBy->EditCustomAttributes = "";
$CCEBooks->UploadedBy->EditValue = ew_HtmlEncode($CCEBooks->UploadedBy->CurrentValue);
// PurchaseFrom
$CCEBooks->PurchaseFrom->EditCustomAttributes = "";
$CCEBooks->PurchaseFrom->EditValue = ew_HtmlEncode($CCEBooks->PurchaseFrom->CurrentValue);
// TelNumber
$CCEBooks->TelNumber->EditCustomAttributes = "";
$CCEBooks->TelNumber->EditValue = ew_HtmlEncode($CCEBooks->TelNumber->CurrentValue);
// Website
$CCEBooks->Website->EditCustomAttributes = "";
$CCEBooks->Website->EditValue = ew_HtmlEncode($CCEBooks->Website->CurrentValue);
// Edit refer script
// CCEModuleID
$CCEBooks->CCEModuleID->HrefValue = "";
// DocumentName
$CCEBooks->DocumentName->HrefValue = "";
// Publisher
$CCEBooks->Publisher->HrefValue = "";
// Authors
$CCEBooks->Authors->HrefValue = "";
// ISBN
$CCEBooks->ISBN->HrefValue = "";
// Edition
$CCEBooks->Edition->HrefValue = "";
// DocumentFile
if (!ew_Empty($CCEBooks->DocumentFile->Upload->DbValue)) {
$CCEBooks->DocumentFile->HrefValue = ew_UploadPathEx(FALSE, $CCEBooks->DocumentFile->UploadPath) . ((!empty($CCEBooks->DocumentFile->EditValue)) ? $CCEBooks->DocumentFile->EditValue : $CCEBooks->DocumentFile->CurrentValue);
if ($CCEBooks->Export <> "") $CCEBooks->DocumentFile->HrefValue = ew_ConvertFullUrl($CCEBooks->DocumentFile->HrefValue);
} else {
$CCEBooks->DocumentFile->HrefValue = "";
}
// UploadedBy
$CCEBooks->UploadedBy->HrefValue = "";
// PurchaseFrom
$CCEBooks->PurchaseFrom->HrefValue = "";
// TelNumber
$CCEBooks->TelNumber->HrefValue = "";
// Website
$CCEBooks->Website->HrefValue = "";
}
// Call Row Rendered event
if ($CCEBooks->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$CCEBooks->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $CCEBooks;
// Initialize form error message
$gsFormError = "";
if (!ew_CheckFileType($CCEBooks->DocumentFile->Upload->FileName)) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("WrongFileType");
}
if ($CCEBooks->DocumentFile->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $CCEBooks->DocumentFile->Upload->FileSize > EW_MAX_FILE_SIZE) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
}
if (in_array($CCEBooks->DocumentFile->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("PhpUploadErr" . $CCEBooks->DocumentFile->Upload->Error);
}
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!ew_CheckInteger($CCEBooks->UploadedBy->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCEBooks->UploadedBy->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, $CCEBooks;
$sFilter = $CCEBooks->KeyFilter();
$CCEBooks->CurrentFilter = $sFilter;
$sSql = $CCEBooks->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
$CCEBooks->CCEModuleID->SetDbValueDef($rsnew, $CCEBooks->CCEModuleID->CurrentValue, NULL, FALSE);
// DocumentName
$CCEBooks->DocumentName->SetDbValueDef($rsnew, $CCEBooks->DocumentName->CurrentValue, NULL, FALSE);
// Publisher
$CCEBooks->Publisher->SetDbValueDef($rsnew, $CCEBooks->Publisher->CurrentValue, NULL, FALSE);
// Authors
$CCEBooks->Authors->SetDbValueDef($rsnew, $CCEBooks->Authors->CurrentValue, NULL, FALSE);
// ISBN
$CCEBooks->ISBN->SetDbValueDef($rsnew, $CCEBooks->ISBN->CurrentValue, NULL, FALSE);
// Edition
$CCEBooks->Edition->SetDbValueDef($rsnew, $CCEBooks->Edition->CurrentValue, NULL, FALSE);
// DocumentFile
$CCEBooks->DocumentFile->Upload->SaveToSession(); // Save file value to Session
if ($CCEBooks->DocumentFile->Upload->Action == "2" || $CCEBooks->DocumentFile->Upload->Action == "3") { // Update/Remove
$CCEBooks->DocumentFile->Upload->DbValue = $rs->fields('DocumentFile'); // Get original value
if (is_null($CCEBooks->DocumentFile->Upload->Value)) {
$rsnew['DocumentFile'] = NULL;
} else {
$rsnew['DocumentFile'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $CCEBooks->DocumentFile->UploadPath), $CCEBooks->DocumentFile->Upload->FileName);
}
}
// UploadedBy
$CCEBooks->UploadedBy->SetDbValueDef($rsnew, $CCEBooks->UploadedBy->CurrentValue, NULL, FALSE);
// PurchaseFrom
$CCEBooks->PurchaseFrom->SetDbValueDef($rsnew, $CCEBooks->PurchaseFrom->CurrentValue, NULL, FALSE);
// TelNumber
$CCEBooks->TelNumber->SetDbValueDef($rsnew, $CCEBooks->TelNumber->CurrentValue, NULL, FALSE);
// Website
$CCEBooks->Website->SetDbValueDef($rsnew, $CCEBooks->Website->CurrentValue, NULL, FALSE);
// Call Row Updating event
$bUpdateRow = $CCEBooks->Row_Updating($rsold, $rsnew);
if ($bUpdateRow) {
if (!ew_Empty($CCEBooks->DocumentFile->Upload->Value)) {
$CCEBooks->DocumentFile->Upload->SaveToFile($CCEBooks->DocumentFile->UploadPath, $rsnew['DocumentFile'], FALSE);
}
$conn->raiseErrorFn = 'ew_ErrorFn';
$EditRow = $conn->Execute($CCEBooks->UpdateSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($CCEBooks->CancelMessage <> "") {
$this->setMessage($CCEBooks->CancelMessage);
$CCEBooks->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("UpdateCancelled"));
}
$EditRow = FALSE;
}
}
// Call Row_Updated event
if ($EditRow)
$CCEBooks->Row_Updated($rsold, $rsnew);
$rs->Close();
// DocumentFile
$CCEBooks->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;
}
}
?>