<%-# 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. -%>

<% unless  @all_timetable_entries.empty? %>
  <div id="timetable-container">
    <div class="employee_list">
      <table id="teacher" cellspacing="1">
        <tr id="weekday-header" class="themed_text"><th></th></tr>
        <tr id="period-count" class="themed_text"><td></td></tr>
        <% @all_teachers.each do |teacher| -%>
          <% unless teacher.nil? %>
            <tr class="batch">
              <td class="batch_name themed_text"><%= "#{teacher.full_name} [ #{teacher.employee_number} ]"  %></td>
            </tr>
          <% end %>
        <% end %>
      </table>
    </div>
    <div id="table-viewer">
      <table id="timetable" cellspacing="1">
        <tr id="weekday-header" class="themed_text">
  <%#*<th></th>%>
          <% @all_weekdays.each do |weekday| -%>
            <th colspan="<%= @all_classtimings.count %>"><%= t("#{Date::DAYNAMES[weekday.day_of_week].downcase}").upcase -%></th>
          <% end -%>
        </tr>
        <tr id="period-count" class="themed_text">
  <%#*<td></td>%>
          <% @all_weekdays.each do |weekday| -%>
            <% @all_classtimings.each do |ct| -%>
              <td class="tte">
                <%= "#{ct.start_time.strftime("%I:%M%p")} - #{ct.end_time.strftime("%I:%M%p")}" -%>
              </td>
            <% end -%>
          <% end -%>
        </tr>
        <% @all_teachers.each do |teacher| -%>
          <% unless teacher.nil? %>
            <tr class="batch">
              <% @all_weekdays.each do |weekday| -%>
                <% @all_classtimings.each do |ct| -%>
                  <td class="tte">
                    <% if @timetable_entries[teacher.id][weekday.id][ct.id].size > 1 %>
                      <div class="entries_wrapper">
                        <div class="entries">
                          <% @timetable_entries[teacher.id][weekday.id][ct.id].each_pair do |k, entry| %>
                            <div class="sub_name">
                              <%= formatted_timetable_cell_2(entry,teacher) unless entry.blank? -%>
                            </div>
                            <div class="batch_code">
                              <%= timetable_batch (entry) unless entry.blank? -%>
                            </div>
                          <div class="gap"></div>
                          <% end %>
                        </div>
                      </div>
                      <% entry = @timetable_entries[teacher.id][weekday.id][ct.id].first %>
                      <div class="sub_name">
                        <%= formatted_timetable_cell_2(entry.last,teacher) unless entry.blank? -%>
                      </div>
                      <div class="batch_code">
                        <%= timetable_batch (entry.last) unless entry.blank? -%>
                      </div>
                      <a class="themed_text add_sym">+</a>
                    <% else %>
                      <% entry = @timetable_entries[teacher.id][weekday.id][ct.id].first %>
                      <div class="sub_name">
                        <%= formatted_timetable_cell_2(entry.last,teacher) unless entry.blank? -%>
                      </div>
                      <div class="batch_code">
                        <%= timetable_batch (entry.last) unless entry.blank? -%>
                      </div>
                    <% end %>
                  </td>
                <% end -%>
              <% end -%>
            </tr>
          <% end -%>
        <% end -%>
      </table>
    </div>
  </div>
<% else %>
  <div id="timetable-container"><%= t('no_entries_found') %></div>
<% end %>