PageRenderTime 29ms CodeModel.GetById 0ms RepoModel.GetById 0ms app.codeStats 0ms

/AC/Admin/SysMn/m018q03109.asp

http://github.com/boss2009/ASP-site
ASP | 275 lines | 246 code | 29 blank | 0 comment | 111 complexity | 8c811ea35cab8ead17df2c409bfd1b6a MD5 | raw file
  1. <%@language="JAVASCRIPT"%>
  2. <!--#include file="../../inc/ASPUtility.inc" -->
  3. <!--#include file="../../Connections/cnnASP02.asp" -->
  4. <!--#include file="../../inc/ASPCheckAdminLogin.inc" -->
  5. <%
  6. var rsPILATStatus = Server.CreateObject("ADODB.Recordset");
  7. rsPILATStatus.ActiveConnection = MM_cnnASP02_STRING;
  8. rsPILATStatus.Source = "{call dbo.cp_PILAT_status(0,'',0,'Q',0)}";
  9. rsPILATStatus.CursorType = 0;
  10. rsPILATStatus.CursorLocation = 2;
  11. rsPILATStatus.LockType = 3;
  12. rsPILATStatus.Open();
  13. var rsPILATStatus_numRows = 0;
  14. %>
  15. <%
  16. var Repeat1__numRows = -1;
  17. var Repeat1__index = 0;
  18. rsPILATStatus_numRows += Repeat1__numRows;
  19. %>
  20. <%
  21. // *** Recordset Stats, Move To Record, and Go To Record: declare stats variables
  22. // set the record count
  23. var rsPILATStatus_total = rsPILATStatus.RecordCount;
  24. // set the number of rows displayed on this page
  25. if (rsPILATStatus_numRows < 0) { // if repeat region set to all records
  26. rsPILATStatus_numRows = rsPILATStatus_total;
  27. } else if (rsPILATStatus_numRows == 0) { // if no repeat regions
  28. rsPILATStatus_numRows = 1;
  29. }
  30. // set the first and last displayed record
  31. var rsPILATStatus_first = 1;
  32. var rsPILATStatus_last = rsPILATStatus_first + rsPILATStatus_numRows - 1;
  33. // if we have the correct record count, check the other stats
  34. if (rsPILATStatus_total != -1) {
  35. rsPILATStatus_numRows = Math.min(rsPILATStatus_numRows, rsPILATStatus_total);
  36. rsPILATStatus_first = Math.min(rsPILATStatus_first, rsPILATStatus_total);
  37. rsPILATStatus_last = Math.min(rsPILATStatus_last, rsPILATStatus_total);
  38. }
  39. %>
  40. <%
  41. // *** Recordset Stats: if we don't know the record count, manually count them
  42. if (rsPILATStatus_total == -1) {
  43. // count the total records by iterating through the recordset
  44. for (rsPILATStatus_total=0; !rsPILATStatus.EOF; rsPILATStatus.MoveNext()) {
  45. rsPILATStatus_total++;
  46. }
  47. // reset the cursor to the beginning
  48. if (rsPILATStatus.CursorType > 0) {
  49. if (!rsPILATStatus.BOF) rsPILATStatus.MoveFirst();
  50. } else {
  51. rsPILATStatus.Requery();
  52. }
  53. // set the number of rows displayed on this page
  54. if (rsPILATStatus_numRows < 0 || rsPILATStatus_numRows > rsPILATStatus_total) {
  55. rsPILATStatus_numRows = rsPILATStatus_total;
  56. }
  57. // set the first and last displayed record
  58. rsPILATStatus_last = Math.min(rsPILATStatus_first + rsPILATStatus_numRows - 1, rsPILATStatus_total);
  59. rsPILATStatus_first = Math.min(rsPILATStatus_first, rsPILATStatus_total);
  60. }
  61. %>
  62. <% var MM_paramName = ""; %>
  63. <%
  64. // *** Move To Record and Go To Record: declare variables
  65. var MM_rs = rsPILATStatus;
  66. var MM_rsCount = rsPILATStatus_total;
  67. var MM_size = rsPILATStatus_numRows;
  68. var MM_uniqueCol = "";
  69. MM_paramName = "";
  70. var MM_offset = 0;
  71. var MM_atTotal = false;
  72. var MM_paramIsDefined = (MM_paramName != "" && String(Request(MM_paramName)) != "undefined");
  73. %>
  74. <%
  75. // *** Move To Record: handle 'index' or 'offset' parameter
  76. if (!MM_paramIsDefined && MM_rsCount != 0) {
  77. // use index parameter if defined, otherwise use offset parameter
  78. r = String(Request("index"));
  79. if (r == "undefined") r = String(Request("offset"));
  80. if (r && r != "undefined") MM_offset = parseInt(r);
  81. // if we have a record count, check if we are past the end of the recordset
  82. if (MM_rsCount != -1) {
  83. if (MM_offset >= MM_rsCount || MM_offset == -1) { // past end or move last
  84. if ((MM_rsCount % MM_size) != 0) { // last page not a full repeat region
  85. MM_offset = MM_rsCount - (MM_rsCount % MM_size);
  86. } else {
  87. MM_offset = MM_rsCount - MM_size;
  88. }
  89. }
  90. }
  91. // move the cursor to the selected record
  92. for (var i=0; !MM_rs.EOF && (i < MM_offset || MM_offset == -1); i++) {
  93. MM_rs.MoveNext();
  94. }
  95. if (MM_rs.EOF) MM_offset = i; // set MM_offset to the last possible record
  96. }
  97. %>
  98. <%
  99. // *** Move To Record: if we dont know the record count, check the display range
  100. if (MM_rsCount == -1) {
  101. // walk to the end of the display range for this page
  102. for (var i=MM_offset; !MM_rs.EOF && (MM_size < 0 || i < MM_offset + MM_size); i++) {
  103. MM_rs.MoveNext();
  104. }
  105. // if we walked off the end of the recordset, set MM_rsCount and MM_size
  106. if (MM_rs.EOF) {
  107. MM_rsCount = i;
  108. if (MM_size < 0 || MM_size > MM_rsCount) MM_size = MM_rsCount;
  109. }
  110. // if we walked off the end, set the offset based on page size
  111. if (MM_rs.EOF && !MM_paramIsDefined) {
  112. if ((MM_rsCount % MM_size) != 0) { // last page not a full repeat region
  113. MM_offset = MM_rsCount - (MM_rsCount % MM_size);
  114. } else {
  115. MM_offset = MM_rsCount - MM_size;
  116. }
  117. }
  118. // reset the cursor to the beginning
  119. if (MM_rs.CursorType > 0) {
  120. if (!MM_rs.BOF) MM_rs.MoveFirst();
  121. } else {
  122. MM_rs.Requery();
  123. }
  124. // move the cursor to the selected record
  125. for (var i=0; !MM_rs.EOF && i < MM_offset; i++) {
  126. MM_rs.MoveNext();
  127. }
  128. }
  129. %>
  130. <%
  131. // *** Move To Record: update recordset stats
  132. // set the first and last displayed record
  133. rsPILATStatus_first = MM_offset + 1;
  134. rsPILATStatus_last = MM_offset + MM_size;
  135. if (MM_rsCount != -1) {
  136. rsPILATStatus_first = Math.min(rsPILATStatus_first, MM_rsCount);
  137. rsPILATStatus_last = Math.min(rsPILATStatus_last, MM_rsCount);
  138. }
  139. // set the boolean used by hide region to check if we are on the last record
  140. MM_atTotal = (MM_rsCount != -1 && MM_offset + MM_size >= MM_rsCount);
  141. %>
  142. <%
  143. // *** Go To Record and Move To Record: create strings for maintaining URL and Form parameters
  144. // create the list of parameters which should not be maintained
  145. var MM_removeList = "&index=";
  146. if (MM_paramName != "") MM_removeList += "&" + MM_paramName.toLowerCase() + "=";
  147. var MM_keepURL="",MM_keepForm="",MM_keepBoth="",MM_keepNone="";
  148. // add the URL parameters to the MM_keepURL string
  149. for (var items=new Enumerator(Request.QueryString); !items.atEnd(); items.moveNext()) {
  150. var nextItem = "&" + items.item().toLowerCase() + "=";
  151. if (MM_removeList.indexOf(nextItem) == -1) {
  152. MM_keepURL += "&" + items.item() + "=" + Server.URLencode(Request.QueryString(items.item()));
  153. }
  154. }
  155. // add the Form variables to the MM_keepForm string
  156. for (var items=new Enumerator(Request.Form); !items.atEnd(); items.moveNext()) {
  157. var nextItem = "&" + items.item().toLowerCase() + "=";
  158. if (MM_removeList.indexOf(nextItem) == -1) {
  159. MM_keepForm += "&" + items.item() + "=" + Server.URLencode(Request.Form(items.item()));
  160. }
  161. }
  162. // create the Form + URL string and remove the intial '&' from each of the strings
  163. MM_keepBoth = MM_keepURL + MM_keepForm;
  164. if (MM_keepBoth.length > 0) MM_keepBoth = MM_keepBoth.substring(1);
  165. if (MM_keepURL.length > 0) MM_keepURL = MM_keepURL.substring(1);
  166. if (MM_keepForm.length > 0) MM_keepForm = MM_keepForm.substring(1);
  167. %>
  168. <%
  169. // *** Move To Record: set the strings for the first, last, next, and previous links
  170. var MM_moveFirst="",MM_moveLast="",MM_moveNext="",MM_movePrev="";
  171. var MM_keepMove = MM_keepBoth; // keep both Form and URL parameters for moves
  172. var MM_moveParam = "index";
  173. // if the page has a repeated region, remove 'offset' from the maintained parameters
  174. if (MM_size > 1) {
  175. MM_moveParam = "offset";
  176. if (MM_keepMove.length > 0) {
  177. params = MM_keepMove.split("&");
  178. MM_keepMove = "";
  179. for (var i=0; i < params.length; i++) {
  180. var nextItem = params[i].substring(0,params[i].indexOf("="));
  181. if (nextItem.toLowerCase() != MM_moveParam) {
  182. MM_keepMove += "&" + params[i];
  183. }
  184. }
  185. if (MM_keepMove.length > 0) MM_keepMove = MM_keepMove.substring(1);
  186. }
  187. }
  188. // set the strings for the move to links
  189. if (MM_keepMove.length > 0) MM_keepMove += "&";
  190. var urlStr = Request.ServerVariables("URL") + "?" + MM_keepMove + MM_moveParam + "=";
  191. MM_moveFirst = urlStr + "0";
  192. MM_moveLast = urlStr + "-1";
  193. MM_moveNext = urlStr + (MM_offset + MM_size);
  194. MM_movePrev = urlStr + Math.max(MM_offset - MM_size,0);
  195. %>
  196. <html>
  197. <head>
  198. <title>PILAT Status Lookup Table</title>
  199. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  200. <link rel="stylesheet" href="../../css/MyStyle.css" type="text/css">
  201. <Script language="Javascript">
  202. function openWindow(page, name){
  203. if (page!='nothing') win1=window.open(page, "", "width=350,height=250,scrollbars=1,left=0,top=0,status=1");
  204. return ;
  205. }
  206. </Script>
  207. </head>
  208. <body>
  209. <h5>PILAT Status Lookup Table</h5>
  210. <a href="../../aspMenu.asp">Master Menu</a> / <a href="../m018Menu.asp">Administrative Options</a> / <a href="../m018Sm03.asp">System Lookup Tables</a>
  211. <table cellspacing="1">
  212. <tr>
  213. <td><% if (MM_offset != 0) { %><a href="<%=MM_moveFirst%>">First Page</a><% } else { %>First Page<% } // end MM_offset != 0 %>|</td>
  214. <td><% if (MM_offset != 0) { %><a href="<%=MM_movePrev%>">Previous Page</a><% } else { %>Previous Page<% } // end MM_offset != 0 %>|</td>
  215. <td><% if (!MM_atTotal) { %><a href="<%=MM_moveNext%>">Next Page</a><% } else { %>Next Page<% } // end !MM_atTotal %>|</td>
  216. <td><% if (!MM_atTotal) { %><a href="<%=MM_moveLast%>">Last Page</a><% } else { %>Last Page<% } // end !MM_atTotal %></td>
  217. </tr>
  218. </table>
  219. <hr>
  220. <table cellpadding="2" cellspacing="1" class="Mtable">
  221. <tr>
  222. <th class="headrow">Description</th>
  223. </tr>
  224. <%
  225. while ((Repeat1__numRows-- != 0) && (!rsPILATStatus.EOF)) {
  226. %>
  227. <tr>
  228. <td><a href="m018e03109.asp?insPILAT_Status_id=<%=(rsPILATStatus.Fields.Item("insPILAT_Status_id").Value)%>"><%=(rsPILATStatus.Fields.Item("chvStatus_Desc").Value)%></a></td>
  229. </tr>
  230. <%
  231. Repeat1__index++;
  232. rsPILATStatus.MoveNext();
  233. }
  234. %>
  235. </table>
  236. <hr>
  237. <table cellpadding="1" cellspacing="1">
  238. <tr>
  239. <td><a href="javascript: openWindow('m018a03109.asp','w18A03109');">Add PILAT Status</a></td>
  240. </tr>
  241. </table>
  242. </body>
  243. </html>
  244. <%
  245. rsPILATStatus.Close();
  246. %>