| Current Path : /var/www/cesa.co.za/ccmadmin/ |
| Current File : /var/www/cesa.co.za/ccmadmin/CCMMessagesadd.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 "CCMMessagesinfo.php" ?>
<?php include "CCMUsersinfo.php" ?>
<?php include "userfn7.php" ?>
<?php
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
header("Cache-Control: post-check=0, pre-check=0", false);
header("Pragma: no-cache"); // HTTP/1.0
?>
<?php
// Create page object
$CCMMessages_add = new cCCMMessages_add();
$Page =& $CCMMessages_add;
// Page init
$CCMMessages_add->Page_Init();
// Page main
$CCMMessages_add->Page_Main();
?>
<?php include "header.php" ?>
<script type="text/javascript">
<!--
// Create page object
var CCMMessages_add = new ew_Page("CCMMessages_add");
// page properties
CCMMessages_add.PageID = "add"; // page ID
CCMMessages_add.FormID = "fCCMMessagesadd"; // form ID
var EW_PAGE_ID = CCMMessages_add.PageID; // for backward compatibility
// extend page with ValidateForm function
CCMMessages_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 + "_SentDateTime"];
if (elm && !ew_CheckDate(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCMMessages->SentDateTime->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_SentByStudentID"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCMMessages->SentByStudentID->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_SentByFacilitatorID"];
if (elm && !ew_CheckInteger(elm.value))
return ew_OnError(this, elm, "<?php echo ew_JsEncode2($CCMMessages->SentByFacilitatorID->FldErrMsg()) ?>");
elm = fobj.elements["x" + infix + "_MessageFile"];
if (elm && !ew_CheckFileType(elm.value))
return ew_OnError(this, elm, ewLanguage.Phrase("WrongFileType"));
// Call Form Custom Validate event
if (!this.Form_CustomValidate(fobj)) return false;
}
return true;
}
// extend page with Form_CustomValidate function
CCMMessages_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) { ?>
CCMMessages_add.ValidateRequired = true; // uses JavaScript validation
<?php } else { ?>
CCMMessages_add.ValidateRequired = false; // no JavaScript validation
<?php } ?>
//-->
</script>
<link rel="stylesheet" type="text/css" media="all" href="calendar/calendar-win2k-cold-1.css" title="win2k-1">
<script type="text/javascript" src="calendar/calendar.js"></script>
<script type="text/javascript" src="calendar/lang/calendar-en.js"></script>
<script type="text/javascript" src="calendar/calendar-setup.js"></script>
<script type="text/javascript">
<!--
var ew_DHTMLEditors = [];
//-->
</script>
<script language="JavaScript" type="text/javascript">
<!--
// Write your client script here, no need to add script tags.
// To include another .js script, use:
// ew_ClientScriptInclude("my_javascript.js");
//-->
</script>
<p><span class="phpmaker"><?php echo $Language->Phrase("Add") ?> <?php echo $Language->Phrase("TblTypeTABLE") ?><?php echo $CCMMessages->TableCaption() ?><br><br>
<a href="<?php echo $CCMMessages->getReturnUrl() ?>"><?php echo $Language->Phrase("GoBack") ?></a></span></p>
<?php
if (EW_DEBUG_ENABLED)
echo ew_DebugMsg();
$CCMMessages_add->ShowMessage();
?>
<form name="fCCMMessagesadd" id="fCCMMessagesadd" action="<?php echo ew_CurrentPage() ?>" method="post" enctype="multipart/form-data" onsubmit="return CCMMessages_add.ValidateForm(this);">
<p>
<input type="hidden" name="t" id="t" value="CCMMessages">
<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 ($CCMMessages->SentDateTime->Visible) { // SentDateTime ?>
<tr<?php echo $CCMMessages->SentDateTime->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->SentDateTime->FldCaption() ?></td>
<td<?php echo $CCMMessages->SentDateTime->CellAttributes() ?>><span id="el_SentDateTime">
<input type="text" name="x_SentDateTime" id="x_SentDateTime" title="<?php echo $CCMMessages->SentDateTime->FldTitle() ?>" value="<?php echo $CCMMessages->SentDateTime->EditValue ?>"<?php echo $CCMMessages->SentDateTime->EditAttributes() ?>>
<img src="images/calendar.png" id="cal_x_SentDateTime" name="cal_x_SentDateTime" alt="<?php echo $Language->Phrase("PickDate") ?>" title="<?php echo $Language->Phrase("PickDate") ?>" style="cursor:pointer;cursor:hand;">
<script type="text/javascript">
Calendar.setup({
inputField: "x_SentDateTime", // input field id
ifFormat: "%Y/%m/%d", // date format
button: "cal_x_SentDateTime" // button id
});
</script>
</span><?php echo $CCMMessages->SentDateTime->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->SentByName->Visible) { // SentByName ?>
<tr<?php echo $CCMMessages->SentByName->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->SentByName->FldCaption() ?></td>
<td<?php echo $CCMMessages->SentByName->CellAttributes() ?>><span id="el_SentByName">
<input type="text" name="x_SentByName" id="x_SentByName" title="<?php echo $CCMMessages->SentByName->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCMMessages->SentByName->EditValue ?>"<?php echo $CCMMessages->SentByName->EditAttributes() ?>>
</span><?php echo $CCMMessages->SentByName->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->SentTo->Visible) { // SentTo ?>
<tr<?php echo $CCMMessages->SentTo->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->SentTo->FldCaption() ?></td>
<td<?php echo $CCMMessages->SentTo->CellAttributes() ?>><span id="el_SentTo">
<textarea name="x_SentTo" id="x_SentTo" title="<?php echo $CCMMessages->SentTo->FldTitle() ?>" cols="35" rows="4"<?php echo $CCMMessages->SentTo->EditAttributes() ?>><?php echo $CCMMessages->SentTo->EditValue ?></textarea>
</span><?php echo $CCMMessages->SentTo->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->MessageSubject->Visible) { // MessageSubject ?>
<tr<?php echo $CCMMessages->MessageSubject->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->MessageSubject->FldCaption() ?></td>
<td<?php echo $CCMMessages->MessageSubject->CellAttributes() ?>><span id="el_MessageSubject">
<input type="text" name="x_MessageSubject" id="x_MessageSubject" title="<?php echo $CCMMessages->MessageSubject->FldTitle() ?>" size="30" maxlength="255" value="<?php echo $CCMMessages->MessageSubject->EditValue ?>"<?php echo $CCMMessages->MessageSubject->EditAttributes() ?>>
</span><?php echo $CCMMessages->MessageSubject->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->MessageText->Visible) { // MessageText ?>
<tr<?php echo $CCMMessages->MessageText->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->MessageText->FldCaption() ?></td>
<td<?php echo $CCMMessages->MessageText->CellAttributes() ?>><span id="el_MessageText">
<textarea name="x_MessageText" id="x_MessageText" title="<?php echo $CCMMessages->MessageText->FldTitle() ?>" cols="35" rows="4"<?php echo $CCMMessages->MessageText->EditAttributes() ?>><?php echo $CCMMessages->MessageText->EditValue ?></textarea>
</span><?php echo $CCMMessages->MessageText->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->SentByStudentID->Visible) { // SentByStudentID ?>
<tr<?php echo $CCMMessages->SentByStudentID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->SentByStudentID->FldCaption() ?></td>
<td<?php echo $CCMMessages->SentByStudentID->CellAttributes() ?>><span id="el_SentByStudentID">
<input type="text" name="x_SentByStudentID" id="x_SentByStudentID" title="<?php echo $CCMMessages->SentByStudentID->FldTitle() ?>" size="30" value="<?php echo $CCMMessages->SentByStudentID->EditValue ?>"<?php echo $CCMMessages->SentByStudentID->EditAttributes() ?>>
</span><?php echo $CCMMessages->SentByStudentID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->SentByFacilitatorID->Visible) { // SentByFacilitatorID ?>
<tr<?php echo $CCMMessages->SentByFacilitatorID->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->SentByFacilitatorID->FldCaption() ?></td>
<td<?php echo $CCMMessages->SentByFacilitatorID->CellAttributes() ?>><span id="el_SentByFacilitatorID">
<input type="text" name="x_SentByFacilitatorID" id="x_SentByFacilitatorID" title="<?php echo $CCMMessages->SentByFacilitatorID->FldTitle() ?>" size="30" value="<?php echo $CCMMessages->SentByFacilitatorID->EditValue ?>"<?php echo $CCMMessages->SentByFacilitatorID->EditAttributes() ?>>
</span><?php echo $CCMMessages->SentByFacilitatorID->CustomMsg ?></td>
</tr>
<?php } ?>
<?php if ($CCMMessages->MessageFile->Visible) { // MessageFile ?>
<tr<?php echo $CCMMessages->MessageFile->RowAttributes ?>>
<td class="ewTableHeader"><?php echo $CCMMessages->MessageFile->FldCaption() ?></td>
<td<?php echo $CCMMessages->MessageFile->CellAttributes() ?>><span id="el_MessageFile">
<input type="file" name="x_MessageFile" id="x_MessageFile" title="<?php echo $CCMMessages->MessageFile->FldTitle() ?>" size="30"<?php echo $CCMMessages->MessageFile->EditAttributes() ?>>
</div>
</span><?php echo $CCMMessages->MessageFile->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
$CCMMessages_add->Page_Terminate();
?>
<?php
//
// Page class
//
class cCCMMessages_add {
// Page ID
var $PageID = 'add';
// Table name
var $TableName = 'CCMMessages';
// Page object name
var $PageObjName = 'CCMMessages_add';
// Page name
function PageName() {
return ew_CurrentPage();
}
// Page URL
function PageUrl() {
$PageUrl = ew_CurrentPage() . "?";
global $CCMMessages;
if ($CCMMessages->UseTokenInUrl) $PageUrl .= "t=" . $CCMMessages->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, $CCMMessages;
if ($CCMMessages->UseTokenInUrl) {
if ($objForm)
return ($CCMMessages->TableVar == $objForm->GetValue("t"));
if (@$_GET["t"] <> "")
return ($CCMMessages->TableVar == $_GET["t"]);
} else {
return TRUE;
}
}
//
// Page class constructor
//
function cCCMMessages_add() {
global $conn, $Language;
// Language object
$Language = new cLanguage();
// Table object (CCMMessages)
$GLOBALS["CCMMessages"] = new cCCMMessages();
// Table object (CCMUsers)
$GLOBALS['CCMUsers'] = new cCCMUsers();
// 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", 'CCMMessages', 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 $CCMMessages;
// Security
$Security = new cAdvancedSecurity();
if (!$Security->IsLoggedIn()) $Security->AutoLogin();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
$Security->TablePermission_Loading();
$Security->LoadCurrentUserLevel($this->TableName);
$Security->TablePermission_Loaded();
if (!$Security->IsLoggedIn()) {
$Security->SaveLastUrl();
$this->Page_Terminate("login.php");
}
if (!$Security->CanAdd()) {
$Security->SaveLastUrl();
$this->Page_Terminate("CCMMessageslist.php");
}
// Create form object
$objForm = new cFormObj();
// Global Page Loading event (in userfn*.php)
Page_Loading();
// Page Load event
$this->Page_Load();
}
//
// Page_Terminate
//
function Page_Terminate($url = "") {
global $conn;
// Page Unload event
$this->Page_Unload();
// Global Page Unloaded event (in userfn*.php)
Page_Unloaded();
// Close connection
$conn->Close();
// Go to URL if specified
$this->Page_Redirecting($url);
if ($url <> "") {
if (!EW_DEBUG_ENABLED && ob_get_length())
ob_end_clean();
header("Location: " . $url);
}
exit();
}
var $sDbMasterFilter = "";
var $sDbDetailFilter = "";
var $lPriv = 0;
//
// Page main
//
function Page_Main() {
global $objForm, $Language, $gsFormError, $CCMMessages;
// Load key values from QueryString
$bCopy = TRUE;
if (@$_GET["CCMMessageID"] != "") {
$CCMMessages->CCMMessageID->setQueryStringValue($_GET["CCMMessageID"]);
} else {
$bCopy = FALSE;
}
// Process form if post back
if (@$_POST["a_add"] <> "") {
$CCMMessages->CurrentAction = $_POST["a_add"]; // Get form action
$this->GetUploadFiles(); // Get upload files
$this->LoadFormValues(); // Load form values
// Validate form
if (!$this->ValidateForm()) {
$CCMMessages->CurrentAction = "I"; // Form error, reset action
$this->setMessage($gsFormError);
}
} else { // Not post back
if ($bCopy) {
$CCMMessages->CurrentAction = "C"; // Copy record
} else {
$CCMMessages->CurrentAction = "I"; // Display blank record
$this->LoadDefaultValues(); // Load default values
}
}
// Perform action based on action code
switch ($CCMMessages->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("CCMMessageslist.php"); // No matching record, return to list
}
break;
case "A": // ' Add new record
$CCMMessages->SendEmail = TRUE; // Send email on add success
if ($this->AddRow()) { // Add successful
$this->setMessage($Language->Phrase("AddSuccess")); // Set up success message
$sReturnUrl = $CCMMessages->getReturnUrl();
if (ew_GetPageName($sReturnUrl) == "CCMMessagesview.php")
$sReturnUrl = $CCMMessages->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
$CCMMessages->RowType = EW_ROWTYPE_ADD; // Render add type
// Render row
$this->RenderRow();
}
// Get upload files
function GetUploadFiles() {
global $objForm, $CCMMessages;
// Get upload data
if ($CCMMessages->MessageFile->Upload->UploadFile()) {
// No action required
} else {
echo $CCMMessages->MessageFile->Upload->Message;
$this->Page_Terminate();
exit();
}
}
// Load default values
function LoadDefaultValues() {
global $CCMMessages;
$CCMMessages->MessageFile->CurrentValue = NULL; // Clear file related field
}
// Load form values
function LoadFormValues() {
// Load from form
global $objForm, $CCMMessages;
$CCMMessages->SentDateTime->setFormValue($objForm->GetValue("x_SentDateTime"));
$CCMMessages->SentDateTime->CurrentValue = ew_UnFormatDateTime($CCMMessages->SentDateTime->CurrentValue, 5);
$CCMMessages->SentByName->setFormValue($objForm->GetValue("x_SentByName"));
$CCMMessages->SentTo->setFormValue($objForm->GetValue("x_SentTo"));
$CCMMessages->MessageSubject->setFormValue($objForm->GetValue("x_MessageSubject"));
$CCMMessages->MessageText->setFormValue($objForm->GetValue("x_MessageText"));
$CCMMessages->SentByStudentID->setFormValue($objForm->GetValue("x_SentByStudentID"));
$CCMMessages->SentByFacilitatorID->setFormValue($objForm->GetValue("x_SentByFacilitatorID"));
$CCMMessages->CCMMessageID->setFormValue($objForm->GetValue("x_CCMMessageID"));
}
// Restore form values
function RestoreFormValues() {
global $objForm, $CCMMessages;
$CCMMessages->CCMMessageID->CurrentValue = $CCMMessages->CCMMessageID->FormValue;
$CCMMessages->SentDateTime->CurrentValue = $CCMMessages->SentDateTime->FormValue;
$CCMMessages->SentDateTime->CurrentValue = ew_UnFormatDateTime($CCMMessages->SentDateTime->CurrentValue, 5);
$CCMMessages->SentByName->CurrentValue = $CCMMessages->SentByName->FormValue;
$CCMMessages->SentTo->CurrentValue = $CCMMessages->SentTo->FormValue;
$CCMMessages->MessageSubject->CurrentValue = $CCMMessages->MessageSubject->FormValue;
$CCMMessages->MessageText->CurrentValue = $CCMMessages->MessageText->FormValue;
$CCMMessages->SentByStudentID->CurrentValue = $CCMMessages->SentByStudentID->FormValue;
$CCMMessages->SentByFacilitatorID->CurrentValue = $CCMMessages->SentByFacilitatorID->FormValue;
}
// Load row based on key values
function LoadRow() {
global $conn, $Security, $CCMMessages;
$sFilter = $CCMMessages->KeyFilter();
// Call Row Selecting event
$CCMMessages->Row_Selecting($sFilter);
// Load SQL based on filter
$CCMMessages->CurrentFilter = $sFilter;
$sSql = $CCMMessages->SQL();
$res = FALSE;
$rs = ew_LoadRecordset($sSql);
if ($rs && !$rs->EOF) {
$res = TRUE;
$this->LoadRowValues($rs); // Load row values
// Call Row Selected event
$CCMMessages->Row_Selected($rs);
$rs->Close();
}
return $res;
}
// Load row values from recordset
function LoadRowValues(&$rs) {
global $conn, $CCMMessages;
$CCMMessages->CCMMessageID->setDbValue($rs->fields('CCMMessageID'));
$CCMMessages->SentDateTime->setDbValue($rs->fields('SentDateTime'));
$CCMMessages->SentByName->setDbValue($rs->fields('SentByName'));
$CCMMessages->SentTo->setDbValue($rs->fields('SentTo'));
$CCMMessages->MessageSubject->setDbValue($rs->fields('MessageSubject'));
$CCMMessages->MessageText->setDbValue($rs->fields('MessageText'));
$CCMMessages->SentByStudentID->setDbValue($rs->fields('SentByStudentID'));
$CCMMessages->SentByFacilitatorID->setDbValue($rs->fields('SentByFacilitatorID'));
$CCMMessages->MessageFile->Upload->DbValue = $rs->fields('MessageFile');
}
// Render row values based on field settings
function RenderRow() {
global $conn, $Security, $Language, $CCMMessages;
// Initialize URLs
// Call Row_Rendering event
$CCMMessages->Row_Rendering();
// Common render codes for all row types
// SentDateTime
$CCMMessages->SentDateTime->CellCssStyle = ""; $CCMMessages->SentDateTime->CellCssClass = "";
$CCMMessages->SentDateTime->CellAttrs = array(); $CCMMessages->SentDateTime->ViewAttrs = array(); $CCMMessages->SentDateTime->EditAttrs = array();
// SentByName
$CCMMessages->SentByName->CellCssStyle = ""; $CCMMessages->SentByName->CellCssClass = "";
$CCMMessages->SentByName->CellAttrs = array(); $CCMMessages->SentByName->ViewAttrs = array(); $CCMMessages->SentByName->EditAttrs = array();
// SentTo
$CCMMessages->SentTo->CellCssStyle = ""; $CCMMessages->SentTo->CellCssClass = "";
$CCMMessages->SentTo->CellAttrs = array(); $CCMMessages->SentTo->ViewAttrs = array(); $CCMMessages->SentTo->EditAttrs = array();
// MessageSubject
$CCMMessages->MessageSubject->CellCssStyle = ""; $CCMMessages->MessageSubject->CellCssClass = "";
$CCMMessages->MessageSubject->CellAttrs = array(); $CCMMessages->MessageSubject->ViewAttrs = array(); $CCMMessages->MessageSubject->EditAttrs = array();
// MessageText
$CCMMessages->MessageText->CellCssStyle = ""; $CCMMessages->MessageText->CellCssClass = "";
$CCMMessages->MessageText->CellAttrs = array(); $CCMMessages->MessageText->ViewAttrs = array(); $CCMMessages->MessageText->EditAttrs = array();
// SentByStudentID
$CCMMessages->SentByStudentID->CellCssStyle = ""; $CCMMessages->SentByStudentID->CellCssClass = "";
$CCMMessages->SentByStudentID->CellAttrs = array(); $CCMMessages->SentByStudentID->ViewAttrs = array(); $CCMMessages->SentByStudentID->EditAttrs = array();
// SentByFacilitatorID
$CCMMessages->SentByFacilitatorID->CellCssStyle = ""; $CCMMessages->SentByFacilitatorID->CellCssClass = "";
$CCMMessages->SentByFacilitatorID->CellAttrs = array(); $CCMMessages->SentByFacilitatorID->ViewAttrs = array(); $CCMMessages->SentByFacilitatorID->EditAttrs = array();
// MessageFile
$CCMMessages->MessageFile->CellCssStyle = ""; $CCMMessages->MessageFile->CellCssClass = "";
$CCMMessages->MessageFile->CellAttrs = array(); $CCMMessages->MessageFile->ViewAttrs = array(); $CCMMessages->MessageFile->EditAttrs = array();
if ($CCMMessages->RowType == EW_ROWTYPE_VIEW) { // View row
// CCMMessageID
$CCMMessages->CCMMessageID->ViewValue = $CCMMessages->CCMMessageID->CurrentValue;
$CCMMessages->CCMMessageID->CssStyle = "";
$CCMMessages->CCMMessageID->CssClass = "";
$CCMMessages->CCMMessageID->ViewCustomAttributes = "";
// SentDateTime
$CCMMessages->SentDateTime->ViewValue = $CCMMessages->SentDateTime->CurrentValue;
$CCMMessages->SentDateTime->ViewValue = ew_FormatDateTime($CCMMessages->SentDateTime->ViewValue, 5);
$CCMMessages->SentDateTime->CssStyle = "";
$CCMMessages->SentDateTime->CssClass = "";
$CCMMessages->SentDateTime->ViewCustomAttributes = "";
// SentByName
$CCMMessages->SentByName->ViewValue = $CCMMessages->SentByName->CurrentValue;
$CCMMessages->SentByName->CssStyle = "";
$CCMMessages->SentByName->CssClass = "";
$CCMMessages->SentByName->ViewCustomAttributes = "";
// SentTo
$CCMMessages->SentTo->ViewValue = $CCMMessages->SentTo->CurrentValue;
$CCMMessages->SentTo->CssStyle = "";
$CCMMessages->SentTo->CssClass = "";
$CCMMessages->SentTo->ViewCustomAttributes = "";
// MessageSubject
$CCMMessages->MessageSubject->ViewValue = $CCMMessages->MessageSubject->CurrentValue;
$CCMMessages->MessageSubject->CssStyle = "";
$CCMMessages->MessageSubject->CssClass = "";
$CCMMessages->MessageSubject->ViewCustomAttributes = "";
// MessageText
$CCMMessages->MessageText->ViewValue = $CCMMessages->MessageText->CurrentValue;
$CCMMessages->MessageText->CssStyle = "";
$CCMMessages->MessageText->CssClass = "";
$CCMMessages->MessageText->ViewCustomAttributes = "";
// SentByStudentID
$CCMMessages->SentByStudentID->ViewValue = $CCMMessages->SentByStudentID->CurrentValue;
$CCMMessages->SentByStudentID->CssStyle = "";
$CCMMessages->SentByStudentID->CssClass = "";
$CCMMessages->SentByStudentID->ViewCustomAttributes = "";
// SentByFacilitatorID
$CCMMessages->SentByFacilitatorID->ViewValue = $CCMMessages->SentByFacilitatorID->CurrentValue;
$CCMMessages->SentByFacilitatorID->CssStyle = "";
$CCMMessages->SentByFacilitatorID->CssClass = "";
$CCMMessages->SentByFacilitatorID->ViewCustomAttributes = "";
// MessageFile
if (!ew_Empty($CCMMessages->MessageFile->Upload->DbValue)) {
$CCMMessages->MessageFile->ViewValue = $CCMMessages->MessageFile->Upload->DbValue;
} else {
$CCMMessages->MessageFile->ViewValue = "";
}
$CCMMessages->MessageFile->CssStyle = "";
$CCMMessages->MessageFile->CssClass = "";
$CCMMessages->MessageFile->ViewCustomAttributes = "";
// SentDateTime
$CCMMessages->SentDateTime->HrefValue = "";
$CCMMessages->SentDateTime->TooltipValue = "";
// SentByName
$CCMMessages->SentByName->HrefValue = "";
$CCMMessages->SentByName->TooltipValue = "";
// SentTo
$CCMMessages->SentTo->HrefValue = "";
$CCMMessages->SentTo->TooltipValue = "";
// MessageSubject
$CCMMessages->MessageSubject->HrefValue = "";
$CCMMessages->MessageSubject->TooltipValue = "";
// MessageText
$CCMMessages->MessageText->HrefValue = "";
$CCMMessages->MessageText->TooltipValue = "";
// SentByStudentID
$CCMMessages->SentByStudentID->HrefValue = "";
$CCMMessages->SentByStudentID->TooltipValue = "";
// SentByFacilitatorID
$CCMMessages->SentByFacilitatorID->HrefValue = "";
$CCMMessages->SentByFacilitatorID->TooltipValue = "";
// MessageFile
if (!ew_Empty($CCMMessages->MessageFile->Upload->DbValue)) {
$CCMMessages->MessageFile->HrefValue = ew_UploadPathEx(FALSE, $CCMMessages->MessageFile->UploadPath) . ((!empty($CCMMessages->MessageFile->ViewValue)) ? $CCMMessages->MessageFile->ViewValue : $CCMMessages->MessageFile->CurrentValue);
if ($CCMMessages->Export <> "") $CCMMessages->MessageFile->HrefValue = ew_ConvertFullUrl($CCMMessages->MessageFile->HrefValue);
} else {
$CCMMessages->MessageFile->HrefValue = "";
}
$CCMMessages->MessageFile->TooltipValue = "";
} elseif ($CCMMessages->RowType == EW_ROWTYPE_ADD) { // Add row
// SentDateTime
$CCMMessages->SentDateTime->EditCustomAttributes = "";
$CCMMessages->SentDateTime->EditValue = ew_HtmlEncode(ew_FormatDateTime($CCMMessages->SentDateTime->CurrentValue, 5));
// SentByName
$CCMMessages->SentByName->EditCustomAttributes = "";
$CCMMessages->SentByName->EditValue = ew_HtmlEncode($CCMMessages->SentByName->CurrentValue);
// SentTo
$CCMMessages->SentTo->EditCustomAttributes = "";
$CCMMessages->SentTo->EditValue = ew_HtmlEncode($CCMMessages->SentTo->CurrentValue);
// MessageSubject
$CCMMessages->MessageSubject->EditCustomAttributes = "";
$CCMMessages->MessageSubject->EditValue = ew_HtmlEncode($CCMMessages->MessageSubject->CurrentValue);
// MessageText
$CCMMessages->MessageText->EditCustomAttributes = "";
$CCMMessages->MessageText->EditValue = ew_HtmlEncode($CCMMessages->MessageText->CurrentValue);
// SentByStudentID
$CCMMessages->SentByStudentID->EditCustomAttributes = "";
$CCMMessages->SentByStudentID->EditValue = ew_HtmlEncode($CCMMessages->SentByStudentID->CurrentValue);
// SentByFacilitatorID
$CCMMessages->SentByFacilitatorID->EditCustomAttributes = "";
$CCMMessages->SentByFacilitatorID->EditValue = ew_HtmlEncode($CCMMessages->SentByFacilitatorID->CurrentValue);
// MessageFile
$CCMMessages->MessageFile->EditCustomAttributes = "";
if (!ew_Empty($CCMMessages->MessageFile->Upload->DbValue)) {
$CCMMessages->MessageFile->EditValue = $CCMMessages->MessageFile->Upload->DbValue;
} else {
$CCMMessages->MessageFile->EditValue = "";
}
}
// Call Row Rendered event
if ($CCMMessages->RowType <> EW_ROWTYPE_AGGREGATEINIT)
$CCMMessages->Row_Rendered();
}
// Validate form
function ValidateForm() {
global $Language, $gsFormError, $CCMMessages;
// Initialize form error message
$gsFormError = "";
if (!ew_CheckFileType($CCMMessages->MessageFile->Upload->FileName)) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("WrongFileType");
}
if ($CCMMessages->MessageFile->Upload->FileSize > 0 && EW_MAX_FILE_SIZE > 0 && $CCMMessages->MessageFile->Upload->FileSize > EW_MAX_FILE_SIZE) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= str_replace("%s", EW_MAX_FILE_SIZE, $Language->Phrase("MaxFileSize"));
}
if (in_array($CCMMessages->MessageFile->Upload->Error, array(1, 2, 3, 6, 7, 8))) {
$gsFormError .= ($gsFormError <> "") ? "<br>" : "";
$gsFormError .= $Language->Phrase("PhpUploadErr" . $CCMMessages->MessageFile->Upload->Error);
}
// Check if validation required
if (!EW_SERVER_VALIDATE)
return ($gsFormError == "");
if (!ew_CheckDate($CCMMessages->SentDateTime->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCMMessages->SentDateTime->FldErrMsg();
}
if (!ew_CheckInteger($CCMMessages->SentByStudentID->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCMMessages->SentByStudentID->FldErrMsg();
}
if (!ew_CheckInteger($CCMMessages->SentByFacilitatorID->FormValue)) {
if ($gsFormError <> "") $gsFormError .= "<br>";
$gsFormError .= $CCMMessages->SentByFacilitatorID->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, $CCMMessages;
$rsnew = array();
// SentDateTime
$CCMMessages->SentDateTime->SetDbValueDef($rsnew, ew_UnFormatDateTime($CCMMessages->SentDateTime->CurrentValue, 5, FALSE), NULL);
// SentByName
$CCMMessages->SentByName->SetDbValueDef($rsnew, $CCMMessages->SentByName->CurrentValue, NULL, FALSE);
// SentTo
$CCMMessages->SentTo->SetDbValueDef($rsnew, $CCMMessages->SentTo->CurrentValue, NULL, FALSE);
// MessageSubject
$CCMMessages->MessageSubject->SetDbValueDef($rsnew, $CCMMessages->MessageSubject->CurrentValue, NULL, FALSE);
// MessageText
$CCMMessages->MessageText->SetDbValueDef($rsnew, $CCMMessages->MessageText->CurrentValue, NULL, FALSE);
// SentByStudentID
$CCMMessages->SentByStudentID->SetDbValueDef($rsnew, $CCMMessages->SentByStudentID->CurrentValue, NULL, FALSE);
// SentByFacilitatorID
$CCMMessages->SentByFacilitatorID->SetDbValueDef($rsnew, $CCMMessages->SentByFacilitatorID->CurrentValue, NULL, FALSE);
// MessageFile
$CCMMessages->MessageFile->Upload->SaveToSession(); // Save file value to Session
if (is_null($CCMMessages->MessageFile->Upload->Value)) {
$rsnew['MessageFile'] = NULL;
} else {
$rsnew['MessageFile'] = ew_UploadFileNameEx(ew_UploadPathEx(TRUE, $CCMMessages->MessageFile->UploadPath), $CCMMessages->MessageFile->Upload->FileName);
}
// Call Row Inserting event
$bInsertRow = $CCMMessages->Row_Inserting($rsnew);
if ($bInsertRow) {
if (!ew_Empty($CCMMessages->MessageFile->Upload->Value)) {
$CCMMessages->MessageFile->Upload->SaveToFile($CCMMessages->MessageFile->UploadPath, $rsnew['MessageFile'], FALSE);
}
$conn->raiseErrorFn = 'ew_ErrorFn';
$AddRow = $conn->Execute($CCMMessages->InsertSQL($rsnew));
$conn->raiseErrorFn = '';
} else {
if ($CCMMessages->CancelMessage <> "") {
$this->setMessage($CCMMessages->CancelMessage);
$CCMMessages->CancelMessage = "";
} else {
$this->setMessage($Language->Phrase("InsertCancelled"));
}
$AddRow = FALSE;
}
if ($AddRow) {
$CCMMessages->CCMMessageID->setDbValue($conn->Insert_ID());
$rsnew['CCMMessageID'] = $CCMMessages->CCMMessageID->DbValue;
// Call Row Inserted event
$CCMMessages->Row_Inserted($rsnew);
}
// MessageFile
$CCMMessages->MessageFile->Upload->RemoveFromSession(); // Remove file value from Session
return $AddRow;
}
// 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;
}
}
?>