<%-# 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 class="linker">
  <%= link_to_remote "#{t('add')}", :url => { :action => 'new', :id => @batch } %>
</div>

<% unless @class_timings.empty? %>
<table id="class-timings-list" width="100%">
  <tr class="tr-head">
    <td><%= t('name') %></td>
    <td><%= t('start_time') %></td>
    <td><%= t('end_time') %></td>
    <td><%= t('operations') %></td>
  </tr>
  <% @class_timings.each do |class_timing| %>
    
    <tr id="class-timing-<%= class_timing.id %>" class="tr-<%= cycle('odd','even')   %>">
      <td class="col-1"><%= class_timing.name %></td>
      <td class="col-3"><%= class_timing.start_time.strftime("%I:%M %p") unless class_timing.start_time.nil? %></td>
      <td class="col-3"><%= class_timing.end_time.strftime("%I:%M %p") unless class_timing.end_time.nil? %></td>
      <td class="col-3"><small><%= link_to_remote("#{t('edit_text')}",
          :url => edit_class_timing_path(class_timing), :method => 'get' ) %> |
    <% @tt = PeriodEntry.find_all_by_class_timing_id(class_timing.id ) %>
  <% if @tt.empty? %>
    <%= link_to_remote("#{t('delete_text')}",
                :url => class_timing_path(class_timing),
                :method => 'delete',
                :confirm => "#{t('confirm_msg')}",
                :update => "class-timing-#{class_timing.id}") %>
              <% else %>
          <s><%= t('delete_text') %></s>
        <% end %></small></td>
    </tr>
  <% end %>
</table>
<% else %>
<h4><%= t('set_in_common') %></h4>
<% end %>
