home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / SurveyList.asp < prev    next >
Text File  |  2006-11-29  |  13KB  |  325 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 displays a list of all the surveys owned
  7. '                     by the current user.
  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/Constants_inc.asp"-->
  17. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  18. <!--#Include File="Include/Utility_inc.asp"-->
  19. <!--#Include File="Include/CurrentUser_inc.asp"-->
  20. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  21. <!--#Include File="Include/Config_inc.asp"-->
  22. <!--#Include File="Include/Encryption_inc.asp"-->
  23. <!--#Include File="Include/adovbs_inc.asp"-->
  24. <%
  25.     Dim strPageTitle
  26.     Dim strSortColumn
  27.     Dim strSortOrder
  28.     Dim strTempSortOrder
  29.     Dim strTableRowColor
  30.  
  31.     'If the user is not logged in, redirect to the login page.  Otherwise, the user does not have "Create" 
  32.     'or "Admin" permission, redirect to the access denied page.
  33.     If IsLoggedIn() = False Then
  34.         Response.Redirect "Login.asp"
  35.     Else
  36.         If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  37.             Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  38.         End If
  39.     End If
  40.     
  41.     If lngUserSecurityLevel = SUR_SECURITY_LEVEL_CREATE Then
  42.         strPageTitle = "My Surveys"
  43.     Else 'lngUserSecurityLevel = SUR_SECURITY_LEVEL_ADMIN
  44.         strPageTitle = "Surveys"
  45.     End If
  46.     
  47.     'Set the sort column and sort order
  48.     If Len(Request.QueryString("SortColumn")) > 0 Then
  49.         strSortColumn = Request.QueryString("SortColumn")
  50.         strSortOrder = Request.QueryString("SortOrder")
  51.     Else
  52.         strSortColumn = "created_date"
  53.         strSortOrder = SUR_SORT_ORDER_DESCENDING
  54.     End If
  55.     
  56.     'Initialize the row color
  57.     strTableRowColor = "TableRowLightColor"
  58. %>
  59. <html>
  60. <head>
  61.     <title><%=strPageTitle%></title>    
  62.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  63. </head>
  64. <script language="JavaScript">
  65. function deleteSurvey(lngSurveyID)
  66. {
  67.     if (confirm("Are you sure you want to delete this survey?") == true) //OK
  68.     {
  69.         window.location.href = 'DeleteSurvey.asp?SurveyID=' + lngSurveyID;
  70.     }
  71. }
  72. function clearSurvey(lngSurveyID)
  73. {
  74.     if (confirm("Are you sure you want to delete all of the responses to this survey?") == true) //OK
  75.     {
  76.         window.location.href = 'DeleteResponses.asp?SurveyID=' + lngSurveyID;
  77.     }
  78. }
  79. </script>
  80. <body class="MainBodyStyle">
  81.  
  82. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  83.  
  84. <table width="754" border="0" cellpadding="0" cellspacing="0" class="MediumBlueBackgroundColor">
  85.     <tr>
  86.         <td width="593" align="left" height="36" valign="center">
  87.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1"><%=strPageTitle%></a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#DesigningSurveys', 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">
  88.         </td>
  89.         <td width="154" align="right" valign="center">
  90.             <a href="CreateSurvey.asp"><img border="0" alt="Create a new survey" src="Resources/Buttons/CreateNewSurvey.gif"></a>
  91.         </td>
  92.         <td width="7"> </td>
  93.     </tr>
  94. </table>
  95.  
  96. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  97.  
  98.     <table name="tblSurveys" cellspacing="0" border="0" cellpadding="6" width="740" class="WhiteBackgroundColor" summary="This page displays a list of all surveys.  If the use is an Admin, then all surveys in the application are displayed.  If the user has Create permission, then only the surveys that this user owns are displayed.">
  99.         <tr class="TableHeadingColor" height="40">
  100.             <th id="Manage" align="center" width="41" valign="center">
  101.                 <span class="TableHeadingBold">Manage</span>
  102.             </th>
  103.             <th id="Status" align="center" width="38" valign="center">
  104. <%
  105.                 'Determine the sort order if the user clicks this column heading
  106.                 If strSortColumn = "status" Then
  107.                     If strSortOrder = SUR_SORT_ORDER_ASCENDING Then
  108.                         strTempSortOrder = SUR_SORT_ORDER_DESCENDING
  109.                     Else
  110.                         strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  111.                     End If
  112.                 Else
  113.                     strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  114.                 End If
  115. %>
  116.                 <span class="TableHeadingBold"><a href="SurveyList.asp?SortColumn=status&SortOrder=<%=strTempSortOrder%>">Status</a></span>
  117.             </th>
  118.             <th id="Title" align="center" width="402" valign="center">
  119. <%
  120.                 'Determine the sort order if the user clicks this column heading
  121.                 If strSortColumn = "title" Then
  122.                     If strSortOrder = SUR_SORT_ORDER_ASCENDING Then
  123.                         strTempSortOrder = SUR_SORT_ORDER_DESCENDING
  124.                     Else
  125.                         strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  126.                     End If
  127.                 Else
  128.                     strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  129.                 End If
  130. %>
  131.                 <span class="TableHeadingBold"><a href="SurveyList.asp?SortColumn=title&SortOrder=<%=strTempSortOrder%>">Title</a></span> <span class="TableHeadingNormal">(click to preview)</span></span>
  132.             </th>
  133.             <th id="CreatedDate" align="center" width="91" valign="center">
  134. <%
  135.                 'Determine the sort order if the user clicks this column heading
  136.                 If strSortColumn = "created_date" Then
  137.                     If strSortOrder = SUR_SORT_ORDER_ASCENDING Then
  138.                         strTempSortOrder = SUR_SORT_ORDER_DESCENDING
  139.                     Else
  140.                         strTempSortOrder = SUR_SORT_ORDER_ASCENDING
  141.                     End If
  142.                 Else
  143.                     strTempSortOrder = SUR_SORT_ORDER_DESCENDING
  144.                 End If
  145. %>
  146.                 <span class="TableHeadingBold"><a href="SurveyList.asp?SortColumn=created_date&SortOrder=<%=strTempSortOrder%>">Date Created</a></span>
  147.             </th>
  148.             <th id="Design" align="center" width="40" valign="center">
  149.                 <span class="TableHeadingBold">Design</span>
  150.             </th>
  151.             <th id="Options" align="center" width="46" valign="center">
  152.                 <span class="TableHeadingBold">Options</span>
  153.             </th>
  154.             <th id="Deploy" align="center" width="45" valign="center">
  155.                 <span class="TableHeadingBold">Deploy</span>
  156.             </th>
  157.             <th id="Analyze" align="center" width="47" valign="center">
  158.                 <span class="TableHeadingBold">Analyze</span>
  159.             </th>
  160.             <th id="Delete" align="center" width="41" valign="center">
  161.                 <span class="TableHeadingBold">Delete</span>
  162.             </th>
  163.             <th id="Clear" align="center" width="40" valign="center">
  164.                 <span class="TableHeadingBold">Clear</span>
  165.             </th>
  166.         </tr>
  167. <%
  168.         Dim strSQL
  169.         Dim rsSurveys
  170.         Dim strColor
  171.         Dim strStatus
  172.         Dim lngSurveyID
  173.  
  174.         'Initialization
  175.         Set rsSurveys = Server.CreateObject("ADODB.Recordset")
  176.  
  177.         'Select the list of all surveys owned by the current user    
  178.         strSQL = "SELECT survey_id, title, created_date, status, response_count " & _
  179.                     "FROM sur_survey "
  180.         'If the user has "Create" permission, only display the surveys they own; otherwise, display all surveys
  181.         If lngUserSecurityLevel = SUR_SECURITY_LEVEL_CREATE Then                
  182.             strSQL = strSQL & "WHERE owners LIKE '%" & GetUsername() & "%' "
  183.         End If
  184.         strSQL = strSQL & "ORDER BY " & strSortColumn & " " & strSortOrder
  185.                 
  186.         rsSurveys.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  187.  
  188.         If rsSurveys.EOF = True Then
  189. %>    
  190.             <tr class="TableRowLightColor">
  191.                 <td class="Normal" valign="top" colspan="10">
  192.                     You do not currently have any surveys.
  193.                     <br><br><br><br><br><br><br><br><br>
  194.                 </td>
  195.             </tr>
  196. <%        
  197.         Else
  198.             rsSurveys.MoveFirst
  199.             Do While Not rsSurveys.EOF
  200.                 strStatus = rsSurveys("status")
  201.                 lngSurveyID = rsSurveys("survey_id") 
  202. %>
  203.                 <tr class="<%=strTableRowColor%>">
  204. <%
  205.                     Select Case strStatus
  206.                         Case SUR_STATUS_DESIGN
  207.                             strColor = SUR_STATUS_DESIGN_COLOR
  208.                         Case SUR_STATUS_OPEN
  209.                             strColor = SUR_STATUS_OPEN_COLOR
  210.                         Case SUR_STATUS_CLOSED
  211.                             strColor = SUR_STATUS_CLOSED_COLOR
  212.                     End Select
  213. %>                    
  214.                     <td align="center" class="Normal" valign="center">
  215.                         <a name="SurveyID<%=lngSurveyID%>">
  216. <%
  217.                         If strStatus = SUR_STATUS_DESIGN Then
  218. %>                    
  219.                             <a href="ChangeStatus.asp?SurveyID=<%=lngSurveyID%>&Launch=Yes&Status=<%=SUR_STATUS_OPEN%>"><img alt="Launch your survey to accept responses" border="0" src="Resources/Buttons/OpenSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  220. <%
  221.                         ElseIf strStatus = SUR_STATUS_CLOSED Then
  222. %>                    
  223.                             <a href="ChangeStatus.asp?SurveyID=<%=lngSurveyID%>&Launch=No&Status=<%=SUR_STATUS_OPEN%>"><img alt="Launch your survey to accept responses" border="0" src="Resources/Buttons/OpenSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  224. <%
  225.                         Else 'strStatus = SUR_STATUS_OPEN
  226. %>            
  227.                             <a href="ChangeStatus.asp?SurveyID=<%=lngSurveyID%>&Launch=No&Status=<%=SUR_STATUS_CLOSED%>"><img alt="Close your survey to all respondents" border="0" src="Resources/Buttons/CloseSmall.gif" onMouseOver="this.style.cursor='hand'"></a>
  228. <%
  229.                         End If
  230. %>                    
  231.                     </td>
  232.                     <td class="Normal">
  233.                         <span style="color:<%=strColor%>"><%=strStatus%></span>
  234.                     </td>
  235.                     <td>
  236.                         <span class="NormalLink"><a target="_blank" href="TakeSurvey.asp?PageNumber=1&SurveyID=<%=EncryptSurveyID(lngSurveyID)%>"><%=rsSurveys("title")%></a><br></span>
  237.                     </td>
  238.                     <td align="center" class="Normal">
  239.                         <%=CustomDateFormatDisplay(DateValue(rsSurveys("created_date")))%>
  240.                     </td>
  241.                     <td align="center" class="Normal">
  242.                         <a href="ModifySurvey.asp?SurveyID=<%=rsSurveys("survey_id")%>"><img alt="Add questions and pages, and control the layout of your survey" border="0" src="Resources/Icons/Design.gif" onMouseOver="this.style.cursor='hand'"></a>
  243.                     </td>
  244.                     <td align="center" class="Normal">
  245.                         <a href="Survey.asp?Nav=SurveyList&SurveyID=<%=lngSurveyID%>"><img alt="Manage your survey and update your survey options" src="Resources/Icons/Options.gif" border="0" onMouseOver="this.style.cursor='hand'"></a>
  246.                     </td>
  247.                     <td align="center" class="Normal">
  248.                         <a href="Deploy.asp?SurveyID=<%=lngSurveyID%>&SurveyName=<%=rsSurveys("title")%>"><img alt="Create links, popup windows, and email invitations to take your survey" src="Resources/Icons/Deploy.gif" border="0" onMouseOver="this.style.cursor='hand'"></a>
  249.                     </td>
  250.                     <td valign="center" align="center" class="Normal">
  251. <%
  252.                         'Only display the link to the reports if the survey is not in design mode and there is at least one response
  253.                         If rsSurveys("status") <> SUR_STATUS_DESIGN And CLng(rsSurveys("response_count")) > 0 Then
  254. %>                
  255.                             <table width="100%" cellpadding="0" cellspacing="0" border="0">
  256.                                 <tr>
  257.                                     <td width="55%" align="center">
  258.                                         <a href="ResultsOverview.asp?DisplayHeader=<%=SUR_BOOLEAN_POSITIVE_DISPLAY%>&SurveyID=<%=rsSurveys("survey_id")%>"><img alt="View the results of your survey" border="0" src="Resources/Icons/Analyze.gif" onMouseOver="this.style.cursor='hand'"></a>
  259.                                     </td>
  260.                                     <td valign="top" align="center">
  261.                                         <span class="Normal"><%=rsSurveys("response_count")%></span>
  262.                                     </td>
  263.                                 </tr>
  264.                             </table>
  265. <%
  266.                         Else
  267. %>
  268.                             <table width="100%" cellpadding="0" cellspacing="0" border="0">
  269.                                 <tr>
  270.                                     <td width="55%" align="center">
  271.                                          
  272.                                     </td>
  273.                                     <td valign="top" align="center">
  274.                                         <span class="Normal">0</span>
  275.                                     </td>
  276.                                 </tr>
  277.                             </table>
  278. <%
  279.                         End If
  280. %>                    
  281.                     </td>
  282.                     <td align="center" class="Normal">
  283.                         <a href="javascript:deleteSurvey('<%=rsSurveys("survey_id")%>');"><img alt="Delete this survey" border="0" src="Resources/Icons/Delete.gif" onMouseOver="this.style.cursor='hand'"></a>
  284.                     </td>
  285.                     <td align="center" class="Normal">
  286. <%
  287.                         If CLng(rsSurveys("response_count")) > 0 Then
  288. %>                
  289.                             <a href="javascript:clearSurvey('<%=rsSurveys("survey_id")%>');"><img alt="Delete responses to this survey" border="0" src="Resources/Icons/Clear.gif" onMouseOver="this.style.cursor='hand'"></a>    
  290. <%
  291.                         Else
  292. %>
  293.                              
  294. <%
  295.                         End If
  296. %>
  297.                     </td>
  298.                 </tr>
  299. <%    
  300.                 'Alternate the colors for the rows in the table
  301.                 If strTableRowColor = "TableRowDarkColor" Then
  302.                     strTableRowColor = "TableRowLightColor"
  303.                 Else
  304.                     strTableRowColor = "TableRowDarkColor"
  305.                 End If
  306.                         
  307.                 rsSurveys.MoveNext
  308.             Loop
  309.         End If
  310. %>
  311.     </table>
  312.  
  313. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  314.  
  315. </body>
  316. </html>
  317. <%
  318.     'Clean up
  319.     rsSurveys.Close
  320.     Set rsSurveys = Nothing
  321.  
  322.     'Ensure that the web server returns the page
  323.     Response.Flush
  324. %>
  325.