<%@ page import="ro.emid.common.types.SetValue" %>
<%@ page import="ro.emid.common.types.SetValueConstants" %>
<%@ page import="ro.emid.common.utils.RequestUtils" %>
<%@ page import="ro.emid.common.utils.StringUtils" %>
<%@ page import="ro.emid.common.utils.sort.SortController" %>
<%@ page import="ro.emid.common.utils.sort.SortData" %>
<%@ page import="java.util.List" %>
<%@ page import="ro.emid.Application" %>
<%@ page import="ro.emid.common.utils.MenuConstants" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>

<%
    /**
     * showSetValue
     * @see ro.emid.lpod.action.admin.LoadSetValueAction
     */

    final String tip = RequestUtils.getString(request, "tip");

    final SortData sd = (SortData) request.getAttribute("sortData");

    final List list = (List) request.getAttribute("list");

%>


<table width="100%" border=0>
    <tr><td>
        <div class="spacer">&nbsp;</div>
        <form action="<%=AppConstants.APP_NAME%>" method="post">
            <input type="hidden" name="action" value="showSetValue">
            <table class="gsaptd" width="100%">
              <tr><td>
                  <%
                      if(!Application.runAsAparatCentral()){
                  %>
                  <input type="button" value="Adaugă" style="float:right;" onclick="
                          window.location = '<%=AppConstants.APP_NAME%>?action=editSetValue&id=-1&tip=<%=tip%>';">
                  <%
                      }
                  %>

                    Tip:
                    <select name="tip">
                      <option value="">Selectati:</option>
                      <option <%=SetValue.SEMNALIZARI.equals( tip) ? "selected" : ""%> value="<%=SetValue.SEMNALIZARI%>">Semnalizări</option>
                    </select>

                    <input type="submit" value="Afișează">

              </td></tr>
            </table>
        </form>
    </td></tr>
    <tr><td>

        <table cellpadding=2 cellspacing=1 width="100%" class="table">
            <thead>
                <tr>
                    <th height=25 nowrap width="10%"><%=SortController.printSortableColumn("Cod:", SetValueConstants.SQL.COD, sd)%></th>
                    <th nowrap ><%=SortController.printSortableColumn("Descriere:", SetValueConstants.SQL.VALOARE, sd)%></th>

                    <%
                        if(!Application.runAsAparatCentral()){
                    %>
                        <th nowrap width="1%">&nbsp;</th>
                    <%
                        }
                    %>

                </tr>
            </thead>
            <tbody>

            <% if( list == null || list.size() == 0){%>
                <tr>
                    <td colspan="10" class="no-data">
                        <% if( StringUtils.isZeroLength( tip)){ %>
                            Selectati tipul de nomenclator...  
                        <% } else {%>
                            Nu exista date ...
                        <% } %>
                    </td>
                </tr>
            <% } else for (int i = 0; i < list.size(); i++) {
                    final SetValue item = (SetValue) list.get(i); %>

                    <tr>
                        <td>
                            <nobr><%=StringUtils.getNullSafe(item.getCod())%></nobr>
                        </td>
                        <td><%=StringUtils.getNullSafe( item.getValoare())%></td>
                        <td>
                            <nobr>
                                <%
                                    if(!Application.runAsAparatCentral()){
                                %>
                                <a class="link" title="Editare"
                                   href="<%=AppConstants.APP_NAME%>?action=editSetValue&id=<%=item.getId()%>&tip=<%=item.getTip()%>"
                                        >Editare</a>
                                <a class="link ml5" title="Ștergere"
                                   onclick="return confirm('Stergeti intrarea din nomenclator ?')"
                                   href="<%=AppConstants.APP_NAME%>?action=deleteSetValue&id=<%=item.getId()%>&tip=<%=item.getTip()%>"
                                        >Șterge</a>
                                <%
                                    }
                                %>
                            </nobr>
                        </td>
                    </tr>
            <% } %>
            </tbody>
        </table>

        </td>
    </tr>
</table>

