NextXbase POS
Point of Sale Terminal
Admin
Manager - Terminal 01
Croissant$3.00
Sourdough Loaf$5.25
Shopping Cart0 items
Subtotal$0.00
Tax (8.00%)$0.00
Total$0.00
</> NextXbase
1 *!* ===========================================================================
2 *!* POSvfp.prg -- Full-Screen Touch POS Terminal (Microsoft Visual FoxPro 9.0)
3 *!*
4 *!* Pure Visual FoxPro OOP syntax: CREATEOBJECT("Form"), .AddObject(),
5 *!* WITH ... ENDWITH blocks, .Top / .Left / .Width / .Height / .Caption /
6 *!* .BackColor = RGB() / .ForeColor = RGB() / .FontName / .FontSize / .FontBold,
7 *!* MESSAGEBOX(), and READ EVENTS.
8 *!* ===========================================================================
9
10 STATIC s_aHeld := {}
11
12 PROCEDURE Main()
13 LOCAL oForm, aCat, aPay, n
14 LOCAL nNavy, nLightBlue, nWhite
15
16 nNavy = RGB( 30, 58, 110 )
17 nLightBlue = RGB( 191, 219, 254 )
18 nWhite = RGB( 255, 255, 255 )
19
20 oForm = CREATEOBJECT( "Form" )
21 WITH oForm
22 .Caption = "NextXbase -- Touch POS (Visual FoxPro dialect)"
23 .Top = 0
24 .Left = 0
25 .Width = 1580
26 .Height = 800
27 ENDWITH
28
29 *!* ---- Header Bar --------------------------------------------------------
30 oForm.AddObject( "lblHdrBg", "Label" )
31 WITH oForm.lblHdrBg
32 .Top = 0
33 .Left = 0
34 .Width = 1580
35 .Height = 60
36 .Caption = ""
37 .BackColor = nNavy
38 ENDWITH
39
40 oForm.AddObject( "lblTitle", "Label" )
41 WITH oForm.lblTitle
42 .Top = 8
43 .Left = 24
44 .Width = 400
45 .Height = 28
46 .Caption = "NextXbase POS"
47 .FontName = "Segoe UI"
48 .FontSize = 22
49 .FontBold = .T.
50 .ForeColor = nWhite
51 .BackColor = nNavy
52 ENDWITH
53
54 oForm.AddObject( "lblSub", "Label" )
55 WITH oForm.lblSub
56 .Top = 36
57 .Left = 24
58 .Width = 400
59 .Height = 18
60 .Caption = "Point of Sale Terminal"
61 .FontName = "Segoe UI"
62 .FontSize = 13
63 .ForeColor = nLightBlue
64 .BackColor = nNavy
65 ENDWITH
66
67 oForm.AddObject( "lblUser", "Label" )
68 WITH oForm.lblUser
69 .Top = 12
70 .Left = 1150
71 .Width = 220
72 .Height = 20
73 .Caption = "Admin"
74 .FontName = "Segoe UI"
75 .FontSize = 13
76 .Alignment = 1
77 .ForeColor = nWhite
78 .BackColor = nNavy
79 ENDWITH
80
81 oForm.AddObject( "lblRole", "Label" )
82 WITH oForm.lblRole
83 .Top = 32
84 .Left = 1150
85 .Width = 220
86 .Height = 18
87 .Caption = "Manager - Terminal 01"
88 .FontName = "Segoe UI"
89 .FontSize = 13
90 .Alignment = 1
91 .ForeColor = nLightBlue
92 .BackColor = nNavy
93 ENDWITH
94
95 *!* ---- Product Catalog Grid ----------------------------------------------
96 oForm.AddObject( "oGrid", "PosProductGrid" )
97 WITH oForm.oGrid
98 .Top = 164
99 .Left = 12
100 .Width = 1150
101 .Height = 574
102 .TileMinWidth = 140
103 .ImageSize = 96
104 .BackColor = RGB( 241, 245, 249 )
105 .AddProduct( "d1", "Cola", 2.50, "img/cola.png", "drinks" )
106 .AddProduct( "d2", "Lemon Soda", 2.50, "img/lemon_soda.png", "drinks" )
107 .AddProduct( "d3", "Water", 1.50, "img/water.png", "drinks" )
108 .AddProduct( "b1", "Coffee", 3.00, "img/coffee.png", "beverages" )
109 .AddProduct( "b2", "Hot Tea", 2.25, "img/hot_tea.png", "beverages" )
110 .AddProduct( "f1", "Burger", 8.99, "img/burger.png", "food" )
111 .AddProduct( "f2", "Fries", 3.50, "img/fries.png", "food" )
112 .AddProduct( "f3", "Pizza Slice", 5.99, "img/pizza_slice.png", "food" )
113 .AddProduct( "f4", "Salad", 6.50, "img/salad.png", "food" )
114 .AddProduct( "s1", "Chips", 2.00, "img/chips.png", "snacks" )
115 .AddProduct( "s2", "Candy Bar", 1.50, "img/candy_bar.png", "snacks" )
116 .AddProduct( "x1", "Ice Cream", 4.50, "img/ice_cream.png", "desserts" )
117 .AddProduct( "x2", "Cake Slice", 5.50, "img/cake_slice.png", "desserts" )
118 .AddProduct( "k1", "Croissant", 3.00, "img/croissant.png", "bakery" )
119 .AddProduct( "k2", "Sourdough Loaf", 5.25, "img/sourdough_loaf.png", "bakery" )
120 ENDWITH
121
122 *!* ---- Category Filter Tiles ---------------------------------------------
123 aCat = { { "", "All", "bi-grid-3x3-gap-fill", RGB( 107, 114, 128 ) }, ;
124 { "drinks", "Drinks", "bi-cup-straw", RGB( 59, 130, 246 ) }, ;
125 { "food", "Food", "bi-egg-fried", RGB( 34, 197, 94 ) }, ;
126 { "snacks", "Snacks", "bi-basket-fill", RGB( 234, 179, 8 ) }, ;
127 { "desserts", "Desserts", "bi-cake2-fill", RGB( 236, 72, 153 ) }, ;
128 { "beverages", "Beverages", "bi-cup-hot-fill", RGB( 168, 85, 247 ) }, ;
129 { "bakery", "Bakery", "bi-shop", RGB( 249, 115, 22 ) } }
130 FOR n = 1 TO ALEN( aCat, 1 )
131 AddCatTile( oForm, oForm.oGrid, n, aCat[ n ], 12 + ( n - 1 ) * 150 )
132 ENDFOR
133
134 *!* ---- Shopping Cart -----------------------------------------------------
135 oForm.AddObject( "oCart", "PosCart" )
136 WITH oForm.oCart
137 .Top = 68
138 .Left = 1176
139 .Width = 264
140 .Height = 390
141 .TaxRate = 0.08
142 .Title = "Shopping Cart"
143 .CheckoutText = "Complete Order"
144 .BackColor = RGB( 10, 10, 10 )
145 ENDWITH
146
147 *!* ---- Touch Numerical Pinpad --------------------------------------------
148 oForm.AddObject( "oPad", "PosNumpad" )
149 WITH oForm.oPad
150 .Top = 468
151 .Left = 1176
152 .Width = 264
153 .Height = 270
154 .BackColor = RGB( 30, 41, 59 )
155 ENDWITH
156
157 *!* ---- Payment & Action Tiles --------------------------------------------
158 aPay = { { "CASH", "bi-cash-stack", RGB( 16, 185, 129 ) }, ;
159 { "CARD", "bi-credit-card-fill", RGB( 59, 130, 246 ) }, ;
160 { "SPLIT", "bi-scissors", RGB( 168, 85, 247 ) }, ;
161 { "DISC", "bi-tag-fill", RGB( 245, 158, 11 ) }, ;
162 { "HOLD", "bi-pause-fill", RGB( 51, 65, 85 ) }, ;
163 { "VOID", "bi-slash-circle", RGB( 239, 68, 68 ) }, ;
164 { "CANCEL", "bi-x-lg", RGB( 244, 63, 94 ) } }
165 FOR n = 1 TO ALEN( aPay, 1 )
166 AddPayTile( oForm, oForm.oCart, n, aPay[ n ], 68 + ( n - 1 ) * 96 )
167 ENDFOR
168
169 *!* ---- Event Bindings ----------------------------------------------------
170 oForm.oGrid.OnSelect = { | hProd | AddToCart( oForm.oCart, oForm.oPad, hProd ) }
171 oForm.oCart.OnCheckout = { || ProcessPayment( oForm.oCart, "CARD" ) }
172
173 oForm.Show()
174 READ EVENTS
175
176 RETURN
177
178 STATIC FUNCTION AddCatTile( oForm, oGrid, nIdx, aC, nLeft )
179 LOCAL cName, oTile, cCatId
180 cName = "cmdCat" + LTRIM( STR( nIdx ) )
181 cCatId = aC[ 1 ]
182 oTile = oForm.AddObject( cName, "PosTile" )
183 WITH oTile
184 .Top = 72
185 .Left = nLeft
186 .Width = 140
187 .Height = 80
188 .Caption = aC[ 2 ]
189 .Icon = aC[ 3 ]
190 .BackColor = aC[ 4 ]
191 .OnClick = { || oGrid.Filter := cCatId, oGrid.Refresh() }
192 ENDWITH
193 RETURN oTile
194
195 STATIC FUNCTION AddPayTile( oForm, oCart, nIdx, aP, nTop )
196 LOCAL cName, oTile, cPayKey
197 cName = "cmdPay" + LTRIM( STR( nIdx ) )
198 cPayKey = aP[ 1 ]
199 oTile = oForm.AddObject( cName, "PosTile" )
200 WITH oTile