#!/bin/sh
loop_msg()
{
$G1ECHO "\n\tThe environment variables for the product you selected were not found."
$G1ECHO "\tCheck the "$G1PROD" variables in the setup script and re-source setup."
$G1ECHO "\n\tAlso check that "$g1area"/"$g1script" is installed."
$G1ECHO "\n\tTerminating database installation.\n"
}
#================================================================
# GeoTAX Database Load
#================================================================
geotax()
{
$G1ECHO "\n"
$G1ECHO " "
$G1ECHO "\tGeoTAX Product Menu"
$G1ECHO "\tProduct Database/Reference Installation"
$G1ECHO "\t                              "
$G1ECHO "\t1.  GeoTAX Master Files"
$G1ECHO "\t2.  User Auxiliary File"
$G1ECHO "\t3.  GeoTAX Auxiliary File"
$G1ECHO "\t4.  Landmark Auxiliary File"
$G1ECHO "\t5.  State Supplied Master File (Florida Format)"
$G1ECHO "\t6.  State Supplied Master File (TS-158 Format)"
$G1ECHO "\t7.  Boundary File"
$G1ECHO "\t8.  PB Software Tax Rate File"
$G1ECHO "\t9.  Payroll Tax Correspondence File"
$G1ECHO "\t10. Sovos Cross Reference File"
$G1ECHO "\t11. PB Software Vertex Cross Reference File"

$G1ECHO "\t                               "
$G1ECHO "\t99. Exit"
$G1ECHO "\n"
$G1ECHO "\tEnter the number of the type of data you want to load "
$G1ECHO "\tand then press enter:  \c"
read geoin
case $geoin in
	1)
               	G1PRINF=" GeoTAX Master Files" ; export G1PRINF
                if test -f $G1GTX/bin/gtxlddb
                then
                        $G1GTX/bin/gtxlddb
                else
                        g1script=gtxxlddb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
 	2)
               	G1PRINF=" User Auxiliary File" ; export G1PRINF
                if test -f $G1GTX/bin/setauxdb
                then
                        $G1GTX/bin/setauxdb
                        $G1GTX/bin/auxlddb
                else
                        g1script=setauxdb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
	3)
                G1PRINF=" GeoTAX Auxiliary File" ; export G1PRINF
                if test -f $G1GTX/bin/setauxdb2
                then
                        $G1GTX/bin/setauxdb2
			                  $G1GTX/bin/auxlddb2
                else
                        g1script=setauxdb2
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
  4)
                G1PRINF=" Landmark Boundary File" ; export G1PRINF
		            if test -f $G1GTX/bin/lmlddb
                then
                        $G1GTX/bin/lmlddb
                else
                        g1script=lmlddb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
  5)
                G1PRINF=" GeoTAX State Supplied (Florida Format)" ; export G1PRINF
	              if test -f $G1GTX/bin/setstsuppdb
                then
                        $G1GTX/bin/setstsuppdb
                        $G1GTX/bin/stsupplddb
                else
                        g1script=setstsuppdb
                        g1area=$G1GTX/bin
			                  loop_msg
                fi
        ;;
  6)
                G1PRINF=" GeoTAX State Supplied (TS-158 Format)" ; export G1PRINF
	              if test -f $G1GTX/bin/setstts158db
                then
                        $G1GTX/bin/setstts158db
                        $G1GTX/bin/stts158lddb
                else
                        g1script=setstts158db
                        g1area=$G1GTX/bin
		            	      loop_msg
                fi
        ;;
  7)
                G1PRINF=" GeoTAX Boundary File" ; export G1PRINF
		            if test -f $G1GTX/bin/bflddb
                then
                        $G1GTX/bin/bflddb
                else
                        g1script=bflddb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
  8)
                G1PRINF=" Pitney Bowes Software Tax Rate File" ; export G1PRINF
                if test -f $G1GTX/bin/setrtedb
                then
                        $G1GTX/bin/setrtedb
                        $G1GTX/bin/rtelddb
                else
                        g1script=setrtedb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;; 
	9)
                G1PRINF=" Payroll Tax Correspondence File" ; export G1PRINF
                if test -f $G1GTX/bin/setpaydb
                then
                        $G1GTX/bin/setpaydb
                        $G1GTX/bin/paytaxdb
                else
                        g1script=setpaydb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
  10)
                G1PRINF=" Sovos Cross Reference File" ; export G1PRINF
                if test -f $G1GTX/bin/setsovdb
                then
                        $G1GTX/bin/setsovdb
                        $G1GTX/bin/sovlddb
                else
                        g1script=setsovdb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
  11)
               	G1PRINF=" PB Software Vertex Cross Reference File"; export G1PRINF
                if test -f $G1GTX/bin/setvtxdb
                then
                        $G1GTX/bin/setvtxdb
                        $G1GTX/bin/vtx9lddb
                else
                        g1script=setvtxdb
                        g1area=$G1GTX/bin
                        loop_msg
                fi
        ;;
	99)
        	$G1ECHO "\n\tUser requested termination."
        	exit
        ;;
	*)    
        	$G1ECHO "\n\tInvalid option. Try again."
        	$G1ECHO "\tPress enter to continue. \c"
        	read xxx
		geoin=
        	geotax;
        ;;     
esac
}
geotax;
