home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey_unconfigured / CreateTemplateAction.asp < prev    next >
Text File  |  2006-10-25  |  15KB  |  295 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 creates a new template either from scratch or by
  7. '                      copying an existing template.
  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/adovbs_inc.asp"-->
  19. <!--#Include File="Include/ID_inc.asp"-->
  20. <!--#Include File="Include/CurrentUser_inc.asp"-->
  21. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  22. <!--#Include File="Include/Constants_inc.asp"-->
  23. <!--#Include File="Include/Collection_inc.asp"-->
  24. <%
  25.     'If the user does not have "Create" or "Admin" permission, redirect them to the access denied page.
  26.     If lngUserSecurityLevel <> SUR_SECURITY_LEVEL_CREATE And lngUserSecurityLevel <> SUR_SECURITY_LEVEL_ADMIN Then
  27.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_ADMIN_SECURITY_LEVEL
  28.     End If
  29.  
  30.     Dim strSQL
  31.     Dim conNewTemplate
  32.     Dim lngOriginalTemplateID
  33.     Dim lngNewTemplateID
  34.     Dim rsOriginalTemplate
  35.     Dim strActiveYN
  36.     Dim strTemplateName
  37.     Dim lngUserID
  38.     Dim strAllowUseYN
  39.     Dim strLogoPath
  40.     Dim strLogoAlignment
  41.     Dim strSurveyAlignment
  42.     Dim strDisplayBorderYN
  43.     Dim strBorderColor
  44.     Dim lngBorderWidth
  45.     Dim strSurveyBackgroundColor
  46.     Dim strPageBackgroundColor
  47.     Dim strMatrixHeaderColor
  48.     Dim strMatrixFirstColor
  49.     Dim strMatrixSecondColor
  50.     Dim strProgressFirstColor
  51.     Dim strProgressSecondColor
  52.     Dim strSurveyNameFontColor
  53.     Dim lngSurveyNameFontSize
  54.     Dim strSurveyNameFontWeight
  55.     Dim strSurveyNameFontFamily
  56.     Dim strPageTitleFontColor
  57.     Dim lngPageTitleFontSize
  58.     Dim strPageTitleFontWeight
  59.     Dim strPageTitleFontFamily
  60.     Dim strPageNumberFontColor
  61.     Dim lngPageNumberFontSize
  62.     Dim strPageNumberFontWeight
  63.     Dim strPageNumberFontFamily
  64.     Dim strQuestionTextFontColor
  65.     Dim lngQuestionTextFontSize
  66.     Dim strQuestionTextFontWeight
  67.     Dim strQuestionTextFontFamily
  68.     Dim strQuestionSubtextFontColor
  69.     Dim lngQuestionSubtextFontSize
  70.     Dim strQuestionSubtextFontWeight
  71.     Dim strQuestionSubtextFontFamily
  72.     Dim strHTMLTop
  73.     Dim strHTMLBottom
  74.     Dim strNavigationLinkFontColor
  75.     Dim lngNavigationLinkFontSize
  76.     Dim strNavigationLinkFontWeight
  77.     Dim strNavigationLinkFontFamily
  78.     Dim strNavigationBackButtonPath
  79.     Dim strNavigationBackLinkText
  80.     Dim strNavigationNextButtonPath
  81.     Dim strNavigationNextLinkText
  82.     Dim strNavigationCancelButtonPath
  83.     Dim strNavigationCancelLinkText
  84.     Dim strNavigationDoneButtonPath
  85.     Dim strNavigationDoneLinkText
  86.             
  87.     'Initialization
  88.     Set rsOriginalTemplate = Server.CreateObject("ADODB.Recordset")
  89.     Set conNewTemplate = Server.CreateObject("ADODB.Connection")
  90.     conNewTemplate.Open SURVEY_APP_CONNECTION
  91.     lngNewTemplateID = ID_GetNextAvailableID("SurveyGenerationTemplate")
  92.     lngUserID = GetUserID()
  93.  
  94.     'Set the values for all fields in the template based on whether this is a copy or a new template
  95.     If CLng(Request.Form("optType")) = SUR_CREATE_TEMPLATE_FROM_SCRATCH Then
  96.         strActiveYN = SUR_BOOLEAN_POSITIVE
  97.         strTemplateName = Request.Form("txtTemplateName")
  98.         strAllowUseYN = SUR_BOOLEAN_NEGATIVE
  99.         strLogoPath = ""
  100.         strLogoAlignment = SUR_LOGO_ALIGNMENT_LEFT
  101.         strSurveyAlignment = SUR_SURVEY_ALIGNMENT_CENTER
  102.         strDisplayBorderYN = SUR_BOOLEAN_POSITIVE
  103.         strBorderColor = SUR_DEFAULT_BORDER_COLOR
  104.         lngBorderWidth = SUR_DEFAULT_BORDER_WIDTH
  105.         strSurveyBackgroundColor = SUR_DEFAULT_SURVEY_BACKGROUND_COLOR
  106.         strPageBackgroundColor = SUR_DEFAULT_PAGE_BACKGROUND_COLOR
  107.         strMatrixHeaderColor = SUR_COLOR_MEDIUM_GRAY_BACKGROUND
  108.         strMatrixFirstColor = SUR_COLOR_MEDIUM_GRAY_BACKGROUND
  109.         strMatrixSecondColor = SUR_COLOR_LIGHT_GRAY_BACKGROUND
  110.         strSurveyNameFontColor = SUR_DEFAULT_FONT_COLOR
  111.         lngSurveyNameFontSize = "18"
  112.         strSurveyNameFontWeight = SUR_FONT_WEIGHT_BOLD
  113.         strSurveyNameFontFamily = SUR_DEFAULT_FONT_FAMILY
  114.         strPageTitleFontColor = SUR_DEFAULT_FONT_COLOR
  115.         lngPageTitleFontSize = "16"
  116.         strPageTitleFontWeight = SUR_FONT_WEIGHT_BOLD
  117.         strPageTitleFontFamily = SUR_DEFAULT_FONT_FAMILY
  118.         strPageNumberFontColor = SUR_DEFAULT_FONT_COLOR
  119.         lngPageNumberFontSize = "12"
  120.         strPageNumberFontWeight = SUR_FONT_WEIGHT_BOLD
  121.         strPageNumberFontFamily = SUR_DEFAULT_FONT_FAMILY
  122.         strQuestionTextFontColor = SUR_DEFAULT_FONT_COLOR
  123.         lngQuestionTextFontSize = "12"
  124.         strQuestionTextFontWeight = SUR_FONT_WEIGHT_NORMAL
  125.         strQuestionTextFontFamily = SUR_DEFAULT_FONT_FAMILY
  126.         strQuestionSubtextFontColor = SUR_DEFAULT_FONT_COLOR
  127.         lngQuestionSubtextFontSize = "10"
  128.         strQuestionSubtextFontWeight = SUR_FONT_WEIGHT_NORMAL
  129.         strQuestionSubtextFontFamily = SUR_DEFAULT_FONT_FAMILY
  130.         strHTMLTop = ""
  131.         strHTMLBottom = ""
  132.         strNavigationLinkFontColor = SUR_DEFAULT_FONT_COLOR
  133.         lngNavigationLinkFontSize = "14"
  134.         strNavigationLinkFontWeight = SUR_FONT_WEIGHT_NORMAL
  135.         strNavigationLinkFontFamily = SUR_DEFAULT_FONT_FAMILY
  136.         strNavigationBackButtonPath = "Resources/SurveyButtons/Back.gif"
  137.         strNavigationBackLinkText = ""
  138.         strNavigationNextButtonPath = "Resources/SurveyButtons/Next.gif"
  139.         strNavigationNextLinkText = ""
  140.         strNavigationDoneButtonPath = "Resources/SurveyButtons/Done.gif"
  141.         strNavigationDoneLinkText = ""
  142.         strNavigationCancelButtonPath = "Resources/SurveyButtons/Cancel.gif"
  143.         strNavigationCancelLinkText = ""
  144.     Else 'SUR_CREATE_TEMPLATE_FROM_EXISTING
  145.         'Load the existing data from the database
  146.         strSQL = "SELECT active_yn, template_name, user_id, allow_use_yn, logo_path, logo_alignment, " & _
  147.                     "survey_alignment, display_border_yn, border_color, border_width, survey_background_color, " & _
  148.                     "page_background_color, matrix_header_color, matrix_first_color, matrix_second_color, survey_name_font_color, " & _
  149.                     "progress_first_color, progress_second_color, survey_name_font_size, survey_name_font_weight, " & _
  150.                     "survey_name_font_family, page_title_font_color, page_title_font_size, page_title_font_weight, " & _
  151.                     "page_title_font_family, page_number_font_color, page_number_font_size, page_number_font_weight, " & _
  152.                     "page_number_font_family, question_text_font_color, question_text_font_size, question_text_font_weight, " & _
  153.                     "question_text_font_family, question_subtext_font_color, question_subtext_font_size, " & _
  154.                     "question_subtext_font_weight, question_subtext_font_family, navigation_link_font_color, " & _
  155.                     "navigation_link_font_size, navigation_link_font_weight, navigation_link_font_family, html_top, html_bottom, " & _
  156.                     "navigation_back_button_path, navigation_back_link_text, navigation_next_button_path, navigation_next_link_text, " & _
  157.                     "navigation_cancel_button_path, navigation_cancel_link_text, navigation_done_button_path, navigation_done_link_text " & _
  158.                   "FROM sur_template " & _
  159.                   "WHERE template_id = " & Request.Form("cboTemplate")
  160.         rsOriginalTemplate.Open ConvertSQL(strSQL), SURVEY_APP_CONNECTION, adOpenForwardOnly, adLockReadOnly, adCmdText
  161.         rsOriginalTemplate.MoveFirst
  162.  
  163.         'Capture all of the fields in local variables
  164.         strActiveYN = rsOriginalTemplate("active_yn")
  165.         strTemplateName = Request.Form("txtTemplateName")
  166.         strAllowUseYN = rsOriginalTemplate("allow_use_yn")
  167.         strLogoPath = rsOriginalTemplate("logo_path")
  168.         strLogoAlignment = rsOriginalTemplate("logo_alignment")
  169.         strSurveyAlignment = rsOriginalTemplate("survey_alignment")
  170.         strDisplayBorderYN = rsOriginalTemplate("display_border_yn")
  171.         strBorderColor = rsOriginalTemplate("border_color")
  172.         lngBorderWidth = rsOriginalTemplate("border_width")
  173.         strSurveyBackgroundColor = rsOriginalTemplate("survey_background_color")
  174.         strPageBackgroundColor = rsOriginalTemplate("page_background_color")
  175.         strMatrixHeaderColor = rsOriginalTemplate("matrix_header_color")
  176.         strMatrixFirstColor = rsOriginalTemplate("matrix_first_color")
  177.         strMatrixSecondColor = rsOriginalTemplate("matrix_second_color")
  178.         strProgressFirstColor = rsOriginalTemplate("progress_first_color")
  179.         strProgressSecondColor = rsOriginalTemplate("progress_second_color")
  180.         strSurveyNameFontColor = rsOriginalTemplate("survey_name_font_color")
  181.         lngSurveyNameFontSize = rsOriginalTemplate("survey_name_font_size")
  182.         strSurveyNameFontWeight = rsOriginalTemplate("survey_name_font_weight")
  183.         strSurveyNameFontFamily = rsOriginalTemplate("survey_name_font_family")
  184.         strPageTitleFontColor = rsOriginalTemplate("page_title_font_color")
  185.         lngPageTitleFontSize = rsOriginalTemplate("page_title_font_size")
  186.         strPageTitleFontWeight = rsOriginalTemplate("page_title_font_weight")
  187.         strPageTitleFontFamily = rsOriginalTemplate("page_title_font_family")
  188.         strPageNumberFontColor = rsOriginalTemplate("page_number_font_color")
  189.         lngPageNumberFontSize = rsOriginalTemplate("page_number_font_size")
  190.         strPageNumberFontWeight = rsOriginalTemplate("page_number_font_weight")
  191.         strPageNumberFontFamily = rsOriginalTemplate("page_number_font_family")
  192.         strQuestionTextFontColor = rsOriginalTemplate("question_text_font_color")
  193.         lngQuestionTextFontSize = rsOriginalTemplate("question_text_font_size")
  194.         strQuestionTextFontWeight = rsOriginalTemplate("question_text_font_weight")
  195.         strQuestionTextFontFamily = rsOriginalTemplate("question_text_font_family")
  196.         strQuestionSubtextFontColor = rsOriginalTemplate("question_subtext_font_color")
  197.         lngQuestionSubtextFontSize = rsOriginalTemplate("question_subtext_font_size")
  198.         strQuestionSubtextFontWeight = rsOriginalTemplate("question_subtext_font_weight")
  199.         strQuestionSubtextFontFamily = rsOriginalTemplate("question_subtext_font_family")
  200.         strNavigationLinkFontColor = rsOriginalTemplate("navigation_link_font_color")
  201.         lngNavigationLinkFontSize = rsOriginalTemplate("navigation_link_font_size")
  202.         strNavigationLinkFontWeight = rsOriginalTemplate("navigation_link_font_weight")
  203.         strNavigationLinkFontFamily = rsOriginalTemplate("navigation_link_font_family")
  204.         strHTMLTop = rsOriginalTemplate("html_top")
  205.         strHTMLBottom = rsOriginalTemplate("html_bottom")
  206.         strNavigationBackButtonPath = rsOriginalTemplate("navigation_back_button_path")
  207.         strNavigationBackLinkText = rsOriginalTemplate("navigation_back_link_text")
  208.         strNavigationNextButtonPath = rsOriginalTemplate("navigation_next_button_path")
  209.         strNavigationNextLinkText = rsOriginalTemplate("navigation_next_link_text")
  210.         strNavigationCancelButtonPath = rsOriginalTemplate("navigation_cancel_button_path")
  211.         strNavigationCancelLinkText = rsOriginalTemplate("navigation_cancel_link_text")
  212.         strNavigationDoneButtonPath = rsOriginalTemplate("navigation_done_button_path")
  213.         strNavigationDoneLinkText = rsOriginalTemplate("navigation_done_link_text")
  214.             
  215.         'Clean up
  216.         rsOriginalTemplate.Close
  217.         Set rsOriginalTemplate = Nothing
  218.  
  219.     End If
  220.  
  221.     'Create the new template using all of the values set above
  222.     strSQL = "INSERT INTO sur_template(template_id, active_yn, template_name, user_id, allow_use_yn, " & _
  223.                 "logo_path, logo_alignment, survey_alignment, display_border_yn, border_color, border_width, survey_background_color, " & _
  224.                 "page_background_color, matrix_header_color, matrix_first_color, " & _
  225.                 "matrix_second_color, progress_first_color, progress_second_color, survey_name_font_color, " & _
  226.                 "survey_name_font_size, survey_name_font_weight, survey_name_font_family, page_title_font_color, " & _
  227.                 "page_title_font_size, page_title_font_weight, page_title_font_family, page_number_font_color, " & _
  228.                 "page_number_font_size, page_number_font_weight, page_number_font_family, question_text_font_color, " & _
  229.                 "question_text_font_size, question_text_font_weight, question_text_font_family, question_subtext_font_color, " & _
  230.                 "question_subtext_font_size, question_subtext_font_weight, question_subtext_font_family, " & _
  231.                 "navigation_link_font_color, navigation_link_font_size, navigation_link_font_weight, " & _
  232.                 "navigation_link_font_family, html_top, html_bottom, navigation_back_button_path, navigation_back_link_text, " & _
  233.                 "navigation_next_button_path, navigation_next_link_text, navigation_cancel_button_path, " & _
  234.                 "navigation_cancel_link_text, navigation_done_button_path, navigation_done_link_text) " & _
  235.              "VALUES(" & lngNewTemplateID & ", " & _
  236.                 SQLEncode(strActiveYN) & ", " & _
  237.                 SQLEncode(strTemplateName) & ", " & _
  238.                 lngUserID & ", " & _
  239.                 SQLEncode(strAllowUseYN) & ", " & _
  240.                 SQLEncode(strLogoPath) & ", " & _
  241.                 SQLEncode(strLogoAlignment) & ", " & _
  242.                 SQLEncode(strSurveyAlignment) & ", " & _
  243.                 SQLEncode(strDisplayBorderYN) & ", " & _
  244.                 SQLEncode(strBorderColor) & ", " & _
  245.                 lngBorderWidth & ", " & _
  246.                 SQLEncode(strSurveyBackgroundColor) & ", " & _
  247.                 SQLEncode(strPageBackgroundColor) & ", " & _
  248.                 SQLEncode(strMatrixHeaderColor) & ", " & _
  249.                 SQLEncode(strMatrixFirstColor) & ", " & _
  250.                 SQLEncode(strMatrixSecondColor) & ", " & _
  251.                 SQLEncode(SUR_DEFAULT_PROGRESS_FIRST_COLOR) & ", " & _
  252.                 SQLEncode(SUR_DEFAULT_PROGRESS_SECOND_COLOR) & ", " & _
  253.                 SQLEncode(strSurveyNameFontColor) & ", " & _
  254.                 lngSurveyNameFontSize & ", " & _
  255.                 SQLEncode(strSurveyNameFontWeight) & ", " & _
  256.                 SQLEncode(strSurveyNameFontFamily) & ", " & _
  257.                 SQLEncode(strPageTitleFontColor) & ", " & _
  258.                 lngPageTitleFontSize & ", " & _
  259.                 SQLEncode(strPageTitleFontWeight) & ", " & _
  260.                 SQLEncode(strPageTitleFontFamily) & ", " & _
  261.                 SQLEncode(strPageNumberFontColor) & ", " & _
  262.                 lngPageNumberFontSize & ", " & _
  263.                 SQLEncode(strPageNumberFontWeight) & ", " & _
  264.                 SQLEncode(strPageNumberFontFamily) & ", " & _
  265.                 SQLEncode(strQuestionTextFontColor) & ", " & _
  266.                 lngQuestionTextFontSize & ", " & _
  267.                 SQLEncode(strQuestionTextFontWeight) & ", " & _
  268.                 SQLEncode(strQuestionTextFontFamily) & ", " & _
  269.                 SQLEncode(strQuestionSubtextFontColor) & ", " & _
  270.                 lngQuestionSubtextFontSize & ", " & _
  271.                 SQLEncode(strQuestionSubtextFontWeight) & ", " & _
  272.                 SQLEncode(strQuestionSubtextFontFamily) & ", " & _
  273.                 SQLEncode(strNavigationLinkFontColor) & ", " & _
  274.                 lngNavigationLinkFontSize & ", " & _
  275.                 SQLEncode(strNavigationLinkFontWeight) & ", " & _
  276.                 SQLEncode(strNavigationLinkFontFamily) & ", " & _
  277.                 SQLEncode(strHTMLTop) & ", " & _
  278.                 SQLEncode(strHTMLBottom) & ", " & _
  279.                 SQLEncode(strNavigationBackButtonPath) & ", " & _
  280.                 SQLEncode(strNavigationBackLinkText) & ", " & _
  281.                 SQLEncode(strNavigationNextButtonPath) & ", " & _
  282.                 SQLEncode(strNavigationNextLinkText) & ", " & _
  283.                 SQLEncode(strNavigationCancelButtonPath) & ", " & _
  284.                 SQLEncode(strNavigationCancelLinkText) & ", " & _
  285.                 SQLEncode(strNavigationDoneButtonPath) & ", " & _
  286.                 SQLEncode(strNavigationDoneLinkText) & ")"
  287.     conNewTemplate.Execute ConvertSQL(strSQL), , adCmdText
  288.  
  289.     'Clean up
  290.     conNewTemplate.Close
  291.     Set conNewTemplate = Nothing
  292.  
  293.     'Redirect to the template page for the template just created
  294.     Response.Redirect "Template.asp?TemplateID=" & lngNewTemplateID
  295. %>