PageRenderTime 43ms CodeModel.GetById 12ms RepoModel.GetById 1ms app.codeStats 0ms

/ST/m002q01.asp

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