<%-# 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">
  <%= stylesheet_link_tag "timetable/new_timetable.css" %>
  <%= image_tag("/images/show_timetable.png") %>
  <h1><%= t('timetable_text') %></h1>
  <h3><%= t('edit_timetable') %></h3>
  <div id="app-back-button">
    <%= link_to_function image_tag("/images/buttons/back.png",:border => 0), "history.back()" %>
  </div>
</div>
<div id="inner-tab-menu">
  <ul>
    <% unless @current %>
      <li>
        <%= link_to t('edit_entries'),:controller=>:timetable_entries,:action => "new",:timetable_id=>@timetable.id %>
      </li>
    <% else %>
      <li>
        <%= link_to t('edit_entries'),{:controller=>:timetable_entries,:action => "new",:timetable_id=>@timetable.id}, :class => 'delete-button',:confirm=>t("edit_current_tte_confirm") %>
      </li>
    <% end %>
    <% if @removable %>
      <li>
        <%= link_to t('delete_text'),{ :action => 'destroy', :id => @timetable.id }, :class => 'delete-button', :confirm => "#{t('delete_timetable')}" %>
      </li>
    <% end %>
  </ul>
</div>
<% if (@timetable && @timetable.errors.present?) %>
  <div id="errorExplanation" class="errorExplanation">
    <% @timetable.errors.each do |e| %>
      <p>
        <%= t("#{e}") %>
      </p>
    <% end %>
  </div>
<% end %>
<div id="page-yield">
  <div class="box">
    <% unless flash[:notice].nil? %>
      <p class="flash-msg"> <%= flash[:notice] %> </p>
    <% end %>
    <% form_for @timetable,:url=>{:controller=>"timetable",:action=>"update_timetable"} do |f| %>
      <input type="hidden" name="_method" value="post" />
      <div class="label-field-pair" >
        <label for="start_date"><%= t('start_date') %></label>
        <div class="text-input-bg">
          <%= f.date_select :start_date,:use_month_numbers=>true,:disabled=>@current,:start_year=>1.years.ago.year,:end_year=>1.years.since.year,:order=>[:day,:month,:year],:include_blank => false %>
        </div>
      </div>

      <div class="label-field-pair">
        <label for="end_date"><%= t('end_date') %></label>
        <div class="text-input-bg">
          <%= f.date_select :end_date,:use_month_numbers=>true,:start_year=>1.years.ago.year,:end_year=>1.years.since.year,:order=>[:day,:month,:year],:include_blank => false %>
        </div>
      </div>


      <%= submit_tag "", :value => "► save", :class => "submit_button" %>
    <% end %>
  </div>
</div>