-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwh.src
executable file
·490 lines (440 loc) · 13.6 KB
/
wh.src
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
'------------------------------------------------------------
' 入庫,出庫,棚卸
'--------------------------------------------------------------------------
'$include:'const.inc'
'$include:'util.def'
'$include:'util.inc'
'$include:'screen.def'
'$include:'screen.inc'
'$include:'input.def'
'$include:'input.inc'
'$include:'com.def'
'$include:'com.inc'
'$include:'barcode.def'
'$include:'barcode.inc'
'$include:'itemcach.def'
'$include:'itemcach.inc'
'$include:'postcach.def'
'$include:'postcach.inc'
'$include:'wh.def'
'-- screen state
const WH.SCREEN.START =1
const WH.SCREEN.FINISH =-1
const WH.SCREEN.USER =0 ' TODO: hold off
const WH.SCREEN.SCAN =1
const WH.SCREEN.VERIFY =2
const WH.SCREEN.SEND =3
const WH.SCREEN.MISSING =4
const WH.SCREEN.REGISTER =5
const WH.SCREEN.ISSUENEWJAN =6
const WH.SCREEN.INPUTCODE =7
const WH.SCREEN.VERIFYITEM =8
'-- string const variable
const WH.MAXPAGESIZE = 10 ' 10 records per page
global WH.NOTFOUND$[6]: WH.NOTFOUND$="999999"
global WH.MAXNUM$[6]: WH.MAXNUM$="999999"
'-- other const variables
const WH.IDLEN=Util.MAXIDLEN
const WH.ITEMLEN=Util.MAXSTRLEN
const WH.CODELEN=20
const WH.RECORDLEN=100
'-- shared variable
global WH.barcode$[15] ' scanned barcode
global WH.num$[10] ' quantity
global WH.productName$[100] ' item name
global WH.missingId$[10] ' missing id (not barcode)
global WH.productCode$[20] ' product code
global WH.existsBarcode% ' exists JAN?
'------------------------------------------------------------
' check user
'
' NOT USED
'------------------------------------------------------------
function WH.ScanUser%(func%)
private numStr$
call Screen.Init
call Screen.Footer
locate 1,1
print "担当者をスキャンしてください"
locate ,,1 : cursor on
WH.barcode$ = Barcode.BarcodeKey$(Barcode.CODE39$)
if instr(Input.CODE.ESC$, WH.barcode$)>0 then
private ret%
ret%=PostCache.Flush%
WH.ScanUser%=WH.SCREEN.FINISH
exit function
end if
' TODO, if this is required.
WH.ScanUser%=WH.SCREEN.SCAN
end function
'------------------------------------------------------------
' scan barcode
'------------------------------------------------------------
function WH.ScanBarcode%(func%)
private numStr$
private ret%
call Screen.Init
call Screen.Footer
locate 1,1
print "バーコードをスキャンしてください"
locate ,,1 : cursor on
WH.barcode$ = Barcode.BarcodeKey2$(Barcode.EAN13$,Barcode.NW7A$)
if instr(Input.CODE.ESC$, WH.barcode$)>0 then
ret%=PostCache.Flush%
WH.ScanBarcode%=WH.SCREEN.FINISH
exit function
end if
locate 1.3
print "数は?(無制限:"+WH.MAXNUM$+")";
locate 1,9
numStr$=Input.Input$(len(WH.MAXNUM$),1) 'up to 6 digits
if instr(Input.CODE.ESC$,numStr$)>0 then
ret%=PostCache.Flush%
WH.ScanBarcode%=WH.SCREEN.FINISH
exit function
end if
WH.num$=numStr$
WH.ScanBarcode%=WH.SCREEN.VERIFY
end function
'------------------------------------------------------------
' verify the barcode
'------------------------------------------------------------
function WH.VerifyBarcode%(func%)
private k$[1]
private ret$[Com.RECVSIZE]
private rec&
call Screen.Init
call Screen.Footer
locate 1,1
print "バーコードをチェックしています..."
rec&=ItemCache.SearchItemByBarcode&(WH.barcode$)
if rec&=0 then
' not found...
WH.existsBarcode%=0
WH.VerifyBarcode%=WH.SCREEN.MISSING
else
' found!
WH.productName$=ItemCache.productName$
WH.existsBarcode%=1
WH.VerifyBarcode%=WH.SCREEN.VERIFYITEM
WH.missingId$=""
end if
end function
'------------------------------------------------------------
' verify item and quantity
'------------------------------------------------------------
function WH.VerifyItem%(func%)
private retYN$[1]
call Screen.Init
call Screen.Footer
locate 1,1
screen ,Lc.RAT.REVERSE
print WH.productName$
screen ,Lc.RAT.NORMAL
print "が"
if WH.num$<>WH.MAXNUM$ then
screen ,Lc.RAT.REVERSE
print WH.num$;
screen ,Lc.RAT.NORMAL
print "個ですか?"
else
screen ,Lc.RAT.REVERSE
print "[無制限]";
screen ,Lc.RAT.NORMAL
print "ですか?"
end if
print
retYN$=Input.InputYesNo$
print retYN$
if retYN$<>"Y" then
WH.VerifyItem%=WH.SCREEN.MISSING
exit function
end if
if WH.missingId$="" then
WH.VerifyItem%=WH.SCREEN.SEND
else
WH.VerifyItem%=WH.SCREEN.REGISTER
end if
end function
'------------------------------------------------------------
' send barcode
'------------------------------------------------------------
function WH.SendBarcode%(func%)
private ret$[Com.RECVSIZE]
call Screen.Init
call Screen.Footer
locate 1,1
if func%=APP.FUNC.INBOUND% or func%=APP.FUNC.INVENTORY% then
print "データをキューに追加中..."
private s%
s%=PostCache.Queue%(WH.barcode$,WH.num$,"",func%)
if s%=0 then
ret$="OK"
else
ret$="ERR"
end if
else
print "データを送信中..."
ret$= Com.Http.Post$(Com.Http.URLPREFIX$+"/postItem.php","c="+WH.barcode$+"&n="+WH.num$+"&f="+mid$(str$(func%),2))
end if
select ret$
case"OK"
'--print "完了!"
'--Input.InputAnyKey
case "OUTOFSTOCK"
beep 1
print "在庫量を超えています"
Input.InputAnyKey
case else
print "更新失敗!"
print "もう一度スキャンをやり直してください";
Input.InputAnyKey
end select
WH.SendBarcode%=WH.SCREEN.SCAN
end function
'------------------------------------------------------------
' choose missing item
'------------------------------------------------------------
function WH.ChooseMissing%(func%)
private ret$[Com.RECVSIZE]
private ids$(WH.RECORDLEN)[WH.IDLEN]
private names$(WH.RECORDLEN)[WH.ITEMLEN]
private productCodes$(WH.RECORDLEN)[WH.CODELEN]
private cnt%
private pos%:pos%=-1
private size% '-- page size
private offset%
private total%
private meta$[100] '-- meta info
private idOffset%
private totalPages%
private currentPage%
private done%
call Screen.Init
call Screen.Footer
locate 1,1
print "未登録リストを取得しています..."
offset%=0
size%=WH.MAXPAGESIZE
done%=0
while done%=0
ret$= Com.Http.Get$(Com.Http.URLPREFIX$+"/listItem.php?o="+mid$(str$(offset%),2)+"?s="+mid$(str$(size%),2))
if offset%>0 then
idOffset%=1
ids$(0)="PREV"
names$(0)="←[前のページ]"
else
idOffset%=1
ids$(0)="DIRECT_INPUT"
names$(0)="<<商品管理コード入力>>"
end if
cnt%=Util.ParseListTabData%(ret$,meta$,ids$,idOffset%,names$,productCodes$)
total%=Util.GetPageInfo%(meta$,offset%,size%)
totalPages%=1+(total%-1)/size%
currentPage%=1+offset%/size%
if totalPages%>currentPage% then
ids$(idOffset%+cnt%)="NEXT"
names$(idOffset%+cnt%)="[次のページ]→"
cnt%=cnt%+1
end if
ids$(idOffset%+cnt%)=WH.NOTFOUND$
names$(idOffset%+cnt%)="<<該当なし>>"
cnt%=cnt%+1
pos%=Input.SelectList%(names$,idOffset%+cnt%)
if pos%>=0 then
select ids$(pos%)
case "PREV"
offset%=offset%-size%
case "NEXT"
offset%=offset%+size%
case "DIRECT_INPUT"
WH.ChooseMissing%=WH.SCREEN.INPUTCODE
done%=1
case else
WH.missingId$=ids$(pos%)
WH.productName$=names$(pos%)
WH.productCode$=productCodes$(pos%)
if func% = APP.FUNC.INVENTORY% then
if WH.existsBarcode% = 1 then
' issue new JAN
WH.ChooseMissing%=WH.SCREEN.ISSUENEWJAN
else
' update
WH.ChooseMissing%=WH.SCREEN.REGISTER
end if
else
' update barcode info
WH.ChooseMissing%=WH.SCREEN.REGISTER
end if
done%=1
end select
else
WH.missingId$=""
WH.ChooseMissing%=WH.SCREEN.SCAN
done%=1
end if
wend
end function
'------------------------------------------------------------
' input item code to register
'------------------------------------------------------------
function WH.InputItemCode%(func%)
private numStr$[20]
private done%: done%=0
private found%: found%=0
private ret$[Com.RECVSIZE]
private cnt%
private data$(2)[100]
while done%=0
call Screen.Init
call Screen.Footer
locate 1,1
print "商品管理コードは?"
locate 1,3
numStr$=Input.Input$(12,1) 'up to 12 digits
if instr(Input.CODE.ESC$,numStr$)>0 then
private r%
r%=PostCache.Flush%
done%=1
else
locate 1,5
print "商品情報取得中..."
ret$= Com.Http.Get$(Com.Http.URLPREFIX$+"/getItem.php?ac="+numStr$)
cnt%=Util.ParseListData%(ret$,data$)
if data$(0)<>"" then
WH.missingId$=data$(0) '-- product id
WH.productName$=data$(1) '-- item name
WH.productCode$=numStr$
found%=1
done%=1
else
' not found...
WH.missingId$=""
WH.productName$=""
WH.productCode$=""
locate 1,5
print "見つかりません"
Input.InputAnyKey
end if
end if
wend
if found%=1 then
WH.InputItemCode%=WH.SCREEN.VERIFYITEM
else
WH.InputItemCode%=WH.SCREEN.MISSING
end if
end function
'------------------------------------------------------------
' register an item
'------------------------------------------------------------
function WH.RegisterItem%(func%)
private ret$[Com.RECVSIZE]
private s%
call Screen.Init
call Screen.Footer
if WH.missingId$=WH.NOTFOUND$ then
locate 1,1
print "該当商品がありません"
if WH.existsBarcode%=1 then
print "商品マスタに情報を入力して新しいバーコードを発行してからスキャンをやり直してください"
else
print
print "商品マスタに情報を入力してからスキャンをやり直してください"
end if
Input.InputAnyKey
else
s%=ItemCache.NullBarcode%(WH.barcode$)
s%=ItemCache.UpdateBarcode%(WH.missingId$,WH.productName$,WH.productCode$,WH.barcode$,0)
locate 1,1
if func%=APP.FUNC.INBOUND% or func%=APP.FUNC.INVENTORY% then
print "データをキューに追加中..."
s%=PostCache.Queue%(WH.barcode$,WH.num$,WH.missingId$,func%)
if s%=0 then
ret$="OK"
else
ret$="ERR"
end if
else
print "バーコードを更新中..."
ret$= Com.Http.Post$(Com.Http.URLPREFIX$+"/updateItem.php","c="+WH.barcode$+"&n="+WH.num$+"&id="+WH.missingId$+"&f="+mid$(str$(func%),2))
end if
private data$(2)[512]
private cnt%
cnt%=Util.ParseListData%(ret$,data$)
ret$=data$(0)
select ret$
case"OK"
'--print "完了!"
'--Input.InputAnyKey
case "OUTOFSTOCK"
beep 1
print "在庫量を超えています"
Input.InputAnyKey
case else
print "更新失敗!"
print "もう一度スキャンをやり直してください";
Input.InputAnyKey
end select
end if
WH.RegisterItem%=WH.SCREEN.SCAN
end function
'------------------------------------------------------------
' ask to issue a new JAN code
'------------------------------------------------------------
function WH.IssueNewJan%(func%)
private ret$[Com.RECVSIZE]
call Screen.Init
call Screen.Footer
locate 1,1
print "バーコードは既に他の商品に対応しています"
print "新しいバーコードを貼ってから再度入庫および棚卸をしてください"
Input.InputAnyKey
WH.IssueNewJan%=WH.SCREEN.SCAN
end function
'------------------------------------------------------------
' main
'------------------------------------------------------------
sub WH.Main(func%)
private isScreen%
private nextScreen%
'-- init
ItemCache.init
PostCache.init
Com.ReadConfig '-- read communication config file
'-- flush post cached data
private ret%
ret%=PostCache.Flush%
'-- init
isScreen% = WH.SCREEN.START
nextScreen% = WH.SCREEN.START
while nextScreen% <> WH.SCREEN.FINISH
'set next screen
if isScreen% <> nextScreen% then
isScreen% = nextScreen%
end If
select isScreen%
case WH.SCREEN.USER
nextScreen% = WH.ScanUser%(func%)
case WH.SCREEN.SCAN
nextScreen% = WH.ScanBarcode%(func%)
case WH.SCREEN.VERIFY
nextScreen% = WH.VerifyBarcode%(func%)
case WH.SCREEN.VERIFYITEM
nextScreen% = WH.VerifyItem%(func%)
case WH.SCREEN.SEND
nextScreen% = WH.SendBarcode%(func%)
case WH.SCREEN.REGISTER
nextScreen% = WH.RegisterItem%(func%)
case WH.SCREEN.MISSING
nextScreen% = WH.ChooseMissing%(func%)
case WH.SCREEN.ISSUENEWJAN
nextScreen% = WH.IssueNewJan%(func%)
case WH.SCREEN.INPUTCODE
nextScreen% = WH.InputItemCode%(func%)
end select
wend
end sub
'------------------------------------------------------------
Main
call WH.Main(APP.func%)
chain "init.pd4"