home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / ModifyLibrary.asp < prev    next >
Text File  |  2006-10-25  |  12KB  |  293 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 create and modify the 
  7. '                     items on 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/SurveyUtility_inc.asp"-->
  18. <!--#Include File="Include/Utility_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/Collection_inc.asp"-->
  23. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  24. <!--#Include File="Include/SurveyRendering_inc.asp"-->
  25. <%
  26.     'In order to modify the library, the user must be the library owner or must be an admin
  27.     If IsUserLibraryOwner(Request.QueryString("LibraryID")) = False And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  28.         Response.Redirect "AccessDenied.asp?LibraryID=" & Request.QueryString("LibraryID") & "&Reason=" & SUR_ACCESS_DENIED_NOT_LIBRARY_OWNER
  29.     End If
  30.  
  31.     Dim strSQL
  32.     Dim lngLibraryID
  33.     Dim strLibraryName
  34.     Dim strStatus
  35.     Dim rsLibrary
  36.     Dim rsItems
  37.     Dim lngOrderNumber
  38.     Dim lngQuestionNumber
  39.     Dim flgFirstItem
  40.     Dim lngItemID
  41.     Dim strQuestionNumberingFormat
  42.     
  43.     'Initialization
  44.     lngLibraryID = Request.QueryString("LibraryID")
  45.     Set rsLibrary = Server.CreateObject("ADODB.Recordset")
  46.     Set rsItems = Server.CreateObject("ADODB.Recordset")
  47.     lngOrderNumber = 0
  48.     flgFirstItem = True
  49.     strQuestionNumberingFormat = SUR_QUESTION_NUMBERING_ENTIRE_SURVEY
  50.     lngQuestionNumber = 1
  51.     
  52.     'Get the title of this library
  53.     strSQL = "SELECT library_name FROM sur_library WHERE library_id = "& lngLibraryID
  54.     rsLibrary.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  55.     rsLibrary.MoveFirst
  56.     strLibraryName = rsLibrary("library_name")
  57.     rsLibrary.Close
  58.     Set rsLibrary = Nothing
  59.  
  60.     'Get all the items for this library
  61.     strSQL = "SELECT i.item_type_id AS item_type_id, i.required_yn, it.item_type_name AS ItemTypeName, " & _
  62.                 "i.other_yn, m.order_number AS order_number, i.item_id as item_id, database_dsn, " & _
  63.                 "i.display_format, i.maximum_length, i.image_path, i.image_height, i.minimum_value, i.maximum_value, " & _ 
  64.                 "i.answer_total, i.minimum_number_responses, i.maximum_number_responses, i.row_text_width, " & _
  65.                 "i.image_width, other_display_type, i.image_alignment, i.random_answer_order_yn, " & _
  66.                 "i.default_value, i.other_text AS OtherTextQuestion, i.item_sub_text, i.item_text, database_sql " & _
  67.              "FROM sur_library_to_item_mapping m, sur_item i, sur_item_type it " & _
  68.              "WHERE i.item_id = m.item_id " & _
  69.              "AND i.item_type_id = it.item_type_id " & _
  70.              "AND it.item_type_id = i.item_type_id " & _
  71.              "AND m.library_id = " & Request.QueryString("LibraryID") & _
  72.              " ORDER BY    m.order_number"
  73.                 
  74.     'If the database is SQL Server, use a Client cursor location so that the MovePrevious method works correctly
  75.     'with OLEDB.
  76.     If SUR_DATABASE_TYPE = "SQLServer" Then
  77.         rsItems.CursorLocation = adUseClient
  78.     End If
  79.  
  80.     rsItems.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenDynamic, , adCmdText
  81. %>
  82. <html>
  83. <head>
  84.     <title>Modify Library</title>
  85.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  86. </head>
  87.  
  88. <script language="JavaScript">
  89. function itemClicked(strItemID, strOrderNumber, strState)
  90. {
  91.     document.forms['frmItems'].OrderNumber.value = strOrderNumber;
  92.     document.forms['frmItems'].ItemID.value = strItemID;
  93.     document.forms['frmItems'].State.value = strState;
  94.     document.forms['frmItems'].action = 'Item.asp';
  95.     document.forms['frmItems'].submit();
  96. }
  97.  
  98. function copyItem(strItemID, strOrderNumber, strLibraryID)
  99. {
  100.     document.forms['frmCopyMove'].ItemID.value = strItemID;
  101.     document.forms['frmCopyMove'].OrderNumber.value = strOrderNumber;
  102.     document.forms['frmCopyMove'].LibraryID.value = strLibraryID;
  103.     document.forms['frmCopyMove'].action = 'CopyItemAction.asp';
  104.     document.forms['frmCopyMove'].submit();
  105. }
  106.  
  107. function moveItem(strItemID, strOrderNumber, strLibraryID)
  108. {
  109.     document.forms['frmCopyMove'].ItemID.value = strItemID;
  110.     document.forms['frmCopyMove'].OrderNumber.value = strOrderNumber;
  111.     document.forms['frmCopyMove'].LibraryID.value = strLibraryID;
  112.     document.forms['frmCopyMove'].action = 'MoveItem.asp';
  113.     document.forms['frmCopyMove'].submit();
  114. }
  115.  
  116. function deleteItem(strItemID, strOrderNumber, strLibraryID)
  117. {
  118.     if (confirm("Are you sure you want to delete this item?") == true) //OK
  119.     {
  120.         window.location.href = 'DeleteItem.asp?ItemID=' + strItemID + '&OrderNumber=' + strOrderNumber + '&LibraryID=' + strLibraryID;
  121.     }
  122. }
  123.  
  124. function reorderItem(strItemID, strOrderNumber, strDirection)
  125. {
  126.     document.forms['frmItems'].ItemID.value = strItemID;
  127.     document.forms['frmItems'].OrderNumber.value = strOrderNumber;
  128.     document.forms['frmItems'].Direction.value = strDirection;
  129.     document.forms['frmItems'].action = 'ReorderItem.asp';
  130.     document.forms['frmItems'].submit();
  131. }
  132.  
  133. </script>
  134.  
  135. <body class="MainBodyStyle">
  136.  
  137. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  138.  
  139. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  140.     <tr>
  141.         <td height="36" valign="center" width="354">
  142.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Modify 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">
  143.         </td>
  144.         <td valign="center" align="right" width="393">
  145.             <a href="LibraryList.asp"><img border="0" alt="Complete designing the current library" name="btnDone" src="Resources/Buttons/Done.gif"></a>
  146.         </td>
  147.         <td width="7"></td>
  148.     </tr>
  149. </table>
  150.  
  151. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  152.  
  153. <table border="0" cellpadding="0" cellspacing="6" width="100%" class="LightGrayBackgroundColor">
  154.     <tr>
  155.         <td width="1"></td>
  156.         <td width="730" valign="center" height="40">
  157.             <span class="H2HeadingStyle"><%=strLibraryName%></span>
  158.             <a href="Library.asp?Nav=ModifyLibrary&LibraryID=<%=lngLibraryID%>"><img alt="Edit the options for this library" border="0" src="Resources/Buttons/EditSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  159.         </td>
  160.         <td width="1"> </td>
  161.     </tr>
  162. </table>
  163. <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr>
  164. <table cellpadding="2" cellspacing="0" border="0" width="100%" class="WhiteBackgroundColor">
  165.     <tr>
  166.         <td colspan="5" height="10"></td>
  167.     </tr>    
  168.     <form action="#" method="post" name="frmItems">
  169.         <input type="hidden" name="State" value="Insert">
  170.         <input type="hidden" name="LibraryID" value="<%=lngLibraryID%>">
  171.         <input type="hidden" name="ItemID" value="">
  172.         <input type="hidden" name="LibraryName" value="<%=strLibraryName%>">
  173.         <input type="hidden" name="OrderNumber" value="">
  174.         <input type="hidden" name="Direction" value="">
  175. <%
  176.     'Loop through all of the items in the survey and render them.
  177.     If rsItems.EOF = False Then
  178.         Do While Not rsItems.EOF
  179.             lngOrderNumber = rsItems("order_number")
  180.             lngItemID = rsItems("item_id")
  181. %>
  182.             <tr>
  183.                 <td width="8"> </td>
  184.                 <td valign="top" width="2%">
  185. <%
  186.                 If flgFirstItem = False Then 'Only display the up arrow if it's NOT the first item on a page
  187. %>            
  188.                     <a href="javascript:reorderItem('<%=lngItemID%>', '<%=lngOrderNumber%>', 'Up');"><img alt="Move this item up one position" border="0" src="Resources/Images/ArrowUp.gif" onMouseOver="this.style.cursor='hand'"></a>
  189. <%
  190.                 End If
  191.  
  192.                 'Check to make sure that this isn't the last item on the page before displaying the down arrow
  193.                 rsItems.MoveNext
  194.                 If rsItems.EOF = False Then
  195. %>            
  196.                     <a href="javascript:reorderItem('<%=lngItemID%>', '<%=lngOrderNumber%>', 'Down');"><img alt="Move this item down one position" border="0" src="Resources/Images/ArrowDown.gif" onMouseOver="this.style.cursor='hand'"></a>
  197. <%
  198.                 End If
  199.                 rsItems.MovePrevious
  200. %>                    
  201.                 </td>
  202.                 <td valign="top" width="91%">
  203.                     <%DisplayFormattedItem rsItems, False, False%>
  204.                 </td>
  205.                 <td valign="top" width="7%">
  206.                     <a href="javascript:itemClicked('<%=lngItemID%>', '<%=lngOrderNumber%>', 'Insert');"><img border="0" alt="Insert a new item above this item" src="Resources/Buttons/InsertSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  207.                     <a href="javascript:itemClicked('<%=lngItemID%>', '<%=lngOrderNumber%>', 'Edit');"><img alt="Edit this item" border="0" src="Resources/Buttons/EditSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  208.                     <a href="javascript:deleteItem('<%=lngItemID%>', '<%=lngOrderNumber%>', '<%=lngLibraryID%>');"><img alt="Delete this item" border="0" src="Resources/Buttons/DeleteSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  209.                     <a href="javascript:copyItem('<%=lngItemID%>', '<%=lngOrderNumber%>', '<%=lngLibraryID%>');"><img alt="Copy this item" border="0" src="Resources/Buttons/CopySmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  210.                 </td>
  211.                 <td width="8"> </td>
  212.             </tr>
  213.             <tr>
  214.                 <td width="8"> </td>
  215.                 <td colspan="3"><hr></td>
  216.                 <td width="8"> </td>
  217.             </tr>
  218. <%    
  219.             rsItems.MoveNext
  220.  
  221.             'If the EOF has been reached, close out the table surrounding the the last page.
  222.             If rsItems.EOF = True Then
  223. %>
  224.                 <tr>
  225.                     <td width="8"> </td>
  226.                     <td valign="top" colspan="2">
  227.                         <span class="Normal">Click on the "Insert" button to add an item here.</span>
  228.                     </td>
  229.                     <td>
  230.                         <a href="javascript:itemClicked('', '<%=(CLng(lngOrderNumber) + 1)%>', 'Insert');"><img alt="Insert a new item at the bottom of the library" border="0" src="Resources/Buttons/InsertSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  231.                     </td>
  232.                     <td width="8"> </td>
  233.                 </tr>
  234. <%            
  235.             End If
  236.  
  237.             'Set the flag to indicate that this is no longer the first item on the page                
  238.             flgFirstItem = False
  239.         Loop
  240.     Else 'rsItems.EOF = True -- There are no items
  241. %>
  242.         <tr>
  243.             <td width="8"> </td>
  244.             <td valign="top" colspan="2" width="710">
  245.                 <span class="Normal">Click on the Insert button to add an item here.</span>
  246.             </td>
  247.             <td width="15">
  248.                 <a href="javascript:itemClicked('', '<%=(CLng(lngOrderNumber) + 1)%>', 'Insert');"><img alt="Insert an item in this library" border="0" src="Resources/Buttons/InsertSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  249.             </td>
  250.             <td width="8"> </td>
  251.         </tr>
  252.         <tr>
  253.             <td width="8"> </td>
  254.             <td colspan="3"><hr></td>
  255.             <td width="8"> </td>
  256.         </tr>
  257. <%        
  258.     End If
  259.  
  260.     'Clean up
  261.     rsItems.Close
  262.     Set rsItems = Nothing
  263. %>            
  264.     </table>
  265.  
  266.     <table border="0" cellpadding="10" cellspacing="3" width="100%" class="WhiteBackgroundColor">
  267.         <tr>
  268.             <td align="right" valign="middle">
  269.                 <a href="LibraryList.asp"><img border="0" alt="Complete designing the current library" name="btnDone" src="Resources/Buttons/Done.gif"></a>
  270.             </td>
  271.         </tr>
  272.     </table>
  273.  
  274. </form>
  275.  
  276. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  277.  
  278. <form name="frmCopyMove" method="post" action="#">
  279.     <input type="hidden" name="LibraryID" value="">
  280.     <input type="hidden" name="State" value="Insert">
  281.     <input type="hidden" name="OrderNumber" value="">
  282.     <input type="hidden" name="ItemID" value="">
  283.     <input type="hidden" name="ReturnToModifySurvey" value="Yes">
  284. </form>
  285.  
  286. </body>
  287. </html>
  288.  
  289. <%        
  290.     'Ensure that the web server returns the page
  291.     Response.Flush
  292. %>
  293.