home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / Library.asp < prev    next >
Text File  |  2006-10-25  |  8KB  |  229 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.11
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page allows for editing an existing library
  7. '                      or creating a new one.  Users can also view and manage
  8. '                      the list of libraries for an email list.
  9. '
  10. '   COPYRIGHT NOTICE                                
  11. '
  12. '   See attached Software License Agreement
  13. '
  14. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  15. '***********************************************************************
  16. %>
  17. <!--#Include File="Include/Config_inc.asp"-->
  18. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  19. <!--#Include File="Include/Utility_inc.asp"-->
  20. <!--#Include File="Include/adovbs_inc.asp"-->
  21. <!--#Include File="Include/Constants_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <!--#Include File="Include/CurrentUser_inc.asp"-->
  24.  
  25. <%
  26.     'If the user does not have "Create" or "Admin" permission, redirect to the access denied page.
  27.     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  28.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  29.     End If
  30.  
  31.     Dim rsLibrary
  32.     Dim lngLibraryID
  33.     Dim strSQL
  34.     Dim strPageTitle
  35.     Dim strLibrary
  36.     Dim lngUserID
  37.     Dim strCreatedDate
  38.     Dim strPublicYN
  39.     Dim strActiveYN
  40.     Dim strState
  41.     Dim strCancelNav
  42.     
  43.     'Initialization
  44.     Set rsLibrary = Server.CreateObject("ADODB.Recordset")
  45.  
  46.     If Request.QueryString("State") = SUR_STATE_INSERT Then
  47.         strPageTitle = "Create New Library"
  48.         strState = SUR_STATE_INSERT
  49.         strLibrary = ""
  50.         lngUserID = ""
  51.         strCreatedDate = ""
  52.         strPublicYN = SUR_BOOLEAN_NEGATIVE
  53.         strActiveYN = SUR_BOOLEAN_POSITIVE
  54.     Else
  55.         'If the user is not the owner of the library and not an admin, they cannot access this survey.
  56.         If IsUserLibraryOwner(Request.QueryString("LibraryID")) = False And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  57.             Response.Redirect "AccessDenied.asp?SurveyID=" & Request.QueryString("SurveyID") & "&Reason=" & SUR_ACCESS_DENIED_NOT_LIBRARY_OWNER
  58.         End If
  59.  
  60.         strPageTitle = "Edit Library"
  61.         lngLibraryID = Request.QueryString("LibraryID")
  62.         strState = SUR_STATE_EDIT
  63.  
  64.         'Load the existing data from the database
  65.         strSQL = "SELECT active_yn, library_name, user_id, created_date, public_yn " & _
  66.                     "FROM sur_library " & _
  67.                     "WHERE library_id = " & lngLibraryID
  68.         rsLibrary.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  69.         rsLibrary.MoveFirst
  70.         strLibrary = rsLibrary("library_name")
  71.         lngUserID = rsLibrary("user_id")
  72.         strCreatedDate = rsLibrary("created_date")
  73.         strPublicYN = rsLibrary("public_yn")
  74.         strActiveYN = rsLibrary("active_yn")
  75.  
  76.         'Clean up
  77.         rsLibrary.Close
  78.         Set rsLibrary = Nothing
  79.     End If
  80. %>
  81.  
  82. <html>
  83. <head>
  84.     <title><%=strPageTitle%></title>
  85.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  86. </head>
  87.  
  88. <script language ="JavaScript" src="ClientInclude/Utility.js"></script>
  89. <script language="JavaScript">
  90. <%
  91.     'Only include the delete function if the library is in edit mode.
  92.     If strState = SUR_STATE_EDIT Then
  93. %>
  94.         function deleteLibrary()
  95.         {
  96.             if (confirm("Are you sure you want to delete this library?") == true) //OK
  97.             {
  98.                 window.location.href = 'DeleteLibrary.asp?LibraryID=<%=lngLibraryID%>';
  99.             }
  100.         }
  101. <%
  102.     End If
  103. %>
  104.  
  105. function submitCheck() 
  106. {
  107.     if (trim(document.forms['frmLibrary'].txtLibrary.value) == "")
  108.     {    
  109.         alert("Please enter a value for the library.");
  110.         document.forms['frmLibrary'].txtLibrary.focus();
  111.     }
  112.     else
  113.     {
  114.         document.forms['frmLibrary'].submit();
  115.     }
  116. }
  117. </script>
  118.  
  119. <body class="MainBodyStyle">
  120.  
  121. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  122.  
  123. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  124.     <tr>
  125.         <td height="36" valign="center">
  126.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strPageTitle%></a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#Libraries', null, 'menubar=no,toolbar=no,titlebar=no,status=no,left=10,top=10,scrollbars=yes,resizable=yes,height=550,width=770');" border="0" src="Resources/Images/Help.gif">
  127.         </td>
  128.     </tr>
  129. </table>
  130.  
  131. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  132.  
  133. <form name="frmLibrary" method="post" action="LibraryAction.asp" onSubmit="return submitCheck();">
  134.     <input type="hidden" name="LibraryID" value="<%=lngLibraryID%>">
  135.     <input type="hidden" name="State" value="<%=strState%>">
  136.     <input type="hidden" name="Nav" value="<%=Request.QueryString("Nav")%>">
  137.     <table width="740" border="0" cellpadding="0" cellspacing="6" class="LightGrayBackgroundColor">
  138.         <tr>
  139.             <td width="1"></td>
  140.             <td width="724" valign="center" height="36" class="Normal">
  141.                 <span class="Normal">
  142.                     All fields marked with an asterisk (<span class="Required">*</span>) are required.
  143.                 </span>
  144.             </td>
  145.             <td width="1"> </td>
  146.         </tr>
  147.     </table>
  148.     <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  149.     <table border="0" cellpadding="0" cellspacing="6" width="740" class="WhiteBackgroundColor">
  150.         <tr>
  151.             <td width="1" rowspan="20"></td>
  152.             <td valign="bottom" class="NormalBold" height="34">
  153.                 <label for="txtLibrary">Library:</label><span class="Required">*</span>
  154.             </td>
  155.             <td valign="bottom" class="Normal">
  156.                 <input value="<%=strLibrary%>" type="text" name="txtLibrary" id="txtLibrary" maxlength="50" style="width:400px" size="30">
  157.             </td>
  158.             <td width="1" rowspan="20"> </td>
  159.         </tr>
  160.         <tr>
  161.             <td valign="center" class="NormalBold">
  162.                 <label for="cboActive">Active:</label>
  163.             </td>
  164.             <td valign="top" class="Normal">
  165.                 <select name="cboActive" id="cboActive" style="width:100px">
  166.                     <option <% If strActiveYN = SUR_BOOLEAN_NEGATIVE Then Response.Write "selected" End If %> value="<%=SUR_BOOLEAN_NEGATIVE%>"><%=SUR_BOOLEAN_NEGATIVE_DISPLAY%></option>
  167.                     <option <% If strActiveYN = SUR_BOOLEAN_POSITIVE Then Response.Write "selected" End If %> value="<%=SUR_BOOLEAN_POSITIVE%>"><%=SUR_BOOLEAN_POSITIVE_DISPLAY%></option>
  168.                 </select>
  169.             </td>
  170.         </tr>
  171.         <tr>
  172.             <td valign="center" class="NormalBold">
  173.                 <label for="cboPublic">Public:</label>
  174.             </td>
  175.             <td valign="top" class="Normal">
  176.                 <select name="cboPublic" id="cboPublic" style="width:100px">
  177.                     <option <% If strPublicYN = SUR_BOOLEAN_NEGATIVE Then Response.Write "selected" End If %> value="<%=SUR_BOOLEAN_NEGATIVE%>"><%=SUR_BOOLEAN_NEGATIVE_DISPLAY%></option>
  178.                     <option <% If strPublicYN = SUR_BOOLEAN_POSITIVE Then Response.Write "selected" End If %> value="<%=SUR_BOOLEAN_POSITIVE%>"><%=SUR_BOOLEAN_POSITIVE_DISPLAY%></option>
  179.                 </select>
  180.             </td>
  181.         </tr>
  182. <%
  183.         'In EDIT mode, dispay the date created
  184.         If strState = SUR_STATE_EDIT Then
  185. %>
  186.             <tr>
  187.                 <td valign="center" class="NormalBold">
  188.                     Created Date:
  189.                 </td>
  190.                 <td valign="top" class="Normal">
  191.                     <%=CustomDateFormatDisplay(DateValue(strCreatedDate))%>
  192.                 </td>
  193.             </tr>
  194. <%
  195.         End If
  196. %>
  197.         <tr>
  198.             <td align="right" valign="middle" colspan="2">
  199. <%
  200.                 If strState = SUR_STATE_EDIT Then
  201. %>
  202.                     <a href="javascript:deleteLibrary();"><img border="0" alt="Delete this library" name="btnDelete" src="Resources/Buttons/Delete.gif"></a>
  203. <%
  204.                 End If
  205.                 
  206.                 'Determine where to return to when the Cancel button is clicked
  207.                 If Len(Request.QueryString("Nav")) > 0 Then
  208.                     strCancelNav = Request.QueryString("Nav") & ".asp?LibraryID=" & Request.QueryString("LibraryID")
  209.                 Else
  210.                     strCancelNav = "LibraryList.asp"
  211.                 End If
  212. %>                    
  213.                 <a href="<%=strCancelNav%>"><img border="0" alt="Cancel" name="btnCancel" src="Resources/Buttons/Cancel.gif"></a>
  214.                 <a href="javascript:submitCheck();"><img border="0" alt="Save" name="btnSave" src="Resources/Buttons/Save.gif"></a>
  215.             </td>
  216.         </tr>
  217.     </form>
  218. </table>
  219.  
  220. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  221.  
  222. </body>
  223. </html>
  224.  
  225. <%        
  226.     'Ensure that the web server returns the page
  227.     Response.Flush
  228. %>
  229.