<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.utils.MenuConstants" %>
<%@ page import="ro.emid.Application" %>
<%@ taglib prefix="emid" tagdir="/WEB-INF/tags" %>

<%! private static boolean in(String value, String... values) {
    if (value == null) return false;
    if (values == null || value.length() == 0) return false;
    for (String s : values) {
        if (s != null && s.equals(value)) return true;
    }
    return false;
}%>

<%
    String jsp = (String) request.getAttribute("__jsp");
    if( jsp == null){
        response.sendRedirect( request.getContextPath() + request.getContextPath() +  ".default");
        return;
    }

    String selectedSubTab = "";
    String action = request.getParameter("action");

    if(in(action, "add-reclamatie-form")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_CALLCENTER;
    }else if(in(action, "atasare-reclamatii")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_ATASARE_RECLAMATII;
    }else if(in(action, "show-incidente", "edit-incident", "save-incident")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_INCIDENTE;
    }else if(in(action, "show-deranjamente", "edit-deranjament", "save-deranjament")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_DERANJAMENTE;
    }else if(in(action, "show-lucrari")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_LP_2;
    }else if(in(action, "show-clienti-eligibili")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_CLIENTI_ELIGIBILI;
    }else if(in(action, "show-clienti-eligibili", "editClientEligibil")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_CLIENTI_ELIGIBILI;
    }else if(in(action, "alocare-localitati", "localitati-nealocate", "syncLocalitatiOpen", "sync-adr-history", "edit-alocare-localitate-ce")) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_LOCALITATI_CENTRE;
    }else if(in(action, "rapoarte",
            "raport-deranjamente-anual",
            "raport-deranjamente-anual2",
            "raport-deranjamente-enc",
            "raport-deranjamente-situatia-sintetica",
            "raport-registrul-deranjamente",
            "raport-statistica-evenimentelor-jt",
            "raport-zilnic",
            "raport-evenimente-cauze",
            "raport-provizorate",
            "raport-reclamatii",
            "raport-reclamatii-per-sesizare",
            "raport-motive-solicitari-informatii",
            "raport-top10-motive-solicitari-informatii"
    )) {
        selectedSubTab = MenuConstants.CALLCENTER.LINK_RAPOARTE;
    }

%>
<%@include file="callcenter/declaratii.jsp"%>

<!DOCTYPE html>
<html>
<head>
    <title>EMID / Callcenter - [<%=AppProperties.getInstance().getVersion()%>]</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=EDGE" />

    <%@include file="layout/includes-emid.jspf"%>

    <link rel="stylesheet" type="text/css" href="<%=AppConstants.WEB_RESOURCE_PATH%>/styles/callcenter.css?<%=AppProperties.getInstance().getVersion()%>">

    <script type="text/javascript">
        var filtruDeranjamenteWindow = null;
        function showFiltruDeranjamente(){
            if( filtruDeranjamenteWindow != null) filtruDeranjamenteWindow.close();
            filtruDeranjamenteWindow = window.open('<%=AppConstants.APP_NAME%>?action=show-filtru-deranjamente','filtruDeranjamente', 'top=100,left=100,width=850, height=500, status=yes,resizable=yes,dependent=yes,alwaysRaised=yes');
        }

        var filtruIncidenteWindow = null;
        function showFiltruIncidente(){
            if( filtruIncidenteWindow != null) filtruIncidenteWindow.close();
            filtruIncidenteWindow = window.open('<%=AppConstants.APP_NAME%>?action=showFiltruIncidente','filtruIncidente', 'top=100,left=100,width=750, height=500, status=yes,resizable=yes,dependent=yes,alwaysRaised=yes');
        }

        var printLucrareWindow = null;
        function printLucrare( id){
            if( printLucrareWindow != null) printLucrareWindow.close();
            printLucrareWindow = window.open('<%=AppConstants.APP_NAME%>?action=printLucrare&id=' + id);
        }
    </script>
</head>
<body>

<div class="header">
    <%@include file="layout/header-emid.jspf"%>

    <div class="subTabsWrapper">
        <% if( Application.runAsAparatCentral()) {%>

        <a class="clean subitem" href="<%=AppConstants.APP_NAME%>?action=show-deranjamente" title="Lista Deranjamente">
            Deranjamente
        </a>&nbsp;&nbsp;|&nbsp;

        <% }else { %>

        <% if( UserUtils.hasCcRightInregistrareReclamatii(user) ){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_CALLCENTER)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=add-reclamatie-form" title="Adaugare reclamatii">Callcenter</a>
            </span>
        <span class="divider"></span>
        <%}%>

        <% if( UserUtils.hasRoleAdminCallcenter( user) || UserUtils.hasCcRightAtasareReclamatii(user)){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_ATASARE_RECLAMATII)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=atasare-reclamatii" title="Atasare reclamatii la incidente/deranjamente/lucrari programate">Ataşare reclamaţii</a>
            </span>
        <span class="divider"></span>
        <%}%>

        <% if( UserUtils.hasRoleAdminCallcenter( user) || UserUtils.hasCcRightEditareLittleIncidente( user)){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_INCIDENTE)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=show-incidente" title="Lista incidente">Incidente</a>
            </span>
        <span class="divider"></span>
        <%}%>

        <% if( UserUtils.hasRoleAdminCallcenter( user) || UserUtils.hasCcRightEditareDeranjamente( user)){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_DERANJAMENTE)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=show-deranjamente" title="Lista Deranjamente">Deranjamente</a>
            </span>
        <span class="divider"></span>
        <%}%>

        <% if( UserUtils.hasRoleAdminCallcenter( user)  || UserUtils.hasAccessCallcenter( user) || UserUtils.hasCcRightEditareLucrariProgramate( user)){%>
        <% if( AppConstants.MODUL_LP1_ENABLED ){ %>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_LP)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=showLucrari" title="Lista Lucrari Programate">LP</a>
            </span>
        <span class="divider"></span>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_LP_2)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=show-lucrari" title="Lista Lucrari Programate">LP 2</a>
            </span>
        <span class="divider"></span>
        <% } else { %>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_LP_2)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=show-lucrari" title="Lucrari Programate">Lucrări programate</a>
            </span>
        <span class="divider"></span>
        <% } %>
        <%}%>

        <% if( UserUtils.hasRoleAdminCallcenter( user) || UserUtils.hasCcRightEditareClientiEligibili( user)){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_CLIENTI_ELIGIBILI)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=show-clienti-eligibili" title="Clienti Eligibili">Clienţi eligibili</a>
            </span>
        <span class="divider"></span>
        <%}%>

        <% if( UserUtils.hasRoleAdminCallcenter( user) || UserUtils.hasCcRightAlocareLocalitatiCentre( user)){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_LOCALITATI_CENTRE)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=alocare-localitati" title="Alocare localitati pe centre">Localităţi / Centre</a>
            </span>
        <span class="divider"></span>
        <% } %>

        <% if( UserUtils.hasRoleAdminCallcenter( user)  || UserUtils.hasCcRightRapoarteDeranjamente( user)){%>
            <span class="subTab">
                <a class="clean subitem <%=selectedSubTab.equals(MenuConstants.CALLCENTER.LINK_RAPOARTE)?"selected":""%>" href="<%=AppConstants.APP_NAME%>?action=rapoarte" title="Rapoarte">Rapoarte</a>
            </span>
        <span class="divider"></span>
        <%}%>

        <% } %>
    </div>
</div>

<emid:messages/>

<div class="content">
    <jsp:include page="<%=jsp%>"/>
</div>

</body>
</html>



