#!/bin/sh
# disable filename globbing
set -f
echo Content-type: text/html
echo

BASE=`pwd`
APPLDIR=$BASE/appl
DATADIR=$BASE/data
PATH=$PATH:$BASE/ihd/bin:.
export PATH APPLDIR DATADIR
ZONA=`./appl/sh/usuar|awk -v a=$REMOTE_USER -F"^" 'index($3,a){print substr($4,1,3);exit}' -`
NIV=`./appl/sh/usuar|awk -v a=$REMOTE_USER -F"^" 'index($3,a){print $10;exit}' -`
#echo  RU=$REMOTE_USER Z=$ZONA N=$NIV
awk ' BEGIN {
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\">"
if("'"$NIV"'"=="") dir="Full"
else if("'"$NIV"'"+0==0) dir="Full"
if("'"$NIV"'"+0==1) dir="VentayDespacho"
if("'"$NIV"'"+0==2) dir="Produccion"
if("'"$NIV"'"+0==3) dir="Vendedores"
#printf "USUARIO=%s  NIVEL=:%s: DIR=%s\n","'"$REMOTE_USER"'","'"$NIV"'",dir
if(dir!="") printf "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=../%s\">\n",dir
else printf "<META HTTP-EQUIV=\"refresh\" content=\"0;URL=google.com\">\n"
print "</head>"
print "</body>"
print "</head>"
} '

