Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <cfsilent>
- <!--- Param FORM variables. --->
- <cfparam name="URL.reg" type="string" default="" />
- <cfparam name="FORM.proposal" type="string" default="" />
- <cfparam name="FORM.reviewerOne" type="string" default="" />
- <cfparam name="FORM.optionsA" type="string" default="" />
- <cfparam name="FORM.optionsB" type="string" default="" />
- <cfquery name="getProposals" datasource="myDSN">
- SELECT proposalID, title, abstract, description, objectives
- FROM ecMooreProposals
- ORDER BY title asc
- </cfquery>
- <cfquery name="viewProposals" datasource="myDSN">
- SELECT ecMooreProposals.proposalID, ecMooreProposals.title, ecMooreProposals.abstract, ecMooreProposals.description, ecMooreProposals.objectives
- FROM ecMooreProposals
- </cfquery>
- <cfquery name="qGetProposals" datasource="myDSN">
- select proposalID, title
- from ecmooreProposals
- order by title asc
- </cfquery>
- <cfquery name="qGetReviewers" datasource="myDSN">
- select username, firstname, lastname, role
- from ecMooreACL
- where username <> <cfqueryparam cfsqltype="cf_sql_varchar" value="jabeasl1"> or username <> <cfqueryparam cfsqltype="cf_sql_varchar" value="langsa">
- </cfquery>
- <!---
- For the form submission flag, since we are asking
- it to be of type numeric, we have to catch the
- CFParam in case someone has hacked the HTML and
- altered the value being sent (a non-numeric value
- will throw a ColdFusion error).
- --->
- <cftry>
- <cfparam
- name="FORM.submitted"
- type="numeric"
- default="0"
- />
- <!--- Catch CFParam data type errors. --->
- <cfcatch>
- <cfset FORM.submitted = 0 />
- </cfcatch>
- </cftry>
- <!--- Define an array to catch the form errors. --->
- <cfset arrErrors = ArrayNew( 1 ) />
- <!--- Check to see if the form has been submitted. --->
- <cfif FORM.submitted>
- <!---
- Now that the form has been submitted, we need
- to validate the data.
- --->
- <cfif NOT Len( FORM.proposal )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select a proposal to assign a reviewer."
- ) />
- </cfif>
- <cfif NOT Len( FORM.reviewerOne )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select the first reviewer. It should only be Jennifer Beasley."
- ) />
- </cfif>
- <!--- Validate first name. --->
- <cfif NOT Len( FORM.optionsA )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select the second reviewer."
- ) />
- </cfif>
- <!--- Validate last name. --->
- <cfif NOT Len( FORM.optionsB )>
- <cfset ArrayAppend(
- arrErrors,
- "Please select the third reviewer."
- ) />
- </cfif>
- <!---
- Now that we have validated our form data, let's
- check to see if there are any form validation
- errors. Only if there are no errors do w want to
- continue processing the data - otherwise, we want
- to skip this next part and let the form re-render.
- --->
- <cfif NOT ArrayLen( arrErrors )>
- <cfquery name="qAddFirstReviewer" datasource="myDSN">
- INSERT INTO ecMooreProposalReviews (proposalID,
- reviewerID,
- completed)
- VALUES ('#form.proposal#',
- '#form.reviewerOne#',
- 'no')
- </cfquery>
- <cfquery name="qAddSecondReviewer" datasource="myDSN">
- INSERT INTO ecMooreProposalReviews (proposalID,
- reviewerID,
- completed)
- VALUES ('#form.proposal#',
- '#form.optionsA#',
- 'no')
- </cfquery>
- <cfquery name="qAddThirdReviewer" datasource="myDSN">
- INSERT INTO ecMooreProposalReviews (proposalID,
- reviewerID,
- completed)
- VALUES ('#form.proposal#',
- '#form.optionsB#',
- 'no')
- </cfquery>
- <cfquery name="qAddFourthReviewer" datasource="myDSN">
- INSERT INTO ecMooreProposalReviews (proposalID,
- reviewerID,
- completed)
- VALUES ('#form.proposal#',
- '#form.optionsC#',
- 'no')
- </cfquery>
- <!------>
- <cfmail
- to="you"
- from="me"
- subject="Proposal Reviewer Assignment Submitted"
- type="html">
- <p>Hello,</p>
- <p>The following reviewers have been assigned to the listed proposal review:</p>
- <cfquery name="qMailProposals" datasource="myDSN">
- select proposalID, title
- from ecmooreProposals
- where proposalID = #form.proposal#
- </cfquery>
- <ul>
- <li>#qMailProposals.title#</li>
- <li>#form.reviewerOne#</li>
- <li>#form.optionsA#</li>
- <li>#form.optionsB#</li>
- <li>#form.optionsC#</li>
- </ul>
- </cfmail>
- <cflocation url="#cgi.SCRIPT_NAME#?reg=y" addtoken="no">
- </cfif>
- </cfif>
- </cfsilent>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
- <title></title>
- <link href="_assets/css/styles.css" rel="stylesheet" type="text/css" />
- <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.js"></script>
- <script type="text/javascript">
- $(document).ready(function() {
- var firstSelected = null;
- var secondSelected = null;
- //initally order select lists (this is a bit of cheat, to help later on
- $('#optionsA').change(function() {
- //remove the currently selected option from 2nd/3rd drop down
- var selectedValue = $('#optionsA option:selected')
- if (selectedValue.val() != "") {
- $('#optionsB option[value="' + selectedValue.val() + '"]').remove();
- $('#optionsC option[value="' + selectedValue.val() + '"]').remove();
- }
- else {
- selectedValue = null;
- }
- //add previous item back in to 2nd/3rd drop down
- if (firstSelected != null) {
- $('#optionsB').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text()));
- $('#optionsC').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text()));
- }
- //save the currently selected value
- firstSelected = selectedValue;
- });
- $('#optionsB').change(function() {
- //remove the currently selected option from 1st/3rd drop down
- var selectedValue = $('#optionsB option:selected')
- if (selectedValue.val() != "") {
- $('#optionsA option[value="' + selectedValue.val() + '"]').remove();
- $('#optionsC option[value="' + selectedValue.val() + '"]').remove();
- }
- else {
- selectedValue = null;
- }
- //add previous item back in to 1st/3rd drop down
- if (secondSelected != null) {
- $('#optionsA').append($('<option>', { value : secondSelected.val() }).text(secondSelected.text()));
- $('#optionsC').append($('<option>', { value : firstSelected.val() }).text(firstSelected.text()));
- }
- //save the currently selected value
- secondSelected = selectedValue;
- });
- });
- </script>
- </head>
- <body>
- <div id="container">
- <div id="banner">
- <h1>Proposal Overview</h1>
- <cfif session.role EQ "admin"><p class="right"><a href="adminDash.cfm">Go To Admin Dash</a></p></cfif>
- <p class="right"><a href="logout.cfm">Logout <cfoutput>#session.username#</cfoutput></a></p>
- </div>
- <cfoutput>
- <!--- Check to see if we have any form errors. --->
- <cfif ArrayLen( arrErrors )>
- <h3>
- Please review the following:
- </h3>
- <ul>
- <cfloop
- index="intError"
- from="1"
- to="#ArrayLen( arrErrors )#"
- step="1">
- <li>
- #arrErrors[ intError ]#
- </li>
- </cfloop>
- </ul>
- </cfif>
- </cfoutput>
- <cfif url.reg EQ "y">
- <p>Proposal assigned.</p>
- <p><a href="#cgi.SCRIPT_NAME#">Assign another proposal.</a></p>
- <cfelse>
- <cfif isDefined("url.id")>
- <cfquery name="viewProposal" datasource="myDSN">
- SELECT DISTINCT(ecMooreProposals.proposalID), ecMooreProposals.title, ecMooreProposals.abstract, ecMooreProposals.description, ecMooreProposals.objectives, ecMooreProposalReviews.proposalID, ecMooreProposalReviews.reviewerID
- FROM ecMooreProposals
- INNER JOIN ecMooreProposalReviews on ecMooreProposals.proposalID = ecMooreProposalReviews.proposalID
- WHERE ecMooreProposals.proposalID = <cfqueryparam cfsqltype="cf_sql_integer" value="#url.id#">
- </cfquery>
- <div id="contentWide">
- <form action="#CGI.script_name#" method="post" enctype="multipart/form-data">
- <!--- Our form submission flag. --->
- <input type="hidden" name="submitted" value="1" />
- <fieldset>
- <cfoutput query="viewProposal">
- <h4>#title#</h4>
- <ol>
- <li>
- <label for="reviewer">Select 2<sup>nd</sup> Reviewer:</label>
- <select name="optionsA" id="optionsA">
- <option value="">– select –</option>
- <cfloop>
- <option value="#reviewerID#">#reviewerID#</option>
- </cfloop>
- </select>
- </li>
- <li>
- <label for="reviewer">Select 3<sup>rd</sup> Reviewer:</label>
- <select name="optionsB" id="optionsB">
- <option value="">– select –</option>
- <option value="#reviewerID#">#reviewerID#</option>
- </select>
- </li>
- <li>
- <label for="reviewer">Select 4<sup>th</sup> Reviewer:</label>
- <select name="optionsC" id="optionsC">
- <option value="">– select –</option>
- <option value="#reviewerID#">#reviewerID#</option>
- </select>
- </li>
- </ol>
- </cfoutput>
- </fieldset>
- <input type="submit" value="Save Reviewer">
- </form>
- </div>
- <cfelse>
- <cfoutput query="viewProposals">
- <h4><a href="#cgi.SCRIPT_NAME#?id=#proposalID#">#title#</a></h4>
- </cfoutput>
- </cfif>
- </cfif>
- <div id="footer"></div>
- </div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment