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

63 lines
4.8 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">
<script src="/assets/admin/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=>"updata_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-10) .. (Time.now.year.to_i+10) %>
<%= ('<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' %>
<% @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>
<% 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' %>
<input type="file" name="<%="[add_student_data][#{field.keys[0]}]"%>" value="<%= @olympia_student_data[field.keys[0]] %>" size="<%=field.values[0][:size]%>" id="<%= field.keys[0] %>" style="margin-top: 1em;" class="col_input<%= @extra_class%>"/>
<% 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')%>">
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
<% end %>
</fieldset>