Don't like ads? PRO users don't see any ads ;-)
Guest

Assign Reviewer

By: aparker81 on Nov 22nd, 2011  |  syntax: ColdFusion  |  size: 10.00 KB  |  hits: 93  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <cfsilent>
  2.  
  3.         <!--- Param FORM variables. --->
  4.         <cfparam name="URL.reg" type="string" default="" />
  5.         <cfparam name="FORM.proposal" type="string" default="" />
  6.         <cfparam name="FORM.reviewerOne" type="string" default="" />
  7.         <cfparam name="FORM.optionsA" type="string" default="" />
  8.         <cfparam name="FORM.optionsB" type="string" default="" />
  9.  
  10.  
  11.  
  12.  
  13. <cfquery name="getProposals" datasource="myDSN">
  14.         SELECT proposalID, title, abstract, description, objectives
  15.         FROM ecMooreProposals
  16.         ORDER BY title asc
  17. </cfquery>
  18.  
  19.  
  20.         <cfquery name="viewProposals" datasource="myDSN">
  21.         SELECT ecMooreProposals.proposalID, ecMooreProposals.title, ecMooreProposals.abstract, ecMooreProposals.description, ecMooreProposals.objectives
  22.         FROM ecMooreProposals
  23.         </cfquery>
  24.  
  25.  
  26.  
  27.  
  28.         <cfquery name="qGetProposals" datasource="myDSN">
  29.                 select proposalID, title
  30.                 from ecmooreProposals
  31.                 order by title asc
  32.         </cfquery>
  33.        
  34.         <cfquery name="qGetReviewers" datasource="myDSN">
  35.                 select username, firstname, lastname, role
  36.                 from ecMooreACL
  37.                 where username <> <cfqueryparam cfsqltype="cf_sql_varchar" value="jabeasl1"> or username <> <cfqueryparam cfsqltype="cf_sql_varchar" value="langsa">
  38.         </cfquery>
  39.  
  40.         <!---
  41.                 For the form submission flag, since we are asking
  42.                 it to be of type numeric, we have to catch the
  43.                 CFParam in case someone has hacked the HTML and
  44.                 altered the value being sent (a non-numeric value
  45.                 will throw a ColdFusion error).
  46.         --->
  47.         <cftry>
  48.                 <cfparam
  49.                         name="FORM.submitted"
  50.                         type="numeric"
  51.                         default="0"
  52.                         />
  53.  
  54.                 <!--- Catch CFParam data type errors. --->
  55.                 <cfcatch>
  56.                         <cfset FORM.submitted = 0 />
  57.                 </cfcatch>
  58.         </cftry>
  59.  
  60.  
  61.         <!--- Define an array to catch the form errors. --->
  62.         <cfset arrErrors = ArrayNew( 1 ) />
  63.  
  64.  
  65.         <!--- Check to see if the form has been submitted. --->
  66.         <cfif FORM.submitted>
  67.  
  68.                 <!---
  69.                         Now that the form has been submitted, we need
  70.                         to validate the data.
  71.                 --->
  72.                 <cfif NOT Len( FORM.proposal )>
  73.                         <cfset ArrayAppend(
  74.                                 arrErrors,
  75.                                 "Please select a proposal to assign a reviewer."
  76.                                 ) />
  77.                 </cfif>
  78.  
  79.                 <cfif NOT Len( FORM.reviewerOne )>
  80.                         <cfset ArrayAppend(
  81.                                 arrErrors,
  82.                                 "Please select the first reviewer.  It should only be Jennifer Beasley."
  83.                                 ) />
  84.                 </cfif>
  85.  
  86.                 <!--- Validate first name. --->
  87.                 <cfif NOT Len( FORM.optionsA )>
  88.                         <cfset ArrayAppend(
  89.                                 arrErrors,
  90.                                 "Please select the second reviewer."
  91.                                 ) />
  92.                 </cfif>
  93.  
  94.                 <!--- Validate last name. --->
  95.                 <cfif NOT Len( FORM.optionsB )>
  96.                         <cfset ArrayAppend(
  97.                                 arrErrors,
  98.                                 "Please select the third reviewer."
  99.                                 ) />
  100.                 </cfif>
  101.  
  102.                 <!---
  103.                         Now that we have validated our form data, let's
  104.                         check to see if there are any form validation
  105.                         errors. Only if there are no errors do w want to
  106.                         continue processing the data - otherwise, we want
  107.                         to skip this next part and let the form re-render.
  108.                 --->
  109.                 <cfif NOT ArrayLen( arrErrors )>
  110.                
  111.                         <cfquery name="qAddFirstReviewer" datasource="myDSN">
  112.                                 INSERT INTO ecMooreProposalReviews (proposalID,
  113.                                                                                 reviewerID,
  114.                                                                                 completed)
  115.                                                                                                        
  116.                                 VALUES ('#form.proposal#',
  117.                                                 '#form.reviewerOne#',
  118.                                                 'no')
  119.                         </cfquery>
  120.                        
  121.                         <cfquery name="qAddSecondReviewer" datasource="myDSN">
  122.                                 INSERT INTO ecMooreProposalReviews (proposalID,
  123.                                                                                 reviewerID,
  124.                                                                                 completed)
  125.                                                                                
  126.                                 VALUES ('#form.proposal#',
  127.                                                 '#form.optionsA#',
  128.                                                 'no')
  129.                         </cfquery>                                                                     
  130.                        
  131.                         <cfquery name="qAddThirdReviewer" datasource="myDSN">
  132.                                 INSERT INTO ecMooreProposalReviews (proposalID,
  133.                                                                                 reviewerID,
  134.                                                                                 completed)
  135.                                                
  136.                                 VALUES ('#form.proposal#',
  137.                                                 '#form.optionsB#',
  138.                                                 'no')
  139.                         </cfquery>
  140.                        
  141.                         <cfquery name="qAddFourthReviewer" datasource="myDSN">
  142.                                 INSERT INTO ecMooreProposalReviews (proposalID,
  143.                                                                                 reviewerID,
  144.                                                                                 completed)
  145.                                                
  146.                                 VALUES ('#form.proposal#',
  147.                                                 '#form.optionsC#',
  148.                                                 'no')
  149.                         </cfquery>
  150.                        
  151.                         <!------>                      
  152.                                         <cfmail
  153.                                                 to="you"
  154.                                                 from="me"
  155.                                                 subject="Proposal Reviewer Assignment Submitted"
  156.                                                 type="html">
  157.                                                
  158.                                         <p>Hello,</p>
  159.                                         <p>The following reviewers have been assigned to the listed proposal review:</p>
  160.  
  161.                                         <cfquery name="qMailProposals" datasource="myDSN">
  162.                                                 select proposalID, title
  163.                                                 from ecmooreProposals
  164.                                                 where proposalID = #form.proposal#
  165.                                         </cfquery>
  166.  
  167.                                         <ul>
  168.                                                 <li>#qMailProposals.title#</li>
  169.                                                 <li>#form.reviewerOne#</li>
  170.                                                 <li>#form.optionsA#</li>
  171.                                                 <li>#form.optionsB#</li>
  172.                                                 <li>#form.optionsC#</li>
  173.                                         </ul>
  174.                                 </cfmail>                              
  175.                         <cflocation url="#cgi.SCRIPT_NAME#?reg=y" addtoken="no">
  176.  
  177.                 </cfif>
  178.  
  179.         </cfif>
  180.  
  181. </cfsilent>
  182.  
  183. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  184. <html xmlns="http://www.w3.org/1999/xhtml">
  185. <head>
  186. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  187. <title></title>
  188. <link href="_assets/css/styles.css" rel="stylesheet" type="text/css" />
  189.  
  190. <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
  191. <script type="text/javascript">
  192.         $(document).ready(function() {
  193.                 var firstSelected = null;
  194.                 var secondSelected = null;
  195.                
  196.                 //initally order select lists (this is a bit of cheat, to help later on
  197.                
  198.                
  199. $('#optionsA').change(function() {
  200.     //remove the currently selected option from 2nd/3rd drop down
  201.     var selectedValue = $('#optionsA option:selected')
  202.     if (selectedValue.val() != "") {
  203.         $('#optionsB option[value="' + selectedValue.val() + '"]').remove();
  204.         $('#optionsC option[value="' + selectedValue.val() + '"]').remove();
  205.     }
  206.     else {
  207.         selectedValue = null;
  208.     }
  209.    
  210.     //add previous item back in to 2nd/3rd drop down
  211.     if (firstSelected != null) {
  212.         $('#optionsB').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text()));
  213.         $('#optionsC').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text()));
  214.     }
  215.    
  216.     //save the currently selected value
  217.     firstSelected = selectedValue;
  218. });
  219.  
  220. $('#optionsB').change(function() {
  221.     //remove the currently selected option from 1st/3rd drop down
  222.     var selectedValue = $('#optionsB option:selected')
  223.     if (selectedValue.val() != "") {
  224.         $('#optionsA option[value="' + selectedValue.val() + '"]').remove();
  225.         $('#optionsC option[value="' + selectedValue.val() + '"]').remove();
  226.     }
  227.     else {
  228.         selectedValue = null;
  229.     }
  230.  
  231.     //add previous item back in to 1st/3rd drop down
  232.     if (secondSelected != null) {
  233.         $('#optionsA').append($('<option>', { value : secondSelected.val() }).text(secondSelected.text()));
  234.         $('#optionsC').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text()));
  235.     }
  236.    
  237.     //save the currently selected value
  238.     secondSelected = selectedValue;
  239. });
  240.         });
  241. </script>
  242.  
  243. </head>
  244. <body>
  245.         <div id="container">
  246.                 <div id="banner">
  247.                         <h1>Proposal Overview</h1>
  248.                                 <cfif session.role EQ "admin"><p class="right"><a href="adminDash.cfm">Go To Admin Dash</a></p></cfif>
  249.                                 <p class="right"><a href="logout.cfm">Logout <cfoutput>#session.username#</cfoutput></a></p>
  250.                 </div>
  251.        
  252.                         <cfoutput>
  253.                                 <!--- Check to see if we have any form errors. --->
  254.                                 <cfif ArrayLen( arrErrors )>
  255.                                         <h3>
  256.                                                 Please review the following:
  257.                                         </h3>
  258.                                         <ul>
  259.                                                 <cfloop
  260.                                                         index="intError"
  261.                                                         from="1"
  262.                                                         to="#ArrayLen( arrErrors )#"
  263.                                                         step="1">
  264.                  
  265.                                                         <li>
  266.                                                                 #arrErrors[ intError ]#
  267.                                                         </li>
  268.                                                 </cfloop>
  269.                                         </ul>
  270.                                 </cfif>
  271.                         </cfoutput>
  272.        
  273.                                 <cfif url.reg EQ "y">
  274.                                         <p>Proposal assigned.</p>
  275.                                         <p><a href="#cgi.SCRIPT_NAME#">Assign another proposal.</a></p>
  276.                                 <cfelse>
  277.                                
  278.                                         <cfif isDefined("url.id")>
  279.                                                 <cfquery name="viewProposal" datasource="myDSN">
  280.                                                         SELECT DISTINCT(ecMooreProposals.proposalID), ecMooreProposals.title, ecMooreProposals.abstract, ecMooreProposals.description, ecMooreProposals.objectives, ecMooreProposalReviews.proposalID, ecMooreProposalReviews.reviewerID
  281.                                                         FROM ecMooreProposals
  282.                                                         INNER JOIN ecMooreProposalReviews on ecMooreProposals.proposalID = ecMooreProposalReviews.proposalID
  283.                                                         WHERE ecMooreProposals.proposalID = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
  284.                                                 </cfquery>
  285.  
  286.                                                 <div id="contentWide">
  287.                                                         <form action="#CGI.script_name#" method="post" enctype="multipart/form-data">
  288.                                                                 <!--- Our form submission flag. --->
  289.                                                                 <input type="hidden" name="submitted" value="1" />
  290.                                                                 <fieldset>
  291.                                                                         <cfoutput query="viewProposal">
  292.                                                                         <h4>#title#</h4>
  293.                                                                                 <ol>
  294.                                                                                                                                        
  295.                                                                                         <li>
  296.                                                                                                 <label for="reviewer">Select 2<sup>nd</sup> Reviewer:</label>
  297.                                                                                                         <select name="optionsA" id="optionsA">
  298.                                                                                 <option value="">&ndash; select &ndash;</option>
  299.                                                                                 <cfloop>
  300.                                                                                         <option value="#reviewerID#">#reviewerID#</option>
  301.                                                                                 </cfloop>
  302.                                                                         </select>
  303.                                                                                         </li>
  304.                                                        
  305.                                                                                         <li>
  306.                                                                                                 <label for="reviewer">Select 3<sup>rd</sup> Reviewer:</label>
  307.                                                                                                         <select name="optionsB" id="optionsB">
  308.                                                                                                                 <option value="">&ndash; select &ndash;</option>
  309.                                                                                                                         <option value="#reviewerID#">#reviewerID#</option>
  310.                                                                                                         </select>
  311.                                                                                         </li>
  312.                                                        
  313.                                                                                         <li>
  314.                                                                                                 <label for="reviewer">Select 4<sup>th</sup> Reviewer:</label>
  315.                                                                                                         <select name="optionsC" id="optionsC">
  316.                                                                                                                 <option value="">&ndash; select &ndash;</option>
  317.                                                                                                                         <option value="#reviewerID#">#reviewerID#</option>
  318.                                
  319.                                                                                                         </select>
  320.                                                                                         </li>
  321.                                                                                 </ol>
  322.                                                                         </cfoutput>
  323.                                                                         </fieldset>
  324.                                                                         <input type="submit" value="Save Reviewer">
  325.                                                         </form>
  326.                                                 </div>
  327.                                        
  328.                                         <cfelse>
  329.                                                 <cfoutput query="viewProposals">
  330.                                                         <h4><a href="#cgi.SCRIPT_NAME#?id=#proposalID#">#title#</a></h4>
  331.                                                 </cfoutput>
  332.                                 </cfif>
  333.                                
  334.                         </cfif>
  335.  
  336.        
  337.                 <div id="footer"></div>
  338.         </div>
  339.                
  340. </body>
  341. </html>
  342.  
  343.