          SUBROUTINE (PASSER)
** Version# 22.0002[216] - 04/12/2010 - 06:47pm - SMITJR - eclipse
*** V22.0002 Change - Custom Coding . - 04/12/2010 - SMITJR - eclipse
** Copied from BP BUSINESS.SUMMARY Version# 22 - 05/13/2003 - 04:05pm - KEVINW - develop

*** Subroutine: BUSINESS.SUMMARY
*-------------------------------------------------------------------------*
*** This routine is used by branch managers and company owners to watch
*** the profit, A/P, A/R at a glance on one screen for any branches
*** they're auth'd. It's kind of a 30,000 foot overview of how the company
*** is doing at this point in time.
*-------------------------------------------------------------------------*
*** PASSER is not used in this routine.
*-------------------------------------------------------------------------*
          SCREEN

          CHECK.KEY 'COGS.VIEW',COGS.VIEW.OK
          CHECK.KEY 'COST.VIEW',COST.VIEW.OK

          BEGIN CASE
          CASE COGS.VIEW.OK AND COST.VIEW.OK
             VIEW.TYPE = 'COGS'
          CASE COGS.VIEW.OK
             VIEW.TYPE = 'COGS'
          CASE COST.VIEW.OK
             VIEW.TYPE = 'COMM.COST'
             PRINT @(2,18):'COGS'
             PRINT @(2,11):'Cost'
          CASE OTHERWISE
             EMSG = 'Not authorized to view COGS/Comm Cost Information.'
             ERR.MESS 10,5,EMSG
IN$$2:       INPNO A,,,0
             GOTO FINISH
          END CASE

          MENU.LOAD  2,16,11, 1,'R'       ;* Recalculate
          MENU.LOAD 16,16,12, 1,'S'       ;* Sales Detail
          MENU.LOAD 32,16,21, 0,'~'       ;* Exec Info System

          *** If no print stats are set for sales in process logic, we
          *** will not activate the hotkey
          READV IP.STATS FROM CTRLFILE,'BUS.SUM.SALES.IP',1 ELSE
             IP.STATS = ''
          END
          IF IP.STATS THEN
             MENU.LOAD 31,16,16,10,'P'    ;* Sales In Process
          END ELSE
             MENU.LOAD ,,,,
          END

          SLS.IP = NO
          INTV   = 5
          AS.OF.DT =DATE()
          PRINT @(37,1):OCONV(AS.OF.DT,'D4/') "L#10"

IN.BR:    INP.BR 14,1,10,BR,NAME,BRCHS,YES
          IF QUIT THEN GOTO FINISH
          IF MOVE=0 OR CHANGED THEN GOSUB UPD.DISP
          ON MOVE+1 GOTO IN.BR,IN.BR,IN.BR,IN.ASOF,IN.BR,IN.ASOF
*-------------------------------------------------------------------------*
IN.ASOF:  *INP.TIMED AS.OF.DT,37,1,10,'D4/',,,,,,,,INTV
IN$$1:    INP AS.OF.DT,37,1,10,'D4/'
          IF QUIT THEN GOTO FINISH
          IF AS.OF.DT = '' THEN
*             INP AS.OF.DT,37,1,10,'D4/'
             GOTO IN.ASOF
             END
          IF MOVE=0 OR CHANGED THEN GOSUB UPD.DISP; GOTO IN.ASOF
          ON MOVE+1 GOTO IN.ASOF,IN.BR,IN.ASOF,IN.ASOF,IN.ASOF,IN.ASOF
*-------------------------------------------------------------------------*
IN.INTV:  INP.TIMED INTV,67,1,2,'R',,,,,,,,INTV
          IF QUIT THEN GOTO FINISH
          IF MOVE=0 OR CHANGED THEN GOSUB UPD.DISP; GOTO IN.INTV
          ON MOVE+1 GOTO IN.INTV,IN.ASOF
          GOTO IN.INTV
*-------------------------------------------------------------------------*
UPD.DISP: *
          BUSINESS.SUMM.GET.DATA.BT BRCHS,AS.OF.DT,AR.AMT,AP.AMT,BANK.AMT,UBAP.AMT,CASH.AMT,INVTY.AMT,AMTS,VIEW.TYPE

          PRINT @(14,8):' ':OCONV(AS.OF.DT,'D4/') "L#10":' '

*-------------------------------------------------------------------------*

          *** using OCONV because there is a bug in Universe that
          *** cause the print conversion not working correctly.
          PRINT @(15,4):OCONV(AR.AMT,'MD2,')        "R#20"
          PRINT @(52,4):OCONV(AP.AMT,'MD2,')        "R#20"
          PRINT @(15,5):OCONV(BANK.AMT, 'MD2,')     "R#20"
          PRINT @(52,5):OCONV(UBAP.AMT, "MD2,")     "R#20"
          PRINT @(15,6):OCONV(CASH.AMT, "MD2,")     "R#20"
          PRINT @(52,6):OCONV(INVTY.AMT,"MD2,")     "R#20"
*         Print Days Outstanding
          YSD=OCONV(AS.OF.DT,'D4/')
          YR=FIELD(YSD,'/',3)
          ST.DT="01/01/":YR
          YTD=ICONV(ST.DT,"D4/")
          IF AMTS<1,3>="0" THEN
          PRINT @(15,7):"No YTD Sales" "R#20"
          END ELSE
          PRINT @(15,7):OCONV(AR.AMT/AMTS<1,3> * (AS.OF.DT-(YTD-1)),'MD0')  "R#20"
          END
*-------------------------------------------------------------------------*

          FOR ROW = 1 TO 5
             IF ROW # 1 THEN DROW = ROW + 1 ELSE DROW = ROW
             IF ROW = 4 THEN
                PRINT @(21,8+DROW):AMTS<ROW,1>               "R2#6":'%'
                PRINT @(45,8+DROW):AMTS<ROW,2>               "R2#6":'%'
                PRINT @(71,8+DROW):AMTS<ROW,3>               "R2#6":'%'
             END ELSE
                PRINT @(11,8+DROW):OCONV(AMTS<ROW,1>,"MD2,") "R#16"
                PRINT @(31,8+DROW):OCONV(AMTS<ROW,2>,"MD2,") "R#20"
                PRINT @(57,8+DROW):OCONV(AMTS<ROW,3>,"MD2,") "R#20"
             END
          NEXT ROW

          *** If we are currently displaying sales IP figures, we need
          *** to recalculate these as well
          IF SLS.IP THEN
             GOSUB UPD.SLS.IP
          END

          RETURN
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO RECALC, SLS.DET, EIS, SLS.IP, COGS.COMM.TOGGLE
*-------------------------------------------------------------------------*
RECALC:   GOSUB UPD.DISP
          RETURN
*-------------------------------------------------------------------------*
SLS.DET:  GLTEMP = LOWER(GL.AUTO)
          BUS.SUM.SLS.DET AS.OF.DT,BR,BRCHS,GLTEMP,VIEW.TYPE
          RETURN
*-------------------------------------------------------------------------*
EIS:      BUS.SUM.EIS BR,BRCHS,AS.OF.DT
          RETURN
*-------------------------------------------------------------------------*
SLS.IP:   *** Toggle between Sales In Process and display true SIP figure
          *** on Sales IP Line
          SLS.IP = NOT(SLS.IP)

          *** If we are toggling off, we need to print blank in Sales IP
          *** field and un-highlinght the hotkey
          IF NOT(SLS.IP) THEN
             PRINT @(31,16):'Sales In '
             PRINT @(41,16):'rocess'
             PRINT @(11,10):''  "R#16"
             PRINT @(31,10):''  "R#20"
             PRINT @(31,10):''  "R#20"
             RETURN
          END

          *** Highlight hotkey to turn on Sales In Process
          PRINT @(31,16):BLINK$:'Sales In ':NORM$
          PRINT @(41,16):BLINK$:'rocess':NORM$

UPD.SLS.IP:*** Because this may take a few minutes, let user know the
          *** system is building Sales IP amount
          WINDOW ,,30,3,3
          PRINT @(0,1):BLINK$:'Building Sales IP Data...':NORM$:

          *** Find Sales IP amount
          IP.AMTS = BUS.SUM.SLS.IP(AS.OF.DT,BRCHS)

          WINDOW.CLOSE

          PRINT @(11,10):OCONV(IP.AMTS<1>+0,'MD2,') "R#16"
          PRINT @(31,10):OCONV(IP.AMTS<2>+0,'MD2,') "R#20"
          PRINT @(57,10):OCONV(IP.AMTS<3>+0,'MD2,') "R#20"

          RETURN
*-------------------------------------------------------------------------*
COGS.COMM.TOGGLE:  *** Toggle between COGS view and Comm-Cost view
          IF VIEW.TYPE = 'COGS' THEN
             IF COST.VIEW.OK THEN
                VIEW.TYPE = 'COMM.COST'
                PRINT @(2,18):'COGS'
                PRINT @(2,11):'Cost'
             END ELSE
                EMSG = 'Not authorized to view Comm Cost Information.'
                ERR.MESS 10,5,EMSG
IN$$3:          INPNO A,,,0
             END
          END ELSE
             IF COGS.VIEW.OK THEN
                VIEW.TYPE = 'COGS'
                PRINT @(2,18):'Cost'
                PRINT @(2,11):'COGS'
             END ELSE
                EMSG = 'Not authorized to view COGS Information.'
                ERR.MESS 10,5,EMSG
IN$$4:          INPNO A,,,0
             END
          END
          GOSUB UPD.DISP

          RETURN
*-------------------------------------------------------------------------*
FINISH:   WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
!SMITJR~04/07/10~01:31

!SMITJR~04/12/10~18:47
