<%@page import="org.apache.log4j.Logger"%>
<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.constants.UserConstants" %>
<%@ page import="ro.emid.common.db.UserAccessDB" %>
<%@ page import="ro.emid.common.types.User" %>

<%
    User user = null;
    final Logger LOG = Logger.getLogger("loginPage_jsp");

    User[] listUsers = UserAccessDB.getAllUser("", UserConstants.SQL_USERNAME, "ASC", 0, Long.MAX_VALUE);
%>

<TABLE border=0 cellPadding=5 cellSpacing=0 width="100%">
  <TR>
    <TD>
      <TABLE class="gsapthead" width="100%" border="0" cellspacing="0" cellpadding="0">
        <TR>
          <TD>
              <form name="login_form" method="post" style="margin: 0 0 0 0;padding: 0 0 0 0;" action="<%=AppConstants.APP_NAME%>?action=login">
                      <table cellspacing="0" width="100%" cellpadding="0" border="0">
                        <tr>
                          <td NOWRAP  valign="top" align="right" WIDTH="100%" COLSPAN=2 >
                            <table cellspacing="0" cellpadding="0" border="0">
                              <tr>
                                <td NOWRAP  class="ivusHdrWelcome">Bine ati venit!</td>
                              </tr>
                            </table>
                          </td>
                         </tr>
                         <tr>
                          <td WIDTH="100%" ></td>
                          <td NOWRAP  class="ivusheadlnk">
                            <SPAN class="TopRowMenu">User Name&nbsp;</SPAN>
                            <SELECT NAME='j_user'>
                            <%for (int i = 0; i < listUsers.length; i++) {
                                user = listUsers[i]; %>
                                <OPTION><%=user.getUsername()%>
                            <%}%>
                            </SELECT>
                            &nbsp;&nbsp;
                            <INPUT class="gSAPInputButton" type="submit" name="login_submit" value="Log In">
                          </td>
                         </tr>
                      </table>
                  <input type="hidden" name="PORTAL_USER" value="wp">
                  <input type="hidden" name="PORTAL_PASSWORD" value="wpuser">
               </form>
          </TD>
        </TR>
      </TABLE>
      <br><span style="FONT-WEIGHT: bold; FONT-SIZE: 16px;">Lista de utilizatori:</span>
      <table class="gsapthead" width="100%" border="0" cellspacing="2" cellpadding="1">
            <%
              try {
               for (int i=0; i<listUsers.length; i++) {
                user = listUsers[i];
             %>
           <tr>
              <td>
               <%=user.getUsername()%>
              </td>
            </tr>
             <%}
              }catch(Throwable t) {
                  LOG.error("Eroare listare informatii despre user-i!", t);
              }%>
            &nbsp;&nbsp;
        </table>
    </TD>
  </TR>
</TABLE>

