<%-- 
    Document   : searchUsers
    Created on : 21.1.2018, 19:59:33
    Author     : themi
--%>
<%@ page import="cz.csu.sdmx.constants.URL"%>
<%@ page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix = "fn" uri = "http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<jsp:include page="reusable/header.jsp">
    <jsp:param name="scripts" value="jquery-ui.js" />
    <jsp:param name="stylesheets" value="jquery-ui.css" />
    <jsp:param name="title" value="Conditions" />
</jsp:include>
<h2>User list</h2>
<script>
    $( function() {
      var availableTags = [
      <c:forEach var="user" items="${users}" varStatus="status">
                "${user.personalNumber}"<c:if test="${!status.last}">,</c:if>
      </c:forEach>
      ];
      $( "#users" ).autocomplete({
        source: availableTags
      });
    } );
</script> 
<form action="<c:url value="<%= URL.USERS_SEARCH%>" />" method="POST">
  <div class="input-group col-lg-5">
      <input type="text" id="q" name="q" class="form-control" placeholder="Personal number" value="${q}">
    <div class="input-group-btn">
      <button class="btn btn-default" style="width: 100px;" type="submit">
        <i class="glyphicon glyphicon-search"></i>
      </button>
    </div>
  </div>
</form>

<table class="col-lg-8 tableList ">
    <tr><th class="col-lg-6">Personal number</th><th class="col-lg-2"></th><th class="col-lg-2"></th></tr>
    <c:forEach var="user" items="${users}">
        <tr>
            <td><c:out value="${user.personalNumber}"/></td>
            <c:set var="updateUrl" value="<%=URL.USER%>" />
            <td><a class="btn cleanButton" href="<c:url value="${updateUrl}${user.personalNumber}" />"><span class="glyphicon glyphicon-pencil"></span></a></td>  
            <td>
                <form class="deleteConditionForm" action="<c:url value="<%=URL.USER_DELETE%>" />" method="POST">
                    <input name="personalNumber" type="hidden" value="${user.personalNumber}" />
                    <button  class="btn cleanButton">
                        <span class="glyphicon glyphicon-trash"></span>
                    </button>
                </form>
            </td>     
        </tr>
    </c:forEach>        
</table>
<jsp:include page="reusable/footer.jsp" />


