| Current Path : /var/www/cesa.co.za/echasl23/ |
| Current File : /var/www/cesa.co.za/echasl23/CommitteeDocumentsadd.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 "CommitteeDocumentsinfo.php" ?>
<?php include "adminusersinfo.php" ?>
<?php include "tblCommitteesinfo.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
$CommitteeDocuments_add = new cCommitteeDocuments_add();
$Page =& $CommitteeDocuments_add;
// Page init
$CommitteeDocuments_add->Page_Init();
// Page main
$CommitteeDocuments_add->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var CommitteeDocuments_add = new ew_Page("CommitteeDocuments_add");
// page properties
CommitteeDocuments_add.PageID = "add"; // page ID
CommitteeDocuments_add.FormID = "fCommitteeDocumentsadd"; // form ID
var EW_PAGE_ID = CommitteeDocuments_add.PageID; // for backward compatibility
// extend page with ValidateForm function
CommitteeDocuments_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 + "_Document"];
if (elm && !ew_CheckFileType(elm.value))
return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
elm = fobj.elements["x" + infix + "_SortOrder"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CommitteeDocuments->SortOrder->FldErrMsg()) ?>");
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
CommitteeDocuments_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) { ?>
CommitteeDocuments_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CommitteeDocuments_add.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("Add") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CommitteeDocuments->TableCaption() ?><br><br>
<a href="<?php echo $CommitteeDocuments->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$CommitteeDocuments_add->ShowMessage();
?>
<form name="fCommitteeDocumentsadd" id="fCommitteeDocumentsadd" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CommitteeDocuments_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CommitteeDocuments">
<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 ($CommitteeDocuments->CommitteeID->Visible) { // CommitteeID ?>
<tr<?php echo $CommitteeDocuments->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CommitteeDocuments->CommitteeID->FldCaption() ?></td>
<td<?php echo $CommitteeDocuments->CommitteeID->CellAttributes() ?>><span id="el_CommitteeID">
<?php if ($CommitteeDocuments->CommitteeID->getSessionValue() <> "") { ?>
<div<?php echo $CommitteeDocuments->CommitteeID->ViewAttributes() ?>><?php echo $CommitteeDocuments->CommitteeID->ViewValue ?></div>
<input type="hidden" id="x_CommitteeID" name="x_CommitteeID" value="<?php echo ew_HtmlEncode($CommitteeDocuments->CommitteeID->CurrentValue) ?>">
<?php } else { ?>
<select id="x_CommitteeID" name="x_CommitteeID" title="<?php echo $CommitteeDocuments->CommitteeID->FldTitle() ?>"<?php echo $CommitteeDocuments->CommitteeID->EditAttributes() ?>>
<?php
if (is_array($CommitteeDocuments->CommitteeID->EditValue)) {
$arwrk = $CommitteeDocuments->CommitteeID->EditValue;
$rowswrk = count($arwrk);
$emptywrk = TRUE;
for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
$selwrk = (strval($CommitteeDocuments->CommitteeID->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 $CommitteeDocuments->CommitteeID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CommitteeDocuments->Document->Visible) { // Document ?>
<tr<?php echo $CommitteeDocuments->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CommitteeDocuments->Document->FldCaption() ?></td>
<td<?php echo $CommitteeDocuments->Document->CellAttributes() ?>><span id="el_Document">
<input type="file" name="x_Document" id="x_Document" title="<?php echo $CommitteeDocuments->Document->FldTitle() ?>" size="30"<?php echo $CommitteeDocuments->Document->EditAttributes() ?>>
</div>
</span><?php echo $CommitteeDocuments->Document->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CommitteeDocuments->DocName->Visible) { // DocName ?>
<tr<?php echo $CommitteeDocuments->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CommitteeDocuments->DocName->FldCaption() ?></td>
<td<?php echo $CommitteeDocuments->DocName->CellAttributes() ?>><span id="el_DocName">
<input type="text" name="x_DocName" id="x_DocName" title="<?php echo $CommitteeDocuments->DocName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CommitteeDocuments->DocName->EditValue ?>"<?php echo $CommitteeDocuments->DocName->EditAttributes() ?>>
</span><?php echo $CommitteeDocuments->DocName->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CommitteeDocuments->SortOrder->Visible) { // SortOrder ?>
<tr<?php echo $CommitteeDocuments->RowAttributes() ?>>
<td class="ewTableHeader"><?php echo $CommitteeDocuments->SortOrder->FldCaption() ?></td>
<td<?php echo $CommitteeDocuments->SortOrder->CellAttributes() ?>><span id="el_SortOrder">
<input type="text" name="x_SortOrder" id="x_SortOrder" title="<?php echo $CommitteeDocuments->SortOrder->FldTitle() ?>" size="30" value="<?php echo $CommitteeDocuments->SortOrder->EditValue ?>"<?php echo $CommitteeDocuments->SortOrder->EditAttributes() ?>>
</span><?php echo $CommitteeDocuments->SortOrder->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
$CommitteeDocuments_add->Page_Terminate();
?>
<?php
//
// Page class
//
class cCommitteeDocuments_add {
// Page ID
var $PageID = 'add';
// Table name
var $TableName = 'CommitteeDocuments';
// Page object name
var $PageObjName = 'CommitteeDocuments_add';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $CommitteeDocuments;
if ($CommitteeDocuments->UseTokenInUrl) $PageUrl .= "t=" . $CommitteeDocuments->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, $CommitteeDocuments;
if ($CommitteeDocuments->UseTokenInUrl) {
if ($objForm)
return ($CommitteeDocuments->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($CommitteeDocuments->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function __construct() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (CommitteeDocuments)
$GLOBALS["CommitteeDocuments"] = new cCommitteeDocuments();
// Table object (adminusers)
$GLOBALS['adminusers'] = new cadminusers();
// Table object (tblCommittees)
$GLOBALS['tblCommittees'] = new ctblCommittees();
// 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", 'CommitteeDocuments', 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 $CommitteeDocuments;
// User profile
$UserProfile = new cUserProfile();
$UserProfile->LoadProfile(@$_SESSION[EW_SESSION_USER_PROFILE]);
// Security
$Security = new cAdvancedSecurity();
if (IsPasswordExpired())
$this->Page_Terminate("changepwd.php");
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("CommitteeDocumentslist.php");
}
$Security->UserID_Loading();
if ($Security->IsLoggedIn()) $Security->LoadUserID();
$Security->UserID_Loaded();
// 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, $CommitteeDocuments;
// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["CommitteeDocumentID"] != "") {
$CommitteeDocuments->CommitteeDocumentID->setQueryStringValue($_GET["CommitteeDocumentID"]);
} else {
$bCopy = FALSE;
}
// Set up master/detail parameters
$this->SetUpMasterDetail();
// Process form if post back
if (@$_POST["a_add"] <> "") {
$CommitteeDocuments->CurrentAction = $_POST["a_add"]; // Get form action
$this->GetUploadFiles(); // Get upload files
$this->LoadFormValues(); // Load form values
// Validate form
if (!$this->ValidateForm()) {
$CommitteeDocuments->CurrentAction = "I"; // Form error, reset action
$this->setMessage($gsFormError);
}
} else { // Not post back
if ($bCopy) {
$CommitteeDocuments->CurrentAction = "C"; // Copy record
} else {
$CommitteeDocuments->CurrentAction = "I"; // Display blank record
$this->LoadDefaultValues(); // Load default values
}
}
// Perform action based on action code
switch ($CommitteeDocuments->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("CommitteeDocumentslist.php"); // No matching record, return to list
}
break;
case "A": // ' Add new record
$CommitteeDocuments->SendEmail = TRUE; // Send email on add success
if ($this->AddRow()) { // Add successful
$this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
$sReturnUrl = $CommitteeDocuments->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "CommitteeDocumentsview.php")
$sReturnUrl = $CommitteeDocuments->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
$CommitteeDocuments->RowType = EW_ROWTYPE_ADD; // Render add type
// Render row
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $CommitteeDocuments;
// Get upload data
if ($CommitteeDocuments->Document->Upload->UploadFile()) {
// No action required
} else {
echo $CommitteeDocuments->Document->Upload->Message;
$this->Page_Terminate();
exit();
}
}
// Load default values
function LoadDefaultValues() {
global $CommitteeDocuments;
$CommitteeDocuments->Document->CurrentValue = NULL; // Clear file related field
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $CommitteeDocuments;
$CommitteeDocuments->CommitteeID->setFormValue($objForm->GetValue("x_CommitteeID"));
$CommitteeDocuments->DocName->setFormValue($objForm->GetValue("x_DocName"));
$CommitteeDocuments->SortOrder->setFormValue($objForm->GetValue("x_SortOrder"));
$CommitteeDocuments->CommitteeDocumentID->setFormValue($objForm->GetValue("x_CommitteeDocumentID"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $CommitteeDocuments;
$CommitteeDocuments->CommitteeDocumentID->CurrentValue = $CommitteeDocuments->CommitteeDocumentID->FormValue;
$CommitteeDocuments->CommitteeID->CurrentValue = $CommitteeDocuments->CommitteeID->FormValue;
$CommitteeDocuments->DocName->CurrentValue = $CommitteeDocuments->DocName->FormValue;
$CommitteeDocuments->SortOrder->CurrentValue = $CommitteeDocuments->SortOrder->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $CommitteeDocuments;
$sFilter = $CommitteeDocuments->KeyFilter();
// Call Row Selecting event
$CommitteeDocuments->Row_Selecting($sFilter);
// Load SQL based on filter
$CommitteeDocuments->CurrentFilter = $sFilter;
$sSql = $CommitteeDocuments->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$CommitteeDocuments->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $CommitteeDocuments;
$CommitteeDocuments->CommitteeDocumentID->setDbValue($rs->fields('CommitteeDocumentID'));
$CommitteeDocuments->CommitteeID->setDbValue($rs->fields('CommitteeID'));
$CommitteeDocuments->Document->Upload->DbValue = $rs->fields('Document');
$CommitteeDocuments->DocName->setDbValue($rs->fields('DocName'));
$CommitteeDocuments->SortOrder->setDbValue($rs->fields('SortOrder'));
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $CommitteeDocuments;
// Initialize URLs
// Call Row_Rendering event
$CommitteeDocuments->Row_Rendering();
// Common render codes for all row types
// CommitteeID
$CommitteeDocuments->CommitteeID->CellCssStyle = ""; $CommitteeDocuments->CommitteeID->CellCssClass = "";
$CommitteeDocuments->CommitteeID->CellAttrs = array(); $CommitteeDocuments->CommitteeID->ViewAttrs = array(); $CommitteeDocuments->CommitteeID->EditAttrs = array();
// Document
$CommitteeDocuments->Document->CellCssStyle = ""; $CommitteeDocuments->Document->CellCssClass = "";
$CommitteeDocuments->Document->CellAttrs = array(); $CommitteeDocuments->Document->ViewAttrs = array(); $CommitteeDocuments->Document->EditAttrs = array();
// DocName
$CommitteeDocuments->DocName->CellCssStyle = ""; $CommitteeDocuments->DocName->CellCssClass = "";
$CommitteeDocuments->DocName->CellAttrs = array(); $CommitteeDocuments->DocName->ViewAttrs = array(); $CommitteeDocuments->DocName->EditAttrs = array();
// SortOrder
$CommitteeDocuments->SortOrder->CellCssStyle = ""; $CommitteeDocuments->SortOrder->CellCssClass = "";
$CommitteeDocuments->SortOrder->CellAttrs = array(); $CommitteeDocuments->SortOrder->ViewAttrs = array(); $CommitteeDocuments->SortOrder->EditAttrs = array();
if ($CommitteeDocuments->RowType == EW_ROWTYPE_VIEW) { // View row
// CommitteeDocumentID
$CommitteeDocuments->CommitteeDocumentID->ViewValue = $CommitteeDocuments->CommitteeDocumentID->CurrentValue;
$CommitteeDocuments->CommitteeDocumentID->CssStyle = "";
$CommitteeDocuments->CommitteeDocumentID->CssClass = "";
$CommitteeDocuments->CommitteeDocumentID->ViewCustomAttributes = "";
// CommitteeID
if (strval($CommitteeDocuments->CommitteeID->CurrentValue) <> "") {
$sFilterWrk = "`CommitteeID` = " . ew_AdjustSql($CommitteeDocuments->CommitteeID->CurrentValue) . "";
$sSqlWrk = "SELECT `CommitteeName` FROM `tblCommittees`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CommitteeName`";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$CommitteeDocuments->CommitteeID->ViewValue = $rswrk->fields('CommitteeName');
$rswrk->Close();
} else {
$CommitteeDocuments->CommitteeID->ViewValue = $CommitteeDocuments->CommitteeID->CurrentValue;
}
} else {
$CommitteeDocuments->CommitteeID->ViewValue = NULL;
}
$CommitteeDocuments->CommitteeID->CssStyle = "";
$CommitteeDocuments->CommitteeID->CssClass = "";
$CommitteeDocuments->CommitteeID->ViewCustomAttributes = "";
// Document
if (!ew_Empty($CommitteeDocuments->Document->Upload->DbValue)) {
$CommitteeDocuments->Document->ViewValue = $CommitteeDocuments->Document->Upload->DbValue;
} else {
$CommitteeDocuments->Document->ViewValue = "";
}
$CommitteeDocuments->Document->CssStyle = "";
$CommitteeDocuments->Document->CssClass = "";
$CommitteeDocuments->Document->ViewCustomAttributes = "";
// DocName
$CommitteeDocuments->DocName->ViewValue = $CommitteeDocuments->DocName->CurrentValue;
$CommitteeDocuments->DocName->CssStyle = "";
$CommitteeDocuments->DocName->CssClass = "";
$CommitteeDocuments->DocName->ViewCustomAttributes = "";
// SortOrder
$CommitteeDocuments->SortOrder->ViewValue = $CommitteeDocuments->SortOrder->CurrentValue;
$CommitteeDocuments->SortOrder->CssStyle = "";
$CommitteeDocuments->SortOrder->CssClass = "";
$CommitteeDocuments->SortOrder->ViewCustomAttributes = "";
// CommitteeID
$CommitteeDocuments->CommitteeID->HrefValue = "";
$CommitteeDocuments->CommitteeID->TooltipValue = "";
// Document
if (!ew_Empty($CommitteeDocuments->Document->Upload->DbValue)) {
$CommitteeDocuments->Document->HrefValue = ew_UploadPathEx(FALSE, $CommitteeDocuments->Document->UploadPath) . ((!empty($CommitteeDocuments->Document->ViewValue)) ? $CommitteeDocuments->Document->ViewValue : $CommitteeDocuments->Document->CurrentValue);
if ($CommitteeDocuments->Export <> "") $CommitteeDocuments->Document->HrefValue = ew_ConvertFullUrl($CommitteeDocuments->Document->HrefValue);
} else {
$CommitteeDocuments->Document->HrefValue = "";
}
$CommitteeDocuments->Document->TooltipValue = "";
// DocName
$CommitteeDocuments->DocName->HrefValue = "";
$CommitteeDocuments->DocName->TooltipValue = "";
// SortOrder
$CommitteeDocuments->SortOrder->HrefValue = "";
$CommitteeDocuments->SortOrder->TooltipValue = "";
} elseif ($CommitteeDocuments->RowType == EW_ROWTYPE_ADD) { // Add row
// CommitteeID
$CommitteeDocuments->CommitteeID->EditCustomAttributes = "";
if ($CommitteeDocuments->CommitteeID->getSessionValue() <> "") {
$CommitteeDocuments->CommitteeID->CurrentValue = $CommitteeDocuments->CommitteeID->getSessionValue();
if (strval($CommitteeDocuments->CommitteeID->CurrentValue) <> "") {
$sFilterWrk = "`CommitteeID` = " . ew_AdjustSql($CommitteeDocuments->CommitteeID->CurrentValue) . "";
$sSqlWrk = "SELECT `CommitteeName` FROM `tblCommittees`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CommitteeName`";
$rswrk = $conn->Execute($sSqlWrk);
if ($rswrk && !$rswrk->EOF) { // Lookup values found
$CommitteeDocuments->CommitteeID->ViewValue = $rswrk->fields('CommitteeName');
$rswrk->Close();
} else {
$CommitteeDocuments->CommitteeID->ViewValue = $CommitteeDocuments->CommitteeID->CurrentValue;
}
} else {
$CommitteeDocuments->CommitteeID->ViewValue = NULL;
}
$CommitteeDocuments->CommitteeID->CssStyle = "";
$CommitteeDocuments->CommitteeID->CssClass = "";
$CommitteeDocuments->CommitteeID->ViewCustomAttributes = "";
} else {
$sFilterWrk = "";
$sSqlWrk = "SELECT `CommitteeID`, `CommitteeName`, '' AS Disp2Fld, '' AS SelectFilterFld FROM `tblCommittees`";
$sWhereWrk = "";
if ($sFilterWrk <> "") {
if ($sWhereWrk <> "") $sWhereWrk .= " AND ";
$sWhereWrk .= "(" . $sFilterWrk . ")";
}
if ($sWhereWrk <> "") $sSqlWrk .= " WHERE " . $sWhereWrk;
$sSqlWrk .= " ORDER BY `CommitteeName`";
$rswrk = $conn->Execute($sSqlWrk);
$arwrk = ($rswrk) ? $rswrk->GetRows() : array();
if ($rswrk) $rswrk->Close();
array_unshift($arwrk, array("", $Language->Phrase("PleaseSelect")));
$CommitteeDocuments->CommitteeID->EditValue = $arwrk;
}
// Document
$CommitteeDocuments->Document->EditCustomAttributes = "";
if (!ew_Empty($CommitteeDocuments->Document->Upload->DbValue)) {
$CommitteeDocuments->Document->EditValue = $CommitteeDocuments->Document->Upload->DbValue;
} else {
$CommitteeDocuments->Document->EditValue = "";
}
// DocName
$CommitteeDocuments->DocName->EditCustomAttributes = "";
$CommitteeDocuments->DocName->EditValue = ew_HtmlEncode($CommitteeDocuments->DocName->CurrentValue);
// SortOrder
$CommitteeDocuments->SortOrder->EditCustomAttributes = "";
$CommitteeDocuments->SortOrder->EditValue = ew_HtmlEncode($CommitteeDocuments->SortOrder->CurrentValue);
}
// Call Row Rendered event
if ($CommitteeDocuments->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$CommitteeDocuments->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $CommitteeDocuments;
// Initialize form error message
$gsFormError = "";
if (!ew_CheckFileType($CommitteeDocuments->Document->Upload->FileName)) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("WrongFileType");
}
if ($CommitteeDocuments->Document->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $CommitteeDocuments->Document->Upload->FileSize > EW_MAX_FILE_SIZE) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
}
if (in_array($CommitteeDocuments->Document->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("PhpUploadErr" . $CommitteeDocuments->Document->Upload->Error);
}
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!ew_CheckInteger($CommitteeDocuments->SortOrder->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CommitteeDocuments->SortOrder->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, $CommitteeDocuments;
$rsnew = array();
// CommitteeID
$CommitteeDocuments->CommitteeID->SetDbValueDef($rsnew, $CommitteeDocuments->CommitteeID->CurrentValue, NULL, FALSE);
// Document
$CommitteeDocuments->Document->Upload->SaveToSession(); // Save file value to Session
if (is_null($CommitteeDocuments->Document->Upload->Value)) {
$rsnew['Document'] = NULL;
} else {
$rsnew['Document'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $CommitteeDocuments->Document->UploadPath), $CommitteeDocuments->Document->Upload->FileName);
}
// DocName
$CommitteeDocuments->DocName->SetDbValueDef($rsnew, $CommitteeDocuments->DocName->CurrentValue, NULL, FALSE);
// SortOrder
$CommitteeDocuments->SortOrder->SetDbValueDef($rsnew, $CommitteeDocuments->SortOrder->CurrentValue, NULL, FALSE);
// Call Row Inserting event
$bInsertRow = $CommitteeDocuments->Row_Inserting($rsnew);
if ($bInsertRow) {
if (!ew_Empty($CommitteeDocuments->Document->Upload->Value)) {
if ($CommitteeDocuments->Document->Upload->FileName == $CommitteeDocuments->Document->Upload->DbValue) { // Overwrite if same file name
$CommitteeDocuments->Document->Upload->SaveToFile($CommitteeDocuments->Document->UploadPath, $rsnew['Document'], TRUE);
$CommitteeDocuments->Document->Upload->DbValue = ""; // No need to delete any more
} else {
$CommitteeDocuments->Document->Upload->SaveToFile($CommitteeDocuments->Document->UploadPath, $rsnew['Document'], FALSE);
}
}
if ($CommitteeDocuments->Document->Upload->Action == "2" || $CommitteeDocuments->Document->Upload->Action == "3") { // Update/Remove
if ($CommitteeDocuments->Document->Upload->DbValue <> "")
@unlink(ew_UploadPathEx(TRUE, $CommitteeDocuments->Document->UploadPath) . $CommitteeDocuments->Document->Upload->DbValue);
}
$conn->raiseErrorFn = 'ew_ErrorFn';
$AddRow = $conn->Execute($CommitteeDocuments->InsertSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($CommitteeDocuments->CancelMessage <> "") {
$this->setMessage($CommitteeDocuments->CancelMessage);
$CommitteeDocuments->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("InsertCancelled"));
}
$AddRow = FALSE;
}
if ($AddRow) {
$CommitteeDocuments->CommitteeDocumentID->setDbValue($conn->Insert_ID());
$rsnew['CommitteeDocumentID'] = $CommitteeDocuments->CommitteeDocumentID->DbValue;
// Call Row Inserted event
$CommitteeDocuments->Row_Inserted($rsnew);
}
// Document
$CommitteeDocuments->Document->Upload->RemoveFromSession(); // Remove file value from Session
return $AddRow;
}
// Set up master/detail based on QueryString
function SetUpMasterDetail() {
global $CommitteeDocuments;
$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 == "tblCommittees") {
$bValidMaster = TRUE;
$this->sDbMasterFilter = $CommitteeDocuments->SqlMasterFilter_tblCommittees();
$this->sDbDetailFilter = $CommitteeDocuments->SqlDetailFilter_tblCommittees();
if (@$_GET["CommitteeID"] <> "") {
$GLOBALS["tblCommittees"]->CommitteeID->setQueryStringValue($_GET["CommitteeID"]);
$CommitteeDocuments->CommitteeID->setQueryStringValue($GLOBALS["tblCommittees"]->CommitteeID->QueryStringValue);
$CommitteeDocuments->CommitteeID->setSessionValue($CommitteeDocuments->CommitteeID->QueryStringValue);
if (!is_numeric($GLOBALS["tblCommittees"]->CommitteeID->QueryStringValue)) $bValidMaster = FALSE;
$this->sDbMasterFilter = str_replace("@CommitteeID@", ew_AdjustSql($GLOBALS["tblCommittees"]->CommitteeID->QueryStringValue), $this->sDbMasterFilter);
$this->sDbDetailFilter = str_replace("@CommitteeID@", ew_AdjustSql($GLOBALS["tblCommittees"]->CommitteeID->QueryStringValue), $this->sDbDetailFilter);
} else {
$bValidMaster = FALSE;
}
}
}
if ($bValidMaster) {
// Save current master table
$CommitteeDocuments->setCurrentMasterTable($sMasterTblVar);
// Reset start record counter (new master key)
$this->lStartRec = 1;
$CommitteeDocuments->setStartRecordNumber($this->lStartRec);
$CommitteeDocuments->setMasterFilter($this->sDbMasterFilter); // Set up master filter
$CommitteeDocuments->setDetailFilter($this->sDbDetailFilter); // Set up detail filter
// Clear previous master key from Session
if ($sMasterTblVar <> "tblCommittees") {
if ($CommitteeDocuments->CommitteeID->QueryStringValue == "") $CommitteeDocuments->CommitteeID->setSessionValue("");
}
} else {
$this->sDbMasterFilter = $CommitteeDocuments->getMasterFilter(); // Restore master filter
$this->sDbDetailFilter = $CommitteeDocuments->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;
}
}
?>