<%@ page import="ro.emid.common.constants.AppConstants" %>
<%@ page import="ro.emid.incidente.action.rapoarte.RaportIndicatoriSimplicatBean" %>
<%@ page import="java.sql.Date" %>
<%@ taglib prefix="emid" tagdir="/WEB-INF/tags" %>
<%
    /**
     * @see ro.emid.incidente.action.rapoarte.RaportIndicatoriSimplificatAction
     */

  Date dataStart = (Date) request.getAttribute("dataStart");
  Date dataStop = (Date) request.getAttribute("dataStop");

  RaportIndicatoriSimplicatBean raport1 = (RaportIndicatoriSimplicatBean) request.getAttribute("bean1");
  RaportIndicatoriSimplicatBean raport2 = (RaportIndicatoriSimplicatBean) request.getAttribute("bean2");
  RaportIndicatoriSimplicatBean raport3 = (RaportIndicatoriSimplicatBean) request.getAttribute("bean3");


  String action = (String) request.getAttribute("action");

    /**
     * @see ro.emid.incidente.action.rapoarte.RaportIndicatoriSimplicatBean#TITLES
     */
  String title = (String) request.getAttribute("title");

%>
<style type="text/css">
  .raport-container{
    padding: 5px;
  }

  .raport-title{
    padding-bottom: 10px;font-size:16px; font-weight:bold;
  }

  .raport-table{
    width: 900px;
    background-color: #ffffff;
  }
</style>

<div class="raport-container">

  <form name="zaforma" action="<%=AppConstants.APP_NAME%>?action=<%=action%>" method="post">
    <input type="hidden" name="run_report" value="1"/>

    <div class="raport-title">
      Raport <%=title%>
    </div>

    <div>
      <emid:filtru-localizare/>
      <label>
        Perioada:
        <emid:datefield name="dataStart" value="<%=dataStart%>"/> -
      </label>
      <emid:datefield name="dataStop" value="<%=dataStop%>"/>
      <input type="submit" value="Rulează" class="ml10"/>
    </div>

    <div>
      <% if (raport1 != null){ %>
      <br>
      <table border="1" bgcolor="white" class="raport-table">
        <thead>
        <tr>
          <th class="gsapthead" width="20%">Indicator</th>
          <th class="gsapthead" width="40%">Cauza întreruperii</th>
          <th class="gsapthead" width="20%">Valoarea realizată</th>
        </tr>
        </thead>
        <tbody>
        <tr>
          <td rowspan="2" align="left">SAIFI</td>
          <td align="left">a. urban + rural planificate</td>
          <td align="right" data-value="<%=raport1.getSaifi1()%>"><%=AppConstants.format3(raport1.getSaifi1())%></td>
        </tr>
        <tr>
          <td align="left">b. urban + rural neplanificate</td>
          <td align="right" data-value="<%=raport1.getSaifi2()%>"><%=AppConstants.format3(raport1.getSaifi2())%></td>
        </tr>
        <tr>
          <td rowspan="2" align="left">SAIDI</td>
          <td align="left">a. urban + rural planificate</td>
          <td align="right" data-value="<%=raport1.getSaidi1()%>"><%=AppConstants.format3(raport1.getSaidi1())%></td>
        </tr>
        <tr>
          <td align="left">b. urban + rural neplanificate</td>
          <td align="right" data-value="<%=raport1.getSaidi2()%>"><%=AppConstants.format3(raport1.getSaidi2())%></td>
        </tr>
        </tbody>
      </table>
      <%
        }
        if (raport2 != null){
      %>
      <br>
      <table border="1" class="raport-table">
        <thead>
        <tr>
          <th class="gsapthead" width="20%">Indicator</th>
          <th class="gsapthead" width="40%">Cauza întreruperii</th>
          <th class="gsapthead" width="20%">Valoarea realizată</th>
        </tr>
        </thead>
        <tbody>
        <tr>
          <td rowspan="2" align="left">SAIFI</td>
          <td align="left">a. urban planificate + neplanificate</td>
          <td align="right" data-value="<%=raport2.getSaifi1()%>"><%=AppConstants.format3(raport2.getSaifi1())%></td>
        </tr>
        <tr>
          <td align="left">b. rural planificate + neplanificate</td>
          <td align="right" data-value="<%=raport2.getSaifi2()%>"><%=AppConstants.format3(raport2.getSaifi2())%></td>
        </tr>
        <tr>
          <td rowspan="2" align="left">SAIDI</td>
          <td align="left">c. urban planificate + neplanificate</td>
          <td align="right" data-value="<%=raport2.getSaidi1()%>"><%=AppConstants.format3(raport2.getSaidi1())%></td>
        </tr>
        <tr>
          <td align="left">d. rural planificate + neplanificate</td>
          <td align="right" data-value="<%=raport2.getSaidi2()%>"><%=AppConstants.format3(raport2.getSaidi2())%></td>
        </tr>
        </tbody>
      </table>
      <%}
        if (raport3 != null){
      %>
      <br>
      <table border="1" class="raport-table">
        <thead>
        <tr>
          <th class="gsapthead" width="20%">Indicator</th>
          <th class="gsapthead" width="40%">Cauza întreruperii</th>
          <th class="gsapthead" width="20%">Valoarea realizată</th>
        </tr>
        </thead>
        <tbody>
        <tr>
          <td align="left">SAIFI</td>
          <td align="left">a. urban + rural planificate + neplanificate</td>
          <td align="right" data-value="<%=raport3.getSaifi1()%>"><%=AppConstants.format3(raport3.getSaifi1())%></td>
        </tr>
        <tr>
          <td rowspan="2" align="left">SAIDI</td>
          <td align="left">b. urban + rural planificate + neplanificate</td>
          <td align="right" data-value="<%=raport3.getSaidi1()%>"><%=AppConstants.format3(raport3.getSaidi1())%></td>
        </tr>
        </tbody>
      </table>
      <%}%>
    </div>
  </form>
</div>


<script type="text/javascript">
  Calendar.setup(
          {
            inputField  : "dataStart",         // ID of the input field
            ifFormat    : "%d.%m.%Y",    // the date format
            button      : "trigger_data_start"       // ID of the button
          }
  );

  Calendar.setup(
          {
            inputField  : "dataStop",         // ID of the input field
            ifFormat    : "%d.%m.%Y",    // the date format
            button      : "trigger_data_stop"       // ID of the button
          }
  );
</script>