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

/osj-osj2duser_detailview.php

http://osjobber.googlecode.com/
PHP | 725 lines | 574 code | 72 blank | 79 comment | 123 complexity | ad959231fddceb15c3d3eaac0e945efd MD5 | raw file
Possible License(s): LGPL-2.1, AGPL-1.0
  1. <?php
  2. define("EW_PAGE_ID", "view", TRUE); // Page ID
  3. define("EW_TABLE_NAME", 'osj-user_detail', 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_detailinfo.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_detail');
  32. if (!$Security->IsLoggedIn()) {
  33. $Security->SaveLastUrl();
  34. Page_Terminate("osj-login.php");
  35. }
  36. if (!$Security->CanView()) {
  37. $Security->SaveLastUrl();
  38. Page_Terminate("osj-osj2duser_detaillist.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. $osj2Duser_detail->Export = @$_GET["export"]; // Get export parameter
  55. $sExport = $osj2Duser_detail->Export; // Get export parameter, used in header
  56. $sExportFile = $osj2Duser_detail->TableVar; // Get export file, used in header
  57. ?>
  58. <?php
  59. if (@$_GET["user_detail_id"] <> "") {
  60. if ($sExportFile <> "") $sExportFile .= "_";
  61. $sExportFile .= ew_StripSlashes($_GET["user_detail_id"]);
  62. }
  63. if ($osj2Duser_detail->Export == "html") {
  64. // Printer friendly, no action required
  65. }
  66. if ($osj2Duser_detail->Export == "xml") {
  67. header('Content-Type: text/xml');
  68. header('Content-Disposition: attachment; filename=' . $sExportFile .'.xml');
  69. }
  70. if ($osj2Duser_detail->Export == "csv") {
  71. header('Content-Type: application/csv');
  72. header('Content-Disposition: attachment; filename=' . $sExportFile .'.csv');
  73. }
  74. ?>
  75. <?php
  76. // Paging variables
  77. $nStartRec = 0; // Start record index
  78. $nStopRec = 0; // Stop record index
  79. $nTotalRecs = 0; // Total number of records
  80. $nDisplayRecs = 1;
  81. $nRecRange = 10;
  82. // Load current record
  83. $bLoadCurrentRecord = FALSE;
  84. if (@$_GET["user_detail_id"] <> "") {
  85. $osj2Duser_detail->user_detail_id->setQueryStringValue($_GET["user_detail_id"]);
  86. } else {
  87. $bLoadCurrentRecord = TRUE;
  88. }
  89. // Get action
  90. if (@$_POST["a_view"] <> "") {
  91. $osj2Duser_detail->CurrentAction = $_POST["a_view"];
  92. } else {
  93. $osj2Duser_detail->CurrentAction = "I"; // Display form
  94. }
  95. switch ($osj2Duser_detail->CurrentAction) {
  96. case "I": // Get a record to display
  97. $nStartRec = 1; // Initialize start position
  98. $rs = LoadRecordset(); // Load records
  99. $nTotalRecs = $rs->RecordCount(); // Get record count
  100. if ($nTotalRecs <= 0) { // No record found
  101. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
  102. Page_Terminate("osj-osj2duser_detaillist.php"); // Return to list page
  103. } elseif ($bLoadCurrentRecord) { // Load current record position
  104. SetUpStartRec(); // Set up start record position
  105. // Point to current record
  106. if (intval($nStartRec) <= intval($nTotalRecs)) {
  107. $rs->Move($nStartRec-1);
  108. }
  109. } else { // Match key values
  110. $bMatchRecord = FALSE;
  111. while (!$rs->EOF) {
  112. if (strval($osj2Duser_detail->user_detail_id->CurrentValue) == strval($rs->fields('user_detail_id'))) {
  113. $bMatchRecord = TRUE;
  114. break;
  115. } else {
  116. $nStartRec++;
  117. $rs->MoveNext();
  118. }
  119. }
  120. if (!$bMatchRecord) {
  121. $_SESSION[EW_SESSION_MESSAGE] = "No records found"; // Set no record message
  122. Page_Terminate("osj-osj2duser_detaillist.php"); // Return to list
  123. } else {
  124. $osj2Duser_detail->setStartRecordNumber($nStartRec); // Save record position
  125. }
  126. }
  127. LoadRowValues($rs); // Load row values
  128. }
  129. // Export data only
  130. if ($osj2Duser_detail->Export == "xml" || $osj2Duser_detail->Export == "csv") {
  131. ExportData();
  132. Page_Terminate(); // Terminate response
  133. }
  134. // Set return url
  135. $osj2Duser_detail->setReturnUrl("osj-osj2duser_detailview.php");
  136. // Render row
  137. $osj2Duser_detail->RowType = EW_ROWTYPE_VIEW;
  138. RenderRow();
  139. ?>
  140. <?php include "osj-header.php" ?>
  141. <script type="text/javascript">
  142. <!--
  143. var EW_PAGE_ID = "view"; // Page id
  144. var EW_SHOW_HIGHLIGHT = "Show highlight";
  145. var EW_HIDE_HIGHLIGHT = "Hide highlight";
  146. //-->
  147. </script>
  148. <script language="JavaScript" type="text/javascript">
  149. <!--
  150. // Write your client script here, no need to add script tags.
  151. // To include another .js script, use:
  152. // ew_ClientScriptInclude("my_javascript.js");
  153. //-->
  154. </script>
  155. <p><span class="phpmaker">View TABLE: User Details
  156. <?php if ($osj2Duser_detail->Export == "") { ?>
  157. &nbsp;&nbsp;<a href="osj-osj2duser_detailview.php?export=html&user_detail_id=<?php echo urlencode($osj2Duser_detail->user_detail_id->CurrentValue) ?>">Printer Friendly</a>
  158. &nbsp;&nbsp;<a href="osj-osj2duser_detailview.php?export=xml&user_detail_id=<?php echo urlencode($osj2Duser_detail->user_detail_id->CurrentValue) ?>">Export to XML</a>
  159. &nbsp;&nbsp;<a href="osj-osj2duser_detailview.php?export=csv&user_detail_id=<?php echo urlencode($osj2Duser_detail->user_detail_id->CurrentValue) ?>">Export to CSV</a>
  160. <?php } ?>
  161. <br><br>
  162. <?php if ($osj2Duser_detail->Export == "") { ?>
  163. <a href="osj-osj2duser_detaillist.php">Back to List</a>&nbsp;
  164. <?php if ($Security->CanAdd()) { ?>
  165. <?php if (ShowOptionLink()) { ?>
  166. <a href="osj-osj2duser_detailadd.php">Add</a>&nbsp;
  167. <?php } ?>
  168. <?php } ?>
  169. <?php if ($Security->CanEdit()) { ?>
  170. <?php if (ShowOptionLink()) { ?>
  171. <a href="<?php echo $osj2Duser_detail->EditUrl() ?>">Edit</a>&nbsp;
  172. <?php } ?>
  173. <?php } ?>
  174. <?php if ($Security->CanDelete()) { ?>
  175. <?php if (ShowOptionLink()) { ?>
  176. <a href="<?php echo $osj2Duser_detail->DeleteUrl() ?>">Delete</a>&nbsp;
  177. <?php } ?>
  178. <?php } ?>
  179. <?php } ?>
  180. </span>
  181. </p>
  182. <?php
  183. if (@$_SESSION[EW_SESSION_MESSAGE] <> "") {
  184. ?>
  185. <p><span class="ewmsg"><?php echo $_SESSION[EW_SESSION_MESSAGE] ?></span></p>
  186. <?php
  187. $_SESSION[EW_SESSION_MESSAGE] = ""; // Clear message
  188. }
  189. ?>
  190. <p>
  191. <?php if ($osj2Duser_detail->Export == "") { ?>
  192. <form action="osj-osj2duser_detailview.php" name="ewpagerform" id="ewpagerform">
  193. <table border="0" cellspacing="0" cellpadding="0">
  194. <tr>
  195. <td nowrap>
  196. <span class="phpmaker">
  197. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  198. <?php if ($Pager->RecordCount > 0) { ?>
  199. <?php if ($Pager->FirstButton->Enabled) { ?>
  200. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  201. <?php } ?>
  202. <?php if ($Pager->PrevButton->Enabled) { ?>
  203. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  204. <?php } ?>
  205. <?php foreach ($Pager->Items as $PagerItem) { ?>
  206. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_detailview.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  207. <?php } ?>
  208. <?php if ($Pager->NextButton->Enabled) { ?>
  209. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  210. <?php } ?>
  211. <?php if ($Pager->LastButton->Enabled) { ?>
  212. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  213. <?php } ?>
  214. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  215. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  216. <?php } else { ?>
  217. <?php if ($Security->CanList()) { ?>
  218. <?php if ($sSrchWhere == "0=101") { ?>
  219. Please enter search criteria
  220. <?php } else { ?>
  221. No records found
  222. <?php } ?>
  223. <?php } else { ?>
  224. You do not have the right permission to view the page
  225. <?php } ?>
  226. <?php } ?>
  227. </span>
  228. </td>
  229. </tr>
  230. </table>
  231. </form>
  232. <?php } ?>
  233. <form>
  234. <table class="ewTable">
  235. <tr class="ewTableRow">
  236. <td class="ewTableHeader">detail_id</td>
  237. <td<?php echo $osj2Duser_detail->user_detail_id->CellAttributes() ?>>
  238. </td>
  239. </tr>
  240. <tr class="ewTableAltRow">
  241. <td class="ewTableHeader">user id</td>
  242. <td<?php echo $osj2Duser_detail->user_id->CellAttributes() ?>>
  243. <div<?php echo $osj2Duser_detail->user_id->ViewAttributes() ?>><?php echo $osj2Duser_detail->user_id->ViewValue ?></div>
  244. </td>
  245. </tr>
  246. <tr class="ewTableRow">
  247. <td class="ewTableHeader">detail creation date</td>
  248. <td<?php echo $osj2Duser_detail->user_detail_creation_date->CellAttributes() ?>>
  249. </td>
  250. </tr>
  251. <tr class="ewTableAltRow">
  252. <td class="ewTableHeader">detail edit date</td>
  253. <td<?php echo $osj2Duser_detail->user_detail_edit_date->CellAttributes() ?>>
  254. </td>
  255. </tr>
  256. <tr class="ewTableRow">
  257. <td class="ewTableHeader">First Name</td>
  258. <td<?php echo $osj2Duser_detail->user_first_name->CellAttributes() ?>>
  259. <div<?php echo $osj2Duser_detail->user_first_name->ViewAttributes() ?>><?php echo $osj2Duser_detail->user_first_name->ViewValue ?></div>
  260. </td>
  261. </tr>
  262. <tr class="ewTableAltRow">
  263. <td class="ewTableHeader">Last Name</td>
  264. <td<?php echo $osj2Duser_detail->user_last_name->CellAttributes() ?>>
  265. <div<?php echo $osj2Duser_detail->user_last_name->ViewAttributes() ?>><?php echo $osj2Duser_detail->user_last_name->ViewValue ?></div>
  266. </td>
  267. </tr>
  268. <tr class="ewTableRow">
  269. <td class="ewTableHeader">Description</td>
  270. <td<?php echo $osj2Duser_detail->user_description->CellAttributes() ?>>
  271. <div<?php echo $osj2Duser_detail->user_description->ViewAttributes() ?>><?php echo $osj2Duser_detail->user_description->ViewValue ?></div>
  272. </td>
  273. </tr>
  274. <tr class="ewTableAltRow">
  275. <td class="ewTableHeader">Company</td>
  276. <td<?php echo $osj2Duser_detail->user_company->CellAttributes() ?>>
  277. <div<?php echo $osj2Duser_detail->user_company->ViewAttributes() ?>><?php echo $osj2Duser_detail->user_company->ViewValue ?></div>
  278. </td>
  279. </tr>
  280. </table>
  281. </form>
  282. <?php if ($osj2Duser_detail->Export == "") { ?>
  283. <form action="osj-osj2duser_detailview.php" name="ewpagerform" id="ewpagerform">
  284. <table border="0" cellspacing="0" cellpadding="0">
  285. <tr>
  286. <td nowrap>
  287. <span class="phpmaker">
  288. <?php if (!isset($Pager)) $Pager = new cNumericPager($nStartRec, $nDisplayRecs, $nTotalRecs, $nRecRange) ?>
  289. <?php if ($Pager->RecordCount > 0) { ?>
  290. <?php if ($Pager->FirstButton->Enabled) { ?>
  291. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->FirstButton->Start ?>"><b>First</b></a>&nbsp;
  292. <?php } ?>
  293. <?php if ($Pager->PrevButton->Enabled) { ?>
  294. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->PrevButton->Start ?>"><b>Previous</b></a>&nbsp;
  295. <?php } ?>
  296. <?php foreach ($Pager->Items as $PagerItem) { ?>
  297. <?php if ($PagerItem->Enabled) { ?><a href="osj-osj2duser_detailview.php?start=<?php echo $PagerItem->Start ?>"><?php } ?><b><?php echo $PagerItem->Text ?></b><?php if ($PagerItem->Enabled) { ?></a><?php } ?>&nbsp;
  298. <?php } ?>
  299. <?php if ($Pager->NextButton->Enabled) { ?>
  300. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->NextButton->Start ?>"><b>Next</b></a>&nbsp;
  301. <?php } ?>
  302. <?php if ($Pager->LastButton->Enabled) { ?>
  303. <a href="osj-osj2duser_detailview.php?start=<?php echo $Pager->LastButton->Start ?>"><b>Last</b></a>&nbsp;
  304. <?php } ?>
  305. <?php if ($Pager->ButtonCount > 0) { ?><br><?php } ?>
  306. Records <?php echo $Pager->FromIndex ?> to <?php echo $Pager->ToIndex ?> of <?php echo $Pager->RecordCount ?>
  307. <?php } else { ?>
  308. <?php if ($Security->CanList()) { ?>
  309. <?php if ($sSrchWhere == "0=101") { ?>
  310. Please enter search criteria
  311. <?php } else { ?>
  312. No records found
  313. <?php } ?>
  314. <?php } else { ?>
  315. You do not have the right permission to view the page
  316. <?php } ?>
  317. <?php } ?>
  318. </span>
  319. </td>
  320. </tr>
  321. </table>
  322. </form>
  323. <?php } ?>
  324. <p>
  325. <script language="JavaScript" type="text/javascript">
  326. <!--
  327. // Write your table-specific startup script here
  328. // document.write("page loaded");
  329. //-->
  330. </script>
  331. <?php include "osj-footer.php" ?>
  332. <?php
  333. // If control is passed here, simply terminate the page without redirect
  334. Page_Terminate();
  335. // -----------------------------------------------------------------
  336. // Subroutine Page_Terminate
  337. // - called when exit page
  338. // - clean up connection and objects
  339. // - if url specified, redirect to url, otherwise end response
  340. function Page_Terminate($url = "") {
  341. global $conn;
  342. // Page unload event, used in current page
  343. Page_Unload();
  344. // Global page unloaded event (in userfn*.php)
  345. Page_Unloaded();
  346. // Close Connection
  347. $conn->Close();
  348. // Go to url if specified
  349. if ($url <> "") {
  350. ob_end_clean();
  351. header("Location: $url");
  352. }
  353. exit();
  354. }
  355. ?>
  356. <?php
  357. // Load recordset
  358. function LoadRecordset($offset = -1, $rowcnt = -1) {
  359. global $conn, $osj2Duser_detail;
  360. // Call Recordset Selecting event
  361. $osj2Duser_detail->Recordset_Selecting($osj2Duser_detail->CurrentFilter);
  362. // Load list page sql
  363. $sSql = $osj2Duser_detail->SelectSQL();
  364. if ($offset > -1 && $rowcnt > -1) $sSql .= " LIMIT $offset, $rowcnt";
  365. // Load recordset
  366. $conn->raiseErrorFn = 'ew_ErrorFn';
  367. $rs = $conn->Execute($sSql);
  368. $conn->raiseErrorFn = '';
  369. // Call Recordset Selected event
  370. $osj2Duser_detail->Recordset_Selected($rs);
  371. return $rs;
  372. }
  373. ?>
  374. <?php
  375. // Load row based on key values
  376. function LoadRow() {
  377. global $conn, $Security, $osj2Duser_detail;
  378. $sFilter = $osj2Duser_detail->SqlKeyFilter();
  379. if (!is_numeric($osj2Duser_detail->user_detail_id->CurrentValue)) {
  380. return FALSE; // Invalid key, exit
  381. }
  382. $sFilter = str_replace("@user_detail_id@", ew_AdjustSql($osj2Duser_detail->user_detail_id->CurrentValue), $sFilter); // Replace key value
  383. if ($Security->CurrentUserID() <> "" && !$Security->IsAdmin()) { // Non system admin
  384. $sFilter = $osj2Duser_detail->AddUserIDFilter($sFilter, $Security->CurrentUserID()); // Add User ID filter
  385. }
  386. // Call Row Selecting event
  387. $osj2Duser_detail->Row_Selecting($sFilter);
  388. // Load sql based on filter
  389. $osj2Duser_detail->CurrentFilter = $sFilter;
  390. $sSql = $osj2Duser_detail->SQL();
  391. if ($rs = $conn->Execute($sSql)) {
  392. if ($rs->EOF) {
  393. $LoadRow = FALSE;
  394. } else {
  395. $LoadRow = TRUE;
  396. $rs->MoveFirst();
  397. LoadRowValues($rs); // Load row values
  398. // Call Row Selected event
  399. $osj2Duser_detail->Row_Selected($rs);
  400. }
  401. $rs->Close();
  402. } else {
  403. $LoadRow = FALSE;
  404. }
  405. return $LoadRow;
  406. }
  407. // Load row values from recordset
  408. function LoadRowValues(&$rs) {
  409. global $osj2Duser_detail;
  410. $osj2Duser_detail->user_detail_id->setDbValue($rs->fields('user_detail_id'));
  411. $osj2Duser_detail->user_id->setDbValue($rs->fields('user_id'));
  412. $osj2Duser_detail->user_detail_creation_date->setDbValue($rs->fields('user_detail_creation_date'));
  413. $osj2Duser_detail->user_detail_edit_date->setDbValue($rs->fields('user_detail_edit_date'));
  414. $osj2Duser_detail->user_first_name->setDbValue($rs->fields('user_first_name'));
  415. $osj2Duser_detail->user_last_name->setDbValue($rs->fields('user_last_name'));
  416. $osj2Duser_detail->user_description->setDbValue($rs->fields('user_description'));
  417. $osj2Duser_detail->user_company->setDbValue($rs->fields('user_company'));
  418. }
  419. ?>
  420. <?php
  421. // Render row values based on field settings
  422. function RenderRow() {
  423. global $conn, $Security, $osj2Duser_detail;
  424. // Call Row Rendering event
  425. $osj2Duser_detail->Row_Rendering();
  426. // Common render codes for all row types
  427. // user_detail_id
  428. $osj2Duser_detail->user_detail_id->CellCssStyle = "";
  429. $osj2Duser_detail->user_detail_id->CellCssClass = "";
  430. // user_id
  431. $osj2Duser_detail->user_id->CellCssStyle = "";
  432. $osj2Duser_detail->user_id->CellCssClass = "";
  433. // user_detail_creation_date
  434. $osj2Duser_detail->user_detail_creation_date->CellCssStyle = "";
  435. $osj2Duser_detail->user_detail_creation_date->CellCssClass = "";
  436. // user_detail_edit_date
  437. $osj2Duser_detail->user_detail_edit_date->CellCssStyle = "";
  438. $osj2Duser_detail->user_detail_edit_date->CellCssClass = "";
  439. // user_first_name
  440. $osj2Duser_detail->user_first_name->CellCssStyle = "";
  441. $osj2Duser_detail->user_first_name->CellCssClass = "";
  442. // user_last_name
  443. $osj2Duser_detail->user_last_name->CellCssStyle = "";
  444. $osj2Duser_detail->user_last_name->CellCssClass = "";
  445. // user_description
  446. $osj2Duser_detail->user_description->CellCssStyle = "";
  447. $osj2Duser_detail->user_description->CellCssClass = "";
  448. // user_company
  449. $osj2Duser_detail->user_company->CellCssStyle = "";
  450. $osj2Duser_detail->user_company->CellCssClass = "";
  451. if ($osj2Duser_detail->RowType == EW_ROWTYPE_VIEW) { // View row
  452. // user_detail_id
  453. $osj2Duser_detail->user_detail_id->CssStyle = "";
  454. $osj2Duser_detail->user_detail_id->CssClass = "";
  455. $osj2Duser_detail->user_detail_id->ViewCustomAttributes = "";
  456. // user_id
  457. $osj2Duser_detail->user_id->ViewValue = $osj2Duser_detail->user_id->CurrentValue;
  458. $osj2Duser_detail->user_id->CssStyle = "";
  459. $osj2Duser_detail->user_id->CssClass = "";
  460. $osj2Duser_detail->user_id->ViewCustomAttributes = "";
  461. // user_detail_creation_date
  462. $osj2Duser_detail->user_detail_creation_date->ViewValue = ew_FormatDateTime($osj2Duser_detail->user_detail_creation_date->ViewValue, 6);
  463. $osj2Duser_detail->user_detail_creation_date->CssStyle = "";
  464. $osj2Duser_detail->user_detail_creation_date->CssClass = "";
  465. $osj2Duser_detail->user_detail_creation_date->ViewCustomAttributes = "";
  466. // user_detail_edit_date
  467. $osj2Duser_detail->user_detail_edit_date->ViewValue = ew_FormatDateTime($osj2Duser_detail->user_detail_edit_date->ViewValue, 6);
  468. $osj2Duser_detail->user_detail_edit_date->CssStyle = "";
  469. $osj2Duser_detail->user_detail_edit_date->CssClass = "";
  470. $osj2Duser_detail->user_detail_edit_date->ViewCustomAttributes = "";
  471. // user_first_name
  472. $osj2Duser_detail->user_first_name->ViewValue = $osj2Duser_detail->user_first_name->CurrentValue;
  473. $osj2Duser_detail->user_first_name->CssStyle = "";
  474. $osj2Duser_detail->user_first_name->CssClass = "";
  475. $osj2Duser_detail->user_first_name->ViewCustomAttributes = "";
  476. // user_last_name
  477. $osj2Duser_detail->user_last_name->ViewValue = $osj2Duser_detail->user_last_name->CurrentValue;
  478. $osj2Duser_detail->user_last_name->CssStyle = "";
  479. $osj2Duser_detail->user_last_name->CssClass = "";
  480. $osj2Duser_detail->user_last_name->ViewCustomAttributes = "";
  481. // user_description
  482. $osj2Duser_detail->user_description->ViewValue = $osj2Duser_detail->user_description->CurrentValue;
  483. if (!is_null($osj2Duser_detail->user_description->ViewValue)) $osj2Duser_detail->user_description->ViewValue = str_replace("\n", "<br>", $osj2Duser_detail->user_description->ViewValue);
  484. $osj2Duser_detail->user_description->CssStyle = "";
  485. $osj2Duser_detail->user_description->CssClass = "";
  486. $osj2Duser_detail->user_description->ViewCustomAttributes = "";
  487. // user_company
  488. $osj2Duser_detail->user_company->ViewValue = $osj2Duser_detail->user_company->CurrentValue;
  489. $osj2Duser_detail->user_company->CssStyle = "";
  490. $osj2Duser_detail->user_company->CssClass = "";
  491. $osj2Duser_detail->user_company->ViewCustomAttributes = "";
  492. // user_detail_id
  493. $osj2Duser_detail->user_detail_id->HrefValue = "";
  494. // user_id
  495. $osj2Duser_detail->user_id->HrefValue = "";
  496. // user_detail_creation_date
  497. $osj2Duser_detail->user_detail_creation_date->HrefValue = "";
  498. // user_detail_edit_date
  499. $osj2Duser_detail->user_detail_edit_date->HrefValue = "";
  500. // user_first_name
  501. $osj2Duser_detail->user_first_name->HrefValue = "";
  502. // user_last_name
  503. $osj2Duser_detail->user_last_name->HrefValue = "";
  504. // user_description
  505. $osj2Duser_detail->user_description->HrefValue = "";
  506. // user_company
  507. $osj2Duser_detail->user_company->HrefValue = "";
  508. } elseif ($osj2Duser_detail->RowType == EW_ROWTYPE_ADD) { // Add row
  509. } elseif ($osj2Duser_detail->RowType == EW_ROWTYPE_EDIT) { // Edit row
  510. } elseif ($osj2Duser_detail->RowType == EW_ROWTYPE_SEARCH) { // Search row
  511. }
  512. // Call Row Rendered event
  513. $osj2Duser_detail->Row_Rendered();
  514. }
  515. ?>
  516. <?php
  517. // Export data in Xml or Csv format
  518. function ExportData() {
  519. global $nTotalRecs, $nStartRec, $nStopRec, $nTotalRecs, $nDisplayRecs, $osj2Duser_detail;
  520. $sCsvStr = "";
  521. $rs = LoadRecordset();
  522. $nTotalRecs = $rs->RecordCount();
  523. $nStartRec = 1;
  524. SetUpStartRec(); // Set Up Start Record Position
  525. // Set the last record to display
  526. if ($nDisplayRecs < 0) {
  527. $nStopRec = $nTotalRecs;
  528. } else {
  529. $nStopRec = $nStartRec + $nDisplayRecs - 1;
  530. }
  531. if ($osj2Duser_detail->Export == "xml") {
  532. $XmlDoc = new cXMLDocument();
  533. }
  534. if ($osj2Duser_detail->Export == "csv") {
  535. $sCsvStr .= "user_detail_id" . ",";
  536. $sCsvStr .= "user_id" . ",";
  537. $sCsvStr .= "user_detail_creation_date" . ",";
  538. $sCsvStr .= "user_detail_edit_date" . ",";
  539. $sCsvStr .= "user_first_name" . ",";
  540. $sCsvStr .= "user_last_name" . ",";
  541. $sCsvStr .= "user_description" . ",";
  542. $sCsvStr .= "user_company" . ",";
  543. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  544. $sCsvStr .= "\n";
  545. }
  546. // Move to first record directly for performance reason
  547. $nRecCount = $nStartRec - 1;
  548. if (!$rs->EOF) {
  549. $rs->MoveFirst();
  550. $rs->Move($nStartRec - 1);
  551. }
  552. while (!$rs->EOF && $nRecCount < $nStopRec) {
  553. $nRecCount++;
  554. if (intval($nRecCount) >= intval($nStartRec)) {
  555. LoadRowValues($rs);
  556. if ($osj2Duser_detail->Export == "xml") {
  557. $XmlDoc->BeginRow();
  558. $XmlDoc->AddField('user_detail_id', $osj2Duser_detail->user_detail_id->CurrentValue);
  559. $XmlDoc->AddField('user_id', $osj2Duser_detail->user_id->CurrentValue);
  560. $XmlDoc->AddField('user_detail_creation_date', $osj2Duser_detail->user_detail_creation_date->CurrentValue);
  561. $XmlDoc->AddField('user_detail_edit_date', $osj2Duser_detail->user_detail_edit_date->CurrentValue);
  562. $XmlDoc->AddField('user_first_name', $osj2Duser_detail->user_first_name->CurrentValue);
  563. $XmlDoc->AddField('user_last_name', $osj2Duser_detail->user_last_name->CurrentValue);
  564. $XmlDoc->AddField('user_description', $osj2Duser_detail->user_description->CurrentValue);
  565. $XmlDoc->AddField('user_company', $osj2Duser_detail->user_company->CurrentValue);
  566. $XmlDoc->EndRow();
  567. }
  568. if ($osj2Duser_detail->Export == "csv") {
  569. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_detail_id->CurrentValue)) . '",';
  570. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_id->CurrentValue)) . '",';
  571. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_detail_creation_date->CurrentValue)) . '",';
  572. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_detail_edit_date->CurrentValue)) . '",';
  573. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_first_name->CurrentValue)) . '",';
  574. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_last_name->CurrentValue)) . '",';
  575. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_description->CurrentValue)) . '",';
  576. $sCsvStr .= '"' . str_replace('"', '""', strval($osj2Duser_detail->user_company->CurrentValue)) . '",';
  577. $sCsvStr = substr($sCsvStr, 0, strlen($sCsvStr)-1); // Remove last comma
  578. $sCsvStr .= "\n";
  579. }
  580. }
  581. $rs->MoveNext();
  582. }
  583. // Close recordset
  584. $rs->Close();
  585. if ($osj2Duser_detail->Export == "xml") {
  586. header("Content-Type: text/xml");
  587. echo $XmlDoc->XML();
  588. }
  589. if ($osj2Duser_detail->Export == "csv") {
  590. echo $sCsvStr;
  591. }
  592. }
  593. ?>
  594. <?php
  595. // Show link optionally based on User ID
  596. function ShowOptionLink() {
  597. global $Security, $osj2Duser_detail;
  598. if ($Security->IsLoggedIn()) {
  599. if (!$Security->IsAdmin()) {
  600. return $Security->IsValidUserID($osj2Duser_detail->user_id->CurrentValue);
  601. }
  602. }
  603. return TRUE;
  604. }
  605. ?>
  606. <?php
  607. // Set up Starting Record parameters based on Pager Navigation
  608. function SetUpStartRec() {
  609. global $nDisplayRecs, $nStartRec, $nTotalRecs, $nPageNo, $osj2Duser_detail;
  610. if ($nDisplayRecs == 0) return;
  611. // Check for a START parameter
  612. if (@$_GET[EW_TABLE_START_REC] <> "") {
  613. $nStartRec = $_GET[EW_TABLE_START_REC];
  614. $osj2Duser_detail->setStartRecordNumber($nStartRec);
  615. } elseif (@$_GET[EW_TABLE_PAGE_NO] <> "") {
  616. $nPageNo = $_GET[EW_TABLE_PAGE_NO];
  617. if (is_numeric($nPageNo)) {
  618. $nStartRec = ($nPageNo-1)*$nDisplayRecs+1;
  619. if ($nStartRec <= 0) {
  620. $nStartRec = 1;
  621. } elseif ($nStartRec >= intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1) {
  622. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1;
  623. }
  624. $osj2Duser_detail->setStartRecordNumber($nStartRec);
  625. } else {
  626. $nStartRec = $osj2Duser_detail->getStartRecordNumber();
  627. }
  628. } else {
  629. $nStartRec = $osj2Duser_detail->getStartRecordNumber();
  630. }
  631. // Check if correct start record counter
  632. if (!is_numeric($nStartRec) || $nStartRec == "") { // Avoid invalid start record counter
  633. $nStartRec = 1; // Reset start record counter
  634. $osj2Duser_detail->setStartRecordNumber($nStartRec);
  635. } elseif (intval($nStartRec) > intval($nTotalRecs)) { // Avoid starting record > total records
  636. $nStartRec = intval(($nTotalRecs-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to last page first record
  637. $osj2Duser_detail->setStartRecordNumber($nStartRec);
  638. } elseif (($nStartRec-1) % $nDisplayRecs <> 0) {
  639. $nStartRec = intval(($nStartRec-1)/$nDisplayRecs)*$nDisplayRecs+1; // Point to page boundary
  640. $osj2Duser_detail->setStartRecordNumber($nStartRec);
  641. }
  642. }
  643. ?>
  644. <?php
  645. // Page Load event
  646. function Page_Load() {
  647. //echo "Page Load";
  648. }
  649. // Page Unload event
  650. function Page_Unload() {
  651. //echo "Page Unload";
  652. }
  653. ?>