<% set jobRS = objConn.Execute("SELECT * FROM job WHERE ID = " & Request("job_id")) displayHeader() if (checkSecurity(30) or (checkSecurity(20) and Session("user_company")=jobRS("company_id") )) then Select Case request("action") Case "billing" GenerateBillToFile() Case "shipping" GenerateShipToFile() End Select else response.Write("Access Denied") end if displayFooter() ' begin ' For Ship To Address Function GenerateShipToFile sqlQuery = "SELECT company.Name as CompanyName, contacts.Name as PersonName, orders.ShipTo_Address1, orders.ShipTo_Address2, orders.ShipTo_City, orders.ShipTo_State, orders.ShipTo_Zip From company left join orders on company.ID=orders.Company_ID left join contacts on contacts.ID = orders.Contact_ID where orders.Job_ID =" & request("job_id") & " and orders.status <> 'Incomplete';" sqlQuery2 = "SELECT * FROM job WHERE ID = " & request("job_id") set objRS = objConn.Execute(sqlQuery) set objRS2 = objConn.Execute(sqlQuery2) Job = objRS2("Job") '----- List records ----- intCounter = 0 intFieldCount = objRS.Fields.Count - 1 JobDescription = objRS2("Job") Response.Write "

Mailing Labels

" HTMLList = "

('Ship To' addresses) Bidders List for " & JobDescription & "


" & vbcrlf MailingList = "Company Name, Contact Name, Address 1, Address 2, City, State, Zip, "&vbcrlf do while not objRS.EOF intCounter = intCounter + 1 For i = 0 To intFieldCount varFieldValue = objRS(i) intType = objRS(i).Type SELECT CASE objRS(i).Name CASE "ShipTo City" if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & ", " end if MailingList = MailingList & varFieldValue & "," CASE "ShipTo State" if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & " " end if MailingList = MailingList & varFieldValue & "," CASE "ShipTo Zip" if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & "
" end if MailingList = MailingList & varFieldValue CASE ELSE if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & "
" & vbcrlf end if MailingList = MailingList & varFieldValue & "," END SELECT Next HTMLList = HTMLList & "
" & vbcrlf MailingList = MailingList & vbcrlf objRS.Movenext loop ' remove spaces and other invalid characters from the jobdescription name Do While InStr(1, JobDescription, " ") JobDescription = Replace(JobDescription, " ", "") JobDescription = Replace(JobDescription, ",", "") JobDescription = Replace(JobDescription, "\", "") JobDescription = Replace(JobDescription, "/", "") JobDescription = Replace(JobDescription, "`", "") JobDescription = Replace(JobDescription, "'", "") JobDescription = Replace(JobDescription, ";", "") JobDescription = Replace(JobDescription, ":", "") JobDescription = Replace(JobDescription, "&", "") Loop Job = Replace(Job, ",", "") Job = Replace(Job, "/", "") Job = Replace(Job, "\", "") Job = Replace(Job, ".", "") Job = Replace(Job, "`", "") Job = Replace(Job, "'", "") Job = Replace(Job, ":", "") Job = Replace(Job, ";", "") Job = Replace(Job, "-", "") Job = Replace(Job, "@", "") Job = Replace(Job, "#", "") Job = Replace(Job, "&", "") Job = Replace(Job, "(", "") Job = Replace(Job, ")", "") io_writeFile "MailingLists/" & Server.URLEncode(generic_properCase(Job)) & "ShipTo.txt",MailingList Response.Write "
(Ship to addresses) Click here to enter Shipping Information

" Response.Write "
(Bill to addresses) Right click here and select 'Save target as...' to download this Comma Seperated Values (*.CSV) Text File.

" Response.write "You can then import this file into Access, Excel, or any other program which supports comma seperated data importation." Response.write "

" & vbcrlf Response.Write "
" & vbcrlf Response.write HTMLList objRS.Close objRS2.Close Set objRS = Nothing Set objRS2 = nothing End Function ' For Bill To Address Function GenerateBillToFile sqlQuery = "SELECT Company.Name as CompanyName, Contacts.Name as PersonName, Orders.BillTo_Address1, Orders.BillTo_Address2, Orders.BillTo_City, Orders.BillTo_State, Orders.BillTo_Zip From Company left join Orders on Company.ID=Orders.Company_ID left join Contacts on Contacts.ID = Orders.Contact_ID where Orders.Job_ID =" & request("job_id") & " and Orders.status <> 'Incomplete';" sqlQuery2 = "SELECT * FROM Job WHERE ID = " & request("job_id") set objRS = objConn.Execute(sqlQuery) set objRS2 = objConn.Execute(sqlQuery2) Job = objRS2("Job") '----- List records ----- intCounter = 0 intFieldCount = objRS.Fields.Count - 1 JobDescription = objRS2("Job") HTMLList = "

('Bill To' addresses) Bidders List for " & JobDescription & "


" & vbcrlf MailingList = "Company Name, Contact Name, Address 1, Address 2, City, State, Zip, "&vbcrlf do while not objRS.EOF intCounter = intCounter + 1 For i = 0 To intFieldCount varFieldValue = objRS(i) intType = objRS(i).Type SELECT CASE objRS(i).Name CASE "ShipTo City" if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & ", " end if MailingList = MailingList & varFieldValue & "," CASE "ShipTo State" if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & " " end if MailingList = MailingList & varFieldValue & "," CASE "ShipTo Zip" if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & "
" end if MailingList = MailingList & varFieldValue CASE ELSE if (trim(varfieldvalue & "") <> "") then HTMLList = HTMLList & varFieldValue & "
" & vbcrlf end if MailingList = MailingList & varFieldValue & "," END SELECT Next HTMLList = HTMLList & "
" & vbcrlf MailingList = MailingList & vbcrlf objRS.Movenext loop ' remove spaces and other invalid characters from the jobdescription name Do While InStr(1, JobDescription, " ") JobDescription = Replace(JobDescription, " ", "") JobDescription = Replace(JobDescription, ",", "") JobDescription = Replace(JobDescription, "\", "") JobDescription = Replace(JobDescription, "/", "") JobDescription = Replace(JobDescription, "`", "") JobDescription = Replace(JobDescription, "'", "") JobDescription = Replace(JobDescription, ";", "") JobDescription = Replace(JobDescription, ":", "") Loop Job = Replace(Job, ",", "") Job = Replace(Job, "/", "") Job = Replace(Job, "\", "") Job = Replace(Job, ".", "") Job = Replace(Job, "`", "") Job = Replace(Job, "'", "") Job = Replace(Job, ":", "") Job = Replace(Job, ";", "") Job = Replace(Job, "-", "") Job = Replace(Job, "@", "") Job = Replace(Job, "#", "") Job = Replace(Job, "&", "") Response.Write "
(Bill to addresses) Right click here and select 'Save target as...' to download this Comma Seperated Values (*.CSV) Text File.

" Response.write "You can then import this file into Access, Excel, or any other program which supports comma seperated data importation." Response.write "

" & vbcrlf Response.Write " " &vbcrlf ' Response.write "
" & vbcrlf Response.write HTMLList io_writeFile "MailingLists/" & Server.URLEncode(generic_properCase(Job)) & "Billto.txt",MailingList ' Response.write "
" & HTMLList ' Response.write "
" & vbcrlf objRS.Close objRS2.Close Set objRS = Nothing Set objRS2 = nothing End Function %>