home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / InsertFromLibrary.asp < prev    next >
Text File  |  2006-11-29  |  9KB  |  257 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 the user to insert a new item into a 
  7. '                      survey from a library.
  8. '
  9. '   COPYRIGHT NOTICE                                
  10. '
  11. '   See attached Software License Agreement
  12. '
  13. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  14. '***********************************************************************
  15. %>
  16. <!--#Include File="Include/Config_inc.asp"-->
  17. <!--#Include File="Include/Utility_inc.asp"-->
  18. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  19. <!--#Include File="Include/adovbs_inc.asp"-->
  20. <!--#Include File="Include/CurrentUser_inc.asp"-->
  21. <!--#Include File="Include/Constants_inc.asp"-->
  22. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  23. <%
  24.     'If the user does not have "Create" or "Admin" permission, redirect them to the access denied page.
  25.     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  26.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  27.     End If
  28.  
  29.     Dim rsItems
  30.     Dim rsLibraries
  31.     Dim strSQL
  32.     Dim lngSurveyID
  33.     Dim lngLibraryID
  34.     Dim lngOriginalSurveyID
  35.     Dim flgNoItemsAvailable
  36.     
  37.     'Initialization 
  38.     Set rsItems = Server.CreateObject("ADODB.Recordset")
  39.     Set rsLibraries = Server.CreateObject("ADODB.Recordset")
  40.     
  41.     'If the form is being submitted to itself, use the selected survey ID.  Otherwise, use the survey ID passed to
  42.     'the page
  43.     If Len(Request.Form("cboLibrary")) > 0 Then
  44.         lngLibraryID = Request.Form("cboLibrary")
  45.         lngOriginalSurveyID = Request.Form("OriginalSurveyID")
  46.     Else
  47.         lngOriginalSurveyID = Request.Form("SurveyID")
  48.     End If
  49.     flgNoItemsAvailable = False
  50. %>
  51. <html>
  52. <head>
  53.     <title>Insert from Library</title>
  54.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  55. </head>
  56.  
  57. <script language ="JavaScript" src="ClientInclude/Utility.js"></script>
  58. <script language="JavaScript">
  59. function submitCheck() 
  60. {
  61.     // Make sure that the user selected an item.
  62.     if (document.forms['frmItem'].cboItem.value == '<%=SUR_COMBO_PLEASE_SELECT%>')
  63.     {    
  64.         alert("Please select an existing item.");
  65.         document.forms['frmItem'].cboItem.focus();
  66.         return false;
  67.     }
  68.  
  69.     return true;
  70. }
  71.  
  72. function librarySelected()
  73. {
  74.     document.forms['frmItem'].action = 'InsertFromLibrary.asp';
  75.     document.forms['frmItem'].submit();
  76. }
  77. </script>
  78.  
  79. <body class="MainBodyStyle">
  80.  
  81. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  82.  
  83. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  84.     <tr>
  85.         <td height="36" valign="center">
  86.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Insert from Library</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">
  87.         </td>
  88.     </tr>
  89. </table>
  90.  
  91. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  92.  
  93. <form name="frmItem" method="post" action="CopyItemAction.asp" onSubmit="return submitCheck();">
  94.     <input type="hidden" name="PageNumber" value="<%=Request.Form("PageNumber")%>">
  95.     <input type="hidden" name="NewPage" value="<%=Request.Form("NewPage")%>">
  96.     <input type="hidden" name="OriginalSurveyID" value="<%=lngOriginalSurveyID%>">
  97.     <input type="hidden" name="SurveyName" value="<%=Request.Form("SurveyName")%>">
  98.     <input type="hidden" name="State" value="<%=SUR_STATE_INSERT%>">
  99.     <input type="hidden" name="OrderNumber" value="<%=Request.Form("OrderNumber")%>">
  100.     <table width="740" border="0" cellpadding="6" cellspacing="0" class="LightGrayBackgroundColor">
  101.         <tr>
  102.             <td width="1" rowspan="10"></td>
  103.             <td colspan="2" height="38" valign="bottom">
  104.                 <span class="H2HeadingStyle">Insert Item from Library</span>
  105.             </td>
  106.             <td width="1" rowspan="10"> </td>
  107.         </tr>
  108.         <tr>
  109.             <td valign="top" class="Normal" height="46">
  110.                 Insert a new item by copying an existing item from a library.  Copying an item from a library copies all 
  111.                 options and answers.
  112.             </td>
  113.         </tr>
  114.     </table>
  115.     <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  116.     <table border="0" cellpadding="0" cellspacing="6" width="740" class="WhiteBackgroundColor">
  117.         <tr>
  118.             <td width="1" rowspan="10"></td>
  119.             <td colspan="2" valign="top" class="Normal">
  120.                 <br>
  121.             </td>
  122.             <td width="1" rowspan="10"> </td>
  123.         </tr>
  124.         <tr>
  125.             <td valign="top" width="25">
  126.                 <span class="NormalBold"><label for="cboLibrary">Library:</label></span>
  127.             </td>
  128.             <td align="left" valign="top">
  129.                 <select name="cboLibrary" id="cboLibrary" style="width:560" onChange="javascript:librarySelected();">
  130. <%
  131.                     'Create the SQL for creating the list of items.  Exclude <HR>'s.
  132.                     strSQL = "SELECT library_id, library_name " & _
  133.                                 "FROM sur_library " & _
  134.                                 "WHERE active_yn = " & SQLEncode(SUR_BOOLEAN_POSITIVE)
  135.                     
  136.                     'If the user is not an admin, only select the libraries owned by this user or that have public access.
  137.                     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  138.                         strSQL = strSQL & " AND user_id = " & GetUserID() & _
  139.                                  " OR public_yn = " & SQLEncode(SUR_BOOLEAN_POSITIVE)
  140.                     End If
  141.                     strSQL = strSQL & " ORDER BY library_name"
  142.                     rsLibraries.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  143.                     
  144.                     'Check to see if there are any libraries
  145.                     If rsLibraries.EOF = True Then
  146. %>
  147.                         <option value="<%=SUR_COMBO_NO_AVAILABLE_LIBRARIES%>"><%=SUR_COMBO_NO_AVAILABLE_LIBRARIES%></option>
  148. <%
  149.                     Else 'There is at least one library
  150.                         rsLibraries.MoveFirst
  151.                         
  152.                         'If no library ID has been set, then this is the first time on the page, so use the ID of the first library
  153.                         If Len(lngLibraryID) = 0 Then
  154.                             lngLibraryID = rsLibraries("library_id")
  155.                         End If
  156.                         
  157.                         Do While Not rsLibraries.EOF
  158. %>
  159.                             <option <% If CStr(rsLibraries("library_id")) = CStr(lngLibraryID) Then Response.Write "selected" End If %> value="<%=rsLibraries("library_id")%>"><%=rsLibraries("library_name")%></option>
  160. <%
  161.                             rsLibraries.MoveNext
  162.                         Loop
  163.                     End If
  164.                     
  165.                     'Clean up 
  166.                     rsLibraries.Close
  167.                     Set rsLibraries = Nothing
  168. %>
  169.                 </select>
  170.             </td>
  171.         </tr>
  172.         <tr>
  173.             <td valign="top" width="25">
  174.                 <span class="NormalBold"><label for="cboItem">Item:</label></span>
  175.             </td>
  176.             <td align="left" valign="top">
  177.                 <select name="cboItem" id="cboItem" style="width:560">
  178. <%
  179.                     'Make sure that a library has been selected before displaying the items
  180.                     If Len(lngLibraryID) > 0 Then
  181.                         'Create the SQL for creating the list of items.  Excluse <HR>'s.
  182.                         strSQL = "SELECT item_type_id, i.item_id As item_id, item_text " & _
  183.                                     "FROM sur_item i, sur_library_to_item_mapping m " & _
  184.                                     "WHERE i.item_id = m.item_id " & _
  185.                                     "AND item_type_id <> 12 " & _ 
  186.                                     "AND m.library_id = " & lngLibraryID & _
  187.                                     " ORDER BY order_number"
  188.                         rsItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  189.  
  190.                         'If there are not items, display an option indicating that there are no available items.  Otherwise, 
  191.                         'display the list of items.
  192.                         If rsItems.EOF Then
  193.                             flgNoItemsAvailable = True
  194. %>
  195.                             <option value="<%=SUR_COMBO_NO_AVAILABLE_ITEMS%>"><%=SUR_COMBO_NO_AVAILABLE_ITEMS%></option>
  196. <%                    
  197.                         Else
  198. %>
  199.                             <option value="<%=SUR_COMBO_PLEASE_SELECT%>"><%=SUR_COMBO_PLEASE_SELECT%></option>
  200. <%                    
  201.                             rsItems.MoveFirst
  202.                             Do While Not rsItems.EOF
  203.                                 If rsItems("item_type_id") = SUR_ITEM_HTML Then
  204. %>
  205.                                     <option value="<%=rsItems("item_id")%>">HTML (Starting with "<%=Left(rsItems("item_text"), 70)%>..."</option>
  206. <%                            
  207.                                 Else
  208. %>
  209.                                     <option value="<%=rsItems("item_id")%>"><%=rsItems("item_text")%></option>
  210. <%
  211.                                 End If
  212.                                 rsItems.MoveNext
  213.                             Loop
  214.                         End If
  215.                         
  216.                         'Clean up 
  217.                         rsItems.Close
  218.                         Set rsItems = Nothing
  219.                         
  220.                     Else 'No library is available, so there are no items to display
  221.                         flgNoItemsAvailable = True
  222. %>
  223.                         <option value="<%=SUR_COMBO_NO_AVAILABLE_ITEMS%>"><%=SUR_COMBO_NO_AVAILABLE_ITEMS%></option>
  224. <%
  225.                     End If
  226. %>
  227.                 </select>
  228.             </td>
  229.         </tr>
  230.         <tr>
  231.             <td valign="top" align="right" colspan="2">
  232.                 <br>
  233.                 <a href="ModifySurvey.asp?SurveyID=<%=lngOriginalSurveyID%>"><img border="0" alt="Cancel" src="Resources/Buttons/Cancel.gif" name="btnCancel"></a>
  234. <%
  235.                 'Only display the continue button if there is at least one item to choose from
  236.                 If flgNoItemsAvailable = False Then
  237. %>                
  238.                     <input type="image" border="0" alt="Continue" src="Resources/Buttons/Continue.gif" name="btnContinue">
  239. <%
  240.                 End If
  241. %>                    
  242.                 <br>
  243.             </td>
  244.         </tr>
  245.     </form>
  246. </table>
  247.  
  248. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  249.  
  250. </body>
  251. </html>
  252.  
  253. <%        
  254.     'Ensure that the web server returns the page
  255.     Response.Flush
  256. %>
  257.