Final part about ESC/POS is to learn how to call the routines specified by the printer/drawer and customer display files.
Open drawer:
Code: Select all
Public Sub openDrawer(fnc As Byte)
'Dim tmp As String, ret As Integer
If DRStatus = 1 Then 'command to IODR
tmp = genPulse(stt.gDRPin)
ret = IODR.WriteData(tmp, Len(tmp))
If fnc = 1 Then
Call noSale
End If
ElseIf DRStatus = 2 Then 'command to IO
tmp = genPulse(stt.gDRPin)
ret = IORP.WriteData(tmp, Len(tmp))
If fnc = 1 Then
Call noSale
End If
End If
End Sub
Code: Select all
Public Sub noSale()
Dim rs As New Recordset
'Dim tmp As String, ret As Integer
'save to disk
ADOCon.Execute "insert into daily_nskey values('" & clerkNo & "',#" & Format(Date & " " & Time, "mm/dd/yyyy hh:mm:ss") & "#,1)"
If stt.gablePrint <> 0 Then
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, Height, Width, 0, Colour)
'information line no sale clerk machine date time
tmp = tmp & "NOSALE "
tmp = tmp & Left(clerkNo, 15) & Space(15 - Len(clerkNo)) & " "
tmp = tmp & Format(Machine, "00") & " "
tmp = tmp & Format(Date & " " & Time, "dd/mm/yy hh:mm") & lineFeed
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End If
End Sub
Public Sub printRAPO()
Dim rs As New Recordset
'Dim tmp As String, ret As Integer
Dim tot As Currency
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
rs.Open "select desn,rec_no,machine,t_date from ref_clerk,trans where rec_no='" & rec_no & "' and trans.clerk=ref_clerk.ck_code", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, Height, Width, 0, Colour)
'information line rec_no clerk machine date time
tmp = tmp & Mid(rs!rec_no, 6, 5) & " "
tmp = tmp & Left(rs!desn, 16) & Space(16 - Len(rs!desn)) & " "
tmp = tmp & Format(rs!Machine, "00") & " "
tmp = tmp & Format(rs!t_date, "dd/mm/yy hh:mm") & lineFeed
tmp = tmp & String(40, "-") & lineFeed
'rapo ( amounts )
tmp = tmp & printRPO
'Call printRPO
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End If
End Sub
Public Sub printPBPay()
Dim rs As New Recordset
'Dim tmp As String, tmp1 As String, tmp2 As String, ret As Integer
Dim tmp1 As String, tmp2 As String
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
rs.Open "select ref_customer.c_Code + ' - ' + ref_customer.desn as [By CODE],ref_clerk.desn,ref_customer.balance,Trans.rec_no,machine,t_date from Trans,ref_clerk,Daily_PB_Pay,ref_customer where Trans.clerk=ref_clerk.ck_code and Trans.rec_no=Daily_PB_Pay.rec_no and Daily_PB_Pay.c_Code=ref_customer.c_Code and Trans.rec_no='" & rec_no & "'", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then 'pb payment
'Welcome text
tmp = printWelcome & lineFeed
stt.getBTH font, Height, Width, Emp, Colour
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'PB code & name
'tmp = tmp & Left(rs![by code], 40 - (Len(Format(rs!balance, "0.00")) + 1))
'tmp = tmp & Space(40 - (Len(Format(rs!balance, "0.00")) + Len(tmp))) & Format(rs!balance, "0.00") & lineFeed
tmp1 = Format(rs!balance, "0.00")
tmp2 = Left(rs![by code], 40 - (Len(tmp1) + 1))
tmp = tmp & tmp2 & Space(40 - (Len(tmp1) + Len(tmp2))) & tmp1 & lineFeed
'information line rec_no clerk machine date time
tmp = tmp & Mid(rs!rec_no, 6, 5) & " "
tmp = tmp & Left(rs!desn, 16) & Space(16 - Len(rs!desn)) & " "
tmp = tmp & Format(rs!Machine, "00") & " "
tmp = tmp & Format(rs!t_date, "dd/mm/yy hh:mm") & lineFeed
tmp = tmp & String(40, "-") & lineFeed
'pb previouse balance
tmp = tmp & selectMode(font, Emp, 1, Width, 0, Colour) 'double height
tmp = tmp & printPreBalance(rs!balance)
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'payments ( + amounts )
tmp = tmp & printPayments
tmp = tmp & printBalance
'pb current balance
tmp = tmp & selectMode(font, Emp, 1, Width, 0, Colour) 'double height
tmp1 = Format(rs!balance, "0.00")
tmp = tmp & "New Balance " & Space(40 - (Len(tmp1) + 12)) & tmp1 & lineFeed
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour) & lineFeed
'Goodbye text
tmp = tmp & printGoodBye & lineFeed
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
'tmp = tmp & "Software by DRT 011 4202420" & lineFeed
tmp = tmp & "POS System By " & oemLine & Space(20 - Len(oemLine)) & " [DRT]" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End If
End Sub
Public Sub printKitchen(IOKP As IO, isSM As Boolean, Optional sm_code As String, Optional sm_desn As String) '0-no KP 1 - stand alone hardware 3-with printer hardware
Dim rs As New Recordset
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
rs.Open "select desn,rec_no,machine,t_date from ref_clerk,trans where rec_no='" & rec_no & "' and trans.clerk=ref_clerk.ck_code", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, Height, Width, 0, Colour)
'information line rec_no clerk machine date time
tmp = tmp & Mid(rs!rec_no, 6, 5) & " "
tmp = tmp & Left(rs!desn, 16) & Space(16 - Len(rs!desn)) & " "
tmp = tmp & Format(rs!Machine, "00") & " "
tmp = tmp & Format(rs!t_date, "dd/mm/yy hh:mm") & lineFeed
If isSM = True Then tmp = tmp & sm_code & Space(40 - (Len(sm_code) + Len(sm_desn))) & sm_desn & lineFeed
tmp = tmp & String(40, "-") & lineFeed
'items with respective discounts
tmp = tmp & printItemDis
tmp = tmp & lineFeed
'item counter
tmp = tmp & printItemCounter
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IOKP.WriteData(tmp, Len(tmp))
End If
End Sub
Public Sub DprintHeader(hdType As Byte, t_date As Date, isPB As Boolean, isSM As Boolean, Optional c_Code As String, Optional PB_Name As String, Optional balance As Currency, Optional sm_code As String, Optional sm_desn As String)
'hdType=0 Item bill hdType=1 PBPayment
'Dim tmp As String, tmp1 As String, ret As Integer
Dim tmp1 As String
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
'Welcome text
tmp = printWelcome & lineFeed
stt.getBTH font, Height, Width, Emp, Colour
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'PB code & name
If isPB = True Then
tmp1 = Left((c_Code & " - " & PB_Name), 40 - (Len(Format(balance, "0.00")) + 1))
tmp = tmp & tmp1 & Space(40 - (Len(Format(balance, "0.00")) + Len(tmp1))) & Format(balance, "0.00") & lineFeed
End If
'information line rec_no clerk machine date time
tmp = tmp & Mid(mncl.gRec_no, 6, 5) & " "
tmp = tmp & Left(clerkName, 16) & Space(16 - Len(clerkName)) & " "
tmp = tmp & Format(Machine, "00") & " "
tmp = tmp & Format(t_date, "dd/mm/yy hh:mm") & lineFeed
If hdType = 0 Then 'item bill
If isSM = True Then tmp = tmp & sm_code & Space(40 - (Len(sm_code) + Len(sm_desn))) & sm_desn & lineFeed
tmp = tmp & "ITEM PRICE QTY AMOUNT" & lineFeed
'----------------------------------------
'cccccccc sssssss.ss qqqqqqq aaaaaaa.aa
'8 10 7 10
End If
tmp = tmp & String(40, "-") & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintItemDis(plu_code As String, desn As String, qty As String, Rate As String, amt As String, isItmDis As Boolean, Optional Key As String, Optional dAmount As String)
'Dim tmp As String, ret As Integer
'print item
tmp = desn & lineFeed
'print code,price,qty,amount
tmp = tmp & Right(plu_code, 8) & Space(8 - Len(plu_code)) & " "
tmp = tmp & Space(10 - Len(Rate)) & Rate & " "
tmp = tmp & Space(7 - Len(qty)) & qty & " "
tmp = tmp & Space(10 - Len(amt)) & amt & lineFeed
If isItmDis = True Then
tmp = tmp & " ITM DIS " & Left(Key, 20) & Space(20 - Len(Key)) & Space(10 - Len(dAmount)) & dAmount & lineFeed 'print discount
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintSubTDis(disStr As String)
'Dim tmp As String, ret As Integer
tmp = lineFeed & disStr & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintSTDVoid(disStr As String)
'Dim tmp As String, ret As Integer
tmp = lineFeed & disStr & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintTax(taxStr As String)
'Dim tmp As String, ret As Integer
tmp = lineFeed & taxStr & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintNetTotal(netStr As String)
'Dim tmp As String, ret As Integer
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
tmp = lineFeed
stt.getBTH font, Height, Width, Emp, Colour 'to increse height & back
tmp = tmp & selectMode(font, Emp, 1, Width, 0, Colour) 'double height
tmp = tmp & netStr & lineFeed
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintPayments(prnStr As String)
'Dim tmp As String, ret As Integer
tmp = prnStr & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DPrintFooter(isPB As Boolean, Optional amount As Currency, Optional NB As Currency, Optional YouSave As Currency)
'Dim tmp As String, tmp1 As String, ret As Integer
Dim tmp1 As String
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
stt.getBTH font, Height, Width, Emp, Colour
tmp = ""
'credit to PB
If isPB = True Then
tmp = selectMode(font, Emp, 1, Width, 0, Colour)
tmp1 = Format(amount, "##0.00")
tmp = tmp & "CREDIT TO PB" & Space(18) & Space(10 - Len(tmp1)) & Right(tmp1, 10) & lineFeed
tmp1 = Format(NB, "##0.00")
tmp = tmp & "NEW BALANCE" & Space(19) & Space(10 - Len(tmp1)) & Right(tmp1, 10) & lineFeed
End If
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'item counter
tmp1 = mncl.Count
tmp = tmp & "ITEM COUNTER" & Space(28 - Len(tmp1)) & tmp1 & lineFeed & lineFeed
'total saving
If YouSave <> 0 Then
tmp1 = "Rs. " & Format(-YouSave, "0.00")
tmp = tmp & "Your saving on this invoice" & Space(13 - Len(tmp1)) & tmp1 & lineFeed & lineFeed
End If
'Goodbye text
tmp = tmp & printGoodBye & lineFeed
tmp = tmp & setJust(1) 'centre
tmp = tmp & "Software by ROBOT.LK Labs https://robot.lk" & lineFeed
tmp = tmp & setJust(0) 'left
'no logo printing in direct mode
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintVoid(cplu_code As String, cqty As String, cRate As String, camt As String, ctotDis As String)
'Dim tmp As String, ret As Integer
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, 1, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
tmp = tmp & "< < VOID > >" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'print code,price,qty,amount
tmp = tmp & Right(cplu_code, 8) & Space(8 - Len(cplu_code)) & " "
tmp = tmp & Space(10 - Len(cRate)) & cRate & " "
tmp = tmp & Space(7 - Len(cqty)) & cqty & " "
tmp = tmp & Space(10 - Len(camt)) & camt & lineFeed
If ctotDis <> "" Then tmp = tmp & " DISCOUNT VOID" & Space(40 - (Len(ctotDis) + 14)) & ctotDis & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintErrCorrect(cplu_code As String, cqty As String, cRate As String, camt As String, ctotDis As String)
'Dim tmp As String, ret As Integer
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, 1, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
tmp = tmp & "< < ERROR CORRECT > >" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'print code,price,qty,amount
tmp = tmp & Right(cplu_code, 8) & Space(8 - Len(cplu_code)) & " "
tmp = tmp & Space(10 - Len(cRate)) & cRate & " "
If Len(cqty) <= 7 Then tmp = tmp & Space(7 - Len(cqty)) & cqty & " "
If Len(camt) <= 10 Then tmp = tmp & Space(10 - Len(camt)) & camt & lineFeed
If ctotDis <> "" Then tmp = tmp & " DISCOUNT VOID" & Space(40 - (Len(ctotDis) + 14)) & ctotDis & lineFeed
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub DprintTrnVoid()
'Dim tmp As String, ret As Integer
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, 1, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
tmp = tmp & "< < RECEIPT VOID > >" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub PrintInvoice()
Dim rs As New Recordset
'Dim tmp As String, tmp1 As String, tmp2 As String, ret As Integer
Dim tmp1 As String, tmp2 As String
Dim tot As Currency, tot1 As Currency
Dim isPB As Boolean, isSM As Boolean
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
'Welcome text
tmp = printWelcome & lineFeed
stt.getBTH font, Height, Width, Emp, Colour
rs.Open "select ref_customer.c_Code + ' - ' + ref_customer.desn as [By CODE]," & _
" ref_salesman.sm_Code,ref_salesman.desn as sm_desn,ref_clerk.desn,ref_customer.balance,Trans.rec_no,machine,t_date,amount" & _
" From Trans, ref_clerk, Daily_PB, ref_customer, ref_salesman, daily_sm" & _
" where Trans.clerk=ref_clerk.ck_code and Trans.rec_no=Daily_PB.rec_no and Daily_PB.c_Code=ref_customer.c_Code and" & _
" daily_sm.rec_no = Trans.rec_no And ref_salesman.sm_code = daily_sm.sm_code and Trans.rec_no='" & rec_no & "'", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then 'pb & sm
isPB = True
isSM = True
Else 'no (pb or sm) > try sm
Set rs = New Recordset
rs.Open "select ref_salesman.sm_Code,ref_salesman.desn as sm_desn,ref_clerk.desn,Trans.rec_no,machine,t_date from Trans,ref_clerk,ref_salesman,daily_sm where Trans.clerk=ref_clerk.ck_code and daily_sm.rec_no=Trans.rec_no and ref_salesman.sm_code=daily_sm.sm_code and Trans.rec_no='" & rec_no & "'", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then 'sm found
isPB = False
isSM = True
Else 'sm not found > try pb
Set rs = New Recordset
rs.Open "select ref_customer.c_Code + ' - ' + ref_customer.desn as [By CODE],ref_clerk.desn,ref_customer.balance,Trans.rec_no,machine,t_date,amount from Trans,ref_clerk,Daily_PB,ref_customer where Trans.clerk=ref_clerk.ck_code and Trans.rec_no=Daily_PB.rec_no and Daily_PB.c_Code=ref_customer.c_Code and Trans.rec_no='" & rec_no & "'", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
isPB = True
isSM = False
Else 'no sm no pb
isPB = False
isSM = False
Set rs = New Recordset
rs.Open "select desn,rec_no,machine,t_date from ref_clerk,trans where rec_no='" & rec_no & "' and trans.clerk=ref_clerk.ck_code", ADOCon, adOpenStatic, adLockReadOnly
End If
End If
End If
If rs.RecordCount <> 0 Then
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'PB code & name
If isPB = True Then
tmp1 = Format(rs!balance, "0.00")
tmp2 = Left(rs![by code], 40 - (Len(tmp1) + 1))
tmp = tmp & tmp2 & Space(40 - (Len(tmp1) + Len(tmp2))) & tmp1 & lineFeed
End If
'information line rec_no clerk machine date time
tmp = tmp & Mid(rs!rec_no, 6, 5) & " "
tmp = tmp & Left(rs!desn, 16) & Space(16 - Len(rs!desn)) & " "
tmp = tmp & Format(rs!Machine, "00") & " "
tmp = tmp & Format(rs!t_date, "dd/mm/yy hh:mm") & lineFeed
If isSM = True Then tmp = tmp & rs!sm_code & Space(40 - (Len(rs!sm_code) + Len(rs!sm_desn))) & rs!sm_desn & lineFeed
tmp = tmp & "ITEM PRICE QTY AMOUNT" & lineFeed
'----------------------------------------
'cccccccc sssssss.ss qqqqqqq aaaaaaa.aa
'8 10 7 10
tmp = tmp & String(40, "-") & lineFeed
'items with respective discounts
tot = 0
tmp = tmp & printItemDis(tot) & lineFeed
'sub total discounts
tot1 = 0
tmp = tmp & printSubTotDis(tot1)
tot = tot + tot1
'tax
tot1 = 0
tmp = tmp & printTax(tot1) & lineFeed
tot = tot + tot1
'net total
tmp = tmp & selectMode(font, Emp, 1, Width, 0, Colour) 'double height
tmp1 = Format(tot, "##0.00")
tmp = tmp & "NET TOTAL " & Space(20) & Space(10 - Len(tmp1)) & Right(tmp1, 10) & lineFeed
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
'payments ( + amounts )
tmp = tmp & printPayments
'balance if any ( - amounts )
tmp = tmp & printBalance
'credit to PB
If isPB = True Then
tmp = tmp & selectMode(font, Emp, 1, Width, 0, Colour)
tmp1 = Format(rs!amount, "##0.00")
tmp = tmp & "CREDIT TO PB" & Space(18) & Space(10 - Len(tmp1)) & Right(tmp1, 10) & lineFeed
tmp1 = Format(rs!balance, "##0.00")
tmp = tmp & "NEW BALANCE" & Space(19) & Space(10 - Len(tmp1)) & Right(tmp1, 10) & lineFeed
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
End If
'item counter
tmp = tmp & printItemCounter & lineFeed
End If
'You save
tmp = tmp & printYouSave
'Goodbye text
tmp = tmp & printGoodBye & lineFeed
tmp = tmp & selectMode(font, Emp, Height, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
'tmp = tmp & "Software by DRT 011 4202420" & lineFeed
tmp = tmp & "POS System By " & oemLine & Space(20 - Len(oemLine)) & " [DRT]" & lineFeed
tmp = tmp & setJust(0) 'left
'no logo printing in direct mode
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Private Function printWelcome() As String
Dim tmp1 As String
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
printWelcome = setJust(1) 'centre
'stt.gWM1
tmp1 = stt.gWM1
If tmp1 <> "0" Then
stt.getWM1H font, Height, Width, Emp, Colour
printWelcome = printWelcome & selectMode(font, Emp, Height, Width, 0, Colour)
printWelcome = printWelcome & tmp1 & lineFeed
End If
'stt.gWM2
tmp1 = stt.gWM2
If tmp1 <> "0" Then
stt.getWM2H font, Height, Width, Emp, Colour
printWelcome = printWelcome & selectMode(font, Emp, Height, Width, 0, Colour)
printWelcome = printWelcome & tmp1 & lineFeed
End If
'stt.gWM3
tmp1 = stt.gWM3
If tmp1 <> "0" Then
stt.getWM3H font, Height, Width, Emp, Colour
printWelcome = printWelcome & selectMode(font, Emp, Height, Width, 0, Colour)
printWelcome = printWelcome & tmp1 & lineFeed
End If
'stt.gWM4
tmp1 = stt.gWM4
If tmp1 <> "0" Then
stt.getWM4H font, Height, Width, Emp, Colour
printWelcome = printWelcome & selectMode(font, Emp, Height, Width, 0, Colour)
printWelcome = printWelcome & tmp1 & lineFeed
End If
'stt.gWM5
tmp1 = stt.gWM5
If tmp1 <> "0" Then
stt.getWM5H font, Height, Width, Emp, Colour
printWelcome = printWelcome & selectMode(font, Emp, Height, Width, 0, Colour)
printWelcome = printWelcome & tmp1 & lineFeed
End If
'stt.gWM6
tmp1 = stt.gWM6
If tmp1 <> "0" Then
stt.getWM6H font, Height, Width, Emp, Colour
printWelcome = printWelcome & selectMode(font, Emp, Height, Width, 0, Colour)
printWelcome = printWelcome & tmp1 & lineFeed
End If
printWelcome = printWelcome & setJust(0) 'left
End Function
Private Function printGoodBye() As String
Dim tmp1 As String
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
printGoodBye = setJust(1) 'centre
'stt.gGM1
tmp1 = stt.gGM1
If tmp1 <> "0" Then
stt.getGM1H font, Height, Width, Emp, Colour
printGoodBye = printGoodBye & selectMode(font, Emp, Height, Width, 0, Colour)
printGoodBye = printGoodBye & tmp1 & lineFeed
End If
'stt.gGM2
tmp1 = stt.gGM2
If tmp1 <> "0" Then
stt.getGM2H font, Height, Width, Emp, Colour
printGoodBye = printGoodBye & selectMode(font, Emp, Height, Width, 0, Colour)
printGoodBye = printGoodBye & tmp1 & lineFeed
End If
'stt.gGM3
tmp1 = stt.gGM3
If tmp1 <> "0" Then
stt.getGM3H font, Height, Width, Emp, Colour
printGoodBye = printGoodBye & selectMode(font, Emp, Height, Width, 0, Colour)
printGoodBye = printGoodBye & tmp1 & lineFeed
End If
printGoodBye = printGoodBye & setJust(0) 'left
End Function
Private Function printItemDis(Optional tot As Currency) As String
Dim rs As New Recordset
Dim rsB As New Recordset
Dim tmp1 As String
rs.Open "SELECT ref_plu.PLU_Code, ref_plu.PLU_Desn, Daily_Sales.Qty, Daily_Sales.Amount, Daily_Plus_Minus.Key, ref_disc.Desn AS dDesn, Daily_Plus_Minus.Amount AS dAmount " & _
"FROM ((ref_plu INNER JOIN Daily_Sales ON ref_plu.PLU_Code = Daily_Sales.plu_code) LEFT JOIN Daily_Plus_Minus ON (cstr(Daily_Sales.CNT) = Daily_Plus_Minus.Status) AND (Daily_Sales.rec_no = Daily_Plus_Minus.rec_no)) LEFT JOIN ref_disc ON Daily_Plus_Minus.Key = ref_disc.Code " & _
"WHERE Daily_Sales.rec_no='" & rec_no & "' " & _
"ORDER BY Daily_Sales.CNT", ADOCon, adOpenStatic, adLockReadOnly
Do While Not rs.EOF
'print item
printItemDis = printItemDis & rs!plu_desn & lineFeed
'print code,price,qty,amount
printItemDis = printItemDis & Right(rs!plu_code, 8) & Space(8 - Len(rs!plu_code)) & " "
If rs!qty <> 0 Then
tmp1 = Format(Round(CCur(rs!amount) / CDbl(rs!qty), 2), "##0.00")
Else
tmp1 = "0.00"
End If
printItemDis = printItemDis & Space(10 - Len(tmp1)) & tmp1 & " "
tmp1 = rs!qty
printItemDis = printItemDis & Space(7 - Len(tmp1)) & tmp1 & " "
tmp1 = Format(rs!amount, "##0.00")
printItemDis = printItemDis & Space(10 - Len(tmp1)) & tmp1
printItemDis = printItemDis & lineFeed
tot = tot + rs!amount
If IsNull(rs!Key) = False Then
printItemDis = printItemDis & " ITM DIS "
tmp1 = Format(rs!dAmount, "##0.00")
printItemDis = printItemDis & Left(rs!dDesn, 20) & Space(20 - Len(rs!dDesn)) & Space(10 - Len(tmp1))
printItemDis = printItemDis & tmp1
printItemDis = printItemDis & lineFeed
tot = tot + rs!dAmount
End If
rs.MoveNext
Loop
End Function
Private Function printSubTotDis(Optional tot As Currency) As String
Dim rs As New Recordset
Dim tmp1 As String
rs.Open "select rec_no,[key] as code,desn,status,sum(amount) as samount " & _
"From daily_plus_minus, ref_disc " & _
"where rec_no='" & rec_no & "' and status='SubTot' and ref_disc.code=daily_plus_minus.[key] " & _
"group by rec_no,[key],desn,status", ADOCon, adOpenStatic, adLockReadOnly
Do While Not rs.EOF
printSubTotDis = printSubTotDis & "SUBT DIS "
tmp1 = Format(rs!samount, "##0.00")
printSubTotDis = printSubTotDis & Left(rs!desn, 21) & Space(21 - Len(rs!desn)) & Space(10 - Len(tmp1))
printSubTotDis = printSubTotDis & tmp1
printSubTotDis = printSubTotDis & lineFeed
tot = tot + rs!samount
rs.MoveNext
Loop
End Function
Private Function printTax(Optional tot As Currency) As String
Dim rs As New Recordset
Dim tmp1 As String
rs.Open "select desn,amount " & _
"From daily_tax,ref_tax " & _
"where daily_tax.t_code=ref_tax.t_code and rec_no='" & rec_no & "' order by daily_tax.t_code", ADOCon, adOpenStatic, adLockReadOnly
Do While Not rs.EOF
tmp1 = Format(rs!amount, "##0.00")
printTax = printTax & Left(rs!desn, 20) & Space(20 - Len(rs!desn)) & Space(10 - Len(tmp1))
printTax = printTax & tmp1
printTax = printTax & lineFeed
tot = tot + rs!amount
rs.MoveNext
Loop
End Function
Private Function printPayments() As String
Dim rs As New Recordset
Dim tmp1 As String
rs.Open "select rec_no,daily_tot.m_code,desn,sum(amount) as samount " & _
"From daily_tot, ref_mode " & _
"Where rec_no='" & rec_no & "' and Amount > 0 And daily_tot.m_code = ref_mode.m_code " & _
"group by rec_no,daily_tot.m_code,desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not rs.EOF
tmp1 = Format(rs!samount, "##0.00")
tmp1 = rs!desn & Space(30 - Len(rs!desn)) & Space(10 - Len(tmp1)) & Right(tmp1, 10)
printPayments = printPayments & tmp1 & lineFeed
rs.MoveNext
Loop
End Function
Private Function printBalance() As String
Dim rs As New Recordset
Dim tmp1 As String
rs.Open "select rec_no,desn,sum(amount) as samount " & _
"From daily_tot, ref_mode " & _
"Where rec_no='" & rec_no & "' and Amount < 0 And daily_tot.m_code = ref_mode.m_code " & _
"group by rec_no,desn", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
tmp1 = Format(-rs!samount, "##0.00")
tmp1 = "BALANCE" & Space(23) & Space(10 - Len(tmp1)) & Right(tmp1, 10)
printBalance = tmp1 & lineFeed
End If
End Function
Private Function printItemCounter() As String
Dim rs As New Recordset
rs.Open "select rec_no,daily_sales.plu_code,ref_plu.plu_desn,sum(daily_sales.qty) as sqty,sum(amount) as samount " & _
"from daily_sales,ref_plu " & _
"where daily_sales.rec_no='" & rec_no & "' and Daily_sales.plu_code=ref_plu.plu_code " & _
"group by rec_no,daily_sales.plu_code,plu_desn", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
printItemCounter = "ITEM COUNTER" & Space(28 - Len(CStr(rs.RecordCount))) & rs.RecordCount & lineFeed
End If
End Function
Private Function printYouSave() As String
Dim rs As New Recordset
Dim tmp1 As String
rs.Open "select sum(amount) as samount " & _
"From daily_plus_minus " & _
"where rec_no='" & rec_no & "' " & _
"group by rec_no", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
If rs!samount <> 0 Then
tmp1 = "Rs. " & Format(-rs!samount, "##0.00")
printYouSave = "Your saving on this invoice" & Space(13 - Len(tmp1)) & tmp1 & lineFeed & lineFeed
End If
End If
End Function
Private Function printPreBalance(curBalance As Currency) As String
Dim tmrs As New Recordset
Dim tmp1 As String
Dim tot As Currency
tmrs.Open "select sum(amount) as tot from daily_tot where rec_no='" & rec_no & "' group by rec_no", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
tot = tmrs!tot
Else
tot = 0
End If
tmp1 = Format(curBalance + tot, "0.00")
printPreBalance = "Previous Balance " & Space(40 - (Len(tmp1) + 17)) & tmp1 & lineFeed
End Function
Private Function printRPO() As String
Dim rs As New Recordset
Dim tmp1 As String
rs.Open "select cash_tray.rec_no,cash_tray.r_code,desn,status,amount " & _
"From cash_tray, ref_rapo, daily_tot " & _
"Where cash_tray.rec_no='" & rec_no & "' and cash_tray.rec_no=daily_tot.rec_no and cash_tray.r_code = ref_rapo.r_code", ADOCon, adOpenStatic, adLockReadOnly
If rs.RecordCount <> 0 Then
If rs!Status = 0 Then
tmp1 = Format(rs!amount, "##0.00")
Else
tmp1 = Format(-rs!amount, "##0.00")
End If
tmp1 = rs!desn & Space(30 - Len(rs!desn)) & Space(10 - Len(tmp1)) & Right(tmp1, 10)
printRPO = printRPO & tmp1 & lineFeed
End If
End Function
Public Sub PrintDailyT(cCloseBalance As Currency)
Dim tmrs As New Recordset
Dim txt As String, txt1 As String
Dim totSales As Currency, totReturns As Currency
Dim curDiscount As Currency, totDiscount As Currency
Dim curTax As Currency, totTax As Currency
Dim curPay As Currency, totPay As Currency
Dim totRA As Currency, totPO As Currency
Dim totCash As Currency
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
'Dim tmp As String, ret As Integer
Dim dtSignIn As Date, dtSignOut As Date
Dim openBalance As Currency, closeBalance As Currency
Dim noOfBills As Integer, noOfRets As Integer, noOfOpens As Integer, noOfCancels As Integer
tmrs.Open "select * from daily_signin where c_code='" & clerkNo & "' and process=0", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
dtSignIn = tmrs!SignIn
dtSignOut = Date + Time
openBalance = tmrs!openBal
' closeBalance = tmrs!closeBal
noOfBills = tmrs!noOfBills
noOfRets = tmrs!noOfRets
noOfOpens = tmrs!noOfOpens
noOfCancels = tmrs!noOfCancels
End If
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, Height, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
tmp = tmp & "Daily Terminal Report" & lineFeed
tmp = tmp & "---------------------" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & "Clerk : " & clerkName & lineFeed
'If Machine = 1 Then
' tmp = tmp & "Station ID : " & Machine & " BORELLA" & lineFeed
'ElseIf Machine = 2 Then
' tmp = tmp & "Station ID : " & Machine & " DEHIWALA" & lineFeed
'End If
tmp = tmp & "Sign-In : " & dtSignIn & lineFeed
tmp = tmp & "Sign-Out : " & dtSignOut & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
txt = Format(openBalance, "0.00")
tmp = tmp & "Opening Balance" & Space(40 - (Len(txt) + 15)) & txt & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
'dtSignIn = DateValue
'Total RA
txt = "0.00"
totRA = 0
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from cash_tray,ref_rapo,daily_tot,trans where status=0 and cash_tray.r_code=ref_rapo.r_code and cash_tray.rec_no=daily_tot.rec_no and cash_tray.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,ref_rapo.r_code,ref_rapo.desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
txt1 = tmrs!desn
txt = Format(tmrs!amt, "###0.00")
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totRA = totRA + tmrs!amt
tmrs.MoveNext
Loop
'print
txt = Format(totRA, "0.00")
tmp = tmp & "Total R/A" & Space(40 - (Len(txt) + 9)) & txt & lineFeed & lineFeed
'Total PO
txt = "0.00"
totPO = 0
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from cash_tray,ref_rapo,daily_tot,trans where status=1 and cash_tray.r_code=ref_rapo.r_code and cash_tray.rec_no=daily_tot.rec_no and cash_tray.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,ref_rapo.r_code,ref_rapo.desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
txt1 = tmrs!desn
txt = Format(-tmrs!amt, "###0.00")
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totPO = totPO + -tmrs!amt
tmrs.MoveNext
Loop
'print
txt = Format(totPO, "0.00")
tmp = tmp & "Total P/O" & Space(40 - (Len(txt) + 9)) & txt & lineFeed & lineFeed
'Total sales
txt = "0.00"
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_sales,trans where daily_sales.rec_no=trans.rec_no and amount>=0 and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
totSales = tmrs!amt
txt = Format(totSales, "###0.00")
End If
'print
tmp = tmp & " Sales" & Space(40 - (Len(txt) + 6)) & txt & lineFeed
txt = "0.00"
'Total returns
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_sales,trans where daily_sales.rec_no=trans.rec_no and amount<0 and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
totReturns = tmrs!amt
txt = Format(totReturns, "###0.00")
End If
'print
tmp = tmp & " Returns" & Space(40 - (Len(txt) + 8)) & txt & lineFeed
'Daily Sales
'print
txt = Format((totSales + totReturns), "###0.00")
tmp = tmp & "Daily Sales" & Space(40 - (Len(txt) + 11)) & txt & lineFeed & lineFeed
'Discounts
Set tmrs = New Recordset
tmrs.Open "select [key]as K,sum(amount) as amt from daily_plus_minus,trans where daily_plus_minus.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,[key] order by [key]", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
curDiscount = tmrs!amt
txt = Format(curDiscount, "###0.00")
txt1 = tmrs!k
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totDiscount = totDiscount + curDiscount
tmrs.MoveNext
Loop
'Total Discount
'print
txt = Format(totDiscount, "###0.00")
tmp = tmp & "Daily Discounts" & Space(40 - (Len(txt) + 15)) & txt & lineFeed & lineFeed
'Tax
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from daily_tax,ref_tax,trans where daily_tax.t_code=ref_tax.t_code and daily_tax.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,daily_tax.t_code,desn order by daily_tax.t_code", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
curTax = tmrs!amt
txt = Format(curTax, "###0.00")
txt1 = tmrs!desn
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totTax = totTax + curTax
tmrs.MoveNext
Loop
'Total Tax
'print
txt = Format(totTax, "###0.00")
tmp = tmp & "Daily Tax" & Space(40 - (Len(txt) + 9)) & txt & lineFeed & lineFeed
'Credit to PB
txt = "0.00"
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_pb,trans where daily_pb.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
txt = Format(tmrs!amt, "###0.00")
End If
'print
tmp = tmp & "Credit to PB" & Space(40 - (Len(txt) + 12)) & txt & lineFeed
'PB Payments
txt = "0.00"
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_pb_Pay,Daily_tot,trans where daily_pb_Pay.rec_no=Daily_Tot.rec_no and daily_pb_Pay.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
txt = Format(tmrs!amt, "###0.00")
End If
'print
tmp = tmp & "PB Payments" & Space(40 - (Len(txt) + 11)) & txt & lineFeed & lineFeed
'Payments
Set tmrs = New Recordset
tmrs.Open "select ref_mode.m_code,desn,sum(amount) as amt from daily_tot,trans,ref_mode where ref_mode.m_code=daily_tot.m_code and daily_tot.rec_no=trans.rec_no and t_date >=#" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,ref_mode.m_code,desn order by ref_mode.m_code", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
If tmrs!m_code = 1 Then
totCash = tmrs!amt
curPay = totCash - totRA + totPO
Else
curPay = tmrs!amt
End If
txt = Format(curPay, "###0.00")
txt1 = tmrs!desn
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totPay = totPay + curPay
tmrs.MoveNext
Loop
'total Payments
'print
txt = Format(totPay, "###0.00")
tmp = tmp & "Total Payments" & Space(40 - (Len(txt) + 14)) & txt & lineFeed & lineFeed
'total cash on tray
'txt = Format(totCash, "###0.00")
'tmp = tmp & "Cash TRNs" & Space(40 - (Len(txt) + 9)) & txt & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
txt = Format(totCash, "###0.00")
tmp = tmp & "Total Cash Tray" & Space(40 - (Len(txt) + 15)) & txt & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
txt = Format(cCloseBalance, "###0.00")
tmp = tmp & "Closing Balance" & Space(40 - (Len(txt) + 15)) & txt & lineFeed
txt = Format(totCash - cCloseBalance, "###0.00")
tmp = tmp & "Varience" & Space(40 - (Len(txt) + 8)) & txt & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
txt = noOfBills
tmp = tmp & "No Of Bills" & Space(40 - (Len(txt) + 11)) & txt & lineFeed
txt = noOfRets
tmp = tmp & "No Of Returns" & Space(40 - (Len(txt) + 13)) & txt & lineFeed
txt = noOfOpens
tmp = tmp & "No Of Opens" & Space(40 - (Len(txt) + 11)) & txt & lineFeed
txt = noOfCancels
tmp = tmp & "No Of Cancels" & Space(40 - (Len(txt) + 13)) & txt & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
tmp = tmp & setJust(1) 'centre
'tmp = tmp & "Software by DRT 011 4202420" & lineFeed
tmp = tmp & "POS System By " & oemLine & Space(20 - Len(oemLine)) & " [DRT]" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub normalPrintDailyT()
Dim tmrs As New Recordset
Dim txt As String, txt1 As String
Dim totSales As Currency, totReturns As Currency
Dim curDiscount As Currency, totDiscount As Currency
Dim curTax As Currency, totTax As Currency
Dim curPay As Currency, totPay As Currency
Dim totRA As Currency, totPO As Currency
Dim totCash As Currency
'Dim font As Byte, Height As Byte, Width As Byte, Emp As Byte, Colour As Byte
'Dim tmp As String, ret As Integer
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, Height, Width, 0, Colour)
tmp = tmp & setJust(1) 'centre
tmp = tmp & "Daily Terminal Report" & lineFeed
tmp = tmp & "---------------------" & lineFeed
tmp = tmp & setJust(0) 'left
'Total RA
txt = "0.00"
totRA = 0
tmrs.Open "select desn,sum(amount) as amt from cash_tray,ref_rapo,daily_tot,trans where status=0 and cash_tray.r_code=ref_rapo.r_code and cash_tray.rec_no=daily_tot.rec_no and cash_tray.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine,ref_rapo.r_code,ref_rapo.desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
txt1 = tmrs!desn
txt = Format(tmrs!amt, "###0.00")
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totRA = totRA + tmrs!amt
tmrs.MoveNext
Loop
'print
txt = Format(totRA, "0.00")
tmp = tmp & "Total R/A" & Space(40 - (Len(txt) + 9)) & txt & lineFeed & lineFeed
'Total PO
txt = "0.00"
totPO = 0
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from cash_tray,ref_rapo,daily_tot,trans where status=1 and cash_tray.r_code=ref_rapo.r_code and cash_tray.rec_no=daily_tot.rec_no and cash_tray.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine,ref_rapo.r_code,ref_rapo.desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
txt1 = tmrs!desn
txt = Format(-tmrs!amt, "###0.00")
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totPO = totPO + -tmrs!amt
tmrs.MoveNext
Loop
'print
txt = Format(totPO, "0.00")
tmp = tmp & "Total P/O" & Space(40 - (Len(txt) + 9)) & txt & lineFeed & lineFeed
'Total sales
txt = "0.00"
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_sales,trans where daily_sales.rec_no=trans.rec_no and amount>=0 and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
totSales = tmrs!amt
txt = Format(totSales, "###0.00")
End If
'print
tmp = tmp & " Sales" & Space(40 - (Len(txt) + 6)) & txt & lineFeed
txt = "0.00"
'Total returns
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_sales,trans where daily_sales.rec_no=trans.rec_no and amount<0 and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
totReturns = tmrs!amt
txt = Format(totReturns, "###0.00")
End If
'print
tmp = tmp & " Returns" & Space(40 - (Len(txt) + 8)) & txt & lineFeed
'Daily Sales
'print
txt = Format((totSales + totReturns), "###0.00")
tmp = tmp & "Daily Sales" & Space(40 - (Len(txt) + 11)) & txt & lineFeed & lineFeed
'Discounts
Set tmrs = New Recordset
tmrs.Open "select [key]as K,sum(amount) as amt from daily_plus_minus,trans where daily_plus_minus.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine,[key] order by [key]", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
curDiscount = tmrs!amt
txt = Format(curDiscount, "###0.00")
txt1 = tmrs!k
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totDiscount = totDiscount + curDiscount
tmrs.MoveNext
Loop
'Total Discount
'print
txt = Format(totDiscount, "###0.00")
tmp = tmp & "Daily Discounts" & Space(40 - (Len(txt) + 15)) & txt & lineFeed & lineFeed
'Tax
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from daily_tax,ref_tax,trans where daily_tax.t_code=ref_tax.t_code and daily_tax.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine,daily_tax.t_code,desn order by daily_tax.t_code", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
curTax = tmrs!amt
txt = Format(curTax, "###0.00")
txt1 = tmrs!desn
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totTax = totTax + curTax
tmrs.MoveNext
Loop
'Total Tax
'print
txt = Format(totTax, "###0.00")
tmp = tmp & "Daily Tax" & Space(40 - (Len(txt) + 9)) & txt & lineFeed & lineFeed
'Credit to PB
txt = "0.00"
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_pb,trans where daily_pb.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
txt = Format(tmrs!amt, "###0.00")
End If
'print
tmp = tmp & "Credit to PB" & Space(40 - (Len(txt) + 12)) & txt & lineFeed
'PB Payments
txt = "0.00"
Set tmrs = New Recordset
tmrs.Open "select sum(amount) as amt from daily_pb_Pay,Daily_tot,trans where daily_pb_Pay.rec_no=Daily_Tot.rec_no and daily_pb_Pay.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
txt = Format(tmrs!amt, "###0.00")
End If
'print
tmp = tmp & "PB Payments" & Space(40 - (Len(txt) + 11)) & txt & lineFeed & lineFeed
'Payments
Set tmrs = New Recordset
tmrs.Open "select ref_mode.m_code,desn,sum(amount) as amt from daily_tot,trans,ref_mode where ref_mode.m_code=daily_tot.m_code and daily_tot.rec_no=trans.rec_no and datevalue(t_date)=#" & Format(Date, "mm/dd/yyyy") & "# and machine=" & Machine & " group by datevalue(t_date),machine,ref_mode.m_code,desn order by ref_mode.m_code", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
If tmrs!m_code = 1 Then
totCash = tmrs!amt
curPay = totCash - totRA + totPO
Else
curPay = tmrs!amt
End If
txt = Format(curPay, "###0.00")
txt1 = tmrs!desn
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totPay = totPay + curPay
tmrs.MoveNext
Loop
'total Payments
'print
txt = Format(totPay, "###0.00")
tmp = tmp & "Daily Payments" & Space(40 - (Len(txt) + 14)) & txt & lineFeed & lineFeed
'total cash on tray
txt = Format(totCash, "###0.00")
tmp = tmp & "Total CashTray" & Space(40 - (Len(txt) + 14)) & txt & lineFeed & lineFeed
tmp = tmp & setJust(1) 'centre
'tmp = tmp & "Software by DRT 011 4202420" & lineFeed
tmp = tmp & "POS System By " & oemLine & Space(20 - Len(oemLine)) & " [DRT]" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
Public Sub printSalesSummary()
Dim tmrs As New Recordset
Dim totCash As Currency, totRA As Currency, totPO As Currency, curPay As Currency, totPay As Currency
Dim txt As String, txt1 As String, tmp1 As String
Dim dtSignIn As Date, dtSignOut As Date
stt.getBTH font, Height, Width, Emp, Colour
tmp = selectMode(font, Emp, Height, Width, 0, Colour)
tmrs.Open "select * from daily_signin where c_code='" & clerkNo & "' and process=0", ADOCon, adOpenStatic, adLockReadOnly
If tmrs.RecordCount <> 0 Then
dtSignIn = tmrs!SignIn
dtSignOut = Date + Time
End If
'tmp = printWelcome & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
tmp = tmp & setJust(1) 'centre
tmp = tmp & "SALES SUMMARY" & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
tmp = tmp & setJust(0) 'left
tmp = tmp & "Clerk : " & clerkName & lineFeed
If Machine = 1 Then
tmp = tmp & "Station ID : " & Machine & " BORELLA" & lineFeed
ElseIf Machine = 2 Then
tmp = tmp & "Station ID : " & Machine & " DEHIWALA" & lineFeed
End If
tmp = tmp & "Date : " & Date & lineFeed
tmp = tmp & "----------------------------------------" & lineFeed
'Total RA
txt = "0.00"
totRA = 0
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from cash_tray,ref_rapo,daily_tot,trans where status=0 and cash_tray.r_code=ref_rapo.r_code and cash_tray.rec_no=daily_tot.rec_no and cash_tray.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,ref_rapo.r_code,ref_rapo.desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
txt1 = tmrs!desn
txt = Format(tmrs!amt, "###0.00")
'print
' tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totRA = totRA + tmrs!amt
tmrs.MoveNext
Loop
'Total PO
txt = "0.00"
totPO = 0
Set tmrs = New Recordset
tmrs.Open "select desn,sum(amount) as amt from cash_tray,ref_rapo,daily_tot,trans where status=1 and cash_tray.r_code=ref_rapo.r_code and cash_tray.rec_no=daily_tot.rec_no and cash_tray.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,ref_rapo.r_code,ref_rapo.desn", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
txt1 = tmrs!desn
txt = Format(-tmrs!amt, "###0.00")
'print
' tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totPO = totPO + -tmrs!amt
tmrs.MoveNext
Loop
Set tmrs = New Recordset
tmrs.Open "select ref_mode.m_code,desn,sum(amount) as amt from daily_tot,trans,ref_mode where ref_mode.m_code=daily_tot.m_code and daily_tot.rec_no=trans.rec_no and t_date >= #" & Format(dtSignIn, "mm/dd/yyyy hh:mm") & "# and t_date <= #" & Format(dtSignOut, "mm/dd/yyyy hh:mm") & "# and clerk='" & clerkNo & "' and machine=" & Machine & " group by datevalue(t_date),machine,ref_mode.m_code,desn order by ref_mode.m_code", ADOCon, adOpenStatic, adLockReadOnly
Do While Not tmrs.EOF
If tmrs!m_code = 1 Then
totCash = tmrs!amt
curPay = totCash - totRA + totPO
Else
curPay = tmrs!amt
End If
txt = Format(curPay, "###0.00")
txt1 = tmrs!desn
'print
tmp = tmp & " " & txt1 & Space(40 - (Len(txt) + Len(txt1) + 1)) & txt & lineFeed
totPay = totPay + curPay
tmrs.MoveNext
Loop
tmp = tmp & lineFeedN(7)
If stt.gRPpCut = 1 Then 'partial
tmp = tmp & setCut(1)
ElseIf stt.gRPpCut = 2 Then 'full
tmp = tmp & setCut(0)
End If
ret = IORP.WriteData(tmp, Len(tmp))
End Sub
See also:
ESC/POS printer source code at https://robot.lk/viewtopic.php?f=39&t=874
ESC/POS Customer Display source code at https://robot.lk/viewtopic.php?f=39&t=875
Barcode printer source code at https://robot.lk/viewtopic.php?f=39&t=877