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

<% form_for [@batch, @exam_group] do |f| %>

  <%= f.error_messages %>
  <div class="exam-basic-details">

    <div class="label-field-pair">
      <%= f.label :name,t('name') %>
      <div class="text-input-bg"><%= f.text_field :name, :value=>@name %></div>
    </div>
    <%= f.hidden_field :exam_type,:value=>@type %>
  <%#= f.hidden_field :cce_exam_category_id,:value=>@cce_exam_category_id %>
    <% unless @batch.cce_enabled? %>
      <div class="label-field-pair">
        <%= f.label :exam_type, t('exam_type')%>
        <div class="text-input-bg"><%= f.text_field :exam_type, :value=>@type=='Marks' ? t('marks') : t('marks_and_grades'),:disabled=>true %>
        </div><%= link_to "#{t('change_type')}", new_batch_exam_group_path(@batch,:ename=>@name),:class=>"type_link" %>
      </div>
    <% else %>
      <div class="label-field-pair">
        <label for="cce_exam_category_id"><%= t('cce_exam_category') %></label>
        <div class="text-input-bg"><%= f.select :cce_exam_category_id,options_for_select([["",""]]+@cce_exam_categories.map{|ec| [ec.name,ec.id]},:selected=>(@exam_group.cce_exam_category_id.present? ? @exam_group.cce_exam_category_id : @cce_exam_category_id.to_i)) %>
        </div>
      </div>
    <% end %>
    <div class="label-field-pair">
      <%= f.label :maximum_marks, t('max_mark') %>
      <div class="text-input-bg"><%= f.text_field :maximum_marks %></div>
    </div>
    <div class="label-field-pair">
      <%= f.label :minimum_marks, t('min_mark') %>
      <div class="text-input-bg"> <%= f.text_field :minimum_marks %></div>
    </div>
  <%# if @batch.gpa_enabled? %>
  <%#*<div class="label-field-pair">%>
  <%#= f.label :is_final_exam, t('is_final_exam') %>
  <%#*<div class="text-input-bg"> <%= f.check_box :is_final_exam %>
  <%#*</div>%>
  <%# end %>

  </div>
  <h4> <%= t('enter_exam_related_details') %>:</h4>

  <table width="100%" id="listing">
    <tr class="tr-head">
      <td><%= t('subject_name') %></td>
      <td><%= t('max') %></td>
      <td><%= t('min') %></td>
      <td><%= t('start_time') %></td>
      <td><%= t('end_time') %></td>
      <td><%= t('do_not_create') %></td>
    </tr>

    <% f.fields_for :exams do |exam_form| %>
      <tr class="tr-<%= cycle('odd', 'even') %>">
        <td class="col-2"><%= exam_form.object.subject.name %><%= exam_form.hidden_field :subject_id %>
        </td>
        <td class="col-1"><div class="label-field-pair2">
            <div class="text-input-bg2">
              <%= exam_form.text_field :maximum_marks, :size => 4, :class => 'max_marks' %>
            </div>
          </div>
        </td>
        <td class="col-1">
          <div class="label-field-pair2">
            <div class="text-input-bg2">
              <%= exam_form.text_field :minimum_marks, :size => 4, :class => 'min_marks' %>
            </div>
          </div>
        </td>
        <td class="col-1">
          <div class="label-field-pair3">
            <div class="text-input-bg3">
              <%= exam_form.calendar_date_select :start_time,:popup=>"force"%>
            </div>
          </div>
        </td>
        <td class="col-1">
          <div class="label-field-pair3">
            <div class="text-input-bg3">
              <%= exam_form.calendar_date_select :end_time,:popup=>"force" %>
            </div>
          </div></td>
        <td class="col-1">
          <div class="label-field-pair2">
            <div class="text-input-bg2">
              <%= exam_form.check_box :_delete %>
            </div>
          </div>
        </td>
      </tr>
    <% end %>
  </table>

  <%= submit_tag "", :value => "► #{t('save_changes')}", :class => "submit_button2" %>


<% end %>
<script>
  $('exam_group_maximum_marks').observe('blur', function() { $$('.max_marks')      .each(function(max_marks_obj){ max_marks_obj.value = $F('exam_group_maximum_marks'); }); });
  $('exam_group_minimum_marks').observe('blur', function() { $$('.min_marks')      .each(function(min_marks_obj){ min_marks_obj.value = $F('exam_group_minimum_marks'); }); });
</script>
