	REMARK	*********************************************\
		*   P/R321.BAS   EMPLOYEE ACTIVITY REPORT   *\
		*   5/18/79                      10:30 AM   *\
		*********************************************

%INCLUDE CURSOR


	DIM E1(50),S(1),R1(2),R2(5),R$(5),G3(5),G2$(5)
	DIM W(2),W1(2),W2$(2),W2(14),E(2)

	DEF FNEXACT(M1,M2)=M1*1000+M2					REMARK  FUNCTION TO LOCATE JOB FILE RECORD

	A1=10000000000
	GOTO 6000

%INCLUDE SUBS1
%INCLUDE GENINFO

745	Q$=" "								REMARK  READ PORTION OF EMPLOYEE MASTER RECORD
	IF X0 <=0 OR X0 > MSTR.RECORDS THEN Q$="N"\
	ELSE\
	READ #1,X0;R$(1),R$(2),R$(3),R$(4),R1(1),R1(2),\
	R2(1),R2(2),R2(3),R2(4),R2(5),R3$,S(1)

	RETURN


825	Z1=109								REMARK  ****    LINE PRINTER ROUTINE    ****

	IF LINE.COUNT%<55 THEN RETURN					REMARK  IF SPACE REMAINS ON REPORT PAGE, RETURN
	P=P+1
	PRINT CHR$(12);TAB((Z1-LEN(G2$(1)))/2);G2$(1);TAB(Z1);"DATE ";	REMARK  PRINT COMPANY NAME AND REPORT DATE
	X0=G3(1):GOSUB 680.5
	PRINT 

	PRINT TAB((Z1-LEN(X4$))/2);X4$;TAB(Z1);"PAGE";P			REMARK  PRINT REPORT TITLE AND PAGE NUMBER
	PRINT 

	PRINT "EMPLOYEE  NAME";TAB(39);"JOB  DESCRIPTION";		REMARK  PRINT COLUMN HEADINGS
	PRINT TAB(102);"MTD HOURS";"  JTD HOURS"
	PRINT 
	LINE.COUNT%=6							REMARK  SET LINE COUNTER FOR NEW REPORT PAGE
	RETURN 


%INCLUDE JOBFILE
%INCLUDE PR-SEARC

4000									REMARK  EXTRACT EMPLOYEE, JOB NUMBERS AND POINTER 
	EMP.NO=INT(WORKFILE.RECORD/A1)
	W(1)=INT((WORKFILE.RECORD-(EMP.NO*A1))/10000)
	DETAIL%=WORKFILE.RECORD-(EMP.NO*A1)-(W(1)*10000)
	RETURN

4100	CLOSE 5								REMARK  FIND FIRST OCCURRENCE OF EMPLOYEE X0 IN WORK FILE
	OPEN "WORKFILE.DAT" AS 5
	READ #5;WORKFILE.RECORD
	X0=X0*A1
	IF END #5 THEN 4110

4105	READ #5;WORKFILE.RECORD
	IF X0>WORKFILE.RECORD THEN 4105
	IF INT(X0/A1)<>INT(WORKFILE.RECORD/A1) THEN\
	WORKFILE.RECORD=10^14
	RETURN

4110	WORKFILE.RECORD=10^14						REMARK  SET ERROR FLAG IF END OF FILE WAS ENCOUNTERED
	RETURN


5300	X0=EMP.NO:GOSUB 745						REMARK  READ THE EMPLOYEE MASTER FILE
	IF Q$="N" OR S(1)=0 THEN R$(1)="NOT ON FILE":S(1)=EMP.NO	REMARK  IF NOT FOUND, SET EMPLOYEE NAME TO ERROR MESSAGE

	X4$="EMPLOYEE ACTIVITY":GOSUB 825				REMARK  CHECK FOR END OF REPORT PAGE

	IF F=0 OR LINE.COUNT%=6\					REMARK  PRINT EMPLOYEE NAME AND NUMBER IF NOT YET PRINTED
	THEN\								REMARK  ON THIS REPORT PAGE
	PRINT USING "######";S(1);:\
	PRINT TAB(10); R$(1);:\
	F=1

5315	K=FNEXACT(W(1),0):GOSUB 1060					REMARK  SEARCH FOR JOB HEADER RECORD

	IF H=-1 THEN W1$="NOT ON FILE":GOTO 5350			REMARK  IF NOT FOUND OR DELETED, SET JOB NAME TO ERROR
	READ #Y6,L;W(1),W(2),W1$,W1(1),W1(2),W2$(1),W2$(2)
	IF W2$(1)="D" THEN W1$="NOT ON FILE":GOTO 5350

	IF W2$(1)="9" THEN 5395						REMARK  SKIP CANCELLED JOBS

5350	W2(1)=0:W2(8)=0							REMARK  READ JOB DETAIL RECORD
	X0=DETAIL%:GOSUB 1100
	IF W2(3)=-1 THEN W2(1)=0:W2(8)=0:GOTO 5395			REMARK  SKIP DELETED JOB DETAIL RECORDS

5370	E(1)=E(1)+W2(1):E(2)=E(2)+W2(8)					REMARK  ADD DETAIL MTD AND JTD HOURS TO EMPLOYEE TOTALS

5375	PRINT TAB(36);:PRINT USING "######";W(1);			REMARK  PRINT JOB NUMBER, DESCRIPTION, MTD AND JTD HOURS
	PRINT "  ";W1$;TAB(100);
	PRINT USING MASKA$;W2(1);W2(8)
	LINE.COUNT%=LINE.COUNT%+1

5395	IF END #5 THEN 5396						REMARK  READ ANOTHER RECORD FROM THE WORKFILE
	READ #5;WORKFILE.RECORD
	GOSUB 4000
	IF S(1)=EMP.NO THEN GOTO 5315 ELSE GOTO 5397

5396	WORKFILE.RECORD=10^14

5397	PRINT TAB(44);"EMPLOYEE TOTALS";TAB(100);			REMARK  PRINT EMPLOYEE TOTALS IF EOF OR NEW EMPLOYEE
	PRINT USING MASKA$;E(1);E(2)
	PRINT
	LINE.COUNT%=LINE.COUNT%+2
	DIM E(2)							REMARK  RE-INITIALIZE EMPLOYEE TOTALS
	F=0
	RETURN


6000	MASK6$="######"							REMARK  SET UP PRINT MASKS
	MASKA$="  ######.##"
	CTRL.C%=1							REMARK  ENABLE CONTROL-C FOR PROGRAM EXIT IN SUBS1.BAS
	Y6=2
	Y9=4
	Y2=Y6
	OPEN "P/R0F110.DAT" RECL 1150 AS 1				REMARK  OPEN EMPLOYEE MASTER AD JOB FILES
	OPEN "JOB0F100.DAT" RECL 160 AS Y6

	OPEN "G/I0F010.DAT" RECL 200 AS Y9				REMARK  OPEN AND LOAD GENERAL INFORMATION FILE
	GOSUB 700

	OPEN "WORKFILE.DAT" AS 5					REMARK  OPEN TEMPORARY WORK AND CRT MASK FILES
	OPEN "CRT" RECL 1100 AS 19

6015	X0=15:GOSUB 260							REMARK  GET EMPLOYEE ACTIVITY REPORT CRT MASK
	LINE.COUNT%=60
	DIM E1(50)
	P=0
	RECORD.COUNT=JOB.RECORDS

6020	X1=271:X2=3:X3=0:X4=999:GOSUB 345				REMARK  ENTER START EMPLOYEE FOR REPORT
	START.EMPLOYEE=X0
	IF X%=3 THEN GOTO 9999
	IF START.EMPLOYEE=0 THEN GOTO 6060				REMARK  IF START EMPLOYEE=0, ENTER EMPLOYEES VIA GRID

6025	X1=292:X2=3:X3=START.EMPLOYEE:X4=999:GOSUB 345			REMARK  ENTER END EMPLOYEE
	END.EMPLOYEE=X0

6050	X2=1:X3=0:X4=1:X2$="ENTRY CORRECT?":GOSUB 665			REMARK  VERIFY EMPLOYEE RANGE: '1'=O.K., '0'=RETRY
	IF X0<>1 THEN 6020
	GOTO 6100							REMARK  BRANCH AROUND GRID ENTRY IF RANGE WAS SELECTED


6060	FOR I1%=1 TO 10
	FOR I%=1 TO 5
6065	X1=64*I1%+7*I%+320:X2=3:X3=0:X4=999:GOSUB 345			REMARK  ENTER EMPLOYEE NUMBER INTO GRID

	IF X0>0 THEN E1(I%+5*(I1%-1))=X0\				REMARK  IF EMPLOYEE NUMBER=0, FALL OUT OF ENTRY LOOP;
	ELSE\								REMARK  OTHERWISE, ACCEPT ENTRY
	I%=5:I1%=10

	NEXT I%
	NEXT I1%

6075	X2=2:X3=0:X4=10							REMARK  PROMPT OPERATOR FOR ROW TO CHANGE
	X2$="ENTER ROW TO CHANGE (0=NONE)":GOSUB 665
	IF X0=0  THEN 6050						REMARK  IF NO MORE CHANGES, PROMPT FOR VERIFICATION

	I1%=X0
6080	X2=1:X3=0:X4=5:X2$="ENTER COLUMN TO CHANGE":GOSUB 665
	IF X0=0 THEN GOTO 6075
	I%=X0
	X1=64*I1%+7*I%+320:X2=3:X3=0:X4=999:GOSUB 345			REMARK  CHANGE EMPLOYEE NUMBER FIELD ON GRID
	E1(I%+5*(I1%-1))=X0
	GOTO 6075

6100	LPRINTER							REMARK  SELECT PRINTER AS OUTPUT DEVICE
6105	I%=0
	IF START.EMPLOYEE=0 THEN GOTO 6150
	X0=START.EMPLOYEE:GOSUB 4100
	IF WORKFILE.RECORD=10^14 THEN GOTO 6140				REMARK  IF START EMPLOYEE NOT FOUND, RESTART PROGRAM
	GOSUB 4000							REMARK  EXTRACT EMPLOYEE NUMBER, JOB NUMBER AND POINTER
	GOSUB 5300

6120	IF WORKFILE.RECORD=10^14 THEN 6140				REMARK  RESTART IF END OF FILE WAS ENCOUNTERED
	X0=INT(WORKFILE.RECORD/A1)
	IF X0 > END.EMPLOYEE THEN GOTO 6140				REMARK  IF PAST EMPLOYEE RANGE, RESTART PROGRAM

	GOSUB 4000
	GOSUB 5300							REMARK  PROCESS EMPLOYEE ACTIVTY RECORD FROM WORKFILE
	GOTO 6120

6140	PRINT CHR$(12):GOTO 6015					REMARK  PROGRAM RESTART ROUTINE


6150	I%=I%+1
	IF I%>50 THEN GOTO 6140
	IF E1(I%)=0 THEN GOTO 6140
6155	X0=E1(I%):GOSUB 4100						REMARK  LOCATE FIRST EMPLOYEE ACTIVITY RECORD FOR\
									        EMPLOYEE WITHIN GRID
	IF WORKFILE.RECORD=10^14 THEN GOTO 6150				REMARK  IF EMPLOYEE RECORD WAS FOUND, PROCESS IT
	GOSUB 4000
	GOSUB 5300
	GOTO 6150
9999	CONSOLE
	PRINT CLEAR.SCREEN$;"EMPLOYEE ACTIVITY REPORT LOADING MENU"
	DELETE 5
	CHAIN "P/R000"
