#!/bin/sh

# disable filename globbing

 echo Content-type: text/html
 echo
 BASE=`pwd`
{
APPLDIR=$BASE/appl
DATADIR=$BASE/data
PATH=$PATH:$BASE/ihd/bin:.
export PATH APPLDIR DATADIR
DESD=09/08/2009
HAST=10/08/2009
RESU=""
CLIE=
t=/tmp/tt
splash> $t
DESD=`awk -F= ' $1=="T1" { print $2 } ' $t `
HAST=`awk -F= ' $1=="T2" { print $2 } ' $t `
CLIE=`awk -F= ' $1=="T3" { print $2 } ' $t `
RESU=`awk -F= ' $1=="T4" { print $2 } ' $t `
cliok=./tmp/cliok
venta=/tmp/venta
ihdm cliok h00"^" h01"^" h02"^" h03"^" h04"^" h05"^" h06 | awk -F"^" ' FILENAME == ARGV[1] { x[$1]=1 ; next } 
x[$1]==1 ' $venta - > $cliok
awk ' { print $0"<br>" } ' $venta
awk ' { print $0"<br>" } ' $cliok
awk -F"^" ' {
g[$1]=g[$1]$6"("substr($4,1,5)")/"
vp[$1] +=$14
kt[$1]+=$13
for (i=7;i<13;i++) vk[$1""(i-7)]+=$i
}
END {
for (z in g) if (index(z,"PULLM")==0) {
printf "%s^",z
for (i=0;i<6;i++) printf "%d^%.2f^",vk[z""i],vp[z]*vk[z""i]/kt[z]
printf "%.0f^%s\n",vp[z],g[z]
}
} ' $venta >"."$venta.fac
awk ' { print $0"<br>" } ' "."$venta.fac

} 2>./error/fact0.err
