Link to home
Create AccountLog in
Avatar of Albee_J
Albee_J

asked on

ColdFusion Form inserting entries twice

I have a form that is used to add/edit/delete entries. However, it is inserting the entries twice.  Please see form superdeck-add.cfm and the listing.cfc that goes with it.


<cfif IsDefined('FORM.Action')>
<cfparam name="FORM.SuperDeckTitle" default="">	
<cfparam name="FORM.SuperDeckText" default="">
<cfparam name="FORM.SuperdeckCategoryID" default="">
<cfparam name="FORM.Live" default="">
<cfparam name="FORM.ExpireDate" default="">
<cfparam name="FORM.ExpireDate" default="">
<cfparam name="FORM.CompanyID" default="">
<cfparam name="FORM.ContactCompanyName" default="">
<cfparam name="FORM.ContactPhone" default="">
<cfparam name="FORM.ContactDisplayURL" default="">
<cfparam name="FORM.ContactActualURL" default="">
<cfparam name="FORM.ContactEmail" default="">
<cfparam name="FORM.ContactName" default="">
<cfparam name="FORM.SuperDeckImage" default="">
 
		<cfinvoke component="Components.SuperDeck.Listing"
			      method="insertListing"
				  returnvariable="Listing"
				  argumentcollection="#FORM#"		  
					>
		</cfinvoke>
<cfset status = 3>		
</cfif>
 
<cfif IsDefined('FORM.SuperDeckID')>
 
	<cfif IsDefined('FORM.Delete')>
		<cfinvoke component="Components.SuperDeck.Listing"
			      method="deleteListing"
				  returnvariable="Listing">
	 			  <cfinvokeargument name="SuperDeckID" value="#FORM.SuperDeckID#">
		</cfinvoke>
		<cfset status = 1>
	<cfelse>
<cfparam name="FORM.SuperDeckTitle" default="">	
<cfparam name="FORM.SuperDeckText" default="">
<cfparam name="FORM.SuperdeckCategoryID" default="">
<cfparam name="FORM.Live" default="">
<cfparam name="FORM.ExpireDate" default="">
<cfparam name="FORM.CompanyID" default="">
<cfparam name="FORM.ContactCompanyName" default="">
<cfparam name="FORM.ContactPhone" default="">
<cfparam name="FORM.ContactDisplayURL" default="">
<cfparam name="FORM.ContactActualURL" default="">
<cfparam name="FORM.ContactEmail" default="">
<cfparam name="FORM.ContactName" default="">
<cfparam name="FORM.SuperDeckImage" default="">
 
 
		<cfinvoke component="Components.SuperDeck.Listing"
			      method="updateListing"
				  returnvariable="Listing"
				  argumentcollection="#FORM#"		  
					>
		</cfinvoke>
        
		<cfparam name="URL.SuperDeckID" default="#FORM.SuperDeckID#">
        <cfset status = 2>
 
	</cfif>
</cfif>
 
<cfif NOT IsDefined('URL.SuperDeckID')>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getCategories"
	 returnvariable="Categories">
	</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getFFIDcompanies"
	 returnvariable="Companies">
	</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getFFIDcompanies"
	 returnvariable="Companies">
</cfinvoke>	
<cfelse>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getOneListing"
	 returnvariable="Listing">
		<cfif IsDefined('URL.SuperDeckID')>			  
	 <cfinvokeargument name="SuperDeckID" value="#URL.SuperDeckID#">
		 </cfif>
</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getFFIDcompanies"
	 returnvariable="Companies">
		<cfif IsDefined('URL.CompanyID')>			  
	 <cfinvokeargument name="CompanyID" value="#URL.CompanyID#">
		 </cfif>
</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getCategories"
	 returnvariable="Categories">
	</cfinvoke>
</cfif>
 
<cfif IsDefined('URL.SuperDeckID')>
<cf_FFID-Admin-Header pagetitle="SuperDeck Edit Listing">
<cfelse>
<cf_FFID-Admin-Header pagetitle="SuperDeck Add Listing">
</cfif>
 
<cf_FFID-Admin-Sidebar>
 
<!--- Page Title --->
<cfoutput>
<h2>SuperDeck <cfif IsDefined('URL.SuperDeckID')>Edit<cfelse>Add</cfif> Listing</h2>
</cfoutput>
<!--- Page Description --->    
<p>Create or edit a Superdeck listing.</p>
<!--- BEGIN Content--->
<cfif IsDefined('status')>
 
 
<cfswitch expression="#status#">
<cfcase value="2"><p align="center"><font color="#ff0000"><b>Listing has been updated.</b></font><br/><a href="http://www.thefabricator.com/SuperDeck/Listing.cfm?SuperDeckID=<cfoutput>#FORM.SuperDeckID#</cfoutput>">View Live</a></p>
</cfcase>
<cfcase value="1"> <p align="center"><font color="#ff0000"><b>Listing has been removed.</b></font></p>
</cfcase>
<cfcase value="3"><p align="center"><font color="#ff0000"><b>Listing has been added.</b></font></p>
</cfcase>
</cfswitch>
</cfif>
 
<cfparam name="Listing.SuperdeckCategoryID" default="0">
<cfoutput>
<cfform action="Superdeck-Add.cfm" enctype="multipart/form-data">
<table cellpadding="3" cellspacing="0" width="600" border="0">
<td align="right"><b>Company:</b></td>
<td><select name="CompanyID">
<option value="INVALID"></option>
<cfloop query="Companies">
<option value="#Companies.CompanyID#" 
<cfif IsDefined('Listing.CompanyID')>
		<cfif Companies.CompanyID EQ Listing.CompanyID>
			selected
		</cfif>
</cfif>
 
>#Companies.CompanyName# - #Companies.CompanyID#</option>
</cfloop>
</select></td>
</tr>
<tr>
<td align="right"><b>Category:</b></b></td>
<td><select name="SuperdeckCategoryID">
<cfloop query="Categories">
	<option value="#Categories.CategoryID#" <cfif Categories.CategoryID EQ Listing.SuperDeckCategoryID>selected</cfif>>#Categories.CategoryName#</option>
</cfloop>
</select>
</td>
</tr>
              <tr>
                <td align="right"><b>Title:</b></td>
                <td>
                <cfif IsDefined('Listing.SuperdeckTitle')>
                <cfinput name="SuperdeckTitle" type="text" size="67" maxlength="255" required="yes" message="Please provide a Title to your ad." value="#Listing.SuperdeckTitle#">
                <cfelse>
                <cfinput name="SuperdeckTitle" type="text" size="67" maxlength="255" required="yes" message="Please provide a Title to your ad.">
                </cfif></td>
              </tr>
              <tr>
                <td valign="top" align="right"><b>Copy:</b><br />
                    <span class="body10pt"><i>150 words max.</i></span></td>
                <td valign="top"><cfif IsDefined('Listing.SuperDeckText')>
<textarea name="SuperDeckText" id="SuperDeckText" required="yes" rows="6" cols="60"><cfoutput>#Listing.SuperDeckText#</cfoutput></textarea>
<script language="javascript1.2">
  generate_wysiwyg('SuperDeckText');
</script>
 
 
<cfelse>
<textarea name="SuperDeckText" id="SuperDeckText" required="yes" rows="6" cols="60"></textarea>
<script language="javascript1.2">
  generate_wysiwyg('SuperDeckText');
</script>
</cfif></td>
</tr>
 
 
<tr>
<td align="right"><b>Product Photo:</b></td>
<td><cfif IsDefined('Listing.SuperDeckImage') AND len(Listing.SuperDeckImage) GT 0>
<cfoutput><img src="http://www.thefabricator.com/SuperDeck/SuperDeckImages/#Listing.SuperDeckImage#"></cfoutput><br>
<input name="SuperDeckImage" type="file">
<cfelse>
<input name="SuperDeckImage" type="file">
</cfif></td>
</tr>
 
<tr>
<td align="right"><b>Live:</b></td>
<td><cfif IsDefined('Listing.Live')>
<cfif Listing.Live EQ 1>
<cfinput name="Live" type="radio" value="1" id="radio" checked> Yes<br/>
<cfinput name="Live" type="radio" value="0" id="radio"> No 
<cfelse>
<cfinput name="Live" type="radio" value="1" id="radio"> Yes<br/>
<cfinput name="Live" type="radio" value="0" id="radio" checked> No
</cfif>
<cfelse>
<cfinput name="Live" type="radio" value="1" id="radio" checked> Yes<br/>
<cfinput name="Live" type="radio" value="0" id="radio"> No 
</cfif></td>
</tr>
<tr>
<td align="right"><b>Expire Date:</b></td>
<td><cfif IsDefined('Listing.ExpireDate')>
<cfinput name="ExpireDate" type="text" required="yes" maxlength="255" size="10" value="#dateformat(Listing.ExpireDate,'short')#">
<cfelse>
<cfinput name="ExpireDate" type="text" required="yes" maxlength="255" size="10">
</cfif> <i>( M/D/YY format )</i></td>
</tr>
<tr><td colspan="2" class="subhead">Contact Information<hr></td></tr>
<tr>
<td align="right"><b>Company Name:</b></td>
<td><cfif IsDefined('Listing.ContactCompanyName')>
<cfinput name="ContactCompanyName" type="text" required="yes" maxlength="255" size="60" value="#Listing.ContactCompanyName#">
<cfelse>
<cfinput name="ContactCompanyName" type="text" required="yes" maxlength="255" size="60">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Name:</b></td>
<td><cfif IsDefined('Listing.ContactName')>
<cfinput name="ContactName" type="text" required="yes" maxlength="255" size="50" value="#Listing.ContactName#">
<cfelse>
<cfinput name="ContactName" type="text" required="yes" maxlength="255" size="50">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Phone:</b></td>
<td><cfif IsDefined('Listing.ContactPhone')>
<cfinput name="ContactPhone" type="text" required="yes" maxlength="255" size="20" value="#Listing.ContactPhone#">
<cfelse>
<cfinput name="ContactPhone" type="text" required="yes" maxlength="255" size="20">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Email:</b></td>
<td><cfif IsDefined('Listing.ContactEmail')>
<cfinput name="ContactEmail" type="text" required="yes" maxlength="255" size="50" value="#Listing.ContactEmail#">
<cfelse>
<cfinput name="ContactEmail" type="text" required="yes" maxlength="255" size="50">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Display URL:</b></td>
<td><cfif IsDefined('Listing.ContactDisplayURL')>
<cfinput name="ContactDisplayURL" type="text" required="yes" maxlength="255" size="60" value="#Listing.ContactDisplayURL#">
<cfelse>
<cfinput name="ContactDisplayURL" type="text" required="yes" maxlength="255" size="60">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Actual URL:</b></td>
<td><cfif IsDefined('Listing.ContactActualURL')>
<cfinput name="ContactActualURL" type="text" required="yes" maxlength="255" size="60" value="#Listing.ContactActualURL#">
<cfelse>
<cfinput name="ContactActualURL" type="text" required="yes" maxlength="255" size="60">
</cfif></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td><cfif IsDefined('URL.SuperDeckID')>
<input type="Submit" name="Submit" value="Update Listing" id="submit">&nbsp;<input type="Submit" name="Delete" value="Remove Listing" id="submit"><input type="hidden" name="SuperDeckID" value="#URL.SuperDeckID#" id="submit">
<cfelse>
<input type="Submit" name="Submit" id="submit" value="Add Listing"><input type="hidden" name="Action" value="Add" id="submit">
</cfif></td>
</tr>
</table>
 
 
</cfform>
</cfoutput>
 
 
<!--- END Content--->
<cf_FFID-Admin-Footer>

Open in new window

Avatar of rob_lorentz
rob_lorentz

form.superDeckId is defined so when you aren't doing your delete you fall into your else and call listing component a second time.
Avatar of Albee_J

ASKER

What should I do to correct the problem?

Sorry, I'm still pretty new to cf.
ASKER CERTIFIED SOLUTION
Avatar of rob_lorentz
rob_lorentz

Link to home
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
See answer
Avatar of Albee_J

ASKER

I implemented the solution and strangely it is still duplicating
<cfparam name="FORM.SuperDeckTitle" default="">	
<cfparam name="FORM.SuperDeckText" default="">
<cfparam name="FORM.SuperdeckCategoryID" default="">
<cfparam name="FORM.Live" default="">
<cfparam name="FORM.ExpireDate" default="">
<cfparam name="FORM.CompanyID" default="">
<cfparam name="FORM.ContactCompanyName" default="">
<cfparam name="FORM.ContactPhone" default="">
<cfparam name="FORM.ContactDisplayURL" default="">
<cfparam name="FORM.ContactActualURL" default="">
<cfparam name="FORM.ContactEmail" default="">
<cfparam name="FORM.ContactName" default="">
<cfparam name="FORM.SuperDeckImage" default="">
 
<cfparam name = "form.act" default="">
<cfif form.act is "Add Listing">
	<cfinvoke component="Components.SuperDeck.Listing"
		      method="insertListing"
			  returnvariable="Listing"
			  argumentcollection="#FORM#"		  
				>
	</cfinvoke>
	<cfset status = 3>		
<cfelseif form.act is "Remove Listing">
	<cfinvoke component="Components.SuperDeck.Listing"
		      method="deleteListing"
			  returnvariable="Listing">
 			  <cfinvokeargument name="SuperDeckID" value="#FORM.SuperDeckID#">
	</cfinvoke>
	<cfset status = 1>
<cfelseIf form.act is "Update Listing">
	<cfinvoke component="Components.SuperDeck.Listing"
		      method="updateListing"
			  returnvariable="Listing"
			  argumentcollection="#FORM#"		  
				>
	</cfinvoke>
	<cfset status = 2>
</cfif>
 
<cfif NOT IsDefined('URL.SuperDeckID')>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getCategories"
	 returnvariable="Categories">
	</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getFFIDcompanies"
	 returnvariable="Companies">
	</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getFFIDcompanies"
	 returnvariable="Companies">
</cfinvoke>	
<cfelse>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getOneListing"
	 returnvariable="Listing">
		<cfif IsDefined('URL.SuperDeckID')>			  
	 <cfinvokeargument name="SuperDeckID" value="#URL.SuperDeckID#">
		 </cfif>
</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getFFIDcompanies"
	 returnvariable="Companies">
		<cfif IsDefined('URL.CompanyID')>			  
	 <cfinvokeargument name="CompanyID" value="#URL.CompanyID#">
		 </cfif>
</cfinvoke>
<cfinvoke component="Components.SuperDeck.Listing"
	 method="getCategories"
	 returnvariable="Categories">
	</cfinvoke>
</cfif>
 
<cfif IsDefined('URL.SuperDeckID')>
<cf_FFID-Admin-Header pagetitle="SuperDeck Edit Listing">
<cfelse>
<cf_FFID-Admin-Header pagetitle="SuperDeck Add Listing">
</cfif>
 
<cf_FFID-Admin-Sidebar>
 
<!--- Page Title --->
<cfoutput>
<h2>SuperDeck <cfif IsDefined('URL.SuperDeckID')>Edit<cfelse>Add</cfif> Listing</h2>
</cfoutput>
<!--- Page Description --->    
<p>Create or edit a Superdeck listing.</p>
<!--- BEGIN Content--->
<cfif IsDefined('status')>
 
 
<cfswitch expression="#status#">
<cfcase value="2"><p align="center"><font color="#ff0000"><b>Listing has been updated.</b></font><br/><a href="http://www.thefabricator.com/SuperDeck/Listing.cfm?SuperDeckID=<cfoutput>#FORM.SuperDeckID#</cfoutput>">View Live</a></p>
</cfcase>
<cfcase value="1"> <p align="center"><font color="#ff0000"><b>Listing has been removed.</b></font></p>
</cfcase>
<cfcase value="3"><p align="center"><font color="#ff0000"><b>Listing has been added.</b></font></p>
</cfcase>
</cfswitch>
</cfif>
 
<cfparam name="Listing.SuperdeckCategoryID" default="0">
<cfoutput>
<cfform action="Superdeck-Add.cfm" enctype="multipart/form-data">
<table cellpadding="3" cellspacing="0" width="600" border="0">
<td align="right"><b>Company:</b></td>
<td><select name="CompanyID">
<option value="INVALID"></option>
<cfloop query="Companies">
<option value="#Companies.CompanyID#" 
<cfif IsDefined('Listing.CompanyID')>
		<cfif Companies.CompanyID EQ Listing.CompanyID>
			selected
		</cfif>
</cfif>
 
>#Companies.CompanyName# - #Companies.CompanyID#</option>
</cfloop>
</select></td>
</tr>
<tr>
<td align="right"><b>Category:</b></b></td>
<td><select name="SuperdeckCategoryID">
<cfloop query="Categories">
	<option value="#Categories.CategoryID#" <cfif Categories.CategoryID EQ Listing.SuperDeckCategoryID>selected</cfif>>#Categories.CategoryName#</option>
</cfloop>
</select>
</td>
</tr>
              <tr>
                <td align="right"><b>Title:</b></td>
                <td>
                <cfif IsDefined('Listing.SuperdeckTitle')>
                <cfinput name="SuperdeckTitle" type="text" size="67" maxlength="255" required="yes" message="Please provide a Title to your ad." value="#Listing.SuperdeckTitle#">
                <cfelse>
                <cfinput name="SuperdeckTitle" type="text" size="67" maxlength="255" required="yes" message="Please provide a Title to your ad.">
                </cfif></td>
              </tr>
              <tr>
                <td valign="top" align="right"><b>Copy:</b><br />
                    <span class="body10pt"><i>150 words max.</i></span></td>
                <td valign="top"><cfif IsDefined('Listing.SuperDeckText')>
<textarea name="SuperDeckText" id="SuperDeckText" required="yes" rows="6" cols="60"><cfoutput>#Listing.SuperDeckText#</cfoutput></textarea>
<script language="javascript1.2">
  generate_wysiwyg('SuperDeckText');
</script>
 
 
<cfelse>
<textarea name="SuperDeckText" id="SuperDeckText" required="yes" rows="6" cols="60"></textarea>
<script language="javascript1.2">
  generate_wysiwyg('SuperDeckText');
</script>
</cfif></td>
</tr>
 
 
<tr>
<td align="right"><b>Product Photo:</b></td>
<td><cfif IsDefined('Listing.SuperDeckImage') AND len(Listing.SuperDeckImage) GT 0>
<cfoutput><img src="http://www.thefabricator.com/SuperDeck/SuperDeckImages/#Listing.SuperDeckImage#"></cfoutput><br>
<input name="SuperDeckImage" type="file">
<cfelse>
<input name="SuperDeckImage" type="file">
</cfif></td>
</tr>
 
<tr>
<td align="right"><b>Live:</b></td>
<td><cfif IsDefined('Listing.Live')>
<cfif Listing.Live EQ 1>
<cfinput name="Live" type="radio" value="1" id="radio" checked> Yes<br/>
<cfinput name="Live" type="radio" value="0" id="radio"> No 
<cfelse>
<cfinput name="Live" type="radio" value="1" id="radio"> Yes<br/>
<cfinput name="Live" type="radio" value="0" id="radio" checked> No
</cfif>
<cfelse>
<cfinput name="Live" type="radio" value="1" id="radio" checked> Yes<br/>
<cfinput name="Live" type="radio" value="0" id="radio"> No 
</cfif></td>
</tr>
<tr>
<td align="right"><b>Expire Date:</b></td>
<td><cfif IsDefined('Listing.ExpireDate')>
<cfinput name="ExpireDate" type="text" required="yes" maxlength="255" size="10" value="#dateformat(Listing.ExpireDate,'short')#">
<cfelse>
<cfinput name="ExpireDate" type="text" required="yes" maxlength="255" size="10">
</cfif> <i>( M/D/YY format )</i></td>
</tr>
<tr><td colspan="2" class="subhead">Contact Information<hr></td></tr>
<tr>
<td align="right"><b>Company Name:</b></td>
<td><cfif IsDefined('Listing.ContactCompanyName')>
<cfinput name="ContactCompanyName" type="text" required="yes" maxlength="255" size="60" value="#Listing.ContactCompanyName#">
<cfelse>
<cfinput name="ContactCompanyName" type="text" required="yes" maxlength="255" size="60">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Name:</b></td>
<td><cfif IsDefined('Listing.ContactName')>
<cfinput name="ContactName" type="text" required="yes" maxlength="255" size="50" value="#Listing.ContactName#">
<cfelse>
<cfinput name="ContactName" type="text" required="yes" maxlength="255" size="50">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Phone:</b></td>
<td><cfif IsDefined('Listing.ContactPhone')>
<cfinput name="ContactPhone" type="text" required="yes" maxlength="255" size="20" value="#Listing.ContactPhone#">
<cfelse>
<cfinput name="ContactPhone" type="text" required="yes" maxlength="255" size="20">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Email:</b></td>
<td><cfif IsDefined('Listing.ContactEmail')>
<cfinput name="ContactEmail" type="text" required="yes" maxlength="255" size="50" value="#Listing.ContactEmail#">
<cfelse>
<cfinput name="ContactEmail" type="text" required="yes" maxlength="255" size="50">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Display URL:</b></td>
<td><cfif IsDefined('Listing.ContactDisplayURL')>
<cfinput name="ContactDisplayURL" type="text" required="yes" maxlength="255" size="60" value="#Listing.ContactDisplayURL#">
<cfelse>
<cfinput name="ContactDisplayURL" type="text" required="yes" maxlength="255" size="60">
</cfif></td>
</tr>
<tr>
<td align="right"><b>Actual URL:</b></td>
<td><cfif IsDefined('Listing.ContactActualURL')>
<cfinput name="ContactActualURL" type="text" required="yes" maxlength="255" size="60" value="#Listing.ContactActualURL#">
<cfelse>
<cfinput name="ContactActualURL" type="text" required="yes" maxlength="255" size="60">
</cfif></td>
</tr>
<tr>
<td align="right">&nbsp;</td>
<td><cfif IsDefined('URL.SuperDeckID')>
<input type="Submit" name="act" value="Update Listing" id="submit">&nbsp;<input type="Submit" name="act" value="Remove Listing" id="submit"><input type="hidden" name="SuperDeckID" value="#URL.SuperDeckID#" id="submit">
<cfelse>
<input type="Submit" name="act" id="submit" value="Add Listing">
</cfif></td>
</tr>
</table>
 
 
</cfform>
</cfoutput>
 
 
<!--- END Content--->

Open in new window

then i suspect the problem is actually in the superDeck.listing component
is this the source for Superdeck-Add.cfm? i hope.
Avatar of Albee_J

ASKER

Yes.

Below is the source for the component...

--------------------------------------------------------------------------


<cfcomponent displayName="Super Deck Component" hint="Grab the schools for FMAF">
      <cffunction name="getListings" displayName="Get All Super Deck" hint="Return all schools in the table" access="public" returnType="any" output="false">
<cfargument required="no" name="Expired">
<cfargument required="no" name="SuperDeckCategory">
<cfquery datasource="FCData" name="listing">
SELECT     tSuperDeck.SuperDeckID, tSuperDeck.SuperDeckTitle, tSuperDeck.SuperDeckText, tSuperDeck.SuperDeckImage, tSuperDeck.ContactCompanyName,
                      tSuperDeck.ContactPhone, tSuperDeck.ContactDisplayURL, tSuperDeck.ContactActualURL, tSuperDeck.ContactEmail, tSuperDeck.ContactName,
                      tSuperDeck.TotalClicks, tSuperDeck.AddedDate, tSuperDeck.ExpireDate, tSuperDeck.Live, tSuperDeck.CompanyLogo,
                      tSuperDeckCategories.CategoryName, tSuperDeck.SuperDeckCategory, tSuperDeckCategories.CategoryNameEsp, tIndDirCompanies.CompanyID,
                      tIndDirCompanies.CompanyName, tSuperDeckCategories.CategoryID, tSuperDeck.SuperDeckCategoryID
FROM         tSuperDeck INNER JOIN
                      tSuperDeckCategories ON tSuperDeck.SuperDeckCategoryID = tSuperDeckCategories.CategoryID LEFT OUTER JOIN
                      tIndDirCompanies ON tSuperDeck.CompanyID = tIndDirCompanies.CompanyID
<cfif IsDefined('Arguments.SuperDeckCategoryName')>
WHERE  SuperDeckCategoryName LIKE ('#Arguments.SuperDeckCategoryName#')
</cfif>
<cfif IsDefined('ARGUMENTS.Expired')>
WHERE     (ExpireDate < #createODBCDate(now())#)
</cfif>
<cfif IsDefined('ARGUMENTS.Current')>
WHERE     (Live = 1)
</cfif>
<cfif IsDefined('ARGUMENTS.Past')>
WHERE     (Live = 0)
</cfif>
ORDER BY CategoryName, SuperDeckTitle
</cfquery>
<cfreturn listing>
      </cffunction>

<cffunction name="getExpired" displayName="Get All Super Deck" hint="Return all schools in the table" access="public" returnType="any" output="false">
<cfquery datasource="FCData" name="listing">
SELECT     tSuperDeck.SuperDeckID, tSuperDeck.SuperDeckTitle, tSuperDeck.SuperDeckText, tSuperDeck.SuperDeckImage, tSuperDeck.ContactCompanyName,
                      tSuperDeck.ContactPhone, tSuperDeck.ContactDisplayURL, tSuperDeck.ContactActualURL, tSuperDeck.ContactEmail, tSuperDeck.ContactName,
                      tSuperDeck.TotalClicks, tSuperDeck.AddedDate, tSuperDeck.ExpireDate, tSuperDeck.Live, tSuperDeck.CompanyLogo,
                      tSuperDeckCategories.CategoryName, tSuperDeck.SuperDeckCategory, tSuperDeckCategories.CategoryNameEsp, tIndDirCompanies.CompanyID,
                      tIndDirCompanies.CompanyName, tSuperDeckCategories.CategoryID, tSuperDeck.SuperDeckCategoryID
FROM         tSuperDeck INNER JOIN
                      tSuperDeckCategories ON tSuperDeck.SuperDeckCategoryID = tSuperDeckCategories.CategoryID LEFT OUTER JOIN
                      tIndDirCompanies ON tSuperDeck.CompanyID = tIndDirCompanies.CompanyID
WHERE     (Live = 0)
ORDER BY tIndDirCompanies.CompanyName
</cfquery>
<cfreturn listing>
</cffunction>
      
<cffunction name="deleteListing" access="public" returnType="void" output="false" hint="Deletes a listing.">
      <cfargument name="SuperDeckID" type="numeric" required="true">
            <cfquery datasource="FCData">
            DELETE FROM tSuperDeck
            WHERE SuperDeckID = <cfqueryparam value="#arguments.SuperDeckID#" cfsqltype="CF_SQL_VARCHAR" maxlength="35">
            </cfquery>
      </cffunction>
            
<cffunction name="updateListing" access="public" returnType="void" output="false" hint="Updates a School.">

<cfargument name="SuperDeckID" type="numeric" required="true">
<cfargument name="SuperDeckTitle" type="string" required="true">
<cfargument name="SuperDeckText" type="string" required="false">
<cfargument name="SuperdeckCategoryID" type="string" required="false">
<cfargument name="Live" type="numeric" default="0">
<cfargument name="ExpireDate" type="string" required="false">
<cfargument name="CompanyID" type="numeric" default="" required="false">
    <cfargument name="ContactCompanyName" type="string" required="false">
    <cfargument name="ContactPhone" type="string" required="false">
    <cfargument name="ContactDisplayURL" type="string" required="false">
    <cfargument name="ContactActualURL" type="string" required="false">
    <cfargument name="ContactEmail" type="string" required="false">
    <cfargument name="ContactName" type="string" required="false">
    <cfargument name="SuperDeckImage" type="string" required="false" value="">
                        <cfif Arguments.SuperDeckImage NEQ "">
<cffile action="Upload" filefield="SuperDeckImage" destination="E:\Coldfusion8\wwwroot\SuperDeck\Images" nameconflict="skip">
       
 <cfftp action = "open"
 username="*****"
 password="****"
 server="Publish7.Argos.net"
 connection = "images"
 passive="Yes"
 stopOnError = "Yes"
 timeout = "1200"
 retrycount="1">
 
<cfftp  action="PUTFILE"
 connection = "images"
 passive="Yes"
 stopOnError = "Yes"
Localfile="E:\Coldfusion8\wwwroot\SuperDeck\Images\#cffile.serverfile#" remotefile="/Laurie H. 009/fma8/wwwroot-theFabricator/SuperDeck/SuperDeckImages/#cffile.serverfile#" >

<cfftp  action = "close"
 connection = "images">    

                    <cfset Image = cffile.serverfile>
      <cfelse>
                    <cfset Image = "">
      </cfif>

      <cfquery datasource="FCData">
            UPDATE tSuperDeck SET
                  CompanyID = #CompanyID#,
                  ExpireDate = #createODBCdate(ExpireDate)#,
                  Live = #Live#,
                  SuperdeckCategoryID = #SuperdeckCategoryID#,
                  SuperDeckText = '#SuperDeckText#',
                  SuperDeckTitle = '#SuperDeckTitle#',
                              ContactCompanyName = '#Arguments.ContactCompanyName#',
                              ContactPhone = '#Arguments.ContactPhone#',
                              ContactDisplayURL = '#Arguments.ContactDisplayURL#',                  
            <cfif Image NEQ "">SuperDeckImage = '#Image#',
            </cfif>
            ContactActualURL = '#Arguments.ContactActualURL#',
                              ContactEmail = '#Arguments.ContactEmail#',
                              ContactName = '#Arguments.ContactName#'                  
                  
            WHERE SuperDeckID = #Arguments.SuperDeckID#
      </cfquery>
</cffunction>
      
<cffunction name="insertListing" access="public" returnType="void" output="false" hint="Inserts a School.">

<cfargument name="SuperDeckTitle" type="string" required="true">
<cfargument name="SuperDeckText" type="string" required="false">
<cfargument name="SuperDeckCategoryID" required="false">
<cfargument name="Live" type="numeric" default="0">
<cfargument name="ExpireDate" type="string" required="false">
<cfargument name="CompanyID" type="numeric" default="" required="false">
    <cfargument name="ContactCompanyName" type="string" required="false">
    <cfargument name="ContactPhone" type="string" required="false">
    <cfargument name="ContactDisplayURL" type="string" required="false">
    <cfargument name="ContactActualURL" type="string" required="false">
    <cfargument name="ContactEmail" type="string" required="false">
    <cfargument name="ContactName" type="string" required="false">
    <cfargument name="SuperDeckImage" type="string" required="false" value="">
      <cfargument name="CompanyLogo" type="string" required="false" value="">
      
                        <cfif Arguments.SuperDeckImage NEQ "">
          <cffile action="Upload" filefield="SuperDeckImage" destination="E:\Coldfusion8\wwwroot\SuperDeck\Images" nameconflict="skip">

 <cfftp action = "open"
 username="****"
 password="*****"
 server="Publish7.Argos.net"
 connection = "images"
 passive="Yes"
 stopOnError = "Yes"
 timeout = "1200"
 retrycount="1">

<cfftp action="PUTFILE"
    connection = "images"
       passive="Yes"
 stopOnError = "Yes"
Localfile="E:\Coldfusion8\wwwroot\SuperDeck\Images\#cffile.serverfile#" remotefile="/Laurie H. 009/wwwroot-theFabricator/SuperDeck/SuperDeckImages/#cffile.serverfile#" >

<cfftp  action = "close"
 connection = "images">    

                            <cfset Image = cffile.serverfile>
      <cfelse>
                    <cfset Image = "">
      </cfif>

            <cfquery datasource="FCData">
            INSERT INTO tSuperDeck(
                  CompanyID,
                  ExpireDate,
                  AddedDate,
                  Live,
                  SuperDeckCategoryID,
                  SuperDeckText,
                  SuperDeckTitle,
                              ContactCompanyName,
                              ContactPhone,
                              ContactDisplayURL,
                              ContactActualURL,
                              ContactEmail,                  
            <cfif Image NEQ "">                  SuperDeckImage,
            </cfif>
            ContactName,
                              TotalClicks                  
            )
            VALUES
            (
                  #Arguments.CompanyID#,
                  #createODBCdate(Arguments.ExpireDate)#,
                  #createODBCdate(now())#,
                  #Arguments.Live#,
                  #Arguments.SuperDeckCategoryID#,
                  '#Arguments.SuperDeckText#',
                  '#Arguments.SuperDeckTitle#',
                              '#Arguments.ContactCompanyName#',
                              '#Arguments.ContactPhone#',
                              '#Arguments.ContactDisplayURL#',
                              '#Arguments.ContactActualURL#',
                              '#Arguments.ContactEmail#',                  
            <cfif Image NEQ "">                  '#Image#',
            </cfif>
                        '#Arguments.ContactName#',
                              0                  
            )
            </cfquery>
            <cfquery datasource="FCData" name="checkListing">
            SELECT     CompanyID, SubcategoryID
            FROM         tIndDirCompanyCategory
            WHERE CompanyID = #Arguments.CompanyID# AND SubcategoryID = 637
            </cfquery>
            
            <cfif checkListing.RecordCount EQ 0>
            <cfquery datasource="FCData" name="insertListing">      
            INSERT INTO tIndDirCompanyCategory
        (
            CompanyID,
            SubcategoryID
            )
            VALUES
            (
            #Arguments.CompanyID#,
            637
            )
            </cfquery>
            </cfif>
            
      </cffunction>
      
<cffunction name="getOneListing" displayName="Get only one school" hint="Return all schools in the table" access="public" returnType="any" output="false">
<cfargument required="no" name="SuperDeckID" type="string">
<cfquery datasource="FCData" name="listing">
SELECT     tSuperDeck.SuperDeckID, tSuperDeck.CompanyID, tSuperDeck.SuperDeckTitle, tSuperDeck.SuperDeckText, tSuperDeck.SuperDeckImage,
                      tSuperDeck.ContactCompanyName, tSuperDeck.ContactPhone, tSuperDeck.ContactDisplayURL, tSuperDeck.ContactActualURL,
                      tSuperDeck.ContactEmail, tSuperDeck.ContactName, tSuperDeck.TotalClicks, tSuperDeck.AddedDate, tSuperDeck.ExpireDate, tSuperDeck.Live,
                      tSuperDeck.CompanyLogo, tSuperDeckCategories.CategoryName, tSuperDeck.SuperDeckCategory,  tSuperDeck.SuperDeckCategoryID
FROM         tSuperDeck INNER JOIN
                      tSuperDeckCategories ON tSuperDeck.SuperDeckCategoryID = tSuperDeckCategories.CategoryID
<cfif IsDefined('Arguments.SuperDeckID')>
WHERE  SuperDeckID = ('#Arguments.SuperDeckID#')
</cfif>
</cfquery>
            <cfreturn listing>
      </cffunction>
      

<cffunction name="getFFIDcompanies" displayName="Get either all FFID companies or just one." hint="Return all FFID companies." access="public" returnType="any" output="false">
<cfargument required="no" name="CompanyID" type="string">
<cfquery datasource="FCData" name="companies">
SELECT     CompanyID, CompanyName
FROM         tIndDirCompanies
<cfif IsDefined('Arguments.CompanyID')>
WHERE  CompanyID = ('#Arguments.CompanyID#')
<cfelse>
</cfif>
ORDER BY CompanyName      
</cfquery>
            <cfreturn companies>
      </cffunction>
      
<cffunction name="updateStatus" access="public" returnType="void" output="false" hint="Updates a School.">

<cfargument name="SuperDeckID" type="numeric" required="true">
<cfargument name="Live" type="numeric" default="">

      <cfquery datasource="FCData">
            UPDATE tSuperDeck SET
                  Live = #Arguments.Live#
            WHERE SuperDeckID = #Arguments.SuperDeckID#
      </cfquery>
</cffunction>      
      
      <cffunction name="getCurrentClicks" access="public" returnType="any" output="false" hint="Updates a School.">
      <cfquery datasource="FCData" name="getCurrentClicks">
SELECT     tIndDirCompanies.CompanyName, tSuperDeck.SuperDeckCategory, tSuperDeck.SuperDeckTitle, tSuperDeck.TotalClicks
FROM         tSuperDeck LEFT OUTER JOIN
                      tIndDirCompanies ON tSuperDeck.CompanyID = tIndDirCompanies.CompanyID
WHERE     (tSuperDeck.Live = 1)
ORDER BY tIndDirCompanies.CompanyName, tSuperDeck.SuperDeckTitle
            </cfquery>
            <cfreturn getCurrentClicks>
</cffunction>      
      
<cffunction name="getSummary" access="public" returnType="any" output="false" hint="Updates a School.">
<cfargument name="Sort" required="Yes">

<cfquery datasource="FCData" name="getSummary">
SELECT     tIndDirCompanies.CompanyName, tSuperDeck.SuperDeckCategory, tSuperDeck.SuperDeckTitle, tSuperDeck.TotalClicks
FROM         tSuperDeck LEFT OUTER JOIN
                      tIndDirCompanies ON tSuperDeck.CompanyID = tIndDirCompanies.CompanyID
WHERE     (tSuperDeck.Live = 1)
ORDER BY tIndDirCompanies.CompanyName, tSuperDeck.SuperDeckTitle       
ORDER BY #ARGUMENTS.Sort# ASC
            </cfquery>
            <cfreturn getSummary>
</cffunction>      

<cffunction name="getCategories" access="public" returnType="any" output="false">
<cfargument name="CategoryID" default="0">

<cfquery datasource="FCData" name="getCategories">
SELECT     CategoryNameEsp, CategoryName, CategoryID
FROM         tSuperDeckCategories
<cfif ARGUMENTS.CategoryID NEQ 0>
WHERE CategoryID = #ARGUMENTS.CategoryID#
</cfif>
ORDER BY CategoryName
</cfquery>
            <cfreturn getCategories>
</cffunction>
      
</cfcomponent>

Avatar of Albee_J

ASKER

I also have a question in the Superdeck-Add.cfm form.  You have

<cfparam name="form.act" default="">
<cfif form.act is "Add Listing">

Where is "Add Listing" being set ?
Avatar of Albee_J

ASKER

rob_lorentz:

I apologize my browser must have been cached your code is working.

I do still have the question about

<cfparam name="form.act" default="">
<cfif form.act is "Add Listing">

Where is "Add Listing" being set ?

I am just trying to understand how that is set....