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

/osj-osj2dresumesedit.php

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