olympiamanagement/app/views/olympiamanagements/_add_student_data.html.erb

75 lines
5.4 KiB
Plaintext

<link rel="stylesheet" media="screen" type="text/css" href="/assets/admin/olympiamanagement.scss">
<link rel="stylesheet" media="print" type="text/css" href="/assets/admin/olympiamanagement.scss">
<%= stylesheet_link_tag "lib/fileupload"%>
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
<script src="/assets/olympiamanagement.js"></script>
<fieldset class="fieldset_block">
<legend class="fieldset_title"><%=t('olympiamanagement.'+(!@olympia_student_data.new_record? ? 'edit_sign_up_student_data' : 'add_sign_up_student_data'))%></legend>
<%=form_for @olympia_student_data ,:url=>{:controller=>"olympiamanagements" ,:action=>"update_student_data",:type=>"add_student_data",:id=>params[:id]}, :html => {:multipart => true} do |form|%>
<% @student_data_field.student_data_fields.each do |field| %>
<div class="col_text">
<% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%>
<% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%>
<%if !["StudentBirthYear","StudentBirthMonth","StudentBirthDay"].include?(field.keys[0]) %>
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.'+field.keys[0]) %></li>
<%elsif field.keys[0]=="StudentBirthYear"%>
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.birth_date') %></li>
<%end%>
<li class="col_r">
<% if field.values[0][:type] == 'String' %>
<input type="text" name="<%="[add_student_data][#{field.keys[0]}]"%>" value="<%= @olympia_student_data[field.keys[0]].to_s %>" size="<%=field.values[0][:size]%>" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>"/>
<% elsif field.values[0][:type] == 'select_num' %>
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
<select name="<%="[add_student_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_student_data[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
<% for @num in field.values[0]["range"][0] .. field.values[0]["range"][1] %>
<%= ('<option value="' + @num.to_s + '">' + @num.to_s + (field.values[0][:unit][I18n.locale.to_s] rescue "") + '</option>').html_safe %>
<% end %>
</select>
<%if ["StudentBirthMonth","StudentBirthDay"].include?(field.keys[0]) %>
<%=t('olympiamanagement.'+field.keys[0])%>
<%end%>
<% elsif field.values[0][:type] == 'Year' %>
<%=t('olympiamanagement.a_d_')%>
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
<select name="<%="[add_student_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_student_data[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
<% for @num in (Time.now.year.to_i-15) .. (Time.now.year.to_i) %>
<%= ('<option value="' + @num.to_s + '">' + @num.to_s + (field.values[0][:unit][I18n.locale.to_s] rescue "") + '</option>').html_safe %>
<% end %>
</select>
<%=t('olympiamanagement.year')%>
<% elsif field.values[0][:type] == 'select_string' %>
<% if field.keys[0] == 'StudentIdentity' && !@olympia_student_data.new_record? %>
<%= field.values[0][:values][I18n.locale.to_s][@olympia_student_data[field.keys[0]].to_i] %>
<% else %>
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
<select name="<%="[add_student_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_student_data[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
<% field.values[0]["values"][I18n.locale.to_s].each_with_index do |value,i| %>
<%= ('<option value="' + ((value.class == String) ? i.to_s : value) + '">' + value.to_s + '</option>').html_safe %>
<% end %>
</select>
<% end %>
<% elsif field.values[0][:type] == 'radio' %>
<%field.values[0][:choices].each_with_index do |choice,i|%>
<input type="radio" size="<%=field.values[0][:size]%>" name="<%="[add_student_data][#{field.keys[0]}]"%>" id="<%="#{field.keys[0]}_#{choice}"%>" class="required" value="<%=choice%>" <%= (@olympia_student_data[field.keys[0]].to_s== choice.to_s) ? 'checked=checked' : '' %>>
<label for="<%="#{field.keys[0]}_#{choice}"%>"><%=field.values[0][:values][I18n.locale.to_s][i]%></label>
<% end %>
<% elsif field.values[0][:type] == 'File' %>
<%= fields_for :add_student_data do |student_data| %>
<%= render :partial => 'image_form', :object => @olympia_student_data, :locals => {:f => student_data,:@extra_class=>@extra_class,:image_field_name=>:olympia_student_images,:field_name=>:student_file,:image_id=>field.keys[0]} %>
<%end%>
<% end %>
</li>
<% if !field.values[0][:hint][I18n.locale.to_s].blank? %>
<span id="-H" class="field-hint-inactive"><%=field.values[0][:hint][I18n.locale.to_s]%></span>
<% end %>
</div>
<% end %>
<div style="clear:both;"></div>
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
<% if @olympia_student_data.new_record? %>
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
<% else %>
<input type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
<% end %>
<% end %>
</fieldset>