<%@ Language=VBScript %> <% '************************************************************************* ' DO NOT MODIFY THIS SCRIPT IF YOU WANT UPDATES TO WORK! ' Function : Customer 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 'Customer dim idCust dim status dim dateCreated dim dateCreatedInt dim name dim lastName dim customerCompany dim phone dim email dim password dim address dim city dim locState dim locCountry dim zip dim paymentType dim shippingName dim shippingLastName dim shippingAddress dim shippingCity dim shippingLocState dim shippingLocCountry dim shippingZip dim futureMail dim generalComments dim affiliate 'Work Fields dim I dim item dim count dim pageSize dim totalPages dim showArr dim sortField dim curPage dim showStatus dim showAff dim showField dim showPhrase '************************************************************************* '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 'Set Row Colors dim rowColor, col1, col2 col1 = "#DDDDDD" col2 = "#EEEEEE" 'Set Number of Items per Page pageSize = 25 'Get Page to show curPage = Request.Form("curPage") 'Form if len(curPage) = 0 then curPage = Request.QueryString("curPage") 'QueryString end if 'Get showStatus showStatus = Request.Form("showStatus") 'Form if len(showStatus) = 0 then showStatus = Request.QueryString("showStatus") 'QueryString end if 'Get showAff showAff = Request.Form("showAff") 'Form if len(showAff) = 0 then showAff = Request.QueryString("showAff") 'QueryString end if 'Get showField showField = Request.Form("showField") 'Form if len(showField) = 0 then showField = Request.QueryString("showField") 'QueryString end if 'Get showPhrase showPhrase = Request.Form("showPhrase") 'Form if len(showPhrase) = 0 then showPhrase = Request.QueryString("showPhrase") 'QueryString end if 'Check if a Cookie Reset was requested if Request.QueryString("resetCookie") = "1" then Response.Cookies("CustSearch").expires = Date() - 30 else 'Check if a Cookie Recall was requested if Request.QueryString("recallCookie") = "1" then for each item in Request.Cookies if item = "CustSearch" then showArr = Split(Request.Cookies(item),"*|*") curPage = showArr(0) showStatus = showArr(1) showField = showArr(2) showPhrase = showArr(3) showAff = showArr(4) end if next else 'Save Search Criteria in a Cookie Response.Cookies("CustSearch") = navCookie(curPage) Response.Cookies("CustSearch").expires = Date() + 30 end if end if 'After attempting to retrieve the search criteria through the various 'mechanisms above (Form/QueryString/Cookie), check that some of the 'critical values are valid. If not, set to default values. if len(curPage) = 0 or not isNumeric(curPage) then curPage = 1 else curPage = CLng(curPage) end if 'Check what we will be sorting the results on sortField = Request.Form("sortField") 'Form if len(sortField) = 0 then sortField = Request.QueryString("sortField") 'QueryString end if if len(sortField) = 0 then sortField = "lastName" end if %>

Customer Maintenance

<% if len(trim(Request.QueryString("msg"))) > 0 then %> <%=Request.QueryString("msg")%>

<% end if %>
Show Customers where    contains the phrase   
   

<% 'Specify fields and table mySQL="SELECT idCust,status,dateCreated,name," _ & " lastName,email,affiliate " _ & "FROM customer " _ & "WHERE 1=1 " 'Dummy check to set up conditional checks below 'Status if len(showStatus) > 0 then mySQL = mySQL & "AND status = '" & showStatus & "' " end if 'Affiliate if len(showAff) > 0 then mySQL = mySQL & "AND affiliate = '" & showAff & "' " end if 'Field and Search Phrase if len(showField) > 0 and len(showPhrase) > 0 then mySQL = mySQL & "AND " & showField & " LIKE '%" & replace(showPhrase,"'","''") & "%' " end if 'Sort Order mySQL = mySQL & "ORDER BY " & sortField set rs = openRSopen(mySQL,0,adOpenStatic,adLockReadOnly,adCmdText,pageSize) if rs.eof then %> <% else rs.MoveFirst rs.PageSize = pageSize totalPages = rs.PageCount rs.AbsolutePage = curPage %> <% rowColor = col1 %> <% rowColor = col2 do while not rs.eof and count < rs.pageSize %> <% count = count + 1 rs.movenext 'Switch Row Color if rowColor = col2 then rowColor = col1 else rowColor = col2 end if loop %> <% end if call closeRS(rs) %>

No Customers matched search criteria.

<% call pageNavigation("selectPageTop") %> Sort :
ID Name EMail Created Status Affiliate  
<%=rs("idCust")%> <%=rs("lastName") & ", " & rs("name")%> <%=rs("email")%> <%=formatTheDate(rs("dateCreated"))%> <%=rs("status")%> <%=rs("affiliate")%> [ ">edit | ">delete ]
<% call pageNavigation("selectPageBot") %>

Help and Instructions :
Find Customer(s) - Customers are displayed in Last Name, First Name sequence.

1. You can list all Customers which contain a specific phrase in one of several fields.

2. You can list Customers based on general Status or Affilate status.

Edit Customer - Click to view or change Customer information, order history, affiliate sales, etc.

Delete Customer - Click to delete a Customer from the Database. Please note that a Customer record can NOT be deleted if there are Orders linked to it. You will have to delete the Orders linked to the Customer first, then return and delete the Customer. Or you could simply InActivate the Customer.

Status - A=Active, I=InActive

Affiliate - Y=Affiliate, N=Not Affiliate, A=Applied

<% call closedb() %> <% '********************************************************************* 'Make QueryString for Paging '********************************************************************* function navQueryStr(pageNum) navQueryStr = "?curPage=" & server.URLEncode(pageNum) _ & "&showStatus=" & server.URLEncode(showStatus) _ & "&showAff=" & server.URLEncode(showAff) _ & "&showField=" & server.URLEncode(showField) _ & "&showPhrase=" & server.URLEncode(showPhrase) end function '********************************************************************* 'Make Cookie Value for Paging '********************************************************************* function navCookie(pageNum) navCookie = pageNum & "*|*" _ & showStatus & "*|*" _ & showField & "*|*" _ & showPhrase & "*|*" _ & showAff end function '********************************************************************* 'Display page navigation '********************************************************************* sub pageNavigation(formFieldName) Response.Write "Page " Response.Write " of " & TotalPages & "  " Response.Write "[ " if curPage > 1 then Response.Write "Back" else Response.Write "Back" end if Response.Write " | " if curPage < TotalPages then Response.Write "Next" else Response.Write "Next" end if Response.Write " ]" end sub %>