	REMARK	**************************************\
		*  P/R200.BAS  PRINT PAYROLL HISTORY *\
		*   5/17/79               11:22 AM   *\
		**************************************

	DIM H1(3),H2(9),A(9,2),S(96),R$(5),R1(2),R2(5),G3(5),G2$(5)
%INCLUDE CURSOR

	DEF FNEXACT(X0,X1)=X0*1000000 + X1
	GOTO 6000
%INCLUDE SUBS1
%INCLUDE GENINFO
%INCLUDE MSTRIN

825	IF LINE.COUNT% < 55  THEN RETURN				REMARK  IF SPACE REMAINS ON REPORT PAGE, RETURN
	A1%=110
	P=P+1
	PRINT CHR$(0CH);							REMARK  PRINT TOP-OF-FORM
	PRINT TAB((A1%-LEN(G2$(1)))/2);G2$(1);TAB(A1%);"DATE ";		REMARK  PRINT COMPANY NAME AND DATE
	X0=G3(1):GOSUB 680.5
	PRINT 
	PRINT TAB((A1%-LEN(X4$))/2);X4$;TAB(A1%);"PAGE";P		REMARK  PRINT REPORT TITLE AND PAGE NUMBER
	PRINT
835	PRINT "EMP NAME ";TAB(28);					REMARK  PRINT REPORT COLUMN HEADINGS
	PRINT "PAY DATE   REG HRS O.T. HRS  VAC HRS  TOTAL PAY";
	PRINT "    FED W/H STATE W/H     FICA     SDI    NET PAY  CHECK"
		PRINT
	LINE.COUNT%=6							REMARK  SET LINE COUNTER FOR NEXT REPORT PAGE
	RETURN 

%INCLUDE HISTORY
%INCLUDE PR-SEARC

4500	LINE.COUNT%=LINE.COUNT% + 2
	GOSUB 825							REMARK  CHECK FOR END OF REPORT PAGE
	PRINT USING MASKA$;X0$,A(1,I%),A(2,I%),A(3,I%),A(4,I%),\	REMARK  PRINT Q-T-D OR TOTAL TO-DATE FOR EMPLOYEE
	A(5,I%),A(6,I%),A(7,I%),A(8,I%),A(9,I%)
	LINE.COUNT%=LINE.COUNT%+1
	A1% = 24*I%							REMARK  SET ARRAY POINTER FOR MASTER FILE TOTALS
	IF S(1+A1%)+S(5+A1%)<>A(1,I%) THEN PRINT TAB(45);"*";		REMARK  PRINT DISCREPANCY FLAGS IF TOTALS \
									        ON THE MASTER FILE DO NOT AGREE WITH HISTORY
	IF S(3+A1%) <> A(2,I%) THEN PRINT TAB(54);"*";
	IF S(8+A1%) <> A(3,I%) THEN PRINT TAB(63);"*";
	IF S(11+A1%) <> A(4,I%) THEN PRINT TAB(74);"*";
	IF S(13+A1%) <> A(5,I%) THEN PRINT TAB(85);"*";
	IF S(14+A1%) <> A(6,I%) THEN PRINT TAB(95);"*";
	IF S(15+A1%) <> A(7,I%) THEN PRINT TAB(104);"*";
	IF S(16+A1%) <> A(8,I%) THEN PRINT TAB(112);"*";
	IF S(11+A1%)-S(18+A1%) <> A(9,I%) THEN PRINT TAB(123);"*";
	PRINT
	RETURN 


5300	FOR I%=1TO 9							REMARK  ACCUMULATE Q-T-D TO TOTAL-TO-DATE FOR EMPLOYEE
	A(I%,1)=A(I%,1)+A(I%,2)
	A(I%,2)=0							REMARK  SET QUARTERLY TOTALS TO ZERO
	NEXT I%
	RETURN


6000	MASKA$="    /######################/        ######.##"		REMARK  SET UP PRINT MASKS
	MASKA$=MASKA$+" #####.## #####.## #######.## #######.##"
	MASKA$=MASKA$+" ######.## #####.## ####.## #######.## ######"
	MASKB$=" ######.## #####.## #####.## #######.## #######.##"
	MASKB$=MASKB$+" ######.## #####.## ####.## #######.## ######"
	MASK3$="###"
	DEF FNA(A1)=A1-INT(A1/10000)*10000				REMARK  EXTRACT MONTH NUMBER FROM GREGORIAN DATE
	DEF FNB(X0)=INT(INT(FNA(X0)/100-1)/3)
	PRINT CLEAR.SCREEN$;"PAYROLL HISTORY REPORT"			REMARK  DISPLAY PROGRAM I.D. ON CRT
	PRINT "ENTER START EMPLOYEE OF ZERO TO EXIT"
	PRINT 
	PRINT 
	PRINT "START EMPLOYEE NUMBER"
	PRINT "END EMPLOYEE NUMBER"
	X1=279:X2=3:X3=0:X4=999:GOSUB 345				REMARK  ENTER START EMPLOYEE NUMBER
	IF X0=0 THEN 6230						REMARK  IF START EMPLOYEE IS ZERO, EXIT PROGRAM
	E1=X0
6045	X1=343:X2=3:X3=E1:X4=999:GOSUB 345				REMARK  ENTER END EMPLOYEE NUMBER
	E2=X0
	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?":GOSUB 665			REMARK  VERIFY ENTRY: '1'=O.K.; '0'=RETRY
	IF X0<>1 THEN 6000
	Y1=3
	Y6=2
	X4$="PAYROLL HISTORY"
	LPRINTER							REMARK  SELECT PRINTER AS OUTPUT DEVICE
	OPEN "P/R0F110.DAT" RECL 1150 AS 1				REMARK  OPEN EMPLOYEE MASTER FILE
	OPEN "P/R0F120.DAT" RECL 102 AS Y6				REMARK  OPEN EMPLOYEE HISTORY FILE
	Y9=3
	OPEN "G/I0F010.DAT" RECL 200 AS Y9
	GOSUB 700							REMARK  READ GENERAL INFORMATION FILE
	LINE.COUNT%=60
	GOSUB 825							REMARK  PRINT HEADINGS FOR FIRST PAGE
	P=0								REMARK  RE-INITIALIZE PAGE COUNT
	IF E2 > MSTR.RECORDS THEN E2=MSTR.RECORDS
	X4$="PAYROLL HISTORY"
	Y2=Y6
	RECORD.COUNT=HISTORY.RECORDS
	K=FNEXACT(E1,0)
	GOSUB 1060							REMARK  LOCATE FIRST EMPLOYEE HISTORY RECORD
	REC%=L-1 							REMARK  SET STARTING RECORD
	IF END #Y6 THEN 6220						REMARK  SET EOF BRANCH FOR HISTORY FILE
6085	REC%=REC%+1
	X0=REC%
	GOSUB 905							REMARK  GET THE NEXT PAYROLL HISTORY RECORD
	IF H1(1) > E2 THEN 6220						REMARK  IF PAST RANGE, EXIT PROGRAM
	IF S(1)=H1(1) THEN 6135						REMARK  BRANCH IF EMPLOYEE NUMBER HAS NOT CHANGED
	IF S(1)=0 THEN S(1)=H1(1):GOTO 6130				REMARK  IF FIRST EMPLOYEE, DON'T PRINT TOTALS
	PRINT
	LINE.COUNT%=LINE.COUNT% + 1
	X0$="QUARTERLY":I%=2:GOSUB 4500					REMARK  PRINT QUARTERLY TOTALS AND ACCUMULATE
	GOSUB 5300
	I%=1:X0$="TOTAL":GOSUB 4500					REMARK  PRINT TOTAL-TO-DATE FOR EMPLOYEE
6115	LINE.COUNT%=60
	FOR I%=1 TO 9:A(I%,1)=0:A(I%,2)=0:NEXT I%			REMARK  INITIALIZE TOTALS ARRAY
	GOSUB 825							REMARK  SKIP TO TOP OF FORM ON NEW EMPLOYEE SUMMARY
	P=0
6130	C%=FNB(H1(2)):YEAR%=INT(H1(2)/10000)
	IF H1(1) <= MSTR.RECORDS THEN X0 = H1(1):GOSUB 745  		REMARK  READ MASTER FILE FOR EMPLOYEE RECORD
	IF H1(1) > MSTR.RECORDS OR S(1)=0\
	THEN R$(1)="NOT ON MASTER FILE"					REMARK  SET EMPLOYEE NAME TO ERROR MESSAGE IF\
									        NO MASTER RECORD EXISTS
	GOSUB 825							REMARK  CHECK FOR END OF REPORT PAGE
	PRINT USING MASK3$; H1(1);					REMARK  PRINT EMPLOYEE NUMBER
	PRINT " ";R$(1);						REMARK  PRINT EMPLOYEE NAME
6135	IF FNB(H1(2)) = C% AND YEAR% = INT(H1(2)/10000) THEN 6170	REMARK  IF NOT NEW QUARTER, SKIP SUBTOTALS
	C%=FNB(H1(2)):YEAR%=INT(H1(2)/10000)				REMARK  SET QUARTER TO NEW INFORMATION
	IF A(4,2) > 0 THEN\						REMARK  PRINT Q-T-D TOTALS 
	PRINT:\
	PRINT USING MASKA$; "QUARTERLY", A(1,2), A(2,2), A(3,2), A(4,2),\
	A(5,2), A(6,2), A(7,2), A(8,2), A(9,2):\			REMARK  PRINT PREVIOUS Q-T-D TOTALS IF NEW QUARTER
	PRINT:\
	LINE.COUNT%=LINE.COUNT% + 2:\
	GOSUB 5300							REMARK  ACCUMULATE TO TOTAL-TO-DATE
6170	PRINT TAB(28);
	X0=FNA(H1(2))*100+INT(H1(2)/10000)
	GOSUB 680.5							REMARK  CONVERT DATE OF CHECK-- YYMMDD TO MMDDYY;\
									        AND THEN PRINT IT
	PRINT USING MASKB$;H2(1),H2(2),H2(3),H2(4),H2(5),H2(6),\	REMARK  PRINT HISTORY RECORD DETAIL
	H2(7),H2(8),H2(4)-H2(9),H1(3)
	LINE.COUNT%=LINE.COUNT%+1
	FOR I%=1TO 8
	A(I%,2)=A(I%,2)+H2(I%)						REMARK  ACCUMULATE TO TOTALS
	NEXT I%
	A(9,2)=A(9,2)+H2(4)-H2(9)
	GOTO 6085
6220	PRINT
	X0$="QUARTERLY":I%=2:GOSUB 4500					REMARK  PRINT Q-T-D TOTALS FOR LAST EMPLOYEE
	GOSUB 5300
	I%=1:X0$="TOTAL":GOSUB 4500

6230	PRINT CHR$(12)							REMARK  END OF PROGRAM
	CONSOLE
	PRINT CLEAR.SCREEN$;"PAYROLL HISTORY REPORT LOADING MENU"
	CHAIN "P/R000"


