: bin/sh ################################################################# # gett21ovh # batch file for finding overheads # CUSTOMDESC # CUSTOMDEF progname=$0 SDATE=$1; EDATE=$2; STIME=$3; ETIME=$4 SDATE="01/01/2002" EDATE="30/04/2005" #SITEID="101" SITEID="ALL" if [ -n "$5" ]; then SITEID=$5 fi echo "SDATE=$SDATE" echo "EDATE=$EDATE" echo "STIME=$STIME" echo "ETIME=$ETIME" echo "SITEID=$SITEID" if [ -n "$6" ]; then OVHDOTYPE=$6 else OVHDOTYPE="ALL" fi ################################################################# lastdayinmonth() # Returns the last day in month, Inputs: $1=mm $2=yyyy { cal $1 $2 | awk '{ if ( NF > 0 ) x=$NF } END { print x }' } ################################################################# # MAIN OUTFILE="ovh.in" rm -f $OUTFILE TMPSTABLE="ovh_$LOGNAME" tmpfile=/tmp/ovh_$$ tmpfile0=/tmp/ovh0_$$ tmpfile1=/tmp/ovh1_$$ rm -f $tmpfile rm -f $tmpfile0 if [ -z "$SITEID" ]; then echo "Enter siteid (Enter for ALL):\c"; read SITEID fi if [ -z "$SITEID" ]; then SITEID="ALL" fi if [ -z "$SDATE" ]; then echo "Enter start date:\c"; read SDATE fi if [ -z "$EDATE" ]; then echo "Enter end date:\c"; read EDATE fi ######## #if [ -z "$STIME" ]; then # echo "Enter start time:\c"; read STIME #fi #if [ -z "$ETIME" ]; then # echo "Enter end time:\c"; read ETIME #fi if [ "$SITEID" = "ALL" ]; then SITEBIT="" else SITEBIT="and site.siteid = $SITEID" fi ############################################### runisql <&1 unload to $tmpfile0 select unique tes.ggrid, tes.siteid, tes.egrid, tes.extn, tes.hdate from $TMPSTABLE tes order by 1,2,3,4,5; SQLCMD4 ##---------------------------------------------------------------- # get periods for each extension awk -F '|' -f gett21ovhpre.awk <$tmpfile0 >$tmpfile1 ##---------------------------------------------------------------- # process overheads doovh() { ovhdotype="$1" awk -F '|' -f gett21ovh.awk \ -v "outfile=$OUTFILE" \ -v "ovhdotype=$ovhdotype" \ -v "sdate=$SDATE" -v "edate=$EDATE" \ <$tmpfile1 } if [ "$OVHDOTYPE" = "ALL" ]; then ## get Overhead costs #doovh "O" ### get Equipment costs #doovh "E" ## get Miscellaneous costs doovh "M" ### get GST costs #doovh "G" else doovh "$OVHDOTYPE" fi ##---------------------------------------------------------------- ############################################### #cat $tmpfile | pr_rep system ovh_ #cp $tmpfile0 0 #cp $tmpfile1 1 rm -f $tmpfile rm -f $tmpfile0 rm -f $tmpfile1 exit 0