<%-- 
 * Copyright
 *   2009 axYus - www.axyus.com
 *   2009 C.Marchand - christophe.marchand@axyus.com
 *
 * This file is part of XEMELIOS.
 *
 * XEMELIOS is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * XEMELIOS is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with XEMELIOS; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
--%>

<%@page import="java.util.*, java.text.SimpleDateFormat,fr.gouv.finances.dgfip.xemelios.export.ExportJob, fr.gouv.finances.dgfip.xemelios.common.config.*"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<c:set var="meta" scope="request"><meta http-equiv="refresh" content="30"/></c:set>
<c:set var="codeEcran" scope="request"><bean:message key="exports.codeEcran"/></c:set>
<c:set var="titreEcran" scope="request"><bean:message key="exports.titreEcran"/></c:set>
<%@ include file="/WEB-INF/jsp/include/entete.jsp" %>
<%
        List<ExportJob> exports = (List<ExportJob>) request.getAttribute("exports");
        DocumentsModel docs = (DocumentsModel) request.getAttribute("docModels");
        SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
%>
<% if (exports != null && exports.size() > 0) {%>
<style type="text/css">
    table#exports {
        border-collapse: collapse;
        border: black solid 1px;
        margin-top: 23px;
        margin-left: 5px;
    }
    table#exports tr td {
        border: black solid 1px;
    }
    table#exports tr th {
        background-color: #5988E9;
        color: #FFFFFF;
        font-weight: bold;
        font-size: 12px;
        text-align: center;
        border-style: solid;
        border-color: black;
        border-width: 1px;
    }
    .centre {
        text-align: center;
    }
</style>
<script type="text/javascript">
    function downloadFile(exportId) {
        alert(exportId);
        if(exportId>=0) {
            document.URL='"'+<%=request.getContextPath()%>+"/getComplexExportResult.do?exportId="+exportId+'"';
        }
    }
</script>
<table width="720px" id="exports">
    <colgroup>
        <col width="18px"/>
        <col width="20%"/>
        <col width="15%"/>
        <col width="15%"/>
        <col width="15%"/>
        <col width="15%"/>
        <col width="5%"/>
        <col width="15%"/>
    </colgroup>
    <theader>
        <tr>
            <th>&nbsp;</th>
            <th><bean:message key="exports.Nom"/></th>
            <th><bean:message key="exports.Document"/></th>
            <th><bean:message key="exports.Etat"/></th>
            <th><bean:message key="exports.SubmitDate"/></th>
            <th><bean:message key="exports.Status"/></th>
            <th><bean:message key="exports.Priority"/></th>
            <th><bean:message key="exports.Comment"/></th>
        </tr>
    </theader>
    <tbody>
        <% for (ExportJob job : exports) {%>
        <% boolean downloadable = job.getStatus() != ExportJob.STATUS_CLEANED && (job.getStatus() == ExportJob.STATUS_TERMINATED || job.getStatus() == ExportJob.STATUS_DOWNLOADED);%>
        <tr>
            <td>
                <% if(downloadable) { %>
                <a href="<%=request.getContextPath()%>/getComplexExportResult.do?exportId=<%= job.getIdExport() %>">
                    <img src="<%=request.getContextPath()%>/img/save.png" alt=""/>
                </a>
                <% } else { %>
                    <img src="<%=request.getContextPath()%>/img/blank.png" alt=""/>
                <% } %>
            </td>
            <td>&nbsp;<%=job.getExportName()%></td>
            <td><%=docs.getDocumentById(job.getDocumentId()).getTitre()%></td>
            <td><%=docs.getDocumentById(job.getDocumentId()).getEtatById(job.getEtatId()).getTitre()%></td>
            <td class="centre"><%=sdf.format(job.getSubmitDate())%></td>
            <td><%=ExportJob.STATUS_TXT_FR[job.getStatus()]%></td>
            <td class="centre"><%=job.getPriority() > 0 ? Integer.toString(job.getPriority()) : ""%></td>
            <td><%=job.getErrorMessage() == null ? "" : job.getErrorMessage()%></td>
        </tr>
        <% }%>
    </tbody>
</table>
<% } else {%>
<% }%>
<%@ include file="/WEB-INF/jsp/include/pied.jsp" %>