**********
* PCREPT *
**********
DO pcreplsl
IF print:okay
   @ 7,19 SAY "HET PLANNINGSOVERZICHT WORDT NU AFGEDRUKT."
   @ 8,0
   SET TALK OFF
   * Dit programma drukt alle planninglijsten af.
   STORE 66 TO maxline
   SET EXACT ON
   SELECT PRIMARY
   USE &opdracht INDEX &opdracht
   GO BOTTOM
   STORE # TO recno
   GO TOP
   DO WHILE *
      SKIP +1
   ENDDO
   IF recno > 0 .AND. .NOT. EOF
      STORE $(prod:nr,1,2) TO cur:pr:ln
      SET FORMAT TO PRINT
      STORE 0 TO pag
      STORE 1 TO line
      DO WHILE .NOT. EOF
         IF .NOT. *
            STORE prod:nr TO memvar
            SELECT SECONDARY
            USE &calcdat INDEX &calcdat
            FIND &memvar
            STORE $(nabewerk,1,15) TO m:nabewerk
            STORE $(afwerk,1,15) TO m:afwerk
            USE &planning INDEX &planning
            FIND &memvar
            SELECT PRIMARY
            STORE F TO dat:okay
            IF select 
               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 
               IF .NOT. ($(prod:nr,1,2) = cur:pr:ln)
                  STORE $(prod:nr,1,2) TO cur:pr:ln
                  STORE line + 2 TO line
                  IF line > maxline
                     STORE 1 TO line
                  ENDIF
               ENDIF
               IF line = 1
               * print kopregel
                  STORE pag + 1 TO pag
                  @ 3,11 SAY 'PROMOTION PLANNING'
                  @ 3,39 SAY 'PRODUCTLINE: TOTAAL'
                  @ 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 '  PROD'
                  @ 7,31 SAY 'ONDERDEEL'
                  @ 7,53 SAY 'FILMS   ADRES  NABE-  AFWER  MAILING   NABEWERKER       ' +;
                             'AFWERKER        OPMERK-'
                  @ 8,11 SAY '   NR'
                  @ 8,53 SAY '         DRG   WERK   KING    DATUM                     ' +;
                             '                 KING  '
                  @ 9,11 SAY '--------'
                  @ 9,21 SAY '------------------------------'
                  @ 9,53 SAY '-----   -----  -----  -----  --------  ---------------  ' +;
                             '---------------  ------'
                  STORE 10 TO line
               ENDIF
   
               * print 1 regel
               @ line,11 SAY $(prod:nr,1,2) + '/' + $(prod:nr,3,5)
               @ line,21 SAY onderdeel
               @ line,53 SAY $(s.films,10,5)
               @ line,61 SAY $(s.adr:drag,10,5)
               @ line,68 SAY $(s.nabewerk,10,5)
               @ line,75 SAY $(s.afwerk,10,5)
               @ line,82 SAY mail:dat
               @ line,92 SAY m:nabewerk
               @ line,109 SAY m:afwerk
               @ line,126 SAY '______'
               STORE line + 1 TO line
               IF line > maxline .AND. (# <> recno)
                  @ line + 1,125 SAY "-> " + STR(pag+1,2)
                  STORE 1 TO line
               ENDIF
            ENDIF
         ENDIF dat:okay
         SKIP +1
      ENDDO
      @ maxline + 2,0 SAY " "
      SET FORMAT TO SCREEN
   ENDIF
ENDIF print:okay
USE
SELECT SECONDARY 
USE
SELECT PRIMARY
RETURN
*
* EINDE PROGRAMMA
*
