<%!

/**********************************************************************
**
**     SAP AG Walldorf
**     (C) Copyright SAP AG 1999-2008
**
***********************************************************************/

#include "publicincl/tools.inc"

struct wdisp_url_type
{
  string	prefix;
  string	virt_host;
  string	logon_group;
  string	stack;

  int		flags;
};
%>

<%
  int i, nr, url_count, dir, max;
  string browser, sstr, systemID, systemID_show;
  struct wdisp_url_type wdisp_url_map[];
  struct icm_sort_type sort_tab[];

  const string ssort = "../public/images/sort.gif";
  const string sasc = "../public/images/sortasc.gif";
  const string sdesc = "../public/images/sortdesc.gif";

  sort_tab[0].header = "URL Prefix";
  sort_tab[0].tool = "Sort by URL prefix";
  sort_tab[0].ffield = "prefix";
  sort_tab[1].header = "Logon Group";
  sort_tab[1].tool = "Sort by Logon Group";
  sort_tab[1].ffield = "logon_group";
  sort_tab[2].header = "Virtual Host";
  sort_tab[2].tool = "Sort by virtual host";
  sort_tab[2].ffield = "virt_host";
  sort_tab[3].header = "Stack";
  sort_tab[3].tool = "Sort by Application Server Stack";
  sort_tab[3].ffield = "stack";
  max = arraylen(sort_tab);
  for (i=0; i < max; i++){
   sort_tab[i].url = ssort;
   sort_tab[i].dir = 0;
  }

  browser = __icm_get_browser_type();
  systemID = htmlenc(__icm_get_form_field ("systemID"));
  if (systemID != "000") {
      systemID_show = "&nbsp;(" + systemID + ")";
  }
  url_count = __wdisp_get_url_map (wdisp_url_map, systemID);

  dir  = __icm_get_form_field ("dir");
  sstr = __icm_get_form_field ("sstr");
  
  if (sstr != "")
    sort (wdisp_url_map, dir, sstr);

  for (i=0; i < max; i++){
   if (sstr == sort_tab[i].ffield){
    if (dir == 1) { sort_tab[i].url = sdesc; sort_tab[i].dir = -1; }
    else if (dir == -1) { sort_tab[i].url = sasc; sort_tab[i].dir = 1; }
    else sort_tab[i].dir = 1;
   }
   else sort_tab[i].dir = 1;
  }
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <link rel=stylesheet type="text/css" href="../public/css/controls_<%=browser%>.css">
    <link rel=stylesheet type="text/css" href="../public/css/sapbsp.css">
    <title>URL Map</title>
    <script type="text/javascript">
      <!--
      function callSubmitAction(dir,sstr)
      {
        document.sortForm.dir.value = dir;
        document.sortForm.sstr.value = sstr;
        document.sortForm.submit();
      }
    </script>
  </head>
  <body class="sapBdy">
   <form action="" name="sortForm" method="GET">
   <input type="hidden" name="dir" value="">
   <input type="hidden" name="sstr" value="">
    <table border=0 cellspacing=1 cellpadding=0 class="sapTbvAlt" width="100%">
      <tr>
        <td class="sapTbvCellAlt" colspan="4"><i><b>Known URL Prefixes<%=systemID_show%></b></i></td>
        <td class="sapTbvCellAlt" align="right">
        <a href="javascript:parent.frames['main'].location.reload()" class="sapBtnEmph" title="refresh page"><nobr>Refresh</nobr></a>
        </td>
      </tr>
      <tr>
        <th align="left" class="sapTbvCellAlt">&nbsp;</th>
<%
        max = arraylen(sort_tab);
	for (i=0;i < max; i++) {
%>
	  <th align="left" class="sapTbvCellAlt"><nobr>
	    <i><%=sort_tab[i].header%></i>
	    <a href="javascript:callSubmitAction('<%=sort_tab[i].dir%>','<%=sort_tab[i].ffield%>')" class="sapBtnStd:link"><img src="<%=sort_tab[i].url%>" title="<%=sort_tab[i].tool%>" alt="" border="0"></a></nobr>
	  </th>
<%
	}
%>
      </tr>

<%
for (nr = 0; nr < url_count; nr++) {
%>
      <tr>
        <td class="sapTbvCellStd"><%=nr%></td>
        <td class="sapTbvCellStd"><%= wdisp_url_map[nr].prefix %></td>
        <td class="sapTbvCellStd"><%= wdisp_url_map[nr].logon_group %></td>
        <td class="sapTbvCellStd"><%= wdisp_url_map[nr].virt_host %></td>
        <td class="sapTbvCellStd"><%= wdisp_url_map[nr].stack %></td>
      </tr>
<%
}
%>
    </table>
   </form>
  </body>
</html>