<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.types.Category" %>
<%@ page import="ro.emid.common.db.CategoryAccessDB" %>
<%@ page import="ro.emid.common.constants.GlobalAppConstants" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.utils.Util" %>
<%
    long parentId = ObjectUtils.getIntValue(request.getParameter("parentId"), 0);
    long selectedValue = ObjectUtils.getIntValue(request.getParameter("selectedValue"), 0);
    boolean disabled = ObjectUtils.getStringValue(request.getParameter("disabled")).equals("true");
    String selectName = ObjectUtils.getStringValue(request.getParameter("selectName"));

    String selectatiOption = ObjectUtils.getStringValue(request.getParameter("selectatiOption"));
    if( ObjectUtils.isEmpty(selectatiOption)){
        selectatiOption = "Selectati:";
    }
%>
<respmesg>
    <% final Category[] categories = CategoryAccessDB.getAllCategoriesByParentId( parentId); %>
    <select class="gSAPSelect" id="<%=selectName%>" name="<%=selectName%>" <%=disabled? "disabled" : ""%>>
        <option value="-1" ><%=selectatiOption%></option>
        <% for (int i = 0; i < categories.length; i++) {
            final Category category = categories[i];%>
            <option codSapAsCentru="<%=AppConstants.format( category.getCodSapAsCentru())%>" isCuSectiiSiCentre="<%=category.isCuSectiiSiCentre()%>" codSAP="<%=Util.escapeToJs(category.getCodSap())%>"  value="<%=category.getId()%>" <%=category.getId() == selectedValue ? "selected" : ""%> ><%=category.getName()%></option>
        <% }%>
    </select>
</respmesg>
