<%-# 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. -%>
<% if @academic_days > 0 %>
  <% form_for :filter, :url => {:action=> 'filter'} 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 params[:subject_id].nil? %>
      <%= f.hidden_field :subject , :value=> params[:subject_id] %>
    <% end %>

    <%= submit_tag "#{t('filter')}",:class=>'submit_button'  %>
    <div class="label-field-pair1">
      <label><%= t('filter') %>:</label>
      <div class="text-input-bg1"><%= f.select :range, [["#{t('below')}","Below"], ["#{t('above')}","Above"], ["#{t('equals')}","Equals"]] %></div>
      <div class="text-input-bg1"><%= f.text_field :value %></div></div>
  <% end %>
  <div class="label-field-pair">
    <label>
      <%  if @config.config_value == 'Daily' %>
        <%= "#{t('total_no_of_wrkng_days')} = " + @academic_days.to_s %>
      <% else %>
        <%= "#{t('total_no_of_wrkng_hours')}= " + @academic_days.to_s %>

      <% end  %>
    </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| %>
      <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) unless @leaves[student.id]['percent'].nil? %></td>
      </tr>
    <% end %>
  </table>
  <% form_for :filter, :url => {:action=> 'report_pdf', :page_height=>1150},:html=>{:target => '_blank'} 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 params[:subject_id].nil? %>
      <%= f.hidden_field :subject , :value=> params[:subject_id] %>
    <% end %>

    <%= submit_tag "►#{t('pdf_report')}" ,:class=>'submit_button2'  %>
  <% end %>
<% else %>
  <div class="label-field-pair2" >
    <%= t('no_reports') %>.
  </div>
<%  end %>