          SUBROUTINE (PASSER)
** Version# 18.0001[1] - 07/16/2010 - 09:38am - SMITJR - eclipse
** Copied from BP ORDERED.DVR.PROD.SUM Version# 18 - 10/07/2002 - 07:53pm - GARJEA - develop

*** Subroutine: ORDERED.DVR.PROD.SUM
*-------------------------------------------------------------------------*
*** This is the Driver Routine for the Product Orders Report, which lists
*** all products that have been ordered between the Start and End Dates
*** for the specified branches, with the customer who ordered them, the
*** order number, quantity ordered, and extended price.
*-------------------------------------------------------------------------*
*** Parameter: PASSER (Not used).
*-------------------------------------------------------------------------*
*** Common Variable Used: DRPT
*-------------------------------------------------------------------------*

          SCREEN

          GOSUB INIT
*-------------------------------------------------------------------------*
*** Branch Input...
INBR:     INP.BR 16,3,10,BR,NAME,BRCHS,TERR.OK
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INBR,INBR,INBR,INBR,INSD,INSD
*-------------------------------------------------------------------------*
*** Start Date Input...
INSD:     INP SD,16,4,10,'VD4/'
          IF F12 THEN GOTO FINISH
          IF ED='' THEN
             ED = SD
             PRINT @(16,5):OCONV(ED,'D4/')
          END
          ON MOVE+1 GOTO INSD,INSD,INBR,INSD,INED,INED
*-------------------------------------------------------------------------*
*** End Date Input...
INED:     INP ED,16,5,10,'VD4/'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INED,INED,INSD,INED,INSLCT,INSLCT
*-------------------------------------------------------------------------*
*** Selection Input for price/buy line, buy/sell group, etc.
INSLCT:   INP SLCT,16,6,20,V_'D:':SEL.LIST
          IF SLCT = 'Product Select Code' THEN
             PRINT @(3,7):'Slct Code  '
          END ELSE
             PRINT @(3,7):SLCT "L#11"
          END

          IF F12 THEN GOTO FINISH

          IF CHANGED THEN
             SLIST = ''
             PRINT @(17,7):SPACE(22)
          END

          SMV = 0
          IF SLCT THEN
             LOCATE SLCT IN SEL.LIST<1> SETTING SMV ELSE GOTO INSLCT
          END

          *** Go load our hotkeys...
          GOSUB LOAD.HKEYS

          ON MOVE+1 GOTO INSLCT,INSLCT,INED,INSLCT,INSLIST,INSLIST
*-------------------------------------------------------------------------*
*** If a selection has been made....
INSLIST:  IF SLCT # '' THEN
IN$$1:       INP TSLIST,16,7,22,SEL.CONV<1,SMV>,V_SEL.VALD<SMV>
             IF CHANGED THEN SLIST = TSLIST
          END ELSE
             SLIST = ''
          END
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INSLIST,INSLIST,INSLCT,INSLIST,INSORT,INSORT
*-------------------------------------------------------------------------*
*** Sort by option...
INSORT:   INP SORTBY,16,8,27,V_VALID.SORTBY
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INSORT,INSORT,INSLIST,INSORT,INBS,INBS
*-------------------------------------------------------------------------*
*** Specify the Customer Type you want to display data for
INBS:     INP LEVEL,26,9,7,V_'D:,Bill-To,Ship-To,Parent'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INBS,INBS,INSORT,INBS,INCOSTS,INCOSTS
*-------------------------------------------------------------------------*
*** Show Costs option...
INCOSTS:  INP COSTS,26,10,10,'YN'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INCOSTS,INCOSTS,INSORT,INCOSTS,INOPT,INOPT
*-------------------------------------------------------------------------*
*** Report detail level option...
INOPT:    INP OPT,26,11,10,V_'D:Summary':VM:'Detail'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INOPT,INOPT,INCOSTS,INOPT,INTYP,INTYP
*-------------------------------------------------------------------------*
*** Product Location Type Input...
INTYP:    INP TYP,26,12,10,V_VALID.LTYPS
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INTYP,INTYP,INOPT,INTYP,INNSTK,INNSTK
*-------------------------------------------------------------------------*
*** Inc/Exc/Only show Nonstocks option...
INNSTK:   INP NSTKS,32,13,7,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INNSTK,INNSTK,INTYP,INNSTK,INCRED,INCRED
*-------------------------------------------------------------------------*
*** Inc/Exc/Only show Credits option...
INCRED:   INP SEL.CREDS,32,14,7,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INCRED,INCRED,INNSTK,INCRED,INBID,INBID
*-------------------------------------------------------------------------*
*** Allow users to show bids on the report, only bids or not show them
INBID:    INP SEL.BID,32,15,10,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INBID,INBID,INCRED,INBID
*-------------------------------------------------------------------------*
*** Allow users to show open orders on the report, only open, or none
INOORD:   INP SEL.OORD,32,16,10,V_'D:Include':VM:'Exclude':VM:'Only'
          IF F12 THEN GOTO FINISH
          ON MOVE+1 GOTO INOORD,INOORD,INBID,INOORD,INOORD,INOORD
*-------------------------------------------------------------------------*
SUBS:     ON OPTION GOTO DOIT,DOIT,DOIT,FSEL,MULTI
*-------------------------------------------------------------------------*
*** Additional Select criteria Input window...
FSEL:     FILTER.INPUT "S",FITEM
          RETURN
*-------------------------------------------------------------------------*
MULTI:    * This is a window for inputting Multiple Selection

          BEGIN CASE
          CASE SLCT = 'Price Line'
             PHYS.PLINE.SELECT SLIST
          CASE SLCT = 'Buy Line'
             PHYS.BLINE.SELECT SLIST
          CASE OTHERWISE
             MTITLE = 'Multiple ':SLCT
IN$$3:       INP.MULTI SLIST,99,'L',SEL.VALD<SMV>,SEL.CONV<1,SMV>,MTITLE,FCODE<1,SMV>
          END CASE

          IF DCOUNT(SLIST,VM) > 1 THEN
             PSLIST = '*Multi*'
          END ELSE
             PSLIST = SLIST
          END

          PRINT @(16,7):PSLIST "L#22"

          RETURN
*-------------------------------------------------------------------------*
DOIT:     *** Validate the Inputs and then run the report...

          IF SD     = '' THEN REQ.FLDS<-1> = 'Start Date'
          IF ED     = '' THEN REQ.FLDS<-1> = 'End Date'
          IF SORTBY = '' THEN REQ.FLDS<-1> = 'Sort By'
          IF LEVEL  = '' THEN REQ.FLDS<-1> = 'Customer Level'
          IF OPT    = '' THEN REQ.FLDS<-1> = 'Detail/Summary'

          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> = 'Sort By'
                REQ.FLDS = ''
                RETURN TO INSORT
             CASE REQ.FLDS<1> = 'Customer Level'
                REQ.FLDS = ''
                RETURN TO INBS
             CASE REQ.FLDS<1> = 'Detail/Summary'
                REQ.FLDS = ''
                RETURN TO INOPT
             END CASE
          END

          IF NUM(SD) AND NUM(ED) THEN
             IF SD > ED THEN
                ERR.MESS 4,1,BELL:' Start Date must be before End Date'
                RETURN TO INSD
             END
          END

          IF OPTION < 3 THEN
             IF COSTS THEN
                PH.COST.AUTH.CHECK COST.TYPE

                IF F12 THEN RETURN

                IF COST.TYPE = '' THEN RETURN
             END ELSE
                COST.TYPE    = 3
             END
          END

          SEL.OPTS = SEL.BID:VM:SEL.OORD

          PH.EXE 'ORDERED.PHR.PROD.SUM',BRCHS,BR,SD,ED,TYP,SORTBY,COST.TYPE,OPT,NSTKS,FITEM,SEL.CREDS,LEVEL,SLCT,SLIST,SEL.OPTS

          IF F12 THEN RETURN

          RETURN TO FINISH
*-------------------------------------------------------------------------*
INIT:     *
*** Initialize variables and define selection lists
          DRPT$      = 'Prod Orders Report'
          SD         = ''
          ED         = ''
          BRCHS      = ''
          TYP        = ''
          COSTS      = YES
          SORTBY     = 'Customer'
          LEVEL      = 'Ship-To'
          OPT        = 'Detail'
          TERR.OK    = YES
          SEL.CREDS  = 'Include'
          FITEM      = ''
          NSTKS      = 'Include'
          REQ.FLDS   = ''
          SLCT       = ''
          SLIST      = ''
          SEL.BID    = 'Exclude'
          SEL.OORD   = 'Include'

*** Set up field validation lists...

          VALID.LTYPS  = 'D:,Stock,Over Shipment,Defective,Review,'
          VALID.LTYPS := 'Display,Tagged'

*** Switch to ',' format when the new INP routine is out to all Accounts...

          VALID.SORTBY  = 'D:,Customer,Product,Writer,In Salesperson,'
          VALID.SORTBY := 'Out Salesperson,In Salesperson by Customer,'
          VALID.SORTBY := 'Out Salesperson by Customer,Zip Code,'
          VALID.SORTBY := '3 Digit Zip,Select Code,Product Select Code,'
          VALID.SORTBY := 'Buy Line,Price Line,State,Branch,Customer PO#,'
          VALID.SORTBY := 'Buy Group,Sell Group'

          GOSUB LOAD.HKEYS

          SEL.LIST       = 'Price Line'
          SEL.VALD       = 'PRICE.LINE'
          SEL.CONV       = ''
          FCODE          = ''

          SEL.LIST<1,2>  = 'Sell Group'
          SEL.VALD<2>    = 'PRICE-GRP,1'

          SEL.LIST<1,3>  = 'Buy Line'
          SEL.VALD<3>    = 'BUY.LINE'

          SEL.LIST<1,4>  = 'Buy Group'
          SEL.VALD<4>    = 'PRICE-GRP,1'

          SEL.LIST<1,5>  = 'Product'
          SEL.VALD<5>    = 'S:VERF.PRD.ID'
          SEL.CONV<1,5>  = 'TPRODUCT;X;1;1'
          FCODE<1,5>     = 'PNLIST'

          SEL.LIST<1,6> = 'Product Select Code'
          SEL.VALD<6>   = 'C:VALID.PRD.SELECT'
          FCODE<1,6>    = 'SCD'

          RETURN
*-------------------------------------------------------------------------*
LOAD.HKEYS: *
          MENU.CLEAR
          MENU.LOAD  2,18, 5, 1,'P'
          MENU.LOAD 10,18, 4, 1,'H'
          MENU.LOAD 17,18, 4, 1,'O'
          MENU.LOAD 24,18, 4, 1,'S'
          IF SLCT THEN
             MENU.LOAD 31,18,11,1,'M'
          END ELSE
             MENU.LOAD ,,,,
          END

          RETURN
*-------------------------------------------------------------------------*
*** Close our window and exit the program...
FINISH:   WINDOW.CLOSE
          RETURN
*-------------------------------------------------------------------------*
!SMITJR~07/16/10~09:38
