PageRenderTime 141ms CodeModel.GetById 1ms RepoModel.GetById 0ms app.codeStats 0ms

/osj-osj2dresumesadd.php

http://osjobber.googlecode.com/
PHP | 674 lines | 509 code | 80 blank | 85 comment | 82 complexity | 14e13aab0165c65daacbf405b6a18411 MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "add", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-resumes', TRUE);
  4. ?>
  5. <?php
  6. session_start(); // Initialize session data
  7. ob_start(); // Turn on output buffering
  8. ?>
  9. <?php include "osj-ewcfg50.php" ?>
  10. <?php include "osj-ewmysql50.php" ?>
  11. <?php include "osj-phpfn50.php" ?>
  12. <?php include "osj-osj2dresumesinfo.php" ?>
  13. <?php include "osj-userfn50.php" ?>
  14. <?php include "osj-osj2dusersinfo.php" ?>
  15. <?php
  16. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
  17. header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT"); // Always modified
  18. header("Cache-Control: private, no-store, no-cache, must-revalidate"); // HTTP/1.1
  19. header("Cache-Control: post-check=0, pre-check=0", false);
  20. header("Pragma: no-cache"); // HTTP/1.0
  21. ?>
  22. <?php
  23. // Open connection to the database
  24. $conn = ew_Connect();
  25. ?>
  26. <?php
  27. $Security = new cAdvancedSecurity();
  28. ?>
  29. <?php
  30. if (!$Security->IsLoggedIn()) $Security->AutoLogin();
  31. $Security->LoadCurrentUserLevel('osj-resumes');
  32. if (!$Security->IsLoggedIn()) {
  33. $Security->SaveLastUrl();
  34. Page_Terminate("osj-login.php");
  35. }
  36. if (!$Security->CanAdd()) {
  37. $Security->SaveLastUrl();
  38. Page_Terminate("osj-osj2dresumeslist.php");
  39. }
  40. if ($Security->IsLoggedIn() && $Security->CurrentUserID() == "") {
  41. $_SESSION[EW_SESSION_MESSAGE] = "You do not have the right permission to view the page";
  42. Page_Terminate("osj-login.php");
  43. }
  44. ?>
  45. <?php
  46. // Common page loading event (in userfn*.php)
  47. Page_Loading();
  48. ?>
  49. <?php
  50. // Page load event, used in current page
  51. Page_Load();
  52. ?>
  53. <?php
  54. $osj2Dresumes->Export = @$_GET["export"]; // Get export parameter
  55. $sExport = $osj2Dresumes->Export; // Get export parameter, used in header
  56. $sExportFile = $osj2Dresumes->TableVar; // Get export file, used in header
  57. ?>
  58. <?php
  59. // Load key values from QueryString
  60. $bCopy = TRUE;
  61. if (@$_GET["resume_id"] != "") {
  62. $osj2Dresumes->resume_id->setQueryStringValue($_GET["resume_id"]);
  63. } else {
  64. $bCopy = FALSE;
  65. }
  66. // Create form object
  67. $objForm = new cFormObj();
  68. // Process form if post back
  69. if (@$_POST["a_add"] <> "") {
  70. $osj2Dresumes->CurrentAction = $_POST["a_add"]; // Get form action
  71. GetUploadFiles(); // Get upload files
  72. LoadFormValues(); // Load form values
  73. } else { // Not post back
  74. if ($bCopy) {
  75. $osj2Dresumes->CurrentAction = "C"; // Copy Record
  76. } else {
  77. $osj2Dresumes->CurrentAction = "I"; // Display Blank Record
  78. LoadDefaultValues(); // Load default values
  79. }
  80. }
  81. // Perform action based on action code
  82. switch ($osj2Dresumes->CurrentAction) {
  83. case "I": // Blank record, no action required
  84. break;
  85. case "C": // Copy an existing record
  86. if (!LoadRow()) { // Load record based on key
  87. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // No record found
  88. Page_Terminate($osj2Dresumes->getReturnUrl()); // Clean up and return
  89. }
  90. break;
  91. case "A": // ' Add new record
  92. $osj2Dresumes->SendEmail = TRUE; // Send email on add success
  93. if (AddRow()) { // Add successful
  94. $_SESSION[EW_SESSION_MESSAGE] = "Add New Record Successful"; // Set up success message
  95. Page_Terminate($osj2Dresumes->KeyUrl($osj2Dresumes->getReturnUrl())); // Clean up and return
  96. } else {
  97. RestoreFormValues(); // Add failed, restore form values
  98. }
  99. }
  100. // Render row based on row type
  101. $osj2Dresumes->RowType = EW_ROWTYPE_ADD; // Render add type
  102. RenderRow();
  103. ?>
  104. <?php include "osj-header.php" ?>
  105. <script type="text/javascript">
  106. <!--
  107. var EW_PAGE_ID = "add"; // Page id
  108. var EW_SHOW_HIGHLIGHT = "Show highlight";
  109. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  110. //-->
  111. </script>
  112. <script type="text/javascript">
  113. <!--
  114. function ew_ValidateForm(fobj) {
  115. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  116. return true;
  117. var i, elm, aelm, infix;
  118. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  119. for (i=0; i<rowcnt; i++) {
  120. infix = (fobj.key_count) ? String(i+1) : "";
  121. elm = fobj.elements["x" + infix + "_resume_permissions_id"];
  122. if (elm && !ew_HasValue(elm)) {
  123. if (!ew_OnError(elm, "Please enter required field - Resume Status Level"))
  124. return false;
  125. }
  126. elm = fobj.elements["x" + infix + "_resume_text"];
  127. if (elm && !ew_HasValue(elm)) {
  128. if (!ew_OnError(elm, "Please enter required field - Resume Text"))
  129. return false;
  130. }
  131. elm = fobj.elements["x" + infix + "_resume_file"];
  132. aelm = fobj.elements["a" + infix + "_resume_file"];
  133. var chk_resume_file = (aelm && aelm[0])?(aelm[2].checked):true;
  134. if (elm && chk_resume_file && !ew_HasValue(elm)) {
  135. if (!ew_OnError(elm, "Please enter required field - Resume Attachment"))
  136. return false;
  137. }
  138. elm = fobj.elements["x" + infix + "_resume_file"];
  139. if (elm && !ew_CheckFileType(elm.value)) {
  140. if (!ew_OnError(elm, "File type is not allowed."))
  141. return false;
  142. }
  143. elm = fobj.elements["x" + infix + "_resume_categories"];
  144. if (elm && !ew_HasValue(elm)) {
  145. if (!ew_OnError(elm, "Please enter required field - Resume Categories"))
  146. return false;
  147. }
  148. elm = fobj.elements["x" + infix + "_resume_title"];
  149. if (elm && !ew_HasValue(elm)) {
  150. if (!ew_OnError(elm, "Please enter required field - Resume Title"))
  151. return false;
  152. }
  153. }
  154. return true;
  155. }
  156. //-->
  157. </script>
  158. <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
  159. <script type="text/javascript">
  160. <!--
  161. _width_multiplier = 16;
  162. _height_multiplier = 60;
  163. var ew_DHTMLEditors = [];
  164. function ew_UpdateTextArea() {
  165. if (typeof ew_DHTMLEditors != 'undefined' &&
  166. typeof FCKeditorAPI != 'undefined') {
  167. var inst;
  168. for (inst in FCKeditorAPI.__Instances)
  169. FCKeditorAPI.__Instances[inst].UpdateLinkedField();
  170. }
  171. }
  172. //-->
  173. </script>
  174. <script type="text/javascript">
  175. <!--
  176. // js for Popup Calendar
  177. //-->
  178. </script>
  179. <script type="text/javascript">
  180. <!--
  181. var ew_MultiPagePage = "Page"; // multi-page Page Text
  182. var ew_MultiPageOf = "of"; // multi-page Of Text
  183. var ew_MultiPagePrev = "Prev"; // multi-page Prev Text
  184. var ew_MultiPageNext = "Next"; // multi-page Next Text
  185. //-->
  186. </script>
  187. <script language="JavaScript" type="text/javascript">
  188. <!--
  189. // Write your client script here, no need to add script tags.
  190. // To include another .js script, use:
  191. // ew_ClientScriptInclude("my_javascript.js");
  192. //-->
  193. </script>
  194. <p><span class="phpmaker">Add to TABLE: Resumes<br><br><a href="<?php echo $osj2Dresumes->getReturnUrl() ?>">Go Back</a></span></p>
  195. <?php
  196. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") { // Mesasge in Session, display
  197. ?>
  198. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  199. <?php
  200. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message in Session
  201. }
  202. ?>
  203. <form name="fosj2Dresumesadd" id="fosj2Dresumesadd" action="osj-osj2dresumesadd.php" method="post" enctype="multipart/form-data">
  204. <p>
  205. <input type="hidden" name="a_add" id="a_add" value="A">
  206. <table class="ewTable">
  207. <tr class="ewTableRow">
  208. <td class="ewTableHeader">Resume Status Level<span class='ewmsg'>&nbsp;*</span></td>
  209. <td<?php echo $osj2Dresumes->resume_permissions_id->CellAttributes() ?>><span id="cb_x_resume_permissions_id">
  210. <select id="x_resume_permissions_id" name="x_resume_permissions_id"<?php echo $osj2Dresumes->resume_permissions_id->EditAttributes() ?>>
  211. <!--option value="">Please Select</option-->
  212. <?php
  213. if (is_array($osj2Dresumes->resume_permissions_id->EditValue)) {
  214. $arwrk = $osj2Dresumes->resume_permissions_id->EditValue;
  215. $rowswrk = count($arwrk);
  216. for ($rowcntwrk = 0; $rowcntwrk < $rowswrk; $rowcntwrk++) {
  217. $selwrk = (strval($osj2Dresumes->resume_permissions_id->CurrentValue) == strval($arwrk[$rowcntwrk][0])) ? " selected" : "";
  218. ?>
  219. <option value="<?php echo ew_HtmlEncode($arwrk[$rowcntwrk][0]) ?>"<?php echo $selwrk ?>>
  220. <?php echo $arwrk[$rowcntwrk][1] ?>
  221. </option>
  222. <?php
  223. }
  224. }
  225. ?>
  226. </select>
  227. </span></td>
  228. </tr>
  229. <input type="hidden" name="x_resume_edit_date" id="x_resume_edit_date" value="<?php echo ew_HtmlEncode($osj2Dresumes->resume_edit_date->CurrentValue) ?>">
  230. <tr class="ewTableAltRow">
  231. <td class="ewTableHeader">Resume Text<span class='ewmsg'>&nbsp;*</span></td>
  232. <td<?php echo $osj2Dresumes->resume_text->CellAttributes() ?>><span id="cb_x_resume_text">
  233. <textarea name="x_resume_text" id="x_resume_text" cols="35" rows="4"<?php echo $osj2Dresumes->resume_text->EditAttributes() ?>><?php echo $osj2Dresumes->resume_text->EditValue ?></textarea>
  234. <script type="text/javascript">
  235. <!--
  236. var editor = new ew_DHTMLEditor("x_resume_text");
  237. editor.create = function() {
  238. var sBasePath = 'fckeditor/';
  239. var oFCKeditor = new FCKeditor('x_resume_text', 35*_width_multiplier, 4*_height_multiplier);
  240. oFCKeditor.BasePath = sBasePath;
  241. oFCKeditor.ReplaceTextarea();
  242. this.active = true;
  243. }
  244. ew_DHTMLEditors[ew_DHTMLEditors.length] = editor;
  245. -->
  246. </script>
  247. </span></td>
  248. </tr>
  249. <tr class="ewTableRow">
  250. <td class="ewTableHeader">Resume Attachment<span class='ewmsg'>&nbsp;*</span></td>
  251. <td<?php echo $osj2Dresumes->resume_file->CellAttributes() ?>><span id="cb_x_resume_file">
  252. <input type="file" name="x_resume_file" id="x_resume_file" size="30"<?php echo $osj2Dresumes->resume_file->EditAttributes() ?>>
  253. </span></td>
  254. </tr>
  255. <tr class="ewTableAltRow">
  256. <td class="ewTableHeader">Resume Categories<span class='ewmsg'>&nbsp;*</span></td>
  257. <td<?php echo $osj2Dresumes->resume_categories->CellAttributes() ?>><span id="cb_x_resume_categories">
  258. </span></td>
  259. </tr>
  260. <tr class="ewTableRow">
  261. <td class="ewTableHeader">Resume Title<span class='ewmsg'>&nbsp;*</span></td>
  262. <td<?php echo $osj2Dresumes->resume_title->CellAttributes() ?>><span id="cb_x_resume_title">
  263. <input type="text" name="x_resume_title" id="x_resume_title" size="30" maxlength="255" value="<?php echo $osj2Dresumes->resume_title->EditValue ?>"<?php echo $osj2Dresumes->resume_title->EditAttributes() ?>>
  264. </span></td>
  265. </tr>
  266. </table>
  267. <p>
  268. <input type="button" name="btnAction" id="btnAction" value=" Add " onClick="ew_SubmitForm(this.form);">
  269. </form>
  270. <script type="text/javascript">
  271. <!--
  272. ew_CreateEditor(); // Create DHTML editor(s)
  273. //-->
  274. </script>
  275. <script language="JavaScript" type="text/javascript">
  276. <!--
  277. // Write your table-specific startup script here
  278. // document.write("page loaded");
  279. //-->
  280. </script>
  281. <?php include "osj-footer.php" ?>
  282. <?php
  283. // If control is passed here, simply terminate the page without redirect
  284. Page_Terminate();
  285. // -----------------------------------------------------------------
  286. // Subroutine Page_Terminate
  287. // - called when exit page
  288. // - clean up connection and objects
  289. // - if url specified, redirect to url, otherwise end response
  290. function Page_Terminate($url = "") {
  291. global $conn;
  292. // Page unload event, used in current page
  293. Page_Unload();
  294. // Global page unloaded event (in userfn*.php)
  295. Page_Unloaded();
  296. // Close Connection
  297. $conn->Close();
  298. // Go to url if specified
  299. if ($url <> "") {
  300. ob_end_clean();
  301. header("Location: $url");
  302. }
  303. exit();
  304. }
  305. ?>
  306. <?php
  307. // Function Get upload files
  308. function GetUploadFiles() {
  309. global $objForm, $osj2Dresumes;
  310. // Get upload data
  311. if ($osj2Dresumes->resume_file->Upload->UploadFile()) {
  312. // No action required
  313. } else {
  314. echo $osj2Dresumes->resume_file->Upload->Message;
  315. exit();
  316. }
  317. }
  318. ?>
  319. <?php
  320. // Load default values
  321. function LoadDefaultValues() {
  322. global $osj2Dresumes;
  323. $osj2Dresumes->user_id->CurrentValue = 0;
  324. $osj2Dresumes->resume_permissions_id->CurrentValue = 0;
  325. $osj2Dresumes->resume_creation_date->CurrentValue = "0000-00-00 00:00:00";
  326. $osj2Dresumes->resume_edit_date->CurrentValue = "CURRENT_TIMESTAMP";
  327. }
  328. ?>
  329. <?php
  330. // Load form values
  331. function LoadFormValues() {
  332. // Load from form
  333. global $objForm, $osj2Dresumes;
  334. $osj2Dresumes->user_id->setFormValue($objForm->GetValue("x_user_id"));
  335. $osj2Dresumes->resume_permissions_id->setFormValue($objForm->GetValue("x_resume_permissions_id"));
  336. $osj2Dresumes->resume_creation_date->setFormValue($objForm->GetValue("x_resume_creation_date"));
  337. $osj2Dresumes->resume_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_creation_date->CurrentValue, 10);
  338. $osj2Dresumes->resume_edit_date->setFormValue($objForm->GetValue("x_resume_edit_date"));
  339. $osj2Dresumes->resume_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_edit_date->CurrentValue, 10);
  340. $osj2Dresumes->resume_text->setFormValue($objForm->GetValue("x_resume_text"));
  341. $osj2Dresumes->resume_categories->setFormValue($objForm->GetValue("x_resume_categories"));
  342. $osj2Dresumes->resume_title->setFormValue($objForm->GetValue("x_resume_title"));
  343. }
  344. // Restore form values
  345. function RestoreFormValues() {
  346. global $osj2Dresumes;
  347. $osj2Dresumes->user_id->CurrentValue = $osj2Dresumes->user_id->FormValue;
  348. $osj2Dresumes->resume_permissions_id->CurrentValue = $osj2Dresumes->resume_permissions_id->FormValue;
  349. $osj2Dresumes->resume_creation_date->CurrentValue = $osj2Dresumes->resume_creation_date->FormValue;
  350. $osj2Dresumes->resume_creation_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_creation_date->CurrentValue, 10);
  351. $osj2Dresumes->resume_edit_date->CurrentValue = $osj2Dresumes->resume_edit_date->FormValue;
  352. $osj2Dresumes->resume_edit_date->CurrentValue = ew_UnFormatDateTime($osj2Dresumes->resume_edit_date->CurrentValue, 10);
  353. $osj2Dresumes->resume_text->CurrentValue = $osj2Dresumes->resume_text->FormValue;
  354. $osj2Dresumes->resume_categories->CurrentValue = $osj2Dresumes->resume_categories->FormValue;
  355. $osj2Dresumes->resume_title->CurrentValue = $osj2Dresumes->resume_title->FormValue;
  356. }
  357. ?>
  358. <?php
  359. // Load row based on key values
  360. function LoadRow() {
  361. global $conn, $Security, $osj2Dresumes;
  362. $sFilter = $osj2Dresumes->SqlKeyFilter();
  363. if (!is_numeric($osj2Dresumes->resume_id->CurrentValue)) {
  364. return FALSE; // Invalid key, exit
  365. }
  366. $sFilter = str_replace("@resume_id@", ew_AdjustSql($osj2Dresumes->resume_id->CurrentValue), $sFilter); // Replace key value
  367. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  368. $sFilter = $osj2Dresumes->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  369. }
  370. // Call Row Selecting event
  371. $osj2Dresumes->Row_Selecting($sFilter);
  372. // Load sql based on filter
  373. $osj2Dresumes->CurrentFilter = $sFilter;
  374. $sSql = $osj2Dresumes->SQL();
  375. if ($rs = $conn->Execute($sSql)) {
  376. if ($rs->EOF) {
  377. $LoadRow = FALSE;
  378. } else {
  379. $LoadRow = TRUE;
  380. $rs->MoveFirst();
  381. LoadRowValues($rs); // Load row values
  382. // Call Row Selected event
  383. $osj2Dresumes->Row_Selected($rs);
  384. }
  385. $rs->Close();
  386. } else {
  387. $LoadRow = FALSE;
  388. }
  389. return $LoadRow;
  390. }
  391. // Load row values from recordset
  392. function LoadRowValues(&$rs) {
  393. global $osj2Dresumes;
  394. $osj2Dresumes->resume_id->setDbValue($rs->fields('resume_id'));
  395. $osj2Dresumes->user_id->setDbValue($rs->fields('user_id'));
  396. $osj2Dresumes->resume_permissions_id->setDbValue($rs->fields('resume_permissions_id'));
  397. $osj2Dresumes->resume_creation_date->setDbValue($rs->fields('resume_creation_date'));
  398. $osj2Dresumes->resume_edit_date->setDbValue($rs->fields('resume_edit_date'));
  399. $osj2Dresumes->resume_text->setDbValue($rs->fields('resume_text'));
  400. $osj2Dresumes->resume_file->Upload->DbValue = $rs->fields('resume_file');
  401. $osj2Dresumes->resume_categories->setDbValue($rs->fields('resume_categories'));
  402. $osj2Dresumes->resume_title->setDbValue($rs->fields('resume_title'));
  403. }
  404. ?>
  405. <?php
  406. // Render row values based on field settings
  407. function RenderRow() {
  408. global $conn, $Security, $osj2Dresumes;
  409. // Call Row Rendering event
  410. $osj2Dresumes->Row_Rendering();
  411. // Common render codes for all row types
  412. // user_id
  413. $osj2Dresumes->user_id->CellCssStyle = "";
  414. $osj2Dresumes->user_id->CellCssClass = "";
  415. // resume_permissions_id
  416. $osj2Dresumes->resume_permissions_id->CellCssStyle = "";
  417. $osj2Dresumes->resume_permissions_id->CellCssClass = "";
  418. // resume_creation_date
  419. $osj2Dresumes->resume_creation_date->CellCssStyle = "";
  420. $osj2Dresumes->resume_creation_date->CellCssClass = "";
  421. // resume_edit_date
  422. $osj2Dresumes->resume_edit_date->CellCssStyle = "";
  423. $osj2Dresumes->resume_edit_date->CellCssClass = "";
  424. // resume_text
  425. $osj2Dresumes->resume_text->CellCssStyle = "";
  426. $osj2Dresumes->resume_text->CellCssClass = "";
  427. // resume_file
  428. $osj2Dresumes->resume_file->CellCssStyle = "";
  429. $osj2Dresumes->resume_file->CellCssClass = "";
  430. // resume_categories
  431. $osj2Dresumes->resume_categories->CellCssStyle = "";
  432. $osj2Dresumes->resume_categories->CellCssClass = "";
  433. // resume_title
  434. $osj2Dresumes->resume_title->CellCssStyle = "";
  435. $osj2Dresumes->resume_title->CellCssClass = "";
  436. if ($osj2Dresumes->RowType == EW_ROWTYPE_VIEW) { // View row
  437. } elseif ($osj2Dresumes->RowType == EW_ROWTYPE_ADD) { // Add row
  438. // resume_permissions_id
  439. $osj2Dresumes->resume_permissions_id->EditCustomAttributes = "";
  440. $arwrk = array();
  441. $arwrk[] = array("0", "Inactive");
  442. $arwrk[] = array("1", "Active");
  443. array_unshift($arwrk, array("", "Please Select"));
  444. $osj2Dresumes->resume_permissions_id->EditValue = $arwrk;
  445. // resume_edit_date
  446. $osj2Dresumes->resume_edit_date->EditCustomAttributes = "";
  447. $osj2Dresumes->resume_edit_date->CurrentValue = ew_FormatDateTime("CURRENT_TIMESTAMP", 10);
  448. // resume_text
  449. $osj2Dresumes->resume_text->EditCustomAttributes = "";
  450. $osj2Dresumes->resume_text->EditValue = ew_HtmlEncode($osj2Dresumes->resume_text->CurrentValue);
  451. // resume_file
  452. $osj2Dresumes->resume_file->EditCustomAttributes = "";
  453. $osj2Dresumes->resume_file->EditValue = $osj2Dresumes->resume_file->CurrentValue;
  454. // resume_categories
  455. $osj2Dresumes->resume_categories->EditCustomAttributes = "";
  456. // resume_title
  457. $osj2Dresumes->resume_title->EditCustomAttributes = "";
  458. $osj2Dresumes->resume_title->EditValue = ew_HtmlEncode($osj2Dresumes->resume_title->CurrentValue);
  459. } elseif ($osj2Dresumes->RowType == EW_ROWTYPE_EDIT) { // Edit row
  460. } elseif ($osj2Dresumes->RowType == EW_ROWTYPE_SEARCH) { // Search row
  461. }
  462. // Call Row Rendered event
  463. $osj2Dresumes->Row_Rendered();
  464. }
  465. ?>
  466. <?php
  467. // Add record
  468. function AddRow() {
  469. global $conn, $Security, $osj2Dresumes;
  470. // Check for duplicate key
  471. $bCheckKey = TRUE;
  472. $sFilter = $osj2Dresumes->SqlKeyFilter();
  473. if (trim(strval($osj2Dresumes->resume_id->CurrentValue)) == "") {
  474. $bCheckKey = FALSE;
  475. } else {
  476. $sFilter = str_replace("@resume_id@", ew_AdjustSql($osj2Dresumes->resume_id->CurrentValue), $sFilter); // Replace key value
  477. }
  478. if (!is_numeric($osj2Dresumes->resume_id->CurrentValue)) {
  479. $bCheckKey = FALSE;
  480. }
  481. if ($bCheckKey) {
  482. $rsChk = $osj2Dresumes->LoadRs($sFilter);
  483. if ($rsChk && !$rsChk->EOF) {
  484. $_SESSION[EW_SESSION_MESSAGE] = "Duplicate value for primary key";
  485. $rsChk->Close();
  486. return FALSE;
  487. }
  488. }
  489. $rsnew = array();
  490. // Field user_id
  491. $osj2Dresumes->user_id->SetDbValueDef(CurrentUserID(), 0);
  492. $rsnew['user_id'] =& $osj2Dresumes->user_id->DbValue;
  493. // Field resume_permissions_id
  494. $osj2Dresumes->resume_permissions_id->SetDbValueDef($osj2Dresumes->resume_permissions_id->CurrentValue, 0);
  495. $rsnew['resume_permissions_id'] =& $osj2Dresumes->resume_permissions_id->DbValue;
  496. // Field resume_creation_date
  497. $osj2Dresumes->resume_creation_date->SetDbValueDef(ew_CurrentDateTime(), ew_CurrentDate());
  498. $rsnew['resume_creation_date'] =& $osj2Dresumes->resume_creation_date->DbValue;
  499. // Field resume_edit_date
  500. $osj2Dresumes->resume_edit_date->SetDbValueDef(ew_UnFormatDateTime($osj2Dresumes->resume_edit_date->CurrentValue, 10), NULL);
  501. $rsnew['resume_edit_date'] =& $osj2Dresumes->resume_edit_date->DbValue;
  502. // Field resume_text
  503. $osj2Dresumes->resume_text->SetDbValueDef($osj2Dresumes->resume_text->CurrentValue, "");
  504. $rsnew['resume_text'] =& $osj2Dresumes->resume_text->DbValue;
  505. // Field resume_file
  506. $osj2Dresumes->resume_file->Upload->SaveToSession(); // Save file value to Session
  507. if (is_null($osj2Dresumes->resume_file->Upload->Value)) {
  508. $rsnew['resume_file'] = NULL;
  509. } else {
  510. $rsnew['resume_file'] = $osj2Dresumes->resume_file->Upload->GetBinary();
  511. }
  512. // Field resume_categories
  513. $osj2Dresumes->resume_categories->SetDbValueDef($osj2Dresumes->resume_categories->CurrentValue, "");
  514. $rsnew['resume_categories'] =& $osj2Dresumes->resume_categories->DbValue;
  515. // Field resume_title
  516. $osj2Dresumes->resume_title->SetDbValueDef($osj2Dresumes->resume_title->CurrentValue, "");
  517. $rsnew['resume_title'] =& $osj2Dresumes->resume_title->DbValue;
  518. // Call Row Inserting event
  519. $bInsertRow = $osj2Dresumes->Row_Inserting($rsnew);
  520. if ($bInsertRow) {
  521. // Field resume_file
  522. $conn->raiseErrorFn = 'ew_ErrorFn';
  523. $AddRow = $conn->Execute($osj2Dresumes->InsertSQL($rsnew));
  524. $conn->raiseErrorFn = '';
  525. } else {
  526. if ($osj2Dresumes->CancelMessage <> "") {
  527. $_SESSION[EW_SESSION_MESSAGE] = $osj2Dresumes->CancelMessage;
  528. $osj2Dresumes->CancelMessage = "";
  529. } else {
  530. $_SESSION[EW_SESSION_MESSAGE] = "Insert cancelled";
  531. }
  532. $AddRow = FALSE;
  533. }
  534. if ($AddRow) {
  535. $osj2Dresumes->resume_id->setDbValue($conn->Insert_ID());
  536. $rsnew['resume_id'] =& $osj2Dresumes->resume_id->DbValue;
  537. // Call Row Inserted event
  538. $osj2Dresumes->Row_Inserted($rsnew);
  539. WriteAuditTrailOnAdd($rsnew);
  540. }
  541. // Field resume_file
  542. $osj2Dresumes->resume_file->Upload->RemoveFromSession(); // Remove file value from Session
  543. return $AddRow;
  544. }
  545. ?>
  546. <?php
  547. // Write Audit Trail start/end for grid update
  548. function WriteAuditTrailDummy($typ) {
  549. $table = 'osj-resumes';
  550. // Write Audit Trail
  551. $filePfx = "log";
  552. $curDate = date("Y/m/d");
  553. $curTime = date("H:i:s");
  554. $id = ew_ScriptName();
  555. $user = CurrentUserID();
  556. $action = $typ;
  557. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
  558. }
  559. ?>
  560. <?php
  561. // Write Audit Trail (add page)
  562. function WriteAuditTrailOnAdd(&$rs) {
  563. global $osj2Dresumes;
  564. $table = 'osj-resumes';
  565. // Get key value
  566. $key = "";
  567. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  568. $key .= $rs['resume_id'];
  569. // Write Audit Trail
  570. $filePfx = "log";
  571. $curDate = date("Y/m/d");
  572. $curTime = date("H:i:s");
  573. $id = ew_ScriptName();
  574. $user = CurrentUserID();
  575. $action = "A";
  576. $oldvalue = "";
  577. foreach (array_keys($rs) as $fldname) {
  578. if ($osj2Dresumes->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
  579. $newvalue = ($osj2Dresumes->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) ? "<MEMO>" : $rs[$fldname]; // Memo Field
  580. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
  581. }
  582. }
  583. }
  584. ?>
  585. <?php
  586. // Page Load event
  587. function Page_Load() {
  588. //echo "Page Load";
  589. }
  590. // Page Unload event
  591. function Page_Unload() {
  592. //echo "Page Unload";
  593. }
  594. ?>