<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Order Maintenance ' Product : CandyPress Store Administration ' Version : 2.5 ' Modified : February 2004 ' Copyright: Copyright (C) 2004 CandyPress.Com ' See "license.txt" for this product for details regarding ' licensing, usage, disclaimers, distribution and general ' copyright requirements. If you don't have a copy of this ' file, you may request one at webmaster@candypress.com '************************************************************************* Option explicit Response.Buffer = true const adminLevel = 1 %> <% 'Database dim mySQL, cn, rs, rs2 'cartHead dim idOrder dim idCust dim orderDate dim orderDateInt dim randomKey dim subTotal dim taxTotal dim shipmentTotal dim handlingFeeTotal dim otherFeeTotal dim Total dim shipmentMethod dim name dim lastName dim customerCompany dim phone dim email dim address dim city dim locState dim locCountry dim zip dim shippingName dim shippingLastName dim shippingPhone dim shippingAddress dim shippingCity dim shippingLocState dim shippingLocCountry dim shippingZip dim paymentType dim cardType dim cardNumber dim cardExpMonth dim cardExpYear dim cardVerify dim cardName dim generalComments dim orderStatus dim auditInfo dim storeComments dim storeCommentsPriv dim adjustAmount dim adjustReason dim discCode dim discPerc dim discTotal 'cartRows dim idCartRow dim idProduct dim sku dim quantity dim unitPrice dim unitWeight dim description dim downloadCount dim downloadDate dim discAmt dim a dim b dim c 'CartRowsOptions dim idCartRowOption dim idOption dim optionPrice dim optionDescrip 'DiscProd dim idDiscProd dim discFromQty dim discToQty 'Work Fields dim action '************************************************************************* 'Open Database Connection call openDB() 'Store Configuration if loadConfig() = false then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Could not load Store Configuration settings.") end if 'Get action action = trim(Request.QueryString("action")) if len(action) = 0 then action = trim(Request.Form("action")) end if action = lCase(action) if action <> "edit" _ and action <> "del" _ and action <> "view" _ and action <> "inv" then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Action Indicator.") end if 'If this is an invoice, show different headers if action = "inv" then %> Invoice <% else %>

Order Maintenance

<% end if 'Get idOrder idOrder = trim(Request.QueryString("recId")) if len(idOrder) = 0 then idOrder = trim(Request.Form("recId")) end if if idOrder = "" or not isNumeric(idOrder) then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") end if 'Get cartHead Record mySQL = "SELECT idCust,orderDate,subTotal,taxTotal,shipmentTotal," _ & " Total,shipmentMethod,name,lastName,customerCompany," _ & " phone,email,address,city,locState,locCountry,zip," _ & " shippingName,shippingLastName,shippingPhone," _ & " shippingAddress,shippingCity,shippingLocState," _ & " shippingLocCountry,shippingZip,paymentType,cardType," _ & " cardNumber,cardExpMonth,cardExpYear,cardVerify," _ & " cardName,generalComments,orderStatus,auditInfo," _ & " adjustAmount,adjustReason,discCode,discPerc,discTotal," _ & " handlingFeeTotal,otherFeeTotal,storeComments," _ & " storeCommentsPriv " _ & "FROM cartHead " _ & "WHERE idOrder=" & idOrder set rs = openRSexecute(mySQL) if rs.eof then response.redirect "sysMsg.asp?errMsg=" & server.URLEncode("Invalid Record ID.") else 'NOTE : storeComments is assigned before storeCommentsPriv because 'we kept on getting the error 'Multiple-step OLE DB operation 'generated errors' on SQL Server 7.0 (Access was fine) if we 'attempted to assign storeCommentsPriv before storeComments. This 'is interesting because the general rule is that you should list 'TEXT/MEMO fields at the end of the SELECT, and read them first to 'last. storeComments = rs("storeComments") storeCommentsPriv = rs("storeCommentsPriv") idCust = rs("idCust") orderDate = rs("orderDate") subTotal = rs("subTotal") taxTotal = rs("taxTotal") shipmentTotal = rs("shipmentTotal") Total = rs("Total") shipmentMethod = trim(rs("shipmentMethod")) Name = trim(rs("name")) LastName = trim(rs("LastName")) CustomerCompany = trim(rs("CustomerCompany")) Phone = trim(rs("Phone")) Email = trim(rs("Email")) Address = trim(rs("Address")) City = trim(rs("City")) locState = trim(rs("locState")) locCountry = trim(rs("locCountry")) Zip = trim(rs("Zip")) shippingName = trim(rs("shippingName")) shippingLastName = trim(rs("shippingLastName")) shippingPhone = trim(rs("shippingPhone")) shippingAddress = trim(rs("shippingAddress")) ShippingCity = trim(rs("ShippingCity")) shippingLocState = trim(rs("shippingLocState")) shippingLocCountry = trim(rs("shippingLocCountry")) shippingZip = trim(rs("shippingZip")) paymentType = trim(rs("paymentType")) cardType = trim(rs("cardType")) cardNumber = trim(EnDeCrypt(Hex2Ascii(rs("cardNumber")),rc4Key)) cardExpMonth = trim(rs("cardExpMonth")) cardExpYear = trim(rs("cardExpYear")) cardVerify = trim(rs("cardVerify")) cardName = trim(rs("cardName")) generalComments = trim(rs("generalComments")) orderStatus = rs("orderStatus") auditInfo = rs("auditInfo") adjustAmount = rs("adjustAmount") adjustReason = trim(rs("adjustReason")) discCode = trim(rs("discCode")) discPerc = trim(rs("discPerc")) discTotal = trim(rs("discTotal")) handlingFeeTotal = rs("handlingFeeTotal") otherFeeTotal = rs("otherFeeTotal") 'Default some values if they are null if isNull(discPerc) then discPerc = 0.00 end if if isNull(discTotal) then discTotal = 0.00 end if if isNull(adjustAmount) then adjustAmount = 0.00 end if end if call closeRS(rs) 'Edit if action = "edit" then if len(trim(Request.QueryString("msg"))) > 0 then %> <%=Request.QueryString("msg")%>

<% end if %> Edit Order  <%call maintNavLinks()%>

Order Number  <%=pOrderPrefix & "-" & idOrder%>     [ Edit Customer | &emailToName=<%=server.URLEncode(name & " " & LastName)%>&emailSubj=<%=server.URLEncode(pCompany & " - Order " & pOrderPrefix & "-" & idOrder)%>">Send Email ]
Order Date  <%=formatTheDate(orderDate)%>
Order Status 
Email Customer if status changes.
Adjust Stock Levels if status changes.
Store Comments
(Can be viewed by the Customer)
Private Comments
(Can NOT be viewed by the Customer)
Email 
Customer ID  <%=idCust%>
Audit Info  <%=auditInfo%>
  Billing Shipping
First Name 
Last Name 
Address 
City 
State/Province 
Zip/PCode 
Country 
Phone 
Company 
Shipping 
Payment 
Card Type 
Card Number 
Card Expire  / (MM/YYYY)
Card Verif. # 
Card Name 
Comments  <%=emptyString(generalComments,"None")%>
<% 'Display all the items and options for this order call showOrderItems(idOrder) %> <% if len(cardNumber) > 0 then %> <% end if %>
Sub Total:   <%=pCurrencySign%>
<%=discCode%>  %  Discount Code:   <%=pCurrencySign%>(-)
Shipping:   <%=pCurrencySign%>
Handling Fee:   <%=pCurrencySign%>
Other Fees:   <%=pCurrencySign%>
Tax:   <%=pCurrencySign%>
*    <%=replace(pCurrencySign," "," ")%>
Total:   <%=pCurrencySign & moneyD(Total)%>
 
 
NB : For added security, it is strongly recommended that you delete the credit card number from the order after processing the payment.
 
<% end if 'View / Invoice / Delete if action = "view" or action = "inv" or action = "del" then 'Delete if action = "del" then %> Delete Order  <%call maintNavLinks()%>
Are you sure you want to Delete this Order?
<% 'View elseif action = "view" then %> View Order  <%call maintNavLinks()%>

<% 'Invoice elseif action = "inv" then %>
<%=pCompany%> Invoice
<% end if %>
<% 'If this is an invoice, we adjust the next couple of 'rows a little bit to include the store address if action = "inv" then %> <% else %> <% end if %>
<%=replace(pCompanyAddr,chr(10),"
")%>
Order Number  <%=pOrderPrefix & "-" & idOrder%>
Order Date  <%=formatTheDate(orderDate)%>
Order Status  <%=orderStatusDesc(orderStatus)%>
Order Number  <%=pOrderPrefix & "-" & idOrder%>     [ Edit Customer | &emailToName=<%=server.URLEncode(name & " " & LastName)%>&emailSubj=<%=server.URLEncode(pCompany & " - Order " & pOrderPrefix & "-" & idOrder)%>">Send Email ]
Order Date  <%=formatTheDate(orderDate)%>
Order Status  <%=orderStatusDesc(orderStatus)%>
Store Comments  <%=replace(emptyString(storeComments,"None"),Chr(10),"
")%>
Private Comments  <%=replace(emptyString(storeCommentsPriv,"None"),Chr(10),"
")%>
Email  <%=email%>
Customer ID  <%=idCust%>
Audit Info  <%=auditInfo%>
<% 'Show credit card info if this is a Credit Card payment 'and not an invoice. if len(cardNumber) > 0 and action <> "inv" then %> <% end if %>
  Billing Shipping
Name  <%=Name & " " & LastName%> <%=emptyString(shippingName,Name) & " " & emptyString(shippingLastName,LastName)%>
Address  <%=address%> <%=emptyString(shippingAddress,address)%>
City  <%=city%> <%=emptyString(shippingCity,city)%>
Location  <% if len(locState) > 0 then Response.Write locState & ", " end if Response.Write locCountry %> <% if len(shippingLocState) = 0 and len(shippingLocCountry) = 0 then if len(locState) > 0 then Response.Write locState & ", " end if Response.Write locCountry else if len(shippingLocState) > 0 then Response.Write shippingLocState & ", " end if Response.Write shippingLocCountry end if %>
Zip/PCode  <%=zip%> <%=emptyString(shippingZip,zip)%>
Phone  <%=phone%> <%=emptyString(shippingPhone,phone)%>
Company  <%=customerCompany%>  
Shipping  <%=shipmentMethod%>
Payment  <%=paymentMsg(paymentType, total, cardNumber)%>
Card Type  <%=cardType%>
Card Number  <%=cardNumber%>
Card Expire  <%=cardExpMonth & "/" & cardExpYear%>  (MM/YYYY)
Card Verif. #  <%=cardVerify%>
Card Name  <%=cardName%>
Comments  <%=emptyString(generalComments,"None")%>
<% 'Display all the items and options for this order call showOrderItems(idOrder) %> <% 'If there's a discount, show discount and sub-total row if discTotal > 0 then %> <% end if %> <% 'If there's a handling fee, show handling fee row if handlingFeeTotal > 0 then %> <% end if 'If there are other fees, show other fee row if otherFeeTotal > 0 then %> <% end if %> <% 'Only show message if this is not an invoice if action <> "inv" then %> <% end if %>
Sub Total:   <%=pCurrencySign & moneyD(subTotal)%>
<%=discCode%> (<%=formatNumber(discPerc,2)%>%) - Discount Code:   <%=pCurrencySign & moneyD(discTotal)%>  (-)
Sub Total:   <%=pCurrencySign & moneyD(subTotal - discTotal)%>
Shipping:   <%=pCurrencySign & moneyD(shipmentTotal)%>
Handling Fee:   <%=pCurrencySign & moneyD(handlingFeeTotal)%>
Other Fees:   <%=pCurrencySign & moneyD(otherFeeTotal)%>
Tax:   <%=pCurrencySign & moneyD(taxTotal)%> 
*Adjustment:   <% if isNumeric(adjustAmount) then Response.Write pCurrencySign & moneyD(adjustAmount) else Response.Write pCurrencySign & moneyD("0") end if %>
Total:   <%=pCurrencySign & moneyD(Total)%>
*Adjustment : <% if len(adjustReason) > 0 then Response.Write adjustReason else Response.Write "No Adjustment(s) for this Order  " end if %>
 
NOTE : This Order as it is displayed here closely resembles the Order as it is displayed to the Customer when they log on to their Account and view an Order's detail. However, fields shown in red are only viewable by the store Administrator.
<% end if if action = "edit" then %>
Help and Instructions :
Order Status - Changing the Order Status will automatically result in the following actions :

  • Send an email to the Customer notifying them of the change (if "Email Customer if status changes" box is checked).
  • Update the Stock Levels of all Products involved (if "Adjust Stock Levels if status changes" box is checked).
  • Append the Date/Time to the "Store Comments" field.
Store Comments - Any text entered here will be viewable by the Customer. It's usefull if for some reason there is a problem with the Order and you want to communicate this to your Customer.

Private Comments - Text entered here will NOT be viewable by the Customer. Use this field to store information that is confidential to your Store.

General Fields - Several other fields are modifiable. These fields are typically entered by the Customer when placing the Order. Under certain circumstances it may be necessary to change this information, mainly due to user error when the Order is placed. The modifications made to these fields are NOT strictly checked to allow maximum flexibility.

Order Total Fields - You can change any of the totals for this order. The only requirement is that you enter a valid numeric value. To ensure maximum flexiblity, no other checks are performed. The final Total is automatically recalculated, but the other totals are not. Therefore you have to make sure that you adjust all related totals appropriately before clicking the update button.

* Adjustment - This option is useful if you want to change the order total without changing any of the other totals such as shipping, taxes, etc. What is also unique about this option, is that it allows you to enter a text description (or reason) for the adjustment. Both the adjustment reason and amount is viewable by the customer. For example, if the customer wants to add another item to their order, you can enter the item description in the adjustment "reason" field, and the item value in the adjusment "amount" field.

<% Response.Write Trim(Replace((pOrderPrefix & "-" & idOrder),Left((pOrderPrefix & "-" & idOrder),(len(pOrderPrefix) + 1)),"")) end if 'Close Database Connection call closedb() 'If this is an invoice, show different footers if action = "inv" then %> <% else %> <% end if '********************************************************************* 'Display the Order's Items '********************************************************************* sub showOrderItems(idOrder) 'Declare local vars dim optionGroupsTotal %> Qty Item Description Sub Total <% 'Get all rows for this cart mySQL="SELECT idCartRow,idProduct,quantity,unitPrice," _ & " description,sku,downloadCount,downloadDate," _ & " discAmt " _ & "FROM cartRows " _ & "WHERE cartRows.idOrder=" & idOrder & " " _ & "ORDER BY idCartRow " set rs = openRSexecute(mySQL) do while not rs.eof 'Assign record values to local values idCartRow = rs("idCartRow") idProduct = rs("idProduct") quantity = rs("quantity") unitPrice = rs("unitPrice") description = rs("description") sku = rs("sku") downloadCount = rs("downloadCount") downloadDate = rs("downloadDate") discAmt = rs("discAmt") 'Cater for orders entered before discounts were added if isNull(discAmt) then discAmt = 0.00 end if %> <%=quantity%> <% if SKU = "" then 'Use idProduct response.write IDProduct else 'Use sku response.write SKU end if 'Write cartRow line (main item) response.write " " & Description & " - " & pCurrencySign & moneyD(unitPrice) & "
" 'Write Discount (if any) if discAmt > 0 then Response.Write "* Discount - " & pCurrencySign & moneyD(discAmt) & "
" end if 'Get all options for this row optionGroupsTotal = 0 mySQL = "SELECT optionPrice,optionDescrip " _ & "FROM cartRowsOptions " _ & "WHERE idCartRow=" & IDCartRow set rs2 = openRSexecute(mySQL) do while not rs2.eof 'Assign record values to local values optionDescrip = rs2("optionDescrip") optionPrice = rs2("optionPrice") 'Write cartRowOptions line(s) (options) Response.Write "* " & optionDescrip if optionPrice <> 0 then Response.Write " - " & pCurrencySign & moneyD(optionPrice) end if Response.Write "
" 'Calculate options Sub Total optionGroupsTotal = optionGroupsTotal + optionPrice rs2.movenext loop call closeRS(rs2) 'Display downloadCount and downloadDate (if not invoice) if isNumeric(downloadCount) and action <> "inv" then if downloadCount > 0 then Response.Write "Downloaded " & downloadCount & " times since '" & formatIntDate(downloadDate) & "'." end if end if %> <%=pCurrencySign & moneyD(Cdbl(quantity * (optionGroupsTotal + unitPrice - discAmt)))%> <% rs.movenext loop call closeRS(rs) end sub '********************************************************************* 'Format the internal integer date '********************************************************************* function formatIntDate(str1) if len(trim(str1))=14 and isnumeric(str1) then formatIntDate = "" _ & left(str1,4) & "/" _ & mid(str1,5,2) & "/" _ & mid(str1,7,2) & " " _ & mid(str1,9,2) & ":" _ & mid(str1,11,2) else formatIntDate = str1 end if end function '********************************************************************* 'Create Navigation Links '********************************************************************* sub maintNavLinks() %> [ List Orders | View | Edit | Invoice | Delete <% if pAuthNet = -1 then %> | Authorize <% end if %> ] <% end sub %>