awk -F= 'BEGIN { 
T["00"]="CODIGO"
T["01"]="CLASIFICACION"
T["02"]="DESCRIPCION"
T["03"]="D/H/A"
T["04"]="ANALISIS"
T["05"]="C.COSTO"
T["06"]="PERIODO"
T["07"]="DEBITOS"
T["08"]="CREDITOS"
T["09"]="SALDOS"
T["10"]="ACUMULADO"
	printf "%s^",T["00"]
}
$2!="" && $1!="B1" && substr($1,length($1)-1)!="00" {
	x=substr($1,length($1)-1)
	printf "%s^",T[x]
}
END {
	print ""
} ' $1 |
 awk -F"^" ' BEGIN {ttop("Consulta de Datos");bgcolor="#FFFFFF"}
NR==1 { for (i=1; i<NF; i++) labels($i)
print "</tr>"
next
}
{ for (i=1; i<NF; i++)if (i==1) boton($i)
else label($i)
print "</tr>"
if (NR%2==0 ) bgcolor="#E1E1E1"
else bgcolor="#FFFFFF"
}
END { foot() } 
function boton(value)
{
	print "<td bgcolor=\"#E1E1E1\">"
printf "<p><input type=\"submit\" style=\"width: 120\" value=\"%s\" name=\"T02\"></p>\n",value
print "</td>"
}
function label(value)
{
printf "<td bgcolor=\"%s\">",bgcolor
printf "<p align=\"center\"><font face=\"Arial\" size=\"3\">&nbsp;%s&nbsp;</font></p>\n",value
print "</td>"
}
function labels(value)
{
print "<td bordercolor=\"#C0C0C0\" bgcolor=\"#003399\" align=\"center\">"
printf "<p align=\"center\"><b><font color=\"#FFFFFF\">%s</font></b></p>\n",value
print "</td>"
}
function ttop(value)
{
print "<html>"
print "<head>"
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=windows-1252\">"
print "<meta name=\"GENERATOR\" content=\"Inhedo 4gt 1.0\">"
print "<meta name=\"ProgId\" content=\"Inhedo Form Generator\">"
printf "<title>%s</title>\n",value
print "</head>"
print "<center>"
print "<body bgcolor=\"#D0D0DF\">"
print "<p align=\"center\"><img border=\"0\" src=\"../logol.jpg\" width=\"200\" height=\"97\"></p>"
printf "<H1>CUENTAS</H1>\n"
print "<form method=\"post\" action=\"../cgi-bin/plancbsc.cgi\" name=billform>"
print "<center>"
print "<table border=\"1\" cellspacing=\"0\" cellpadding=\"0\" bordercolor=\"#999999\" height=\"50\">"
printf "<input type=\"hidden\" value=\"Query\" name=\"B1\">\n"
print "<tr>"
print "</center>"
}
function foot()
{
print "</table>"
print "</center>"
print "</form>"
print "</body>"
print "</html>"
} ' - $2
awk ' BEGIN {
print "</body>"
print "</form>"
print "<form method=\"GET\" action=\"../planc.htm\">"
printf "<p align=\"center\"><input type=\"submit\" value=\"Continuar\" name=\"B1\" style=\"width: 200; height: 50; font-weight: bold; font-size: 18pt\"></p>\n"
print "</form>"
print "</body>"
print "</html>"
exit } ' - $2
