/osj-osj2dapplicationsadd.php
PHP | 682 lines | 516 code | 80 blank | 86 comment | 90 complexity | b2b5bf3113a13f06b41e89ff8b116482 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
- <?php
- define("EW_PAGE_ID", "add", TRUE); // Page ID
- define("EW_TABLE_NAME", 'osj-applications', TRUE);
- ?>
- <?php
- session_start(); // Initialize session data
- ob_start(); // Turn on output buffering
- ?>
- <?php include "osj-ewcfg50.php" ?>
- <?php include "osj-ewmysql50.php" ?>
- <?php include "osj-phpfn50.php" ?>
- <?php include "osj-osj2dapplicationsinfo.php" ?>
- <?php include "osj-userfn50.php" ?>
- <?php include "osj-osj2dusersinfo.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
-
- // Open connection to the database
- $conn = ew_Connect();
- ?>
- <?php
- $Security = new cAdvancedSecurity();
- ?>
- <?php
- if (!$Security->IsLoggedIn()) $Security->AutoLogin();
- $Security->LoadCurrentUserLevel('osj-applications');
- if (!$Security->IsLoggedIn()) {
- $Security->SaveLastUrl();
- Page_Terminate("osj-login.php");
- }
- if (!$Security->CanAdd()) {
- $Security->SaveLastUrl();
- Page_Terminate("osj-osj2dapplicationslist.php");
- }
- if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
- $_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
- Page_Terminate("osj-login.php");
- }
- ?>
- <?php
-
- // Common page loading event (in userfn*.php)
- Page_Loading();
- ?>
- <?php
-
- // Page load event, used in current page
- Page_Load();
- ?>
- <?php
- $osj2Dapplications->Export = @$_GET["export"]; // Get export parameter
- $sExport = $osj2Dapplications->Export; // Get export parameter, used in header
- $sExportFile = $osj2Dapplications->TableVar; // Get export file, used in header
- ?>
- <?php
-
- // Load key values from QueryString
- $bCopy = TRUE;
- if (@$_GET["application_id"] != "") {
- $osj2Dapplications->application_id->setQueryStringValue($_GET["application_id"]);
- } else {
- $bCopy = FALSE;
- }
-
- // Create form object
- $objForm = new cFormObj();
-
- // Process form if post back
- if (@$_POST["a_add"] <> "") {
- $osj2Dapplications->CurrentAction = $_POST["a_add"]; // Get form action
- GetUploadFiles(); // Get upload files
- LoadFormValues(); // Load form values
- } else { // Not post back
- if ($bCopy) {
- $osj2Dapplications->CurrentAction = "C"; // Copy Record
- } else {
- $osj2Dapplications->CurrentAction = "I"; // Display Blank Record
- LoadDefaultValues(); // Load default values
- }
- }
-
- // Perform action based on action code
- switch ($osj2Dapplications->CurrentAction) {
- case "I": // Blank record, no action required
- break;
- case "C": // Copy an existing record
- if (!LoadRow()) { // Load record based on key
- $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
- Page_Terminate($osj2Dapplications->getReturnUrl()); // Clean up and return
- }
- break;
- case "A": // ' Add new record
- $osj2Dapplications->SendEmail = TRUE; // Send email on add success
- if (AddRow()) { // Add successful
- $_SESSION[EW_SESSION_MESSAGE] = "Add New Record Successful"; // Set up success message
- Page_Terminate($osj2Dapplications->KeyUrl($osj2Dapplications->getReturnUrl())); // Clean up and return
- } else {
- RestoreFormValues(); // Add failed, restore form values
- }
- }
-
- // Render row based on row type
- $osj2Dapplications->RowType = EW_ROWTYPE_ADD; // Render add type
- RenderRow();
- ?>
- <?php include "osj-header.php" ?>
- <script type="text/javascript">
- <!--
- var EW_PAGE_ID = "add"; // Page id
- var EW_SHOW_HIGHLIGHT = "Show highlight";
- var EW_HIDE_HIGHLIGHT = "Hide highlight";
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- function ew_ValidateForm(fobj) {
- 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 + "_resume_id"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Resume"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_post_id"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Post ID"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_post_id"];
- if (elm && !ew_CheckInteger(elm.value)) {
- if (!ew_OnError(elm, "A post id is required."))
- return false;
- }
- elm = fobj.elements["x" + infix + "_application_email"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Application Email"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_application_email"];
- if (elm && !ew_CheckEmail(elm.value)) {
- if (!ew_OnError(elm, "All applications require an email address."))
- return false;
- }
- elm = fobj.elements["x" + infix + "_application_text"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Application Comments"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_application_file"];
- aelm = fobj.elements["a" + infix + "_application_file"];
- var chk_application_file = (aelm && aelm[0])?(aelm[2].checked):true;
- if (elm && chk_application_file && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Application Attachment"))
- return false;
- }
- elm = fobj.elements["x" + infix + "_application_file"];
- if (elm && !ew_CheckFileType(elm.value)) {
- if (!ew_OnError(elm, "File type is not allowed."))
- return false;
- }
- elm = fobj.elements["x" + infix + "_application_file_name"];
- if (elm && !ew_HasValue(elm)) {
- if (!ew_OnError(elm, "Please enter required field - Application File Name"))
- return false;
- }
- }
- return true;
- }
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
- var ew_DHTMLEditors = [];
-
- //-->
- </script>
- <script type="text/javascript">
- <!--
-
- // js for Popup Calendar
- //-->
-
- </script>
- <script type="text/javascript">
- <!--
- var ew_MultiPagePage = "Page"; // multi-page Page Text
- var ew_MultiPageOf = "of"; // multi-page Of Text
- var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
- var ew_MultiPageNext = "Next"; // multi-page Next Text
-
- //-->
- </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">Add to TABLE: Applications<br><br><a href="<?php echo $osj2Dapplications->getReturnUrl() ?>">Go Back</a></span></p>
- <?php
- if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Mesasge in Session, display
- ?>
- <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
- <?php
- $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
- }
- ?>
- <form name="fosj2Dapplicationsadd" id="fosj2Dapplicationsadd" action="osj-osj2dapplicationsadd.php" method="post" enctype="multipart/form-data" onSubmit="return ew_ValidateForm(this);">
- <p>
- <input type="hidden" name="a_add" id="a_add" value="A">
- <table class="ewTable">
- <tr class="ewTableRow">
- <td class="ewTableHeader">Resume<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dapplications->resume_id->CellAttributes() ?>><span id="cb_x_resume_id">
- <select id="x_resume_id" name="x_resume_id"<?php echo $osj2Dapplications->resume_id->EditAttributes() ?>>
- <!--option value="">Please Select</option-->
- <?php
- if (is_array($osj2Dapplications->resume_id->EditValue)) {
- $arwrk = $osj2Dapplications->resume_id->EditValue;
- $rowswrk = count($arwrk);
- for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
- $selwrk = (strval($osj2Dapplications->resume_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
- ?>
- <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
- <?php echo $arwrk[$rowcntwrk][1] ?>
- </option>
- <?php
- }
- }
- ?>
- </select>
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">Post ID<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dapplications->post_id->CellAttributes() ?>><span id="cb_x_post_id">
- <input type="text" name="x_post_id" id="x_post_id" size="30" value="<?php echo $osj2Dapplications->post_id->EditValue ?>"<?php echo $osj2Dapplications->post_id->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableRow">
- <td class="ewTableHeader">Application Email<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dapplications->application_email->CellAttributes() ?>><span id="cb_x_application_email">
- <input type="text" name="x_application_email" id="x_application_email" title="Email" size="30" maxlength="255" value="<?php echo $osj2Dapplications->application_email->EditValue ?>"<?php echo $osj2Dapplications->application_email->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">Application Comments<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dapplications->application_text->CellAttributes() ?>><span id="cb_x_application_text">
- <textarea name="x_application_text" id="x_application_text" cols="35" rows="4"<?php echo $osj2Dapplications->application_text->EditAttributes() ?>><?php echo $osj2Dapplications->application_text->EditValue ?></textarea>
- </span></td>
- </tr>
- <tr class="ewTableRow">
- <td class="ewTableHeader">Application Attachment<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dapplications->application_file->CellAttributes() ?>><span id="cb_x_application_file">
- <input type="file" name="x_application_file" id="x_application_file" title="Resume Attachment" size="30"<?php echo $osj2Dapplications->application_file->EditAttributes() ?>>
- </span></td>
- </tr>
- <tr class="ewTableAltRow">
- <td class="ewTableHeader">Application File Name<span class='ewmsg'> *</span></td>
- <td<?php echo $osj2Dapplications->application_file_name->CellAttributes() ?>><span id="cb_x_application_file_name">
- <input type="text" name="x_application_file_name" id="x_application_file_name" title="Resume Attachment Filename" size="30" maxlength="255" value="<?php echo $osj2Dapplications->application_file_name->EditValue ?>"<?php echo $osj2Dapplications->application_file_name->EditAttributes() ?>>
- </span></td>
- </tr>
- </table>
- <p>
- <input type="submit" name="btnAction" id="btnAction" value=" Add ">
- </form>
- <script language="JavaScript" type="text/javascript">
- <!--
-
- // Write your table-specific startup script here
- // document.write("page loaded");
- //-->
-
- </script>
- <?php include "osj-footer.php" ?>
- <?php
-
- // If control is passed here, simply terminate the page without redirect
- Page_Terminate();
-
- // -----------------------------------------------------------------
- // Subroutine Page_Terminate
- // - called when exit page
- // - clean up connection and objects
- // - if url specified, redirect to url, otherwise end response
- function Page_Terminate($url = "") {
- global $conn;
-
- // Page unload event, used in current page
- Page_Unload();
-
- // Global page unloaded event (in userfn*.php)
- Page_Unloaded();
-
- // Close Connection
- $conn->Close();
-
- // Go to url if specified
- if ($url <> "") {
- ob_end_clean();
- header("Location: $url");
- }
- exit();
- }
- ?>
- <?php
-
- // Function Get upload files
- function GetUploadFiles() {
- global $objForm, $osj2Dapplications;
-
- // Get upload data
- if ($osj2Dapplications->application_file->Upload->UploadFile()) {
-
- // No action required
- } else {
- echo $osj2Dapplications->application_file->Upload->Message;
- exit();
- }
- }
- ?>
- <?php
-
- // Load default values
- function LoadDefaultValues() {
- global $osj2Dapplications;
- $osj2Dapplications->user_id->CurrentValue = 0;
- $osj2Dapplications->resume_id->CurrentValue = 0;
- $osj2Dapplications->post_id->CurrentValue = $_REQUEST["post_id"];
- $osj2Dapplications->application_date->CurrentValue = "0000-00-00 00:00:00";
- $osj2Dapplications->application_file_name->CurrentValue = NULL; // Clear file related field
- }
- ?>
- <?php
-
- // Load form values
- function LoadFormValues() {
-
- // Load from form
- global $objForm, $osj2Dapplications;
- $osj2Dapplications->user_id->setFormValue($objForm->GetValue("x_user_id"));
- $osj2Dapplications->resume_id->setFormValue($objForm->GetValue("x_resume_id"));
- $osj2Dapplications->post_id->setFormValue($objForm->GetValue("x_post_id"));
- $osj2Dapplications->application_date->setFormValue($objForm->GetValue("x_application_date"));
- $osj2Dapplications->application_date->CurrentValue = ew_UnFormatDateTime($osj2Dapplications->application_date->CurrentValue, 6);
- $osj2Dapplications->application_email->setFormValue($objForm->GetValue("x_application_email"));
- $osj2Dapplications->application_text->setFormValue($objForm->GetValue("x_application_text"));
- }
-
- // Restore form values
- function RestoreFormValues() {
- global $osj2Dapplications;
- $osj2Dapplications->user_id->CurrentValue = $osj2Dapplications->user_id->FormValue;
- $osj2Dapplications->resume_id->CurrentValue = $osj2Dapplications->resume_id->FormValue;
- $osj2Dapplications->post_id->CurrentValue = $osj2Dapplications->post_id->FormValue;
- $osj2Dapplications->application_date->CurrentValue = $osj2Dapplications->application_date->FormValue;
- $osj2Dapplications->application_date->CurrentValue = ew_UnFormatDateTime($osj2Dapplications->application_date->CurrentValue, 6);
- $osj2Dapplications->application_email->CurrentValue = $osj2Dapplications->application_email->FormValue;
- $osj2Dapplications->application_text->CurrentValue = $osj2Dapplications->application_text->FormValue;
- }
- ?>
- <?php
-
- // Load row based on key values
- function LoadRow() {
- global $conn, $Security, $osj2Dapplications;
- $sFilter = $osj2Dapplications->SqlKeyFilter();
- if (!is_numeric($osj2Dapplications->application_id->CurrentValue)) {
- return FALSE; // Invalid key, exit
- }
- $sFilter = str_replace("@application_id@", ew_AdjustSql($osj2Dapplications->application_id->CurrentValue), $sFilter); // Replace key value
- if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
- $sFilter = $osj2Dapplications->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
- }
-
- // Call Row Selecting event
- $osj2Dapplications->Row_Selecting($sFilter);
-
- // Load sql based on filter
- $osj2Dapplications->CurrentFilter = $sFilter;
- $sSql = $osj2Dapplications->SQL();
- if ($rs = $conn->Execute($sSql)) {
- if ($rs->EOF) {
- $LoadRow = FALSE;
- } else {
- $LoadRow = TRUE;
- $rs->MoveFirst();
- LoadRowValues($rs); // Load row values
-
- // Call Row Selected event
- $osj2Dapplications->Row_Selected($rs);
- }
- $rs->Close();
- } else {
- $LoadRow = FALSE;
- }
- return $LoadRow;
- }
-
- // Load row values from recordset
- function LoadRowValues(&$rs) {
- global $osj2Dapplications;
- $osj2Dapplications->application_id->setDbValue($rs->fields('application_id'));
- $osj2Dapplications->user_id->setDbValue($rs->fields('user_id'));
- $osj2Dapplications->resume_id->setDbValue($rs->fields('resume_id'));
- $osj2Dapplications->post_id->setDbValue($rs->fields('post_id'));
- $osj2Dapplications->application_date->setDbValue($rs->fields('application_date'));
- $osj2Dapplications->application_email->setDbValue($rs->fields('application_email'));
- $osj2Dapplications->application_text->setDbValue($rs->fields('application_text'));
- $osj2Dapplications->application_file->Upload->DbValue = $rs->fields('application_file');
- $osj2Dapplications->application_file_name->setDbValue($rs->fields('application_file_name'));
- }
- ?>
- <?php
-
- // Render row values based on field settings
- function RenderRow() {
- global $conn, $Security, $osj2Dapplications;
-
- // Call Row Rendering event
- $osj2Dapplications->Row_Rendering();
-
- // Common render codes for all row types
- // user_id
-
- $osj2Dapplications->user_id->CellCssStyle = "";
- $osj2Dapplications->user_id->CellCssClass = "";
-
- // resume_id
- $osj2Dapplications->resume_id->CellCssStyle = "";
- $osj2Dapplications->resume_id->CellCssClass = "";
-
- // post_id
- $osj2Dapplications->post_id->CellCssStyle = "";
- $osj2Dapplications->post_id->CellCssClass = "";
-
- // application_date
- $osj2Dapplications->application_date->CellCssStyle = "";
- $osj2Dapplications->application_date->CellCssClass = "";
-
- // application_email
- $osj2Dapplications->application_email->CellCssStyle = "";
- $osj2Dapplications->application_email->CellCssClass = "";
-
- // application_text
- $osj2Dapplications->application_text->CellCssStyle = "";
- $osj2Dapplications->application_text->CellCssClass = "";
-
- // application_file
- $osj2Dapplications->application_file->CellCssStyle = "";
- $osj2Dapplications->application_file->CellCssClass = "";
-
- // application_file_name
- $osj2Dapplications->application_file_name->CellCssStyle = "";
- $osj2Dapplications->application_file_name->CellCssClass = "";
- if ($osj2Dapplications->RowType == EW_ROWTYPE_VIEW) { // View row
- } elseif ($osj2Dapplications->RowType == EW_ROWTYPE_ADD) { // Add row
-
- // resume_id
- $osj2Dapplications->resume_id->EditCustomAttributes = "";
- $sSqlWrk = "SELECT `resume_id`, `resume_title` FROM `osj-resumes`";
- $sSqlWrk .= " WHERE (" . "`user_id` = ".CurrentUserID()."" . ")";
- $sSqlWrk .= " ORDER BY `resume_title` Asc";
- $rswrk = $conn->Execute($sSqlWrk);
- $arwrk = ($rswrk) ? $rswrk->GetRows() : array();
- if ($rswrk) $rswrk->Close();
- array_unshift($arwrk, array("", "Please Select"));
- $osj2Dapplications->resume_id->EditValue = $arwrk;
-
- // post_id
- $osj2Dapplications->post_id->EditCustomAttributes = "";
- $osj2Dapplications->post_id->EditValue = ew_HtmlEncode($osj2Dapplications->post_id->CurrentValue);
-
- // application_email
- $osj2Dapplications->application_email->EditCustomAttributes = "";
- $osj2Dapplications->application_email->EditValue = ew_HtmlEncode($osj2Dapplications->application_email->CurrentValue);
-
- // application_text
- $osj2Dapplications->application_text->EditCustomAttributes = "";
- $osj2Dapplications->application_text->EditValue = ew_HtmlEncode($osj2Dapplications->application_text->CurrentValue);
-
- // application_file
- $osj2Dapplications->application_file->EditCustomAttributes = "";
- $osj2Dapplications->application_file->EditValue = $osj2Dapplications->application_file->CurrentValue;
-
- // application_file_name
- $osj2Dapplications->application_file_name->EditCustomAttributes = "";
- $osj2Dapplications->application_file_name->EditValue = ew_HtmlEncode($osj2Dapplications->application_file_name->CurrentValue);
- } elseif ($osj2Dapplications->RowType == EW_ROWTYPE_EDIT) { // Edit row
- } elseif ($osj2Dapplications->RowType == EW_ROWTYPE_SEARCH) { // Search row
- }
-
- // Call Row Rendered event
- $osj2Dapplications->Row_Rendered();
- }
- ?>
- <?php
-
- // Add record
- function AddRow() {
- global $conn, $Security, $osj2Dapplications;
-
- // Check for duplicate key
- $bCheckKey = TRUE;
- $sFilter = $osj2Dapplications->SqlKeyFilter();
- if (trim(strval($osj2Dapplications->application_id->CurrentValue)) == "") {
- $bCheckKey = FALSE;
- } else {
- $sFilter = str_replace("@application_id@", ew_AdjustSql($osj2Dapplications->application_id->CurrentValue), $sFilter); // Replace key value
- }
- if (!is_numeric($osj2Dapplications->application_id->CurrentValue)) {
- $bCheckKey = FALSE;
- }
- if ($bCheckKey) {
- $rsChk = $osj2Dapplications->LoadRs($sFilter);
- if ($rsChk && !$rsChk->EOF) {
- $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for primary key";
- $rsChk->Close();
- return FALSE;
- }
- }
- $rsnew = array();
-
- // Field user_id
- $osj2Dapplications->user_id->SetDbValueDef(CurrentUserID(), 0);
- $rsnew['user_id'] =& $osj2Dapplications->user_id->DbValue;
-
- // Field resume_id
- $osj2Dapplications->resume_id->SetDbValueDef($osj2Dapplications->resume_id->CurrentValue, 0);
- $rsnew['resume_id'] =& $osj2Dapplications->resume_id->DbValue;
-
- // Field post_id
- $osj2Dapplications->post_id->SetDbValueDef($osj2Dapplications->post_id->CurrentValue, 0);
- $rsnew['post_id'] =& $osj2Dapplications->post_id->DbValue;
-
- // Field application_date
- $osj2Dapplications->application_date->SetDbValueDef(ew_CurrentDateTime(), ew_CurrentDate());
- $rsnew['application_date'] =& $osj2Dapplications->application_date->DbValue;
-
- // Field application_email
- $osj2Dapplications->application_email->SetDbValueDef($osj2Dapplications->application_email->CurrentValue, "");
- $rsnew['application_email'] =& $osj2Dapplications->application_email->DbValue;
-
- // Field application_text
- $osj2Dapplications->application_text->SetDbValueDef($osj2Dapplications->application_text->CurrentValue, "");
- $rsnew['application_text'] =& $osj2Dapplications->application_text->DbValue;
-
- // Field application_file
- $osj2Dapplications->application_file->Upload->SaveToSession(); // Save file value to Session
- if (is_null($osj2Dapplications->application_file->Upload->Value)) {
- $rsnew['application_file'] = NULL;
- } else {
- $rsnew['application_file'] = $osj2Dapplications->application_file->Upload->GetBinary();
- }
- $osj2Dapplications->application_file_name->SetDbValueDef($osj2Dapplications->application_file->Upload->FileName, "");
- $rsnew['application_file_name'] =& $osj2Dapplications->application_file_name->DbValue;
-
- // Field application_file_name
- // Call Row Inserting event
-
- $bInsertRow = $osj2Dapplications->Row_Inserting($rsnew);
- if ($bInsertRow) {
-
- // Field application_file
- $conn->raiseErrorFn = 'ew_ErrorFn';
- $AddRow = $conn->Execute($osj2Dapplications->InsertSQL($rsnew));
- $conn->raiseErrorFn = '';
- } else {
- if ($osj2Dapplications->CancelMessage <> "") {
- $_SESSION[EW_SESSION_MESSAGE] = $osj2Dapplications->CancelMessage;
- $osj2Dapplications->CancelMessage = "";
- } else {
- $_SESSION[EW_SESSION_MESSAGE] = "Insert cancelled";
- }
- $AddRow = FALSE;
- }
- if ($AddRow) {
- $osj2Dapplications->application_id->setDbValue($conn->Insert_ID());
- $rsnew['application_id'] =& $osj2Dapplications->application_id->DbValue;
-
- // Call Row Inserted event
- $osj2Dapplications->Row_Inserted($rsnew);
- WriteAuditTrailOnAdd($rsnew);
- if ($osj2Dapplications->SendEmail) SendEmailOnAdd($rsnew);
- }
-
- // Field application_file
- $osj2Dapplications->application_file->Upload->RemoveFromSession(); // Remove file value from Session
- return $AddRow;
- }
- ?>
- <?php
-
- // Write Audit Trail start/end for grid update
- function WriteAuditTrailDummy($typ) {
- $table = 'osj-applications';
-
- // Write Audit Trail
- $filePfx = "log";
- $curDate = date("Y/m/d");
- $curTime = date("H:i:s");
- $id = ew_ScriptName();
- $user = CurrentUserID();
- $action = $typ;
- ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
- }
- ?>
- <?php
-
- // Write Audit Trail (add page)
- function WriteAuditTrailOnAdd(&$rs) {
- global $osj2Dapplications;
- $table = 'osj-applications';
-
- // Get key value
- $key = "";
- if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
- $key .= $rs['application_id'];
-
- // Write Audit Trail
- $filePfx = "log";
- $curDate = date("Y/m/d");
- $curTime = date("H:i:s");
- $id = ew_ScriptName();
- $user = CurrentUserID();
- $action = "A";
- $oldvalue = "";
- foreach (array_keys($rs) as $fldname) {
- if ($osj2Dapplications->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
- $newvalue = ($osj2Dapplications->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) ? "<MEMO>" : $rs[$fldname]; // Memo Field
- ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
- }
- }
- }
- ?>
- <?php
-
- // Send email after add success
- function SendEmailOnAdd(&$rs) {
- $sFn = "txt/notify.txt";
- $sTable = 'osj-applications';
- $sSubject = $sTable . " record inserted";
- $sAction = "Inserted";
-
- // Get key value
- $sKey = "";
- if ($sKey <> "") $sKey .= EW_COMPOSITE_KEY_SEPARATOR;
- $sKey .= $rs['application_id'];
- ew_SendNotifyEmail($sFn, $sSubject, $sTable, $sKey, $sAction);
- }
- ?>
- <?php
-
- // Page Load event
- function Page_Load() {
-
- //echo "Page Load";
- }
-
- // Page Unload event
- function Page_Unload() {
-
- //echo "Page Unload";
- }
- ?>