<%-# Fedena
#Copyright 2010 Foradian Technologies Private Limited
#
#This product includes software developed at
#Project Fedena - http://www.projectfedena.org/
#
#Licensed under the Apache License, Version 2.0 (the "License");
#you may not use this file except in compliance with the License.
#You may obtain a copy of the License at
#
#  http://www.apache.org/licenses/LICENSE-2.0
#
#Unless required by applicable law or agreed to in writing,
#software distributed under the License is distributed on an
#"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#KIND, either express or implied.  See the License for the
#specific language governing permissions and limitations
#under the License. -%>

<div id="content-header">
  <%= image_tag("/images/attendence/attendence.png") %>
  <h1><%= t('attendance_report') %></h1>
  <h3><%= t('filtered_report') %></h3>
  <div id="app-back-button">
    <%= link_to_function image_tag("/images/buttons/back.png",:border => 0), "history.back()" %>
  </div>
</div>
<div id="page-yield">
  <div class="label-field-pair">
    <label>
      <%= "#{t('total_no_of_wrkng_days')} : " + @academic_days.to_s %><br/>
      <%= t('filtered') %>: <%=  t(@range.downcase) %> <%= @value %> %
    </label>
  </div>
  <table id="listing" align="center" width="80%">
    <tr class="tr-head">
      <td>
        <%= t('name') %>
      </td>
      <td>
        <%= t('total') %>
      </td>
      <td>
        <%= t('percentage') %>(%)
      </td>
    </tr>
    <tr class="blank"></tr>
    <% @students.each do |student| %>
      <% unless @leaves[student.id]['percent'].blank? %>
        <% if @range == 'Below' %>
          <% if @leaves[student.id]['percent'].round(2) < @value.to_f %>
            <tr class="tr-<%= cycle('odd', 'even') %>">
              <td class="col-2"><%= link_to student.full_name, {:controller => "attendance_reports", :action => "student_details", :id => student.id } %></td>
              <td class="col-3"> <%= @leaves[student.id]['total'] %></td>
              <td class="col-3"><%= @leaves[student.id]['percent'].round(2)  %></td>
            </tr>
          <% end %>
        <% elsif @range == 'Above' %>
          <% if @leaves[student.id]['percent'].round(2) > @value.to_f %>
            <tr class="tr-<%= cycle('odd', 'even') %>">
              <td class="col-2"><%= link_to student.full_name, {:controller => "attendance_reports", :action => "student_details", :id => student.id } %></td>
              <td class="col-3"> <%= @leaves[student.id]['total'] %></td>
              <td class="col-3"><%= @leaves[student.id]['percent'].round(2)  %></td>
            </tr>
          <% end %>
        <% elsif @range == 'Equals' %>
          <% if @leaves[student.id]['percent'].round(2) == @value.to_f %>
            <tr class="tr-<%= cycle('odd', 'even') %>">
              <td class="col-2"><%= link_to student.full_name, {:controller => "attendance_reports", :action => "student_details", :id => student.id } %></td>
              <td class="col-3"> <%= @leaves[student.id]['total'] %></td>
              <td class="col-3"><%= @leaves[student.id]['percent'].round(2)  %></td>
            </tr>
          <% end %>
        <% end %>
      <% end %>
    <% end %>
  </table>
  <% form_for :filter, :url => {:action=> 'filter_report_pdf'} do |f| %>
    <%= f.hidden_field :batch , :value=> @batch.id %>
    <%= f.hidden_field :start_date , :value=> @start_date %>
    <%= f.hidden_field :end_date , :value=> @end_date %>
    <%= f.hidden_field :report_type , :value=> @mode %>
    <% unless @subject.nil? %>
      <%= f.hidden_field :subject , :value=>@subject.id %>
    <% end %>
    <%= f.hidden_field :range, :value=>params[:filter][:range] %>
    <%= f.hidden_field :value, :value=>params[:filter][:value] %>
    <%= submit_tag "► #{t('pdf_report')}",:class=>'submit_button'  %>
  <% end %>

  <div class="extender"></div>
</div>