<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.job.JobRequest" %>
<%@ page import="ro.emid.common.utils.pagination.PaginationController" %>
<%@ page import="ro.emid.common.utils.pagination.PaginationData" %>
<%@ page import="ro.emid.common.job.JobConstants" %>


<%
        /**
         * @see ro.emid.administrare.sync.ac.LoadSyncAcHistoryAction
         */
    PaginationData pd = (PaginationData) request.getAttribute("pd");
    JobRequest[] jobs = (ro.emid.common.job.JobRequest[]) request.getAttribute("result");
%>


<div class="mb5">
    <span class="page-title">Istoric sincronizare date cu aparat central</span>
</div>

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

<form action="<%=AppConstants.APP_NAME%>?action=sync-ac-history" method="post">
<table cellpadding=2 cellspacing=1 width="100%" class="table mt10">
    <thead>
        <tr>
            <th>#</th>
            <th>Status</th>
            <th>Procedura</th>
            <th>Utilizator</th>
            <th>Data lansare</th>
            <th>Data start</th>
            <th>Data finis</th>
            <th>Detalii</th>
        </tr>
    </thead>
    <tbody>
    <% if (jobs.length == 0) { %>
        <tr>
            <td colspan="10" class="no-data"> Nu exista comenzi de sincronizare ...</td>
        </tr>
    <% } for (JobRequest jobRequest : jobs) { %>
        <tr>
            <td>
                <%=jobRequest.getId()%>
            </td>
            <td>
                <%=AppConstants.format( JobConstants.JOB_STATUS_TEXT.get(jobRequest.getStatus()), "n/a")%>
            </td>
            <td>
                <%=jobRequest.getJobId()%>
            </td>
            <td>
                <%=AppConstants.format(jobRequest.getUsername())%>
            </td>
            <td>
                <%=AppConstants.formatDataTime(jobRequest.getDateRequest())%>
            </td>
            <td>
                <%=AppConstants.formatDataTime(jobRequest.getDateJobStart())%>
            </td>
            <td>
                <%=AppConstants.formatDataTime(jobRequest.getDateJobEnd())%>
            </td>
            <td width="400px">
                <%=AppConstants.format(jobRequest.getJobResult())%>
            </td>
        </tr>
    <%}%>
    </tbody>
    <tfoot>
        <tr>
            <td colspan="8">
                <div class="pull-left">
                    <input type="button" value="Refresh" data-href="<%=AppConstants.APP_NAME%>?action=sync-ac-history" />
                </div>
                <div class="pull-right">
                    <%=PaginationController.printPaginationData(pd)%>
                </div>
            </td>
        </tr>
    </tfoot>
</table>
</form>
