<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.db.CategoryAccessDB" %>
<%@ page import="ro.emid.common.types.Eveniment" %>
<%@ page import="ro.emid.incidente.db.EvenimentAccessDB" %>
<%@ page import="ro.emid.common.types.Category" %>
<%@ page import="ro.emid.incidente.IncidenteSessionUtils" %>

<%@ include file="../incidente/declaratii.jsp"%>

<% if (request.getAttribute("close") !=null) {%>
    <script type="text/javascript">
        opener.location="<%=AppConstants.APP_NAME%>?action=showEvenimente";
        window.close();
    </script>
<%}%>

<%
    final long idSucursala = IncidenteSessionUtils.getSucursalaId(session);
    final Category[] centre = CategoryAccessDB.getAllCategoriesByParentId(idSucursala);
    final long evenimentId = ObjectUtils.getLongValue(request.getParameter("evenimentId"), -1);

    final Eveniment evenimentu = EvenimentAccessDB.getById( evenimentId);
%>


<TABLE class="gsapthead" align=center border=0 cellPadding=10 cellSpacing=0 width="100%">
    <TBODY>
        <TR>
            <TD>
                <TABLE align=center border=0 cellPadding=5 cellSpacing=0 width="100%" class="gsaptd">
                <tr><td>
                    Ati selectat evenimentul <b><%=evenimentu.getText()%></b> cu numarul <b><%=evenimentu.getNrComanda()%></b><br>
                    Unde doriti sa trimiteti evenimentul?
                    <form name="zaforma" style="padding:0; margin:5" action="<%=AppConstants.APP_NAME%>" method="post">
                        <input type="hidden" name="action" value="changeCentruForEveniment">
                        <input type="hidden" name="evenimentId" value="<%=evenimentId%>">

                        <select name="codFormatie">
                            <option value="">Selectati:</option>
                            <%for (int i = 0; i < centre.length; i++) {
                                final Category category = centre[i];%>
                                <optgroup label="<%=category.getName()%>">
                                    <% final Category[] formatii = CategoryAccessDB.getAllCategoriesByParentId( category.getId()); %>
                                    <% for (int j = 0; j < formatii.length; j++) {
                                        final Category formatia = formatii[j]; %>
                                        <option value="<%=formatia.getCodSap()%>"><%=formatia.getName()%></option>
                                    <%}%>
                                </optgroup>
                            <%}%>
                        </select>

                        <br> <br>
                        <input type="submit" value="Trimite" />  &nbsp;&nbsp;
                        <input type="button" value="Renunta" onclick="window.close()" />

                    </form>
                    </td></tr>
                    </TABLE></td>
            </TR>
        </TBODY>
    </TABLE>



