Advertisement
Guest User

Processing for Dynamic Fields Form

a guest
Jan 3rd, 2011
194
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ColdFusion 5.56 KB | None
  1. <cfoutput>
  2.  
  3.   <cfloop index="ii" list="#form.fieldnames#">
  4.  
  5.     <!---Sets the upload destinations and uploads the files--->
  6.     <cfif left(ii,9) is "DOCUPLOAD" and len(trim(form[ii]))>
  7.      
  8.       <cfset MyNumber = mid (ii, 10, 3)>
  9.      
  10.       <!---<cffile action="upload" filefield="#ii#" destination="#expandPath('\')#data\docs\#form.matternumber#\#form["x" & ii]#" nameconflict="overwrite" />--->
  11.      
  12.       <cffile action="upload" filefield="#ii#" destination="#expandPath('\')#data\docs\#form.matternumber#" nameconflict="overwrite" />
  13.      
  14.       <!--- Get the just uploaded file and read it as a binary file --->
  15.       <cffile action="readbinary" file="#expandPath('\')#data\docs\#form.matternumber#\#form["x" & ii]#\#cffile.serverFile#" variable="fileBin" />
  16.      
  17.       <!---sets the docpath variable for insertion into the database--->
  18.       <cfset docpath = "#expandPath('\')#data\docs\#form.matternumber#\#form["x" & ii]#\#cffile.serverFile#" />
  19.      
  20.       <cfset docpath = "#expandPath('\')#data\docs\#form.matternumber#\#cffile.serverFile#" />
  21.      
  22.      
  23.       <cftransaction>
  24.         <cfquery name="InsertMetadata" datasource="#application.datasource#" result="GetLastUploaded">
  25.               INSERT INTO           tbl_DocumentProperties(docPath,docName,UploadedBy,batchnum,emailTxt,emailSubject,email1,email2,email3,email4,email5,SendEmail,AttachFile)                  
  26.               VALUES    ('#DocPath#','#cffile.serverFile#','#session.umemberid#',#batchnum#,'#form.emailtxt#','#vSubject#','#form.email1#','#form.email2#','#form.email3#','#form.email4#','#form.email5#',#form.SendEmail#,#form.AttachFile#)     
  27.         </cfquery>
  28.        
  29.         <!---Gets the DocDate values from the form--->
  30.        
  31.         <cfset MyName = "DOCDATE#MyNumber#">
  32.        
  33.         <cfif isDefined ("form.#MyName#") and len (trim (form [MyName]))>
  34.             <cfquery name="UpdateMetaData1" datasource="#application.datasource#">
  35.                 UPDATE  tbl_DocumentProperties
  36.                 SET     docDate = '#form[MyName]#'
  37.                 WHERE   docPropID = <cfqueryparam value="#GetLastUploaded.IDENTITYCOL#" cfsqltype="cf_sql_integer" />
  38.             </cfquery>
  39.         </cfif>
  40.        
  41.         <!---Gets text values of DocType for insertion into email --->
  42.        
  43.         <cfset MyName = "DOCTYPE#MyNumber#">
  44.        
  45.         <cfif isDefined ("form.#MyName#") and len (trim (form [MyName]))>
  46.        
  47.             <cfquery name="GetDocTypes" datasource="#application.datasource#">
  48.                   SELECT    DocTypeDesc
  49.                   FROM      tbl_DocTypes
  50.                   WHERE     DocTypeID = <cfqueryparam value="#form[MyName]#" cfsqltype="cf_sql_varchar" />
  51.             </cfquery>
  52.            
  53.             <cfquery name="UpdateMetaData2" datasource="#application.datasource#">
  54.                  UPDATE tbl_DocumentProperties
  55.                  SET docType = '#GetDocTypes.DocTypeDesc#'
  56.                  WHERE docPropID = <cfqueryparam value="#GetLastUploaded.IDENTITYCOL#" cfsqltype="cf_sql_integer" />
  57.             </cfquery>
  58.            
  59.         </cfif>
  60.        
  61.         <!---Get the folderID from the folder name, because we want to store the number not the name in the database, but we need the name to build the destination path--->
  62.        
  63.         <cfset MyName = "XDOCUPLOAD#MyNumber#">
  64.        
  65.         <cfif isDefined ("form.#MyName#") and len (trim (form [MyName]))>
  66.        
  67.           <cfquery name="getFolderID" datasource="#application.datasource#">
  68.                 SELECT  FolderID
  69.                 FROM        tbl_FolderNames
  70.                 WHERE   FolderName = <cfqueryparam value="#form[MyName]#" cfsqltype="cf_sql_varchar" />
  71.           </cfquery>
  72.          
  73.           <cfset vFolderName = #form[MyName]#>
  74.          
  75.           <cfquery name="UpdateMetaData3" datasource="#application.datasource#">
  76.                 UPDATE      tbl_DocumentProperties
  77.                 SET         FolderUploadedTo = #getFolderID.FolderID#
  78.                 WHERE       docPropID = <cfqueryparam value="#GetLastUploaded.IDENTITYCOL#" cfsqltype="cf_sql_integer" />
  79.            </cfquery>
  80.         </cfif>
  81.        
  82.         <!--- Insert the fields for the LegalKey table  --->
  83.        
  84.         <cfset MyName = "DATECODE#MyNumber#">
  85.        
  86.         <cfif isDefined ("form.#MyName#") and len (trim (form [MyName]))>
  87.        
  88.        
  89.             <cfquery name="insertLK" datasource="#application.datasource#" result="GetLastUpdated">
  90.                 INSERT INTO
  91.               tbl_LegalKey(ClientID,MatterID,date_code,uploadedBy,Comments,DocumentFileName,DocumentFolderName,DocumentFile)
  92.                 VALUES
  93.                 ('#Left(form.CMnumber,6)#', '#form.matternumber#', #form[MyName]#,#session.umemberid#,'#form.emailTxt#','#cffile.serverFile#','#vFolderName#',<cfqueryparam value="#fileBin#" cfsqltype="cf_sql_blob" /> )
  94.             </cfquery>
  95.        
  96.         </cfif>
  97.        
  98.         <!--- Update the record in the LegalKey table to store the sd_id --->
  99.        
  100.         <cfset MyName = "SDOC#MyNumber#">
  101.        
  102.         <cfif isDefined ("form.#MyName#") and len (trim (form [MyName]))>
  103.            
  104.             <cfquery name="updateLK" datasource="#application.datasource#">
  105.                 UPDATE  tbl_LegalKey
  106.                 SET sd_id = '#form[MyName]#'
  107.                 WHERE LKID = <cfqueryparam value="#GetLastUpdated.IDENTITYCOL#" cfsqltype="cf_sql_integer" />
  108.             </cfquery>
  109.            
  110.             <cfquery name="UpdateMetaData2" datasource="#application.datasource#">
  111.                  UPDATE tbl_DocumentProperties
  112.                  SET docType = '#form[MyName]#'
  113.                  WHERE docPropID = <cfqueryparam value="#GetLastUploaded.IDENTITYCOL#" cfsqltype="cf_sql_integer" />
  114.             </cfquery>
  115.        
  116.         </cfif>
  117.        
  118.       </cftransaction>
  119.      
  120.     </cfif>
  121.   </cfloop>
  122. </cfoutput>
Advertisement
RAW Paste Data Copied
Advertisement