bcost=./tmp/bcost
date=`date +%d/%m/%Y`
awk -F= '
FILENAME==ARGV[1] {cost[$1]=$2;next}
/cotizH00/ { print "H02"$2 }
/cotizH01/ { print "H03"$2 }
/cotizH03/ { print "H04"$2"\r" }
/cotizH05/ { print "H05"$2"\r" }
/cotizH13/ { print "H09"$2 }
/cotizD/ { cot[$1]=$2 ; rg=substr($1,7,2) +0 }
END {
print "H01'"$date"'"
print "H1100"
rg++

for (i=0;i<rg;i++)
{
	reg=sprintf("cotizD%.2d",i)
	if(cot[reg"09"]==1)
	{
		x=sprintf("D%.2d",f++)
		printf "%s00%.2d\n",x,i+1
		printf "%s01%s\n",x,cot[reg"01"]
		printf "%s03%s\n",x,cot[reg"03"]
		printf "%s04%s\n",x,cot[reg"05"]
		printf "%s05%s\n",x,cot[reg"07"]
		printf "%s06%s\n",x,cost[cot[reg"00"]"^B"]
		printf "%s07%s\n",x,cost[cot[reg"00"]"^G"]
		printf "%s08%s\n",x,cost[cot[reg"00"]"^M"]
		printf "%s09%s\n",x,cost[cot[reg"00"]"^P"]
	}
}
print " "
} ' $bcost $1 > $1.W
awk ' { print $0"<br>" } ' $1.W
x=`./ihd/bin/ihmu wrkor $1.W -N1`
rm $1.W
ihdm wrkor h11"^" h02"^" h00"^" h01^ | awk -F"^" ' BEGIN { printf "var otinfo=new Array()\n" }
function trail(txt) { while (substr(txt,length(txt),1)==" ") txt=substr(txt,1,length(txt)-1); return (txt) }
$1=="99" { next } 
ant==$2 {next}
{ ant=$2 }
{ ot[$2]=ot[$2]$3" - "$4"\\r" }
END {
for(i in ot)
printf "otinfo[\"%s\"]=\"%s\"\n",i,ot[i]
}
' - >../js/otinfo.js
./wrkorget.cgi $x
