**********
* PCREPP *
**********
* Dit programma drukt de planninglijst per productline af.
* De normale ingang is de variabele m:pr:ln die de string bevat
* van de gewenste productline.
STORE T TO print:okay
STORE F TO finished
DO WHILE .NOT. finished
   STORE ".." TO m:pr:ln
   DO WHILE VAL(m:pr:ln) = 0
      @ 7,5 SAY "VAN WELKE PRODUCTLINE WILT U DE GEGEVENS AFDRUKKEN ? (1/99) " GET m:pr:ln PICTURE "##"
      @ 20,66 SAY "AKKOORD :.:"
      READ
      CLEAR GETS
   ENDDO
   STORE "." TO akk
   DO WHILE .NOT. (akk $ "JN")
      STORE "." TO akk
      @ 20,74 GET akk PICTURE "!"
      READ
      CLEAR GETS
   ENDDO
   IF akk = "N"
      STORE "." TO again
      DO WHILE .NOT. (again $ 'JN')
         STORE "." TO again
         @ 20,57 SAY "OPNIEUW INTIKKEN " GET again PICTURE "!"
         READ
         CLEAR GETS
      ENDDO
      @ 20,57 SAY "                    "
      IF again = "N"
         STORE T TO finished
         STORE F TO print:okay
      ENDIF
   ELSE 
      STORE T TO finished
   ENDIF
ENDDO
@ 7,0
@ 20,0
IF print:okay
   DO pcreplsl
ENDIF
IF print:okay
   STORE "--------------------" TO ln 
   STORE 66 TO maxline
   SET EXACT OFF
   SELECT PRIMARY
   USE &opdracht INDEX &opdracht
   GO BOTTOM
   STORE # TO recno
   FIND &m:pr:ln
   IF (#=0)
      @ 7,0
      STORE "." TO akk
      @ 22,0 SAY "PRODUCTLINE NIET AANWEZIG, DRUK RETURN " GET akk
      READ
   ELSE
      @ 7,0
      @ 7,19 SAY "HET PLANNINGSOVERZICHT WORDT NU AFGEDRUKT."
      @ 8,0
      SELECT SECONDARY
      USE &prod:descr
      STORE STR(&m:pr:ln,2) TO memvar
      GO &memvar
      STORE pr:ln:ds TO m:pr:ln:ds
      USE
      USE &planning INDEX &planning
      SELECT PRIMARY
      SET FORMAT TO PRINT
      SET EXACT ON
      STORE 0 TO pag
      STORE 1 TO line
      DO WHILE m:pr:ln = $(prod:nr,1,2) .AND. (.NOT. EOF) 
         SELECT SECONDARY
         STORE p.prod:nr TO memvar
         FIND &memvar
         SELECT PRIMARY
         *
         * Deze module bepaalt of de data in het record binnen de gewenste 
         * periode vallen. (start:per <= datum <= eind:per)
         *
         STORE F TO dat:okay
         IF select .AND. .NOT. *
            STORE $(s.ontw:ts,1,8) TO datum
            DO pcrepltd
            STORE $(s.schn:ts,1,8) TO datum
            DO pcrepltd
            STORE $(s.werktek,1,8) TO datum
            DO pcrepltd
            STORE $(s.zetwerk,1,8) TO datum
            DO pcrepltd
            STORE $(s.proef,1,8) TO datum
            DO pcrepltd
            STORE $(s.films,1,8) TO datum
            DO pcrepltd
            STORE $(s.adr:drag,1,8) TO datum
            DO pcrepltd
            STORE $(s.nabewerk,1,8) TO datum
            DO pcrepltd
            STORE $(s.afwerk,1,8) TO datum
            DO pcrepltd
            STORE $(p.mail:dat,1,8) TO datum
            DO pcrepltd
         ENDIF
         IF .NOT. select
            STORE T TO dat:okay
         ENDIF
         IF dat:okay .AND..NOT. *
            IF line = 1
               * print kopregel
               STORE pag + 1 TO pag
               @ 3,11 SAY 'PROMOTION PLANNING'
               @ 3,39 SAY 'PRODUCTLINE: ' + m:pr:ln:ds
               @ 3,85 SAY 'PAG: ' + STR(pag,2)
               @ 3,101 SAY 'DATUM: ' + sysdate
               @ 4,11 SAY '=================='
               @ 4,39 SAY '---------------------------------'
               IF select
                  @ 5, 99 SAY periode
                  @ 6, 99 SAY "------------------------------"
               ENDIF
               @ 7,11 SAY 'AANTAL'
               @ 7,21 SAY 'PROD'
               @ 7,38 SAY 'ONDERDEEL'
               @ 7,62 SAY 'ONTWE  SCHOO  WERK-   ZET   PROEF  FILMS  ADRES  NABE-  ' +;
                          'AFWER MAILING'
               @ 8,11 SAY 'CODES'
               @ 8,22 SAY 'NR'
               @ 8,62 SAY ' T/S    T/S    TEK   WERK                 DRG    WERK   ' +;
                          ' KING  DATUM'
               @ 9,11 SAY '------'
               @ 9,19 SAY '--------'
               @ 9,29 SAY '-------------------------------'
               @ 9,62 SAY '-----  -----  -----  -----  -----  -----  -----  -----  ' +;
                          '----- --------'
               STORE 10 TO line
            ENDIF
            * print 2 regels
            @ line,13 SAY STR(nr:codes,2)
            @ line,19 SAY $(prod:nr,1,2) + '/' + $(prod:nr,3,5)
            @ line,29 SAY onderdeel
            @ line,62 SAY $(s.ontw:ts,1,5)
            @ line,69 SAY $(s.schn:ts,1,5)
            @ line,76 SAY $(s.werktek,1,5)
            @ line,83 SAY $(s.zetwerk,1,5)
            @ line,90 SAY $(s.proef,1,5)
            @ line,97 SAY $(s.films,1,5)
            @ line,104 SAY $(s.adr:drag,1,5)
            @ line,111 SAY $(s.nabewerk,1,5)
            @ line,118 SAY $(s.afwerk,1,5)
            @ line,124 SAY mail:dat
            STORE line + 1 TO line
            @ line,54 SAY 'ACTUAL'
            @ line,62 SAY $(s.ontw:ts,10,5)
            @ line,69 SAY $(s.schn:ts,10,5)
            @ line,76 SAY $(s.werktek,10,5)
            @ line,83 SAY $(s.zetwerk,10,5)
            @ line,90 SAY $(s.proef,10,5)
            @ line,97 SAY $(s.films,10,5)
            @ line,104 SAY $(s.adr:drag,10,5)
            @ line,111 SAY $(s.nabewerk,10,5)
            @ line,118 SAY $(s.afwerk,10,5)
            STORE line + 1 TO line
            @ line,11 SAY ln + ln + ln + ln + ln + ln + "-"
            STORE line + 1 TO line
            IF line > maxline .AND. (# <> recno)
               @ line + 1,125 SAY "-> " + STR(pag+1,2)
               STORE 1 TO line
            ENDIF
         ENDIF
         SKIP +1
      ENDDO
      @ maxline + 2,0 SAY " "
      SET FORMAT TO SCREEN
    ENDIF
ENDIF print:okay
USE
SELECT SECONDARY 
USE
SELECT PRIMARY
RETURN
*
* EINDE PROGRAMMA
*
