     **************  TIMECALC COMMAND FILE  ******************
* Verifies that employee name and number match, then
* calculates billing charges for employee time.
*************************************************************

SET TALK OFF
ERASE
SELECT PRIMARY
RESTORE FROM B:Constant

GO TOP
DO WHILE .NOT. EOF
   ERASE
   @  4,20 SAY '     ** DO NOT INTERRUPT **      '
   @  5,20 SAY '     PROCESSING TIME CHARGES     '

   IF * .OR. Job:Nmbr = 31 .OR. Check:Nmbr <> '---'
      SKIP
   ELSE
      REPLACE Client WITH !(Client), Name WITH !(Name)
      STORE STR(#,4) TO Number
      @  7,20 SAY '         Record # '+Number
      @  8,20 SAY '         '+Name
      ? CHR(7)
      IF Emp:Nmbr<=0 .OR. Emp:Nmbr>MaxEmpl .OR. Hours = 0
         ERASE
         REPLACE Hours WITH Hours*1.00
         REPLACE Emp:Nmbr WITH Emp:Nmbr*1
         @  4,0 SAY ' '
         DISPLAY
         @ 6,3 SAY 'HOURS='
         @ 6,18 SAY '=EMPLOYEE NUMBER'
         ?
         ? 'Press ANY KEY to correct the EMPLOYEE NUMBER,'
         ? 'or press H to correct HOURS.'
         WAIT TO Decision
         IF !(Decision) <> 'H'
            @ 6,14 GET Emp:Nmbr
         ELSE
            @ 6,8 GET Hours
         ENDIF
         READ
      ELSE
         SELECT SECONDARY
         USE B:Personne
         STORE T TO Looking
         DO WHILE Looking .AND. .NOT. EOF
            IF $(Name,1,10)=$(P.Name,1,10)
               IF Emp:Nmbr=P.Emp:Nmbr
                  SELECT PRIMARY
                  * Formula optimistically assumes 65 billable hours out
                  * of 75 hours possible in two weeks.  Eff. mult.=3.23
                  REPLACE Amount WITH Pay:Rate*2.8*Hours/65
                  SELECT SECONDARY
                  STORE F TO Looking
               ELSE
                  SELECT PRIMARY
                  STORE T TO Fixing
                  DO WHILE Fixing
                     ERASE
                     @ 4,0 SAY ' '
                     DISPLAY
                     @ 6,16 SAY '=EMPLOYEE NUMBER'
                     ?
                     ? 'The correct Employee Number is'
                     ?? S.Emp:Nmbr
                     ?? ' for '+S.Name
                     ? 'Press ANY KEY to change the EMPLOYEE NUMBER'
                     ? 'press N to change the NAME.'
                     WAIT TO Choice
                     IF !(Choice) <> 'N'
                        @ 6,12 GET Emp:Nmbr
                        READ
                        STORE F TO Fixing
                     ELSE
                        @ 5,25 GET Name
                        REPLACE Name WITH !(Name)
                        READ
                        STORE F TO Fixing
                     ENDIF Employee number
                     ERASE
                  ENDDO Fixing
                  SELECT SECONDARY
                  GO TOP
               ENDIF Numbers match
            ELSE
               SKIP
            ENDIF

            IF EOF
               ERASE
               SELECT PRIMARY
               @ 4,0 SAY ' '
               DISPLAY
               @ 6,16 'SAY '=EMPLOYEE NUMBER'
               ?
               ? 'This name is not listed in the Personnel file,'
               ? 'so time charge were not calculated.'
               ? 'Press any key to change the name, or write the'
               ? 'record number down and press D to DELETE.'
               WAIT TO Change
               IF !(Change) <> 'D'
                  @ 5,25 GET Name
                  REPLACE Name WITH !(Name)
                  READ
                  SKIP-1
               ELSE
                  ERASE
                  DELETE
                  DISPLAY
                  ?
                  ? 'THIS RECORD HAS BEEN DELETED.'
                  WAIT
               ENDIF Change
               SELECT SECONDARY
            ENDIF no name
         ENDDO Looking
         SELECT PRIMARY
         SKIP
      ENDIF
   ENDIF deleted
ENDDO billing calculations

RELEASE All
RETURN
