-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathACTIV3.TXT
1717 lines (1551 loc) · 57.3 KB
/
ACTIV3.TXT
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
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
DECLARE SUB openfile (filename$, filenum%, type$, reclen%, retry%)
DECLARE SUB getseq (filenum%, g$, l%, retry%)
DECLARE SUB putseq (filenum%, p$, retry%)
DECLARE SUB getrandom (filenum%, t%, recnum%, retry%)
DECLARE SUB putrandom (filenum%, t%, recnum%, retry%)
DECLARE SUB killfile (filename$, retry%)
DECLARE SUB makedir (dir$, retry%)
DECLARE SUB remdir (dir$, retry%)
DECLARE SUB rename (old$, new$, retry%)
DECLARE SUB checkprinter (retry%)
DECLARE SUB menu (numberofoptions%, selection%, top%, t%, promptline%, rubout%)
DECLARE SUB promptdisplay (prompt$, promptline%, promptfore%, promptback%, clearline%)
DECLARE SUB displaysublevels (disp%, levelpath1$, levelpath2$)
DECLARE SUB alertbox (top%, numberofalerts%, yesorno$)
DECLARE SUB ruboutmenu (top%, t%, numberofoptions%)
DECLARE SUB agentmenudata (l%, n%, includeunit%, success%)
DECLARE SUB checkexist (l%, newname$, newnum$, exist%, success%)
DECLARE SUB nukedir (dir$, dir%, success%)
DECLARE SUB importengine (num$, success%)
DECLARE SUB exportengine (success%)
DECLARE SUB writeconfig (filename$, numberofdbs%, managername$, managernum$, success%)
DECLARE SUB readconfig (filename$, numberofdbs%, managername$, managernum$, success%)
DECLARE SUB league (lev%, l%, leaguelevel%, n%, success%)
DECLARE SUB removeagent (l%, num$, success%)
DECLARE SUB compiledb (l%, d%)
DECLARE SUB insertagent (l%, name$, num$, success%)
DECLARE SUB cascadecheck (l%, n%, file$, ret%, ad%, success%)
DECLARE FUNCTION getlevel$ (l%, plural%, short%)
DECLARE FUNCTION add$ (a$, b$)
DECLARE FUNCTION decrypt$ (in$)
DECLARE FUNCTION encrypt$ (in$)
'$INCLUDE: 'common.inc'
OnlyOneAgent:
DATA You Can't Have A League Table|With Only One Adviser|PAK|
LeagueLevelMenu:
DATA Previous Menu|Returns To The Previous Menu
DATA Advisers|Produces A League Table Of Advisers
DATA Sales Teams|Produces A League Table Of Sales Teams
DATA Branches|Produces A League Table Of Branches
DATA Snr Branches|Produces A League Table Of Senior Branches
DATA Regions|Produces A League Table Of Regions
LeagueTableFields:
DATA Approaches|Selects Approaches
DATA Appointments Made|Selects Appointments Made
DATA Appointments This Week|Selects Appointments This Week
DATA 1st Appointments|Selects 1st Appointments
DATA 2nd Appointments|Selects 2nd Appointments
DATA Total FPAs|Selects Total FPAs
DATA CUFSELL FPAs|Selects CUFSELL FPAs
DATA Total Sales|Selects Total Sales
DATA CUFSELL Sales|Selects CUFSELL Sales
DATA Total Commission|Selects Total Commission
DATA CUFSELL Commission|Selects CUFSELL Commission
DATA Service Calls|Selects Service Calls
DATA Referrals|Selects Referrals
DATA Name|Selects Name
DATA Previous Menu|Returns to the Previous Menu
FieldDisplayData2:
DATA Approaches,Appts Made
DATA Appts Week,1st Appts
DATA 2nd Appts,Total FPAs,CUFSELL FPAs
DATA Total Sales,CUFSELL Sales
DATA Total Comm,CUFSELL Comm
DATA Service Calls,Referrals
LTData:
DATA To Screen|Displays The League Table On Screen
DATA To Printer|Prints The League Table
DATA Previous Menu|Returns To The Previous Menu
NoDataAvailable:
DATA There Is No Data Available|PAK|
UnSuccessful:
DATA Unsuccessful Attempt To Retrieve Data|Operation Aborted|PAK|
DiskSwap2:
DATA Please Insert Disk *|PAK|
WrongSequence:
DATA You Have Inserted Disk *|Please Insert Disk #|PAK|
ExportLimit:
DATA This Disk Has Reached Its Limit|For Exporting Data|PAK|
DiskSwap:
DATA Disk Full|Please Insert Another Disk|PAK|
Sure:
DATA Are You SURE (Y/N)?|
DoneDel:
DATA The * Has Been Deleted|PAK|
ContainsSubLevels:
DATA The * Specified Has * In It|It Cannot Be Deleted|PAK|
ExportWarning:
DATA "Please Insert An Export Disk Into Drive A:|Warning: All Data Will Be Erased From It|PAK|"
ImportReady:
DATA "Please Insert An Import Disk Into Drive A:|PAK|"
NoImp:
DATA There Are No * To Import|From This Disk|PAK|
ImpExisting:
DATA You Have Tried To Import An Existing *|Go Ahead (Y/N)?|
ImpTerm:
DATA You Have Tried To Import A Terminated *|Terminated * Are No Longer Accessible|PAK|
SUB deleteagent (l%)
IF l% = 4 THEN
t% = 43
ELSEIF l% = 2 THEN
t% = 37
ELSEIF l% = 1 THEN
t% = 40
ELSE
t% = 39
END IF
CALL cascadecheck(l%, numberofdbs%, filename$, ret%, 0, s%)
IF s% = 0 THEN GOTO faileddel
IF ret% <> 0 THEN EXIT SUB
CALL agentmenudata(l%, n%, 0, s%)
IF s% = 0 THEN GOTO faileddel
option$(0) = "Delete " + getlevel$(l%, 0, 0)
CALL menu(n%, selection%, 4, t%, 25, 0)
IF selection% < n% THEN
name$ = RTRIM$(LEFT$(option$(selection%), 25))
num$ = RTRIM$(RIGHT$(option$(selection%), 7))
ELSEIF selection% = n% THEN
CALL ruboutmenu(4, t%, n%)
EXIT SUB
END IF
IF l% > 1 THEN
p$ = path$
FOR i% = 5 TO l% + 1 STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
g$ = LCASE$(getlevel$(l%, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
CALL readconfig(p$ + num$ + "\" + g$ + ".cfg", numberofdbs%, man1$, man2$, s%)
IF numberofdbs% <> 0 THEN GOTO notempty
END IF
RESTORE Sure
READ al$
CALL alertbox(15, 1, yn$)
IF yn$ <> "y" THEN
CALL ruboutmenu(4, t%, n%)
EXIT SUB
END IF
CALL promptdisplay("Deleting " + getlevel$(l%, 0, 0) + "...", 20, VAL(MID$(colour$, 25, 2)), VAL(MID$(colour$, 27, 2)), 1)
p$ = path$
FOR i% = 5 TO l% + 1 STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
CALL removeagent(l%, num$, s%)
IF s% = 0 THEN GOTO faileddel
g$ = LCASE$(getlevel$(l% + 1, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
CALL readconfig(p$ + g$ + ".cfg", numberofdbs%, man1$, man2$, s%)
IF s% = 0 THEN GOTO faileddel
CALL writeconfig(p$ + g$ + ".cfg", numberofdbs% - 1, man1$, man2$, s%)
IF s% = 0 THEN GOTO faileddel
IF l% = 1 THEN
CALL killfile(p$ + num$ + ".*", retry%)
IF retry% = 0 THEN GOTO faileddel
ELSE
CALL killfile(p$ + num$ + ".*", retry%)
IF retry% = 0 THEN GOTO faileddel
CALL killfile(p$ + num$ + "\*.*", retry%)
IF retry% = 0 THEN GOTO faileddel
CALL remdir(p$ + num$, retry%)
IF retry% = 0 THEN GOTO faileddel
END IF
IF l% = 1 THEN CALL compiledb(1, 1)
CALL promptdisplay("", 20, 0, 0, 1)
RESTORE DoneDel
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l%, 0, 0) + MID$(al$, INSTR(al$, "*") + 1)
CALL alertbox(15, 2, yn$)
detail$(l%, 1) = ""
detail$(l%, 0) = ""
CALL displaysublevels(1, "", "")
CALL ruboutmenu(4, t%, n%)
EXIT SUB
notempty:
RESTORE ContainsSubLevels
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l%, 0, 0) + MID$(al$, INSTR(al$, "*") + 1)
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l% - 1, 1, 0) + MID$(al$, INSTR(al$, "*") + 1)
IF l% = 4 THEN
al$ = LEFT$(al$, INSTR(al$, "In") - 1) + "Under" + MID$(al$, INSTR(al$, "In") + 2)
END IF
CALL alertbox(15, 3, yn$)
CALL ruboutmenu(4, t%, n%)
EXIT SUB
faileddel:
CALL promptdisplay("", 18, 0, 0, 1)
RESTORE UnSuccessful
READ al$
CALL alertbox(15, 3, yn$)
CALL ruboutmenu(4, t%, n%)
END SUB
SUB exportdb (l%)
DIM d$(6, 1)
FOR i% = 1 TO 6
d$(i%, 1) = detail$(i%, 1)
d$(i%, 0) = detail$(i%, 0)
NEXT
IF l% = 4 THEN
t% = 43
ELSEIF l% = 2 THEN
t% = 37
ELSEIF l% = 1 THEN
t% = 40
ELSE
t% = 39
END IF
CALL cascadecheck(l%, numberofdbs%, filename$, ret%, 0, s%)
IF s% = 0 THEN GOSUB failedexp: EXIT SUB
IF ret% <> 0 THEN EXIT SUB
CALL agentmenudata(l%, n%, 1, s%)
IF s% = 0 THEN GOSUB failedexp: EXIT SUB
option$(0) = "Export " + getlevel$(l%, 0, 0)
CALL menu(n%, selection%, 4, t%, 25, 0)
IF selection% = n% THEN
CALL ruboutmenu(4, t%, n%)
EXIT SUB
ELSEIF selection% = n% - 1 THEN
IF l% + 1 = 6 THEN
detail$(l% + 1, 1) = "U.K."
detail$(l% + 1, 0) = "uk"
END IF
detail$(l%, 1) = ""
detail$(l%, 0) = ""
ELSE
detail$(l%, 1) = RTRIM$(LEFT$(option$(selection%), 25))
detail$(l%, 0) = RTRIM$(RIGHT$(option$(selection%), 7))
END IF
RESTORE ExportWarning
READ al$
CALL alertbox(15, 3, y$)
IF y$ = "esc" THEN
CALL ruboutmenu(4, t%, n%)
EXIT SUB
END IF
CALL promptdisplay("Clearing Disk - Please Wait...", 20, VAL(MID$(colour$, 25, 2)), VAL(MID$(colour$, 27, 2)), 1)
FOR i% = 1 TO l% - 1
detail$(i%, 1) = ""
detail$(i%, 0) = ""
NEXT
CALL nukedir("A:", 1, s%)
IF s% = 0 THEN GOSUB failedexp: GOTO doneexp
backup% = 1
CALL promptdisplay("Exporting Database - Please Wait...", 20, VAL(MID$(colour$, 25, 2)), VAL(MID$(colour$, 27, 2)), 1)
CALL exportengine(s%)
backup% = 0
IF s% = 0 THEN GOSUB failedexp
doneexp:
CALL promptdisplay("", 20, 0, 0, 1)
CALL ruboutmenu(4, t%, n%)
FOR i% = 1 TO 6
detail$(i%, 1) = d$(i%, 1)
detail$(i%, 0) = d$(i%, 0)
NEXT
EXIT SUB
failedexp:
CLOSE
RESTORE UnSuccessful
READ al$
CALL alertbox(15, 3, yesorno$)
RETURN
END SUB
SUB exportengine (success%)
curyear% = VAL(RIGHT$(DATE$, 4))
curmonth% = VAL(LEFT$(DATE$, 2))
success% = 1
p$ = path$
FOR i% = 1 TO 6
IF detail$(i%, 0) = "" THEN level% = i% + 1
NEXT
IF level% = 0 THEN level% = 1
FOR i% = 5 TO level% STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
file$ = LEFT$(p$, LEN(p$) - 1)
IF level% = 6 THEN file$ = p$ + "uk"
g$ = LCASE$(getlevel$(level%, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
datfile$ = "A:\" + g$ + ".dat"
CALL openfile(datfile$, 1, "R", 32, r%)
IF r% <> 1 THEN success% = 0: EXIT SUB
IF LOF(1) / 32 = 31 THEN
RESTORE ExportLimit
READ al$
CALL alertbox(15, 3, y$)
EXIT SUB
END IF
agentsinteam.agentname = encrypt$(detail$(level%, 1) + SPACE$(25 - LEN(detail$(level%, 1))))
agentsinteam.agentnumber = encrypt$(detail$(level%, 0) + SPACE$(7 - LEN(detail$(level%, 0))))
CALL putrandom(1, 1, LOF(1) / 32 + 1, r%)
IF r% <> 1 THEN success% = 0: EXIT SUB
CLOSE #1
y% = curyear%
finum% = 1
CALL openfile("A:\" + detail$(level%, 0), 2, "SO", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
CALL putseq(2, LTRIM$(RTRIM$(STR$(finum%))), r%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
found% = 0
first% = 1
DO
IF y% <> curyear% OR first% = 1 THEN
extension$ = "." + LTRIM$(RTRIM$(STR$(y% MOD 100)))
ELSE
extension$ = ".db"
END IF
filename$ = file$ + extension$
CALL openfile(filename$, 1, "R", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
length% = (LOF(1) / 148)
IF length% = 0 THEN
CLOSE #1
CALL killfile(filename$, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
IF found% = 0 THEN
IF first% = 0 THEN y% = y% - 1
first% = 0
GOTO roundagain
END IF
CALL putseq(2, CHR$(1), r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(2, CHR$(1), r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CLOSE #2
GOTO donenode
END IF
found% = 1
CALL putseq(2, extension$, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(2, extension$, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
FOR i% = 1 TO length%
CALL getrandom(1, 2, i%, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
a$ = agentweek.wholerecord
CALL putseq(2, a$, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(2, a$, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
NEXT
CALL putseq(2, CHR$(255), r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(2, CHR$(255), r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CLOSE #1
IF found% = 1 THEN first% = 0: y% = y% - 1
roundagain:
LOOP
donenode:
inffile% = 1
IF level% = 1 THEN EXIT SUB
g$ = LCASE$(getlevel$(level%, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
CALL readconfig(p$ + g$ + ".cfg", numberofdbs%, a$, b$, s%)
IF s% = 0 THEN success% = 0: EXIT SUB
g$ = LCASE$(getlevel$(level% - 1, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
datfile$ = p$ + g$ + ".dat"
IF level% = 2 THEN
CALL openfile(p$ + "advisert.dat", 1, "R", 32, retry%)
IF retry% = 0 THEN CLOSE : EXIT SUB
n% = numberofdbs% + LOF(1) / 32
CLOSE 1
IF n% = numberofdbs% THEN
CALL killfile(p$ + "advisert.dat", retry%)
IF retry% = 0 THEN CLOSE : EXIT SUB
END IF
ELSE
n% = numberofdbs%
END IF
IF n% = 0 THEN EXIT SUB
CALL openfile("A:\" + detail$(level%, 0) + ".inf", 7, "SO", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
CALL putseq(7, LTRIM$(RTRIM$(STR$(numberofdbs%))), r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(7, LTRIM$(RTRIM$(STR$(numberofdbs%))), r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL putseq(7, a$, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(7, a$, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL putseq(7, b$, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(7, b$, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL putseq(7, LTRIM$(RTRIM$(STR$(n% - numberofdbs%))), r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(7, LTRIM$(RTRIM$(STR$(n% - numberofdbs%))), r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
DIM dbfilenum$(n%, 1)
CALL openfile(datfile$, 1, "R", 32, retry%)
IF retry% = 0 THEN success% = 0: EXIT SUB
FOR i% = 1 TO numberofdbs%
CALL getrandom(1, 1, i%, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
dbnum$ = LTRIM$(RTRIM$(decrypt$(agentsinteam.agentnumber)))
dbname$ = LTRIM$(RTRIM$(decrypt$(agentsinteam.agentname)))
db$ = agentsinteam.agentname + agentsinteam.agentnumber
dbfilenum$(i%, 0) = dbnum$
dbfilenum$(i%, 1) = dbname$
CALL putseq(7, db$, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(7, dbnum$, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
NEXT
CLOSE #1
IF n% > numberofdbs% THEN
CALL openfile(p$ + "advisert.dat", 1, "R", 32, retry%)
IF retry% = 0 THEN CLOSE : EXIT SUB
FOR i% = numberofdbs% + 1 TO n%
CALL getrandom(1, 1, i%, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
dbnum$ = LTRIM$(RTRIM$(decrypt$(agentsinteam.agentnumber)))
dbname$ = LTRIM$(RTRIM$(decrypt$(agentsinteam.agentname)))
db$ = agentsinteam.agentname + agentsinteam.agentnumber
dbfilenum$(i%, 0) = dbnum$
dbfilenum$(i%, 1) = dbname$
CALL putseq(7, db$, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk
CALL putseq(7, dbnum$, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
NEXT
CLOSE #1
END IF
CLOSE #7
IF retry% = 0 THEN success% = 0: EXIT SUB
FOR i% = 1 TO numberofdbs%
d$ = detail$(level% - 1, 0)
e$ = detail$(level% - 1, 1)
detail$(level% - 1, 0) = dbfilenum$(i%, 0)
detail$(level% - 1, 1) = dbfilenum$(i%, 1)
CALL exportengine(s%)
detail$(level% - 1, 0) = d$
detail$(level% - 1, 1) = e$
IF s% = 0 THEN success% = 0: CLOSE : EXIT SUB
NEXT
EXIT SUB
nextdisk:
IF inffile% = 1 THEN
CLOSE #7
ELSE
CLOSE #2
END IF
RESTORE DiskSwap
READ al$
CALL alertbox(15, 3, y$)
IF y$ = "esc" THEN CLOSE : success% = 0: EXIT SUB
finum% = finum% + 1
IF inffile% = 1 THEN
CALL openfile("A:\" + detail$(level%, 0) + ".inf", 7, "SO", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
CALL putseq(7, LTRIM$(RTRIM$(STR$(finum%))), r%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
ELSE
CALL openfile("A:\" + detail$(level%, 0), 2, "SO", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
CALL putseq(2, LTRIM$(RTRIM$(STR$(finum%))), r%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
RETURN
END SUB
SUB importdb (l%)
IF l% = 4 THEN
t% = 43
ELSEIF l% = 2 THEN
t% = 37
ELSEIF l% = 1 THEN
t% = 40
ELSE
t% = 39
END IF
CALL cascadecheck(l%, numberofdbs%, filename$, ret%, 1, s%)
IF s% = 0 THEN GOSUB failedimp: EXIT SUB
IF ret% <> 0 THEN EXIT SUB
curname$ = detail$(l%, 1)
curnum$ = detail$(l%, 0)
RESTORE ImportReady
READ al$
CALL alertbox(15, 2, y$)
IF y$ = "esc" THEN EXIT SUB
g$ = LCASE$(getlevel$(l%, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
file$ = "A:\" + g$ + ".dat"
CALL openfile(file$, 1, "R", 32, retry%)
IF retry% = 0 THEN GOSUB failedimp: EXIT SUB
numberofdbs% = LOF(1) / 32
IF numberofdbs% = 0 THEN
RESTORE NoImp
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l%, 1, 0) + MID$(al$, INSTR(al$, "*") + 1)
CALL alertbox(15, 3, y$)
EXIT SUB
END IF
FOR i% = 1 TO numberofdbs%
CALL getrandom(1, 1, i%, retry%)
IF retry% = 0 THEN GOSUB failedimp: EXIT SUB
a$ = LTRIM$(RTRIM$(decrypt$(agentsinteam.agentname)))
b$ = LTRIM$(RTRIM$(decrypt$(agentsinteam.agentnumber)))
option$(i%) = a$ + SPACE$(27 - LEN(a$)) + b$ + SPACE$(7 - LEN(b$)) + "|Selects " + a$
NEXT
CLOSE #1
option$(0) = "Import " + getlevel$(l%, 0, 0)
option$(numberofdbs% + 1) = "Previous Menu|Returns To Previous Menu"
CALL menu(numberofdbs% + 1, selection%, 4, t%, 25, 0)
IF selection% = numberofdbs% + 1 THEN
CALL ruboutmenu(4, t%, numberofdbs% + 1)
EXIT SUB
END IF
CALL checkexist(l%, RTRIM$(LEFT$(option$(selection%), 25)), RTRIM$(RIGHT$(option$(selection%), 7)), exist%, s%)
IF s% = 0 THEN GOSUB failedimp
IF exist% <> 0 THEN
SELECT CASE exist%
CASE 1, 3
RESTORE ImpExisting
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l%, 0, 0) + MID$(al$, INSTR(al$, "*") + 1)
CALL alertbox(15, 2, yn$)
CASE 4, 6
RESTORE ImpTerm
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l%, 0, 0) + MID$(al$, INSTR(al$, "*") + 1)
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + getlevel$(l%, 1, 0) + MID$(al$, INSTR(al$, "*") + 1)
CALL alertbox(15, 3, yn$)
CASE ELSE
END SELECT
IF NOT (exist% > 0 AND exist% < 4 AND yn$ = "y") AND exist% <> 0 THEN
CALL ruboutmenu(4, t%, numberofdbs% + 1)
EXIT SUB
END IF
END IF
IF (exist% = 1 OR exist% = 3) AND l% > 1 THEN
CALL promptdisplay("Clearing Existing Database - Please Wait...", 20, VAL(MID$(colour$, 25, 2)), VAL(MID$(colour$, 27, 2)), 1)
p$ = path$
FOR i% = 5 TO l% STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
p$ = LEFT$(p$, LEN(p$) - 1)
IF RIGHT$(p$, 1) = "\" THEN p$ = p$ + RTRIM$(RIGHT$(option$(selection%), 7))
CALL nukedir(p$, 1, s%)
IF s% = 0 THEN
GOSUB failedimp
GOTO doneimp
END IF
END IF
CALL promptdisplay("Importing Database - Please Wait...", 20, VAL(MID$(colour$, 25, 2)), VAL(MID$(colour$, 27, 2)), 1)
detail$(l%, 1) = ""
detail$(l%, 0) = ""
CALL importengine(RTRIM$(MID$(option$(selection%), 28, 7)), s%)
IF s% = 0 THEN GOSUB failedimp
IF exist% = 0 OR exist% = 2 OR exist% = 5 THEN
p$ = path$
FOR i% = 5 TO l% + 1 STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
name$ = RTRIM$(LEFT$(option$(selection%), 25))
num$ = RTRIM$(RIGHT$(option$(selection%), 7))
CALL insertagent(l%, name$, num$, s%)
g$ = LCASE$(getlevel$(l% + 1, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
CALL readconfig(p$ + g$ + ".cfg", dbs%, man1$, man2$, s%)
IF s% = 0 THEN GOSUB failedimp: GOTO doneimp
CALL writeconfig(p$ + g$ + ".cfg", dbs% + 1, man1$, man2$, s%)
IF s% = 0 THEN GOSUB failedimp: GOTO doneimp
END IF
doneimp:
CALL promptdisplay("", 20, 0, 0, 1)
CALL ruboutmenu(4, t%, numberofdbs% + 1)
detail$(l%, 1) = curname$
detail$(l%, 0) = curnum$
EXIT SUB
failedimp:
CLOSE
RESTORE UnSuccessful
READ al$
CALL alertbox(15, 3, yesorno$)
RETURN
END SUB
SUB importengine (num$, success%)
curyear% = VAL(RIGHT$(DATE$, 4))
curmonth% = VAL(LEFT$(DATE$, 2))
success% = 1
p$ = path$
FOR i% = 1 TO 6
IF detail$(i%, 0) = "" THEN level% = i%
NEXT
IF level% = 0 THEN level% = 1
FOR i% = 5 TO level% + 1 STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
finum% = 1
CALL openfile("A:\" + num$, 1, "SI", 1, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
CALL getseq(1, finum$, 1, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF VAL(finum$) <> finum% THEN GOSUB wrongdisk
DO
CALL getseq(1, extension$, 1, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
filename$ = p$ + num$ + extension$
CALL openfile(filename$, 2, "R", 148, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
i% = 1
DO
CALL getseq(1, a$, 1, r%)
IF a$ = CHR$(255) THEN GOSUB nextfile
IF a$ = CHR$(1) THEN CLOSE #1: GOTO donenode2
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
agentweek.wholerecord = a$
CALL putrandom(2, 2, i%, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
i% = i% + 1
LOOP UNTIL EOF(1)
GOSUB nextdisk2
CLOSE #2
y% = y% - 1
LOOP
donenode2:
inffile% = 1
CLOSE #2
IF level% = 1 THEN EXIT SUB
CALL openfile("A:\" + num$ + ".inf", 7, "SI", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
IF EOF(7) THEN
GOSUB nextdisk2
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL getseq(7, numberofdbs$, 1, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
numberofdbs% = VAL(numberofdbs$)
IF EOF(7) THEN
GOSUB nextdisk2
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL getseq(7, a$, 1, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
IF EOF(7) THEN
GOSUB nextdisk2
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL getseq(7, b$, 1, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
IF EOF(7) THEN
GOSUB nextdisk2
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
END IF
CALL getseq(7, numberofterms$, 1, r%)
IF r% <> 1 THEN success% = 0: CLOSE : EXIT SUB
numberofterms% = VAL(numberofterms$)
g$ = LCASE$(getlevel$(level%, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
IF level% <> 6 THEN
CALL makedir(p$ + num$, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
CALL writeconfig(p$ + num$ + "\" + g$ + ".cfg", numberofdbs%, a$, b$, s%)
IF s% = 0 THEN success% = 0: EXIT SUB
g$ = LCASE$(getlevel$(level% - 1, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
datfile$ = p$ + num$ + "\" + g$ + ".dat"
ELSE
CALL writeconfig(p$ + g$ + ".cfg", numberofdbs%, a$, b$, s%)
IF s% = 0 THEN success% = 0: EXIT SUB
g$ = LCASE$(getlevel$(level% - 1, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
datfile$ = p$ + g$ + ".dat"
END IF
n% = numberofdbs% + numberofterms%
IF n% = 0 THEN EXIT SUB
DIM dbfilenum$(n%)
CALL openfile(datfile$, 1, "R", 32, retry%)
IF retry% = 0 THEN success% = 0: EXIT SUB
FOR i% = 1 TO numberofdbs%
IF EOF(7) THEN GOSUB nextdisk2
CALL getseq(7, db$, 1, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
agentsinteam.agentname = LEFT$(db$, 25)
agentsinteam.agentnumber = RIGHT$(db$, 7)
dbfilenum$(i%) = LTRIM$(RTRIM$(decrypt$(RIGHT$(db$, 7))))
CALL putrandom(1, 1, i%, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
NEXT
CLOSE #1
IF numberofterms% > 0 THEN
CALL openfile(p$ + "advisert.dat", 1, "R", 32, retry%)
IF retry% = 0 THEN CLOSE : EXIT SUB
FOR i% = 1 TO numberofterms%
IF EOF(7) THEN GOSUB nextdisk2
CALL getseq(7, db$, 1, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
agentsinteam.agentname = LEFT$(db$, 25)
agentsinteam.agentnumber = RIGHT$(db$, 7)
dbfilenum$(i%) = decrypt$(RIGHT$(db$, 7))
CALL putrandom(1, 1, i%, r%)
IF r% = 0 THEN success% = 0: CLOSE : EXIT SUB
NEXT
CLOSE #1
END IF
CLOSE #7
FOR i% = 1 TO numberofdbs%
d$ = detail$(level%, 0)
detail$(level%, 0) = num$
CALL importengine(dbfilenum$(i%), s%)
detail$(level%, 0) = d$
IF s% = 0 THEN success% = 0: CLOSE : EXIT SUB
NEXT
EXIT SUB
nextfile:
CALL getseq(1, extension$, 1, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF r% = 2 THEN
GOSUB nextdisk2
END IF
IF extension$ = CHR$(1) THEN a$ = CHR$(1): RETURN
filename$ = file$ + extension$
CLOSE #2
CALL openfile(filename$, 2, "R", 148, retry%)
i% = 1
CALL getseq(1, a$, 1, r%)
RETURN
nextdisk2:
IF inffile% = 1 THEN
CLOSE #7
ELSE
CLOSE #1
END IF
RESTORE DiskSwap2
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + LTRIM$(RTRIM$(STR$(finum%))) + MID$(al$, INSTR(al$, "*") + 1)
CALL alertbox(15, 3, y$)
IF y$ = "esc" THEN CLOSE : success% = 0: EXIT SUB
finum% = finum% + 1
IF inffile% = 1 THEN
CALL openfile("A:\" + num$ + ".inf", 7, "SI", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
CALL getseq(1, finum$, 1, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF VAL(finum$) <> finum% THEN GOSUB wrongdisk
ELSE
CALL openfile("A:\" + num$, 1, "SI", 148, retry%)
IF retry% <> 1 THEN success% = 0: CLOSE : EXIT SUB
CALL getseq(1, finum$, 1, r%)
IF r% = 0 THEN success% = 0: EXIT SUB
IF VAL(finum$) <> finum% THEN GOSUB wrongdisk
END IF
RETURN
wrongdisk:
RESTORE WrongSequence
READ al$
al$ = LEFT$(al$, INSTR(al$, "*") - 1) + LTRIM$(RTRIM$(finum$)) + MID$(al$, INSTR(al$, "*") + 1)
al$ = LEFT$(al$, INSTR(al$, "#") - 1) + LTRIM$(RTRIM$(STR$(finum%))) + MID$(al$, INSTR(al$, "#") + 1)
CALL alertbox(15, 3, y$)
IF y$ = "esc" THEN success% = 0: CLOSE : EXIT SUB
RETURN
END SUB
SUB league (lev%, l%, leaguelevel%, n%, success%)
IF l% = 1 THEN
CALL openfile(path$ + "temp", 1, "SO", 1, retry%)
IF retry% = 0 THEN success% = 0: EXIT SUB
END IF
p$ = path$
FOR i% = 5 TO lev% STEP -1
p$ = p$ + detail$(i%, 0) + "\"
NEXT
g$ = LCASE$(getlevel$(lev%, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
cfgfile$ = p$ + g$ + ".cfg"
g$ = LCASE$(getlevel$(lev% - 1, 0, 1))
IF g$ = "snr branch" THEN g$ = "area"
datfile$ = p$ + g$ + ".dat"
CALL displaysublevels(0, levelpath1$, levelpath2$)
info$ = detail$(lev%, 1) + " " + detail$(lev%, 0)
CALL readconfig(cfgfile$, num%, m$, n$, s%)
IF s% = 0 THEN success% = 0: EXIT SUB
CALL openfile(datfile$, 2, "R", 32, retry%)
IF retry% = 0 THEN success% = 0: EXIT SUB
FOR i% = 1 TO num%
CALL getrandom(2, 1, i%, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
dbnum$ = RTRIM$(decrypt$(agentsinteam.agentnumber))
dbname$ = RTRIM$(decrypt$(agentsinteam.agentname))
IF lev% > 1 THEN
detail$(lev% - 1, 0) = dbnum$
detail$(lev% - 1, 1) = dbname$
END IF
IF l% = leaguelevel% THEN
CALL putseq(1, dbname$, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
CALL putseq(1, dbnum$, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
CALL putseq(1, p$ + dbnum$, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
n% = n% + 1
END IF
IF lev% > 1 AND l% <> leaguelevel% THEN
CLOSE #2: CALL league(lev% - 1, l% + 1, leaguelevel%, n%, s%)
IF s% = 0 THEN success% = 0: CLOSE : EXIT SUB
CALL openfile(datfile$, 2, "R", 32, retry%)
IF retry% = 0 THEN success% = 0: CLOSE : EXIT SUB
END IF
IF lev% > 1 THEN
detail$(lev% - 1, 0) = ""
detail$(lev% - 1, 1) = ""
END IF
NEXT
CLOSE #2
IF l% = 1 THEN CLOSE #1
END SUB
SUB ltable (startmonth%, endmonth%, startyear%, endyear%)
curyear% = VAL(RIGHT$(DATE$, 4))
DIM b$(14)
FOR i% = 1 TO 6
IF detail$(i%, 0) = "" THEN l% = i% + 1
NEXT
IF l% = 0 THEN l% = 1
t% = 20
IF l% = 1 THEN
RESTORE OnlyOneAgent
READ al$
CALL alertbox(15, 2, yn$)
EXIT SUB
END IF
leaguelevel:
selection% = 0
IF l% > 2 THEN
RESTORE LeagueLevelMenu
option$(0) = "League Table"
FOR i% = 1 TO l%
READ option$(l% - i% + 1)
NEXT
CALL menu(l%, selection%, 4, t%, 25, 1)
leaguelevel% = selection%
ELSE
leaguelevel% = 1
END IF
IF selection% <> l% THEN GOTO leaguefield
EXIT SUB
leaguefield:
RESTORE LeagueTableFields
option$(0) = "Sort Field"
FOR i% = 1 TO 15
READ option$(i%)
NEXT
RESTORE FieldDisplayData2
FOR i% = 1 TO 13
READ b$(i%)
NEXT
b$(14) = "Name"
CALL menu(15, selection%, 4, t%, 25, 1)
IF selection% <> 15 THEN
sortf% = selection%
sortf$ = b$(selection%)
GOTO extrafield
ELSEIF selection% = 15 THEN
IF l% = 2 THEN EXIT SUB
GOTO leaguelevel
END IF
extrafield:
RESTORE LeagueTableFields
option$(0) = "Append Field"
FOR a% = 1 TO 15
READ option$(a%)
NEXT
option$(14) = "None|Selects No Extra Field"
CALL menu(15, selection%, 4, t%, 25, 1)
IF selection% <> 15 THEN
appf% = selection%
appf$ = b$(selection%)
IF appf$ = "Name" THEN appf$ = "None"
GOTO chooseoutput
ELSEIF selection% = 15 THEN
GOTO leaguefield