<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.types.Category" %>
<%@ page import="ro.emid.common.types.CategoryInfo" %>
<%@ page import="java.util.Map" %>

<%@ taglib prefix="emid" tagdir="/WEB-INF/tags" %>

<%
    /**
     * @see ro.emid.lpod.action.category.ShowSucursaleAction
     */
    final Category[] sucursale = (Category[]) request.getAttribute("sucursale");
    final Map<Long, CategoryInfo> categoryInfoMap = (Map<Long, CategoryInfo>) request.getAttribute("categoryInfoMap");
    final Long nrIncidenteTotal = (Long) request.getAttribute("nrIncidenteTotal");
%>

<emid:template-lp title="Sucursale">
    <jsp:attribute name="breadcrumb">
        <emid:localizare-lp/>
    </jsp:attribute>
    <jsp:attribute name="body">
        <table border=0 cellPadding=2 cellSpacing=1 width="100%" class="gSAPTHEAD" style="BACKGROUND-COLOR: white">
            <tr>
                <th class="gsapthead" colSpan=2 height=25 noWrap>Sucursale Electrica:</th>
                <th class="gsapthead" noWrap width=80>Nr. lucrări</th>
                <th class="gsapthead" noWrap width=150>Data ultimei editări</th>
            </tr>
            <% if (null == sucursale) {%>
            <tr>
                <td>
                    Nu sunt centre definite ...
                </td>
            </tr>
            <%} else {
                for(int i=0; i < sucursale.length; i++) { %>
                    <% CategoryInfo categoryInfo = categoryInfoMap.get(sucursale[i].getId()); %>
                    <tr class="row<%=i%2%>">
                        <td height=50 align="center" valign="middle">
                            <img
                                    height=25
                                    src="<%= AppConstants.WEB_RESOURCE_PATH + "/images/folder_big.gif" %>"
                                    width=46></td>
                        <td height=50 width="100%">
                            <span style="font-size: 12px"><%=AppConstants.format(sucursale[i].getCodSap())%> </span> - <A title="Centre exploatare <%=sucursale[i].getName()%>" class="link" href="<%=AppConstants.APP_NAME%>?action=showCentre&sucursalaId=<%=sucursale[i].getId()%>">
                            <%=sucursale[i].getName()%></A>&nbsp;<%=(sucursale[i].getDescription() == null) ? "": '-' + sucursale[i].getDescription()%><BR>
                                    <span style="font-size: 10px;"><% final Category[] centre = categoryInfo.getChildren();
                                        if (centre != null) for (Category c : centre) {%>
                                            <%=c.getName() + ", "%>
                                        <%}%>
                                    </span>
                        </td>
                        <td height=50 valign="middle" align="center">
                            <span class=gensmall><%=AppConstants.format(categoryInfo.getCountFise(), "")%></span>
                        </td>
                        <td height=50 noWrap valign="middle" align="center">
                            <span class=gensmall><%=AppConstants.formatZiSaptaminaData(categoryInfo.getLastDate())%></span>
                        </td>
                    </tr>
                <%}%>
                <tr style="font-weight:bold;">
                    <td class="gsapthead" colspan="2" align="right">&nbsp;Total:&nbsp;</td>
                    <td class="gsapthead" align="center"><%=nrIncidenteTotal%></td>
                    <td class="gsapthead">&nbsp;</td>
                </tr>
            <%}%>
        </table>
    </jsp:attribute>
</emid:template-lp>
