<%@ page import="ro.emid.common.constants.EvenimentDispecerLogConstants" %>

<%@ page import="ro.emid.common.logger.EvenimentDispecerLog" %>
<%@ page import="ro.emid.common.utils.RequestUtils" %>

<%@ page import="ro.emid.common.utils.sort.SortController" %>
<%@ page import="ro.emid.common.utils.sort.SortData" %>
<%@ page import="java.util.List" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>



<%
    /**
     * showIstoricEveniment
     * @see ro.emid.administrare.action.admin.LoadIstoricEvenimentAction
     */

    final SortData sd = (SortData) request.getAttribute("sortData");
    final List list = (List) request.getAttribute("list");
%>

<table border=0 width="70%">
    <tr><td>
        <div class="spacer">&nbsp;</div>
        <form action="<%=AppConstants.APP_NAME%>?action=showIstoricEveniment" method="post">
            <%=SortController.initSort(sd)%>
            <table class="gsaptd" width="100%">
              <tr><td>

                  <input style="float:right;" type="button" value="Inapoi" onclick="window.history.back();">

                  ID :
                  <input type="text" name="idEveniment" size="18" value="<%=RequestUtils.getString( request, "idEveniment")%>" />
                  &nbsp;&nbsp;

                  <input type="submit" value="Afiseaza">
              </td></tr>
            </table>
        </form>
    </td></tr>
    <tr><td>
        <table cellpadding=2 width="100%" cellspacing=1 class="table">
            <thead>
                <tr>
                    <th nowrap width="1%" height=25><%=SortController.printSortableColumn("Data operatie:", EvenimentDispecerLogConstants.SQL_LOG.DATA_OP, sd)%></th>
                    <th nowrap width="2%"><%=SortController.printSortableColumn("Utilizator:", EvenimentDispecerLogConstants.SQL_LOG.DATA_OP, sd)%></th>
                    <th nowrap >Numar Eveniment</th>
                    <th nowrap width="1%">&nbsp;</th>
                </tr>
            </thead>
            <tbody>
            <% if( list == null || list.size() == 0){ %>
                <tr>
                    <td colspan="5" class="no-data">Nu exista date ...</td>
                </tr>
            <% } else for (int i = 0; i < list.size(); i++) {
                final EvenimentDispecerLog log = (EvenimentDispecerLog) list.get(i); %>

                <tr>
                    <td align="center" nowrap><%=AppConstants.format(log.getDataOperatie())%></td>
                    <td align="center" nowrap><%=AppConstants.format(log.getUserOperatie())%></td>
                    <td align="center" nowrap><%=AppConstants.format(log.getNumar())%></td>

                    <td>
                        <% if( i > 0){ %>
                            <% final EvenimentDispecerLog log_ = (EvenimentDispecerLog) list.get(i - 1); %>
                            [<a class="link" href="#" onclick="showModificari('<%=log.hashCode()%>', '<%=log_.getId()%>', '<%=log.getId()%>')">modificari</a>]
                        <% } %>
                    </td>
                </tr>
                <tr id="trLog<%=log.hashCode()%>" style="display: none">
                    <td id="tdLog<%=log.hashCode()%>" colspan="4" style="padding-left: 40px">

                    </td>
                </tr>

            <% } %>
            </tbody>
        </table>
    </td></tr>
</table>


<script type="text/javascript">

    function showModificari( id, idLog1, idLog2){
        var trId = "trLog" + id;
        var tdId = "tdLog" + id;
        if( Element.visible( trId)){
            Element.hide( trId);
        }else{
            $(tdId).innerHTML = "&nbsp;&nbsp;&nbsp; Se incarca ...";
            Element.addClassName( tdId, "loadingModificari");

            Element.show( trId);

            new Ajax.Request('<%=AppConstants.APP_NAME%>?action=getModificariEveniment',
            {
                method: 'post',
                parameters: "idLog1="+idLog1 + "&idLog2="+idLog2,
                onComplete: function( originalRequest){

                    Element.removeClassName( tdId, "loadingModificari");


                    var response = getResponseMesg( originalRequest.responseText);

                    
                    $(tdId).innerHTML = response;
                }
            });
        }
    }

</script>
