          SUBROUTINE (PASSER)
** Version# 27.0002[2] - 01/18/2017 - 03:41pm - TSMITH - eclipse
*** V27.0002 Change - Custom Coding 471 - 01/18/2017 - TSMITH - eclipse
** Copied from CBP CD.DVR.PRINT.CHECKS Version# 27.0001[1] - 12/12/2016 - 12:28pm - TSMITH - eclipse

*** Subroutine - CD.DVR.PRINT.CHECK
*-------------------------------------------------------------------------*
*** This routine is the driver for printing checks.  The user is prompted
*** for the following:
*-------------------------------------------------------------------------*
*** Pay On Start Date  - Start date to look for payables ready to pay (IN)
*** Pay On End Date    - End Date to look for payables ready to pay   (IN)
*** Payable Branches   - What payable branches will be cutting checks (IN)
*** Check Posting Date - What date to use for the check posting       (IN)
*** Bank Account       - Which Bank to pay out of.                    (IN)
*** Bank Account Brnch - Which Bank Branch number.                    (IN)
*** Next Check Number  - Next Check Number to use.                    (IN)
*** Currency           - What currency to print checks in.            (IN)
*-------------------------------------------------------------------------*
*** COMMON VARIABLES : None Specified
*-------------------------------------------------------------------------*
          SCREEN

          *** Set up any variables needed for this routine
          GOSUB INIT

          *** Load the hotkeys for the screen.
          GOSUB LOAD.HOTKEYS

*-------------------------------------------------------------------------*
INSD:     INP SD,24,3,10,'D4/'
          IF F12 THEN GOTO FINISH
          IF QUIT THEN PRINT BELL:; GOTO INSD
          IF SD # '' AND ED = '' THEN
             ED = SD
             PRINT @(24,4):OCONV(ED,'D4/')
          END
          ON MOVE+1 GOTO INSD,INSD,INSD,INSD,INED,INED
*-------------------------------------------------------------------------*
INED:     INP ED,24,4,10,'D4/'
          IF F12 THEN GOTO FINISH
          IF QUIT THEN PRINT BELL:; GOTO INED
          ON MOVE+1 GOTO INED,INED,INSD,INED
*-------------------------------------------------------------------------*
INBR:     INP.BR 24,5,10,BR,NAME,BRCHS,YES
          IF F12 THEN GOTO FINISH
          IF QUIT THEN PRINT BELL:; GOTO INBR
          ON MOVE+1 GOTO INBR,INBR,INED,INBR
*-------------------------------------------------------------------------*
INCHKDT:  INP CHKDT,24,6,10,'D4/'
          IF F12 THEN GOTO FINISH
          IF CHANGED THEN
             PRMPT = 'Authorization to Change Check Posting Date in Print Checks'
             AUTH.PRMT = 'AP.CHANGE.CHECK.POST.DATE'
             AUTH.USR  =  USER.ID
             UT.GET.AUTH PRMPT,AUTH.PRMT,APRV.OK,,AUTH.USR
             IF NOT(APRV.OK) THEN
                CHKDT = DATE()
                PRINT @(24,6):BELL:OCONV(CHKDT,'D4/')
                MESS 5,8,BELL:'User not authorized.'
                GOTO INCHKDT
             END
           END
          IF CHKDT THEN
             CHK.GL.POST CHKDT,OK,'D'
             IF NOT(OK) THEN
                MESS 5,8,BELL:OCONV(CHKDT,'D4/'):' is in a closed period'
                CHKDT = DATE()
                PRINT @(24,6):OCONV(CHKDT,'D4/')
                GOTO INCHKDT
             END
          END ELSE
             ** If not check date specified send them back
             PRINT BELL:; GOTO INCHKDT
          END
          IF QUIT THEN PRINT BELL:; GOTO INCHKDT
          ON MOVE+1 GOTO INCHKDT, INCHKDT, INBR, INCHKDT
*-------------------------------------------------------------------------*
INBANK:
          SV.MV = MOVE  ;* So that the move doesn't get stepped on
                        ;* in GET.BANK.
          GET.BANK BANK.ID,BANK.DESC,BR
          PRINT @(24,7):BANK.DESC"L#15"
          GOSUB DISP.CHKNO
          GOSUB DISP.ECHKNO
          PRINT @(24,9):EFT.VEN   "L#7"
          IF F12 THEN GOTO FINISH
          MOVE = SV.MV
          ON MOVE+1 GOTO INBANK,INBANK,INCHKDT,INBANK
*-------------------------------------------------------------------------*
INBANKBR: INP.BR 24,8,10,BANKBR,TERR.TYPE=-1
          IF F12 THEN GOTO FINISH
          IF QUIT THEN PRINT BELL:; GOTO INBANKBR
          ON MOVE+1 GOTO INBANKBR, INBANKBR, INBANK, INBANKBR
*-------------------------------------------------------------------------*
*** Allow the user to specify if they would like to include, exclude or
*** only run the check run for EFT vendors
INEFTVEN: INP EFT.VEN,24,9,7,V_'D:':ORDER.OPTS
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INEFTVEN, INEFTVEN, INBANKBR, INEFTVEN
*-------------------------------------------------------------------------*
*** Input for the starting check number for the run of checks.
INCHKNO:  CHKNO = CHK.NO
IN$$3:    INP CHKNO,24,10,7,"R"
          IF F12 THEN GOTO FINISH
          IF QUIT THEN PRINT BELL:; GOTO INCHKNO
          *** Checking equality because control can be retuned after gosub
          *** subs with changed reset.
          IF CHK.NO # CHKNO THEN
             IF CHKNO = '' THEN GOSUB DISP.CHKNO; GOTO INCHKNO
             CHECK.ID = BANK.ID:'~':CHKNO
             READV TST FROM CHKXFILE,CHECK.ID,1 ELSE TST = ''
             IF TST # '' THEN
                MESS 3,3,BELL:'Check # ':CHKNO:' already on file'
                PRINT @(24,10):CHK.NO "R#7"
                GOTO INCHKNO
             END
             CHK.NO = CHKNO
          END

          ON MOVE+1 GOTO INCHKNO, INCHKNO, INEFTVEN, INCHKNO
*-------------------------------------------------------------------------*
*** Allow user to change the EFT check that was auto displayed whent the
*** bank was entered
INECHKNO: ECHKNO = ECHK.NO
IN$$4:    INP ECHKNO,24,11,7,"R"
          IF F12 THEN GOTO FINISH
          *** Checking equality because control can be retuned after gosub
          *** subs with changed reset.
          IF ECHKNO # ECHK.NO THEN
             IF ECHKNO = '' THEN GOSUB DISP.ECHKNO; GOTO INECHKNO
             CHECK.ID  = BANK.ID:'~E':ECHKNO
             READV TST FROM CHKXFILE,CHECK.ID,1 ELSE TST = ''
             IF TST # '' THEN
                MESS 3,3,BELL:'Check # ':ECHKNO:' already on file'
                PRINT @(24,11):ECHKNO "R#7"
                GOTO INECHKNO
             END
             ECHK.NO = ECHKNO
          END

          ON MOVE+1 GOTO INECHKNO, INECHKNO, INCHKNO, INECHKNO
*-------------------------------------------------------------------------*
INZERO:   *** Input to prompt for Zero dollar check printing capability
          ***
          *** Y = Zero Dollar checks will print
          *** N = Zero Dollar checks will never print
          *** C = A disbursement record created but no check prints and
          ***     no EFT staging record created.
          ***
IN$$7:    INP ZERO.CHK,31,12,1,V_'D:':'Y - Yes':VM:'N - No':VM:'C - Clear Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INZERO, INZERO, INECHKNO, INZERO, INZERO, INZERO
*-------------------------------------------------------------------------*
INIT:     *** Set up any variables needed for this routine
          SD       = ''              ;* PayOn Start Date
          ED       = ''              ;* PayOn End Date
          BRCHS    = ''              ;* Branches
          BANK.ID  = ''              ;* Bank ID
          CHKDT    = DATE()          ;* Check Date
          BANKBR   = ''              ;* Bank Branch
          ORIG.CHK = ''              ;* Check Number
          FITEM    = ''
          EFT.VEN  = 'Include'
          ECHKNO   = ''
          CHKNO    = ''
          CHK.NO   = ''
          ZERO.CHK = 'N'

          PRINT @(24,6):OCONV(CHKDT,'D4/')

          *** Print Default Zero Dollar Check prompt
          PRINT @(31,12):'N'

          *** Read the control file EFT.SETUP to get the File type of the
          *** bank to later display the EFT Batch ID
          READ STUP FROM CTRLFILE,'EFT.SETUP' ELSE STUP = ''
          BNK.ID = STUP<1>     ;* Bank IDs
          F.TYPE = STUP<2>     ;* Form Types

          *** Read the control file, CD.EFT.FORMATS to get the next batch
          *** ID for the EFT form type
          READ EFT.FORM FROM CTRLFILE,'CD.EFT.FORMATS' ELSE EFT.FORM = ''
          FRM.TYPE = EFT.FORM<1>     ;* Form Types
          NEXT.NUM = EFT.FORM<3>     ;* Next Batch ID for the form type

          ORDER.OPTS    = 'Include':VM:'Exclude':VM:'Only'


          RETURN
*-------------------------------------------------------------------------*
LOAD.HOTKEYS: *** Load any hotkeys needed for this routine
          MENU.LOAD  2,14,7,1,'P'    ;* Preview Hot Key
          MENU.LOAD 12,14,5,2,'R'    ;* Print Hot Key
          MENU.LOAD 20,14,4,1,'S'    ;* Select Hot Key

          RETURN
*-------------------------------------------------------------------------*
DISP.CHKNO: *** Auto Display the next check number for the bank ID entered
          *** Define the control rec where the next check number is stored
          CTRL.REC = 'NEXT.CHK.NO:'
          *** Call on routine to get the next check number from control rec
          CHK.GET.NEXT.ID BANK.ID,CHK.NO,CTRL.REC

          ORIG.CHK = CHK.NO
          CHKNO = CHK.NO

          *** Print the next check number for the bank user entered
          PRINT @(24,10):CHK.NO"R#7"

          RETURN
*-------------------------------------------------------------------------*
DISP.ECHKNO: *** Auto Display the next check number for the bank ID entered
          *** Define the control rec where the next check number is stored
          CTRL.REC = 'NEXT.EFT.CHK.NO:'
          *** Call on routine to get the next check number from control rec
          CHK.GET.NEXT.ID BANK.ID,ECHK.NO,CTRL.REC,'E'

          ORIG.ECHK = ECHK.NO
          ECHKNO    = ECHK.NO
          *** Print the next check number for the bank user entered
          PRINT @(24,11):ECHK.NO"R#7"

          RETURN
*-------------------------------------------------------------------------*
SUBS:     *** Handle the hotkeys.

          *** If not bank account is specified, then return
          IF BANK.ID = '' THEN
             E.MESS = "You must enter a Bank Account to continue"
             ERR.MESS 1,1,BELL:E.MESS
IN$$6:       INPNO A,,,0
             RETURN
          END

          *** If these values don't match, a change has been made to the
          *** input field without being activated by pressing <<return>>
          *** or moving off the field. We return to the field in question.
          IF ECHK.NO # ECHKNO OR CHK.NO # CHKNO THEN
             E.MESS  = "Please press <<return>> to register field"
             E.MESS := AM:"before using hotkeys"
             ERR.MESS 2,1,BELL:E.MESS
IN$$5:       INP A
             RETURN
          END
          ON OPTION GOTO PREVIEW, PRT.CHECKS, FSEL
*-------------------------------------------------------------------------*
PREVIEW:  IF ED='' OR SD>ED THEN
             MESS 2,1,BELL:' Start date must be before end date'
             RETURN TO INSD
          END

          IF ZERO.CHK = '' THEN ZERO.CHK = 'N'

          CD.REP.CHECK.PREVIEW.AD SD,ED,BRCHS,BANK.ID,CHK.NO,,,FITEM,ECHK.NO,EFT.VEN,CHKDT,ZERO.CHK
          RETURN
*-------------------------------------------------------------------------*
PRT.CHECKS:  *
          IDS   = ''
          IF ED = '' OR SD > ED       THEN PRINT BELL:; RETURN TO INED
          IF BRCHS     = ''           THEN PRINT BELL:; RETURN TO INBR
          IF CHKDT+0   = 0            THEN PRINT BELL:; RETURN TO INCHKDT
          IF BANK.ID+0 = 0            THEN PRINT BELL:; RETURN TO INBANK
          IF BANKBR    = ''           THEN PRINT BELL:; RETURN TO INBANKBR


          READVU CUR.CHK FROM CTRLFILE,'NEXT.CHK.NO:':BANK.ID,1 ELSE CUR.CHK = 1

          IF ORIG.CHK # CUR.CHK THEN
             MESS 3,3,BELL:'Check Number changed by Another User'
             GOSUB DISP.CHKNO
             RETURN TO INCHKNO
          END

          *** If user changed the check number, save the check# user
          *** entered in control file
          IF CHK.NO # ORIG.CHK THEN
             WRITEV CHK.NO ON CTRLFILE,'NEXT.CHK.NO:':BANK.ID,1
          END

          *** If user changed the EFT check number, save the EFT check#
          *** user entered in control file
          IF ECHK.NO # ORIG.ECHK THEN
             WRITEV ECHK.NO ON CTRLFILE,'NEXT.EFT.CHK.NO:':BANK.ID,1
          END

          *** If multi currencies are allowed for the company and the
          *** currency input prompt is not filled in from the Select hotkey
          *** screen, display a warning message
          READ VALID.CUR FROM CTRLFILE,'VALID.CURRENCIES' THEN
             CUR.CNT = DCOUNT(VALID.CUR<1>,VM)
             IF CUR.CNT > 1 THEN
                LOCATE '92~1' IN FITEM<1,1> SETTING POS ELSE
                   RES  = ''
                   PMSG = 'Do You Wish To Print Checks For Multiple Currencies (Y/N)? '
IN$$2:             INP.PROMPT  RES,PMSG,'YN',1
                   IF NOT(RES) THEN
                     RETURN
                   END
                END
             END
          END

          WINDOW ,,45,3,3
          PRINT @(0,1):'Ready to Print Checks (Y/N) : '
IN$$1:    INP SURE,30,1,1,'YN'
          WINDOW.CLOSE
          IF QUIT OR NOT(SURE) THEN RETURN

          *** Check to see if user has authorization to
          *** print signatures on checks
          READ SIG FROM CTRLFILE,'AP.CHECK.SIGNATURE.LOGO' ELSE SIG = 0
          IF SIG THEN
             IF USE.ECLIPSE.FORMS$ THEN
                CTRL.ID = "ECLIPSE.FORMS.DEFAULTS"
                READV SIG.FILE FROM CTRLFILE,CTRL.ID,16 ELSE SIG.FILE = ""
             END ELSE
                SIG.FILE = "NOT ECLIPSE FORMS"
             END

             IF (SIG.FILE # "") THEN
                WARN.MSG = 'Print AP check signature? (Y/N)'
                NAUTH.MSG = 'You are not authorized to print AP check signatures'
                KEY.ID = 'AP.SIGNATURE.PRINT'
                GET.USER.AUTH KEY.ID,WARN.MSG,NAUTH.MSG,ACTION.OK,USR.ID
                IF NOT(ACTION.OK) THEN PRT.SIG = NO ELSE PRT.SIG = YES
             END ELSE
                PRT.SIG = NO
             END
          END ELSE
             PRT.SIG = NO
          END

          IF ZERO.CHK = '' THEN ZERO.CHK = 'N'

          CD.PRINT.CHECKS SD,ED,BRCHS,CHKDT,BANK.ID,BANKBR,IDS,FITEM,EFT.VEN,PRT.SIG,USR.ID,ZERO.CHK

          *** Need to release this control record since if the batch
          *** just contained EFT checks we did not release this in
          *** CD.PRINT.CHECK.BODY
          RELEASE CTRLFILE,'NEXT.CHK.NO:':BANK.ID

          RETURN TO FINISH
*-------------------------------------------------------------------------*
FSEL:     * allows for the entry of items to select off of.
          FILTER.INPUT 'P',FITEM
          RETURN
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
!TSMITH~01/18/17~15:41
