<%@ page import="ro.emid.common.db.ReclamatieAccessDB" %>
<%@ page import="ro.emid.common.types.Reclamatie" %>
<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.utils.Util" %>
<%@ page import="ro.emid.common.utils.UserUtils" %>
<%@ page import="ro.emid.common.types.User" %>
<%@ page import="ro.emid.common.utils.SessionUtils" %>


<respmesg>
    <% try{
        final User user = SessionUtils.getUserLogat(session);
        final long idObj = ObjectUtils.getLongValue( request.getParameter("idObj"));
        final long objType = ObjectUtils.getLongValue(request.getParameter("objType"));
        final long idPrimaReclamatie = ObjectUtils.getLongValue(request.getParameter("idPrimaReclamatie"));

        final Reclamatie[] reclamatii = ReclamatieAccessDB.getAll(" AND OBJECT_TYPE =" + objType  + " AND LEGAT_OBJECT_ID = " + idObj, "DATA", "ASC");
%>

<% if( reclamatii == null || reclamatii.length == 0){ %>
    Fără reclamaţii ataşate ...
<% }else{ %>

    <table class="table">
        <% for (int i = 0; i < reclamatii.length; i++) {
            final Reclamatie reclamatie = reclamatii[i]; %>

            <tr title="<%=Util.escapeToHtml( reclamatie.getMobil() != null ? "Nr. telefon: " + reclamatie.getMobil() : reclamatie.getFix() != null ? "Nr. telefon: " + reclamatie.getFix() : "Fara telefon")%>, dubluclick pentru mai multe detalii ..." ondblclick="showDateReclamatie(<%=reclamatie.getId()%>)">
                <td><%=reclamatie.getTitlu()%></td>
                <td width="1%">
                    <% if(UserUtils.hasRoleAdminCallcenter(user) || UserUtils.hasRoleUtilizatorCallcenter(user)) {%>
                        <a class="link" href="#" onclick="scoateReclamatieCuAjax('<%=reclamatie.getId()%>', '<%=reclamatie.getObjectId()%>', <%=reclamatie.getId() == idPrimaReclamatie%>, <%=reclamatii.length%>); return false;">
                            Scoate
                        </a>
                    <% } %>
                </td>
            </tr>
        <% } %>
    </table>
<%  } %>
    
<% }catch (Throwable th){%>
    <%=th.getMessage()%>
<% } %>
</respmesg>