%
job_id = Request("job_id")
strAction = Request("action")
Select Case strAction
Case "generate"
strFileName = GenerateFile(lngRecord)
DisplayLink(strFileName)
Case Else
DisplayForm
End Select
Function DisplayForm()
displayHeader()
Response.Write "
Generate Shipping Labels
"
Response.write "Please enter the following information to generate the shipping labels:"
Response.write ""
displayFooter()
End Function
Function GenerateFile(lngRecord)
strWeight = Request("package_weight")
strSrvType = db_qdSelect("SELECT DeliveryMethod FROM lkdeliverymethod WHERE ID = " & Request("service_type"), "DeliveryMethod")
if UCase(Left(strSrvType,4)) = "UPS " Then strSrvType = Mid(strSrvType, 5)
strPckgType = Request("package_type")
strBilling = Request("billing")
strSatDlvr = Request("saturday_delivery")
strAcctNum = Request("ups_account_number")
strRefNum = request("reference")
If (CheckSecurity(3)) then
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 =" & job_id & " and Orders.status <> 'Incomplete';"
sqlQuery2 = "SELECT * FROM Job WHERE ID = " & job_id
set objRS = objConn.Execute(sqlQuery)
set objRS2 = objConn.Execute(sqlQuery2)
'----- List records -----
intCounter = 0
intFieldCount = objRS.Fields.Count - 1
JobDescription = objRS2("Description")
HTMLList = "
('Ship To' addresses) Bidders List for " & JobDescription & "
" & vbcrlf
MailingList = ""
MailingList = MailingList & "company,c_name,add1,add2,city,state,zip,weight,srv_type,pckgtype,billing,sat_dlvr,acct_num,ref_num" & 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 & strWeight & "," & strSrvType & "," & strPckgType & ","
MailingList = MailingList & strBilling & "," & strSatDlvr & "," & strAcctNum & ","
MailingList = MailingList & strRefNum & 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
io_writeFile "MailingLists/" & generic_properCase(JobDescription) & "Shipping.txt",MailingList
End If
GenerateFile = generic_properCase(JobDescription) & "Shipping.txt"
End Function
Function DisplayLink(strFileName)
displayHeader()
response.write "Click here for CSV (Comma Seperated Values) Shipping Labels. Right click to save the file."
displayFooter()
End Function
%>