tldm-universe/CMS/BP.CLOCK/MSD.PERFECT.KWD
2024-09-10 15:25:06 -04:00

289 lines
8.2 KiB
Plaintext
Executable File

* MSD.CLOCK.PERFECT
*
* SCOTT REDMOND
* 06/27/94
*
* PURPOSE: GENERATE PERFECT ATTENDENCE REPORT FOR PAYROLL
*
*---------------------------------------------------------------------*
*
OPEN 'CLOCKFILE' TO CLOCKFILE ELSE ABORT 201, 'CLOCKFILE'
OPEN 'CM' TO CM ELSE ABORT 201, 'CM'
OPEN 'PERFECT.WORK' TO PERFECT.WORK ELSE ABORT 201, 'PERFECT.WORK'
OPEN 'USER' TO USER ELSE ABORT 201, 'USER'
*
*
*----------------*
*
$INCLUDE GEN.COMMON
$INCLUDE USER
*
*----------------*
*
T=0
PERF=0
WT=0
OLD.WEEK=0
EOF=0
WEEK=0
PERFECT.SW=0
UTABLE=''
REPORT=0
*
CRT CS
HDG='PERFECT ATTENDENCE REPORT'
HDL=(80-(LEN(HDG))) / 2
CRT @(0,0):RV:STR(" ",80):ERV
CRT @(HDL,0):RV:HDG:ERV
CRT @(0,1):'MSD.CLOCK.PERFECT'
*
THIS.YEAR=OCONV(DATE(),'DY')
DAY=OCONV(DATE(),'DJ')
IF DAY <= 182 THEN
REPORT=1
END ELSE
REPORT=2
END
*
100 *
CRT @(0,22):CL:RV:" ENTER REPORT YEAR ELSE <return> FOR CURRENT YEAR ":ERV
CRT @(23,5):CL:RV:" YEAR OF REPORT :":ERV:" ":THIS.YEAR
CRT @(40,5):
INPUT YEAR,5
IF YEAR=PF3 THEN GOTO 9000
IF NOT(NUM(YEAR)) THEN GOTO 100
IF YEAR='' THEN YEAR = THIS.YEAR
IF LEN(YEAR)=2 THEN
YEAR=THIS.YEAR[1,2]:YEAR
END
CRT @(41,5):CL:YEAR
*
200 *
CRT @(0,22):CL:RV:" ENTER THE REPORT NUMBER ":ERV
CRT @(23,8):CL:RV:" #1 01/01/":YEAR[3,2]:" thru 06/30/":YEAR[3,2]:" ":ERV
CRT @(23,10):CL:RV:" #2 07/01/":YEAR[3,2]:" thru 12/31/":YEAR[3,2]:" ":ERV
CRT @(23,12):CL:RV:" SELECT REPORT # :":ERV:REPORT
CRT @(41,12):
INPUT IN.REPORT,4
IF IN.REPORT=PF3 THEN GOTO 9000
IF IN.REPORT='' THEN IN.REPORT=REPORT
IF IN.REPORT < 1 OR IN.REPORT > 2 THEN
CRT @(0,22):CL:RV:" SELECT REPORT #1 OR REPORT #2 <return> :":
INPUT DUMMY
GOTO 200
END
REPORT=IN.REPORT
CRT @(0,5):CR
CRT @(22,5):CL:RV:" PERFECT ATTENDENCE REPORT FOR ":YEAR:" ":ERV
IF REPORT=1 THEN
NDG=" 01/01/":YEAR[3,2]:" thru 06/30/":YEAR[3,2]:" "
NDL=(80-(LEN(NDG))) / 2
CRT @(0,8):CL
CRT @(NDL,8):RV:NDG:ERV
REPORT.ONE.DATE='01/01/':YEAR[3,2]
REPORT.TWO.DATE='06/30/':YEAR[3,2]
REPORT.ONE=ICONV(REPORT.ONE.DATE,'D')
REPORT.TWO=ICONV(REPORT.TWO.DATE,'D')
END ELSE
NDG=" 07/01/":YEAR[3,2]:" thru 12/31/":YEAR[3,2]:" "
NDL=(80-(LEN(NDG))) / 2
CRT @(0,8):CL
CRT @(NDL,8):RV:NDG:ERV
REPORT.ONE.DATE='07/01/':YEAR[3,2]
REPORT.TWO.DATE='12/31/':YEAR[3,2]
REPORT.ONE=ICONV(REPORT.ONE.DATE,'D')
REPORT.TWO=ICONV(REPORT.TWO.DATE,'D')
END
*
CRT @(23,16):CL:"SEND REPORT TO THE PRINTER (Y/N) :":
INPUT PRINT.ANS,15
IF PRINT.ANS = 'Y' THEN
PRINT.SW=1
EXECUTE "EX PRINTER"
END ELSE
PRINT.SW = 0
END
*
CLEARFILE PERFECT.WORK
*
*----- time table ----------------------------------------------*
CRT @(0,11):CR:
* <1>=sunday - first day of week
* <2>=saturday - last day of week
*
ATT.ONE=0 ; ATT.TWO=0 ; TIME.TABLE=''
FOR GG = REPORT.ONE TO REPORT.TWO
IF OCONV(GG,'DWA')='SUNDAY' THEN
ATT.ONE=ATT.ONE+1
TIME.TABLE<1,ATT.ONE>=GG
END
IF OCONV(GG,'DWA')='SATURDAY' THEN
ATT.TWO=ATT.TWO+1
TIME.TABLE<2,ATT.TWO>=GG
END
NEXT GG
*
SELECT CLOCKFILE
LOOP
READNEXT CKEY ELSE EOF=1
UNTIL EOF DO
T=T+1
IF REM(T,100)=0 THEN GOSUB 5000 ;* refresh totals
CDATE=OCONV(CKEY,'G1|1')
CUSER=OCONV(CKEY,'G0|1')
IF CDATE >= REPORT.ONE AND CDATE <= REPORT.TWO THEN
READ USER.REC FROM USER,CUSER ELSE GO 4999
GOSUB 2000 ; * ELIMINATION PROCESS
IF ELIM.SW THEN GO 3555
GOSUB 3000
3555 *
GOSUB 4000
4999 *
REPEAT
GOSUB 5000
9000 *
STOP
*
2000 *--- elimination process -------------------------------*
ELIM.SW=0
IF USER.REC<UR$CLOCK.SYSTEM> # 'C' THEN ELIM.SW=1
IF USER.REC<UR$HIRE.DATE> >= REPORT.ONE THEN ELIM.SW=1
RETURN
*
3000 *--- calculate clock totals -----------------------------*
CU.KEY=CUSER:"*":USER.REC<1>:".":USER.REC<2>
READ OUT.REC FROM PERFECT.WORK,CU.KEY ELSE OUT.REC=''
LOCATE(CDATE,TIME.TABLE,1;POSITION;"AR") ELSE NULL
IF CDATE=TIME.TABLE<1,POSITION> ELSE POSITION=POSITION-1
IF CDATE <= TIME.TABLE<2,POSITION> THEN
READ CLOCK.REC FROM CLOCKFILE,CKEY THEN
PERIOD=TIME.TABLE<3,POSITION>
*----- initialize totals with each user, each day -----*
OUT.TIME=0 ; IN.TIME=0 ; DAILY.TIME=0
VAC.TOTAL=0 ; SICK.TOTAL=0 ; HOLIDAY.TOTAL=0
FUNERAL.TOTAL=0 ; JURY.TOTAL=0 ; WORKMANS.TOTAL=0
PERSONAL.TOTAL=0 ; BONUS.TOTAL=0 ; OTHER.TOTAL=0
*
TIMCT=DCOUNT(CLOCK.REC<1>,VM)
FOR TIM = 1 TO TIMCT ;* calc daily time
IF CLOCK.REC<2,TIM>='OFF' THEN
OUT.TIME=CLOCK.REC<1,TIM>
DAILY.TIME=DAILY.TIME+(OUT.TIME-IN.TIME)
END ELSE
JOB=''
JOB=OCONV(CLOCK.REC<2,TIM>,'G1-1')
JOB.TWO=JOB[2,2]'L%3'
IF JOB[1,1]='V' THEN ;* compute vacation
VAC.TOTAL=VAC.TOTAL+JOB.TWO
END
IF JOB[1,1]='S' THEN ;* compute sick
SICK.TOTAL=SICK.TOTAL+JOB.TWO
END
IF JOB[1,1]='H' THEN ;* compute holiday
HOLIDAY.TOTAL=HOLIDAY.TOTAL+JOB.TWO
END
IF JOB[1,1]='P' THEN ;* personal
PERSONAL.TOTAL=PERSONAL.TOTAL+JOB.TWO
END
IF JOB[1,1]='F' THEN ;* funeral
FUNERAL.TOTAL=FUNERAL.TOTAL+JOB.TWO
END
IF JOB[1,1]='W' THEN ;* workmans comp.
WORKMANS.TOTAL=WORKMANS.TOTAL+JOB.TWO
END
IF JOB[1,1]='B' THEN ;* bonus day
BONUS.TOTAL=BONUS.TOTAL+JOB.TWO
END
IF JOB[1,1]='J' THEN ;* jury duty
JURY.TOTAL=JURY.TOTAL+JOB.TWO
END
IN.TIME=CLOCK.REC<1,TIM>
END
NEXT TIM
DAILY.TIME =(DAILY.TIME/60)/60 ;* convert seconds to hours
DAILY.HOURS=INT(DAILY.TIME)
DAILY.DECI =OCONV(DAILY.TIME,'G1.1')[1,3]
TWO.DECI =DAILY.DECI[1,2]'L%2'
EXTRA.DECI =DAILY.DECI[3,1]
IF EXTRA.DECI >= 5 THEN
IF TWO.DECI=99 THEN
TWO.DECI='00'
DAILY.HOURS=DAILY.HOURS+1
END ELSE
TWO.DECI=TWO.DECI+1'R%2'
END
END ELSE
IF TWO.DECI=99 THEN
TWO.DECI='00'
DAILY.HOURS=DAILY.HOURS+1
END
END
END
OTHER.TOTAL =SICK.TOTAL+PERSONAL.TOTAL+WORKMANS.TOTAL
OUTPUT.HOURS =DAILY.HOURS:TWO.DECI
OUTPUT.HOURS =OUTPUT.HOURS
GOOD.HOURS =(OUTPUT.HOURS-OTHER.TOTAL)'R%4'
OUT.REC<POSITION,1>=(OUT.REC<POSITION,1>+GOOD.HOURS)'R%4'
OUT.REC<POSITION,2>=OCONV(TIME.TABLE<1,POSITION>,'D2/')
WRITE OUT.REC ON PERFECT.WORK,CU.KEY
WT=WT+1
END
END
4000 *--- calculate project totals --------------------------*
SELECT CMS.SUPPORT.TRANS.FILE
*
T=0
TWK=0
*
100 READNEXT SKEY ELSE GO 999
READ SREC FROM CMS.SUPPORT.TRANS.FILE,SKEY ELSE GO 100
IF REM(T,50)=0 THEN
CRT @(0,10):CR:"SUPPORT RECORDS READ: ":T
CRT @(0,11):"WORK RECORDS WRITTEN: ":TWK
END
T=T+1
*
LOCATE(CDATE,TIME.TABLE,1;POSITION;"AR") ELSE NULL
IF CDATE=TIME.TABLE<1,POSITION> ELSE POSITION=POSITION-1
IF CDATE <= TIME.TABLE<2,POSITION> THEN
CT=DCOUNT(SREC<SS$ACTION.DATE>,VM)
FOR X = 1 TO CT
IF SREC<SS$ACTION.CODE,X>=30 THEN
IF SREC<SS$ACTION.DATE,X> >= REPORT.ONE AND SREC<SS$ACTION.DATE,X> <= REPORT.TWO THEN
IF USERS # '' THEN
IF USERS # SREC<SS$ACTION.OPERATOR,X> THEN GO 1225
END
WKREC=''
WKREC<1>=SREC<SS$CLIENT>
WKREC<2>=SREC<SS$ACTION.DATE,X>
WKREC<3>=SREC<SS$ACTION.CODE,X>
WKREC<4>=SREC<SS$ACTION.TIME,X>
WKREC<5>=SREC<SS$ACTION.OPERATOR,X>
WKREC<6>=SREC<SS$ACTION.MINUTES,X>
WKREC<7>=SREC<SS$ACTION.TASK,X>
WKREC<8>=SREC<SS$ACTION.BILL.CODE,X>
IF WKREC<8>='1' THEN WKREC<8>='Bl' ELSE
IF WKREC<8>='2' THEN WKREC<8>='SC' ELSE
IF WKREC<8>='3' THEN WKREC<8>='Fr'
END
END
WKREC<9>=SREC<SS$ACTION.COMMENT,X>
TASK=WKREC<7>
LOCATE(TASK,SREC,SS$TASK.NUMBER;FND) THEN
DESC=SREC<SS$TASK.DESCRIPTION,FND>
END ELSE
DESC='TASK DESCRIPTION NOT FOUND!'
END
WKREC<10>=DESC
WKREC<11>=SKEY
TWK=TWK+1
WRITE WKREC ON WORKFILE,TWK
END
END
1225 *
NEXT X
5000 *--- refresh totals ------------------------------------*
CRT @(NDL,14):CL:"ITEMS PROCESSED :":T'L,'
CRT @(NDL,15):CL:"ITEMS FOUND :":WT'L,'
RETURN