Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2591 lines
65 KiB

  1. <% '==================================================
  2. ' Module: ots_table.asp
  3. '
  4. ' Synopsis: Object Task Selector Table Formatting Functions
  5. '
  6. ' Copyright (c) Microsoft Corporation. All rights reserved.
  7. '================================================== %>
  8. <%
  9. '
  10. ' --------------------------------------------------------------
  11. ' T A B L E O B J E C T
  12. ' --------------------------------------------------------------
  13. '
  14. Const OTS_TABLE_DIM = 22
  15. Const OTS_TABLE_OBJECT = 0
  16. Const OTS_TABLE_TYPE = 1
  17. Const OTS_TABLE_CAPTION = 2
  18. Const OTS_TABLE_DESC = 3
  19. Const OTS_TABLE_COLS = 4
  20. Const OTS_TABLE_ROWS = 5
  21. Const OTS_TABLE_ID = 6
  22. Const OTS_TABLE_TASKS = 7
  23. Const OTS_TABLE_SORT = 8
  24. Const OTS_TABLE_TASKS_TITLE = 9
  25. Const OTS_TABLE_PKEY_NAME = 10
  26. Const OTS_TABLE_MULTI_SELECT = 11
  27. Const OTS_TABLE_AUTO_INIT = 12
  28. Const OTS_TABLE_SEARCHING = 13
  29. Const OTS_TABLE_PAGING = 14
  30. Const OTS_TABLE_PAGE_MAX = 15
  31. Const OTS_TABLE_PAGE_MIN = 16
  32. Const OTS_TABLE_PAGE_CURRENT = 17
  33. Const OTS_TABLE_PAGE_RESET = 18
  34. Const OTS_TABLE_SORT_COL = 19
  35. Const OTS_TABLE_SORT_SEQ = 20
  36. Const OTS_TABLE_SORT_SET = 21
  37. Const OTS_TABLE_OBJECT_ID = "Table" ' Note: DO NOT LOCALIZE
  38. Const OTS_TABLE_TYPE_BASIC = 1
  39. DIM OTS_TABLE_NEXT_ID
  40. OTS_TABLE_NEXT_ID = 1
  41. ' --------------------------------------------------------------
  42. '
  43. ' Function: OTS_CreateTable
  44. '
  45. ' Synopsis: Create a new object task selection object
  46. '
  47. ' Arguments: [in] Caption for the table
  48. ' [in] Description of what the table contains
  49. '
  50. ' Returns: The Table object
  51. '
  52. ' --------------------------------------------------------------
  53. Public Function OTS_CreateTable(ByVal TableCaption, ByVal TableDescription)
  54. Dim Table()
  55. ReDim Table(OTS_TABLE_DIM)
  56. SA_ClearError()
  57. Table(OTS_TABLE_OBJECT) = OTS_TABLE_OBJECT_ID
  58. Table(OTS_TABLE_TYPE) = OTS_TABLE_TYPE_BASIC
  59. Table(OTS_TABLE_CAPTION) = TableCaption
  60. Table(OTS_TABLE_DESC) = TableDescription
  61. Table(OTS_TABLE_COLS) = Null
  62. Table(OTS_TABLE_PKEY_NAME) = "PKey"
  63. Table(OTS_TABLE_MULTI_SELECT) = FALSE
  64. Table(OTS_TABLE_AUTO_INIT) = TRUE
  65. Table(OTS_TABLE_SEARCHING) = FALSE
  66. Table(OTS_TABLE_PAGING) = FALSE
  67. Table(OTS_TABLE_PAGE_MAX) = 0
  68. Table(OTS_TABLE_PAGE_MIN) = 1
  69. Table(OTS_TABLE_PAGE_CURRENT) = 1
  70. Table(OTS_TABLE_PAGE_RESET) = FALSE
  71. Table(OTS_TABLE_SORT_COL) = 0
  72. Table(OTS_TABLE_SORT_SEQ) = "A"
  73. Table(OTS_TABLE_SORT_SET) = FALSE
  74. OTS_CreateTable = Table
  75. End Function
  76. ' --------------------------------------------------------------
  77. '
  78. ' Function: OTS_IsValidTable
  79. '
  80. ' Synopsis: Verify that the reference object is a valid table. To
  81. ' be valid it must be an array, of the correct size,
  82. ' which has OTS_TABLE_OBJECT_ID as the first element
  83. '
  84. ' Note: This is the only function in this package
  85. ' that DOES NOT RETURN FAILURE CODES. If
  86. ' the table is valid it returns true. Otherwise
  87. ' it returns false.
  88. '
  89. ' Returns: True if the table is valid, otherwise false
  90. '
  91. ' --------------------------------------------------------------
  92. Private Function OTS_IsValidTable(ByRef Table)
  93. Dim bisValidTable
  94. bisValidTable = false
  95. If (IsArray(Table)) Then
  96. If ( UBound(Table) >= OTS_TABLE_DIM ) Then
  97. Dim tableObject
  98. tableObject = Table(OTS_TABLE_OBJECT)
  99. If (tableObject = OTS_TABLE_OBJECT_ID) Then
  100. bisValidTable = true
  101. Else
  102. SA_TraceOut "OTS_IsValidTable", "(tableObject <> OTS_TABLE_OBJECT_ID)"
  103. End If
  104. Else
  105. SA_TraceOut "OTS_IsValidTable", "(UBound(Table) >= OTS_TABLE_DIM)"
  106. End If
  107. Else
  108. SA_TraceOut "OTS_IsValidTable", "(IsArray(Table))"
  109. End If
  110. OTS_IsValidTable = bisValidTable
  111. End Function
  112. ' --------------------------------------------------------------
  113. '
  114. ' Function: OTS_IsAutoInitEnabled
  115. '
  116. ' Synopsis: Check and return the state of the auto initialization
  117. ' option.
  118. '
  119. ' Arguments: [in] Table
  120. '
  121. ' Return gc_ERR_SUCCESS or error code
  122. '
  123. ' --------------------------------------------------------------
  124. Public Function OTS_IsAutoInitEnabled(ByRef Table)
  125. Dim rc
  126. OTS_IsAutoInitEnabled = FALSE
  127. SA_ClearError()
  128. If (OTS_IsValidTable(Table)) Then
  129. OTS_IsAutoInitEnabled = Table(OTS_TABLE_AUTO_INIT)
  130. Else
  131. Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsAutoInitEnabled")
  132. End If
  133. End Function
  134. ' --------------------------------------------------------------
  135. '
  136. ' Function: OTS_EnableAutoInit
  137. '
  138. ' Synopsis: Toggle the auto initialization option.
  139. '
  140. ' Arguments: [in] Table
  141. ' [in] bEnabled boolean flag, TRUE to enable, FALSE to disable
  142. '
  143. ' Return gc_ERR_SUCCESS or error code
  144. '
  145. ' --------------------------------------------------------------
  146. Public Function OTS_EnableAutoInit(ByRef Table, ByVal bEnable)
  147. Dim rc
  148. OTS_EnableAutoInit = gc_ERR_SUCCESS
  149. SA_ClearError()
  150. If (OTS_IsValidTable(Table)) Then
  151. Table(OTS_TABLE_AUTO_INIT) = bEnable
  152. Else
  153. OTS_EnableAutoInit = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnableAutoInit")
  154. End If
  155. End Function
  156. ' --------------------------------------------------------------
  157. '
  158. ' Function: OTS_IsSearchEnabled
  159. '
  160. ' Synopsis: Check and return the state of the searching option
  161. '
  162. ' Arguments: [in] Table
  163. '
  164. ' Return gc_ERR_SUCCESS or error code
  165. '
  166. ' --------------------------------------------------------------
  167. Public Function OTS_IsSearchEnabled(ByRef Table)
  168. Dim rc
  169. OTS_IsSearchEnabled = FALSE
  170. SA_ClearError()
  171. If (OTS_IsValidTable(Table)) Then
  172. Dim aColAttributes
  173. Dim colCount
  174. If ( 0 = OTS_GetColumnAttributes(Table, aColAttributes)) Then
  175. For colCount = 0 to UBound(aColAttributes)-1
  176. If (aColAttributes(colCount) AND OTS_COL_SEARCH) Then
  177. OTS_IsSearchEnabled = TRUE
  178. End If
  179. Next
  180. End If
  181. Else
  182. Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsSearchEnabled")
  183. End If
  184. End Function
  185. ' --------------------------------------------------------------
  186. '
  187. ' Function: OTS_EnableSearch
  188. '
  189. ' Synopsis: Toggle the search capability
  190. '
  191. ' Arguments: [in] Table
  192. ' [in] bEnabled boolean flag, TRUE to enable, FALSE to disable
  193. '
  194. ' Return gc_ERR_SUCCESS or error code
  195. '
  196. ' --------------------------------------------------------------
  197. 'Public Function OTS_EnableSearch(ByRef Table, ByVal bEnable)
  198. ' Dim rc
  199. ' OTS_EnableSearch = gc_ERR_SUCCESS
  200. '
  201. ' SA_ClearError()
  202. ' If (OTS_IsValidTable(Table)) Then
  203. ' Table(OTS_TABLE_SEARCHING) = bEnable
  204. ' Else
  205. ' OTS_EnableSearch = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnableSearch")
  206. ' End If
  207. '
  208. 'End Function
  209. ' --------------------------------------------------------------
  210. '
  211. ' Function: OTS_IsPagingEnabled
  212. '
  213. ' Synopsis: Check and return the state of the paging option
  214. '
  215. ' Arguments: [in] Table
  216. '
  217. ' Return gc_ERR_SUCCESS or error code
  218. '
  219. ' --------------------------------------------------------------
  220. Public Function OTS_IsPagingEnabled(ByRef Table)
  221. Dim rc
  222. OTS_IsPagingEnabled = FALSE
  223. SA_ClearError()
  224. If (OTS_IsValidTable(Table)) Then
  225. OTS_IsPagingEnabled = Table(OTS_TABLE_PAGING)
  226. Else
  227. Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsPagingEnabled")
  228. End If
  229. End Function
  230. ' --------------------------------------------------------------
  231. '
  232. ' Function: OTS_EnablePaging
  233. '
  234. ' Synopsis: Toggle the paging capability
  235. '
  236. ' Arguments: [in] Table
  237. ' [in] bEnabled boolean flag, TRUE to enable, FALSE to disable
  238. '
  239. ' Return gc_ERR_SUCCESS or error code
  240. '
  241. ' --------------------------------------------------------------
  242. Public Function OTS_EnablePaging(ByRef Table, ByVal bEnable)
  243. Dim rc
  244. OTS_EnablePaging = gc_ERR_SUCCESS
  245. SA_ClearError()
  246. If (OTS_IsValidTable(Table)) Then
  247. Table(OTS_TABLE_PAGING) = bEnable
  248. Table(OTS_TABLE_PAGE_MAX) = -1
  249. Table(OTS_TABLE_PAGE_MIN) = 1
  250. Table(OTS_TABLE_PAGE_CURRENT) = 1
  251. Else
  252. OTS_EnablePaging = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnablePaging")
  253. End If
  254. End Function
  255. Public Function OTS_SetPagingRange(ByRef Table, ByVal iMin, ByVal iMax, ByVal iCurrent)
  256. Dim rc
  257. OTS_SetPagingRange = gc_ERR_SUCCESS
  258. SA_ClearError()
  259. If (OTS_IsValidTable(Table)) Then
  260. Table(OTS_TABLE_PAGE_RESET) = TRUE
  261. Table(OTS_TABLE_PAGE_MAX) = iMax
  262. Table(OTS_TABLE_PAGE_MIN) = iMin
  263. Table(OTS_TABLE_PAGE_CURRENT) = iCurrent
  264. Else
  265. OTS_SetPagingRange = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetPagingRange")
  266. End If
  267. End Function
  268. Private Function OTS_IsPagingReset(ByRef Table)
  269. Dim rc
  270. OTS_IsPagingReset = FALSE
  271. SA_ClearError()
  272. If (OTS_IsValidTable(Table)) Then
  273. OTS_IsPagingReset = Table(OTS_TABLE_PAGE_RESET)
  274. Else
  275. Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsPagingReset")
  276. End If
  277. End Function
  278. Public Function OTS_GetPagingRange(ByRef Table, ByRef bEnabled, ByRef iPageMin, ByRef iPageMax, ByRef iPageCurrent)
  279. If ( OTS_IsPagingEnabled(Table) ) Then
  280. bEnabled = TRUE
  281. If ( Len(Trim(Request.QueryString(FLD_PagingPageCurrent))) > 0 ) Then
  282. iPageMin = CInt(SA_GetParam(FLD_PagingPageMin))
  283. iPageMax = CInt(SA_GetParam(FLD_PagingPageMax))
  284. iPageCurrent = CInt(SA_GetParam(FLD_PagingPageCurrent))
  285. Else
  286. If ( OTS_IsPagingReset(Table) ) Then
  287. iPageMax = CInt(Table(OTS_TABLE_PAGE_MAX))
  288. iPageMin = CInt(Table(OTS_TABLE_PAGE_MIN))
  289. iPageCurrent = CInt(Table(OTS_TABLE_PAGE_CURRENT))
  290. Else
  291. iPageMin = CInt(SA_GetParam(FLD_PagingPageMin))
  292. iPageMax = CInt(SA_GetParam(FLD_PagingPageMax))
  293. iPageCurrent = CInt(SA_GetParam(FLD_PagingPageCurrent))
  294. End If
  295. End If
  296. Else
  297. bEnabled = FALSE
  298. iPageMin = 1
  299. iPageMax = 0
  300. iPageCurrent = 1
  301. End If
  302. End Function
  303. ' --------------------------------------------------------------
  304. '
  305. ' Function: OTS_SetTableTasksTitle
  306. '
  307. ' Synopsis: Set the tasks title
  308. '
  309. ' Arguments: [in] Table
  310. ' [in] Title
  311. '
  312. ' Return gc_ERR_SUCCESS or error code
  313. '
  314. ' --------------------------------------------------------------
  315. Public Function OTS_SetTableTasksTitle(ByRef Table, ByVal TasksTitle)
  316. Dim rc
  317. rc = gc_ERR_SUCCESS
  318. SA_ClearError()
  319. If (OTS_IsValidTable(Table)) Then
  320. Table(OTS_TABLE_TASKS_TITLE) = TasksTitle
  321. Else
  322. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableTasksTitle")
  323. End If
  324. OTS_SetTableTasksTitle = rc
  325. End Function
  326. ' --------------------------------------------------------------
  327. '
  328. ' Function: OTS_GetTableTasksTitle
  329. '
  330. ' Synopsis: Get the tasks title
  331. '
  332. ' Arguments: [in] Table
  333. '
  334. ' Return gc_ERR_SUCCESS or error code
  335. '
  336. ' --------------------------------------------------------------
  337. Public Function OTS_GetTableTasksTitle(ByRef Table, ByRef tasksTitle)
  338. Dim rc
  339. rc = gc_ERR_SUCCESS
  340. SA_ClearError()
  341. If (OTS_IsValidTable(Table)) Then
  342. tasksTitle = Table(OTS_TABLE_TASKS_TITLE)
  343. Else
  344. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableTasksTitle")
  345. End If
  346. OTS_GetTableTasksTitle = rc
  347. End Function
  348. ' --------------------------------------------------------------
  349. '
  350. ' Function: OTS_SetTableMultiSelection
  351. '
  352. ' Synopsis: Enable OTS table multi selection capability.
  353. '
  354. ' Arguments: [in] Table
  355. ' [in] bEnableMultiSelect set to TRUE to enable, FALSE to disable
  356. '
  357. ' Return gc_ERR_SUCCESS or error code
  358. '
  359. ' History: Added SAK 2.0
  360. '
  361. ' --------------------------------------------------------------
  362. Public Function OTS_SetTableMultiSelection(ByRef Table, ByVal bEnableMultiSelect)
  363. SA_ClearError()
  364. OTS_SetTableMultiSelection = gc_ERR_SUCCESS
  365. If (OTS_IsValidTable(Table)) Then
  366. Call SA_TraceOut("OTS_TABLE", "Setting multi selection to " + CStr(bEnableMultiSelect))
  367. Table(OTS_TABLE_MULTI_SELECT) = bEnableMultiSelect
  368. Else
  369. OTS_SetTableMultiSelection = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsTableMultiSelection")
  370. End If
  371. End Function
  372. ' --------------------------------------------------------------
  373. '
  374. ' Function: OTS_IsTableMultiSelection
  375. '
  376. ' Synopsis: Check to see if multi selection is enabled.
  377. '
  378. ' Arguments: [in] Table
  379. '
  380. ' Return TRUE if multi selection is enabled, otherwise false
  381. '
  382. ' History: Added SAK 2.0
  383. '
  384. ' --------------------------------------------------------------
  385. Public Function OTS_IsTableMultiSelection(ByRef Table)
  386. SA_ClearError()
  387. OTS_IsTableMultiSelection = FALSE
  388. If (OTS_IsValidTable(Table)) Then
  389. OTS_IsTableMultiSelection = Table(OTS_TABLE_MULTI_SELECT)
  390. Else
  391. Call SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsTableMultiSelection")
  392. End If
  393. End Function
  394. ' --------------------------------------------------------------
  395. '
  396. ' Function: OTS_EnableTableSort
  397. ' DEPRECATED in SAK 2.0 Replaced with OTS_SortTable
  398. '
  399. ' Synopsis: Enable table sorting. If sorting is enabled it is performed
  400. ' inside ServeTable before the table is rendered.
  401. '
  402. '
  403. ' Arguments: [in] Table
  404. ' [in] EnableSort true to sort, false to not sort
  405. '
  406. ' Return gc_ERR_SUCCESS or error code
  407. '
  408. ' --------------------------------------------------------------
  409. Public Function OTS_EnableTableSort(ByRef Table, ByVal EnableSort)
  410. Dim rc
  411. rc = gc_ERR_SUCCESS
  412. SA_ClearError()
  413. If (OTS_IsValidTable(Table)) Then
  414. Table(OTS_TABLE_SORT) = EnableSort
  415. Else
  416. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_EnableTableSort")
  417. End If
  418. OTS_EnableTableSort = rc
  419. End Function
  420. ' ---------------------------------------------------------------------------
  421. '
  422. ' Function: OTS_SetTableSortCriteria
  423. '
  424. ' Synopsis: Set the advanced sorting options for the OTS table. If the table is sorted
  425. ' externally, this API can be used to indicated the current sort column and
  426. ' sort sequence, which is indicated visually in the UI by display of a sort
  427. ' sequence image in the current sort column. It's unnecessary to call this
  428. ' API if the table is sorted using OTS_SortTable.
  429. '
  430. ' Arguments: [in] Table
  431. ' [in] sortCol Index number of current sort column
  432. ' [in] sortSeq Sort sequence, "A" for ascending, "D" for descending
  433. '
  434. ' Return gc_ERR_SUCCESS or error code
  435. '
  436. ' --------------------------------------------------------------
  437. Public Function OTS_SetTableSortCriteria(ByRef Table, ByVal sortCol, ByVal sortSeq)
  438. Dim rc
  439. rc = gc_ERR_SUCCESS
  440. SA_ClearError()
  441. If (OTS_IsValidTable(Table)) Then
  442. Table(OTS_TABLE_SORT_COL) = sortCol
  443. Table(OTS_TABLE_SORT_SEQ) = sortSeq
  444. Table(OTS_TABLE_SORT_SET) = TRUE
  445. Else
  446. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableSortCriteria")
  447. End If
  448. OTS_SetTableSortCriteria = rc
  449. End Function
  450. Private Function OTS_IsColumnSortEnabled(ByRef Table)
  451. Dim rc
  452. rc = gc_ERR_SUCCESS
  453. SA_ClearError()
  454. If (OTS_IsValidTable(Table)) Then
  455. rc = Table(OTS_TABLE_SORT_SET)
  456. Else
  457. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsColumnSortEnabled")
  458. End If
  459. OTS_IsColumnSortEnabled = rc
  460. End Function
  461. Private Function OTS_GetTableSortSequence(ByRef Table, ByRef sortSequence)
  462. Dim rc
  463. rc = gc_ERR_SUCCESS
  464. SA_ClearError()
  465. If (OTS_IsValidTable(Table)) Then
  466. sortSequence = SA_GetParam(FLD_SortingSequence)
  467. If ( Len(Trim(sortSequence)) <= 0 ) Then
  468. sortSequence = Table(OTS_TABLE_SORT_SEQ)
  469. End If
  470. Else
  471. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableSortSequence")
  472. End If
  473. OTS_GetTableSortSequence = rc
  474. End Function
  475. ' --------------------------------------------------------------
  476. '
  477. ' Function: OTS_GetTableSortColumn
  478. '
  479. ' Synopsis: Get the sort column number
  480. '
  481. ' Arguments: [in] Table
  482. ' [out] sortCol zero (0) based index of soft column
  483. '
  484. ' Return gc_ERR_SUCCESS or error code
  485. '
  486. ' --------------------------------------------------------------
  487. Private Function OTS_GetTableSortColumn(ByRef Table, ByRef sortCol)
  488. Dim columns
  489. Dim col
  490. Dim rc
  491. rc = gc_ERR_SUCCESS
  492. SA_ClearError()
  493. If (OTS_IsValidTable(Table)) Then
  494. '
  495. ' If SAK 2.0
  496. If ( SA_GetVersion() >= gc_V2 ) Then
  497. '
  498. ' Use the current sort column parameter if available
  499. sortCol = SA_GetParam(FLD_SortingColumn)
  500. If ( Len(Trim(sortCol)) > 0 ) Then
  501. sortCol = CInt(sortCol)
  502. OTS_GetTableSortColumn = rc
  503. Exit Function
  504. '
  505. ' Else if the sort criteria was set then use it
  506. ElseIf ( TRUE = Table(OTS_TABLE_SORT_SET) ) Then
  507. sortCol = Table(OTS_TABLE_SORT_COL)
  508. OTS_GetTableSortColumn = rc
  509. Exit Function
  510. '
  511. ' Otherwise drop through and use SAK 1.x logic
  512. Else
  513. End If
  514. End If
  515. If (IsArray(Table(OTS_TABLE_COLS))) Then
  516. Dim colCount
  517. Dim count
  518. Dim found
  519. found = false
  520. columns = Table(OTS_TABLE_COLS)
  521. colCount = UBound(columns)
  522. For count = 0 to colCount-1
  523. Dim bIsColSort
  524. rc = OTS_IsColumnSort(columns(count), bIsColSort)
  525. If ( rc <> gc_ERR_SUCCESS) Then
  526. OTS_GetTableSortColumn = rc
  527. Exit Function
  528. End If
  529. If (bIsColSort) Then
  530. sortCol = count
  531. found = true
  532. count = colCount+1
  533. End If
  534. Next
  535. If (NOT found) Then
  536. sortCol = 0
  537. End If
  538. Else
  539. rc = SA_SetLastError(OTS_ERR_NO_COLUMNS, "OTS_GetTableSortColumn")
  540. End If
  541. Else
  542. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableSortColumn")
  543. End If
  544. OTS_GetTableSortColumn = rc
  545. End Function
  546. ' --------------------------------------------------------------
  547. '
  548. ' Function: OTS_IsTableSortEnabled
  549. '
  550. ' Synopsis: Check to see if table sorting is enabled
  551. '
  552. ' Arguments: [in] Table
  553. ' [out] bIsSortEnabledOut set with value of sort enabled flag
  554. '
  555. ' Return gc_ERR_SUCCESS or error code
  556. '
  557. ' --------------------------------------------------------------
  558. Public Function OTS_IsTableSortEnabled(ByRef Table, ByRef bIsSortEnabledOut)
  559. Dim rc
  560. rc = gc_ERR_SUCCESS
  561. SA_ClearError()
  562. If (OTS_IsValidTable(Table)) Then
  563. bIsSortEnabledOut = Table(OTS_TABLE_SORT)
  564. Else
  565. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_IsTableSortEnabled")
  566. End If
  567. OTS_IsTableSortEnabled = rc
  568. End Function
  569. ' --------------------------------------------------------------
  570. '
  571. ' Function: OTS_AddTableTask
  572. '
  573. ' Synopsis: Add a Task to the table
  574. '
  575. ' Arguments: [in] Table
  576. ' [in] Task to be added to the table. Task must have been
  577. ' created with the CreateTask API.
  578. '
  579. ' Return gc_ERR_SUCCESS or error code
  580. '
  581. ' --------------------------------------------------------------
  582. Public Function OTS_AddTableTask(ByRef Table, ByRef Task)
  583. Dim rc
  584. rc = gc_ERR_SUCCESS
  585. SA_ClearError()
  586. If (OTS_IsValidTable(Table)) Then
  587. If (OTS_IsValidTask(Task)) Then
  588. Dim tasks
  589. Dim currentTasks
  590. Dim taskCount
  591. '
  592. ' Get the array
  593. '
  594. currentTasks = Table(OTS_TABLE_TASKS)
  595. If IsArray(currentTasks) Then
  596. '
  597. ' Resize the array
  598. '
  599. tasks = currentTasks
  600. taskCount = UBOUND(tasks)
  601. taskCount = taskCount + 1
  602. ReDim Preserve tasks(taskCount)
  603. Else
  604. '
  605. ' Create the array
  606. '
  607. taskCount = 1
  608. ReDim tasks(taskCount)
  609. End If
  610. '
  611. ' Store the new task
  612. '
  613. tasks(taskCount-1) = Task
  614. '
  615. ' Update the OTS_TABLE_TASKS
  616. '
  617. Table(OTS_TABLE_TASKS) = tasks
  618. Else
  619. rc = SA_SetLastError(OTS_ERR_INVALID_TASK, "OTS_AddTableTask")
  620. End If
  621. Else
  622. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_AddTableTask")
  623. End If
  624. OTS_AddTableTask = rc
  625. End Function
  626. ' --------------------------------------------------------------
  627. '
  628. ' Function: OTS_AddTableColumn
  629. '
  630. ' Synopsis: Add a column to the table
  631. '
  632. ' Arguments: [in] Table
  633. ' [in] Column to be added to the table
  634. '
  635. ' Return gc_ERR_SUCCESS or error code
  636. '
  637. ' --------------------------------------------------------------
  638. Public Function OTS_AddTableColumn(ByRef Table, ByRef Column)
  639. Dim rc
  640. rc = gc_ERR_SUCCESS
  641. SA_ClearError()
  642. If (OTS_IsValidTable(Table)) Then
  643. If (OTS_IsValidColumn(Column)) Then
  644. Dim cols
  645. Dim currentCols
  646. Dim colCount
  647. '
  648. ' Get the current column array
  649. '
  650. currentCols = Table(OTS_TABLE_COLS)
  651. If IsArray(currentCols) Then
  652. '
  653. ' Resize the existing cols array
  654. '
  655. cols = currentCols
  656. colCount = UBOUND(cols)
  657. colCount = colCount + 1
  658. ReDim Preserve cols(colCount)
  659. Else
  660. '
  661. ' Create the cols array
  662. '
  663. colCount = 1
  664. ReDim cols(colCount)
  665. End If
  666. '
  667. ' Store the new column
  668. '
  669. cols(colCount-1) = Column
  670. '
  671. ' Update the OTS_TABLE_COLS
  672. '
  673. Table(OTS_TABLE_COLS) = cols
  674. Else
  675. rc = SA_SetLastError(OTS_ERR_INVALID_COLUMN, "OTS_AddTableColumn")
  676. End If
  677. Else
  678. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_AddTableColumn")
  679. End If
  680. OTS_AddTableColumn = rc
  681. End Function
  682. ' --------------------------------------------------------------
  683. '
  684. ' Function: OTS_AddTableRow
  685. '
  686. ' Synopsis: Add a row to the table
  687. '
  688. ' Arguments: [in] Table
  689. ' [in] RowIn row array to be added to the table,
  690. ' must be an array type.
  691. '
  692. ' Return gc_ERR_SUCCESS or error code
  693. '
  694. ' --------------------------------------------------------------
  695. Public Function OTS_AddTableRow(ByRef Table, ByRef RowIn)
  696. Dim rows
  697. Dim currentRows
  698. Dim rowCount
  699. Dim rc
  700. rc = gc_ERR_SUCCESS
  701. SA_ClearError()
  702. If (OTS_IsValidTable(Table)) Then
  703. If (IsArray(RowIn)) Then
  704. '
  705. ' Get the current rows array
  706. '
  707. currentRows = Table(OTS_TABLE_ROWS)
  708. If IsArray(currentRows) Then
  709. '
  710. ' Resize the existing array
  711. '
  712. rows = currentRows
  713. rowCount = UBOUND(rows)
  714. rowCount = rowCount + 1
  715. ReDim Preserve rows(rowCount)
  716. Else
  717. '
  718. ' Create the array
  719. '
  720. rowCount = 1
  721. ReDim rows(rowCount)
  722. End If
  723. '
  724. ' Store the new row
  725. '
  726. rows(rowCount-1) = RowIn
  727. '
  728. ' Update the OTS_TABLE_COLS
  729. '
  730. Table(OTS_TABLE_ROWS) = rows
  731. Else
  732. rc = SA_SetLastError(OTS_ERR_ROW_NOT_ARRAYTYPE, "OTS_AddTableRow")
  733. End If
  734. Else
  735. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_AddTableRow")
  736. End If
  737. OTS_AddTableRow = rc
  738. End Function
  739. ' --------------------------------------------------------------
  740. '
  741. ' Function: OTS_SetTableRow
  742. '
  743. ' Synopsis: Set a row to the table
  744. '
  745. ' Arguments: [in] Table
  746. ' [in] RowIn row array to be set in the table,
  747. ' must be an array type.
  748. ' [in] RowNumber zero (0) based index of the row to
  749. ' be set.
  750. '
  751. ' Return gc_ERR_SUCCESS or error code
  752. '
  753. ' --------------------------------------------------------------
  754. Public Function OTS_SetTableRow(ByRef Table, ByVal RowNumber, ByRef RowIn)
  755. Dim rc
  756. rc = gc_ERR_SUCCESS
  757. SA_ClearError()
  758. If (OTS_IsValidTable(Table)) Then
  759. '
  760. ' If the rows have not been presized, do it now
  761. '
  762. If (NOT IsArray(Table(OTS_TABLE_ROWS))) Then
  763. rc = OTS_SetTableRowCount(Table, RowNumber+1)
  764. End If
  765. '
  766. ' Grow the rows array if necessary
  767. '
  768. If (UBound(Table(OTS_TABLE_ROWS)) <= RowNumber) Then
  769. rc = OTS_SetTableRowCount(Table, RowNumber+1 )
  770. End If
  771. '
  772. ' Row data must be Array type
  773. '
  774. If (IsArray(RowIn) ) Then
  775. Table(OTS_TABLE_ROWS)(RowNumber) = RowIn
  776. Else
  777. rc = SA_SetLastError(OTS_ERR_ROW_NOT_ARRAYTYPE, "OTS_SetTableRow")
  778. End If
  779. Else
  780. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableRow")
  781. End If
  782. OTS_SetTableRow = rc
  783. End Function
  784. ' --------------------------------------------------------------
  785. '
  786. ' Function: OTS_SetTableRowCount
  787. '
  788. ' Synopsis: Set the number of rows in the table. This function can
  789. ' be used to initialize the size of the rows array or to
  790. ' grow or shrink the size of the rows array. Previous
  791. ' contents of the rows array are preserved.
  792. '
  793. ' Arguments: [in] Table
  794. ' [in] RowCount
  795. '
  796. ' Return gc_ERR_SUCCESS or error code
  797. '
  798. ' --------------------------------------------------------------
  799. Public Function OTS_SetTableRowCount(ByRef Table, ByVal RowCount)
  800. Dim rows
  801. Dim rc
  802. rc = gc_ERR_SUCCESS
  803. SA_ClearError()
  804. If (OTS_IsValidTable(Table)) Then
  805. If (IsArray(Table(OTS_TABLE_ROWS))) Then
  806. '
  807. ' Resize the existing rows array
  808. '
  809. rows = Table(OTS_TABLE_ROWS)
  810. ReDim Preserve rows(rowCount)
  811. Table(OTS_TABLE_ROWS) = rows
  812. Else
  813. '
  814. ' Create the rows array
  815. '
  816. ReDim rows(rowCount)
  817. Table(OTS_TABLE_ROWS) = rows
  818. End If
  819. Else
  820. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableRowCount")
  821. End If
  822. OTS_SetTableRowCount = rc
  823. End Function
  824. ' --------------------------------------------------------------
  825. '
  826. ' Function: OTS_GetTablePKeyName
  827. '
  828. ' Synopsis: Get the name of the PKey query string
  829. '
  830. ' Arguments: [in] Table
  831. ' [out] PKeyName
  832. '
  833. ' Return gc_ERR_SUCCESS or error code
  834. '
  835. ' --------------------------------------------------------------
  836. Private Function OTS_GetTablePKeyName(ByRef Table, ByRef pKeyName)
  837. Dim rc
  838. rc = gc_ERR_SUCCESS
  839. SA_ClearError()
  840. If (OTS_IsValidTable(Table)) Then
  841. pKeyName = Table(OTS_TABLE_PKEY_NAME)
  842. Else
  843. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTablePKeyName")
  844. End If
  845. OTS_GetTablePKeyName = rc
  846. End Function
  847. ' --------------------------------------------------------------
  848. '
  849. ' Function: OTS_SetTablePKeyName
  850. '
  851. ' Synopsis: Set the name of the PKey query string
  852. '
  853. ' Arguments: [in] Table
  854. ' [in] PKeyName
  855. '
  856. ' Return gc_ERR_SUCCESS or error code
  857. '
  858. ' --------------------------------------------------------------
  859. Private Function OTS_SetTablePKeyName(ByRef Table, ByVal pKeyName)
  860. Dim rc
  861. rc = gc_ERR_SUCCESS
  862. SA_ClearError()
  863. If (OTS_IsValidTable(Table)) Then
  864. Table(OTS_TABLE_PKEY_NAME) = pKeyName
  865. Else
  866. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTablePKeyName")
  867. End If
  868. OTS_SetTablePKeyName = rc
  869. End Function
  870. ' --------------------------------------------------------------
  871. '
  872. ' Function: OTS_GetKeyColumnForTable
  873. '
  874. ' Synopsis: Get the key column number
  875. '
  876. ' Arguments: [in] Table
  877. ' [out] keyCol zero (0) based index of key column
  878. '
  879. ' Return gc_ERR_SUCCESS or error code
  880. '
  881. ' --------------------------------------------------------------
  882. Private Function OTS_GetKeyColumnForTable(ByRef Table, ByRef keyCol)
  883. Dim columns
  884. Dim col
  885. Dim rc
  886. rc = gc_ERR_SUCCESS
  887. SA_ClearError()
  888. If (OTS_IsValidTable(Table)) Then
  889. If (IsArray(Table(OTS_TABLE_COLS))) Then
  890. Dim colCount
  891. Dim count
  892. Dim found
  893. found = false
  894. columns = Table(OTS_TABLE_COLS)
  895. colCount = UBound(columns)
  896. For count = 0 to colCount-1
  897. Dim bIsColKey
  898. rc = OTS_IsColumnKey(columns(count), bIsColKey)
  899. If ( rc <> gc_ERR_SUCCESS) Then
  900. OTS_GetKeyColumnForTable = rc
  901. Exit Function
  902. End If
  903. If (bIsColKey) Then
  904. keyCol = count
  905. found = true
  906. count = colCount+1
  907. End If
  908. Next
  909. If (NOT found) Then
  910. keyCol = 0
  911. End If
  912. Else
  913. rc = SA_SetLastError(OTS_ERR_NO_COLUMNS, "OTS_GetKeyColumnForTable")
  914. End If
  915. Else
  916. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetKeyColumnForTable")
  917. End If
  918. OTS_GetKeyColumnForTable = rc
  919. End Function
  920. ' --------------------------------------------------------------
  921. '
  922. ' Function: OTS_SetTableRows
  923. '
  924. ' Synopsis: Set all rows for the table
  925. '
  926. ' Arguments: [in] Table
  927. ' [in] RowsIn Two dimensional array of table rows
  928. '
  929. ' Returns: gc_ERR_SUCCESS if rows returned
  930. ' OTS_ERR_NO_ROWS if no rows exist
  931. ' OTS_ERR_INVALID_TABLE if the table is invalid
  932. '
  933. ' --------------------------------------------------------------
  934. Private Function OTS_SetTableRows(ByRef Table, ByRef RowsIn)
  935. Dim rc
  936. rc = gc_ERR_SUCCESS
  937. SA_ClearError()
  938. If (OTS_IsValidTable(Table)) Then
  939. If ( IsArray( RowsIn ) ) Then
  940. Table(OTS_TABLE_ROWS) = RowsIn
  941. Else
  942. rc = OTS_ERR_NO_ROWS
  943. End If
  944. Else
  945. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableRows")
  946. End If
  947. OTS_SetTableRows = rc
  948. End Function
  949. ' --------------------------------------------------------------
  950. '
  951. ' Function: OTS_GetTableRows
  952. '
  953. ' Synopsis: Get all rows for the table
  954. '
  955. ' Arguments: [in] Table
  956. ' [out] RowsOut Two dimensional array of table rows
  957. '
  958. ' Returns: gc_ERR_SUCCESS if rows returned
  959. ' OTS_ERR_NO_ROWS if no rows exist
  960. ' OTS_ERR_INVALID_TABLE if the table is invalid
  961. '
  962. ' --------------------------------------------------------------
  963. Private Function OTS_GetTableRows(ByRef Table, ByRef RowsOut)
  964. Dim rc
  965. rc = gc_ERR_SUCCESS
  966. SA_ClearError()
  967. If (OTS_IsValidTable(Table)) Then
  968. If ( IsArray( Table(OTS_TABLE_ROWS)) ) Then
  969. RowsOut = Table(OTS_TABLE_ROWS)
  970. Else
  971. rc = OTS_ERR_NO_ROWS
  972. End If
  973. Else
  974. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableRows")
  975. End If
  976. OTS_GetTableRows = rc
  977. End Function
  978. ' --------------------------------------------------------------
  979. '
  980. ' Function: OTS_GetTableRow
  981. '
  982. ' Synopsis: Get a row for the table
  983. '
  984. ' Arguments: [in] Table
  985. ' [out] RowOut array variable for a single row
  986. '
  987. ' Return gc_ERR_SUCCESS or error code
  988. '
  989. ' --------------------------------------------------------------
  990. Private Function OTS_GetTableRow(ByRef Table, ByVal RowNumber, ByRef RowOut)
  991. Dim rows
  992. Dim rc
  993. rc = gc_ERR_SUCCESS
  994. SA_ClearError()
  995. rc = OTS_GetTableRows(Table, rows)
  996. If ( rc = gc_ERR_SUCCESS ) Then
  997. If (RowNumber < UBound(rows) ) Then
  998. If IsArray(rows(RowNumber)) Then
  999. RowOut = rows(RowNumber)
  1000. Else
  1001. rc = SA_SetLastError(OTS_ERR_ROW_NOT_ARRAYTYPE, _
  1002. "OTS_GetTableRow")
  1003. End If
  1004. Else
  1005. rc = SA_SetLastError(OTS_ERR_INVALID_ROW, _
  1006. "OTS_GetTableRow")
  1007. End If
  1008. Else
  1009. '
  1010. ' Error already set by GetTableRows
  1011. '
  1012. End If
  1013. OTS_GetTableRow = rc
  1014. End Function
  1015. ' --------------------------------------------------------------
  1016. '
  1017. ' Function: OTS_GetTableTasks
  1018. '
  1019. ' Synopsis: Get the table tasks
  1020. '
  1021. ' Arguments: [in] Table
  1022. ' [out] TasksOut Two dimensional array of table tasks
  1023. '
  1024. ' Return gc_ERR_SUCCESS or error code
  1025. '
  1026. ' --------------------------------------------------------------
  1027. Private Function OTS_GetTableTasks(ByRef Table, ByRef TasksOut)
  1028. Dim rc
  1029. rc = gc_ERR_SUCCESS
  1030. SA_ClearError()
  1031. If (OTS_IsValidTable(Table) ) Then
  1032. If (IsArray(Table(OTS_TABLE_TASKS))) Then
  1033. TasksOut = Table(OTS_TABLE_TASKS)
  1034. Else
  1035. rc = SA_SetLastError(OTS_ERR_TASK_NOT_ARRAYTYPE, _
  1036. "OTS_GetTableTasks")
  1037. End If
  1038. Else
  1039. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1040. "OTS_GetTableTasks")
  1041. End If
  1042. OTS_GetTableTasks = rc
  1043. End Function
  1044. ' --------------------------------------------------------------
  1045. '
  1046. ' Function: OTS_GetTableColumns
  1047. '
  1048. ' Synopsis: Get the table columns
  1049. '
  1050. ' Arguments: [in] Table
  1051. ' [out] ColumnsOut array of table columns
  1052. '
  1053. ' Return gc_ERR_SUCCESS or error code
  1054. '
  1055. ' --------------------------------------------------------------
  1056. Private Function OTS_GetTableColumns(ByRef Table, ByRef ColumnsOut)
  1057. Dim rc
  1058. rc = gc_ERR_SUCCESS
  1059. SA_ClearError()
  1060. If (OTS_IsValidTable(Table) ) Then
  1061. If (IsArray(Table(OTS_TABLE_COLS))) Then
  1062. ColumnsOut = Table(OTS_TABLE_COLS)
  1063. Else
  1064. rc = SA_SetLastError(OTS_ERR_NO_COLUMNS, _
  1065. "OTS_GetTableColumns")
  1066. End If
  1067. Else
  1068. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1069. "OTS_GetTableColumns")
  1070. End If
  1071. OTS_GetTableColumns = rc
  1072. End Function
  1073. ' --------------------------------------------------------------
  1074. '
  1075. ' Function: OTS_GetColumnAttributes
  1076. '
  1077. ' Synopsis: Get the array of column attributes
  1078. '
  1079. ' Arguments: [in] Table
  1080. ' [out] AttributesOut array of column attributes, one
  1081. ' element for each column.
  1082. '
  1083. ' Return gc_ERR_SUCCESS or error code
  1084. '
  1085. ' --------------------------------------------------------------
  1086. Private Function OTS_GetColumnAttributes(ByRef Table, ByRef AttributesOut)
  1087. Dim rc
  1088. rc = gc_ERR_SUCCESS
  1089. SA_ClearError()
  1090. If (OTS_IsValidTable(Table) ) Then
  1091. Dim columns
  1092. rc = OTS_GetTableColumns(Table, columns)
  1093. If (rc = gc_ERR_SUCCESS) Then
  1094. Dim count
  1095. Dim index
  1096. Dim Attributes()
  1097. count = UBound(columns)
  1098. ReDim Attributes(count)
  1099. For index = 0 to (count-1)
  1100. Dim colAttr
  1101. rc = OTS_GetColumnFlags(columns(index), colAttr)
  1102. if ( rc <> gc_ERR_SUCCESS) Then
  1103. OTS_GetColumnAttributes = rc
  1104. Exit Function
  1105. End If
  1106. Attributes(index) = colAttr
  1107. Next
  1108. AttributesOut = Attributes
  1109. Else
  1110. '
  1111. ' Error set by GetTableColumns
  1112. '
  1113. End If
  1114. Else
  1115. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1116. "OTS_GetColumnAttributes")
  1117. End If
  1118. OTS_GetColumnAttributes = rc
  1119. End Function
  1120. ' --------------------------------------------------------------
  1121. '
  1122. ' Function: OTS_GetTableCaption
  1123. '
  1124. ' Synopsis: Get the table heading
  1125. '
  1126. ' Arguments: [in] Table
  1127. ' [out] CaptionOut the caption
  1128. '
  1129. ' Return gc_ERR_SUCCESS or error code
  1130. '
  1131. ' --------------------------------------------------------------
  1132. Private Function OTS_GetTableCaption(ByRef Table, ByRef CaptionOut)
  1133. Dim rc
  1134. rc = gc_ERR_SUCCESS
  1135. SA_ClearError()
  1136. If (OTS_IsValidTable(Table) ) Then
  1137. CaptionOut = Table(OTS_TABLE_CAPTION)
  1138. Else
  1139. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1140. "OTS_GetTableCaption")
  1141. End If
  1142. OTS_GetTableCaption = rc
  1143. End Function
  1144. ' --------------------------------------------------------------
  1145. '
  1146. ' Function: OTS_GetTableDescription
  1147. '
  1148. ' Synopsis: Get the table description
  1149. '
  1150. ' Arguments: [in] Table
  1151. ' [out] TitleOut the title
  1152. '
  1153. ' Return gc_ERR_SUCCESS or error code
  1154. '
  1155. ' --------------------------------------------------------------
  1156. Private Function OTS_GetTableDescription(ByRef Table, ByRef TitleOut)
  1157. Dim rc
  1158. rc = gc_ERR_SUCCESS
  1159. SA_ClearError()
  1160. If (OTS_IsValidTable(Table) ) Then
  1161. TitleOut = Table(OTS_TABLE_DESC)
  1162. Else
  1163. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1164. "OTS_GetTableDescription")
  1165. End If
  1166. OTS_GetTableDescription = rc
  1167. End Function
  1168. ' --------------------------------------------------------------
  1169. '
  1170. ' Function: OTS_GetTableID
  1171. '
  1172. ' Synopsis: Get the table's HTML ID TAG. If the table ID has
  1173. ' not been set then we initialize it here.
  1174. '
  1175. ' Arguments: [in] Table
  1176. ' [out] TableId id of the table
  1177. '
  1178. ' Return gc_ERR_SUCCESS or error code
  1179. '
  1180. ' --------------------------------------------------------------
  1181. Private Function OTS_GetTableID(ByRef Table, ByRef TableIdOut)
  1182. Dim rc
  1183. rc = gc_ERR_SUCCESS
  1184. SA_ClearError()
  1185. If (OTS_IsValidTable(Table) ) Then
  1186. If (IsEmpty(Table(OTS_TABLE_ID))) Then
  1187. Table(OTS_TABLE_ID) = OTS_TABLE_OBJECT_ID _
  1188. + CStr(OTS_TABLE_NEXT_ID)
  1189. OTS_TABLE_NEXT_ID = OTS_TABLE_NEXT_ID + 1
  1190. End If
  1191. TableIdOut = Table(OTS_TABLE_ID)
  1192. Else
  1193. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableID")
  1194. End If
  1195. OTS_GetTableID = rc
  1196. End Function
  1197. ' --------------------------------------------------------------
  1198. '
  1199. ' Function: OTS_SetTableID
  1200. '
  1201. ' Synopsis: Set the table ID
  1202. '
  1203. ' Arguments: [in] Table
  1204. ' [in] TableID table id
  1205. '
  1206. ' Return gc_ERR_SUCCESS or error code
  1207. '
  1208. ' --------------------------------------------------------------
  1209. Public Function OTS_SetTableID(ByRef Table, ByVal TableID)
  1210. Dim rc
  1211. rc = gc_ERR_SUCCESS
  1212. SA_ClearError()
  1213. If (OTS_IsValidTable(Table) ) Then
  1214. Table(OTS_TABLE_ID) = TableID
  1215. Else
  1216. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_SetTableID")
  1217. End If
  1218. OTS_SetTableID = rc
  1219. End Function
  1220. ' --------------------------------------------------------------
  1221. '
  1222. ' Function: OTS_GetTableSize
  1223. '
  1224. ' Synopsis: Calculate the table size in Rows and Columns
  1225. '
  1226. ' Arguments: [in] Table
  1227. ' [out] RowsOut rows in longest column
  1228. ' [out] ColsOut number of columns
  1229. '
  1230. ' Return gc_ERR_SUCCESS or error code
  1231. '
  1232. ' --------------------------------------------------------------
  1233. Private Function OTS_GetTableSize(ByRef Table, ByRef RowsOut, ByRef ColsOut)
  1234. Dim rowCt
  1235. Dim colCt
  1236. Dim count
  1237. Dim columns
  1238. Dim rows
  1239. Dim rc
  1240. rc = gc_ERR_SUCCESS
  1241. SA_ClearError()
  1242. If (OTS_IsValidTable(Table)) Then
  1243. rc = OTS_GetTableColumns(Table, columns)
  1244. If (rc = gc_ERR_SUCCESS) Then
  1245. colCt = UBound(columns)
  1246. rc = OTS_GetTableRows(Table, rows)
  1247. If (rc = gc_ERR_SUCCESS) Then
  1248. rowCt = UBound(rows)
  1249. RowsOut = rowCt
  1250. ColsOut = colCt
  1251. Else If ( rc = OTS_ERR_NO_ROWS ) Then
  1252. rc = gc_ERR_SUCCESS
  1253. SA_ClearError()
  1254. RowsOut = 0
  1255. ColsOut = colCt
  1256. End If
  1257. End If
  1258. Else
  1259. '
  1260. ' GetTableColumns set last error
  1261. '
  1262. End If
  1263. Else
  1264. rc = SA_SetLastError(OTS_ERR_INVALID_TABLE, "OTS_GetTableSize")
  1265. End If
  1266. OTS_GetTableSize = rc
  1267. End Function
  1268. ' --------------------------------------------------------------
  1269. '
  1270. ' Function: OTS_ServeTable
  1271. '
  1272. ' Synopsis: Render the specified table as HTML
  1273. '
  1274. ' --------------------------------------------------------------
  1275. Public Function OTS_ServeTable(ByRef Table)
  1276. OTS_ServeTable = OTS_ServeTaskViewTable(Table)
  1277. End Function
  1278. Public Function OTS_ServeTaskViewTable(ByRef Table)
  1279. Dim rc
  1280. rc = gc_ERR_SUCCESS
  1281. SA_ClearError()
  1282. '
  1283. ' Validate the table
  1284. '
  1285. If (NOT OTS_IsValidTable(Table)) Then
  1286. '
  1287. ' This is a big function so I am short circuiting the exit point
  1288. ' to make it easier to follow the logic.
  1289. '
  1290. OTS_ServeTaskViewTable = _
  1291. SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1292. "OTS_ServeTaskViewTable")
  1293. Exit Function
  1294. End If
  1295. '
  1296. ' Check sorting option, this SAK 1.X backward compatibility feature.
  1297. ' SAK 2.0 uses should be calling OTS_SortTable(Table, sortCol, sortSequence, bUseCompareCallback)
  1298. '
  1299. If ( SA_GetVersion() < gc_V2 ) Then
  1300. Dim bSortEnabled
  1301. rc = OTS_IsTableSortEnabled(Table, bSortEnabled)
  1302. If ( rc <> gc_ERR_SUCCESS ) Then
  1303. '
  1304. ' IsTableSortEnabled set the last error. I am short circuiting the
  1305. ' exit point to make the logic easier to follow.
  1306. '
  1307. OTS_ServeTaskViewTable = rc
  1308. Exit Function
  1309. End If
  1310. If ( bSortEnabled ) Then
  1311. 'Call SA_TraceOut("OTS_TABLE", "Sorting table")
  1312. Dim sseq
  1313. Call OTS_GetTableSortSequence(Table, sseq)
  1314. Dim keyCol
  1315. Call OTS_GetTableSortColumn(Table, keyCol)
  1316. rc = OTS_SortTable(Table, keyCol, sseq, FALSE)
  1317. End If
  1318. End If
  1319. '
  1320. ' Outer Table for nifty border and Caption
  1321. '
  1322. If OTS_IsAutoInitEnabled(Table) Then
  1323. OTS_EmitAutoInitJavascript(Table)
  1324. End If
  1325. 'Response.Write("<TABLE cols=1 border='0' cellspacing='0' cellpadding='0'")
  1326. 'Response.Write(" width='550px' height='275px' class='ObjTaskHeaderFrame' >"+vbCrLf)
  1327. '
  1328. ' Caption
  1329. '
  1330. Dim tableCaption
  1331. rc = OTS_GetTableCaption(Table, tableCaption)
  1332. If ( rc <> gc_ERR_SUCCESS) Then
  1333. OTS_ServeTaskViewTable = rc
  1334. Exit Function
  1335. End If
  1336. ' Page Title bar was moved into FRAMEWORK in SAK 2.0. Following code is to allow
  1337. ' SAK 1.x code to continue working.
  1338. If ( NOT SA_IsCurrentPageType(PT_AREA)) Then
  1339. Response.Write("<div class='PageHeaderBar'>")
  1340. Response.Write(Server.HTMLEncode(tableCaption))
  1341. Response.Write("</div></br>")
  1342. End If
  1343. '
  1344. ' Description
  1345. '
  1346. Dim tableDescription
  1347. rc = OTS_GetTableDescription(Table, tableDescription)
  1348. If ( rc <> gc_ERR_SUCCESS) Then
  1349. OTS_ServeTaskViewTable = rc
  1350. Exit Function
  1351. End If
  1352. 'Response.Write("<div class='PageDescriptionText'>")
  1353. 'Response.Write(Server.HTMLEncode(tableDescription)+"</div>")
  1354. Response.Write(Server.HTMLEncode(tableDescription))
  1355. 'Put it in a div to center everything
  1356. ' Response.Write("<div class=PageBodyInnerIndent >")
  1357. Response.Write("<BR><BR>")
  1358. '
  1359. ' Inner Table containing Items, spacer column, and Tasks
  1360. '
  1361. Response.Write("<table cols=3 border=0 cellpadding=0 cellspacing=0 width='550px' height='250px'")
  1362. Response.Write(" class='ObjHeaderFrame' id='moduleContents2'>"+vbCrLf)
  1363. Call OTS_RenderTableToolBar(Table)
  1364. '
  1365. ' Inner Table has one row
  1366. Response.Write("<tr height='250px' valign='top'>"+vbCrLf)
  1367. '
  1368. ' First cell contains items
  1369. '
  1370. Response.Write("<td width='550px' valign='top'>"+vbCrLf)
  1371. '
  1372. ' DIV to handle scrolling of items: I thing this DIV is obsolete...
  1373. '
  1374. If ( OTS_IsExplorer() ) Then
  1375. Response.Write("<div style='valign:top;width:550px;height:100%;overflow:auto'>"+vbCrLf)
  1376. End If
  1377. '
  1378. ' Render the items
  1379. '
  1380. rc = OTS_RenderTaskItems(Table)
  1381. If ( rc <> gc_ERR_SUCCESS ) Then
  1382. OTS_ServeTaskViewTable = rc
  1383. End If
  1384. Dim sPKeyParamName
  1385. Call OTS_GetTablePKeyName(table, sPKeyParamName)
  1386. Dim bColumnSortingEnabled
  1387. bColumnSortingEnabled = OTS_IsColumnSortEnabled(Table)
  1388. Dim sortCol
  1389. Call OTS_GetTableSortColumn( Table, sortCol)
  1390. Dim sortSequence
  1391. Call OTS_GetTableSortSequence(Table, sortSequence)
  1392. sortSequence = SA_GetParam(FLD_SortingSequence)
  1393. If ( Len(Trim(sortSequence)) <= 0 ) Then
  1394. sortSequence = "A"
  1395. End If
  1396. Dim iPageMin
  1397. Dim iPageMax
  1398. Dim iPageCurrent
  1399. Dim bPagingEnabled
  1400. Call OTS_GetPagingRange( Table, bPagingEnabled, iPageMin, iPageMax, iPageCurrent)
  1401. Response.Write("<input type=hidden name='tSelectedItem' value='"+Request.Form("tSelectedItem")+"'>"+vbCrLf)
  1402. Response.Write("<input type=hidden name='tSelectedItemNumber' value='"+Request.Form("tSelectedItemNumber")+"' >"+vbCrLf)
  1403. Response.Write("<input type=hidden name='fldPKeyParamName' value='"+sPKeyParamName+"' >"+vbCrLf)
  1404. Response.Write("<input type=hidden name='"+FLD_SearchRequest+"' value='0' >"+vbCrLf)
  1405. Response.Write("<input type=hidden name='"+FLD_PagingRequest+"' value='0' >"+vbCrLf)
  1406. Response.Write("<input type=hidden name='"+FLD_PagingAction+"' value='' >"+vbCrLf)
  1407. Response.Write("<input type=hidden name='"+FLD_PagingPageMin+"' value='"+CStr(iPageMin)+"' >"+vbCrLf)
  1408. Response.Write("<input type=hidden name='"+FLD_PagingPageMax+"' value='"+CStr(iPageMax)+"' >"+vbCrLf)
  1409. Response.Write("<input type=hidden name='"+FLD_PagingPageCurrent+"' value='"+CStr(iPageCurrent)+"' >"+vbCrLf)
  1410. if ( bPagingEnabled ) Then
  1411. Response.Write("<input type=hidden name='"+FLD_PagingEnabled+"' value='T' >"+vbCrLf)
  1412. Else
  1413. Response.Write("<input type=hidden name='"+FLD_PagingEnabled+"' value='F' >"+vbCrLf)
  1414. End If
  1415. If ( bColumnSortingEnabled ) Then
  1416. Response.Write("<input type=hidden name='"+FLD_SortingEnabled+"' value='1' >"+vbCrLf)
  1417. Else
  1418. Response.Write("<input type=hidden name='"+FLD_SortingEnabled+"' value='0' >"+vbCrLf)
  1419. End If
  1420. Response.Write("<input type=hidden name='"+FLD_SortingRequest+"' value='0' >"+vbCrLf)
  1421. Response.Write("<input type=hidden name='"+FLD_SortingColumn+"' value='"+CStr(sortCol)+"' >"+vbCrLf)
  1422. Response.Write("<input type=hidden name='"+FLD_SortingSequence+"' value='"+sortSequence+"' >"+vbCrLf)
  1423. Response.Write("<input type=hidden name='"+FLD_IsToolbarEnabled+"' value='1' >"+vbCrLf)
  1424. If ( OTS_IsExplorer() ) Then
  1425. Response.Write("</div>"+vbCrLf)
  1426. End If
  1427. Response.Write("</td>"+vbCrLf)
  1428. '
  1429. ' Second cell is a divider between items and tasks
  1430. '
  1431. 'Response.Write("<td width=10px>&nbsp;</td>"+vbCrLf)
  1432. '
  1433. ' Third cell contains tasks
  1434. '
  1435. Response.Write("<td class='TasksTextNoPad' valign='top' width='140px'>"+vbCrLf)
  1436. '
  1437. ' Render the tasks
  1438. '
  1439. rc = OTS_RenderTasks(Table)
  1440. If ( rc <> gc_ERR_SUCCESS ) Then
  1441. OTS_ServeTaskViewTable = rc
  1442. End If
  1443. Response.Write("</td>"+vbCrLf)
  1444. Response.Write("</TR>"+vbCrLf)
  1445. Response.Write("</TABLE>"+vbCrLf)
  1446. If ( SA_GetVersion() >= gc_V2 ) Then
  1447. '
  1448. ' Form tag is emitted by Framework
  1449. Else
  1450. Response.Write("</form >"+vbCrLf)
  1451. End If
  1452. 'Response.Write("</div>"+vbCrLf)
  1453. 'Response.Write("</TD>"+vbCrLf)
  1454. 'Response.Write("</TR>"+vbCrLf)
  1455. 'Response.Write("</TABLE>"+vbCrLf)
  1456. Call OTS_OutputTasksScript(Table)
  1457. OTS_ServeTaskViewTable = rc
  1458. End Function
  1459. Private Function OTS_RenderTableToolBar(ByRef Table)
  1460. DIM columns
  1461. Dim maxRows
  1462. Dim maxColumns
  1463. Dim rc
  1464. Dim rowCount
  1465. Dim colCount
  1466. Dim columnObject
  1467. Dim attributesForColumns
  1468. Dim bMultiSelect
  1469. '
  1470. ' Get the table extents (Max rows and columns)
  1471. '
  1472. rc = OTS_GetTableSize(Table, maxRows, maxColumns)
  1473. If (rc <> gc_ERR_SUCCESS ) Then
  1474. '
  1475. ' GetTableSize set the last error
  1476. '
  1477. OTS_RenderTableToolBar = rc
  1478. Exit Function
  1479. End If
  1480. '
  1481. ' Get the table columns
  1482. '
  1483. rc = OTS_GetTableColumns(Table, columns)
  1484. If (rc <> gc_ERR_SUCCESS) Then
  1485. OTS_RenderTableToolBar = rc
  1486. Exit Function
  1487. End If
  1488. '
  1489. ' Get attributes for all the columns
  1490. '
  1491. rc = OTS_GetColumnAttributes(Table, attributesForColumns)
  1492. If (rc <> gc_ERR_SUCCESS) Then
  1493. OTS_RenderTableToolBar = rc
  1494. Exit Function
  1495. End If
  1496. If OTS_IsTableMultiSelection(table) Then
  1497. bMultiSelect=1
  1498. Else
  1499. bMultiSelect=0
  1500. End If
  1501. '
  1502. ' OPTIMIZATION:
  1503. ' From here on we want the upper limit for the column count
  1504. '
  1505. maxColumns = maxColumns - 1
  1506. Dim bEnableSearch
  1507. Dim bEnablePaging
  1508. Dim iPageMin
  1509. Dim iPageMax
  1510. Dim iPageCurrent
  1511. bEnableSearch = OTS_IsSearchEnabled(Table)
  1512. Call OTS_GetPagingRange(Table, bEnablePaging, iPageMin, iPageMax, iPageCurrent)
  1513. If ( bEnableSearch OR bEnablePaging ) Then
  1514. Response.Write("<tr nowrap height=25px>"+vbCrLf)
  1515. Response.Write("<TD colspan=3>")
  1516. Response.Write("<TABLE class=OTSToolBarHeader>")
  1517. Response.Write("<TR nowrap>")
  1518. If ( bEnableSearch ) Then
  1519. Dim L_SEARCH_TEXT
  1520. Dim L_SEARCH_BUTTON
  1521. Dim iCurrentSelectedCol
  1522. L_SEARCH_TEXT = GetLocString("sacoremsg.dll", "40200BBA", "")
  1523. L_SEARCH_BUTTON = GetLocString("sacoremsg.dll", "40200BBB", "")
  1524. iCurrentSelectedCol = Int(SA_GetParam(FLD_SearchItem))
  1525. Response.Write("<TD nowrap style='padding-left:10px;'>"+L_SEARCH_TEXT+"</TD>")
  1526. Response.Write("<TD>")
  1527. Response.Write("<select size='1' name='"+FLD_SearchItem+"'>")
  1528. Dim iSearchColCt
  1529. iSearchColCt = 0
  1530. For colCount = 0 to (maxColumns)
  1531. If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1532. '
  1533. ' Column is hidden
  1534. '
  1535. ElseIf (attributesForColumns(colCount) AND OTS_COL_FLAG_SEARCH) Then
  1536. Dim sSearchColumn
  1537. Dim sSelected
  1538. iSearchColCt = iSearchColCt + 1
  1539. If ( colCount = iCurrentSelectedCol ) Then
  1540. sSelected = " selected "
  1541. Else
  1542. sSelected = ""
  1543. End If
  1544. columnObject = columns(colCount)
  1545. Call OTS_GetColumnHeading(columnObject, sSearchColumn)
  1546. Response.Write("<option value='"+CStr(colCount)+"' "+sSelected+" >"+Server.HTMLEncode(sSearchColumn)+"</option>")
  1547. End If
  1548. Next
  1549. If (iSearchColCt <= 0 ) Then
  1550. Response.Write("<option value='"+CStr(0)+"' >"+Server.HTMLEncode(GetLocString("sacoremsg.dll", "40200BBD", ""))+"</option>")
  1551. End If
  1552. Response.Write("</select>")
  1553. Response.Write("</TD>")
  1554. Response.Write("<TD>")
  1555. Response.Write("<input type=text name='"+FLD_SearchValue+"' value="""+Server.HTMLEncode(SA_GetParam(FLD_SearchValue))+""" onChange='OTS_SetSearchChanged();'>")
  1556. Response.Write("</input>")
  1557. Response.Write("</TD>")
  1558. Response.Write("<TD nowrap class=OTSToolBarHeaderRightBorder>")
  1559. Call SA_ServeOnClickButton(L_SEARCH_BUTTON, "images/butSearchEnabled.gif", "javascript:OTS_SubmitSearch();", 40, 28, "")
  1560. Response.Write("</TD>")
  1561. End If
  1562. If ( bEnablePaging ) Then
  1563. Dim sAttributes
  1564. Dim sImage
  1565. Dim sPageID
  1566. Dim L_NEXT_BUTTON
  1567. Dim L_PREVIOUS_BUTTON
  1568. Dim L_PAGE_X_OF_Y
  1569. Dim aParam(2)
  1570. Dim repString
  1571. aParam(0) = CStr(iPageCurrent)
  1572. aParam(1) = CStr(iPageMax - iPageMin + 1)
  1573. repString = aParam
  1574. L_PAGE_X_OF_Y = GetLocString("sacoremsg.dll", "40200BBE", repString)
  1575. If ( bEnableSearch ) Then
  1576. Response.Write("<TD>")
  1577. Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;")
  1578. Response.Write("</TD>")
  1579. End If
  1580. L_NEXT_BUTTON = ""
  1581. L_PREVIOUS_BUTTON = ""
  1582. If ( iPageCurrent > iPageMin ) Then
  1583. sAttributes = " title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1584. sImage = "images/butPagePreviousEnabled.gif"
  1585. Else
  1586. sAttributes = "DISABLED title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1587. sImage = "images/butPagePreviousDisabled.gif"
  1588. End If
  1589. Response.Write("<TD>")
  1590. Call SA_ServeOnClickButton(L_PREVIOUS_BUTTON, sImage, "javascript:OTS_SubmitPageChange('prev');", 0, 0, sAttributes)
  1591. Response.Write("</TD>")
  1592. If ( iPageCurrent < iPageMax ) Then
  1593. sAttributes = " title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1594. sImage = "images/butPageNextEnabled.gif"
  1595. Else
  1596. sAttributes = "DISABLED title="""+Server.HTMLEncode(L_PAGE_X_OF_Y)+ """"
  1597. sImage = "images/butPageNextDisabled.gif"
  1598. End If
  1599. Response.Write("<TD class=OTSToolBarHeaderRightBorder>")
  1600. Call SA_ServeOnClickButton(L_NEXT_BUTTON, sImage, "javascript:OTS_SubmitPageChange('next');", 0, 0, sAttributes)
  1601. Response.Write("</TD>")
  1602. End If
  1603. Response.Write("<TD width='100%'>")
  1604. Response.Write("</TD>")
  1605. Response.Write("</TR>"+vbCrLf)
  1606. Response.Write("</TABLE>")
  1607. Response.Write("</TD>")
  1608. Response.Write("</TR>"+vbCrLf)
  1609. End If
  1610. OTS_RenderTableToolBar = rc
  1611. End Function
  1612. Private Function OTS_RenderTaskItems(ByRef Table)
  1613. DIM columns
  1614. Dim maxRows
  1615. Dim maxColumns
  1616. Dim rc
  1617. Dim rowCount
  1618. Dim colCount
  1619. Dim columnObject
  1620. Dim colAlign
  1621. Dim attributesForColumns
  1622. Dim keyColumn
  1623. Dim sInputType
  1624. Dim bMultiSelect
  1625. Dim L_CELLTRUNCATION_TEXT
  1626. Dim sortCol
  1627. L_CELLTRUNCATION_TEXT = GetLocString("sacoremsg.dll", "40200BBC", "")
  1628. '
  1629. ' Validate the table
  1630. '
  1631. If (NOT OTS_IsValidTable(Table)) Then
  1632. OTS_RenderTaskItems = SA_SetLastError(OTS_ERR_INVALID_TABLE, _
  1633. "OTS_RenderTaskItems")
  1634. Exit Function
  1635. End If
  1636. '
  1637. ' Get the table extents (Max rows and columns)
  1638. '
  1639. rc = OTS_GetTableSize(Table, maxRows, maxColumns)
  1640. If (rc <> gc_ERR_SUCCESS ) Then
  1641. '
  1642. ' GetTableSize set the last error
  1643. '
  1644. OTS_RenderTaskItems = rc
  1645. Exit Function
  1646. End If
  1647. '
  1648. ' Get the table columns
  1649. '
  1650. rc = OTS_GetTableColumns(Table, columns)
  1651. If (rc <> gc_ERR_SUCCESS) Then
  1652. OTS_RenderTaskItems = rc
  1653. Exit Function
  1654. End If
  1655. '
  1656. ' Get Key column for table
  1657. '
  1658. rc = OTS_GetKeyColumnForTable(Table, keyColumn)
  1659. If (rc <> gc_ERR_SUCCESS) Then
  1660. OTS_RenderTaskItems = rc
  1661. Exit Function
  1662. End If
  1663. '
  1664. ' Get attributes for all the columns
  1665. '
  1666. rc = OTS_GetColumnAttributes(Table, attributesForColumns)
  1667. If (rc <> gc_ERR_SUCCESS) Then
  1668. OTS_RenderTaskItems = rc
  1669. Exit Function
  1670. End If
  1671. If OTS_IsTableMultiSelection(table) Then
  1672. sInputType = "checkbox"
  1673. bMultiSelect=1
  1674. Else
  1675. sInputType = "radio"
  1676. bMultiSelect=0
  1677. End If
  1678. Response.Write("<table cols="+CStr(maxColumns)+" border=0 cellpadding=0 cellspacing=0 width='100%'>"+vbCrLf)
  1679. '
  1680. ' OPTIMIZATION:
  1681. ' From here on we want the upper limit for the column count
  1682. '
  1683. maxColumns = maxColumns - 1
  1684. '
  1685. ' Write column headings
  1686. '
  1687. Response.Write("<TR nowrap height=25px>"+vbCrLf)
  1688. Dim bIsFirstVisibleCol
  1689. bIsFirstVisibleCol = true
  1690. Dim sSortSequence
  1691. Dim sSortImage
  1692. Dim sSortImageURL
  1693. Call OTS_GetTableSortSequence(Table, sSortSequence)
  1694. If (Trim(UCase(sSortSequence)) = "A") Then
  1695. sSortSequence = "A"
  1696. sSortImageURL = "images/butSortAscending.gif"
  1697. Else
  1698. sSortSequence = "D"
  1699. sSortImageURL = "images/butSortDescending.gif"
  1700. End If
  1701. Call OTS_GetTableSortColumn(Table, sortCol)
  1702. For colCount = 0 to (maxColumns)
  1703. Dim sOnClickColHeading
  1704. If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1705. '
  1706. ' Column is hidden
  1707. '
  1708. Else
  1709. Dim colHeading
  1710. Dim bIsSortable
  1711. columnObject = columns(colCount)
  1712. If ( attributesForColumns(colCount) AND OTS_COL_SORT ) Then
  1713. bIsSortable = TRUE
  1714. Else
  1715. bIsSortable = FALSE
  1716. End If
  1717. rc = OTS_GetColumnHeading(columnObject, colHeading)
  1718. If (rc <> gc_ERR_SUCCESS) Then
  1719. OTS_RenderTaskItems = rc
  1720. Exit Function
  1721. End If
  1722. rc = OTS_GetColumnAlign(columnObject, colAlign)
  1723. If (rc <> gc_ERR_SUCCESS) Then
  1724. OTS_RenderTaskItems = rc
  1725. Exit Function
  1726. End If
  1727. sSortImage = ""
  1728. sOnClickColHeading = " "
  1729. If ( SA_GetVersion() >= gc_V2 ) Then
  1730. If ( TRUE = bIsSortable ) Then
  1731. sOnClickColHeading = " onClick=""OTS_SubmitSort('"+CStr(colCount)+"', '"+sSortSequence+"');"" "
  1732. If ( colCount = sortCol ) Then
  1733. sSortImage = "<img src='"+m_VirtualRoot+sSortImageURL+"' >"
  1734. End If
  1735. End If
  1736. End If
  1737. If (bIsFirstVisibleCol) Then
  1738. bIsFirstVisibleCol = false
  1739. If ( bMultiSelect ) Then
  1740. Response.Write("<TD class='ObjHeaderTitleNoVLine' align=center nowrap >")
  1741. Response.Write("<input type=checkbox name=fldMacroMultiSelect onClick=OTS_OnMacroMultiSelect()>")
  1742. Response.Write("</TD>")
  1743. Else
  1744. Response.Write("<TD class='ObjHeaderTitleNoVLine'>&nbsp;</TD>")
  1745. End If
  1746. Response.Write("<TD "+sOnClickColHeading+" class='ObjHeaderTitle' align="+colAlign+" nowrap>"+_
  1747. Server.HTMLEncode(colHeading)+"&nbsp;"+sSortImage+"&nbsp;</TD>")
  1748. Else
  1749. Response.Write("<TD "+sOnClickColHeading+" class='ObjHeaderTitle' align="+colAlign+" nowrap>"+_
  1750. Server.HTMLEncode(colHeading)+"&nbsp;"+sSortImage+"&nbsp;</TD>")
  1751. End If
  1752. End If
  1753. Next
  1754. Response.Write("</TR>"+vbCrLf)
  1755. '
  1756. ' Write table data
  1757. '
  1758. Dim keyId
  1759. Dim selectId
  1760. Dim tableId
  1761. rc = OTS_GetTableID(Table, tableId)
  1762. If (rc <> gc_ERR_SUCCESS) Then
  1763. OTS_RenderTaskItems = rc
  1764. Exit Function
  1765. End If
  1766. selectId = Quote("TVItem_"+tableId)
  1767. Dim selectRowClass
  1768. If (OTS_IsExplorer()) Then
  1769. selectRowClass = "SelectedRow"
  1770. Else
  1771. selectRowClass = "AlternatingDark"
  1772. End If
  1773. Dim thisRowClass
  1774. Dim maxDispRows
  1775. Dim minDispRows
  1776. minDispRows = 9 'We will always output at least 1+ this many rows
  1777. maxDispRows = Max(minDispRows, (maxRows - 1))
  1778. If ( maxRows > 0 ) Then
  1779. For rowCount = 0 to (maxDispRows)
  1780. Dim rowData
  1781. Dim sOnRowClicked
  1782. '
  1783. ' OnClick handler only applies to data rows
  1784. '
  1785. If ( rowCount < maxRows ) Then
  1786. sOnRowClicked = "onClick=""return OTS_RowClicked('"+CStr(rowCount)+"')"" "
  1787. Else
  1788. sOnRowClicked = ""
  1789. End If
  1790. If ( rowCount Mod 2 ) Then
  1791. ' onselectstart='return false;'
  1792. ' onmousemove=""OTS_OnMouseMove('"+CStr(rowCount)+"', '"+CStr(bMultiSelect)+"');""
  1793. ' onmousedown=""return OTS_OnMouseDown('"+CStr(rowCount)+"', '"+CStr(bMultiSelect)+"');""
  1794. ' onmouseup=""return OTS_OnMouseUp('"+CStr(rowCount)+"', '"+CStr(bMultiSelect)+"');""
  1795. Response.Write("<TR onselectstart='return false;' "+sOnRowClicked+" id = row"+CStr(rowCount)_
  1796. +" height=22px class='AlternatingLight'>"+vbCrLf)
  1797. thisRowClass = "AlternatingLight"
  1798. Else
  1799. If (rowCount = 0) Then
  1800. Response.Write("<TR onselectstart='return false;' "+sOnRowClicked+" id = row"+CStr(rowCount)_
  1801. +" height=22px class='AlternatingDark' >"+vbCrLf)
  1802. Else
  1803. Response.Write("<TR onselectstart='return false;' "+sOnRowClicked+" id = row"+CStr(rowCount)_
  1804. +" height=22px class='AlternatingDark' >"+vbCrLf)
  1805. End If
  1806. thisRowClass = "AlternatingDark"
  1807. End If
  1808. If ( rowCount < maxRows ) Then
  1809. rc = OTS_GetTableRow(Table, rowCount, rowData)
  1810. If (rc <> gc_ERR_SUCCESS) Then
  1811. OTS_RenderTaskItems = rc
  1812. Exit Function
  1813. End If
  1814. '
  1815. ' Verify row has correct number of columns
  1816. '
  1817. If (maxColumns < UBound(rowData)) Then
  1818. SA_TraceOut "ServeTaskViewTable", ("maxColumns:"+_
  1819. CStr(maxColumns)+_
  1820. " < UBound(rowData):"+_
  1821. CStr(UBound(rowData)))
  1822. Exit Function
  1823. End If
  1824. '
  1825. ' Extract the key column
  1826. '
  1827. keyId = CStr(rowData(keyColumn))
  1828. '
  1829. ' Write the first column
  1830. '
  1831. Dim onClickHandler
  1832. keyId = FormatJScriptString(keyId)
  1833. onClickHandler = " onClick=""return OTS_OnItemClicked('"+keyId+"','"+CStr(rowCount)+"');"" "
  1834. 'If (OTS_IsExplorer()) Then
  1835. ' onClickHandler = " onClick='OTS_OnItemClicked("""+keyId+""","""+CStr(rowCount)+""");' "
  1836. 'Else
  1837. ' onClickHandler = " onClick='OTS_OnItemClicked("""+keyId+""","""+CStr(rowCount)+""");'"
  1838. 'End If
  1839. 'No vertical line on the first cell, it contains the input(radio/checkbox) control
  1840. Response.Write("<TD align=center class="+thisRowClass+"NoVline>"+vbCrLf)
  1841. 'Response.Write("<font face='Tahoma'>")
  1842. If ( rowCount = 0 ) Then
  1843. If ( bMultiSelect = 1 ) Then
  1844. Response.Write("<INPUT id=radio"+CStr(rowCount)+_
  1845. onClickHandler+_
  1846. " type="+sInputType+" value="""+keyId+""" name="+selectId+">")
  1847. Else
  1848. Response.Write("<INPUT id=radio"+CStr(rowCount)+_
  1849. onClickHandler+_
  1850. " type="+sInputType+" checked value="""+keyId+""" name="+selectId+">")
  1851. End If
  1852. Response.Write("</font>")
  1853. 'Need to make sure that we have an array so we will send a hidden radio button
  1854. If ( maxRows = 1 ) Then
  1855. Response.Write("<INPUT id=radio"+CStr(rowCount+1)+_
  1856. " type="+sInputType+" value="""+keyId+"2_RowHidden" + """ name="+selectId+" style='display:none'>")
  1857. Response.Write("</font>")
  1858. End If
  1859. Else
  1860. Response.Write("<INPUT id=radio"+CStr(rowCount)+_
  1861. onClickHandler+_
  1862. " type="+sInputType+" value="""+keyId+""" name="+selectId+">")
  1863. Response.Write("</font>")
  1864. End If
  1865. Else 'output a blank cell
  1866. Response.Write("<TD class="+thisRowClass+"NoVline>&nbsp;"+vbCrLf)
  1867. End If
  1868. Response.Write(vbCrLf+"</TD>"+vbCrLf)
  1869. For colCount = 0 to maxColumns
  1870. Dim cellData
  1871. If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1872. '
  1873. ' Column is hidden
  1874. '
  1875. Else
  1876. If ( rowCount < maxRows ) Then
  1877. Dim sCellTitle
  1878. Dim iCellWidth
  1879. '
  1880. ' Column is visible
  1881. '
  1882. cellData = rowData(colCount)
  1883. colAlign = (columns(colCount))(OTS_COL_ALIGN)
  1884. sCellTitle = ""
  1885. If ( OTS_IsColumnWidthDynamic(columns(colCount)) ) Then
  1886. Call OTS_GetColumnWidth( columns(colCount), iCellWidth)
  1887. If ( LEN(cellData) > iCellWidth ) Then
  1888. sCellTitle = " title=""" + Server.HTMLEncode(cellData) + """ "
  1889. cellData = Left(cellData, iCellWidth) + L_CELLTRUNCATION_TEXT
  1890. End If
  1891. End If
  1892. Response.Write("<TD " + sCellTitle + " onselectstart='return false;' align="+colAlign+" class="+thisRowClass+">"+vbCrLf)
  1893. '
  1894. ' Write the cell data
  1895. '
  1896. If cellData="" then
  1897. Response.Write("&nbsp;")
  1898. Else
  1899. Response.Write(Server.HTMLEncode((cellData)))
  1900. End If
  1901. Response.Write("</TD>"+vbCrLf)
  1902. Else 'output a blank cell
  1903. Response.Write("<TD class="+thisRowClass+">&nbsp;</td>"+vbCrLf)
  1904. End If
  1905. End If
  1906. Next ' Columns
  1907. Response.Write("</TR>"+vbCrLf)
  1908. Next ' Rows
  1909. Else
  1910. For rowCount = 0 to minDispRows
  1911. If ( rowCount Mod 2 ) Then
  1912. Response.Write("<TR height=22px class='AlternatingLightNoVline'>"+vbCrLf)
  1913. Response.Write("<TD class='AlternatingLightNoVline'>&nbsp;</td>"+vbCrLf)
  1914. For colCount = 0 to (maxColumns)
  1915. If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1916. Else
  1917. Response.Write("<TD class='AlternatingLight'>&nbsp;</td>"+vbCrLf)
  1918. End If
  1919. Next
  1920. Else
  1921. Response.Write("<TR height=22px class='AlternatingDark' >"+vbCrLf)
  1922. Response.Write("<TD class='AlternatingDarkNoVline'>&nbsp;</td>"+vbCrLf)
  1923. For colCount = 0 to (maxColumns)
  1924. If (attributesForColumns(colCount) AND OTS_COL_FLAG_HIDDEN) Then
  1925. Else
  1926. Response.Write("<TD class='AlternatingDark'>&nbsp;</td>"+vbCrLf)
  1927. End If
  1928. Next
  1929. End If
  1930. Response.Write("</TR>"+vbCrLf)
  1931. Next
  1932. End If
  1933. Response.Write("</TABLE>"+vbCrLf)
  1934. OTS_RenderTaskItems = rc
  1935. End Function
  1936. Private Function OTS_RenderTasks(ByRef Table)
  1937. Dim rc
  1938. DIM tasks
  1939. DIM rowCount
  1940. DIM maxRows
  1941. DIM tasksTitle
  1942. DIM pKeyName
  1943. Dim bMultiSelect
  1944. rc = gc_ERR_SUCCESS
  1945. '
  1946. ' Validate the table
  1947. '
  1948. If (NOT OTS_IsValidTable(Table)) Then
  1949. OTS_RenderTasks = SA_SetLastError(OTS_ERR_INVALID_TABLE,_
  1950. "OTS_RenderTasks")
  1951. Exit Function
  1952. End If
  1953. '
  1954. ' Get tasks data
  1955. '
  1956. rc = OTS_GetTableTasks(Table, tasks)
  1957. If (rc <> gc_ERR_SUCCESS) Then
  1958. OTS_RenderTasks = rc
  1959. Exit Function
  1960. End If
  1961. '
  1962. ' Get tasks title
  1963. '
  1964. rc = OTS_GetTableTasksTitle(Table, tasksTitle)
  1965. If (rc <> gc_ERR_SUCCESS) Then
  1966. OTS_RenderTasks = rc
  1967. Exit Function
  1968. End If
  1969. Dim selectId
  1970. Dim tableId
  1971. rc = OTS_GetTableID(Table, tableId)
  1972. If (rc <> gc_ERR_SUCCESS) Then
  1973. OTS_RenderTasks = rc
  1974. Exit Function
  1975. End If
  1976. rc = OTS_GetTablePKeyName( Table, pKeyName)
  1977. If (rc <> gc_ERR_SUCCESS) Then
  1978. OTS_RenderTasks = rc
  1979. Exit Function
  1980. End If
  1981. If OTS_IsTableMultiSelection(table) Then
  1982. bMultiSelect = 1
  1983. Else
  1984. bMultiSelect = 0
  1985. End If
  1986. selectId = "TVItem_"+tableId
  1987. Response.Write("<table cols=1 width='140px' border=0 cellpadding=0 cellspacing=0 class='TasksTable'")
  1988. Response.Write(">"+vbCrLf)
  1989. '
  1990. ' Task Table Header
  1991. Response.Write("<TR height='25px'>")
  1992. Response.Write("<TD class='TasksHeaderTitle'>")
  1993. Response.Write(Server.HTMLEncode(tasksTitle))
  1994. Response.Write("</TD>")
  1995. Response.Write("</TR>"+vbCrLf)
  1996. '
  1997. ' Write task table
  1998. '
  1999. maxRows = UBound(tasks)
  2000. For rowCount = 0 to (maxRows-1)
  2001. Dim taskName
  2002. Dim taskDesc
  2003. Dim taskLink
  2004. Dim task
  2005. Dim taskHoverText
  2006. Dim taskPageType
  2007. Response.Write("<TR height='20px'>")
  2008. task = tasks(rowCount)
  2009. If (NOT IsArray(task)) Then
  2010. OTS_RenderTasks = SA_SetLastError(OTS_ERR_TASK_NOT_ARRAYTYPE,_
  2011. "OTS_RenderTasks")
  2012. Exit Function
  2013. End If
  2014. taskName = task(OTS_TASK_TASK)
  2015. 'taskDesc = FormatJScriptString(task(OTS_TASK_DESC))
  2016. taskDesc = Server.HTMLEncode(SA_EscapeQuotes(task(OTS_TASK_DESC)))
  2017. taskHoverText = " title=""" + Server.HTMLEncode(task(OTS_TASK_DESC)) + """"
  2018. taskLink = task(OTS_TASK_LINK)
  2019. taskLink = FormatJScriptString(taskLink)
  2020. taskPageType = task(OTS_TASK_PAGE_TYPE)
  2021. 'Response.Write("<TD class='TasksTableCell'>")
  2022. Response.Write("<TD class='TasksTableCell' "+_
  2023. taskHoverText +_
  2024. " onMouseOver=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(1)+"); OTS_OnShowTaskDescription("+Quote(taskDesc)+"); return true;"" "+_
  2025. " onMouseOut=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(0)+"); OTS_OnShowTaskDescription(''); return true;"" "+_
  2026. " onclick=""OTS_OnSelectTask("+CStr(rowCount)+", "+Quote(pKeyName)+", "+Quote(selectId)+", "+Quote(taskLink)+", "+Quote(taskDesc)+", "+Quote(CStr(taskPageType))+", "+Quote(CStr(bMultiSelect))+");"" >")
  2027. '
  2028. ' Output a task row
  2029. '
  2030. '
  2031. ' IExplorer properly supports onclick event in SPAN's (HTML 4.0)
  2032. '
  2033. 'If (OTS_IsExplorer() ) Then
  2034. Response.Write("<DIV class=TasksTextDisabled ID='OTSTask"+CStr(rowCount)+"'"+_
  2035. " onMouseOver=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(1)+"); OTS_OnShowTaskDescription("+Quote(taskDesc)+"); return true;"" "+_
  2036. " onMouseOut=""OTS_OnTaskHover("+CStr(rowCount)+", "+CStr(0)+"); OTS_OnShowTaskDescription(''); return true;"" "+_
  2037. " xxonclick=""OTS_OnSelectTask("+CStr(rowCount)+", "+Quote(pKeyName)+", "+Quote(selectId)+", "+Quote(taskLink)+", "+Quote(taskDesc)+", "+Quote(CStr(taskPageType))+", "+Quote(CStr(bMultiSelect))+");"" >")
  2038. 'Response.Write("<TD class='TasksTableCell'>")
  2039. 'Response.Write("&nbsp;&nbsp;")
  2040. Response.Write(Server.HTMLEncode(taskName))
  2041. 'Response.Write("</TD>")
  2042. Response.Write("</DIV>")
  2043. '
  2044. ' Navigator is not compliant with HTML 4.0, work around uses hyperlink
  2045. '
  2046. 'Else
  2047. ' Response.Write("<A class='TasksText' href='#' "+_
  2048. ' " onMouseOver=""OTS_OnShowTaskDescription("+Quote(taskDesc)+"); return true;"" "+_
  2049. ' " onMouseOut=""OTS_OnShowTaskDescription(''); return true;"" "+_
  2050. ' " onclick=""OTS_OnSelectTask("+CStr(rowCount)+", "+Quote(pKeyName)+", "++Quote(selectId)+", "+Quote(taskLink)+", "+Quote(taskDesc)+", "+Quote(CStr(taskPageType))+", "+Quote(CStr(bMultiSelect))+");"" >")
  2051. ' Response.Write(Server.HTMLEncode(taskName))
  2052. ' Response.Write("</a>")
  2053. 'End If
  2054. Response.Write("</TD>")
  2055. Response.Write("</TR>"+vbCrLf)
  2056. Next
  2057. Response.Write("<TR height='100%'><TD>&nbsp;</TD></TR></TABLE>"+vbCrLf)
  2058. OTS_RenderTasks = rc
  2059. End Function
  2060. Private Function OTS_OutputTasksScript(ByRef Table)
  2061. Dim rc
  2062. DIM tasks
  2063. DIM task
  2064. DIM rowCount
  2065. DIM maxRows
  2066. DIM taskFunction
  2067. rc = gc_ERR_SUCCESS
  2068. '
  2069. ' Validate the table
  2070. '
  2071. If (NOT OTS_IsValidTable(Table)) Then
  2072. OTS_OutputTasksScript = SA_SetLastError(OTS_ERR_INVALID_TABLE,_
  2073. "OTS_OutputTasksScript")
  2074. Exit Function
  2075. End If
  2076. '
  2077. ' Get tasks data
  2078. '
  2079. rc = OTS_GetTableTasks(Table, tasks)
  2080. If (rc <> gc_ERR_SUCCESS) Then
  2081. Response.Write("<script language='JavaScript'>"+vbCrLf)
  2082. Response.Write("//"+vbCrLf)
  2083. Response.Write("// Task Objects"+vbCrLf)
  2084. Response.Write("//"+vbCrLf)
  2085. Response.Write("var aTasks = new Array();"+vbCrLf)
  2086. Response.Write("</script>"+vbCrLf)
  2087. OTS_OutputTasksScript = rc
  2088. Exit Function
  2089. End If
  2090. '
  2091. ' Write task table
  2092. '
  2093. maxRows = UBound(tasks)
  2094. Response.Write("<script language='JavaScript'>"+vbCrLf)
  2095. Response.Write("//"+vbCrLf)
  2096. Response.Write("// Task Objects"+vbCrLf)
  2097. Response.Write("//"+vbCrLf)
  2098. Response.Write("var aTasks = new Array();"+vbCrLf)
  2099. For rowCount = 0 to (maxRows-1)
  2100. task = tasks(rowCount)
  2101. taskFunction = task(OTS_TASK_FUNCTION)
  2102. Response.Write("aTasks["+CStr(rowCount)+"] = new OTS_TaskObject('"+taskFunction+"');"+vbCrLf)
  2103. Next
  2104. Response.Write("</script>"+vbCrLf)
  2105. OTS_OutputTasksScript = rc
  2106. End Function
  2107. Public Function Quote(s)
  2108. Quote = "'"+s+"'"
  2109. End Function
  2110. ' --------------------------------------------------------------
  2111. '
  2112. ' Function: Max
  2113. '
  2114. ' Synopsis: Calculate the maximum between two values
  2115. '
  2116. ' --------------------------------------------------------------
  2117. Private Function Max(ByVal op1, ByVal op2)
  2118. If ( op1 > op2 ) Then
  2119. Max = op1
  2120. Else
  2121. Max = op2
  2122. End If
  2123. End Function
  2124. Function OTS_IsExplorer()
  2125. If InStr(Request.ServerVariables("HTTP_USER_AGENT"), "MSIE") Then
  2126. OTS_IsExplorer = true
  2127. Else
  2128. OTS_IsExplorer = false
  2129. End If
  2130. End Function
  2131. Private Function OTS_EmitAutoInitJavascript(ByRef table)
  2132. Response.Write("<script>"+vbCrLf)
  2133. Response.Write(" function Init()"+vbCrLf)
  2134. Response.Write(" {"+vbCrLf)
  2135. If ( OTS_IsTableMultiSelection( table ) ) Then
  2136. Response.Write(" // Multiselection OTS items not automatically reselected"+vbCrLf)
  2137. Response.Write(" // "+vbCrLf)
  2138. Response.Write(" OTS_Init('');"+vbCrLf)
  2139. Else
  2140. Dim sPKeyParamName
  2141. Call OTS_GetTablePKeyName(table, sPKeyParamName)
  2142. Response.Write(" // "+vbCrLf)
  2143. Response.Write(" // Autoselect OTS item"+vbCrLf)
  2144. Response.Write(" // "+vbCrLf)
  2145. Response.Write(" OTS_Init('"+Request.QueryString(sPKeyParamName)+"');"+vbCrLf)
  2146. End If
  2147. Response.Write(" }"+vbCrLf)
  2148. Response.Write("</script>"+vbCrLf)
  2149. End Function
  2150. %>