%
'--------------------------------------------------------
' Configurations for this page
'--------------------------------------------------------
myPageName = "editOrder.asp"
myPageTable = "orders"
'--------------------------------------------------------
displayHeader()
if (checkSecurity(30) or checkSecurity(CONST_securityLevelToEditOrdersAll) or checkSecurity(CONST_securityLevelToEditOrdersForCompanyJob)) then
select case request("action")
case "getById"
getOrderById()
case "assignset"
assignSet()
case "edit"
editOrder() ' gets company/contact info from super user and gets quantity, discipline, and bid category information
case "fulfill"
editOrder()
case "delete"
editOrder()
case "deleteExecute"
deleteExecute()
case "finish"
if request("print") <> "" then
printOrder()
else
finishOrder()
end if
case "list"
list()
case else
list()
end select
else
response.Write("You must be a super user to access this section ")
security_getLogonInfo(myPageName & "?job_id=" & request("job_id"))
end if
displayFooter()
'-----------------------------------------------------------------------------------------------------------------------------------
'
'-----------------------------------------------------------------------------------------------------------------------------------
function list()
select case request("action")
case "fill"
%>
Retrieve Order By ID
<%
end select
sqlString = "select lkdeliverymethod.deliveryMethod, orders.*, job.job as jobName, company.name as companyName, contacts.name as contactName, pgc.name as pushgroupContactName "
sqlString = sqlString & "from orders left outer join job on (orders.job_id = job.id) left outer join company on (orders.company_id=company.id) left outer join contacts on (orders.contact_id=contacts.id) left outer join contacts pgc on (orders.pushgroup_contact_id = pgc.id) left outer join lkdeliverymethod on (lkdeliverymethod.id=orders.shipment_method) "
sqlString = sqlString & "where orders.id=orders.id "
if not (checkSecurity(CONST_securityLevelToEditOrdersAll)) then
sqlString = sqlString & " and job.company_id="&Session("User_Company")&" "
end if
select case request("action")
case "fill"
if CONST_statusToDisplayInFillOrder <> "" then
fillStatusList = split(CONST_statusToDisplayInFillOrder,",")
sqlString = sqlString & " and (orders.status = 'Pending'"
For Each statusType in fillStatusList
sqlString = sqlString & " or orders.status = '"&trim(statusType)&"'"
Next
sqlString = sqlString & ")"
else
sqlString = sqlString & " and (orders.status = 'Pending' or orders.status = 'Waiting on Deposit' or orders.status='Hold' or orders.status = 'Waiting on CC Approv' or orders.status = 'Waiting on Approval' or orders.status = 'Not Approved' or orders.status='Incomplete' )"
end if
case else
sqlString = sqlString & " and orders.date_ordered > DATE_SUB(now(), interval "&CONST_manageOrdersInterval&" day) "
end select
sqlString = sqlString & " order by id"
showList sqlString
end function
'--------------------------------------------------------------------------
' This function shows the list of companies.
'--------------------------------------------------------------------------
function showList(sqlString)
dim headerArray(11)
dim jsRowArray(2)
dim displayArray(11,4,1)
set objRS = objConn.Execute(sqlString)
headerArray(0) = " "
headerArray(1) = "Job Order ID"
headerArray(2) = "Company MBE/WBE"
headerArray(3) = "Contact"
headerArray(4) = "Pushgroup Contact ID"
headerArray(5) = "Status"
headerArray(6) = "Date Ordered"
if checkSecurity(30) and CONST_displayDeliveryMethEditOrder then
headerArray(6) = headerArray(6) & " Delivery Method"
end if
if CONST_displayFreeSetInEditOrderList then
headerArray(7) = "Free Set"
end if
if CONST_displayTaxInEditOrderList then
headerArray(8) = "Tax"
end if
headerArray(9) = "Comments"
if CONST_displayFreightInEditOrderList then
headerArray(10) = "Freight"
end if
if CONST_displayQuantityInEditOrderList then
headerArray(11) = "Quantity Of Full Sets"
end if
select case request("action")
case "fill"
displayArray(0,0,0) = "Fill | Edit | Delete"
displayArray(0,4,1) = "text"
displayArray(1,0,0) = "jobName"
displayArray(1,0,1) = "field_br"
displayArray(1,1,0) = "id"
displayArray(1,1,1) = "field_br"
displayArray(2,0,0) = "companyName"
displayArray(2,0,1) = "field_br"
displayArray(2,1,0) = "minority_owned_company"
displayArray(2,1,1) = "field"
displayArray(3,0,0) = "contactName"
displayArray(3,0,1) = "field"
displayArray(4,0,0) = "pushgroupContactName"
displayArray(4,0,1) = "field"
displayArray(5,0,0) = "status"
displayArray(5,0,1) = "field"
displayArray(6,0,0) = "date_ordered"
displayArray(6,0,1) = "field_br"
if checkSecurity(30) and CONST_displayDeliveryMethEditOrder then
displayArray(6,1,0) = "deliveryMethod"
displayArray(6,1,1) = "field"
end if
if CONST_displayFreeSetInEditOrderList then
displayArray(7,0,0) = "free_set"
displayArray(7,0,1) = "field"
end if
if CONST_displayTaxInEditOrderList then
displayArray(8,0,0) = "tax"
displayArray(8,0,1) = "field"
end if
displayArray(9,0,0) = "comment"
displayArray(9,0,1) = "field"
if CONST_displayFreightInEditOrderList then
displayArray(10,0,0) = "freight"
displayArray(10,0,1) = "field"
end if
if CONST_displayQuantityInEditOrderList then
displayArray(11,0,0) = "orderQuantity"
displayArray(11,0,1) = "orderQuantity"
end if
jsRowArray(0) = "this.className='rowDisplayDataHover'"
jsRowArray(1) = "return"
generic_selectionList objRS, displayArray, headerArray, jsRowArray
end function
'--------------------------------------------------------
'
'--------------------------------------------------------
function getOrderById()
%>
Retrieve Order
Enter the order number you wish to pull up.
<%
end function
'--------------------------------------------------------
'
'--------------------------------------------------------
function editOrder()
select case request("action")
case "edit"
actionName = "Edit"
submitName = "Update"
actionValue = "finish"
case "fulfill"
actionName = "Edit"
submitName = "Update"
actionValue = "finish"
case "delete"
actionName = "Delete"
submitName = "Delete"
actionValue = "deleteExecute"
end select
if request("order_id") = "" then
response.Write("There was no order id to retrieve.")
end if
sqlString = "select * from orders where id = " & request("order_id")
set orderRS = objConn.Execute(sqlString)
if orderRS.EOF then
response.Write("There is no order associated with this order id.")
end if
sqlString = "select count(*) as total from company"
set objRS = objConn.Execute(sqlString)
if (Cint("0" & objRS("total")) > 100) then
limitResults = true
else
limitResults = false
end if
sqlString = "select * from job where id = " & orderRS("job_id")
set jobRS = objConn.Execute(sqlString)
generic_displayValidator()
%>
<%=actionName %> Order
<%
end function
'-----------------------------------------------------------------------------------
' This function increments the value in the job.sets_issued and assigns that number
' to this order
'-----------------------------------------------------------------------------------
function assignSet()
set orderRS = objConn.Execute("select * from orders where id="&request("order_id"))
set jobRS = objConn.Execute("select * from job where id="&orderRS("job_id"))
if (cint("0"&jobRS("sets_issued")) >= cint("0"&jobRS("sets")) and jobRS("sets") <> "") then
response.Write("All sets allowed for this job have been assigned. In order assign more sets you must edit the job and increase the number of sets available.")
exit function
end if
setNumber = cint("0"&jobRS("sets_issued")) + 1
sqlString = "update job set sets_issued="&setNumber&" where id="&orderRS("job_id")
objConn.Execute(sqlString)
if db_getData(orderRS, "sets_issued") <> "" then
setNumber = db_getData(orderRS, "sets_issued") & ", " & setNumber
end if
sqlString = "update orders set sets_issued='"&setNumber&"' where id="&request("order_id")
objConn.Execute(sqlString)
generic_redirect(myPageName&"?action="&request("prevAction")&"&order_id="&request("order_id"))&"&rd="&request("rd")
end function
'-----------------------------------------------------------------------------------
' This function updates the data in the DB for the order and then opens a window
' showing the invoice
'-----------------------------------------------------------------------------------
function printOrder()
processData()
%>
<%
if request("print") = "Print & Return" then
select case request("rd")
case "bidders.asp"
generic_redirect("bidders.asp?job_id="&request("job_id"))
case "fill"
if (CONST_goToBiddersListAfterFill) then
generic_redirect("bidders.asp?job_id="&request("job_id"))
else
generic_redirect("editOrder.asp?action=fill")
end if
case else
if (CONST_goToBiddersListAfterFill) then
generic_redirect("bidders.asp?job_id="&request("job_id"))
else
generic_redirect("editOrder.asp")
end if
end select
else
generic_redirect("editOrder.asp?action=edit&order_id="&request("order_id"))
end if
end function
'-----------------------------------------------------------------------------------
' This function does the final processing of the order. It calls the function to save the data
' to the DB and displays the confirmation page.
'-----------------------------------------------------------------------------------
function finishOrder()
processData()
select case request("rd")
case "bidders.asp"
generic_redirect("bidders.asp?job_id="&request("job_id"))
case "fill"
if (CONST_goToBiddersListAfterFill) then
generic_redirect("bidders.asp?job_id="&request("job_id"))
else
generic_redirect("editOrder.asp?action=fill")
end if
case else
if (CONST_goToBiddersListAfterFill) then
generic_redirect("bidders.asp?job_id="&request("job_id"))
else
generic_redirect("editOrder.asp")
end if
end select
end function
'-----------------------------------------------------------------------------------
' This function saves the data from an order to the DB. It is called from finishOrder
' and skipJackOrder
'-----------------------------------------------------------------------------------
function processData()
set objRS = objConn.Execute("select * from job where id="&request("job_id"))
isTaxable = cbool(objRS("taxable"))
if isTaxable then
' tax = db_qdSelect("select tax from contacts where id = " & Session("User_Id"), "tax")
if tax = "" and request("shipto_county") <> "" then
tax = db_qdSelect("select tax from lkcounties where id="&request("shipto_county"), "tax")
end if
if tax = "" then
if CONST_useShippingForTax then
tax = db_qdSelect("select tax from lkstates where state = '"&request("shipto_state")&"'", "tax")
else
tax = db_qdSelect("select tax from lkstates where state = '"&request("billto_state")&"'", "tax")
end if
end if
else
tax = 0
end if
sqlString = "update orders set "
sqlString = sqlString & "tax = '"& tax & "', "
sqlString = sqlString & "status = '"& request("status") & "', "
sqlString = sqlString & "bid_category='" & db_addSlashes(request("bid_categories")) & "', "
sqlString = sqlString & "date_shipped = '" & db_mysqlDate(request("date_shipped")) & "', "
sqlString = sqlString & "date_filled = '" & db_mysqlDate(request("date_filled")) & "', "
sqlString = sqlString & "return_due = '" & db_mysqlDate(request("return_due")) & "', "
sqlString = sqlString & "date_returned = '" & db_mysqlDate(request("date_returned")) & "', "
sqlString = sqlString & "minority_owned_company="&db_getCheckBox(request("minority_owned_company"))&", "
sqlString = sqlString & "tracking_number = '" & request("tracking_number") & "', "
sqlString = sqlString & "shipment_method = '" & request("shipment_method") & "', "
sqlString = sqlString & "comment = '" & db_addSlashes(request("comment")) & "', "
sqlString = sqlString & "contact_id = " & request("contact_id") & ", "
sqlString = sqlString & "care_of = '" & db_addSlashes(request("care_of")) & "', "
sqlString = sqlString & "shipto_address1 = '" & db_addSlashes(request("shipto_address1")) & "', "
sqlString = sqlString & "shipto_address2 = '" & db_addSlashes(request("shipto_address2")) & "', "
sqlString = sqlString & "shipto_city = '" & db_addSlashes(request("shipto_city")) & "', "
sqlString = sqlString & "shipto_state = '" & request("shipto_state") & "', "
sqlString = sqlString & "shipto_zip = '" & request("shipto_zip") & "', "
sqlString = sqlString & "billto_address1 = '" & db_addSlashes(request("billto_address1")) & "', "
sqlString = sqlString & "billto_address2 = '" & db_addSlashes(request("billto_address2")) & "', "
sqlString = sqlString & "billto_city = '" & db_addSlashes(request("billto_city")) & "', "
sqlString = sqlString & "billto_state = '" & request("billto_state") & "', "
sqlString = sqlString & "billto_zip = '" & request("billto_zip") & "', "
sqlString = sqlString & "freight = " & request("freight") & ", "
sqlString = sqlString & "trade_id = " & request("trade_id") & ", "
sqlString = sqlString & "free_set = " & db_getCheckBox(request("free_set")) & ", "
sqlString = sqlString & "Sets_Issued = '" & request("Sets_Issued") & "' "
sqlString = sqlString & "where id=" & request("order_id")
response.Write(" " & sqlString & " ")
objConn.Execute(sqlString)
'----------------------------------------------------------------------------------------------------------------
order_id = request("order_id")
'----------------------------------------------------------------------------------------------------------------
' Disciplines Disciplines Disciplines Disciplines Disciplines Disciplines Disciplines Disciplines Disciplines Disciplines
totalQty = 0
totalCost = 0
sqlString = "select * from order_lines where order_id = " & order_id & " and item_type='job_discipline' order by line_number"
set objRS = objConn.Execute(sqlString)
if CONST_disciplinesEnabled and not objRS.EOF then
discCount = 0
do while not objRS.EOF
sqlString = "update order_lines set "
sqlString = sqlString & "order_id = " & order_id & ", "
sqlString = sqlString & "quantity = " & request("discQuant" & discCount) & ", "
sqlString = sqlString & "unit_price = " & request("discPrice" & discCount) & ", "
' sqlString = sqlString & "shipping_cost = " & cdbl("0"&request("discSH" & discCount)) & ", "
sqlString = sqlString & "extended_price = " & CDbl("0"& request("discQuant" & discCount)) * CDbl("0"& request("discPrice" & discCount)) & ", "
sqlString = sqlString & "payment_type='"& request("discPayment" & discCount) & "', "
sqlString = sqlString & "paid="& db_getCheckBox(request("discPaid" & discCount)) &", "
sqlString = sqlString & "date_paid='"& db_mysqlDate(request("discDatePaid" & discCount)) &"', "
sqlString = sqlString & "comment='"& request("discComment" & discCount) &"' "
sqlString = sqlString & "where id=" & request("discId" & discCount)
objConn.Execute(sqlString)
totalCost = totalCost + cdbl(cint(request("discQuant" & discCount))*cdbl(request("discPrice" & discCount)))
totalQty = totalQty + cint(request("discQuant" & discCount))
discCount = discCount + 1
objRS.MoveNext
loop
response.Write("sub Total after disc: " & totalCost & " "&vbcrlf)
else
if request("discQuant0") <> "" then
discCount = 0
sqlString = "update order_lines set "
sqlString = sqlString & "order_id = " & order_id & ", "
sqlString = sqlString & "quantity = " & request("discQuant" & discCount) & ", "
sqlString = sqlString & "unit_price = " & request("discPrice" & discCount) & ", "
' sqlString = sqlString & "shipping_cost = " & cdbl("0"&request("discSH" & discCount)) & ", "
sqlString = sqlString & "extended_price = " & CDbl("0"& request("discQuant" & discCount)) * CDbl("0"& request("discPrice" & discCount)) & ", "
sqlString = sqlString & "payment_type='"& request("discPayment" & discCount) & "', "
sqlString = sqlString & "paid="& db_getCheckBox(request("discPaid" & discCount)) &", "
sqlString = sqlString & "date_paid='"& db_mysqlDate(request("discDatePaid" & discCount)) &"', "
sqlString = sqlString & "comment='"& request("discComment" & discCount) &"' "
sqlString = sqlString & "where id=" & request("discId" & discCount)
objConn.Execute(sqlString)
totalCost = totalCost + cdbl(cint(request("discQuant" & discCount))*cdbl(costPerEach))
totalQty = totalQty + cint(request("discQuant" & discCount))
discCount = discCount + 1
end if
end if
if request("quantity") <> "" then
sqlString = "update order_lines set "
sqlString = sqlString & "quantity = " & request("quantity") & ", "
end if
'----------------------------------------------------------------------------------------------------------------
'IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES IMAGES
sqlString = "select * from order_lines where order_id = " & order_id & " and item_type='images' order by line_number"
set objRS = objConn.Execute(sqlString)
if CONST_orderIndividualSheets and not objRS.EOF then ' similar madness logic as above
sheetCount = 0
do while not objRS.EOF
sqlString = "update order_lines set "
sqlString = sqlString & "order_id = " & order_id & ", "
sqlString = sqlString & "quantity = " & request("sheetQuant" & sheetCount) & ", "
sqlString = sqlString & "unit_price = " & request("sheetPrice" & sheetCount) & ", "
sqlString = sqlString & "extended_price = " & CDbl("0"& request("sheetQuant" & sheetCount)) * CDbl("0"& request("sheetPrice" & sheetCount)) & ", "
sqlString = sqlString & "payment_type='"& request("sheetPayment" & sheetCount) & "', "
sqlString = sqlString & "paid="& db_getCheckBox(request("sheetPaid" & sheetCount)) &", "
sqlString = sqlString & "date_paid='"& db_mysqlDate(request("sheetDatePaid" & sheetCount)) &"', "
sqlString = sqlString & "comment='"& request("sheetComment" & sheetCount) &"' "
sqlString = sqlString & "where id=" & request("sheetId" & sheetCount)
objConn.Execute(sqlString)
totalCost = totalCost + cdbl(cint(request("sheetQuant" & sheetCount))*cdbl(request("sheetPrice" & sheetCount)))
totalQty = totalQty + cint(request("sheetQuant" & sheetCount))
sheetCount = sheetCount + 1
objRS.MoveNext
loop
end if
'----------------------------------------------------------------------------------------------------------------
sqlString = "select * from order_lines where order_id = " & order_id & " order by line_number"
set objRS = objConn.Execute(sqlString)
if CONST_minOrder > 0 and CONST_minOrder > totalCost then
totalCost = CONST_minOrder
end if
if (CONST_orderMinCCOrderDisabled <> true) then
if generic_isCreditCardOrder(db_qdSelect("select paymentOption from lkpaymentoption where id ="&objRS("payment_type"),"paymentOption")) then
if CONST_minCCOrder > 0 and CONST_minCCOrder > totalCost then
totalCost = CONST_minCCOrder
end if
end if
end if
sqlString = "SELECT freight FROM job WHERE id = " & request("job_id")
set objRS = objConn.Execute(sqlString)
freight = objRS("freight")
sqlString = "select * from lkdeliverymethod where id = '" & request("shipment_method") & "'"
set objRS = objConn.Execute(sqlString)
response.Write("debug: about to check if we should charge shipping.. If we get an exception error after this it is most likely the delivery method is stored in the old way and a different method needs to be picked ")
If objRS("chargeFreight") = "-1" Then
select case lcase(CONST_shippingChargeMethod)
case "percentage"
freight = subTotal * objRS("shippingChargePercentage")
case "per method"
sqlString = "select * from job_delivery_cost where job_id="&request("job_id")&" and delivery_id="&request("shipment_method")
set tempRS = objConn.Execute(sqlString)
if (tempRS.EOF) then
if (objRS("cost") <> "") then
freight = cdbl(objRS("cost"))
end if
else
freight = cdbl(tempRS("cost"))
end if
If CONST_multiplyFreight Then
freight = freight * totalQty
End If
case "static"
If CONST_multiplyFreight Then
freight = freight * totalQty
End If
case else
sqlString = "select * from job_delivery_cost where job_id="&request("job_id")&" and delivery_id="&request("shipment_method")
set tempRS = objConn.Execute(sqlString)
if (tempRS.EOF) then
if (objRS("cost") <> "") then
freight = cdbl(objRS("cost"))
end if
else
freight = cdbl(tempRS("cost"))
end if
If CONST_multiplyFreight Then
freight = freight * totalQty
End If
end select
Else
freight = "0"
End If
sqlString = "update orders set freight = " & freight & " where id = " & order_id
objConn.Execute(sqlString)
end function
function deleteExecute()
sqlString = "delete from order_lines where order_id = " & request("order_id")
objConn.Execute(sqlString)
sqlString = "delete from orders where id = " & request("order_id")
objConn.Execute(sqlString)
select case request("rd")
case "bidders.asp"
generic_redirect("bidders.asp?job_id="&request("job_id"))
case "fill"
generic_redirect("editOrder.asp?action=fill")
case else
generic_redirect("editOrder.asp")
end select
end function
%>