<%@ page language="java" import="java.util.*,java.sql.*,java.sql.Date,java.sql.Time,java.net.*,java.awt.*,java.awt.image.*,javax.swing.*,java.io.*"%>

<%
    String country;
    String environmentParameter;
	String eboxId;
	%>
	
<html>
<head>
<title>Current Data for All monitored items</title>
</head>
<jsp:useBean id="em" scope="session" class="EntrakMain"/>
<jsp:useBean id="sql" scope="session" class="SQLStatement"/>
<script>
  function loadFrame(url,target) {

        var newWin=window.open(url,target);		
        newWin.location.replace(url);
		//updated from newWin.location.reload();

    } //function loadFrame(url,target)
     
</script>

<body>
 
<%
			country=request.getParameter("country");
			eboxId=request.getParameter("eboxId");
%>
<table BORDER ="1"  ALIGN="center" CELLSPACING ="1" CELLPADDING="4" WIDTH="550" >
  <tr> 
	<td><b> No </b></td-->
	<td><b> Country</b></td>	
	<td><b> Location Name </b></td>
	<td><b> e-Box ID </b> </td>
  </tr>
  <%
  
    Vector listOfEntity = new Vector();
	Vector listOfEbox_id = new Vector(); 		
	String intervalTerm = "60 MINUTE";
    sql = new SQLStatement(em.con);
	String clName = ClassLoaderName.getName(getClassLoader().toString());			
    sql.setClassLoaderName(clName);
	
  	String command ="select entity.district, entity.name, entity.ref from smarthomes.entity, smarthomes.monitored "+
				" where entity.ref =monitored.m_id AND datetime >current_date AND entity.district LIKE \'"+ country +"\'"+  
				" group by entity.name order by  entity.district ASC, entity.name ASC "; 
				
    ResultSet rs = sql.executeSqlRs(command); 			
	int count=0;				 
	
	while (rs.next()){ 	 
	    String ebox_country = rs.getString("entity.district");    
		String entityName  = rs.getString("entity.name");		 		 
		String eboxID = rs.getString("entity.ref");
        listOfEntity.add( entityName ) ;
		listOfEbox_id.add( eboxID );  
        count++;
		 	 
%>
  <tr> 
	<td><%=count %></td>
	<td><%=ebox_country %></td>

	<td><%=entityName %></td>
	<td><%=eboxID %></td>
  </tr>
  <%	  		  	 		 		 		 
	}	  
if(count ==0) { 		 	 					
%><script>
    loadFrame("message_info.jsp?message=No Data available. Check Connection","imgFrame_c");
 </script>       
<% 
}
%>
</table>
</body>
</html>
