<%!
struct server_spec_type
{
  int    max_conn;
  int    cur_conn;
  int    peak_conn;
};
struct server_spec_stack
{
  int    req_no_total_stateless;
  int    req_no_total_group;
  int    req_no_total_stateful;

  int    req_no_act_stateless;
  int    req_no_act_group;
  int    req_no_act_stateful;
  string req_no_timesection[16];
  string req_per_min_stateless[16];
  string req_per_min_group[16];
  string req_per_min_stateful[16];

  int    resp_time_last;
  int    resp_time_avg;
  int    resp_time_min;
  int    ping_time_last;

  boolean operational;
  boolean valid;
  boolean active;
  boolean responding;

  int    capacity;
  boolean capacity_is_fixed;
  int    load;
  int    load_static;

  string error_text;
};
struct wdisp_host_info_type
{
  string name;
  string host_name;
  string http_port;
  string https_port;

  boolean has_abap;
  boolean has_j2ee;

  struct server_spec_stack stack[2];

  struct server_spec_type http;
  struct server_spec_type https;
};
struct wdisp_group_info_type
{
  string name;
  string pref_server;
  string last_server;
  string next_server;
  int    no_server;
};
struct wdisp_url_type
{
  string	prefix;
  string	virt_host;
  string	logon_group;
  string	stack;

  int		flags;
};
%>

<%
  int host_count, group_count, url_count, nr;
  int tabsel;
  string what, browser, group, str, cap, systemID, systemID_show;
  struct wdisp_host_info_type wdisp_host_info[];
  struct wdisp_group_info_type wdisp_group_info[];
  struct wdisp_url_type wdisp_url_map[];

  systemID = __icm_get_form_field ("systemID");
  if (systemID != "000") {
      systemID_show = "&nbsp;(" + systemID + ")";
  }
  group_count = __wdisp_get_groups (wdisp_group_info, systemID);
  
  tabsel = __icm_get_form_field ("tabsel");
  if ((tabsel < 0) || (tabsel > group_count))
    tabsel = 0;

  browser = __icm_get_browser_type();
  what = anumenc(__icm_get_form_field ("what"));
  group = wdisp_group_info[tabsel].name;
  host_count = __wdisp_get_host_info (group, wdisp_host_info, systemID);
  url_count = __wdisp_get_url_map (wdisp_url_map, systemID, group);

%>
<!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> Table test </title>
	<script type="text/javascript" src="../public/js/bspMenu.js"></script>
	<script type="text/javascript">
	<!--
        window.onload = function() {
<%
    for (nr = 0; nr < host_count; nr++) {
%>
          initializeMenu ("GroupDetailMenuABAP<%=nr%>", "groupDetailObjABAP<%=nr%>");
          initializeMenu ("GroupDetailMenuJava<%=nr%>", "groupDetailObjJava<%=nr%>");
<%
    }
%>
        }
	document.onclick=bspMenuHide;

	function preview(wintype)
	{
	  popUp = window.open(wintype, 'Preview', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=400,height=300,left=22,top=22');
	  popUp.focus();
	}
	function callSubmitAction(form,value,wval,systemID)
	{
	  var Form = document[form];
	  Form.tabsel.value = value;
	  Form.what.value = wval;
	  Form.systemID.value = systemID;
	  Form.submit();
	}
	//-->
    </script>
    </head>
    <body class="sapBdy">
<%
    for (nr = 0; nr < host_count; nr++) {
%>
      <div id="GroupDetailMenuABAP<%=nr%>" style="width:180;background-color:#ffffc8" class="bspMenuBox" onMouseover="bspMenuHighlight(event)" onMouseout="bspMenuUnHighlight(event)" onClick="bspMenuSelect(event,'GroupDetailMenuABAP<%=nr%>')" display:none>

      <div class="bspMenuItem">
      <table border=0 cellspacing=0 cellpadding=0 class="sapTbvAlt" width="100%">
<%
	if (wdisp_host_info[nr].has_abap) {
	  if (!wdisp_host_info[nr].stack[0].active) {
	    __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	    __output ("<b>Server was manually deactivated</b>");
	    __output("</td></tr>");
	    wdisp_host_info[nr].stack[0].error_text = "Server was manually deactivated";
	  }
	  else if (!wdisp_host_info[nr].stack[0].valid) {
	    __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	    __output ("<b>Server is not reachable</b>");
	    __output("</td></tr>");
	    wdisp_host_info[nr].stack[0].error_text = "Server is not reachable";
	  }
	  else if (!wdisp_host_info[nr].stack[0].responding) {
	    __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	    __output ("<b>Server is not responding to ping requests</b>");
	    __output("</td></tr>");
	    wdisp_host_info[nr].stack[0].error_text = "Server is not responding to ping requests";
	  }
	} else {
	  __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	  __output ("<b>Server offers no ABAP services</b>");
	  __output("</td></tr>");
	  wdisp_host_info[nr].stack[0].error_text = "Server offers no ABAP services";
	}
%>
	</table></div>
      </div>

      <div id="GroupDetailMenuJava<%=nr%>" style="width:180;background-color:#ffffc8" class="bspMenuBox" onMouseover="bspMenuHighlight(event)" onMouseout="bspMenuUnHighlight(event)" onClick="bspMenuSelect(event,'GroupDetailMenuJava<%=nr%>')" display:none>

      <div class="bspMenuItem">
      <table border=0 cellspacing=0 cellpadding=0 class="sapTbvAlt" width="100%">
<%
	if (wdisp_host_info[nr].has_j2ee) {
	  if (!wdisp_host_info[nr].stack[1].active) {
	    __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	    __output ("<b>Server was manually deactivated</b>");
	    __output("</td></tr>");
	    wdisp_host_info[nr].stack[1].error_text = "Server was manually deactivated";
	  }
	  else if (!wdisp_host_info[nr].stack[1].valid) {
	    __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	    __output ("<b>Server is not reachable</b>");
	    __output("</td></tr>");
	    wdisp_host_info[nr].stack[1].error_text = "Server is not reachable";
	  }
	  else if (!wdisp_host_info[nr].stack[1].responding) {
	    __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	    __output ("<b>Server is not responding to ping requests</b>");
	    __output("</td></tr>");
	    wdisp_host_info[nr].stack[1].error_text = "Server is not responding to ping requests";
	  }
	} else {
	  __output("<tr><td style=\"background-color:#ffffc8\" class=\"sapTbvCellAlt\">");
	  __output ("<b>Server offers no Java services</b>");
	  __output("</td></tr>");
	  wdisp_host_info[nr].stack[1].error_text = "Server offers no Java services";
	}
%>
	</table></div>
      </div>
<%
    }
%>

    <table border="0" cellspacing="0" cellpadding="0" class="sapTbvAlt" width="100%">
    <tr>
      <td class="sapTbvCellAlt">
	<b><i>Server Group Monitor<%=systemID_show%></i></b>
      </td>
      <td class="sapTbvCellAlt" align="right">
	<a accesskey="r" onKeyUp="javascript:callUrlWithKey(event,82,'./confirm.icp?what=reload_wdisp_group_conf')" 
	   href="./confirm.icp?what=reload_wdisp_group_conf" class="sapBtnStd">
	<nobr><u>R</u>eload Web Dispatcher configuration</nobr></a>
      </td>
      <td class="sapTbvCellAlt" align="right">
	<a href="javascript:location.reload()" class="sapBtnEmph" title="refresh page"><nobr>Refresh</nobr></a>
      </td>
    </tr>
    <tr>
    <td class="sapTbvCellStd" Colspan="3">
    <form action="" method="GET" name="FormTabStrip">
      <input type="hidden" name="tabsel" value="">
      <input type="hidden" name="what" value="">
      <input type="hidden" name="systemID" value="">
	<table border="0" cellpadding="0" cellspacing="0" width="100%">
	  <tr>
	    <td valign="top">
	      <br>
		<table border="0" cellpadding="0" cellspacing="0" width="100%">
		  <tr valign="top">
		    <td>
		      <!--HEADERS-->
		      <table border="0" cellpadding="0" cellspacing="0">
			<tr>
			  <!--HEADER ITEM-->
			  <td nowrap></td>
<%
    for (nr = 0; nr<group_count; nr++) {
%>
			  <td nowrap
<%
      if (nr == tabsel)
      {
%>
			    class="sapTbsTabSel">
			    <a title="Status of Server Group <%=wdisp_group_info[nr].name%>" class="sapLnk" OnMouseOver="window.status = '<%=wdisp_group_info[nr].name%>'; return true;" style="text-decoration:none">
			     <b><%=wdisp_group_info[nr].name%></b>

<%    } 
      else
      {
%>
			    class="sapTbsTab">
			    <a title="Status of Server Group <%=wdisp_group_info[nr].name%>" class="sapLnk" OnMouseOver="window.status = '<%=wdisp_group_info[nr].name%>'; return true;" href="javascript:callSubmitAction('FormTabStrip','<%=nr%>','','<%=systemID%>')"
			     style="text-decoration:none"><%=wdisp_group_info[nr].name%>
<%    }
%>
			    </a>
			  </td>
<%
   }
%>
			  <!--HEADER ITEM END-->
			  <td nowrap class="sapTbsTabBlk"> </td>
			</tr>
		      </table>
		      <!--HEADER END-->
		      <!--CONTENTS-->
		      <table class="sapTbsWhl" border="0" cellspacing="0" cellpadding="0"
			width="100%">
			<tr>
			  <td align="left" valign="top">

			    <table border="0" cellspacing="0" cellpadding="0" class="sapTbvAlt" width="100%">
			      <tr>
				<td class="sapTbvCellAlt" width="400">
				  <b><i>Status of Server Group "<%=htmlenc(group)%>"</i></b>
				</td>
			      </tr>
			      <tr>
				<td class="sapTbvCellAlt" Colspan=2>
				  <table border=0 cellspacing=1 cellpadding=0 class="sapTbvAlt">
				    <tr>
				      <td class="sapTbvCellAlt" Colspan=2>
					<b><i>Loadbalancing Information</i></b>
				      </td>
				    </tr>
				    <tr>
				      <td class="sapTbvCellStd">Number of Servers in this group</td>
				      <td class="sapTbvCellStd"><%= wdisp_group_info[tabsel].no_server %></td>
				    </tr>
				    <tr>
				      <td class="sapTbvCellStd">Last used Server</td>
				      <td class="sapTbvCellStd"><%= wdisp_group_info[tabsel].last_server %></td>
				    </tr>
				    <tr>
				      <td class="sapTbvCellStd">Preferred next Server</td>
				      <td class="sapTbvCellStd"><%= wdisp_group_info[tabsel].next_server %></td>
				    </tr>
				  </table>
				</td>
			      </tr>
			      <tr>
				<td class="sapTbvCellAlt" Colspan=2>&nbsp;</td>
			      </tr>
			      <tr>
				<td class="sapTbvCellAlt" Colspan=2>
				  <table border=0 cellspacing=1 cellpadding=0 class="sapTbvAlt">
				    <tr>
				      <td class="sapTbvCellAlt" Colspan=13>
					<b><i>Hosts in Group</i></b>
				      </td>
				    </tr>
				    <tr>
				      <th class="sapTbvCellAlt" align="center" width=20>
					<i>Nr.</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=20>
					<i>Operational (ABAP)</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=20>
					<i>Operational (Java)</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=100>
					<i>Name</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=100>
					<i>Hostname</i>
				      </th>
				    </tr>
<%
        for (nr = 0; nr < host_count; nr++)
	{
%>
				    <tr>
				      <td class="sapTbvCellStd"><%= nr %></td>
<%
	
	__output("<td class=\"sapTbvCellStd\">");
	if (wdisp_host_info[nr].has_abap) {
	  if (wdisp_host_info[nr].stack[0].operational)
	    __output ("<img src=\"../public/icons/s_s_okay.gif\" alt=\"OK\" title=\"OK\">");
	  else {
	    __output ("<a id=\"groupDetailObjABAP",nr,"\" onMouseOver=\"bspMenuShow('GroupDetailMenuABAP'+", nr, ",event)\" onMouseOut=\"bspMenuHide(event,1)\">");
	    __output ("<img src=\"../public/icons/s_m_erro.gif\" alt=\"", wdisp_host_info[nr].stack[0].error_text, "\">");
	    __output ("</a>");
	  }
	}
	else {
	    __output ("<a id=\"groupDetailObjABAP",nr,"\" onMouseOver=\"bspMenuShow('GroupDetailMenuABAP'+", nr, ",event)\" onMouseOut=\"bspMenuHide(event,1)\">");
	  __output("-");
	}
	__output("</td>");

	__output("<td class=\"sapTbvCellStd\">");
	if (wdisp_host_info[nr].has_j2ee) {
	  if (wdisp_host_info[nr].stack[1].operational)
	    __output ("<img src=\"../public/icons/s_s_okay.gif\" alt=\"OK\" title=\"OK\">");
	  else {
	    __output ("<a id=\"groupDetailObjJava",nr,"\" onMouseOver=\"bspMenuShow('GroupDetailMenuJava'+", nr, ",event)\" onMouseOut=\"bspMenuHide(event,1)\">");
	    __output ("<img src=\"../public/icons/s_m_erro.gif\" alt=\"", wdisp_host_info[nr].stack[1].error_text, "\">");
	    __output ("</a>");
	  }
	}
	else {
	    __output ("<a id=\"groupDetailObjJava",nr,"\" onMouseOver=\"bspMenuShow('GroupDetailMenuJava'+", nr, ",event)\" onMouseOut=\"bspMenuHide(event,1)\">");
	  __output("-");
	}
	__output("</td>");
%>
				      <td class="sapTbvCellStd" align="left">
					<%= wdisp_host_info[nr].name %>
				      </td>
				      <td class="sapTbvCellStd"><%= wdisp_host_info[nr].host_name %></td>
				    </tr>
<%
	}
%>
				  </table>
				</td>
			      </tr>
			      <tr>
				<td class="sapTbvCellAlt" Colspan=2>&nbsp;</td>
			      </tr>
			      <tr>
				<td class="sapTbvCellAlt" Colspan=2>
				  <table border=0 cellspacing=1 cellpadding=0 class="sapTbvAlt">
				    <tr>
				      <td class="sapTbvCellAlt" Colspan=12>
					<b><i>URL Prefixes for this Logon Group</i></b>
				      </td>
				    </tr>
				    <tr>
				      <th class="sapTbvCellAlt" align="center" width=20>
					<i>Nr.</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=20>
					<i>URL</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=100>
					<i>Virtual Host</i>
				      </th>
				      <th class="sapTbvCellAlt" align="center" width=100>
					<i>Stack</i>
				      </th>
				    </tr>
<%
        for (nr = 0; nr < url_count; nr++)
	{
%>
				    <tr>
				      <td class="sapTbvCellStd"><%= nr %></td>
				      <td class="sapTbvCellStd" align="left">
					<a href="javascript:preview('<%=wdisp_url_map[nr].prefix%>')">
					<%=wdisp_url_map[nr].prefix%></a>
				      </td>
				      <td class="sapTbvCellStd" align="center">
					<%=wdisp_url_map[nr].virt_host %>
				      </td>
				      <td class="sapTbvCellStd" align="center">
					<%=wdisp_url_map[nr].stack %>
				      </td>
				    </tr>
<%
	}
%>
				  </table>
				</td>
			      </tr>
			    </table>
			  </td>
			</tr>
		      </table>
		      <!--CONTENTS END-->
		    </td>
		  </tr>
		</table>
	    </td>
	  </tr>
	</table>
    </form>
    </td>
    </tr>
    </table>
    </body>
  </html>
