<%@ 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.db.framework.ReportStatement" %>
<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.types.Deranjament" %>
<%@ page import="java.sql.Date" %>
<%@ page import="java.sql.Timestamp" %>
<%@ page import="java.util.Calendar" %>
<%@ page import="ro.emid.callcenter.CallcenterSessionUtils" %>
<%@ page import="ro.emid.common.constants.RoleConstants" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>

<%@ include file="../callcenter/declaratii.jsp" %>
<%
    long filialaId = CallcenterSessionUtils.getFilialaId(session);
    long sucursalaId = CallcenterSessionUtils.getSucursalaId(session);
    long centruId = CallcenterSessionUtils.getCentruId(session);

    if (0 < ObjectUtils.getLongValue(request.getParameter("filiala"), -2)) {
        filialaId = ObjectUtils.getLongValue(request.getParameter("filiala"));
    }

    if (0 < ObjectUtils.getLongValue(request.getParameter("sucursala"), -2)) {
        sucursalaId = ObjectUtils.getLongValue(request.getParameter("sucursala"));
    }

    if (0 < ObjectUtils.getLongValue(request.getParameter("centruId"), -2)) {
        centruId = ObjectUtils.getLongValue(request.getParameter("centruId"));
    }

    Category filialaRaport = CategoryAccessDB.getById(filialaId);
    if (filialaRaport == null) filialaRaport = new Category();

    Category sucursalaRaport = CategoryAccessDB.getById(sucursalaId);
    if (sucursalaRaport == null) sucursalaRaport = new Category();

    Category centruRaport = CategoryAccessDB.getById(centruId);
    if (centruRaport == null) centruRaport = new Category();


    Date dataStart = ObjectUtils.getDateValue(request.getParameter("data_start"), AppConstants.FORMAT_DATA_TIME);
    Date dataStop = ObjectUtils.getDateValue(request.getParameter("data_stop"), AppConstants.FORMAT_DATA_TIME);

    final Calendar c = Calendar.getInstance();
    c.set(c.get(Calendar.YEAR), c.get(Calendar.MONTH), c.get(Calendar.DATE), 7, 0, 0);
    if (dataStart == null) dataStart = new Date(c.getTime().getTime());

    if (dataStop == null) {
        c.add(Calendar.DATE, 1);
        dataStop = new Date(c.getTime().getTime());
    }

    final String value_data_start = AppConstants.formatx(dataStart);
    final String value_data_stop = AppConstants.formatx(dataStop);

    final Timestamp dataStartx = new Timestamp(dataStart.getTime());
    final Timestamp dataStopx = new Timestamp(dataStop.getTime());

    final ReportStatement raport1_a = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */ COUNT(*) FROM deranjamente")
            .addOrSetFilter("DATA_ANUNTARE", ">=", dataStartx)
            .addOrSetFilter("DATA_ANUNTARE", "<=", dataStopx)

                    //conditia de in curs de rezolvare
            .addStringCriteria("AND DATA_SOSIRE_ECHIPA IS NOT NULL AND DATA_REZOLVARE IS NULL")
            ;

    final ReportStatement raport1_b = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */ COUNT(*) FROM deranjamente")
            //conditia de in afara perioadei
            .addOrSetFilter("DATA_ANUNTARE", "<", dataStartx)
            .addOrSetFilter("DATA_ANUNTARE", ">", dataStop)
                    //conditia de in curs de rezolvare
            .addStringCriteria("AND DATA_SOSIRE_ECHIPA IS NOT NULL AND DATA_REZOLVARE IS NULL")
            ;

    final ReportStatement raport2_a = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */ COUNT(*) FROM deranjamente")
            .addOrSetFilter("DATA_ANUNTARE", ">=", dataStartx)
            .addOrSetFilter("DATA_ANUNTARE", "<=", dataStopx)
            .addStringCriteria("AND DATA_REZOLVARE IS NOT NULL")
            .addOrSetFilter("DATA_REZOLVARE", ">=", dataStartx)
            .addOrSetFilter("DATA_REZOLVARE", "<=", dataStopx);

    final ReportStatement raport2_b = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */ COUNT(*) FROM deranjamente")
            .addOrSetFilter("DATA_ANUNTARE", "<", dataStartx)
            .addStringCriteria("AND DATA_REZOLVARE IS NOT NULL")
            .addOrSetFilter("DATA_REZOLVARE", ">=", dataStartx)
            .addOrSetFilter("DATA_REZOLVARE", "<=", dataStopx);

    final ReportStatement raport13_1 = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */  SUM(ENC_CASNICI) FROM deranjamente ");
    final ReportStatement raport13_2 = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */  SUM(ENC_MICI + ENC_MARI) FROM deranjamente ");
    final ReportStatement raport13_3 = new ReportStatement("SELECT /*+ INDEX(RAPORT_ZILNIC_CC_IDX) */  SUM(ENC_CASNICI + ENC_MICI + ENC_MARI) FROM deranjamente ");


    if (centruRaport.getId() > 0) {
        raport1_a.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));
        raport1_b.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));
        raport2_a.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));
        raport2_b.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));

        raport13_1.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));
        raport13_2.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));
        raport13_3.addOrSetFilter("SECTIE_ID", "=", new Long(centruRaport.getId()));
    } else if (sucursalaRaport.getId() > 0) {
        raport1_a.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));
        raport1_b.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));
        raport2_a.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));
        raport2_b.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));

        raport13_1.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));
        raport13_2.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));
        raport13_3.addOrSetFilter("SUCURSALA_ID", "=", new Long(sucursalaRaport.getId()));
    } else if (filialaRaport.getId() > 0) {
        raport1_a.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));
        raport1_b.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));
        raport2_a.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));
        raport2_b.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));

        raport13_1.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));
        raport13_2.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));
        raport13_3.addOrSetFilter("FILIALA_ID", "=", new Long(filialaRaport.getId()));
    }

    raport13_1.addOrSetFilter("DATA_ANUNTARE", ">=", dataStartx).addOrSetFilter("DATA_ANUNTARE", "<=", dataStopx);
    raport13_2.addOrSetFilter("DATA_ANUNTARE", ">=", dataStartx).addOrSetFilter("DATA_ANUNTARE", "<=", dataStopx);
    raport13_3.addOrSetFilter("DATA_ANUNTARE", ">=", dataStartx).addOrSetFilter("DATA_ANUNTARE", "<=", dataStopx);
%>

<TABLE border=0 cellPading=0 cellSpacing=0 width="100%">
    <TR>
        <TD>
            <SPAN style="FONT-SIZE: 12px; FONT-WEIGHT: bold">

                <A class="link"
                     href="<%=GlobalAppConstants.APP_NAME%>?action=rapoarte">Rapoarte</A> - Raport zilnic
            </span>
        </TD>
    </TR>
</TABLE>

<center>
    <br/>
    <span style="font-size: 14px">Raport zilnic</span>
</center>


<div class="spacer"></div>
<table class="gsaptd">
    <tr>
        <td>
            <form name="zaforma" action="<%=GlobalAppConstants.APP_NAME%>" method="post">
                <input type="hidden" name="action" value="raport-zilnic">
                Filiala:
                <SELECT name="filiala" onchange="fill_sucursala_select()"
                        class="gSAPSelect" <%=user.getIeLevel() == RoleConstants.NIVEL_FULL ? "" : "disabled"%> >
                    <OPTION value="-1">ELECTRICA SA:</OPTION>
                    <% final Category[] filiale = CategoryAccessDB.getAllCategoriesByParentId(-1);
                        if (filiale != null) for (int i = 0; i < filiale.length; i++) {%>
                    <OPTION <%=(filiale[i].getId() == filialaRaport.getId()) ? "selected=\"true\" " : ""%>value="<%=filiale[i].getId()%>"><%=filiale[i].getName()%>
                    </OPTION>
                    <%} %>
                </SELECT>&nbsp;&nbsp;

                Sucursala:
    <span id="sucursalaDiv">
    <SELECT name="sucursala" class="gSAPSelect" onchange="fill_centru_select()">
        <option value="-1">Selectati:</option>
    </SELECT></span>&nbsp;&nbsp;

                C.E.:
    <span id="centruDiv">
        <SELECT name="centruId" class="gSAPSelect">
            <OPTION value="-1">Selectati:</OPTION>
        </SELECT>
    </span>

                &nbsp;&nbsp;<input type="text" id="data_start" name="data_start" size="14"
                                   value="<%=value_data_start%>"/> <a href="#" id="trigger_data_start"><img
                    src="<%=AppConstants.WEB_RESOURCE_PATH + "/images/cal.gif"%>" width="16" height="16" border="0"
                    alt="Apasa pt. a selecta data."></a> -
                <input type="text" id="data_stop" name="data_stop" size="14" value="<%=value_data_stop%>"/> <a href="#"
                                                                                                               id="trigger_data_stop"><img
                    src="<%=AppConstants.WEB_RESOURCE_PATH + "/images/cal.gif"%>" width="16" height="16" border="0"
                    alt="Apasa pt. a selecta data."></a>
                <input type="submit" value="Aplica">
            </form>
        </td>
    </tr>
</table>
<div class="spacer"></div>


<%
    long urban = 0;
    long rural = 0;
%>

<TABLE id="table" border=1 cellPadding=2 cellSpacing=1 width="80%" class="gSAPTHEAD" style="BACKGROUND-COLOR: white">
    <col>
    <col>
    <col align="center">
    <col align="right">
    <col align="right">
    <col align="right">
    <tr noSelect="true">
        <th class="gsapthead">&nbsp;</th>
        <th class="gsapthead">&nbsp;</th>
        <th class="gsapthead">Categorie</th>
        <th class="gsapthead">Urban</th>
        <th class="gsapthead">Rural</th>
        <th class="gsapthead">Total</th>
    </tr>
    <tr>
        <td rowspan="2">1.</td>
        <td rowspan="2">Numar de deranjamente <b>aflate in curs de rezolvare</b> la sfarsitul perioadei</td>
        <td>a</td>
        <td><%=urban = raport1_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=rural = raport1_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <td><%=urban = raport1_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=rural = raport1_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>

    <!-- -->
    <tr>
        <td rowspan="2">2.</td>
        <td rowspan="2">Numar de deranjamente <b>rezolvate</b> la sfarsitul perioadei</td>
        <td>a</td>
        <td><%=urban = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=rural = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <td><%=urban = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=rural = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>

    <!-- -->
    <tr>
        <td rowspan="2">2.1</td>
        <td rowspan="2">Numar de deranjamente <b>rezolvate</b> la sfarsitul perioadei, <b><br>avand cauze in afara
            instalatiilor FDEE:</b></td>
        <td>a</td>
        <% raport2_a.addOrSetFilter("APARTENENTA_INST", "!=", new Integer(Deranjament.APARTINE_ELECTRICA)); %>
        <td><%=urban = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=rural = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <% raport2_b.addOrSetFilter("APARTENENTA_INST", "!=", new Integer(Deranjament.APARTINE_ELECTRICA)); %>
        <td><%=urban = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=rural = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>

    <%
        long nrDerElectricaUrban_a = 0;
        long nrDerElectricaUrban_b = 0;

        long nrDerElectricaRural_a = 0;
        long nrDerElectricaRural_b = 0;
    %>
    <!-- -->
    <tr>
        <td rowspan="2">2.2</td>
        <td rowspan="2">Numar de deranjamente <b>rezolvate</b> la sfarsitul perioadei, <b><br>avand cauze in
            instalatiile FDEE:</b></td>
        <td>a</td>
        <% raport2_a.removeFilter("APARTENENTA_INST"); %>
        <% raport2_a.addOrSetFilter("APARTENENTA_INST", "=", new Integer(Deranjament.APARTINE_ELECTRICA)); %>
        <td><%=nrDerElectricaUrban_a = urban = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=nrDerElectricaRural_a = rural = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <% raport2_b.removeFilter("APARTENENTA_INST"); %>
        <% raport2_b.addOrSetFilter("APARTENENTA_INST", "=", new Integer(Deranjament.APARTINE_ELECTRICA)); %>
        <td><%=nrDerElectricaUrban_b = urban = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
        </td>
        <td><%=nrDerElectricaRural_b = rural = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
        </td>
        <td><%=urban + rural%>
        </td>
    </tr>

    <!-- -->
    <%long procente = 0;%>
    <tr>
        <td rowspan="2">2.2.1</td>
        <td rowspan="2">Numar de deranjamente <b>rezolvate</b> intr-un interval mai mic de <b>12 ore</b> (mediul <b>urban</b>)
        </td>
        <td>a</td>
        <% raport2_a.addOrSetFilter("floor((data_rezolvare - data_anuntare)*24)", "<", new Long(12)); %>
        <td>
            <%=urban = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
            <%
                procente = 0;
                if (nrDerElectricaUrban_a != 0) {
                    procente = (int) (urban * 1.0 / nrDerElectricaUrban_a * 100);
                }
            %>
            (<%=procente%>%)
        </td>
        <td>&nbsp;</td>
        <td><%=urban%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <% raport2_b.addOrSetFilter("floor((data_rezolvare - data_anuntare)*24)", "<", new Long(12)); %>
        <td>
            <%=urban = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_URBAN)).getLongResult()%>
            <% procente = 0;
                if (nrDerElectricaUrban_b != 0) {
                    procente = (int) (urban * 1.0 / nrDerElectricaUrban_b * 100);
                }
            %>
            (<%=procente%>%)
        </td>
        <td>&nbsp;</td>
        <td><%=urban%>
        </td>
    </tr>

    <!-- -->
    <tr>
        <td rowspan="2">2.2.2</td>
        <td rowspan="2">Numar de deranjamente <b>rezolvate</b> intr-un interval mai mic de <b>24 ore</b> (mediul <b>rural</b>)
        </td>
        <td>a</td>
        <% raport2_a.addOrSetFilter("floor((data_rezolvare - data_anuntare)*24)", "<", new Long(24)); %>
        <td>&nbsp;</td>
        <td>
            <%=rural = raport2_a.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
            <% procente = 0;
                if (nrDerElectricaRural_a != 0) {
                    procente = (int) (rural * 1.0 / nrDerElectricaRural_a * 100);
                }
            %>
            (<%=procente%>%)
        </td>
        <td><%=rural%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <% raport2_b.addOrSetFilter("floor((data_rezolvare - data_anuntare)*24)", "<", new Long(24)); %>
        <td>&nbsp;</td>
        <td>
            <%=rural = raport2_b.addOrSetFilter("MEDIUL", "=", new Long(Deranjament.MEDIU_RURAL)).getLongResult()%>
            <% procente = 0;
                if (nrDerElectricaRural_b != 0) {
                    procente = (int) (rural * 1.0 / nrDerElectricaRural_b * 100);
                }
            %>
            (<%=procente%>%)
        </td>
        <td><%=rural%>
        </td>
    </tr>
</TABLE>

<br>
<br>

<TABLE id="table2" border=1 cellPadding=2 cellSpacing=1 width="80%" class="gSAPTHEAD" style="BACKGROUND-COLOR: white">
    <col>
    <col align="center">
    <col align="right">
    <col align="right">
    <col align="right">
    <tr noSelect="true">
        <th class="gsapthead">&nbsp;</th>
        <th class="gsapthead">Categorie</th>
        <th class="gsapthead">Casnici</th>
        <th class="gsapthead">Altii</th>
        <th class="gsapthead">Total</th>
    </tr>
    <tr>
        <td rowspan="2">Energia electrica <b>nelivrata consumatorilor</b> intrerupti cu prilejul deranjamentelor (kWh)
        </td>
        <td>a</td>
        <td><%=raport13_1.getLongResult()%>
        </td>
        <td><%=raport13_2.getLongResult()%>
        </td>
        <td><%=raport13_3.getLongResult()%>
        </td>
    </tr>
    <tr>
        <td>b</td>
        <%
            raport13_1.removeFilter("DATA_ANUNTARE").addOrSetFilter("DATA_ANUNTARE", "<", dataStartx);
            raport13_2.removeFilter("DATA_ANUNTARE").addOrSetFilter("DATA_ANUNTARE", "<", dataStartx);
            raport13_3.removeFilter("DATA_ANUNTARE").addOrSetFilter("DATA_ANUNTARE", "<", dataStartx);
        %>
        <td><%=raport13_1.getLongResult()%>
        </td>
        <td><%=raport13_2.getLongResult()%>
        </td>
        <td><%=raport13_3.getLongResult()%>
        </td>
    </tr>
</TABLE>

<br>
<b>Legenda:</b><br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;categorie <b>a</b>-deranjamente produse in perioada de referinta<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;categorie <b>b</b>-deranjamente produse in afara perioadei de referinta

<script type="text/javascript">
    var table = new Table("table", "table");
    var table2 = new Table("table2", "table2");
</script>

<script type="text/javascript">
    Calendar.setup(
            {
                inputField  : "data_start",         // ID of the input field
                ifFormat    : "%d.%m.%Y %H:%M",    // the date format
                button      : "trigger_data_start"       // ID of the button
            }
    );

    Calendar.setup(
            {
                inputField  : "data_stop",         // ID of the input field
                ifFormat    : "%d.%m.%Y %H:%M",    // the date format
                button      : "trigger_data_stop"       // ID of the button
            }
    );
</script>

<script type="text/javascript">
    function fill_sucursala_select(selectedValue, disabled, firstShow) {
        resetComboLeaveFirstOption(document.zaforma.sucursala);
        resetComboLeaveFirstOption(document.zaforma.centruId);

        var filialaId = document.zaforma.filiala[ document.zaforma.filiala.selectedIndex].value;
        if (filialaId > -1) {
            var params = "parentId=" + filialaId + "&selectName=sucursala&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
            //alert( params);

            getCategoriesFromServer(params, function(originalRequest) {
                //alert( getResponseMesg (originalRequest.responseText));
                $('sucursalaDiv').innerHTML = getResponseMesg(originalRequest.responseText);

                document.zaforma.sucursala.onchange = fill_centru_select;

                if (firstShow) {
                    fill_centru_select(<%=centruRaport.getId()%>, <%=user.getIeLevel() == RoleConstants.NIVEL_CENTRU || user.getIeLevel() == RoleConstants.NIVEL_FORMATIE%>);
                }
            });
        }
    }

    function fill_centru_select(selectedValue, disabled) {
        resetComboLeaveFirstOption(document.zaforma.centruId);

        var sucursalaId = document.zaforma.sucursala[ document.zaforma.sucursala.selectedIndex].value;
        if (sucursalaId > -1) {
            var params = "parentId=" + sucursalaId + "&selectName=centruId&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
            //alert( params);

            getCategoriesFromServer(params, function(originalRequest) {
                //alert( getResponseMesg (originalRequest.responseText));
                $('centruDiv').innerHTML = getResponseMesg(originalRequest.responseText);
            });
        }
    }


    fill_sucursala_select(<%=sucursalaRaport.getId()%>, <%=user.getIeLevel() == RoleConstants.NIVEL_SUCURSALA || user.getIeLevel() == RoleConstants.NIVEL_CENTRU || user.getIeLevel() == RoleConstants.NIVEL_FORMATIE%>, true);
</script>
