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

/osj-osj2duser_levellist.php

http://osjobber.googlecode.com/
PHP | 1178 lines | 957 code | 107 blank | 114 comment | 322 complexity | 81839b44f6b8a82b9e76ca28d5d34f0f MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "list", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-user_level', 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-osj2duser_levelinfo.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-user_level');
  32. if (!$Security->CanAdmin()) {
  33. $Security->SaveLastUrl();
  34. Page_Terminate("osj-login.php");
  35. }
  36. ?>
  37. <?php
  38. // Common page loading event (in userfn*.php)
  39. Page_Loading();
  40. ?>
  41. <?php
  42. // Page load event, used in current page
  43. Page_Load();
  44. ?>
  45. <?php
  46. $osj2Duser_level->Export = @$_GET["export"]; // Get export parameter
  47. $sExport = $osj2Duser_level->Export; // Get export parameter, used in header
  48. $sExportFile = $osj2Duser_level->TableVar; // Get export file, used in header
  49. ?>
  50. <?php
  51. if ($osj2Duser_level->Export == "html") {
  52. // Printer friendly, no action required
  53. }
  54. if ($osj2Duser_level->Export == "xml") {
  55. header('Content-Type: text/xml');
  56. header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
  57. }
  58. if ($osj2Duser_level->Export == "csv") {
  59. header('Content-Type: application/csv');
  60. header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
  61. }
  62. ?>
  63. <?php
  64. // Paging variables
  65. $nStartRec = 0; // Start record index
  66. $nStopRec = 0; // Stop record index
  67. $nTotalRecs = 0; // Total number of records
  68. $nDisplayRecs = 10;
  69. $nRecRange = 10;
  70. $nRecCount = 0; // Record count
  71. // Search filters
  72. $sSrchAdvanced = ""; // Advanced search filter
  73. $sSrchBasic = ""; // Basic search filter
  74. $sSrchWhere = ""; // Search where clause
  75. $sFilter = "";
  76. // Master/Detail
  77. $sDbMasterFilter = ""; // Master filter
  78. $sDbDetailFilter = ""; // Detail filter
  79. $sSqlMaster = ""; // Sql for master record
  80. // Set up records per page dynamically
  81. SetUpDisplayRecs();
  82. // Handle reset command
  83. ResetCmd();
  84. // Check QueryString parameters
  85. if (@$_GET["a"] <> "") {
  86. $osj2Duser_level->CurrentAction = $_GET["a"];
  87. // Clear inline mode
  88. if ($osj2Duser_level->CurrentAction == "cancel") {
  89. ClearInlineMode();
  90. }
  91. // Switch to inline edit mode
  92. if ($osj2Duser_level->CurrentAction == "edit") {
  93. InlineEditMode();
  94. }
  95. } else {
  96. // Create form object
  97. $objForm = new cFormObj;
  98. if (@$_POST["a_list"] <> "") {
  99. $osj2Duser_level->CurrentAction = $_POST["a_list"]; // Get action
  100. // Inline Update
  101. if ($osj2Duser_level->CurrentAction == "update" && @$_SESSION[EW_SESSION_INLINE_MODE] == "edit") {
  102. InlineUpdate();
  103. }
  104. }
  105. }
  106. // Build filter
  107. $sFilter = "";
  108. if (!$Security->CanList()) {
  109. $sFilter = "(0=1)"; // Filter all records
  110. }
  111. if ($sDbDetailFilter <> "") {
  112. if ($sFilter <> "") $sFilter .= " AND ";
  113. $sFilter .= "(" . $sDbDetailFilter . ")";
  114. }
  115. if ($sSrchWhere <> "") {
  116. if ($sFilter <> "") $sFilter .= " AND ";
  117. $sFilter .= "(" . $sSrchWhere . ")";
  118. }
  119. // Set up filter in Session
  120. $osj2Duser_level->setSessionWhere($sFilter);
  121. $osj2Duser_level->CurrentFilter = "";
  122. // Set Up Sorting Order
  123. SetUpSortOrder();
  124. // Export data only
  125. if ($osj2Duser_level->Export == "xml" || $osj2Duser_level->Export == "csv") {
  126. ExportData();
  127. Page_Terminate(); // Terminate response
  128. }
  129. // Set Return Url
  130. $osj2Duser_level->setReturnUrl("osj-osj2duser_levellist.php");
  131. ?>
  132. <?php include "osj-header.php" ?>
  133. <?php if ($osj2Duser_level->Export == "") { ?>
  134. <script type="text/javascript">
  135. <!--
  136. var EW_PAGE_ID = "list"; // Page id
  137. var EW_SHOW_HIGHLIGHT = "Show highlight";
  138. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  139. //-->
  140. </script>
  141. <script type="text/javascript">
  142. <!--
  143. function ew_ValidateForm(fobj) {
  144. if (fobj.a_confirm && fobj.a_confirm.value == "F")
  145. return true;
  146. var i, elm, aelm, infix;
  147. var rowcnt = (fobj.key_count) ? Number(fobj.key_count.value) : 1;
  148. for (i=0; i<rowcnt; i++) {
  149. infix = (fobj.key_count) ? String(i+1) : "";
  150. elm = fobj.elements["x" + infix + "_user_level_id"];
  151. if (elm && !ew_HasValue(elm)) {
  152. if (!ew_OnError(elm, "Please enter required field - user level id"))
  153. return false;
  154. }
  155. elm = fobj.elements["x" + infix + "_user_level_id"];
  156. if (elm && !ew_CheckInteger(elm.value)) {
  157. if (!ew_OnError(elm, "Incorrect integer - user level id"))
  158. return false;
  159. }
  160. elm = fobj.elements["x" + infix + "_user_level_name"];
  161. if (elm && !ew_HasValue(elm)) {
  162. if (!ew_OnError(elm, "Please enter required field - user level name"))
  163. return false;
  164. }
  165. elmId = fobj.elements["x" + infix + "_user_level_id"];
  166. elmName = fobj.elements["x" + infix + "_user_level_name"];
  167. if (elmId && elmName) {
  168. elmId.value = elmId.value.replace(/^\s+|\s+$/, '');
  169. elmName.value = elmName.value.replace(/^\s+|\s+$/, '');
  170. if (elmId && !ew_CheckInteger(elmId.value)) {
  171. if (!ew_OnError(elmId, "User Level ID must be integer"))
  172. return false;
  173. }
  174. var level = parseInt(elmId.value);
  175. if (level == 0) {
  176. if (elmName.value.toLowerCase() != "default") {
  177. if (!ew_OnError(elmName, "User level name for user level 0 must be 'Default'"))
  178. return false;
  179. }
  180. } else if (level == -1) {
  181. if (elmName.value.toLowerCase() != "administrator") {
  182. if (!ew_OnError(elmName, "User level name for user level -1 must be 'Administrator'"))
  183. return false;
  184. }
  185. } else if (level < -1) {
  186. if (!ew_OnError(elmId, "User defined User Level ID must be larger than 0"))
  187. return false;
  188. } else if (level > 0) {
  189. if (elmName.value.toLowerCase() == "administrator" || elmName.value.toLowerCase() == "default") {
  190. if (!ew_OnError(elmName, "User defined User Level name cannot be 'Administrator' or 'Default'"))
  191. return false;
  192. }
  193. }
  194. }
  195. }
  196. return true;
  197. }
  198. //-->
  199. </script>
  200. <script type="text/javascript">
  201. <!--
  202. var firstrowoffset = 1; // First data row start at
  203. var lastrowoffset = 0; // Last data row end at
  204. var EW_LIST_TABLE_NAME = 'ewlistmain'; // Table name for list page
  205. var rowclass = 'ewTableRow'; // Row class
  206. var rowaltclass = 'ewTableAltRow'; // Row alternate class
  207. var rowmoverclass = 'ewTableHighlightRow'; // Row mouse over class
  208. var rowselectedclass = 'ewTableSelectRow'; // Row selected class
  209. var roweditclass = 'ewTableEditRow'; // Row edit class
  210. //-->
  211. </script>
  212. <script type="text/javascript">
  213. <!--
  214. var ew_DHTMLEditors = [];
  215. //-->
  216. </script>
  217. <script type="text/javascript">
  218. <!--
  219. // js for Popup Calendar
  220. //-->
  221. </script>
  222. <script type="text/javascript">
  223. <!--
  224. function ew_SelectKey(elem) {
  225. var f = elem.form;
  226. if (!f.elements["key_m[]"]) return;
  227. if (f.elements["key_m[]"][0]) {
  228. for (var i=0; i<f.elements["key_m[]"].length; i++)
  229. f.elements["key_m[]"][i].checked = elem.checked;
  230. } else {
  231. f.elements["key_m[]"].checked = elem.checked;
  232. }
  233. ew_ClickAll(elem);
  234. }
  235. function ew_Selected(f) {
  236. if (!f.elements["key_m[]"]) return false;
  237. if (f.elements["key_m[]"][0]) {
  238. for (var i=0; i<f.elements["key_m[]"].length; i++)
  239. if (f.elements["key_m[]"][i].checked) return true;
  240. } else {
  241. return f.elements["key_m[]"].checked;
  242. }
  243. return false;
  244. }
  245. //-->
  246. </script>
  247. <script language="JavaScript" type="text/javascript">
  248. <!--
  249. // Write your client script here, no need to add script tags.
  250. // To include another .js script, use:
  251. // ew_ClientScriptInclude("my_javascript.js");
  252. //-->
  253. </script>
  254. <?php } ?>
  255. <?php if ($osj2Duser_level->Export == "") { ?>
  256. <?php } ?>
  257. <?php
  258. // Load recordset
  259. $bExportAll = (defined("EW_EXPORT_ALL") && $osj2Duser_level->Export <> "");
  260. $bSelectLimit = ($osj2Duser_level->Export == "" && $osj2Duser_level->SelectLimit);
  261. if (!$bSelectLimit) $rs = LoadRecordset();
  262. $nTotalRecs = ($bSelectLimit) ? $osj2Duser_level->SelectRecordCount() : $rs->RecordCount();
  263. $nStartRec = 1;
  264. if ($nDisplayRecs <= 0) $nDisplayRecs = $nTotalRecs; // Display all records
  265. if (!$bExportAll) SetUpStartRec(); // Set up start record position
  266. if ($bSelectLimit) $rs = LoadRecordset($nStartRec-1, $nDisplayRecs);
  267. ?>
  268. <p><span class="phpmaker" style="white-space: nowrap;">TABLE: User Levels
  269. <?php if ($osj2Duser_level->Export == "") { ?>
  270. &nbsp;&nbsp;<a href="osj-osj2duser_levellist.php?export=html">Printer Friendly</a>
  271. &nbsp;&nbsp;<a href="osj-osj2duser_levellist.php?export=xml">Export to XML</a>
  272. &nbsp;&nbsp;<a href="osj-osj2duser_levellist.php?export=csv">Export to CSV</a>
  273. <?php } ?>
  274. </span></p>
  275. <?php if ($osj2Duser_level->Export == "") { ?>
  276. <?php } ?>
  277. <?php
  278. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  279. ?>
  280. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  281. <?php
  282. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  283. }
  284. ?>
  285. <?php if ($osj2Duser_level->Export == "") { ?>
  286. <form action="osj-osj2duser_levellist.php" name="ewpagerform" id="ewpagerform">
  287. <table border="0" cellspacing="0" cellpadding="0">
  288. <tr>
  289. <td nowrap>
  290. <span class="phpmaker">
  291. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  292. <?php if ($Pager->RecordCount > 0) { ?>
  293. <?php if ($Pager->FirstButton->Enabled) { ?>
  294. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  295. <?php } ?>
  296. <?php if ($Pager->PrevButton->Enabled) { ?>
  297. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  298. <?php } ?>
  299. <?php foreach ($Pager->Items as $PagerItem) { ?>
  300. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_levellist.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  301. <?php } ?>
  302. <?php if ($Pager->NextButton->Enabled) { ?>
  303. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  304. <?php } ?>
  305. <?php if ($Pager->LastButton->Enabled) { ?>
  306. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  307. <?php } ?>
  308. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  309. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  310. <?php } else { ?>
  311. <?php if ($Security->CanList()) { ?>
  312. <?php if ($sSrchWhere == "0=101") { ?>
  313. Please enter search criteria
  314. <?php } else { ?>
  315. No records found
  316. <?php } ?>
  317. <?php } else { ?>
  318. You do not have the right permission to view the page
  319. <?php } ?>
  320. <?php } ?>
  321. </span>
  322. </td>
  323. <?php if ($nTotalRecs > 0) { ?>
  324. <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  325. <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
  326. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
  327. <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
  328. <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
  329. <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
  330. </select>
  331. </span></td>
  332. <?php } ?>
  333. </tr>
  334. </table>
  335. </form>
  336. <?php } ?>
  337. <form name="fosj2Duser_levellist" id="fosj2Duser_levellist" action="osj-osj2duser_levellist.php" method="post">
  338. <?php if ($osj2Duser_level->Export == "") { ?>
  339. <table>
  340. <tr><td><span class="phpmaker">
  341. <?php if ($Security->CanAdd()) { ?>
  342. <a href="osj-osj2duser_leveladd.php">Add</a>&nbsp;&nbsp;
  343. <?php } ?>
  344. <?php if ($nTotalRecs > 0) { ?>
  345. <?php if ($Security->CanDelete()) { ?>
  346. <a href="" onClick="if (!ew_Selected(document.fosj2Duser_levellist)) alert('No records selected'); else {document.fosj2Duser_levellist.action='osj-osj2duser_leveldelete.php';document.fosj2Duser_levellist.encoding='application/x-www-form-urlencoded';document.fosj2Duser_levellist.submit();};return false;">Delete Selected Records</a>&nbsp;&nbsp;
  347. <?php } ?>
  348. <?php } ?>
  349. </span></td></tr>
  350. </table>
  351. <?php } ?>
  352. <?php if ($nTotalRecs > 0) { ?>
  353. <table id="ewlistmain" class="ewTable">
  354. <?php
  355. $OptionCnt = 0;
  356. if ($Security->CanView()) {
  357. $OptionCnt++; // view
  358. }
  359. if ($Security->CanEdit()) {
  360. $OptionCnt++; // edit
  361. }
  362. $OptionCnt++; // permission
  363. if ($Security->CanDelete()) {
  364. $OptionCnt++; // multi select
  365. }
  366. ?>
  367. <!-- Table header -->
  368. <tr class="ewTableHeader">
  369. <?php if ($osj2Duser_level->Export == "") { ?>
  370. <?php if ($Security->CanView()) { ?>
  371. <td nowrap>&nbsp;</td>
  372. <?php } ?>
  373. <?php if ($Security->CanEdit()) { ?>
  374. <td nowrap>&nbsp;</td>
  375. <?php } ?>
  376. <td nowrap>&nbsp;</td>
  377. <?php if ($Security->CanDelete()) { ?>
  378. <td nowrap><input type="checkbox" class="phpmaker" onClick="ew_SelectKey(this);"></td>
  379. <?php } ?>
  380. <?php } ?>
  381. <td valign="top">
  382. <?php if ($osj2Duser_level->Export <> "") { ?>
  383. user level id
  384. <?php } else { ?>
  385. <a href="osj-osj2duser_levellist.php?order=<?php echo urlencode('user_level_id') ?>&ordertype=<?php echo $osj2Duser_level->user_level_id->ReverseSort() ?>">user level id<?php if ($osj2Duser_level->user_level_id->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Duser_level->user_level_id->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  386. <?php } ?>
  387. </td>
  388. <td valign="top">
  389. <?php if ($osj2Duser_level->Export <> "") { ?>
  390. user level name
  391. <?php } else { ?>
  392. <a href="osj-osj2duser_levellist.php?order=<?php echo urlencode('user_level_name') ?>&ordertype=<?php echo $osj2Duser_level->user_level_name->ReverseSort() ?>">user level name<?php if ($osj2Duser_level->user_level_name->getSort() == "ASC") { ?><img src="images/sortup.gif" width="10" height="9" border="0"><?php } elseif ($osj2Duser_level->user_level_name->getSort() == "DESC") { ?><img src="images/sortdown.gif" width="10" height="9" border="0"><?php } ?></a>
  393. <?php } ?>
  394. </td>
  395. </tr>
  396. <?php
  397. if (defined("EW_EXPORT_ALL") && $osj2Duser_level->Export <> "") {
  398. $nStopRec = $nTotalRecs;
  399. } else {
  400. $nStopRec = $nStartRec + $nDisplayRecs - 1; // Set the last record to display
  401. }
  402. $nRecCount = $nStartRec - 1;
  403. if (!$rs->EOF) {
  404. $rs->MoveFirst();
  405. if (!$osj2Duser_level->SelectLimit) $rs->Move($nStartRec - 1); // Move to first record directly
  406. }
  407. $RowCnt = 0;
  408. $nEditRowCnt = 0;
  409. if ($osj2Duser_level->CurrentAction == "edit") $RowIndex = 1;
  410. while (!$rs->EOF && $nRecCount < $nStopRec) {
  411. $nRecCount++;
  412. if (intval($nRecCount) >= intval($nStartRec)) {
  413. $RowCnt++;
  414. // Init row class and style
  415. $osj2Duser_level->CssClass = "ewTableRow";
  416. $osj2Duser_level->CssStyle = "";
  417. // Init row event
  418. $osj2Duser_level->RowClientEvents = "onmouseover='ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
  419. // Display alternate color for rows
  420. if ($RowCnt % 2 == 0) {
  421. $osj2Duser_level->CssClass = "ewTableAltRow";
  422. }
  423. LoadRowValues($rs); // Load row values
  424. $osj2Duser_level->RowType = EW_ROWTYPE_VIEW; // Render view
  425. if ($osj2Duser_level->CurrentAction == "edit") {
  426. if (CheckInlineEditKey() && $nEditRowCnt == 0) { // Inline edit
  427. $osj2Duser_level->RowType = EW_ROWTYPE_EDIT; // Render edit
  428. }
  429. }
  430. if ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT && $osj2Duser_level->EventCancelled) { // Update failed
  431. if ($osj2Duser_level->CurrentAction == "edit") {
  432. RestoreFormValues(); // Restore form values
  433. }
  434. }
  435. if ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { // Edit row
  436. $nEditRowCnt++;
  437. $osj2Duser_level->CssClass = "ewTableEditRow";
  438. $osj2Duser_level->RowClientEvents = "onmouseover='this.edit=true;ew_MouseOver(this);' onmouseout='ew_MouseOut(this);' onclick='ew_Click(this);'";
  439. }
  440. RenderRow();
  441. ?>
  442. <!-- Table body -->
  443. <tr<?php echo $osj2Duser_level->DisplayAttributes() ?>>
  444. <?php if ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { ?>
  445. <?php if ($osj2Duser_level->CurrentAction == "edit") { ?>
  446. <td colspan="<?php echo $OptionCnt ?>" align="right"><span class="phpmaker">
  447. <a href="" onClick="if (ew_ValidateForm(document.fosj2Duser_levellist)) document.fosj2Duser_levellist.submit();return false;">Update</a>&nbsp;<a href="osj-osj2duser_levellist.php?a=cancel">Cancel</a>
  448. <input type="hidden" name="a_list" id="a_list" value="update">
  449. </span></td>
  450. <?php } ?>
  451. <?php } else { ?>
  452. <?php if ($osj2Duser_level->Export == "") { ?>
  453. <?php if ($Security->CanView()) { ?>
  454. <td nowrap><span class="phpmaker"><?php if ($osj2Duser_level->user_level_id->CurrentValue <= 0) { ?>-<?php } else { ?>
  455. <a href="<?php echo $osj2Duser_level->ViewUrl() ?>">View</a>
  456. <?php } ?></span></td>
  457. <?php } ?>
  458. <?php if ($Security->CanEdit()) { ?>
  459. <td nowrap><span class="phpmaker"><?php if ($osj2Duser_level->user_level_id->CurrentValue <= 0) { ?>-<?php } else { ?>
  460. <a href="<?php echo $osj2Duser_level->EditUrl() ?>">Edit</a><span class="ewSeparator">&nbsp;|&nbsp;</span><a href="<?php echo $osj2Duser_level->InlineEditUrl() ?>">Inline Edit</a>
  461. <?php } ?></span></td>
  462. <?php } ?>
  463. <td nowrap><span class="phpmaker"><?php if ($osj2Duser_level->user_level_id->CurrentValue < 0) { ?>-<?php } else { ?>
  464. <a href="osj-userpriv.php?user_level_id=<?php echo $osj2Duser_level->user_level_id->CurrentValue ?>">Permission</a>
  465. <?php } ?></span></td>
  466. <?php if ($Security->CanDelete()) { ?>
  467. <td nowrap><span class="phpmaker"><?php if ($osj2Duser_level->user_level_id->CurrentValue <= 0) { ?>-<?php } else { ?>
  468. <input type="checkbox" name="key_m[]" id="key_m[]" value="<?php echo ew_HtmlEncode($osj2Duser_level->user_level_id->CurrentValue) ?>" class="phpmaker" onclick='ew_ClickMultiCheckbox(this);'>
  469. <?php } ?></span></td>
  470. <?php } ?>
  471. <?php } ?>
  472. <?php } ?>
  473. <!-- user_level_id -->
  474. <td<?php echo $osj2Duser_level->user_level_id->CellAttributes() ?>>
  475. <?php if ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  476. <div<?php echo $osj2Duser_level->user_level_id->ViewAttributes() ?>><?php echo $osj2Duser_level->user_level_id->EditValue ?></div>
  477. <input type="hidden" name="x<?php echo $RowIndex ?>_user_level_id" id="x<?php echo $RowIndex ?>_user_level_id" value="<?php echo ew_HtmlEncode($osj2Duser_level->user_level_id->CurrentValue) ?>">
  478. <?php } else { ?>
  479. <div<?php echo $osj2Duser_level->user_level_id->ViewAttributes() ?>><?php echo $osj2Duser_level->user_level_id->ViewValue ?></div>
  480. <?php } ?>
  481. </td>
  482. <!-- user_level_name -->
  483. <td<?php echo $osj2Duser_level->user_level_name->CellAttributes() ?>>
  484. <?php if ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { // Edit Record ?>
  485. <input type="text" name="x<?php echo $RowIndex ?>_user_level_name" id="x<?php echo $RowIndex ?>_user_level_name" title="User Level Description" size="30" maxlength="50" value="<?php echo $osj2Duser_level->user_level_name->EditValue ?>"<?php echo $osj2Duser_level->user_level_name->EditAttributes() ?>>
  486. <?php } else { ?>
  487. <div<?php echo $osj2Duser_level->user_level_name->ViewAttributes() ?>><?php echo $osj2Duser_level->user_level_name->ViewValue ?></div>
  488. <?php } ?>
  489. </td>
  490. </tr>
  491. <?php if ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { ?>
  492. <?php } ?>
  493. <?php
  494. }
  495. $rs->MoveNext();
  496. }
  497. ?>
  498. </table>
  499. <?php if ($osj2Duser_level->Export == "") { ?>
  500. <table>
  501. <tr><td><span class="phpmaker">
  502. <?php if ($Security->CanAdd()) { ?>
  503. <a href="osj-osj2duser_leveladd.php">Add</a>&nbsp;&nbsp;
  504. <?php } ?>
  505. <?php if ($nTotalRecs > 0) { ?>
  506. <?php if ($Security->CanDelete()) { ?>
  507. <a href="" onClick="if (!ew_Selected(document.fosj2Duser_levellist)) alert('No records selected'); else {document.fosj2Duser_levellist.action='osj-osj2duser_leveldelete.php';document.fosj2Duser_levellist.encoding='application/x-www-form-urlencoded';document.fosj2Duser_levellist.submit();};return false;">Delete Selected Records</a>&nbsp;&nbsp;
  508. <?php } ?>
  509. <?php } ?>
  510. </span></td></tr>
  511. </table>
  512. <?php } ?>
  513. <?php } ?>
  514. <?php if ($osj2Duser_level->CurrentAction == "edit") { ?>
  515. <input type="hidden" name="key_count" id="key_count" value="<?php echo $RowIndex ?>">
  516. <?php } ?>
  517. </form>
  518. <?php
  519. // Close recordset and connection
  520. if ($rs) $rs->Close();
  521. ?>
  522. <?php if ($osj2Duser_level->Export == "") { ?>
  523. <form action="osj-osj2duser_levellist.php" name="ewpagerform" id="ewpagerform">
  524. <table border="0" cellspacing="0" cellpadding="0">
  525. <tr>
  526. <td nowrap>
  527. <span class="phpmaker">
  528. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  529. <?php if ($Pager->RecordCount > 0) { ?>
  530. <?php if ($Pager->FirstButton->Enabled) { ?>
  531. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  532. <?php } ?>
  533. <?php if ($Pager->PrevButton->Enabled) { ?>
  534. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  535. <?php } ?>
  536. <?php foreach ($Pager->Items as $PagerItem) { ?>
  537. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_levellist.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  538. <?php } ?>
  539. <?php if ($Pager->NextButton->Enabled) { ?>
  540. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  541. <?php } ?>
  542. <?php if ($Pager->LastButton->Enabled) { ?>
  543. <a href="osj-osj2duser_levellist.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  544. <?php } ?>
  545. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  546. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  547. <?php } else { ?>
  548. <?php if ($Security->CanList()) { ?>
  549. <?php if ($sSrchWhere == "0=101") { ?>
  550. Please enter search criteria
  551. <?php } else { ?>
  552. No records found
  553. <?php } ?>
  554. <?php } else { ?>
  555. You do not have the right permission to view the page
  556. <?php } ?>
  557. <?php } ?>
  558. </span>
  559. </td>
  560. <?php if ($nTotalRecs > 0) { ?>
  561. <td nowrap>&nbsp;&nbsp;&nbsp;&nbsp;</td>
  562. <td align="right" valign="top" nowrap><span class="phpmaker">Records Per Page&nbsp;
  563. <select name="<?php echo EW_TABLE_REC_PER_PAGE ?>" id="<?php echo EW_TABLE_REC_PER_PAGE ?>" onChange="this.form.submit();" class="phpmaker">
  564. <option value="10"<?php if ($nDisplayRecs == 10) echo " selected" ?>>10</option>
  565. <option value="20"<?php if ($nDisplayRecs == 20) echo " selected" ?>>20</option>
  566. <option value="50"<?php if ($nDisplayRecs == 50) echo " selected" ?>>50</option>
  567. </select>
  568. </span></td>
  569. <?php } ?>
  570. </tr>
  571. </table>
  572. </form>
  573. <?php } ?>
  574. <?php if ($osj2Duser_level->Export == "") { ?>
  575. <?php } ?>
  576. <?php if ($osj2Duser_level->Export == "") { ?>
  577. <script language="JavaScript" type="text/javascript">
  578. <!--
  579. // Write your table-specific startup script here
  580. // document.write("page loaded");
  581. //-->
  582. </script>
  583. <?php } ?>
  584. <?php include "osj-footer.php" ?>
  585. <?php
  586. // If control is passed here, simply terminate the page without redirect
  587. Page_Terminate();
  588. // -----------------------------------------------------------------
  589. // Subroutine Page_Terminate
  590. // - called when exit page
  591. // - clean up connection and objects
  592. // - if url specified, redirect to url, otherwise end response
  593. function Page_Terminate($url = "") {
  594. global $conn;
  595. // Page unload event, used in current page
  596. Page_Unload();
  597. // Global page unloaded event (in userfn*.php)
  598. Page_Unloaded();
  599. // Close Connection
  600. $conn->Close();
  601. // Go to url if specified
  602. if ($url <> "") {
  603. ob_end_clean();
  604. header("Location: $url");
  605. }
  606. exit();
  607. }
  608. ?>
  609. <?php
  610. // Set up number of records displayed per page
  611. function SetUpDisplayRecs() {
  612. global $nDisplayRecs, $nStartRec, $osj2Duser_level;
  613. $sWrk = @$_GET[EW_TABLE_REC_PER_PAGE];
  614. if ($sWrk <> "") {
  615. if (is_numeric($sWrk)) {
  616. $nDisplayRecs = intval($sWrk);
  617. } else {
  618. if (strtolower($sWrk) == "all") { // Display all records
  619. $nDisplayRecs = -1;
  620. } else {
  621. $nDisplayRecs = 10; // Non-numeric, load default
  622. }
  623. }
  624. $osj2Duser_level->setRecordsPerPage($nDisplayRecs); // Save to Session
  625. // Reset start position
  626. $nStartRec = 1;
  627. $osj2Duser_level->setStartRecordNumber($nStartRec);
  628. } else {
  629. if ($osj2Duser_level->getRecordsPerPage() <> "") {
  630. $nDisplayRecs = $osj2Duser_level->getRecordsPerPage(); // Restore from Session
  631. } else {
  632. $nDisplayRecs = 10; // Load default
  633. }
  634. }
  635. }
  636. // Exit out of inline mode
  637. function ClearInlineMode() {
  638. global $osj2Duser_level;
  639. $osj2Duser_level->setKey("user_level_id", ""); // Clear inline edit key
  640. $osj2Duser_level->CurrentAction = ""; // Clear action
  641. $_SESSION[EW_SESSION_INLINE_MODE] = ""; // Clear inline mode
  642. }
  643. // Switch to Inline Edit Mode
  644. function InlineEditMode() {
  645. global $Security, $osj2Duser_level;
  646. if (!$Security->CanEdit()) Page_Terminate("osj-login.php"); // Go to login page
  647. $bInlineEdit = TRUE;
  648. if (@$_GET["user_level_id"] <> "") {
  649. $osj2Duser_level->user_level_id->setQueryStringValue($_GET["user_level_id"]);
  650. } else {
  651. $bInlineEdit = FALSE;
  652. }
  653. if ($bInlineEdit) {
  654. if (LoadRow()) {
  655. $osj2Duser_level->setKey("user_level_id", $osj2Duser_level->user_level_id->CurrentValue); // Set up inline edit key
  656. $_SESSION[EW_SESSION_INLINE_MODE] = "edit"; // Enable inline edit
  657. }
  658. }
  659. }
  660. // Peform update to inline edit record
  661. function InlineUpdate() {
  662. global $objForm, $osj2Duser_level;
  663. $objForm->Index = 1;
  664. LoadFormValues(); // Get form values
  665. if (CheckInlineEditKey()) { // Check key
  666. $osj2Duser_level->SendEmail = TRUE; // Send email on update success
  667. $bInlineUpdate = EditRow(); // Update record
  668. } else {
  669. $bInlineUpdate = FALSE;
  670. }
  671. if ($bInlineUpdate) { // Update success
  672. $_SESSION[EW_SESSION_MESSAGE] = "Update successful"; // Set success message
  673. ClearInlineMode(); // Clear inline edit mode
  674. } else {
  675. if (@$_SESSION[EW_SESSION_MESSAGE] == "") {
  676. $_SESSION[EW_SESSION_MESSAGE] = "Update failed"; // Set update failed message
  677. }
  678. $osj2Duser_level->EventCancelled = TRUE; // Cancel event
  679. $osj2Duser_level->CurrentAction = "edit"; // Stay in edit mode
  680. }
  681. }
  682. // Check inline edit key
  683. function CheckInlineEditKey() {
  684. global $osj2Duser_level;
  685. //CheckInlineEditKey = True
  686. if (strval($osj2Duser_level->getKey("user_level_id")) <> strval($osj2Duser_level->user_level_id->CurrentValue)) {
  687. return FALSE;
  688. }
  689. return TRUE;
  690. }
  691. // Set up Sort parameters based on Sort Links clicked
  692. function SetUpSortOrder() {
  693. global $osj2Duser_level;
  694. // Check for an Order parameter
  695. if (@$_GET["order"] <> "") {
  696. $osj2Duser_level->CurrentOrder = ew_StripSlashes(@$_GET["order"]);
  697. $osj2Duser_level->CurrentOrderType = @$_GET["ordertype"];
  698. // Field user_level_id
  699. $osj2Duser_level->UpdateSort($osj2Duser_level->user_level_id);
  700. // Field user_level_name
  701. $osj2Duser_level->UpdateSort($osj2Duser_level->user_level_name);
  702. $osj2Duser_level->setStartRecordNumber(1); // Reset start position
  703. }
  704. $sOrderBy = $osj2Duser_level->getSessionOrderBy(); // Get order by from Session
  705. if ($sOrderBy == "") {
  706. if ($osj2Duser_level->SqlOrderBy() <> "") {
  707. $sOrderBy = $osj2Duser_level->SqlOrderBy();
  708. $osj2Duser_level->setSessionOrderBy($sOrderBy);
  709. }
  710. }
  711. }
  712. // Reset command based on querystring parameter cmd=
  713. // - RESET: reset search parameters
  714. // - RESETALL: reset search & master/detail parameters
  715. // - RESETSORT: reset sort parameters
  716. function ResetCmd() {
  717. global $sDbMasterFilter, $sDbDetailFilter, $nStartRec, $sOrderBy;
  718. global $osj2Duser_level;
  719. // Get reset cmd
  720. if (@$_GET["cmd"] <> "") {
  721. $sCmd = $_GET["cmd"];
  722. // Reset Sort Criteria
  723. if (strtolower($sCmd) == "resetsort") {
  724. $sOrderBy = "";
  725. $osj2Duser_level->setSessionOrderBy($sOrderBy);
  726. $osj2Duser_level->user_level_id->setSort("");
  727. $osj2Duser_level->user_level_name->setSort("");
  728. }
  729. // Reset start position
  730. $nStartRec = 1;
  731. $osj2Duser_level->setStartRecordNumber($nStartRec);
  732. }
  733. }
  734. ?>
  735. <?php
  736. // Set up Starting Record parameters based on Pager Navigation
  737. function SetUpStartRec() {
  738. global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Duser_level;
  739. if ($nDisplayRecs == 0) return;
  740. // Check for a START parameter
  741. if (@$_GET[EW_TABLE_START_REC] <> "") {
  742. $nStartRec = $_GET[EW_TABLE_START_REC];
  743. $osj2Duser_level->setStartRecordNumber($nStartRec);
  744. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  745. $nPageNo = $_GET[EW_TABLE_PAGE_NO];
  746. if (is_numeric($nPageNo)) {
  747. $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
  748. if ($nStartRec <= 0) {
  749. $nStartRec = 1;
  750. } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
  751. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
  752. }
  753. $osj2Duser_level->setStartRecordNumber($nStartRec);
  754. } else {
  755. $nStartRec = $osj2Duser_level->getStartRecordNumber();
  756. }
  757. } else {
  758. $nStartRec = $osj2Duser_level->getStartRecordNumber();
  759. }
  760. // Check if correct start record counter
  761. if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
  762. $nStartRec = 1; // Reset start record counter
  763. $osj2Duser_level->setStartRecordNumber($nStartRec);
  764. } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
  765. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
  766. $osj2Duser_level->setStartRecordNumber($nStartRec);
  767. } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
  768. $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
  769. $osj2Duser_level->setStartRecordNumber($nStartRec);
  770. }
  771. }
  772. ?>
  773. <?php
  774. // Load form values
  775. function LoadFormValues() {
  776. // Load from form
  777. global $objForm, $osj2Duser_level;
  778. $osj2Duser_level->user_level_id->setFormValue($objForm->GetValue("x_user_level_id"));
  779. $osj2Duser_level->user_level_name->setFormValue($objForm->GetValue("x_user_level_name"));
  780. }
  781. // Restore form values
  782. function RestoreFormValues() {
  783. global $osj2Duser_level;
  784. $osj2Duser_level->user_level_id->CurrentValue = $osj2Duser_level->user_level_id->FormValue;
  785. $osj2Duser_level->user_level_name->CurrentValue = $osj2Duser_level->user_level_name->FormValue;
  786. }
  787. ?>
  788. <?php
  789. // Load recordset
  790. function LoadRecordset($offset = -1, $rowcnt = -1) {
  791. global $conn, $osj2Duser_level;
  792. // Call Recordset Selecting event
  793. $osj2Duser_level->Recordset_Selecting($osj2Duser_level->CurrentFilter);
  794. // Load list page sql
  795. $sSql = $osj2Duser_level->SelectSQL();
  796. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  797. // Load recordset
  798. $conn->raiseErrorFn = 'ew_ErrorFn';
  799. $rs = $conn->Execute($sSql);
  800. $conn->raiseErrorFn = '';
  801. // Call Recordset Selected event
  802. $osj2Duser_level->Recordset_Selected($rs);
  803. return $rs;
  804. }
  805. ?>
  806. <?php
  807. // Load row based on key values
  808. function LoadRow() {
  809. global $conn, $Security, $osj2Duser_level;
  810. $sFilter = $osj2Duser_level->SqlKeyFilter();
  811. if (!is_numeric($osj2Duser_level->user_level_id->CurrentValue)) {
  812. return FALSE; // Invalid key, exit
  813. }
  814. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level->user_level_id->CurrentValue), $sFilter); // Replace key value
  815. // Call Row Selecting event
  816. $osj2Duser_level->Row_Selecting($sFilter);
  817. // Load sql based on filter
  818. $osj2Duser_level->CurrentFilter = $sFilter;
  819. $sSql = $osj2Duser_level->SQL();
  820. if ($rs = $conn->Execute($sSql)) {
  821. if ($rs->EOF) {
  822. $LoadRow = FALSE;
  823. } else {
  824. $LoadRow = TRUE;
  825. $rs->MoveFirst();
  826. LoadRowValues($rs); // Load row values
  827. // Call Row Selected event
  828. $osj2Duser_level->Row_Selected($rs);
  829. }
  830. $rs->Close();
  831. } else {
  832. $LoadRow = FALSE;
  833. }
  834. return $LoadRow;
  835. }
  836. // Load row values from recordset
  837. function LoadRowValues(&$rs) {
  838. global $osj2Duser_level;
  839. $osj2Duser_level->user_level_id->setDbValue($rs->fields('user_level_id'));
  840. if (is_null($osj2Duser_level->user_level_id->CurrentValue)) {
  841. $osj2Duser_level->user_level_id->CurrentValue = 0;
  842. } else {
  843. $osj2Duser_level->user_level_id->CurrentValue = intval($osj2Duser_level->user_level_id->CurrentValue);
  844. }
  845. $osj2Duser_level->user_level_name->setDbValue($rs->fields('user_level_name'));
  846. }
  847. ?>
  848. <?php
  849. // Render row values based on field settings
  850. function RenderRow() {
  851. global $conn, $Security, $osj2Duser_level;
  852. // Call Row Rendering event
  853. $osj2Duser_level->Row_Rendering();
  854. // Common render codes for all row types
  855. // user_level_id
  856. $osj2Duser_level->user_level_id->CellCssStyle = "";
  857. $osj2Duser_level->user_level_id->CellCssClass = "";
  858. // user_level_name
  859. $osj2Duser_level->user_level_name->CellCssStyle = "";
  860. $osj2Duser_level->user_level_name->CellCssClass = "";
  861. if ($osj2Duser_level->RowType == EW_ROWTYPE_VIEW) { // View row
  862. // user_level_id
  863. $osj2Duser_level->user_level_id->ViewValue = $osj2Duser_level->user_level_id->CurrentValue;
  864. $osj2Duser_level->user_level_id->CssStyle = "";
  865. $osj2Duser_level->user_level_id->CssClass = "";
  866. $osj2Duser_level->user_level_id->ViewCustomAttributes = "";
  867. // user_level_name
  868. $osj2Duser_level->user_level_name->ViewValue = $osj2Duser_level->user_level_name->CurrentValue;
  869. $osj2Duser_level->user_level_name->CssStyle = "";
  870. $osj2Duser_level->user_level_name->CssClass = "";
  871. $osj2Duser_level->user_level_name->ViewCustomAttributes = "";
  872. // user_level_id
  873. $osj2Duser_level->user_level_id->HrefValue = "";
  874. // user_level_name
  875. $osj2Duser_level->user_level_name->HrefValue = "";
  876. } elseif ($osj2Duser_level->RowType == EW_ROWTYPE_ADD) { // Add row
  877. } elseif ($osj2Duser_level->RowType == EW_ROWTYPE_EDIT) { // Edit row
  878. // user_level_id
  879. $osj2Duser_level->user_level_id->EditCustomAttributes = "";
  880. $osj2Duser_level->user_level_id->EditValue = $osj2Duser_level->user_level_id->CurrentValue;
  881. $osj2Duser_level->user_level_id->CssStyle = "";
  882. $osj2Duser_level->user_level_id->CssClass = "";
  883. $osj2Duser_level->user_level_id->ViewCustomAttributes = "";
  884. // user_level_name
  885. $osj2Duser_level->user_level_name->EditCustomAttributes = "";
  886. $osj2Duser_level->user_level_name->EditValue = ew_HtmlEncode($osj2Duser_level->user_level_name->CurrentValue);
  887. } elseif ($osj2Duser_level->RowType == EW_ROWTYPE_SEARCH) { // Search row
  888. }
  889. // Call Row Rendered event
  890. $osj2Duser_level->Row_Rendered();
  891. }
  892. ?>
  893. <?php
  894. // Update record based on key values
  895. function EditRow() {
  896. global $conn, $Security, $osj2Duser_level;
  897. $sFilter = $osj2Duser_level->SqlKeyFilter();
  898. if (!is_numeric($osj2Duser_level->user_level_id->CurrentValue)) {
  899. return FALSE;
  900. }
  901. $sFilter = str_replace("@user_level_id@", ew_AdjustSql($osj2Duser_level->user_level_id->CurrentValue), $sFilter); // Replace key value
  902. $osj2Duser_level->CurrentFilter = $sFilter;
  903. $sSql = $osj2Duser_level->SQL();
  904. $conn->raiseErrorFn = 'ew_ErrorFn';
  905. $rs = $conn->Execute($sSql);
  906. $conn->raiseErrorFn = '';
  907. if ($rs === FALSE)
  908. return FALSE;
  909. if ($rs->EOF) {
  910. $EditRow = FALSE; // Update Failed
  911. } else {
  912. // Save old values
  913. $rsold =& $rs->fields;
  914. $rsnew = array();
  915. // Field user_level_id
  916. // Field user_level_name
  917. $osj2Duser_level->user_level_name->SetDbValueDef($osj2Duser_level->user_level_name->CurrentValue, "");
  918. $rsnew['user_level_name'] =& $osj2Duser_level->user_level_name->DbValue;
  919. // Call Row Updating event
  920. $bUpdateRow = $osj2Duser_level->Row_Updating($rsold, $rsnew);
  921. if ($bUpdateRow) {
  922. $conn->raiseErrorFn = 'ew_ErrorFn';
  923. $EditRow = $conn->Execute($osj2Duser_level->UpdateSQL($rsnew));
  924. $conn->raiseErrorFn = '';
  925. } else {
  926. if ($osj2Duser_level->CancelMessage <> "") {
  927. $_SESSION[EW_SESSION_MESSAGE] = $osj2Duser_level->CancelMessage;
  928. $osj2Duser_level->CancelMessage = "";
  929. } else {
  930. $_SESSION[EW_SESSION_MESSAGE] = "Update cancelled";
  931. }
  932. $EditRow = FALSE;
  933. }
  934. }
  935. // Call Row Updated event
  936. if ($EditRow) {
  937. $osj2Duser_level->Row_Updated($rsold, $rsnew);
  938. }
  939. if ($EditRow) {
  940. WriteAuditTrailOnEdit($rsold, $rsnew);
  941. }
  942. $rs->Close();
  943. return $EditRow;
  944. }
  945. ?>
  946. <?php
  947. // Export data in Xml or Csv format
  948. function ExportData() {
  949. global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $osj2Duser_level;
  950. $sCsvStr = "";
  951. $rs = LoadRecordset();
  952. $nTotalRecs = $rs->RecordCount();
  953. $nStartRec = 1;
  954. // Export all
  955. if (defined("EW_EXPORT_ALL")) {
  956. $nStopRec = $nTotalRecs;
  957. } else { // Export 1 page only
  958. SetUpStartRec(); // Set Up Start Record Position
  959. // Set the last record to display
  960. if ($nDisplayRecs < 0) {
  961. $nStopRec = $nTotalRecs;
  962. } else {
  963. $nStopRec = $nStartRec + $nDisplayRecs - 1;
  964. }
  965. }
  966. if ($osj2Duser_level->Export == "xml") {
  967. $XmlDoc = new cXMLDocument();
  968. }
  969. if ($osj2Duser_level->Export == "csv") {
  970. $sCsvStr .= "user_level_id" . ",";
  971. $sCsvStr .= "user_level_name" . ",";
  972. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  973. $sCsvStr .= "\n";
  974. }
  975. // Move to first record directly for performance reason
  976. $nRecCount = $nStartRec - 1;
  977. if (!$rs->EOF) {
  978. $rs->MoveFirst();
  979. $rs->Move($nStartRec - 1);
  980. }
  981. while (!$rs->EOF && $nRecCount < $nStopRec) {
  982. $nRecCount++;
  983. if (intval($nRecCount) >= intval($nStartRec)) {
  984. LoadRowValues($rs);
  985. if ($osj2Duser_level->Export == "xml") {
  986. $XmlDoc->BeginRow();
  987. $XmlDoc->AddField('user_level_id', $osj2Duser_level->user_level_id->CurrentValue);
  988. $XmlDoc->AddField('user_level_name', $osj2Duser_level->user_level_name->CurrentValue);
  989. $XmlDoc->EndRow();
  990. }
  991. if ($osj2Duser_level->Export == "csv") {
  992. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level->user_level_id->CurrentValue)) . '",';
  993. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_level->user_level_name->CurrentValue)) . '",';
  994. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  995. $sCsvStr .= "\n";
  996. }
  997. }
  998. $rs->MoveNext();
  999. }
  1000. // Close recordset
  1001. $rs->Close();
  1002. if ($osj2Duser_level->Export == "xml") {
  1003. header("Content-Type: text/xml");
  1004. echo $XmlDoc->XML();
  1005. }
  1006. if ($osj2Duser_level->Export == "csv") {
  1007. echo $sCsvStr;
  1008. }
  1009. }
  1010. ?>
  1011. <?php
  1012. // Write Audit Trail start/end for grid update
  1013. function WriteAuditTrailDummy($typ) {
  1014. $table = 'osj-user_level';
  1015. // Write Audit Trail
  1016. $filePfx = "log";
  1017. $curDate = date("Y/m/d");
  1018. $curTime = date("H:i:s");
  1019. $id = ew_ScriptName();
  1020. $user = CurrentUserID();
  1021. $action = $typ;
  1022. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, "", "", "", "");
  1023. }
  1024. ?>
  1025. <?php
  1026. // Write Audit Trail (edit page)
  1027. function WriteAuditTrailOnEdit(&$rsold, &$rsnew) {
  1028. global $osj2Duser_level;
  1029. $table = 'osj-user_level';
  1030. // Get key value
  1031. $key = "";
  1032. if ($key <> "") $key .= EW_COMPOSITE_KEY_SEPARATOR;
  1033. $key .= $rsold['user_level_id'];
  1034. // Write Audit Trail
  1035. $filePfx = "log";
  1036. $curDate = date("Y/m/d");
  1037. $curTime = date("H:i:s");
  1038. $id = ew_ScriptName();
  1039. $user = CurrentUserID();
  1040. $action = "U";
  1041. foreach (array_keys($rsnew) as $fldname) {
  1042. if ($osj2Duser_level->fields[$fldname]->FldDataType <> EW_DATATYPE_BLOB) { // Ignore Blob Field
  1043. if ($osj2Duser_level->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // DateTime Field
  1044. $modified = (ew_FormatDateTime($rsold[$fldname], 0) <> ew_FormatDateTime($rsnew[$fldname], 0));
  1045. } else {
  1046. $modified = ($rsold[$fldname] <> $rsnew[$fldname]);
  1047. }
  1048. if ($modified) {
  1049. if ($osj2Duser_level->fields[$fldname]->FldDataType == EW_DATATYPE_MEMO) { // Memo Field
  1050. $oldvalue = "<MEMO>";
  1051. $newvalue = "<MEMO>";
  1052. } else {
  1053. $oldvalue = $rsold[$fldname];
  1054. $newvalue = $rsnew[$fldname];
  1055. }
  1056. ew_WriteAuditTrail($filePfx, $curDate, $curTime, $id, $user, $action, $table, $fldname, $key, $oldvalue, $newvalue);
  1057. }
  1058. }
  1059. }
  1060. }
  1061. ?>
  1062. <?php
  1063. // Page Load event
  1064. function Page_Load() {
  1065. //echo "Page Load";
  1066. }
  1067. // Page Unload event
  1068. function Page_Unload() {
  1069. //echo "Page Unload";
  1070. }
  1071. ?>