<%@ page import="ro.emid.administrare.obj.binder.SesiuneRaportareBinder" %>
<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.common.constants.SesiuneRaportareConstants" %>
<%@ page import="ro.emid.common.db.SesiuneRaportareAccessDB" %>
<%@ page import="ro.emid.common.types.SesiuneRaportare" %>
<%@ page import="ro.emid.common.types.User" %>
<%@ page import="ro.emid.common.utils.ObjectUtils" %>
<%@ page import="ro.emid.common.utils.SessionUtils" %>
<%@ page import="java.sql.Timestamp" %>

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

<%
    final User user = SessionUtils.getUserLogat(session);
    long sesiuneRaportareId = ObjectUtils.getLongValue(request.getParameter("id"), -1);

    SesiuneRaportare sesiuneRaportare = null;
    if (sesiuneRaportareId == -1) {
        SesiuneRaportareBinder binder = (SesiuneRaportareBinder) request.getAttribute(SesiuneRaportareConstants.BEAN);
        if (binder != null) {
            sesiuneRaportare = (SesiuneRaportare) binder.getBean();
        }
    } else {
        sesiuneRaportare = SesiuneRaportareAccessDB.get(sesiuneRaportareId);
    }


    if (sesiuneRaportare == null) {
        sesiuneRaportare = new SesiuneRaportare();
    }
%>
<%@ include file="../layout/messages.jspf" %>

<TABLE cellSpacing=1 cellPadding=5 width="100%">
    <TR>
        <TD>
            <TABLE class=gSAPTHEAD cellSpacing=1 cellPadding=2 width="100%" border=0>
                <tr>
                    <td align="left">
                        <span style="FONT-WEIGHT: bold; FONT-SIZE: 14px;"> Sesiune Raportare:</span>
                    </td>
                </tr>
            </TABLE>
            <TABLE border=0 cellPadding=2 cellSpacing=1 width="100%" class="gSAPTHEAD">
                <form name="zaforma" action="<%=AppConstants.APP_NAME%>" method="post">
                    <input type="hidden" name="action" value="saveSesiuneRaportare">
                    <input type="hidden" name="<%=SesiuneRaportareConstants.ID%>" value="<%=sesiuneRaportare.getId()%>">

                    <tr>
                        <td width="70px"></td>
                        <td>
                            <table width="100%">
                                <tr>
                                    <td width="200px">An:</td>
                                    <td>
                                        <input class="gsapinputtext" type="text" name="<%=SesiuneRaportareConstants.AN%>"
                                               value="<%=AppConstants.format(sesiuneRaportare.getAn())%>">
                                    </td>
                                </tr>
                                <tr>
                                    <td>Stare:</td>
                                    <td>
                                        <input disabled="true" readonly class="gsapinputtext" type="text" name="<%=SesiuneRaportareConstants.DESCHISA_STRING%>"
                                               value="<%= sesiuneRaportare.isDeschisa()  ? "Deschisa" : "Inchisa" %>">

                                        <input type="hidden" name="<%=SesiuneRaportareConstants.DESCHISA%>"
                                               value="<%= sesiuneRaportare.isDeschisa() ? 1 : 0 %>">
                                        <input type="hidden" name="<%= SesiuneRaportareConstants.USER_UPDATE%>"
                                               value="<%= user.getUsername() %>">
                                        <input type="hidden" name="<%= SesiuneRaportareConstants.DATA_UPDATE%>"
                                               value="<%= AppConstants.format(new Timestamp( System.currentTimeMillis()))%>">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                    <tr>
                        <td>&nbsp;</td>
                    </tr>

                    <tr>
                        <td></td>
                        <td>
                            <input type="submit" value="Salveaza"> &nbsp;&nbsp;&nbsp;
                            <input type="button" value="Renunta"
                                   onclick="redirectTo('<%=AppConstants.APP_NAME%>?action=show-sesiuni');">
                        </td>
                    </tr>
                </form>
            </TABLE>
        </TD>
    </TR>
</TABLE>

<style type="text/css">
    .f {
        /*background-color:#ccccff;*/
    }

    .s {
        /*background-color:#d9d9ff;*/
    }

    .c {
        /*background-color:#e6e6fc;*/
    }
</style>
