Hi, im doing a project where i want to incorporate a external payment/invoicing system to my web shop system. What i have to do is to make a unique kid number for each invoice i print out from the web shop. This kid number is quite complex, and have to be set up with certain rules according to the external invoicing system. I got the code in visual basic to do this, the problem is that i know nothing about visual basic, so if someone could help me rewrite this function to suit php4 and mysql, it would be greatly appreciated. Here is the VB code i got from the system administrator of the external system:
Public Function calculatekid(ordernumber)
Dim strKid
Dim kid As Integer
Dim i As Integer
Dim s As Integer
Dim x As Integer
Dim length As Integer
Dim strEcreditid
Dim strFakturanr
Dim SQLstr As String
Dim objRS As Object
kid = 0
i = 0
s = 1
SQLstr = "select
'1'+convert(varchar(4),k.ecreditid)+right('00000000000'+convert(varchar(12),
m.fakturanumber),7) as kid "
SQLstr = SQLstr + "FROM tbl_orderhead m, tbl_shops k "
SQLstr = SQLstr + "WHERE m.shopid = k.shopid AND m.ordernumber = " &
ordernumber
Set objRS = openRS_R(SQLstr)
If Not objRS.EOF Then
strKid = objRS("kid")
length = (Len(strKid) - 1)
Do While i <= length
i = i + 1
s = s + 1
x = Mid(strKid, i, 1)
If s Mod 2 = 1 Then
kid = kid + x
Else
If Len(CStr(x * 2)) > 1 Then
kid = kid + Right(x * 2, 1) + Left(x * 2, 1)
Else
kid = kid + x * 2
End If
End If
Loop
calculatekid = Trim(strKid) & CStr(Right(10 - (kid Mod 10), 1))
End If
End Function
I hope any1 could help me with this.
Thanks
Tom