<%@ page import="ro.emid.common.action.dispecer.JSP_OD" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.types.CategoryCheckData" %>
<%@ page import="ro.emid.common.types.CategoryOD" %>
<%@ page import="ro.emid.common.utils.Util" %>
<%@ page import="ro.emid.lpod.LpodSessionUtils" %>
<%@ page import="java.util.List" %>

<% if (request.getAttribute("act") !=null) {%>
    <script type="text/javascript">
        window.opener.categoriesChecked();
        window.close();
    </script>
<%}else{%>

<style type="text/css">
    .filiala{
        color :#990033;
    }

    .sucursala{
        color: #330099 ;
    }

    .centru{
        color : #006600;
        
    }
</style>

<%
    /** @see ro.emid.lpod.action.dispecer.LoadStructuraOdEvenimenteAction */
    final List filiale = (List) request.getAttribute(JSP_OD.RECORDS);

    final CategoryCheckData checkData = LpodSessionUtils.getCategoriiSelectate(session);
%>

<TABLE class="gsaptd" align=center border=0 cellPadding=10 cellSpacing=0 width="100%">
    <TBODY>
        <TR>
            <TD>
                <form name="zaforma" action="<%=AppConstants.APP_NAME%>" method="post" style="margin: 0px">
                    <input type="hidden" name="action" value="save-checked-categories-od" />
                    <div class="treeContainer" id="treeCategorii" style="overflow: auto; height: 530px">

                    <% if (null == filiale || filiale.size() == 0) {%>
                            Nu sunt filiale definite ...
                    <% } else {

                        for( int i = 0; i < filiale.size(); i++) {
                            final CategoryOD f = (CategoryOD) filiale.get( i);

                            final List sucursale = f.getChildren();%>


                            <div class="filiala" checkName="filialaId" checkValue="<%=f.getId()%>" checked="<%=Util.exists( checkData.getIdFiliale(), f.getId())%>" expanded="<%=LpodSessionUtils.getFilialaId( session) == f.getId()%>">
                                <span class="nodeText"><%=f.getName()%></span>
                                <div class="childsContainer">
                                    <% if( sucursale != null && sucursale.size() > 0) for (int j = 0; j < sucursale.size(); j++) {
                                        final CategoryOD s = (CategoryOD) sucursale.get(j); %>
                                        <div class="sucursala" checkName="sucursalaId" checkValue="<%=s.getId()%>" checked="<%=Util.exists( checkData.getIdSucursale(), s.getId())%>" expanded="<%=LpodSessionUtils.getSucursalaId( session) == s.getId()%>" >
                                            <span class="nodeText"><%=s.getName()%></span>
                                            <div class="childsContainer">
                                                 <% final List centre = s.getChildren();
                                                    if( centre != null && centre.size() > 0) for (int k = 0; k < centre.size(); k++) {
                                                        final CategoryOD c = (CategoryOD) centre.get( k); %>
                                                        <div class="centru" checkName="centruId" checkValue="<%=c.getId()%>" checked="<%=Util.exists( checkData.getIdCentre(), c.getId())%>">
                                                            <span class="nodeText"><%=c.getName()%></span>
                                                        </div>
                                                 <% } %>
                                            </div>
                                        </div>
                                    <% } %>
                                </div>
                             </div>
                       <% } %>
                    </div>
                    <% } %>
                    <br>
                    <input type="submit" value="OK">&nbsp;&nbsp;
                    <input type="reset" value="Reset">&nbsp;&nbsp;
                    <input type="button" value="Renunta" onclick="window.close()">
                </form>
            </TD>
        </tr>
    </TBODY>
</TABLE>

<script type="text/javascript">
    var countSelected = 0;
    var treeCategorii = new StaticTree( "treeCategorii", false, true, function( node){

    });
</script>
<%}%>


