|
<%Server.ScriptTimeout =3000
hits=0
leads=0
sales=0
salesnum=0
totalEarned=0
varnull=0
Set conn = Server.CreateObject("ADODB.Connection")
Set rs = Server.CreateObject("ADODB.Recordset")
Conn.Open dsn
rs.open "SELECT AfUsername, status from AF_Users where AfUsername = '" & session("AfUsername") & "'", conn,1,3
if not rs.eof then
UserStatus=rs("status")
end if
rs.close
if UserStatus=0 then
rs.open "SELECT afcurrency, ConStatus, BonusAmount, BonusWhen, FlatFee, EnableTiers, Tier2Commission, Tier3Commission, Tier4Commission, Tier5Commission, Tier6Commission, Tier7Commission FROM AF_Constants where ConStatus = " & UserStatus & "", conn,1,3
else
rs.open "SELECT afcurrency, ConStatus, ConstantsID, BonusAmount, BonusWhen, FlatFee, EnableTiers, Tier2Commission, Tier3Commission, Tier4Commission, Tier5Commission, Tier6Commission, Tier7Commission FROM AF_Constants where ConstantsID = " & UserStatus & "", conn,1,3
end if
if not rs.eof then
afcurrency=rs("afcurrency")
BonusAmount=rs("BonusAmount")
BonusWhen=rs("BonusWhen")
EnableTiers=rs("EnableTiers")
FlatFee=rs("FlatFee")
if EnableTiers=1 and flatFee=0 then EnableTiers=2
Tier2Commission=rs("Tier2Commission")
Tier3Commission=rs("Tier3Commission")
Tier4Commission=rs("Tier4Commission")
Tier5Commission=rs("Tier5Commission")
Tier6Commission=rs("Tier6Commission")
Tier7Commission=rs("Tier7Commission")
end if
rs.close
if EnableTiers=1 or EnableTiers=2 then
rs.open "SELECT * from AF_Tiers where AfUsername = '" & session("AfUsername") & "'", conn,1,3
i=0
ti2=0
ti3=0
ti4=0
ti5=0
ti6=0
ti7=0
dim tier2()
dim tier3()
dim tier4()
dim tier5()
dim tier6()
dim tier7()
if not rs.eof then
Do Until Rs.EOF
i=i+1
ReDim Preserve tier2(i)
ReDim Preserve tier3(i)
ReDim Preserve tier4(i)
ReDim Preserve tier5(i)
ReDim Preserve tier6(i)
ReDim Preserve tier7(i)
if rs("tier2") <>"" then tier2(i)=rs("tier2")
if rs("tier3") <>"" then tier3(i)=rs("tier3")
if rs("tier4") <>"" then tier4(i)=rs("tier4")
if rs("tier5") <>"" then tier5(i)=rs("tier5")
if rs("tier6") <>"" then tier6(i)=rs("tier6")
if rs("tier7") <>"" then tier7(i)=rs("tier7")
Rs.MoveNext
Loop
end if
rs.close
rs.open "SELECT * from AF_Payments",conn
if not rs.eof then
Do Until Rs.EOF
for k=1 to i
if Tier2Commission>0 then
if rs("AfUsername")=tier2(k) then
if EnableTiers=1 then ' Tiers Flat Fee Enabled
ti2=ti2+(rs("numOfSales")*Tier2Commission)
elseif EnableTiers=2 then
totalearned=(rs("Earn"))*Tier2Commission/100
ti2=ti2+totalearned
end if
end if
end if
if Tier3Commission>0 then
if rs("AfUsername")=tier3(k) then
if EnableTiers=1 then ' Tiers Flat Fee Enabled
ti3=ti3+(rs("numOfSales")*Tier3Commission)
elseif EnableTiers=2 then
totalearned=(rs("Earn"))*Tier3Commission/100
ti3=ti3+totalearned
end if
end if
end if
if Tier4Commission>0 then
if rs("AfUsername")=tier4(k) then
if EnableTiers=1 then ' Tiers Flat Fee Enabled
ti4=ti4+(rs("numOfSales")*Tier4Commission)
elseif EnableTiers=2 then
totalearned=(rs("Earn"))*Tier4Commission/100
ti4=ti4+totalearned
end if
end if
end if
if Tier5Commission>0 then
if rs("AfUsername")=tier5(k) then
if EnableTiers=1 then ' Tiers Flat Fee Enabled
ti5=ti5+(rs("numOfSales")*Tier5Commission)
elseif EnableTiers=2 then
totalearned=(rs("Earn"))*Tier5Commission/100
ti5=ti5+totalearned
end if
end if
end if
if Tier6Commission>0 then
if rs("AfUsername")=tier6(k) then
if EnableTiers=1 then ' Tiers Flat Fee Enabled
ti6=ti6+(rs("numOfSales")*Tier6Commission)
elseif EnableTiers=2 then
totalearned=(rs("Earn"))*Tier6Commission/100
ti6=ti6+totalearned
end if
end if
end if
if Tier7Commission>0 then
if rs("AfUsername")=tier7(k) then
if EnableTiers=1 then ' Tiers Flat Fee Enabled
ti7=ti7+(rs("numOfSales")*Tier7Commission)
elseif EnableTiers=2 then
totalearned=(rs("Earn"))*Tier7Commission/100
ti7=ti7+totalearned
end if
end if
end if
next
Rs.MoveNext
Loop
end if
rs.close
end if
rs.open "SELECT * from AF_Hits WHERE AfUsername ='" & session("AfUsername") & "'", conn,1,3
if rs.eof then%>
You have not earned any commissions yet. <%else Do Until Rs.EOF hits=hits+rs("hits") leads=leads+rs("leads") sales=sales+rs("sales") salesnum=salesnum+rs("salesnum") earn=earn+rs("Earn") Rs.MoveNext Loop totalEarned=Earn totalDownline=ti2+ti3+ti4+ti5+ti6+ti7 total=totalEarned+totalDownline rs.close rs.open "SELECT * from AF_Payments WHERE AfUsername ='" & session("AfUsername") & "'", conn,1,3 if not rs.eof then if total>=BonusWhen and isNull(rs("Bonus")) then totalEarned=totalEarned+BonusAmount total=total+BonusAmount totalBonus=rs("Earn")+BonusAmount product_name="Bonus" Bonus1="1" sql = "INSERT into AF_Hits(AfUsername, hits, leads, salesnum, sales, product_name, earn, date) Values('" & session("AfUsername") & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & varnull & "', '" & product_name & "', '" & BonusAmount & "', '" & now() & "')" conn.execute(sql) SQL = "update AF_Payments Set Earn = '"& totalBonus &"', Bonus = '" & Bonus1 & "' Where AfUsername = '" & session("AfUsername") & "'" Set RS = conn.Execute(SQL) end if end if %> <%if EnableTiers=1 or EnableTiers=2 then%>
<%if totalEarned+totalDownline |