<%@ page import="ro.emid.administrare.obj.binder.UserBinder" %>
<%@ page import="ro.emid.common.db.CategoryAccessDB" %>
<%@ page import="ro.emid.common.db.NomAccessDB" %>
<%@ page import="ro.emid.common.utils.UserUtils" %>
<%@ page import="java.util.List" %>
<%@ page import="ro.emid.common.db.CategoryODAccessDB" %>
<%@ page import="ro.emid.common.types.*" %>
<%@ page import="ro.emid.common.constants.*" %>
<%@ page import="ro.emid.common.AppProperties" %>

<%
    /**
     * @see ro.emid.administrare.action.user.EditUserAction
     */

    UserBinder binder = (UserBinder) request.getAttribute(UserConstants.BEAN);
    User useru = (User) binder.getBean();

    Category lpFilialaSelectata = (Category)request.getAttribute("lpFilialaSelectata");
    Category lpSucursalaSelectata = (Category)request.getAttribute("lpSucursalaSelectata");
    Category lpCentruSelectat = (Category)request.getAttribute("lpCentruSelectat");
    Category lpFormatiaSelectata = (Category)request.getAttribute("lpFormatiaSelectata");
    Category ccFilialaSelectata = (Category)request.getAttribute("ccFilialaSelectata");
    Category ccSucursalaSelectata = (Category)request.getAttribute("ccSucursalaSelectata");
    Category ccCentruSelectat = (Category)request.getAttribute("ccCentruSelectat");
    Category ccFormatiaSelectata = (Category)request.getAttribute("ccFormatiaSelectata");
    Category ieFilialaSelectata = (Category)request.getAttribute("ieFilialaSelectata");
    Category ieSucursalaSelectata = (Category)request.getAttribute("ieSucursalaSelectata");
    Category ieCentruSelectat = (Category)request.getAttribute("ieCentruSelectat");
    Category ieFormatiaSelectata = (Category)request.getAttribute("ieFormatiaSelectata");
%>

<%@ include file="../../layout/messages.jspf" %>


<table border="0" class=gSAPTHEAD cellSpacing=1 cellPadding=2 width="100%" border=0>
    <tr>
        <td align="left">
            <span style="FONT-WEIGHT: bold; FONT-SIZE: 16px;"> <%= useru.getId() == -1 ? "Adaugare utilizator:" : "Actualizare utilizator" %></span>
        </td>
    </tr>
</TABLE>
<form name="zaforma" action="<%=GlobalAppConstants.APP_NAME%>?action=save-user" method="post">
<input type="hidden" name="<%=UserConstants.ID%>" value="<%=useru.getId()%>">
<table border=0 cellPadding=2 cellSpacing=1 width="100%" class="gSAPTHEAD">
<tr class="compartiment">
    <td colspan="2"> </td>
</tr>
<tr>
    <td width="70px"></td>
    <td>
        <table border="0" width="100%">
            <tr>
                <td width="200px">Username:</td>
                <td>
                    <input class="gsapinputtext" type="text" name="<%=UserConstants.USERNAME%>"
                           value="<%=GlobalAppConstants.format( useru.getUsername())%>">
                </td>
            </tr>
            <tr>
                <td>Nume Prenume:</td>
                <td>
                    <input class="gsapinputtext" type="text" name="<%=UserConstants.NAME%>"
                           value="<%=GlobalAppConstants.format( useru.getFullName())%>">
                </td>
            </tr>
        </table>
    </td>
</tr>
<tr>
    <td>&nbsp;</td>
</tr>


<tr>
    <td>&nbsp;
</tr>


<tr class="compartiment">
    <td colspan="2">Drepturi aplicatii:</td>
</tr>
<tr>
<td></td>
<td>


<%------------------------------ Incidente--%>
<fieldset style="margin: 0; cursor: default;">
    <legend><input onclick="onAppIncidenteClick()" type="checkbox"
                   name="<%=UserConstants.APP_INCIDENTE%>" <%=useru.isIeAccess() ? "checked" : ""%>
                   value="<%=RoleConstants.CHECKED_VALUE%>" id="appIncidente"><label
            for="appIncidente">Incidente</label></legend>

    <div id="div_enable_incidente">
        <table border="0" style="font-size:13px" cellspacing="0" cellpadding="0" width="100%">
            <tr valign="top">
                <td width="200px"><b>Rol:</b></td>
                <td>
                    <input type="radio"
                           name="<%=UserConstants.ROLES_INCIDENTE%>" <%=useru.getIeRole() == RoleConstants.ROL_ADMIN ? "checked" : ""%>
                           value="<%=RoleConstants.ROL_ADMIN%>" id="ieAdmin"><label
                        for="ieAdmin">Administrator</label> &nbsp;&nbsp;&nbsp;
                    <input type="radio"
                           name="<%=UserConstants.ROLES_INCIDENTE%>" <%=useru.getIeRole() == RoleConstants.ROL_UTILIZATOR ? "checked" : ""%>
                           value="<%=RoleConstants.ROL_UTILIZATOR%>" id="ieWorker"><label
                        for="ieWorker">Utilizator</label> &nbsp;&nbsp;&nbsp;
                    <input type="radio"
                           name="<%=UserConstants.ROLES_INCIDENTE%>" <%=useru.getIeRole() == RoleConstants.ROL_VIEW ? "checked" : ""%>
                           value="<%=RoleConstants.ROL_VIEW%>" id="ieView"><label for="ieView">View</label>
                    &nbsp;&nbsp;&nbsp;
                </td>
            </tr>


            <tr valign="top">
                <td><b>Zona:</b></td>
                <td>
                    <table border="0">
                        <tr>
                            <td width="150"><label>Filiala:</label></td>
                            <td>
                                <% final Category[] ie_filiale = CategoryAccessDB.getAllCategoriesByParentId(-1); %>
                                <select class="gSAPSelect" name="<%=UserConstants.IE_FILIALA_ID%>"
                                        onchange="ie_on_filiala_changed()">
                                    <option value="-1">Selectati:</option>
                                    <% for (int ie_i = 0; ie_i < ie_filiale.length; ie_i++) {
                                        final Category ie_category = ie_filiale[ie_i]; %>
                                    <option value="<%=ie_category.getId()%>" <%=ie_category.getId() == ieFilialaSelectata.getId() ? "selected" : ""%> ><%=ie_category.getName()%>
                                    </option>
                                    <% }%>
                                </select>
                            </td>
                        </tr>
                        <tr>
                            <td><label>Sucursala:</label></td>
                            <td>
                                        <span id="ie_sucursalaDiv">
                                        <select id="<%=UserConstants.IE_SUCURSALA_ID%>"
                                                name="<%=UserConstants.IE_SUCURSALA_ID%>" class="gSAPSelect">
                                            <option value="-1">Selectati:</option>
                                        </select>
                                        </span>
                            </td>
                        </tr>
                        <tr>
                            <td><label>C.E.:</label></td>
                            <td>
                                        <span id="ie_centruDiv">
                                            <SELECT id="<%=UserConstants.IE_CENTRU_ID%>"
                                                    name="<%=UserConstants.IE_CENTRU_ID%>" class="gSAPSelect">
                                                <OPTION value="-1">Selectati:</OPTION>
                                            </SELECT>
                                        </span>
                            </td>
                        </tr>
                        <tr>
                            <td><label>Formatia de lucru:</label></td>
                            <td>
                                        <span id="ie_formatiaDiv">
                                            <SELECT id="<%=UserConstants.IE_FORMATIA_ID%>"
                                                    name="<%=UserConstants.IE_FORMATIA_ID%>" class="gSAPSelect">
                                                <OPTION value="-1">Selectati:</OPTION>
                                            </SELECT>
                                        </span>
                            </td>
                        </tr>
                    </table>

                    <script type="text/javascript">

                        function ie_on_filiala_changed() {
                            ie_fill_sucursala_select();
                            resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.IE_CENTRU_ID%>);
                            resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.IE_FORMATIA_ID%>);
                        }

                        function ie_on_sucursala_changed() {
                            ie_fill_centru_select();
                            resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.IE_FORMATIA_ID%>);
                        }

                        function ie_on_centru_changed() {
                            ie_fill_formatia_select();
                        }

                        function ie_fill_sucursala_select(selectedValue, disabled) {
                            resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.IE_SUCURSALA_ID%>);

                            var filialaId = document.zaforma.<%=UserConstants.IE_FILIALA_ID%>[ document.zaforma.<%=UserConstants.IE_FILIALA_ID%>.selectedIndex].value;
                            var params = "parentId=" + filialaId + "&selectName=<%=UserConstants.IE_SUCURSALA_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                            //alert( params);

                            if (filialaId == -1) return;

                            getCategoriesFromServer(params, function (originalRequest) {
                                //alert(getResponseMesg(originalRequest.responseText));
                                $('ie_sucursalaDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                                document.zaforma.<%=UserConstants.IE_SUCURSALA_ID%>.onchange = ie_on_sucursala_changed;
                            });
                        }

                        function ie_fill_centru_select(selectedValue, disabled, parentId) {
                            resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.IE_CENTRU_ID%>);

                            var sucursalaId = (parentId ? parentId : document.zaforma.<%=UserConstants.IE_SUCURSALA_ID%>[ document.zaforma.<%=UserConstants.IE_SUCURSALA_ID%>.selectedIndex].value);

                            if (sucursalaId == -1) return;
                            var params = "parentId=" + sucursalaId + "&selectName=<%=UserConstants.IE_CENTRU_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                            //alert( params);

                            getCategoriesFromServer(params, function (originalRequest) {
                                //alert(getResponseMesg(originalRequest.responseText));
                                $('ie_centruDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                                document.zaforma.<%=UserConstants.IE_CENTRU_ID%>.onchange = ie_on_centru_changed;
                            });
                        }

                        function ie_fill_formatia_select(selectedValue, disabled, parentId) {
                            resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.IE_FORMATIA_ID%>);
                            var centruId = (parentId ? parentId : document.zaforma.<%=UserConstants.IE_CENTRU_ID%>[ document.zaforma.<%=UserConstants.IE_CENTRU_ID%>.selectedIndex].value);

                            if (centruId == -1) return;
                            var params = "parentId=" + centruId + "&selectName=<%=UserConstants.IE_FORMATIA_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                            //alert( params);

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

                    </script>
                </td>
            </tr>


            <tr valign="top">
                <td><b>Drepturi:</b>&nbsp;&nbsp;</td>
                <td>
                    <input type="checkbox" name="<%=UserConstants.IE_RIGHT_ARHIVARE%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           id="<%=UserConstants.IE_RIGHT_ARHIVARE%>" <%=UserUtils.hasIeRightArhivare(useru) ? "checked" : ""%> >
                    <label for="<%=UserConstants.IE_RIGHT_ARHIVARE%>"><%=UserConstants.IE_LABEL_ARHIVARE%>
                    </label>&nbsp;

                    <input type="checkbox" name="<%=UserConstants.IE_RIGHT_RAPOARTE_INCIDENTE%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           id="<%=UserConstants.IE_RIGHT_RAPOARTE_INCIDENTE%>" <%=UserUtils.hasIeRightRapoarteIncidente(useru) ? "checked" : ""%> >
                    <label for="<%=UserConstants.IE_RIGHT_RAPOARTE_INCIDENTE%>"><%=UserConstants.IE_LABEL_RAPOARTE_INCIDENTE%>
                    </label>&nbsp;

                    <input type="checkbox" name="<%=UserConstants.IE_RIGHT_TRIMITERE_IE%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           id="<%=UserConstants.IE_RIGHT_TRIMITERE_IE%>" <%=UserUtils.hasIeRightTrimitereIE(useru) ? "checked" : ""%>>
                    <label for="<%=UserConstants.IE_RIGHT_TRIMITERE_IE%>"><%=UserConstants.IE_LABEL_TRIMITERE_IE%>
                    </label>&nbsp;

                    <input type="checkbox" name="<%=UserConstants.IE_RIGHT_VIZUALIZARE_VOLUM_INSTALATII%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           id="<%=UserConstants.IE_RIGHT_VIZUALIZARE_VOLUM_INSTALATII%>" <%=UserUtils.hasIeRightVizualizareVolumInstalatii(useru) ? "checked" : ""%>>
                    <label for="<%=UserConstants.IE_RIGHT_VIZUALIZARE_VOLUM_INSTALATII%>"><%=UserConstants.IE_LABEL_VIZUALIZARE_VOLUM_INSTALATII%>
                    </label>&nbsp;

                    <input type="checkbox" name="<%=UserConstants.IE_RIGHT_VIZUALIZARE_NOMENCLATOR_BDI%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           id="<%=UserConstants.IE_RIGHT_VIZUALIZARE_NOMENCLATOR_BDI%>" <%=UserUtils.hasIeRightVizualizareNomenclatorBDI(useru) ? "checked" : ""%>>
                    <label for="<%=UserConstants.IE_RIGHT_VIZUALIZARE_NOMENCLATOR_BDI%>"><%=UserConstants.IE_LABEL_VIZUALIZARE_NOMENCLATOR_BDI%>
                    </label>&nbsp;
                </td>
            </tr>
        </table>
    </div>

</fieldset>


<%---------------------------------- Call center / Deranjamente--%>
<fieldset style="margin: 0; cursor: default;">
<legend><input type="checkbox" onclick="onAppDeranjamenteClick()"
               name="<%=UserConstants.APP_CALLCENTER_DERANJAMENTE%>" <%=useru.isCcAccess() ? "checked" : ""%>
               value="<%=RoleConstants.CHECKED_VALUE%>" id="appDeranjamente"><label for="appDeranjamente">Call
    center / Deranjamente</label>
</legend>

<table border="0" style="font-size:13px" cellspacing="0" cellpadding="0" width="100%">
<tr>
    <td width="200px"><b>Rol:</b></td>
    <td>
        <input type="radio"
               name="<%=UserConstants.ROLES_CALLCENTER_DERANJAMENTE%>" <%=useru.getCcRole() == RoleConstants.ROL_ADMIN ? "checked" : ""%>
               value="<%=RoleConstants.ROL_ADMIN%>" id="rdAdmin"><label
            for="rdAdmin">Administrator</label> &nbsp;&nbsp;&nbsp;
        <input type="radio"
               name="<%=UserConstants.ROLES_CALLCENTER_DERANJAMENTE%>" <%=useru.getCcRole() == RoleConstants.ROL_UTILIZATOR ? "checked" : ""%>
               value="<%=RoleConstants.ROL_UTILIZATOR%>" id="rdWorker"><label
            for="rdWorker">Utilizator</label>
        &nbsp;&nbsp;&nbsp;
        <input type="radio"
               name="<%=UserConstants.ROLES_CALLCENTER_DERANJAMENTE%>" <%=useru.getCcRole() == RoleConstants.ROL_VIEW ? "checked" : ""%>
               value="<%=RoleConstants.ROL_VIEW%>" id="rdView"><label for="rdView">View</label>
        &nbsp;&nbsp;&nbsp;
    </td>
</tr>

<tr valign="top">
    <td><b>Zona:</b></td>
    <td>
        <table border="0">
            <tr>
                <td width="150">Filiala:</td>
                <td>
                    <% Category[] cc_filiale = CategoryAccessDB.getAllCategoriesByParentId(-1); %>
                    <select class="gSAPSelect" name="<%=UserConstants.CC_FILIALA_ID%>"
                            onchange="cc_on_filiala_changed()">
                        <option value="-1">Selectati:</option>
                        <% for (int cc_i = 0; cc_i < cc_filiale.length; cc_i++) {
                            Category cc_category = cc_filiale[cc_i]; %>
                        <option value="<%=cc_category.getId()%>" <%=cc_category.getId() == ccFilialaSelectata.getId() ? "selected" : ""%> ><%=cc_category.getName()%>
                        </option>
                        <% }%>
                    </select>
                </td>
            </tr>
            <tr>
                <td>Sucursala:</td>
                <td>
                    <span id="cc_sucursalaDiv">
                        <select id="<%=UserConstants.CC_SUCURSALA_ID%>" name="<%=UserConstants.CC_SUCURSALA_ID%>" class="gSAPSelect">
                            <option value="-1">Selectati:</option>
                        </select>
                    </span>
                </td>
            </tr>
            <tr>
                <td>C.E.:</td>
                <td>
                    <span id="cc_centruDiv">
                        <SELECT id="<%=UserConstants.CC_CENTRU_ID%>" name="<%=UserConstants.CC_CENTRU_ID%>" class="gSAPSelect">
                            <OPTION value="-1">Selectati:</OPTION>
                        </SELECT>
                    </span>
                </td>
            </tr>
            <tr>
                <td>Formatia de lucru:</td>
                <td>
                    <span id="cc_formatiaDiv">
                        <SELECT id="<%=UserConstants.CC_FORMATIA_ID%>" name="<%=UserConstants.CC_FORMATIA_ID%>" class="gSAPSelect">
                            <OPTION value="-1">Selectati:</OPTION>
                        </SELECT>
                    </span>
                </td>
            </tr>
        </table>

        <script type="text/javascript">

            function cc_on_filiala_changed() {
                cc_fill_sucursala_select();
                resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.CC_CENTRU_ID%>);
                resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.CC_FORMATIA_ID%>);
            }

            function cc_on_sucursala_changed() {
                cc_fill_centru_select();
                resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.CC_FORMATIA_ID%>);
            }

            function cc_on_centru_changed() {
                cc_fill_formatia_select();
            }

            function cc_fill_sucursala_select(selectedValue, disabled) {
                resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.CC_SUCURSALA_ID%>);

                var filialaId = document.zaforma.<%=UserConstants.CC_FILIALA_ID%>[ document.zaforma.<%=UserConstants.CC_FILIALA_ID%>.selectedIndex].value;
                var params = "parentId=" + filialaId + "&selectName=<%=UserConstants.CC_SUCURSALA_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                //alert( params);

                if (filialaId == -1) return;

                getCategoriesFromServer(params, function (originalRequest) {
                    //$('cc_sucursalaDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                    jQuery('#cc_sucursalaDiv').html(getResponseMesg(originalRequest.responseText));
                    $('<%=UserConstants.CC_SUCURSALA_ID%>').onchange = cc_on_sucursala_changed;
                });
            }

            function cc_fill_centru_select(selectedValue, disabled, parentId) {
                resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.CC_CENTRU_ID%>);
                var sCombo = $('<%=UserConstants.CC_SUCURSALA_ID%>');
                var sucursalaId = (parentId ? parentId : sCombo[sCombo.selectedIndex].value);

                if (sucursalaId == -1) return;
                var params = "parentId=" + sucursalaId + "&selectName=<%=UserConstants.CC_CENTRU_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                //alert( params);

                getCategoriesFromServer(params, function (originalRequest) {
                    //alert( getResponseMesg (originalRequest.responseText));
                    $('cc_centruDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                    $('<%=UserConstants.CC_CENTRU_ID%>').onchange = cc_on_centru_changed;
                });
            }

            function cc_fill_formatia_select(selectedValue, disabled, parentId) {
                resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.CC_FORMATIA_ID%>);
                var cCombo = $('<%=UserConstants.CC_CENTRU_ID%>');
                var centruId = (parentId ? parentId : cCombo[ cCombo.selectedIndex].value);

                if (centruId == -1) return;
                var params = "parentId=" + centruId + "&selectName=<%=UserConstants.CC_FORMATIA_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                //alert( params);

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

        </script>
    </td>
</tr>


<tr valign="top">
    <td><b>Zona+:</b></td>
    <td>
        <%Category.ArboreView categs[] = CategoryAccessDB.getAllCategoriesArboreView("");%>
<span id="locatieSelectTemplate" style="display:none">
<select class="gSAPSelect" name="<%=UserConstants.ID_LOCATII_SUPL%>">
    <option>Selectati:</option>
    <% for (int indexfor3 = 0; indexfor3 < categs.length; indexfor3++) {
        Category.ArboreView categ = categs[indexfor3]; %>

    <option class="<%=categ.isF()?"f":categ.isS()?"s":categ.isC()?"c":""%>"
            value="<%=categ.getId()%>"><%=categ.getFullPath(" - ")%>
    </option>
    <% } %>
</select>
<input type="button" value="-" onclick="stergeLocatieSelect(this.parentNode.parentNode);">
</span>

        <table border="0">
            <tr valign="bottom">
                <td>
                    <% Long[] ids = UserUtils.getIdLocatiiSuplAsArray(useru); %>
                    <table border="0" border="0" id="locatii">
                        <% for (int indexfor1 = 0; indexfor1 < ids.length; indexfor1++) {
                            Long id = ids[indexfor1]; %>
                        <tr>
                            <td nowrap>
                                <select id="zonaplusselect" class="gSAPSelect"
                                        name="<%=UserConstants.ID_LOCATII_SUPL%>">
                                    <option>Selectati:</option>
                                    <% for (int k = 0; k < categs.length; k++) {
                                        Category.ArboreView categ = categs[k]; %>

                                    <option <%=categ.getId() == id.longValue() ? "selected" : ""%>
                                            class="<%=categ.isF()?"f":categ.isS()?"s":categ.isC()?"c":""%>"
                                            value="<%=categ.getId()%>"><%=categ.getFullPath(" - ")%>
                                    </option>
                                    <% } %>
                                </select>
                                <input id="minusbutton" type="button" value="-"
                                       onclick="stergeLocatieSelect(this.parentNode.parentNode);">
                            </td>
                        </tr>
                        <% } %>
                    </table>
                </td>
                <td style="padding-bottom: 3px">
                    <input id="plusbutton" type="button" value=" + " onclick="addLocatieSelect()">
                </td>
            </tr>
        </table>

        <script type="text/javascript">
            var table = $("locatii");

            function addLocatieSelect() {
                var rowCount = table.rows.length;
                var row = table.insertRow(rowCount);

                var td = row.insertCell(0);
                td.noWrap = true;
                td.innerHTML = $("locatieSelectTemplate").innerHTML;
            }

            function stergeLocatieSelect(tr) {
                var rows = table.rows;
                var index = -1;
                for (var i = 0; i < rows.length; i++) {
                    if (rows[i] == tr) {
                        index = i;
                        break;
                    }
                }

                if (index >= 0) {
                    table.deleteRow(i);
                }
            }
        </script>
        <span style="font-size:10px">Nota: Alocarea utilizatorului la alte locatii decit cea specificata in sectiunea <b>Zona</b></span>
    </td>
</tr>
<%if (AppConstants.CIR_ACTIV) {%>
<tr>
    <td><b>CIR:</b></td>
    <td>
        <select name="<%=UserConstants.COD_CIR%>" class="gSAPSelect" id="cir">
            <option value="-1">Selectati:</option>
            <% Nomenclator[] cirs = NomAccessDB.getAllNom(NomConstants.NOM_CIR);%>
            <% for (int indexfor = 0; indexfor < cirs.length; indexfor++) {
                Nomenclator cir = cirs[indexfor]; %>
            <option value="<%=cir.getCod()%>" <%=cir.getCod() == useru.getCcCodCir() ? "selected" : ""%> ><%=cir.getDescriere()%>
            </option>
            <%}%>
        </select>
    </td>
</tr>
<%}%>

<tr valign="top">
    <td><b>Drepturi:</b></td>
    <td>
        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_INREGISTRARE_RECLAMATII%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_INREGISTRARE_RECLAMATII%>" <%=UserUtils.hasCcRightInregistrareReclamatii(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_INREGISTRARE_RECLAMATII%>"><%=UserConstants.CC_LABEL_INREGISTRARE_RECLAMATII%>
        </label> &nbsp;

        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_ATASARE_RECLAMATII%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_ATASARE_RECLAMATII%>" <%=UserUtils.hasCcRightAtasareReclamatii(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_ATASARE_RECLAMATII%>"><%=UserConstants.CC_LABEL_ATASARE_RECLAMATII%>
        </label> &nbsp;

        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_LITTLE_INCIDENTE%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_LITTLE_INCIDENTE%>" <%=UserUtils.hasCcRightEditareLittleIncidente(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_LITTLE_INCIDENTE%>"><%=UserConstants.CC_LABEL_LITTLE_INCIDENTE%>
        </label>&nbsp;

        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_DERANJAMENTE%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_DERANJAMENTE%>" <%=UserUtils.hasCcRightEditareDeranjamente(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_DERANJAMENTE%>"><%=UserConstants.CC_LABEL_DERANJAMENTE%>
        </label>&nbsp;

        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_LUCRARI_PROGRAMATE%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_LUCRARI_PROGRAMATE%>" <%=UserUtils.hasCcRightEditareLucrariProgramate(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_LUCRARI_PROGRAMATE%>"><%=UserConstants.CC_LABEL_LUCRARI_PROGRAMATE%>
        </label> <br>

        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_CLIENTI_ELIGIBILI%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_CLIENTI_ELIGIBILI%>" <%=UserUtils.hasCcRightEditareClientiEligibili(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_CLIENTI_ELIGIBILI%>"><%=UserConstants.CC_LABEL_CLIENTI_ELIGIBILI%>
        </label>&nbsp;

        <input type="checkbox" onclick="Element.toggle('flagsRapoarteDeranjamente')"
               name="<%=UserConstants.CC_RIGHT_RAPOARTE_DERANJAMENTE%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_RAPOARTE_DERANJAMENTE%>" <%=UserUtils.hasCcRightRapoarteDeranjamente(useru) ? "checked" : ""%> >
        <label
                for="<%=UserConstants.CC_RIGHT_RAPOARTE_DERANJAMENTE%>"><%=UserConstants.CC_LABEL_RAPOARTE_DERANJAMENTE%>
        </label>&nbsp;

        <input type="checkbox" name="<%=UserConstants.CC_RIGHT_ALOCARE_LOCALITATI_CENTRE%>"
               value="<%=RoleConstants.CHECKED_VALUE%>"
               id="<%=UserConstants.CC_RIGHT_ALOCARE_LOCALITATI_CENTRE%>" <%=UserUtils.hasCcRightAlocareLocalitatiCentre(useru) ? "checked" : ""%>>
        <label
                for="<%=UserConstants.CC_RIGHT_ALOCARE_LOCALITATI_CENTRE%>"><%=UserConstants.CC_LABEL_ALOCARE_LOCALITATI_CENTRE%>
        </label>&nbsp;


        <div id="flagsRapoarteDeranjamente"
             style="padding-left: 30px;<% if( !UserUtils.hasCcRightRapoarteDeranjamente(useru)){ %> display:none;<%}%>">
            <% int indexRapoarte = 0; %>
            <input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                   name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte) ) {%>
                   checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport indicatori performanta distributie (raport anual)</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte) ){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport indicatori performanta furnizare (raport anual)</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Energia electrica nelivrata consumatorilor datorita producerii
            deranjamentelor</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Situatia sintetica a deranjamentelor produse</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Situatia sintetica a deranjamentelor individual colectiv</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Registrul de Deranjamente</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Statistica evenimentelor produse in instalatiile de JT</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Zilnic</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Evenimente Cauze</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Provizorate</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Deranjamente cu emitere comanda catre AISE</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Deranjamente cu referat catre S.O CEMTJT</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Reclamatii</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Reclamatii grupate dupa continut sesizare</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Motive solicitari informatii</label>
            <br/><input type="checkbox" id="rd<%=indexRapoarte%>" value="<%=RoleConstants.CHECKED_VALUE%>"
                        name="rd<%=indexRapoarte%>" <%if( UserUtils.hasRightRaportDeranjamente(useru, indexRapoarte)){%>
                        checked <%}%> > <label
                for="rd<%=indexRapoarte++%>"> Raport Solicitari informatii</label>
        </div>
    </td>
</tr>
</table>
</fieldset>


<%----------------------------------------- Lucrari programate--%>
<fieldset style="margin: 0; cursor: default;">
    <legend><input onclick="onAppLpClick()" type="checkbox"
                   name="<%=UserConstants.APP_LUCRARI_PROGRAMATE%>" <%=useru.isLpAccess() ? "checked" : ""%>
                   value="1" id="appLp"><label for="appLp">Lucrari programate</label></legend>

    <table border="0" style="font-size:13px" cellspacing="0" cellpadding="0" width="100%">
        <tr valign="top">
            <td width="200px"><b>Rol:</b></td>
            <td>
                <input type="radio"
                       name="<%=UserConstants.ROLES_LUCRARI_PROGRAMATE%>" <%=useru.getLpRole() == RoleConstants.ROL_UTILIZATOR ? "checked" : ""%>
                       value="<%=RoleConstants.ROL_UTILIZATOR%>" id="lpWorker"><label for="lpWorker">Utilizator</label>
                &nbsp;&nbsp;&nbsp;
                <input type="radio"
                       name="<%=UserConstants.ROLES_LUCRARI_PROGRAMATE%>" <%=useru.getLpRole() == RoleConstants.ROL_VIEW ? "checked" : ""%>
                       value="<%=RoleConstants.ROL_VIEW%>" id="lpView"><label for="lpView">View</label> &nbsp;&nbsp;&nbsp;
            </td>
        </tr>


        <tr valign="top">
            <td><b>Zona:</b></td>
            <td>
                <table border="0">
                    <tr>
                        <td width="150">Filiala:</td>
                        <td>
                            <% Category[] lp_filiale = CategoryAccessDB.getAllCategoriesByParentId(-1); %>
                            <select class="gSAPSelect" name="<%=UserConstants.LP_FILIALA_ID%>"
                                    onchange="lp_on_filiala_changed()">
                                <option value="-1">Selectati:</option>
                                <% for (int lp_i = 0; lp_i < lp_filiale.length; lp_i++) {
                                    Category lp_category = lp_filiale[lp_i]; %>
                                <option value="<%=lp_category.getId()%>" <%=lp_category.getId() == lpFilialaSelectata.getId() ? "selected" : ""%> ><%=lp_category.getName()%>
                                </option>
                                <% }%>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>Sucursala:</td>
                        <td>
                                                        <span id="lp_sucursalaDiv">
                                                        <select id="<%=UserConstants.LP_SUCURSALA_ID%>"
                                                                name="<%=UserConstants.LP_SUCURSALA_ID%>"
                                                                class="gSAPSelect">
                                                            <option value="-1">Selectati:</option>
                                                        </select>
                                                        </span>
                        </td>
                    </tr>
                    <tr>
                        <td>C.E.:</td>
                        <td>
                                                        <span id="lp_centruDiv">
                                                            <SELECT id="<%=UserConstants.LP_CENTRU_ID%>"
                                                                    name="<%=UserConstants.LP_CENTRU_ID%>"
                                                                    class="gSAPSelect">
                                                                <OPTION value="-1">Selectati:</OPTION>
                                                            </SELECT>
                                                        </span>
                        </td>
                    </tr>
                    <tr>
                        <td>Formatia de lucru:</td>
                        <td>
                                                        <span id="lp_formatiaDiv">
                                                            <SELECT id="<%=UserConstants.LP_FORMATIA_ID%>"
                                                                    name="<%=UserConstants.LP_FORMATIA_ID%>"
                                                                    class="gSAPSelect">
                                                                <OPTION value="-1">Selectati:</OPTION>
                                                            </SELECT>
                                                        </span>
                        </td>
                    </tr>
                </table>

                <script type="text/javascript">

                    function lp_on_filiala_changed() {
                        lp_fill_sucursala_select();
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.LP_CENTRU_ID%>);
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.LP_FORMATIA_ID%>);
                    }

                    function lp_on_sucursala_changed() {
                        lp_fill_centru_select();
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.LP_FORMATIA_ID%>);
                    }

                    function lp_on_centru_changed() {
                        lp_fill_formatia_select();
                    }

                    function lp_fill_sucursala_select(selectedValue, disabled) {
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.LP_SUCURSALA_ID%>);

                        var filialaId = document.zaforma.<%=UserConstants.LP_FILIALA_ID%>[ document.zaforma.<%=UserConstants.LP_FILIALA_ID%>.selectedIndex].value;
                        var params = "parentId=" + filialaId + "&selectName=<%=UserConstants.LP_SUCURSALA_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                        //alert( params);

                        if (filialaId == -1) return;

                        getCategoriesFromServer(params, function (originalRequest) {
                            //alert(getResponseMesg(originalRequest.responseText));
                            $('lp_sucursalaDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                            document.zaforma.<%=UserConstants.LP_SUCURSALA_ID%>.onchange = lp_on_sucursala_changed;
                        });
                    }

                    function lp_fill_centru_select(selectedValue, disabled, parentId) {
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.LP_CENTRU_ID%>);

                        var sucursalaId = (parentId ? parentId : document.zaforma.<%=UserConstants.LP_SUCURSALA_ID%>[ document.zaforma.<%=UserConstants.LP_SUCURSALA_ID%>.selectedIndex].value);

                        if (sucursalaId == -1) return;
                        var params = "parentId=" + sucursalaId + "&selectName=<%=UserConstants.LP_CENTRU_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                        //alert( params);

                        getCategoriesFromServer(params, function (originalRequest) {
                            //alert(getResponseMesg(originalRequest.responseText));
                            $('lp_centruDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                            document.zaforma.<%=UserConstants.LP_CENTRU_ID%>.onchange = lp_on_centru_changed;
                        });
                    }

                    function lp_fill_formatia_select(selectedValue, disabled, parentId) {
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.LP_FORMATIA_ID%>);
                        var centruId = (parentId ? parentId : document.zaforma.<%=UserConstants.LP_CENTRU_ID%>[ document.zaforma.<%=UserConstants.LP_CENTRU_ID%>.selectedIndex].value);

                        if (centruId == -1) return;
                        var params = "parentId=" + centruId + "&selectName=<%=UserConstants.LP_FORMATIA_ID%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                        //alert( params);

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

                </script>
            </td>
        </tr>
    </table>
</fieldset>


<%-------------------------- Operatiuni dispecer--%>
<fieldset style="margin: 0; cursor: default;">
    <legend>
        <input type="checkbox" onclick="onAppDispecerClick()"
               name="<%=UserConstants.APP_OPERATIUNI_DISPECER%>" <%=useru.isOdAccess() ? "checked" : ""%> value="1"
               id="appD"><label for="appD">Dispecer</label>
    </legend>
    <table border="0" style="font-size:13px" cellspacing="0" cellpadding="0" width="100%">
        <tr>
            <td width="200px"><b>Rol:</b></td>
            <td>
                <input type="radio"
                       name="<%=UserConstants.ROLES_OPERATIUNI_DISPECER%>" <%=useru.getOdRole() == RoleConstants.ROL_UTILIZATOR  ? "checked" : ""%>
                       value="<%=RoleConstants.ROL_UTILIZATOR%>" id="odWorker"><label for="odWorker">Utilizator</label>
                &nbsp;&nbsp;&nbsp;
                <input type="radio"
                       name="<%=UserConstants.ROLES_OPERATIUNI_DISPECER%>" <%=useru.getOdRole() == RoleConstants.ROL_VIEW ? "checked" : ""%>
                       value="<%=RoleConstants.ROL_VIEW%>" id="odView"><label for="odView">View</label> &nbsp;&nbsp;&nbsp;
            </td>
        </tr>

        <tr valign="top">
            <td><b>Zona:</b></td>
            <td>
                <table border="0">
                    <tr>
                        <td width="150">Filiala:</td>
                        <td>
                            <% List filialeD = CategoryODAccessDB.getChildCategs(-1); %>
                            <select class="gSAPSelect" name="<%=UserConstants.OD_FILIALA_D%>"
                                    onchange="on_filiala_d_changed()">
                                <option value="-1">Selectati:</option>
                                <% for (int i = 0; i < filialeD.size(); i++) {
                                    ro.emid.common.types.CategoryOD category = (CategoryOD) filialeD.get(i); %>
                                <option value="<%=category.getId()%>" <%=category.getId() == useru.getOdFilialaD() ? "selected" : ""%> ><%=category.getName()%>
                                </option>
                                <% } %>
                            </select>
                        </td>
                    </tr>
                    <tr>
                        <td>DED:</td>
                        <td>
                                                        <span id="dedDiv">
                                                        <select name="<%=UserConstants.OD_DED%>" class="gSAPSelect">
                                                            <option value="-1">Selectati:</option>
                                                        </select>
                                                        </span>
                        </td>
                    </tr>
                    <tr>
                        <td>DED-L:</td>
                        <td>
                                                        <span id="dedlDiv">
                                                            <SELECT name="<%=UserConstants.OD_DEDL%>"
                                                                    class="gSAPSelect">
                                                                <OPTION value="-1">Selectati:</OPTION>
                                                            </SELECT>
                                                        </span>
                        </td>
                    </tr>
                </table>

                <script type="text/javascript">
                    function on_filiala_d_changed() {
                        fill_ded_select();
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.OD_DEDL%>);
                    }

                    function on_ded_changed() {
                        fill_dedl_select();
                    }

                    function fill_ded_select(selectedValue, disabled) {
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.OD_DED%>);

                        var filialaId = document.zaforma.<%=UserConstants.OD_FILIALA_D%>[ document.zaforma.<%=UserConstants.OD_FILIALA_D%>.selectedIndex].value;
                        var params = "parentId=" + filialaId + "&selectName=<%=UserConstants.OD_DED%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                        //alert(params);

                        if (filialaId == -1) return;

                        getCategoriesDispecerFromServer(params, function (originalRequest) {
                            //alert(getResponseMesg(originalRequest.responseText));
                            $('dedDiv').innerHTML = getResponseMesg(originalRequest.responseText);
                            document.zaforma.<%=UserConstants.OD_DED%>.onchange = on_ded_changed;
                        });
                    }

                    function fill_dedl_select(selectedValue, disabled, parentId) {
                        resetComboLeaveFirstOption(document.zaforma.<%=UserConstants.OD_DEDL%>);

                        var sucursalaId = (parentId ? parentId : document.zaforma.<%=UserConstants.OD_DED%>[ document.zaforma.<%=UserConstants.OD_DED%>.selectedIndex].value);

                        if (sucursalaId == -1) return;
                        var params = "parentId=" + sucursalaId + "&selectName=<%=UserConstants.OD_DEDL%>&disabled=" + disabled + (selectedValue ? "&selectedValue=" + selectedValue : "");
                        //alert(params);

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

                </script>
            </td>
        </tr>
    </table>
</fieldset>


<%---------------------  Administrare--%>
<fieldset style="margin: 0; cursor: default;">
    <legend>
        <input onclick="onAppAdministrareClick()" type="checkbox"
               name="<%=UserConstants.APP_ADMIN%>" <%=useru.isAdmAccess() ? "checked" : ""%>
               value="<%=RoleConstants.CHECKED_VALUE%>" id="appA"><label for="appA">Administrare</label>
    </legend>

    <table>
        <tr>
            <td width="200px">

            <td width="200px">
                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_UTILIZATORI%>"
                       onclick="Element.toggle('EditareUtilizatoriPerAplicatie')"
                       name="<%=UserConstants.ADM_RIGHT_UTILIZATORI%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightUtilizatori(useru) ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_UTILIZATORI%>"><%= UserConstants.ADM_LABEL_UTILIZATORI %>
            </label> &nbsp;
                <br/>

                <div id="EditareUtilizatoriPerAplicatie"
                     style="padding-left: 30px;width:300px; <% if( !UserUtils.hasAdmRightUtilizatori(useru)){ %> display:none;<%}%>">

                    <input type="checkbox" id="<%= UserConstants.ADM_RIGHT_UTILIZ_IE%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           name="<%= UserConstants.ADM_RIGHT_UTILIZ_IE%>" <%if( UserUtils.hasAdmRightUtilizatoriIncidente(useru)) {%>
                           checked <%}%> > <label
                        for="<%= UserConstants.ADM_RIGHT_UTILIZ_IE%>"><%= UserConstants.ADM_LABEL_UTILIZ_IE%>
                </label><br/>


                    <input type="checkbox" id="<%= UserConstants.ADM_RIGHT_UTILIZ_CC%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           name="<%= UserConstants.ADM_RIGHT_UTILIZ_CC%>" <%if( UserUtils.hasAdmRightUtilizatoriCallCenterDeranjamente(useru)) {%>
                           checked <%}%> > <label
                        for="<%= UserConstants.ADM_RIGHT_UTILIZ_CC%>"><%= UserConstants.ADM_LABEL_UTILIZ_CC%>
                </label><br/>


                    <input type="checkbox" id="<%= UserConstants.ADM_RIGHT_UTILIZ_LP%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           name="<%= UserConstants.ADM_RIGHT_UTILIZ_LP%>" <%if( UserUtils.hasAdmRightUtilizatoriLucrariProgramate(useru)) {%>
                           checked <%}%> > <label
                        for="<%= UserConstants.ADM_RIGHT_UTILIZ_LP%>"><%= UserConstants.ADM_LABEL_UTILIZ_LP%>
                </label><br/>


                    <input type="checkbox" id="<%= UserConstants.ADM_RIGHT_UTILIZ_OD%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           name="<%= UserConstants.ADM_RIGHT_UTILIZ_OD%>" <%if( UserUtils.hasAdmRightUtilizatoriOperatiuniDispecer(useru)) {%>
                           checked <%}%> > <label
                        for="<%= UserConstants.ADM_RIGHT_UTILIZ_OD%>"><%= UserConstants.ADM_LABEL_UTILIZ_OD%>
                </label><br/>


                    <input type="checkbox" id="<%= UserConstants.ADM_RIGHT_UTILIZ_ADM%>"
                           value="<%=RoleConstants.CHECKED_VALUE%>"
                           name="<%= UserConstants.ADM_RIGHT_UTILIZ_ADM%>" <%if( UserUtils.hasAdmRightUtilizatoriAdministrare(useru)) {%>
                           checked <%}%> > <label
                        for="<%= UserConstants.ADM_RIGHT_UTILIZ_ADM%>"><%= UserConstants.ADM_LABEL_UTILIZ_ADM%>
                </label><br/>
                </div>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_NOMENCLATOR_BDI%>"
                       name="<%=UserConstants.ADM_RIGHT_NOMENCLATOR_BDI%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightNomenclatoareBdi(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_NOMENCLATOR_BDI%>"><%=UserConstants.ADM_LABEL_NOMENCLATOR_BDI%>
            </label> &nbsp;
                <br/>


                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_NOMENCLATOR_GENERALE%>"
                       name="<%=UserConstants.ADM_RIGHT_NOMENCLATOR_GENERALE%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightNomenclatoareGenerale(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_NOMENCLATOR_GENERALE%>"><%=UserConstants.ADM_LABEL_NOMENCLATOR_GENERALE%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_VOLUM_INSTALATII%>"
                       name="<%=UserConstants.ADM_RIGHT_VOLUM_INSTALATII%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightVolumInstalatii(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_VOLUM_INSTALATII%>"><%=UserConstants.ADM_LABEL_VOLUM_INSTALATII%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_SESIUNI_RAPORTARE%>"
                       name="<%=UserConstants.ADM_RIGHT_SESIUNI_RAPORTARE%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightSesiuniRaportare(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_SESIUNI_RAPORTARE%>"><%=UserConstants.ADM_LABEL_SESIUNI_RAPORTARE%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_CONSTANTA_AD%>"
                       name="<%=UserConstants.ADM_RIGHT_CONSTANTA_AD%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightConstantaAD(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_CONSTANTA_AD%>"><%=UserConstants.ADM_LABEL_CONSTANTA_AD%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_PROPRIETATI%>"
                       name="<%=UserConstants.ADM_RIGHT_PROPRIETATI%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightProprietati(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_PROPRIETATI%>"><%=UserConstants.ADM_LABEL_PROPRIETATI%>
            </label> &nbsp;


            </td>
            <td width="200px" valign="top">

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_SEMNALIZARI%>"
                       name="<%=UserConstants.ADM_RIGHT_SEMNALIZARI%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightSemnalizari(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_SEMNALIZARI%>"><%=UserConstants.ADM_LABEL_SEMNALIZARI%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_CE_NIVELE_TENSIUNE%>"
                       name="<%=UserConstants.ADM_RIGHT_CE_NIVELE_TENSIUNE%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightCeNiveleTensiune(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_CE_NIVELE_TENSIUNE%>"><%=UserConstants.ADM_LABEL_CE_NIVELE_TENSIUNE%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_CE_DISPECERI%>"
                       name="<%=UserConstants.ADM_RIGHT_CE_DISPECERI%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightCeDispeceri(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_CE_DISPECERI%>"><%=UserConstants.ADM_LABEL_CE_DISPECERI%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_SYNC_AC_MANAGER%>"
                       name="<%=UserConstants.ADM_RIGHT_SYNC_AC_MANAGER%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightSyncAcManager(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_SYNC_AC_MANAGER%>"><%=UserConstants.ADM_LABEL_SYNC_AC_MANAGER%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_MESSAGE%>"
                       name="<%=UserConstants.ADM_RIGHT_MESSAGE%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightMessage(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_MESSAGE%>"><%=UserConstants.ADM_LABEL_MESSAGE%>
            </label> &nbsp;
                <br/>

                <input type="checkbox" id="<%=UserConstants.ADM_RIGHT_LOGURI%>"
                       name="<%=UserConstants.ADM_RIGHT_LOGURI%>"
                       value="<%=RoleConstants.CHECKED_VALUE%>"
                    <%=UserUtils.hasAdmRightLoguri(useru)  ? "checked" : ""%>><label
                    for="<%=UserConstants.ADM_RIGHT_LOGURI%>"><%=UserConstants.ADM_LABEL_LOGURI%>
            </label> &nbsp;


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


</td>
<tr>
    <td></td>
    <td>
        <input type="submit" value="Salvează"> &nbsp;&nbsp;&nbsp;
        <input type="button" value="Renunţă"
                <% if(useru.getId() == -1){ %>
                    onclick="redirectTo('<%=GlobalAppConstants.APP_NAME%>?action=show-users');">
                <% }else{ %>
                    onclick="redirectTo('<%=GlobalAppConstants.APP_NAME%>?action=view-user&id=<%=useru.getId()%>');">
                <% } %>
    </td>
</tr>
</TABLE>
</form>

<script type="text/javascript">

    function onAppIncidenteClick() {
        var enable = $('appIncidente').checked;
        $('ieAdmin').disabled = !enable;
        $('ieWorker').disabled = !enable;
        $('ieView').disabled = !enable;

        try {
            document.zaforma.<%=UserConstants.IE_FILIALA_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.IE_SUCURSALA_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.IE_CENTRU_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.IE_FORMATIA_ID%>.disabled = !enable;
        } catch (e) {
        }

        $('<%=UserConstants.IE_RIGHT_ARHIVARE%>').disabled = !enable;
        $('<%=UserConstants.IE_RIGHT_RAPOARTE_INCIDENTE%>').disabled = !enable;
        $('<%=UserConstants.IE_RIGHT_TRIMITERE_IE%>').disabled = !enable;
        $('<%=UserConstants.IE_RIGHT_VIZUALIZARE_VOLUM_INSTALATII%>').disabled = !enable;
        $('<%=UserConstants.IE_RIGHT_VIZUALIZARE_NOMENCLATOR_BDI%>').disabled = !enable;
    }

    function onAppDeranjamenteClick() {
        var enable = $('appDeranjamente').checked;

        $('rdAdmin').disabled = !enable;
        $('rdWorker').disabled = !enable;
        $('rdView').disabled = !enable;
        try {
            document.zaforma.<%=UserConstants.CC_FILIALA_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.CC_SUCURSALA_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.CC_CENTRU_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.CC_FORMATIA_ID%>.disabled = !enable;
            document.zaforma.plusbutton.disabled = !enable;
            document.zaforma.minusbutton.disabled = !enable;
            document.zaforma.zonaplusselect.disabled = !enable;
        } catch (e) {
        }
        $('<%=UserConstants.CC_RIGHT_INREGISTRARE_RECLAMATII%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_ATASARE_RECLAMATII%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_LITTLE_INCIDENTE%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_DERANJAMENTE%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_LUCRARI_PROGRAMATE%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_CLIENTI_ELIGIBILI%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_RAPOARTE_DERANJAMENTE%>').disabled = !enable;
        $('<%=UserConstants.CC_RIGHT_ALOCARE_LOCALITATI_CENTRE%>').disabled = !enable;
        try {
            var cirCombo = $('cir');
            cirCombo.disabled = !enable;

            if (cirCombo.disabled) selectOption(cirCombo, -1);
        } catch (e) {
        }
    }

    function onAppLpClick() {
        var enable = $('appLp').checked;

        $('lpWorker').disabled = !enable;
        $('lpView').disabled = !enable;

        try {
            document.zaforma.<%=UserConstants.LP_FILIALA_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.LP_SUCURSALA_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.LP_CENTRU_ID%>.disabled = !enable;
            document.zaforma.<%=UserConstants.LP_FORMATIA_ID%>.disabled = !enable;
        } catch (e) {
        }
    }

    function onAppDispecerClick() {
        var enable = $('appD').checked;

        $('odWorker').disabled = !enable;
        $('odView').disabled = !enable;

        try {
            document.zaforma.<%=UserConstants.OD_FILIALA_D%>.disabled = !enable;
            document.zaforma.<%=UserConstants.OD_DED%>.disabled = !enable;
            document.zaforma.<%=UserConstants.OD_DEDL%>.disabled = !enable;
        } catch (e) {
        }
    }

    function onAppAdministrareClick() {
        var enable = $('appA').checked;
        $('<%=UserConstants.ADM_RIGHT_UTILIZATORI%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_NOMENCLATOR_BDI%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_NOMENCLATOR_GENERALE%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_VOLUM_INSTALATII%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_SESIUNI_RAPORTARE%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_CONSTANTA_AD%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_PROPRIETATI%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_SEMNALIZARI%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_CE_NIVELE_TENSIUNE%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_CE_DISPECERI%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_SYNC_AC_MANAGER%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_MESSAGE%>').disabled = !enable;
        $('<%=UserConstants.ADM_RIGHT_LOGURI%>').disabled = !enable;
    }

    jQuery(document).ready(function(){
        onAppIncidenteClick();
        onAppDeranjamenteClick();
        onAppLpClick();
        onAppDispecerClick();
        onAppAdministrareClick();

        ie_fill_sucursala_select(<%=ieSucursalaSelectata.getId()%>);
        ie_fill_centru_select(<%=ieCentruSelectat.getId()%>, false, <%=ieSucursalaSelectata.getId()%>);
        ie_fill_formatia_select(<%=ieFormatiaSelectata.getId()%>, false, <%=ieCentruSelectat.getId()%>);

        cc_fill_sucursala_select(<%=ccSucursalaSelectata.getId()%>);
        cc_fill_centru_select(<%=ccCentruSelectat.getId()%>, false, <%=ccSucursalaSelectata.getId()%>);
        cc_fill_formatia_select(<%=ccFormatiaSelectata.getId()%>, false, <%=ccCentruSelectat.getId()%>);

        lp_fill_sucursala_select(<%=lpSucursalaSelectata.getId()%>);
        lp_fill_centru_select(<%=lpCentruSelectat.getId()%>, false, <%=lpSucursalaSelectata.getId()%>);
        lp_fill_formatia_select(<%=lpFormatiaSelectata.getId()%>, false, <%=lpCentruSelectat.getId()%>);

        fill_ded_select(<%=useru.getOdDedId()%>);
        fill_dedl_select(<%=useru.getOdDedLId()%>, false, <%=useru.getOdDedId()%>);
    });

</script>
<%@ include file="../../message.jsp" %>

