Re: selecting different template based on file name

2009-09-28 Thread Tom Chiverton

On Tuesday 22 Sep 2009, Damo Drumm wrote:
   where IINVOICE_Key = #url.invoice#
   AND InvoiceTemplateType_Key = 1
   /cfquery

Use CFQUERYPARAM !
Unless you really want someone putting 
?invoice=0;drop table InvoiceTemplate; -- 
into their address bar to take down the system...

-- 
Helping to authoritatively bully best-of-breed impactful interactive 
deliverables as part of the IT team of the year, '09 and '08



This email is sent for and on behalf of Halliwells LLP.

Halliwells LLP is a limited liability partnership registered in England and 
Wales under registered number OC307980 whose registered office address is at 
Halliwells LLP, 3 Hardman Square, Spinningfields, Manchester, M3 3EB.  A list 
of members is available for inspection at the registered office together with a 
list of those non members who are referred to as partners.  We use the word 
“partner” to refer to a member of the LLP, or an employee or consultant with 
equivalent standing and qualifications. Regulated by the Solicitors Regulation 
Authority.

CONFIDENTIALITY

This email is intended only for the use of the addressee named above and may be 
confidential or legally privileged.  If you are not the addressee you must not 
read it and must not use any information contained in nor copy it nor inform 
any person other than Halliwells LLP or the addressee of its existence or 
contents.  If you have received this email in error please delete it and notify 
Halliwells LLP IT Department on 0870 365 2500.

For more information about Halliwells LLP visit www.halliwells.co

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326690
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


selecting different template based on file name

2009-09-22 Thread Damo Drumm

Hi im having trouble with the below piece of code, im trying to set it up to 
add the correct template as a watermark based on the filename in the database 
in field (INVOICE_PDFFile)
can anyone help me out?
at the minute im getting this error message - Error Executing Database Query.
[Macromedia][SQLServer JDBC Driver][SQLServer]Ambiguous column name 
'InvoiceTemplateType_Key'.


heres my code:
cfparam name=currentline default=1
cfparam name=previousstring default=
cfset timestamp = timeformat(now(),HHmmss)
cfset pdfname = url.invoice_timestamp.pdf

cfquery name=qgetinvoice datasource=#request.dsn#
select INVOICE_PDFFile
from INVOICE
where INVOICE_Key = #url.invoice#
/cfquery

cfpdf action=getinfo  name=pdfinfo 
source=#request.maindrivePath#PDFs\#qgetinvoice.INVOICE_PDFFile#

cfif pdfinfo.TotalPages gt 1
cfset totalpages = 1-pdfinfo.TotalPages
cfelse
cfset totalpages = 1
/cfif

cfquery name=qgetcreditnotetemplate datasource=#request.dsn#
select InvoiceTemplate_FileName, 
InvoiceTemplateType_Key, Invoive_Key
from InvoiceTemplate IT, INVOICE I
where IINVOICE_Key = #url.invoice#
AND InvoiceTemplateType_Key = 1
/cfquery


cfpdf
action = addwatermark
source = #request.maindrivePath#PDF\#qgetinvoice.INVOICE_PDFFile#
image = #request.maindrivePath#PDF\#qgetcreditnotetemplate#
foreground = No
overwrite = yes
pages = #totalpages#
opacity = 10
Position = 10, -50
 showonprint = YES
destination = #request.maindrivePath#temppdf\#pdfname#


cflocation url=temppdf/#pdfname# 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326480
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


re: selecting different template based on file name

2009-09-22 Thread Jason Fisher

The error means that InvoiceTemplateType_Key is a column in both tables, so 
you have to let the database know which one you actually want.  Use your 
table aliases:

cfquery name=qgetcreditnotetemplate datasource=#request.dsn#
 SELECT 
IT.InvoiceTemplate_FileName, 
  IT.InvoiceTemplateType_Key, 
  I.Invoive_Key
 FROM InvoiceTemplate IT, INVOICE I
 WHERE I.IINVOICE_Key = #url.invoice#
  AND IT.InvoiceTemplateType_Key = 1
/cfquery

Looks like you're not JOINing your tables either, which could be pretty bad 
in both performance and results, and please be sure you're using 
CFQUERYPARAM in actual code to screen that URL variable.  Something like 
this (making assumptions here about data types and column references):


cfquery name=qgetcreditnotetemplate datasource=#request.dsn#
 SELECT 
IT.InvoiceTemplate_FileName, 

  IT.InvoiceTemplateType_Key, 

  I.Invoive_Key
 FROM InvoiceTemplate IT INNER JOIN
  INVOICE I ON IT.InvoiceTemplateType_Key = 
I.InvoiceTemplateType_Key
 WHERE I.IINVOICE_Key = cfqueryparam cfsqltype=CF_SQL_INTEGER 
value=#url.invoice# /
  AND IT.InvoiceTemplateType_Key = cfqueryparam 
cfsqltype=CF_SQL_INTEGER value=1 /
/cfquery

 



~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326482
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4


Re: selecting different template based on file name

2009-09-22 Thread Damo Drumm

Hi Jason
Ive tried that but Im still getting the same error

The error means that InvoiceTemplateType_Key is a column in both tables, so 
you have to let the database know which one you actually want.  Use your 
table aliases:

cfquery name=qgetcreditnotetemplate datasource=#request.dsn#
SELECT 
 IT.InvoiceTemplate_FileName, 
  IT.InvoiceTemplateType_Key, 
  I.Invoive_Key
 FROM InvoiceTemplate IT, INVOICE I
 WHERE I.IINVOICE_Key = #url.invoice#
  AND IT.InvoiceTemplateType_Key = 1
   /cfquery

Looks like you're not JOINing your tables either, which could be pretty bad 
in both performance and results, and please be sure you're using 
CFQUERYPARAM in actual code to screen that URL variable.  Something like 
this (making assumptions here about data types and column references):


cfquery name=qgetcreditnotetemplate datasource=#request.dsn#
SELECT 
 IT.InvoiceTemplate_FileName, 

  IT.InvoiceTemplateType_Key, 

  I.Invoive_Key
 FROM InvoiceTemplate IT INNER JOIN
  INVOICE I ON IT.InvoiceTemplateType_Key = 
I.InvoiceTemplateType_Key
 WHERE I.IINVOICE_Key = cfqueryparam cfsqltype=CF_SQL_INTEGER 
value=#url.invoice# /
  AND IT.InvoiceTemplateType_Key = cfqueryparam 
cfsqltype=CF_SQL_INTEGER value=1 /
   /cfquery 

~|
Want to reach the ColdFusion community with something they want? Let them know 
on the House of Fusion mailing lists
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:326484
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4