	REMARK	*******************************************\
		*  P/R050.BAS  PAYROLL TRANSACTION ENTRY  *\
		*  5/16/79                     5:45 PM    *\
		*******************************************

%INCLUDE CURSOR

	DIM S(1),T2(8),W$(5),P$(7),R$(5),R2(5),G3(5),G2$(5)

	DEF FNR(Z1)=INT(Z1*100+.5)/100					REMARK  ROUNDING FUNCTION
	DEF FNEXACT(X0,X1)=X0*100+X1					REMARK  KEY LOCATOR FUNCTION
%INCLUDE PRNMASK
	 GOTO 6000

%INCLUDE SUBS1
%INCLUDE GENINFO

1020	A4=X1								REMARK  ENTER AND REDISPLAY JOB NUMBER ON CRT
	X2=6
	X3=0
	X4=999999
	GOSUB 345
	GOSUB 210
	PRINT USING MASK6$;X0
	RETURN 

1040	K=FNEXACT(T2(6),0)
	Y2=4
	RECORD.COUNT=JOB.RECORDS
%INCLUDE PR-SEARCH

5300	IF T2(4)=3 OR T2(4)=0 THEN 5600					REMARK  REJECT ENTRY IF PROHIBITED BY WORK TYPE
	X1=586
	GOSUB 1020							REMARK  ENTER JOB NUMBER
	IF X0=0 THEN RETURN
	T2(6)=X0
	K$=STR$(T2(6))
	GOSUB 1040							REMARK  REMARK LOCATE JOB HEADER
	IF H = -1 THEN X2$="NOT ON FILE":GOSUB 615			REMARK  WARN IF JOB HEADER NOT ON FILE
	RETURN


5350	IF T2(4)<>2 THEN 5600						REMARK  ENTER DEPARTMENT NUMBER IF WORK TYPE CODE=2
	X1=654
	X2=2
	X3=0
	X4=10
	GOSUB 345 
	T2(5)=X0
	RETURN 


5400	IF T2(3)=0 THEN GOTO 5600					REMARK  IF PAY TYPES ARE INCONSISTENT, REJECT ENTRY
	IF T2(3)=2 AND R2(1)=1 THEN GOTO 5600
5405	X1=715:X2=5:X3=0:X4=99.99:GOSUB 345				REMARK  ENTER HOURS
	HOURS=HOURS+X0-T2(7)
	T2(7)=X0
5408	X1=737
	GOSUB 210
	PRINT USING MASK2.2$;HOURS					REMARK  DISPLAY TOTAL HOURS ENTERED SO FAR FOR EMPLOYEE
	RETURN 


5450	IF T2(3)<> 4 THEN 5600						REMARK  ENTER QUANTITY FOR PIECEWORK TRANSACTIONS
	X1=778:X2=6:X3=1:X4=999999:GOSUB 345
	N=X0
5460	T2(8)=FNR(N*N1)							REMARK  CALCULATE AND DISPLAY PIECEWORK AMOUNT
	X1=905
	GOSUB 210
	PRINT USING MASK4.2$;T2(8)
	RETURN


5500	IF T2(3)=4\							REMARK  IF PAY TYPE=4, THEN ENTER PIESEWORK RATE
	THEN\
	X1=841:X2=7:X3=0:X4=9999.99:GOSUB 345:\	
	N1=X0:\
	GOTO 5460\							REMARK  RE-DISPLAY PIECEWORK AMOUNT
	ELSE GOTO 5600


5550	IF R2(1)<>1 OR T2(3)<>2 THEN GOTO 5600				REMARK  ENTER VACATION PAY AMOUNT FOR HOURLY EMPLOYEES
	X1=905:X2=7:X3=0:X4=9999.99:GOSUB 345
	T2(8)=X0
	RETURN 


5600	X2$="OUT OF RANGE"						REMARK  DISPLAY ERROR BULLETIN ON CRT
	GOSUB 615
	RETURN 


5650	X1=524								REMARK  CLEAR TRANSACTION DATA FROM SCREEN FOR NEXT ENTRY
	GOSUB 210
	PRINT TAB(20)
	FOR I%=1TO 6
	X1=10
	GOSUB 215
	PRINT "        "
	NEXT I%
	RETURN 


5700	X2$="INCONSISTENT"						REMARK  FLASH THIS ERROR MESSAGE WHEN TYPE CODES DO NOT\
									        AGREE WITH EMPLOYEE RECORD OR DATA ENTERED
	GOSUB 615
	RETURN 


5750	IF X0=0\
	THEN\
	PRINT #Y4,TRANSACTION.COUNT%+1;\				REMARK  SAVE TRANSACTION RECORD ON DISK IF X0 IS ZERO
	T2(1),G3(5),T2(3),T2(4),T2(5),T2(6),T2(7),T2(8):\
	TRANSACTION.COUNT%=TRANSACTION.COUNT%+1:\
	CLOSE Y4:\
	OPEN "P/R0F040.DAT" RECL 42 AS Y4:\
	X1=524:\
	GOSUB 210:\
	PRINT "***RECORDED***":\
	FOR I=1 TO 60:\
	NEXT I:\
	GOTO 5760

5755	X2$="CANCEL"							REMARK  IF CODE ENTERED=99, THEN CANCEL TRANSACTION
	X9=99
	GOSUB 615
	IF T2(7)=0 THEN 5760
	HOURS=HOURS-T2(7)
	GOSUB 5408


5760	FOR I%=5 TO 8							REMARK  INITIALIZE TRANSACTION RECORD VARIABLES
	T2(I%)=0
	NEXT I%
	N=0
	N1=0
	GOSUB 5650							REMARK  CLEAR SCREEN OF PREVIOUS TRANSACTION DATA

5767	RETURN

5770	X9=0
	X2$="USE ALPHA KEYS TO SET UP NEXT TRANSACTION(D=NO CHANGE;E=EXIT)"
	X2=1:X3=0:X4=0:X0=0:GOSUB 665					REMARK  PROMPT FOR ALPHA KEY ENTRY
	IF X0$="" OR X0$="D" THEN RETURN				REMARK  IF NO CHANGES SPECIFIED, RETURN

	IF X0$<"A" OR X0$>"E"\						REMARK  REJECT INVALID ALPHA ENTRIES
	THEN X2$="OUT OF RANGE":GOSUB 615:GOTO 5770

	IF X0$ = "E" THEN GOTO 7300					REMARK  END PROGRAM IF 'E' WAS ENTERED

	F=ASC(X0$)-64							REMARK  GET THE DECIMAL VALUE OF THE LETTER KEYED IN
	X9=T2(1)
	ON F GOSUB 7200,7400,7350					REMARK  CHANGE EMPLOYEE, PAY TYPE OR WORK TYPE BASED ON CODE
	GOTO 5770


6000	MASK12$="/############/"					REMARK  START OF MAINLINE
	MASKA$="   # /############/"
	Y4=3
	Y8=4
	Y9=5
	OPEN "P/R0F110.DAT" RECL 1150 AS 1				REMARK  OPEN EMPLOYEE MASTER FILE
	OPEN "G/I0F010.DAT" RECL  200 AS Y9
	OPEN "P/R0F040.DAT" RECL 42 AS 3				REMARK  OPEN TRANSACTION FILE
	OPEN "JOB0F100.DAT" RECL 160 AS 4,"CRT" RECL 1100 AS 19		REMARK  OPEN JOB KEY FILE AND CRT MASK FILE

	GOSUB 700							REMARK  LOAD GENERAL INFORMATION FILE


	RECS%=0								REMARK  SEARCH TRANSACTION FILE FOR EOF
	IF END #Y4 THEN 6020

	FOR F%=10 TO 1 STEP -1						REMARK  SEARCH IN A FILE 1024 RECORDS MAXIMUM
	READ #Y4,(2^F%)+RECS%;LINE X$
	RECS%=RECS% + 2^F%
6020	NEXT F%

	TRANSACTION.COUNT%=RECS%


	P$(1)="SALARY"							REMARK  SET UP PAY AND WORK TYPE DESCRIPTIONS
	P$(2)="HOURLY"
	P$(3)="VACATION"
	P$(4)="HOLIDAY"
	P$(5)="PIECE WORK"
	P$(6)="OVERTIME"
	P$(7)="COMP TIME"
6028	W$(1)="N/A"
	W$(2)="PHASE I"
	W$(3)="PHASE II"
	W$(4)="NO JOB NO."
	W$(5)="JOB NO."

	X0=5								REMARK  LOAD AND DISPLAY CRT MASK NUMBER 5
	GOSUB 260

	X1=23								REMARK  DISPLAY TODAY'S DATE
	X0=G3(1)
	GOSUB 680

	X1=7
	GOSUB 215
	PRINT G3(5)							REMARK  DISPLAY DAY NUMBER

	GOSUB 7150							REMARK  ENTER COMPANY NUMBER AND NAME

	GOSUB 7400							REMARK  PROMPT OPERATOR FOR PAY TYPE

	GOSUB 7350							REMARK  PROMPT OPERATOR FOR WORK TYPE


6140	IF T2(4)=1 OR T2(4)=2 OR T2(4)=4\				REMARK  ENTER JOB NUMBER IF PHASE 1,2 OR TYPE=4
	THEN GOSUB 5300

	IF T2(4)=2 THEN GOSUB 5350					REMARK  ENTER DEPARTMENT NUMBER IF PHASE 2

	IF T2(3)=1\							REMARK  IF PAY TYPE IS 1,3,5 OR 6, REQUEST HOURS
	OR T2(3)=3\
	OR T2(3)=5\
	OR T2(3)=6\
	THEN\
	GOSUB 5400

	IF T2(3)=4 THEN\						REMARK  ENTER HOURS AND RATE FOR PIECEWORK PAY TYPES
	GOSUB 5400:\
	GOSUB 5450:\
	GOSUB 5500

	IF T2(3) <> 2 THEN GOTO 6155
	IF R2(1)=1 THEN GOSUB 5550\					REMARK  ENTER VACATION PAY AMOUNT FOR HOURLY EMPLOYEE
	ELSE GOSUB 5400							REMARK  ENTER VACATION HOURS FOR SALARIED EMPLOYEE

6155	X=0:X2=2:X3=0:X4=99						REMARK  PROMPT OPERATOR FOR CHANGES TO ENTERED FIELDS
	X2$="ENTER FIELD TO CHANGE ('0' = NONE; '99' TO CANCEL)"
	GOSUB 665
	F=X0
	IF F>6 AND F < 99\
	THEN\
	X2$="OUT OF RANGE":GOSUB 615:GOTO 6155

	IF F=0 THEN GOTO 6175
	IF F=99  THEN GOTO 6180						REMARK  IF FIELD TO CHANGE = 99, CANCEL TRANSACTION

	ON F GOSUB 5300,5350,5400,5450,5500,5550			REMARK  CHANGE FIELDS AND RE-PROMPT
	GOTO 6155

6175	X0=0								REMARK  SAVE TRANSACTION RECORD ON FILE
6180	GOSUB 5750
	IF T2(4)=0 OR T2(4)=3 THEN GOSUB 7200 ELSE GOTO 6185

	IF X0>0 THEN GOTO 6140						REMARK  IF NEW EMPLOYEE=0 OR WORK TYPE NOT 0 OR 3,
6185	GOSUB 5770							REMARK  ALLOW ALPHA-KEY FIELD CHANGES
	GOTO 6140



	GOSUB 265							REMARK  DISPLAY CURRENT TRANSACTION DATA ON CRT
	X1=23
	X0=G3(1)
	GOSUB 680							REMARK  DISPLAY DATE
	X1=7
	GOSUB 215
	PRINT G3(5)							REMARK  DISPLAY DAY NUMBER AND COMPANY NAME
	GOSUB 7160
	X1=12
	GOSUB 215
	GOSUB 7265							REMARK  DISPLAY EMPLOYEE NUMBER AND NAME
7010	X1=12
	GOSUB 215
	PRINT USING MASKA$;T2(3),P$(T2(3)+1)				REMARK  DISPLAY PAY TYPE AND DESCRIPTION
	X1=12
	GOSUB 215
	PRINT USING MASKA$;T2(4),W$(T2(4)+1)				REMARK  DISPLAY WORK TYPE AND DESCRIPTION
	PRINT
	X1=11
	GOSUB 215
	PRINT USING MASK6$;T2(6)					REMARK  DISPLAY JOB NUMBER
	X1=13
	GOSUB 215
	PRINT USING MASK2$;T2(5)					REMARK  DISPLAY DEPARTMENT NUMBER
7070	X1=12
	GOSUB 215
	PRINT USING MASK2.2$;T2(7);					REMARK  DISPLAY HOURS
	X1=18
	GOSUB 215
	PRINT USING MASK2.2$;HOURS					REMARK  DISPLAY TOTAL HOURS ENTERED FOR THIS EMPLOYEE
	X1=11
	GOSUB 215
	PRINT USING MASK6$;N						REMARK  DISPLAY PIECEWORK QUANTITY
	X1=10
	GOSUB 215
	PRINT USING MASK4.2$;N1						REMARK  DISPLAY PIECEWORK RATE
	X1=10
	GOSUB 215	
	PRINT USING MASK4.2$;T2(8)					REMARK  DISPLAY TRANSACTION AMOUNT
	RETURN 

7150	GOSUB 7160							REMARK  FIRST ENTRY OF EMPLOYEE NUMBER
	GOSUB 7200
	IF X0=0  THEN GOTO 7300						REMARK  IF ZERO ENTERED, END PROGRAM
	RETURN 
7160	X1=267
	GOSUB 210
	PRINT USING"  ## /123456890123456789012/";G1,G2$(1)
	RETURN 
7200	REMARK **********PROMPT FOR ENTRY OF EMPLOYEE NUMBER**********
	X1=332
	X2=3
	X3=0
	X4=999
	GOSUB 345 
	IF X0=0 AND T2(4)=0 THEN RETURN
	IF X0=0 AND T2(4)=3 THEN RETURN
	IF X0>MSTR.RECORDS OR X0=0 THEN GOSUB 5600:GOTO 7200		REMARK  FLASH ERROR MESSAGE IF EMPLOYEE NUMBER IS INVALID

	GOSUB 745							REMARK  READ EMPLOYEE MASTER RECORD

	IF S(1)=0 THEN X2$="EMPLOYEE NOT ON FILE":GOSUB 615:GOTO 7200	REMARK  IF EMPLOYEE IS INACTIVE OR DELETED, FLASH ERROR
	IF R2(1)=99 THEN X2$="EMPLOYEE INACTIVE":GOSUB 615:GOTO 7200


7260	HOURS=0								REMARK  INITIALIZE TOTAL ENTERED HOURS FOR THIS EMPLOYEE
	GOSUB 5408
	T2(1)=S(1)
	X1=331
	GOSUB 210
7265	PRINT USING MASK4$+" "+MASK.22A$;S(1),R$(1)			REMARK  DISPLAY EMPLOYEE NUMBER AND NAME

	IF R2(1)=1 AND T2(3)=0 THEN GOSUB 5700				REMARK  FLASH OPERATOR WARNING IF NEEDED
	RETURN 


7300	PRINT CLEAR.SCREEN$;"P/R TRANS. ENTRY LOADING MENU"		REMARK  TERMINATE PROGRAM AND LOAD MENU HERE
	CHAIN "P/R000"


7350	X1=462								REMARK  CHANGE WORK TYPE SUBROUTINE
	X2=1
	X3=0
	X4=4
	GOSUB 345 
	T2(4)=X0
	X1=X1+2
	GOSUB 210
	PRINT USING MASK12$;W$(T2(4)+1);				REMARK  DISPLAY WORK TYPE AND CORRESPONDING DESCRIPTION
	RETURN 



7400	X1=398								REMARK CHANGE PAY TYPE SUBROUTINE
	X2=1
	X3=0
	X4=6
	GOSUB 345
	T2(3)=X0
	X1=X1+2
	GOSUB 210
	PRINT USING MASK12$;P$(T2(3)+1)
	IF R2(1)=1 AND T2(3)=0 THEN GOSUB 5700				REMARK  FLASH OPERATOR WARNING IF INDICATED
	RETURN


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