	REMARK	******************************************\
		*  P/R240.BAS  SUMMARY FILE MAINTENANCE  *\
		*   5/17/79                     1:21 PM  *\
		******************************************


%INCLUDE CURSOR
	RESTORE
	DATA"HRS","AMT"
	DIM B1(5),S(1),G3(5),R1(2),R2(5)
	DIM G2$(5),A(14,12),A1.0(6)
	DIM R$(5)
	DEF FNA(Z1)=Z1-INT(Z1/10)*10					REMARK  FUNCTION TO STRIP OFF TENS DIGIT
	GOTO 6000

%INCLUDE GENINFO
%INCLUDE SUBS1


	
745	READ #1,X0;R$(1),R$(2),R$(3),R$(4),R1(1),R1(2),R2(1),R2(2),\	REMARK  READ PORTION OF MASTER RECORD
	R2(3),R2(4),R2(5),R3$,S(1)
	RETURN


825	Z1=110								REMARK  LINE PRINTER ROUTINE
	IF LINE.COUNT% < 55 THEN RETURN					REMARK  IF SPACE REMAINS ON REPORT PAGE, RETURN

	PRINT CHR$(12);TAB((Z1-LEN(G2$(1)))/2);G2$(1);TAB(Z1);"DATE ";	REMARK  PRINT COMPANY NAME AND REPORT DATE
	P=P+1
	X0=G3(1):GOSUB 680.5
	PRINT 

	PRINT TAB((Z1-LEN(X4$))/2);X4$;TAB(Z1);"PAGE";P			REMARK  PRINT REPORT HEADINGS
	PRINT
	PRINT "EMP #  PT";TAB(14);"  MON     TUE     WED     THU     FRI";
	PRINT "     SAT     SUN     MON     TUE     WED     THU     FRI";
	PRINT "     SAT     SUN"
	PRINT
	LINE.COUNT%=5							REMARK  RESET LINE COUNTER FOR NEW REPORT PAGE
	RETURN


873	READ #Y5,X0;B1(1),B1(2),B1(3),B1(4),B1(5)			REMARK  READ TRANSACTION SUMMARY RECORD
	RETURN


875	PRINT #Y5,X0;B1(1),B1(2),B1(3),B1(4),B1(5)			REMARK  WRITE TRANSACTION SUMMARY RECORD
	RETURN


1060	L=0								REMARK  SEARCH FILE FOR SUMMARY RECORD
1070	L=L+1
	IF L > RECORD.COUNT THEN H=-1:RETURN
	X0=L:GOSUB 873							REMARK  IF RECORD ID GREATER THAN EMPLOYEE NUMBER, RETURN
	IF B1(1) > E1 THEN H=-1:RETURN
	IF B1(1)=E1 AND B1(2) >= DAY.NO THEN H=0:RETURN
	GOTO 1070


5300	X1=404:X2=2:X3=0:X4=16:GOSUB 345				REMARK  ENTER PAY TYPE
	IF FNA(X0)>6 THEN X2$="OUT OF RANGE":GOSUB 615:GOTO 5300	REMARK  REJECT OUT-OF-RANGE ENTRIES
	IF R2(1)=1 AND FNA(X0)=0\
	THEN\
	X2$="INCONSISTENT PAY TYPE":GOSUB 615:\				REMARK  FLAG PAY TYPES INCONSISTENT WITH EMPLOYEE TYPE
	GOTO 5300\
	ELSE\
	B1(3)=X0:RETURN


5350	IF FNA(B1(3))>0 AND R2(1)<>1 THEN GOTO 5370
	IF R2(1)=1 AND FNA(B1(3))<>2 THEN 5370
5360	X2$="OUT OF RANGE":GOSUB 615					REMARK  REJECT ENTRY OF HOURS IF NOT APPLICABLE
	RETURN 

5370	X1=465:X2=5:X3=0:X4=99.99:GOSUB 345				REMARK  ENTER HOURS
	B1(4)=X0
	RETURN 


5400	IF R2(1) = 0 AND FNA(B1(3))=2 THEN GOTO 5405			REMARK  ENTER AMOUNT IF PAY TYPES PERMIT IT
	IF FNA(B1(3)) = 2 OR FNA(B1(3)) = 4\
	THEN\
	X1=527:X2=7:X3=0:X4=9999.99:GOSUB 345:\
	B1(5)=X0:\
	RETURN 

5405	X2$="OUT OF RANGE"
	GOSUB 615
	RETURN


5450	IF P=0 THEN LINE.COUNT%=60
	X4$="PAYROLL BIWEEKLY SUMMARY":GOSUB 825			REMARK  PRINT BIWEEKLY PAYROLL SUMMARY
	FOR K%=1 TO 6
	IF A1.0(K%)=0 THEN  5475
	PRINT USING B$;E1;						REMARK  PRINT EMPLOYEE NUMBER
5463	RESTORE 
	Z%=K%*2-1
	FOR A1=Z% TO Z%+A.0
	READ X4$
	PRINT TAB(5);X4$;K%;						REMARK  PRINT "HRS" OR "AMT"
5465	FOR J%=1 TO 14
	IF A(J%,A1)=0 THEN  5470
	PRINT TAB(J%*8+4);
	PRINT USING D$;A(J%,A1);					REMARK  PRINT HOURS/AMOUNT FOR DAY 'J'
5470	NEXT J%
	PRINT 
	NEXT A1
	LINE.COUNT%=LINE.COUNT%+1+A.0
5475	NEXT K%

	A1.0(1)=0:A1.0(2)=0:A1.0(3)=0:A1.0(4)=0:A1.0(5)=0:A1.0(6)=0	REMARK  INITIALIZE TOTALS

	DIM A(14,12)							REMARK  RE-INITIALIZE TOTALS ARRAY BY RE-DIMENSIONING IT
	RETURN 


6000	A$=" ###.##"							REMARK  SET UP PRINT MASKS FOR REPORT
	B$="###"
	C$="##"
	D$="####.##"
	Y5=2
	Y9=3
	OPEN "P/R0F110.DAT" RECL 1150 AS 1				REMARK  OPEN EMPLOYEE MASTER FILE
	OPEN "P/R0F050.DAT" RECL 30 AS Y5				REMARK  OPEN PAYROLL TRANSACTION SUMMARY FILE
	OPEN "G/I0F010.DAT" RECL 200 AS Y9:GOSUB 700			REMARK  OPEN AND LOAD GENERAL INFORMATION FILE
	OPEN "CRT" RECL 1100 AS 19


	WHILE B1(1) <> 9000000000					REMARK  FIND END OF SUMMARY FILE
	READ #Y5;B1(1)
	RECORD.COUNT=RECORD.COUNT+1
	WEND


6020	B=10
	X0=10:GOSUB 260							REMARK  LOAD AND DISPLAY CRT MASK NUMBER 10

	X2=1:X3=0:X4=2:X2$="ENTER OPERATION (0=END;1=CHANGE OR DELETE;2=PRINT)"
	GOSUB 665


	IF X0=0 THEN\							REMARK  END PROGRAM AND LOAD MENU IF ZERO CODE ENTERED
	PRINT CLEAR.SCREEN$;"P/R SUMMARY F/M LOADING MENU":\
	CHAIN "P/R000"


	IF X0=2 THEN  6200						REMARK  IF CODE = 2, BRANCH TO PRINT ROUTINE


6030	X1=270:X2=3:X3=0:X4=999:GOSUB 345				REMARK  ENTER EMPLOYEE NUMBER
	E1=X0
	IF X0=0 THEN  6020						REMARK  REQUEST OPERATION CODE IF EMPLOYEE = 0
	R$(1)="NOT ON MASTER"
	IF X0<=MSTR.RECORDS THEN GOSUB 745				REMARK  READ EMPLOYEE MASTER FILE RECORD

6031	IF R2(1)=99 OR S(1)=0 OR X0>MSTR.RECORDS\
	THEN R$(1)="NOT ON MASTER" 

6053	X1=284:GOSUB 210
	PRINT R$(1);TAB(30)						REMARK  PRINT EMPLOYEE NAME OR ERROR MESSAGE IF NOT FOUND

	X1=326:X2=2:X3=0:X4=14:GOSUB 345				REMARK  ENTER DAY NUMBER
	DAY.NO=X0

	GOSUB 1060							REMARK  SEARCH SUMMARY FILE FOR EMPLOYEE ENTERED

	R5=L
	IF H=-1 AND DAY.NO=0 AND B1(1)=E1 THEN H=0
	IF B1(1)=E1 AND DAY.NO <> 0 AND B1(2) <> DAY.NO THEN H=-1
	IF H=-1 THEN X2$="NOT ON FILE":GOSUB 615:GOTO 6030		REMARK  DISPLAY ERROR MESSAGE IF EMPLOYEE NOT FOUND


6070	X1=256:GOSUB 210
	GOSUB 7025							REMARK  DISPLAY TRANSACTION SUMMARY DATA

6075	X2=2:X3=0:X4=99
	X2$="ENTER FIELD TO CHANGE (0=NONE;98=NEW EMPL;99=DELETE)"	REMARK  PROMPT OPERATOR FOR FIELD TO CHANGE
	GOSUB 665
	X1=64:GOSUB 210:PRINT TAB(64):PRINT TAB(64);
	IF X0=0 THEN  6095
	IF X0=98 THEN  6030						REMARK  REQUEST NEW EMPLOYEE

	IF X0=99 THEN  6100						REMARK  BRANCH TO DELETE ROUTINE IF INDICATED

	IF X0 > 3 THEN 6075
	ON X0	GOSUB 5300,5350,5400
	GOTO 6075
6095	X0=L:GOSUB 875							REMARK  SAVE RECORD ON FILE
	L=L+1
	IF L > RECORD.COUNT THEN 6030
	X0=L
	GOSUB 873							REMARK  GET NEXT PAYROLL SUMMARY RECORD
	IF B1(1)=E1 THEN  6070
	GOTO 6030
6100	X2=3:X3=0:X4=0:X2$="ENTER DELETE CODE":GOSUB 665		REMARK  PROMPT OPERATOR FOR DELETE CODE
	IF X0$ <> "DEL" THEN  6075
	A.0=1
	IF RECORD.COUNT=1\						REMARK  SKIP RE-WRITING IF ONLY ONE RECORD ON FILE
	THEN RECORD.COUNT=RECORD.COUNT+1:GOTO 6105

	FOR I=L TO RECORD.COUNT-1					REMARK  PHYSICALLY RE-WRITE OVER DELETED RECORD
	X0=I+1:GOSUB 873
	X0=I:GOSUB 875
	NEXT I

6105	RECORD.COUNT=RECORD.COUNT-1
	B1(1)=9000000000:B1(2)=0:B1(3)=0:\
	B1(4)=0:B1(5)=0:X0=RECORD.COUNT:GOSUB 875
	X2$="RECORD DELETED":GOSUB 615					REMARK  FLASH DELETED RECORD BULLETIN
	GOTO 6030


6200	X0=11:GOSUB 260							REMARK  LOAD SUMMARY FILE PRINT CRT MASK
6205	X1=282:X2=3:X3=0:X4=999:GOSUB 345				REMARK  ENTER START EMPLOYEE NUMBER
	E1=X0
	X1=346:X2=3:X3=E1:X4=999:GOSUB 345				REMARK  ENTER END EMPLOYEE NUMBER
	E2=X0
	X1=411:X2=2:X3=0:X4=14:GOSUB 345				REMARK  ENTER START DAY NUMBER
	D1=X0
	X1=475:X2=2:X3=D1:X4=14:GOSUB 345				REMARK  ENTER END DAY NUMBER
	D2=X0
	X1=540:X2=1:X3=0:X4=1:GOSUB 345					REMARK  PROMPT TO PRINT AMOUNT FIELDS OPTIONALLY
	A.0=X0
	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?":GOSUB 665			REMARK  VERIFY ENTRIES:'1'=O.K; '0'=RETRY
	IF X0 <> 1 THEN  6205
6295	LPRINTER							REMARK  SELECT PRINTER AS OUTPUT DEVICE
	P=0
	I=1
	IF E2 > MSTR.RECORDS THEN E2=MSTR.RECORDS
	DAY.NO=0
	GOSUB 1060							REMARK  GET FIRST EMPLOYEE NUMBER IN RANGE
	R5=L

6305	FOR I1%=L TO RECORD.COUNT
	X0=I1%
	GOSUB 873							REMARK  READ THE NEXT PAYROLL SUMMARY RECORD
	IF B1(1) > E2 THEN I1%=RECORD.COUNT+1:GOTO 6360
	IF B1(2) < D1 OR B1(2) > D2\
	OR FNA(B1(3))=0 THEN GOTO 6360					REMARK  IF SUMMARY RECORD IS INVALID, SKIP IT

	IF B1(1) > E1 THEN GOSUB 5450:E1=B1(1)				REMARK  PRINT A DETAIL LINE ON REPORT
	
6340	J%=FNA(B1(3))*2
6350	A(B1(2),J%-1)=B1(4)
	A(B1(2),J%)=B1(5)
	A1.0(J%/2)=1
6360	NEXT I1%
6370	GOSUB 5450							REMARK  PRINT TOTALS FOR REPORT
	CONSOLE
	GOTO 6020							REMARK  REQUEST A NEW OPERATION


7000	REMARK DISPLAY CRT MASK 10 OR 11
	CONSOLE
	X0=B:GOSUB 260
	PRINT
	PRINT 
	PRINT 
	PRINT 
	IF B=11 THEN  7060
7025	X1=13:GOSUB 215
	PRINT USING B$;B1(1);						REMARK  DISPLAY EMPLOYEE NUMBER
	X1=12:GOSUB 215
	PRINT R$(1);TAB(63)						REMARK  DISPLAY EMPLOYEE NAME
	X1=7:GOSUB 215

	PRINT USING C$;B1(2)						REMARK  DISPLAY DAY NUMBER FOR SUMMARY RECORD
	X1=21:GOSUB 215
	PRINT USING C$;B1(3)						REMARK  DISPLAY PAY TYPE
	X1=16:GOSUB 215
	PRINT USING A$;B1(4)						REMARK  DISPLAY HOURS
	X1=16:GOSUB 215
	PRINT USING D$;B1(5)
	RETURN 


7060	X1=24:GOSUB 215
	PRINT USING B$;E1						REMARK  DISPLAY START EMPLOYEE NUMBER
	X1=24:GOSUB 215
	PRINT USING B$;E2						REMARK  DISPLAY END EMPLOYEE NUMBER
	X1=24:GOSUB 215
	PRINT USING B$;D1						REMARK  DISPLAY START DAY
	X1=24:GOSUB 215
	PRINT USING B$;D2						REMARK  DISPLAY END DAY
	X1=24:GOSUB 215
	PRINT USING B$;A.0						REMARK  DISPLAY AMOUNT PRINT OPTION
	RETURN 
