#!/usr/bin/ksh

# ***********************************************************************************
#  Platform:      Unix - AIX / SUN / HP / Linux                                     *
#  Printstream:   PDF                                                               *
#  Application:   SPL Bill Print                                                    *
# ==================================================================================*
#  Master Command File called to execute integrated Sort, DOC1 Generate and PCE,    *
#  Code-1 Plus, MailStream Plus, and Print Files for SPL Bill Print                 *
# ==================================================================================*

# ***********************************************************************************
#    Command Line Position Parameters for "Display Bill"                            *
# ==================================================================================*
#      $1      - Bill Id                                                            *
#      $2      - ?                                                                  *
#      $3      - Userid of CSR requesting Bill                                      *
#      $4      - Path Containing DOC1 Executables (see $D1HOST below)               *
#      $5      - Path Containing Bill Print Extract (see $XTRCTPTH below)           *
#      $6      - Path where PDF and Log are to be placed after DOC1GEN executes     *
# ==================================================================================*

# do not change the following line
export SPLBILL_CALLED_SWITCH='Y'                                                          
# ***********************************************************************************
#    Modify the following file paths for each installation environment              *
# ==================================================================================*
#      G1MSP                                                                        *
#              - Names root directory where MailStream Plus was installed           *
#              - Typical value:                                                     *
#                G1MSP=/group1/msn                                                  *
#      ** MAILSTREAM NOTE**                                                         *
#                A number of variables are explicitly set to installation site      *
#                specific paths and file names in the file                          *
#                splbill_s5_v3_called_mstream_setup.sh                              *
#                After installing Code-1 at your site, update that setup file to    *
#                reflect the site specific values using "setup" from the MailStream *
#                directory as a reference point.                                    *
#      G1MSPDB                                                                      *
#              - Names root directory MailStream postal databases                   *
#              - NOTE:  must be a different directory from G1C1PDB !!!              *
#              - Typical value:                                                     *
#                G1MSPDB=/group1/msn/db                                             *
#      G1C1P                                                                        *
#              - Names root directory where Code-1 Plus was installed               *
#              - Typical value:                                                     *
#                G1C1P=/group1/c1p                                                  *
#      ** CODE-1 NOTE**                                                             *
#                A number of variables are explicitly set to installation site      *
#                specific paths and file names in the file                          *
#                splbill_s5_v3_called_code1_setup.sh                                *
#                After installing Code-1 at your site, update that setup file to    *
#                reflect the site specific values, using "setup" from the Code-1    *
#                directory as a reference point.                                    *
#      G1C1PDB                                                                      *
#              - Names root directory Code-1 postal databases                       *
#              - NOTE:  must be a different directory from G1MSPDB !!!              *
#              - Typical value:                                                     *
#                G1C1PDB=/group1/c1p/db                                             *
#      D1HOST                                                                       *
#              - Names root directory where the DOC1 Generate was installed         *
#              - Typical value:                                                     *
#                D1HOST=/group1/doc1/productionengines                              *
#      D1APPATH                                                                     *
#              - Names directory containing HIP, INI, CTL, OPS, ETS                 *
#              - Sample coding:                                                     *
#                D1APPATH=/group1/doc1/application/bill                             *
#      PRODPATH                                                                     *
#              - Names directory for output files from Sort and DOC1;               *
#              - Sample coding: PRODPATH=/prod/doc1/files                           *
#      XTRCTPTH                                                                     *
#              - Names directory containing SPL Bill Print Extract                  *
#              - Sample coding: XTRCTPTH=/spl/extract                               *
# ***********************************************************************************

export G1MSP=$1/msn
export G1MSPDB=$1/msn/db
export G1C1P=$1/c1p
export G1C1PDB=$1/c1p/db
export D1HOST=$4
export D1APPATH=$2
export PRODPATH=$SPLEBASE/splapp/billView 
export XTRCTPTH=$5

# ***********************************************************************************
#    The following switches which enable certain steps to be bypassed               *
# ==================================================================================*
#      PRINTFILES                                                                   *
#              - May be:  Y or N                                                    *
#              - "N" prevents files from being copied into InfoPrint Hotfolders     *
#      RUN_TYPE                                                                     *
#              - Indicates that this execution is for batch billing rather than     *
#                online billing;                                                    *
#              - Acceptable values are BATCH and ONLINE; use BATCH for Batch Bill   *
#                Print (ONLINE is for SPL-invoked "Display Bill" button)            *
#              - value of RUN_TYPE=BATCH enables all steps within the called Unix   *
#                shell script to be run                                             *
#      CODE1                                                                        *
#              - May be:  Y or N                                                    *
#              - "N" allows Code-1 Plus to be bypassed                              *
#      MSTREAM                                                                      *
#              - May be:  Y or N                                                    *
#              - "N" allows MailStream Plus to be bypassed                          *
#      DELETEFILES                                                                  *
#              - May be:  Y or N                                                    *
#              - "N" prevents intSPLediate work files from being deleted            *
# ***********************************************************************************

export PRINTFILES='N'
export RUN_TYPE='ONLINE'
export CODE1='N'
export MSTREAM='N'                                                                      
export DELETEFILES='Y'

# ***********************************************************************************
#    The following symbols are used for controls                                    *
# ==================================================================================*
#      PSTREAM                                                                      *
#              - Identifies the type of print description language for output       *
#              - Possible values are AFP, PDF or PostScript                         *
#      PRES                                                                         *
#              - Indicates the resolution for the printer                           *
#              - For PDF, this must be 72                                           *
#      PRINT                                                                        *
#              - File Extension of print files created                              *
#              - Possible values are AFP, PDF, or PS                                *
# ***********************************************************************************

export PSTREAM='PDF'                                                                    
export PRES='72'                                                                        
export PRINT='PS'                                                                       

# ***********************************************************************************
#    The symbols identify application resource files for DOC1.  These values of the *
#    file names should not be changed unless the files are renamed or replaced.     *
# ==================================================================================*
#   L O G F I L E                                                                   *
#   =============                                                                   *
#      LOGFILE                                                                      *
#              - Name of a log file to be created by this process                   *
#              - Previous version of file will be replaced                          *
#              - File will be written to $PRODPATH directory                        *
#              - Sample coding:  LOGFILE=spl-bill.log                               *
#                                                                                   *
#    D O C 1   R E S O U R C E   F I L E S                                          *
#    =====================================                                          *
#      GEN_OPS                                                                      *
#              - Names DOC1 Generate Initialization file for Format Bills           *
#              - Sample value: GEN_OPS=splbill_s5_v3_doc1gen.ops                    *
#              - File must be present in the $D1APPATH directory                    *
#      GEN_HIP                                                                      *
#              - Name of DOC1 Generate Application Rules (.HIP)                     *
#              - Sample value: GEN_HIP=splbill_s5_v3_doc1gen_pdf.hip                *
#              - File must be present in the $D1APPATH directory                    *
#      GEN_ETS                                                                      *
#              - Names Look-Up file using Country Codes to produce Country Names    *
#              - Sample value: GEN_ETS=splbill_s5_v3_doc1gen.ets                    *
#              - File must be present in the $D1APPATH directory                    *
#      GEN_CNTL                                                                     *
#              - Names Look-Up file with controls distinguishing ONLINE vs. BATCH   *
#              - Sample value: GEN_CNTL=splbill_s5_v3_doc1gen_control_pdf.ets       *
#              - File must be present in the $D1APPATH directory                    *
#      FRGN_PCE_INI                                                                 *
#              - Names DOC1PCE Initialization file for Foreign step                 *
#              - Sample value: FRGN_PCE_INI=splbill_s5_v3_frgnsplt_pce.ini          *
#              - File must be present in the $D1APPATH directory                    *
#      FRGN_PCE_CTL                                                                 *
#              - Names DOC1PCE Rules file for Foreign step                          *
#              - Sample value: FRGN_PCE_CTL=splbill_s5_v3_frgnsplt_pce.ctl          *
#              - File must be present in the $D1APPATH directory                    *
#      SPCL_PCE_INI                                                                 *
#              - Names DOC1PCE Initialization file for Special Handling step        *
#              - Sample value: SPCL_PCE_INI=splbill_s5_v3_spcsplt_pce.ini           *
#              - File must be present in the $D1APPATH directory                    *
#      SPCL_PCE_CTL                                                                 *
#              - Names DOC1PCE Rules file for Special Handling step                 *
#              - Sample value: SPCL_PCE_CTL=splbill_s5_v3_spcsplt_pce.ctl           *
#              - File must be present in the $D1APPATH directory                    *
#      CPRT_PCE_INI                                                                 *
#              - Names DOC1PCE Initialization file for Create Print step            *
#              - Sample value: CPRT_PCE_INI=splbill_s5_v3_createprt_pce.ini         *
#              - File must be present in the $D1APPATH directory                    *
#      CPRT_PCE_CTL                                                                 *
#              - Names DOC1PCE Rules file for Create Print step                     *
#              - Sample value: CPRT_PCE_CTL=splbill_s5_v3_createprt_pce.ctl         *
#              - File must be present in the $D1APPATH directory                    *
#      MAXAUTO                                                                      *
#              - Identifies the maximum number of sheets that a Bill may            *
#                contain and still be considered an Automated Bill; if a Bill       *
#                has more sheets than the MAXAUTO value, the Bill will be           *
#                classified as an Oversized Bill                                    *
#              - Sample value: MAXAUTO=6                                            *
#                                                                                   *
#    S P L   B I L L   P R I N T   F I L E                                          *
#    =====================================                                          *
#      SPL_UNSORTED_EXTRACT                                                         *
#              - Names SPL Bill Print Extract                                       *
#              - Typical coding SPL_UNSORTED_EXTRACT=bpxtr01.dat                    *
#                                                                                   *
#    C O D E - 1   /   M A I L S T R E A M   P A R A M E T E R S                    *
#    ===========================================================                    *
#      C1PRM                                                                        *
#              - Names Code-1 Parameters file                                       *
#              - Sample value: C1PRM=splbill_s5_v3_code1.prm                        *
#              - File must be present in the $C1P/data directory                    *
#      MSPRM                                                                        *
#              - Names MailStream Parameters file                                   *
#              - Sample value: MSPRM=splbill_s5_v3_mstream.prm                      *
#              - File must be present in the $MSP/data directory                    *
# ***********************************************************************************

export LOGFILE=$3_$1.log                                                          
#DGS export LOGFILE=$6/$3_$1_$2.log                                                          
export GEN_OPS=splbill_s5_v3_doc1gen.ops;
export GEN_HIP=splbill_s5_v3_doc1gen_pdf.hip
export GEN_ETS=splbill_s5_v3_doc1gen.ets
export GEN_CNTL=splbill_s5_v3_doc1gen_control_pdf.ets
export LOGOXML=splbill_s5_v3_doc1gen_logo.xml
export FRGN_PCE_INI=splbill_s5_v3_frgnsplt_pce.ini
export FRGN_PCE_CTL=splbill_s5_v3_frgnsplt_pce.ctl
export SPCL_PCE_INI=splbill_s5_v3_spcsplt_pce.ini
export SPCL_PCE_CTL=splbill_s5_v3_spcsplt_pce.ctl
export CPRT_PCE_INI=splbill_s5_v3_createprt_pce.ini
export CPRT_PCE_CTL=splbill_s5_v3_createprt_pce.ctl
export MAXAUTO=12 

export C1PRM=splbill_s5_v3_code1.prm
export MSPRM=splbill_s5_v3_mstream.prm

export SPL_UNSORTED_EXTRACT=$3.$1.DAT
export ONLINE_PDF=$6/$3.$1.PDF

rm -f $PRODPATH/$LOGFILE
$D1APPATH/splbill_s5_v3_called_jobsteps.sh
