          SUBROUTINE (PASSER)
** Version# 28.0001[1] - 11/22/2010 - 03:28pm - SMITJR - eclipse
** Copied from BP GL.DVR.GEN.JRL Version# 28 - 06/05/2009 - 09:54am - ANNEM - main

*** Subroutine - GL.DVR.GEN.LED
*-------------------------------------------------------------------------*
*** Program to allow parameters to be entered for the general ledger
*** report.
*-------------------------------------------------------------------------*
*** PASSER - Not Used
*-------------------------------------------------------------------------*
*** Common Variables: DRPT
*-------------------------------------------------------------------------*

          WINDOW ,,,,9,'GL.DVR.GEN.JRL'

          DRPT$ = 'General Ledger'
          BR    = PASSER<1>
          BRCHS = PASSER<2>
          GL.ID = PASSER<3>
          SL.ID = PASSER<4>
          SD    = PASSER<5>
          ED    = PASSER<6>
          IF SL.ID = '' THEN
             SL.ALLOWED = 'N'
          END ELSE
             SL.ALLOWED = 'Y'
          END
          SORT  = 'Account#'
          DET   = 'Totals By Day'
          BRKON = NO
          DWNLD = NO
          REQ.FLDS = ''
          TEMPLATE = ''
          XCH      = ''
          XCH.CHNG = 'As of Current Date'
          CALC     = ''
          GL.GRP   = ''
          SV.GL.ID = GL.ID

          PRINT @(15,3):BR                              "L#15"
          PRINT @(15,4):OCONV(SD,'D4/')                 "L#10"
          PRINT @(15,5):OCONV(ED,'D4/')                 "L#10"
          PRINT @(15,6):OCONV(GL.ID,'TGENLED;X;3;3')    "L#25"

          GOSUB LD.MENU

          *** check to see what accounts they have access to
          CHECK.KEY.DETAIL 'GL.ACCOUNTS',ENTRY.OK,,DET.LIST
          *** in this case if they don't have this key they have access
          *** to all accouts so if your a super user you need to have
          *** entry.ok set to no so you have full access to all accounts
          IF NOT(DET.LIST) THEN
             LOCATE 'SUPERUSER' IN AUTH.KEYS<1> SETTING POS THEN ENTRY.OK = NO
          END

          IF NOT(ENTRY.OK) THEN
             DET.LIST = ''
          END

*-------------------------------------------------------------------------*
INBR:     TERR.OK = YES
IN$$1:    INP.BR 15,3,15,BR,NAME,BRCHS,TERR.OK
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INBR, INBR, INBR, INBR, INSD, INSD
*-------------------------------------------------------------------------*
INSD:     INP SD,15,4,10,'VD4/'
          IF F12 THEN GOTO FINISH
          IF ED = ''THEN
             ED = SD
             PRINT @(15,5):OCONV(ED,'D4/')    'L#10'
          END
          ON MOVE+1 GOTO INSD,INSD,INBR,INSD,INED,INED
*-------------------------------------------------------------------------*
INED:     INP ED,15,5,10,'VD4/'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INED,INED,INSD,INED,INACCT,INACCT
*-------------------------------------------------------------------------*
INACCT:   INP GL.ID,15,6,25,'TGENLED;X;3;3',V_'S:VERF.GL.POSTABLE'
          IF F12 THEN GOTO FINISH
          IF CHANGED THEN
             TEMPLATE = ''
             PRINT @(15,7):''"L#25"
          END
          *** If Gl Number is null bypass go straight to Templates.
          IF GL.ID # '' THEN
             IF ENTRY.OK THEN
                *** Make sure they have this account defined off of the
                *** detail authkey.
                LOCATE GL.ID IN DET.LIST<1> SETTING POS ELSE
                   GL.ID = SV.GL.ID
                   PRINT @(15,6):OCONV(GL.ID,'TGENLED;X;3;3')    "L#25"
                   GOTO INACCT
                END
             END

             READV SL.ALLOWED FROM GLFILE,GL.ID,31 ELSE SL.ALLOWED='N'

             IF SL.ALLOWED = '' THEN SL.ALLOWED = 'N'
             IF SL.ALLOWED = 'N' THEN
                PRINT @(15,8):''                              "L#10"
                SL.ID = ''
                GOSUB LD.MENU
                ON MOVE+1 GOTO INACCT,INACCT,INED,INACCT,INSORT,INSORT
             END ELSE
                GOSUB LD.MENU
                ON MOVE+1 GOTO INACCT,INACCT,INED,INACCT,INSUB,INSUB
             END
          END ELSE
             SL.ALLOWED = 'N'
             GOSUB LD.MENU
             ON MOVE+1 GOTO INACCT,INACCT,INED,INACCT,INTEMP,INTEMP
          END
*-------------------------------------------------------------------------*
INTEMP:   INP TEMPLATE,15,7,25,'TGENLED;X;3;3',V_"S:VERF.GL.ID,~GRP"
          IF F12 THEN GOTO FINISH
          IF CHANGED THEN
             GL.GRP   = ''
             GL.REC   = ''
             GROUP    = NO
             OPTS     = ''
             GL.ERR   = ''
             GL.READ TEMPLATE,GL.REC,GL.GRP,GROUP,OPTS,GL.ERR
             IF GL.ERR OR NOT(GROUP) THEN PRINT BELL:; GOTO INTEMP

             GL.ID = ''
             PRINT @(15,6):''"L#25"
             GOSUB LD.MENU
          END
          ON MOVE+1 GOTO INTEMP,INTEMP,INACCT,INTEMP,INSUB,INSUB
*-------------------------------------------------------------------------*
INSUB:    *** Input Subledger info.
          IF DCOUNT(SL.ID,VM) > 1 THEN
             GOTO MOVE.SUB
          END

IN$$4:    INP SL.ID,15,8,10,'MCU'

          IF F12 THEN GOTO FINISH

          IF CHANGED OR HELP THEN

             VAL = SL.ID

             *** If template specified send in null for GL Number
             IF TEMPLATE THEN
                GLN = ''
             END ELSE
                GLN = GL.ID
             END

             VALIDATE.INP VAL,15,8,10,'S:VERF.GL.SUBLEDGER.ID,':GLN
             QUIT = ""; F12 = ""

             SL.ID = VAL

             *** Display SubLedger info
             IF DCOUNT(SL.ID,VM) > 1 THEN
                PRINT @(15,8):'*Multi*'                       "L#10"
             END ELSE
                PRINT @(15,8):SL.ID                           "L#10"
             END

             GOSUB LD.MENU

             *** If nothing returned go back to input
             IF SL.ID = '' THEN GOTO INSUB
          END

MOVE.SUB: ON MOVE+1 GOTO INSUB,INSUB,INACCT,INSUB,INSORT,INSORT
*-------------------------------------------------------------------------*
INSORT:   INP SORT,15,9,18,V_'D:Account# by Branch':VM:'Account#'
          IF F12 THEN GOTO FINISH
          IF SL.ID THEN
             ON MOVE+1 GOTO INSORT,INSORT,INSUB,INSORT,INDET,INDET
          END ELSE
             IF GL.ID THEN
                IF SL.ALLOWED = 'N' THEN
                   ON MOVE+1 GOTO INSORT,INSORT,INACCT,INSORT,INDET,INDET
                END ELSE
                   ON MOVE+1 GOTO INSORT,INSORT,INSUB,INSORT,INDET,INDET
                END
             END ELSE
                IF TEMPLATE THEN
                   ON MOVE+1 GOTO INSORT,INSORT,INSUB,INSORT,INDET,INDET
                END ELSE
                   ON MOVE+1 GOTO INSORT,INSORT,INTEMP,INSORT,INDET,INDET
                END
             END
          END
*-------------------------------------------------------------------------*
INDET:    *** Input Detail Prompt
IN$$5:    INP DET,23,10,15,V_'D:Summary':VM:'Branch Summary':VM:'Totals By Day':VM:'Detail'
          IF F12 THEN GOTO FINISH
          IF TRIM(DET) = '' THEN
             DET   = 'Totals By Day'
             PRINT @(23,10):DET
             MOVE = 0
          END
          ON MOVE+1 GOTO INDET,INDET,INSORT,INDET,INXCH,INXCH
*-------------------------------------------------------------------------*
INXCH:    INP XCH,23,11,10,V_"S:VERF.XCURR.ID"
          IF F12 THEN GOTO FINISH
          IF CHANGED THEN
             IF XCH # '' THEN
                PRINT @(23,12):XCH.CHNG "L#18"
             END ELSE PRINT @(23,12):'' "L#18"
          END
          ON MOVE+1 GOTO INXCH,INXCH,INDET,INXCH,INCALC,INCALC
*-------------------------------------------------------------------------*
INCALC:   IF XCH = '' THEN GOTO INBRKON
IN$$3:    INP CALC,23,12,18,V_"D:,As of Current Date,Historically,Average"
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INCALC,INCALC,INXCH,INCALC,INBRKON,INBRKON
*-------------------------------------------------------------------------*
INBRKON:  INP BRKON,23,13,1,'YN'
          IF F12 THEN GOTO FINISH
          IF MOVE=2 THEN
          IF XCH = '' THEN GOTO INXCH ELSE GOTO INCALC
             ON MOVE+1 GOTO INBRKON,INBRKON,INXCH,INBRKON,INDWNLD,INDWNLD
          END ELSE
             ON MOVE+1 GOTO INBRKON,INBRKON,INCALC,INBRKON,INDWNLD,INDWNLD
          END
*-------------------------------------------------------------------------*
INDWNLD:  INP DWNLD,23,14,1,'YN'
          IF F12 THEN GOTO FINISH
          IF MOVE=2 THEN
             GOTO INBRKON
          END ELSE GOTO INDWNLD
*-------------------------------------------------------------------------*
SUBS:
          *** IF SubLedger HotKey then go to that subroutine.
          IF OPTION = 4 THEN GOTO GET.SUBS

          IF SD   = '' THEN REQ.FLDS<-1> = 'Start Date'
          IF ED   = '' THEN REQ.FLDS<-1> = 'End Date'
          IF DET  = '' THEN REQ.FLDS<-1> = 'Detail/Summary'
          IF GL.ID = '' AND TEMPLATE = '' AND SL.ID = '' THEN REQ.FLDS<-1> = 'Account, Template or SubLedger'
          IF XCH # '' AND CALC = '' THEN REQ.FLDS<-1> = 'Calculate Exchange'

          IF REQ.FLDS # '' THEN
             ERR.MESS 8,3,BELL:'Missing Required Field(s):  ':AM:REQ.FLDS
IN$$2:       INPNO A,,,0
             BEGIN CASE
             CASE REQ.FLDS<1> = 'Start Date'
                REQ.FLDS = ''
                RETURN TO INSD
             CASE REQ.FLDS<1> = 'End Date'
                REQ.FLDS = ''
                RETURN TO INED
             CASE REQ.FLDS<1> = 'Detail/Summary'
                REQ.FLDS = ''
                RETURN TO INDET
             CASE REQ.FLDS<1> = 'Account, Template or SubLedger'
                REQ.FLDS = ''
                RETURN TO INACCT
             CASE REQ.FLDS<1> = 'Calculate Exchange'
                REQ.FLDS = ''
                RETURN TO INCALC
             END CASE
          END

          IF NUM(SD) AND NUM(ED) THEN
             IF SD > ED THEN
                MESS 2,1,BELL:' Start date must be before end date'
                RETURN TO INSD
             END
          END

          IF SORT  = '' THEN SORT = 'Account#'
          GL.GRP = LOWER(GL.GRP)
          PH.EXE 'GL.PHR.GEN.JRL.GDEY',SD,ED,BRCHS,BR,GL.ID,SL.ID,TEMPLATE,GL.GRP,SORT,DET,BRKON,,XCH,CALC,DWNLD
          GL.GRP = RAISE(GL.GRP)

          IF F12 THEN RETURN

          RETURN TO FINISH
*-------------------------------------------------------------------------*
GET.SUBS: *** Retreives Multipl SubLedgers

          GL.SUB.LEDGER.MULTI SL.ID,GL.ID,NO

          GOSUB LD.MENU

          *** Return to INSORT because we don't want to return to subledger
          RETURN TO INSORT
*-------------------------------------------------------------------------*
LD.MENU:  *** Load Menu

          MENU.CLEAR
          MENU.LOAD  2,16,5,1,'P'       ;* Print
          MENU.LOAD 10,16,4,1,'H'       ;* Hold
          MENU.LOAD 17,16,4,1,'O'       ;* Options
          IF (GL.ID AND SL.ALLOWED # 'N') OR TEMPLATE OR (GL.ID = '' AND TEMPLATE = '') THEN
             MENU.LOAD 24,16,4,1,'S'    ;* SubLedgers
          END ELSE
             MENU.LOAD ,,,,             ;* Take away SubLedgers HotKey
          END

          IF DCOUNT(SL.ID,VM) > 1 THEN
             PRINT @(25,16):BLINK$:'ubL':NORM$
             PRINT @(15,8):'*Multi*'                       "L#10"
          END ELSE
             PRINT @(25,16):NORM$:'ubL'
             PRINT @(15,8):SL.ID                           "L#10"
          END

          RETURN
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
!SMITJR~11/22/10~15:28
