This commit is contained in:
BOHUNG 2020-02-05 09:49:35 +08:00
parent 4e7a7056a5
commit c3c4773bac
17 changed files with 389 additions and 45 deletions

BIN
app/assets/images/gif.gif Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

View File

@ -247,6 +247,15 @@ class Admin::OlympiamanagementsController < OrbitAdminController
end end
def download_scan_file_of_certificate def download_scan_file_of_certificate
@sign_up_setting_id = SignUpSetting.last.id @sign_up_setting_id = SignUpSetting.last.id
if !params[:student_id].to_s.blank?
@student = OlympiaStudentDataField.where(:student_id=>params[:student_id]).first
if @student.nil?
redirect_to :back
else
tmp_filename_data = @student.olympia_student_images.last.student_file.file.read
send_data(tmp_filename_data, type: 'image/jpg', disposition: 'attachment', filename: "#{params[:student_name]}.jpg")
end
else
@student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id) @student_data_list = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting_id)
@student_data_image_path_arr = @student_data_list.flat_map{|student_data| student_data.olympia_student_images}.map{|student_image| student_image.student_file.file.file} @student_data_image_path_arr = @student_data_list.flat_map{|student_data| student_data.olympia_student_images}.map{|student_image| student_image.student_file.file.file}
zip_path = "tmp/student_images/#{@sign_up_setting_id}/" zip_path = "tmp/student_images/#{@sign_up_setting_id}/"
@ -279,6 +288,74 @@ class Admin::OlympiamanagementsController < OrbitAdminController
tmp_filename_data = File.read(@filename) tmp_filename_data = File.read(@filename)
send_data(tmp_filename_data, type: 'application/zip', disposition: 'attachment', filename: Pathname.new(@filename).basename.to_s) send_data(tmp_filename_data, type: 'application/zip', disposition: 'attachment', filename: Pathname.new(@filename).basename.to_s)
end end
end
def add_sign_up_student_data
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
redirect_to :back if @olympia_school_data_field.nil?
@required_fields = [:school_contact_person_name,:department_job_title,:office_tel_number,:fax,:mobile_number,:email]
@flag = true
@required_fields.each do |field|
if @olympia_school_data_field[field].to_s.blank?
@flag = false
break
end
end
if !@flag
I18n.t('olympiamanagement.please_set_school_connect_data')
@error_msg << "<p><a href=#{school_connection_data_olympiamanagements_path}>#{I18n.t('olympiamanagement.please_set_school_connect_data')}</a></p>"
render 'import_error_msg'
else
@student_data_field = StudentDataField.first
@olympia_student_data = (OlympiaStudentDataField.find(params[:id]) rescue OlympiaStudentDataField.new)
end
end
def update_student_data
if params[:type] == 'add_student_data'
@error_msg = []
@student_params = params.require(:add_student_data).permit!
@all_fields_name = (StudentDataField.first || StudentDataField.new).student_data_fields.map{|hash| hash.keys[0]}
if @student_params.select{|key,value| !value.to_s.blank?}.count < @all_fields_name.slice(0,@all_fields_name.count-1).count
@error_msg << "缺少#{@all_fields_name.slice(0,@all_fields_name.count-1).count-@student_params.select{|key,value| !value.to_s.blank?}.count}個欄位值"
end
@student_params.select{|key,value| value.to_s.blank?}.keys.each do |key|
@error_msg << "#{I18n.t('olympiamanagement.'+key)}欄位值為空"
end
@id_error_msg = checkid(@student_params['StudentIDNO'])
if @id_error_msg.length != 0
@error_msg << @id_error_msg
end
if @student_params['StudentIdentity'] == '1' && (@student_params['olympia_student_images']['0']['StudentFile'].nil? rescue true)
@error_msg << I18n.t('olympiamanagement.StudentFile')
end
@olympia_school_data_field = OlympiaSchoolDataFields.find(params[:school_id]) rescue nil
@enrollment_limited = ((@olympia_school_data_field.enrollment_limited.nil? || @olympia_school_data_field.enrollment_limited == 0) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number.to_i && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number.to_i}.first.enrollment_available.to_i : @olympia_school_data_field.enrollment_limited.to_i)
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:school_id],:sign_up_setting_id=>@sign_up_setting_id)
if @student_fields.length > @enrollment_limited
@error_msg << ((I18n.locale.to_s == "zh_tw") ? ("一般身分報名人數上限為 #{@enrollment_limited} 人。") : ("Enrollment limited of General identity is #{@enrollment_limited} people."))
@error_msg << I18n.t('olympiamanagement.already_exceed_enrollment_limited')
end
if @error_msg.empty?
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
if @olympia_student_data.nil?
@olympia_student_data = OlympiaStudentDataField.create(@student_params)
@olympia_student_data.olympia_school_data_fields_id = @olympia_school_data_field.id
@olympia_student_data.sign_up_setting_id = SignUpSetting.last.id
@olympia_student_data.save
else
@olympia_student_data.update_attributes(@student_params)
end
redirect_to admin_olympiamanagements_sign_up_student_data_list_path
else
render 'import_error_msg'
end
elsif params[:type] == 'delete_student_data'
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
@olympia_student_data.destroy if !@olympia_student_data.nil?
redirect_to :back
else
render :html => '404'
end
end
def import_editing_number_of_school_class def import_editing_number_of_school_class
@olympia_school_data_field = OlympiaSchoolDataFields.new @olympia_school_data_field = OlympiaSchoolDataFields.new
end end
@ -301,4 +378,78 @@ class Admin::OlympiamanagementsController < OrbitAdminController
tmp_filename_data = File.read(dir_path +@filename) tmp_filename_data = File.read(dir_path +@filename)
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: "#{Time.now.year}#{Time.now.month}#{Time.now.day}_import_schoo_class_setting.xlsx") send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: "#{Time.now.year}#{Time.now.month}#{Time.now.day}_import_schoo_class_setting.xlsx")
end end
def checkid(id_number)
@ALP_STR = "ABCDEFGHJKLMNPQRSTUVXYWZIO"
@NUM_STR = "0123456789"
def CheckPID(id_number)
@sMsg = ""
sPID = id_number
if(sPID == '')
@sMsg = "請輸入身分證字號"
elsif (sPID.length != 10)
@sMsg = "身分證字號長度應為 10 "
else
sPID = sPID.upcase.strip
@sMsg = chkPID_CHAR(sPID)
if (@sMsg.length != 0)
return @sMsg
end
@iChkNum = getPID_SUM(sPID)
if (@iChkNum % 10 != 0)
iLastNum = sPID[9].to_i
for i in 0 .. 10
xRightAlpNum = @iChkNum - iLastNum + i
if ((xRightAlpNum % 10) == 0)
@sMsg = "身分證字號最後一個數應為:#{i}"
break
end
end
end
end
return @sMsg;
end
# 身分證字號檢查器 - 檢查合法字元
def chkPID_CHAR(sPID)
@sMsg = ""
#sPID = sPID.upcase.strip;
iPIDLen = String(sPID).length
sChk = @ALP_STR + @NUM_STR
for i in 0 ... iPIDLen
if (sChk.index(sPID[i]) < 0)
@sMsg = "這個身分證字號含有不正確的字元!"
break
end
end
if (@sMsg.length == 0)
if (@ALP_STR.index(sPID[0]) < 0)
@sMsg = "身分證字號第 1 碼應為英文字母(A~Z)。"
elsif ((sPID[1] != "1") && (sPID[1] != "2"))
@sMsg = "身分證字號第 2 碼應為數字(1~2)。"
else
for i in 2 ... iPIDLen
if (@NUM_STR.index(sPID[i]) < 0)
@sMsg = "#{i + 1} 碼應為數字(0~9)。"
break
end
end
end
end
return @sMsg
end
#身份證字號檢查器 - 累加檢查碼
def getPID_SUM(sPID)
@iChkNum = 0
#第 1 碼
@iChkNum = @ALP_STR.index(sPID[0]) + 10
@iChkNum = (@iChkNum / 10) + (@iChkNum % 10 * 9)
# 第 2 - 9 碼
for i in 1 ... (sPID.length - 1)
@iChkNum += sPID[i].to_i * (9 - i)
end
# 第 10 碼
@iChkNum += sPID[9].to_i;
return @iChkNum;
end
return CheckPID(id_number);
end
end end

View File

@ -201,7 +201,6 @@ class OlympiamanagementsController < ApplicationController
@page_content = render_to_string(:formats=> [:html] ,:partial=>'add_student_data.html',:locals=>{:@error=>(@@error rescue nil),:@student_data_field=>@student_data_field,:@olympia_student_data=>@olympia_student_data}) @page_content = render_to_string(:formats=> [:html] ,:partial=>'add_student_data.html',:locals=>{:@error=>(@@error rescue nil),:@student_data_field=>@student_data_field,:@olympia_student_data=>@olympia_student_data})
render_contents_in_index_page(@breadcumb+@page_content.html_safe) render_contents_in_index_page(@breadcumb+@page_content.html_safe)
end end
#if @flag = false
end end
end end
def sign_up_student_data_list def sign_up_student_data_list
@ -532,7 +531,7 @@ class OlympiamanagementsController < ApplicationController
end end
format_date(final_html_for_render,(original_view == "home" ? "home" : page.module)) rescue final_html_for_render format_date(final_html_for_render,(original_view == "home" ? "home" : page.module)) rescue final_html_for_render
end end
def updata_school_data def update_school_data
@readonly_fields = ['account_number','password','school_name','school_code','school_address','class_number','enrollment_limited'] @readonly_fields = ['account_number','password','school_name','school_code','school_address','class_number','enrollment_limited']
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>params[:olympia_user_name]).first @olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>params[:olympia_user_name]).first
redirect_to :back if @olympia_school_data_field.nil? redirect_to :back if @olympia_school_data_field.nil?
@ -545,10 +544,17 @@ class OlympiamanagementsController < ApplicationController
redirect_to add_sign_up_student_data_olympiamanagements_path redirect_to add_sign_up_student_data_olympiamanagements_path
#render_contents_in_index_page(@olympia_school_data_field.attributes.to_s) #render_contents_in_index_page(@olympia_school_data_field.attributes.to_s)
end end
def updata_student_data def update_student_data
if params[:type] == 'add_student_data' if params[:type] == 'add_student_data'
@error_msg = [] @error_msg = []
@student_params = params.require(:add_student_data).permit! @student_params = params.require(:add_student_data).permit!
@edit_unenable = ['StudentIdentity']
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
if !@olympia_student_data.nil?
@edit_unenable.each do |key|
@student_params[key] = @olympia_student_data[key]
end
end
@all_fields_name = (StudentDataField.first || StudentDataField.new).student_data_fields.map{|hash| hash.keys[0]} @all_fields_name = (StudentDataField.first || StudentDataField.new).student_data_fields.map{|hash| hash.keys[0]}
if @student_params.select{|key,value| !value.to_s.blank?}.count < @all_fields_name.slice(0,@all_fields_name.count-1).count if @student_params.select{|key,value| !value.to_s.blank?}.count < @all_fields_name.slice(0,@all_fields_name.count-1).count
@error_msg << "缺少#{@all_fields_name.slice(0,@all_fields_name.count-1).count-@student_params.select{|key,value| !value.to_s.blank?}.count}個欄位值" @error_msg << "缺少#{@all_fields_name.slice(0,@all_fields_name.count-1).count-@student_params.select{|key,value| !value.to_s.blank?}.count}個欄位值"
@ -592,7 +598,6 @@ class OlympiamanagementsController < ApplicationController
else else
render :html => '404' render :html => '404'
end end
#render :html => '123'
end end
def checkid(id_number) def checkid(id_number)
@ALP_STR = "ABCDEFGHJKLMNPQRSTUVXYWZIO" @ALP_STR = "ABCDEFGHJKLMNPQRSTUVXYWZIO"

View File

@ -0,0 +1,34 @@
<div class="control-group">
<div class="controls">
<!-- if this page editing please add class "fileupload-edit" -->
<div class="fileupload fileupload-new clearfix" data-provides="fileupload">
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %>
<div class="fileupload-new thumbnail pull-left">
<%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %>
</div>
<% end %>
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
<% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false)%>
<span class="btn btn-file">
<%= f.fields_for image_field_name do |index| %>
<%= index.fields_for "0" do |image| %>
<%= image.hidden_field(:_id,{:value=>image_form.send(image_field_name).last.id.to_s}) %>
<%= image.file_field field_name, {:id => (image_id rescue "input-upload"), :class => ('fileupload-new'+(@extra_class rescue "")), :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.change') %>
<% end %>
<% end %>
</span>
<%= f.check_box(:remove_image,{:checked=>false},"true","false") %>
<%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this image' : '該圖片' %>
<%else%>
<span class="btn btn-file">
<%= f.fields_for image_field_name do |index| %>
<%= index.fields_for "0" do |image| %>
<%= image.file_field field_name, {:id => (image_id rescue "input-upload"), :class => ('fileupload-new'+(@extra_class rescue "")), :accept=> 'image/png,image/gif,image/jpeg'} %><%= t('preferences.select_image') %>
<% end %>
<% end %>
</span>
<%end%>
<input type="button" value="<%= t(:cancel) %>" class="btn fileupload-exists" data-dismiss="fileupload">
</div>
</div>
</div>

View File

@ -0,0 +1,68 @@
<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|%>
<input type="hidden" name="school_id" value='<%= params[:school_id].to_s %>' />
<% @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 style="display: inline-block;" 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')%>">
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
<% end %>
</fieldset>

View File

@ -0,0 +1,68 @@
<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=>"updata_student_date",:type=>"add_student_data",:id=>params[:id]}, :html => {:multipart => true} do |form|%>
<input type="hidden" name="school_id" value='<%= params[:school_id].to_s %>' />
<% @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' %>
<%= 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')%>">
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
<% end %>
</fieldset>

View File

@ -11,4 +11,4 @@
</ul> </ul>
<%= link_to t('back'), :back, :class => 'btn' %> <input name="goback" type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" value="<%=t('back')%>">

View File

@ -1,7 +1,7 @@
<link rel="stylesheet" media="screen" type="text/css" href="/assets/admin/olympiamanagement.scss"> <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"> <link rel="stylesheet" media="print" type="text/css" href="/assets/admin/olympiamanagement.scss">
<script src="/assets/admin/olympiamanagement.js"></script> <script src="/assets/admin/olympiamanagement.js"></script>
<% th_name_list = ['StudentIdentity','StudentName','StudentClass','StudentArea','StudentPhone','action']%> <% th_name_list = ['StudentName','StudentSex','StudentClass','birth_date','StudentIdentity','StudentArea','scan_file_of_certificate','action']%>
<table cellspacing="0" class="ts_rowsonly" width="100%" id="RSS_Table_page_contest_admin_1"> <table cellspacing="0" class="ts_rowsonly" width="100%" id="RSS_Table_page_contest_admin_1">
<thead> <thead>
<tr> <tr>
@ -14,7 +14,15 @@
<% @student_fields.each do |field| %> <% @student_fields.each do |field| %>
<tr> <tr>
<% th_name_list.each do |th_name|%> <% th_name_list.each do |th_name|%>
<%if th_name != 'action'%> <%if th_name == 'birth_date'%>
<td><%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %></td>
<% elsif th_name == 'scan_file_of_certificate'%>
<% if !field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.empty? %>
<td><a href='<%="#{admin_olympiamanagements_download_scan_file_of_certificate_path}?student_id=#{field.id}" %>'><%= "#{field.StudentName}.gif" %><img src="/assets/gif.gif" border="0" alt="<%= "#{field.StudentName}.gif" %>"></a></td>
<% else %>
<td>&nbsp;</td>
<% end %>
<%elsif th_name != 'action'%>
<% @value = field[th_name] %> <% @value = field[th_name] %>
<% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%> <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%>
<% if !@index.nil? %> <% if !@index.nil? %>
@ -23,8 +31,8 @@
<td><%= @value %></td> <td><%= @value %></td>
<% else %> <% else %>
<td> <td>
<a href="<%=add_sign_up_student_data_olympiamanagements_path+"?id=#{field.id}"%>"><img src="/assets/edit.gif" alt="<%= t('olympiamanagement.edit') %>" align="top" width="24"><%= t('olympiamanagement.edit') %></a> <a href="<%=admin_olympiamanagements_add_sign_up_student_data_path+"?id=#{field.id}&school_id=#{field.olympia_school_data_fields_id}"%>"><img src="/assets/edit.gif" alt="<%= t('olympiamanagement.edit') %>" align="top" width="24"><%= t('olympiamanagement.edit') %></a>
<a href="<%=updata_student_data_olympiamanagements_path+"?id=#{field.id}&type=delete_student_data"%>"><img src="/assets/trash.gif" alt="<%= t('olympiamanagement.delete') %>" align="top" width="24"><%= t('olympiamanagement.delete') %></a> <a href="<%=admin_olympiamanagements_update_student_data_path+"?id=#{field.id}&type=delete_student_data"%>"><img src="/assets/trash.gif" alt="<%= t('olympiamanagement.delete') %>" align="top" width="24"><%= t('olympiamanagement.delete') %></a>
</td> </td>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -5,7 +5,7 @@
<script src="/assets/olympiamanagement.js"></script> <script src="/assets/olympiamanagement.js"></script>
<fieldset class="fieldset_block"> <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> <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|%> <%=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| %> <% @student_data_field.student_data_fields.each do |field| %>
<div class="col_text"> <div class="col_text">
<% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%> <% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%>
@ -38,12 +38,16 @@
</select> </select>
<%=t('olympiamanagement.year')%> <%=t('olympiamanagement.year')%>
<% elsif field.values[0][:type] == 'select_string' %> <% 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." %> <% @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> <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| %> <% 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 %> <%= ('<option value="' + ((value.class == String) ? i.to_s : value) + '">' + value.to_s + '</option>').html_safe %>
<% end %> <% end %>
</select> </select>
<% end %>
<% elsif field.values[0][:type] == 'radio' %> <% elsif field.values[0][:type] == 'radio' %>
<%field.values[0][:choices].each_with_index do |choice,i|%> <%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' : '' %>> <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' : '' %>>

View File

@ -3,7 +3,7 @@
<script src="/assets/admin/olympiamanagement.js"></script> <script src="/assets/admin/olympiamanagement.js"></script>
<fieldset class="fieldset_block"> <fieldset class="fieldset_block">
<legend class="fieldset_title"><%=t('olympiamanagement.school_connection_data')%></legend> <legend class="fieldset_title"><%=t('olympiamanagement.school_connection_data')%></legend>
<%=form_for @olympia_school_data_field ,:url=>{:controller=>"olympiamanagements" ,:action=>"updata_school_data",:olympia_user_name=>(session[:olympia_login_id] rescue "")} do |form|%> <%=form_for @olympia_school_data_field ,:url=>{:controller=>"olympiamanagements" ,:action=>"update_school_data",:olympia_user_name=>(session[:olympia_login_id] rescue "")} do |form|%>
<% @school_data_fields.each do |field| %> <% @school_data_fields.each do |field| %>
<div class="col_text"> <div class="col_text">
<% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%> <% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%>

View File

@ -5,5 +5,5 @@
<% end %> <% end %>
</ul> </ul>
<p align="center"> <p align="center">
<%= link_to t('back'), :back, :class => 'btn' %> <input name="goback" type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" value="<%=t('back')%>">
</p> </p>

View File

@ -24,7 +24,7 @@
<% else %> <% else %>
<td> <td>
<a href="<%=add_sign_up_student_data_olympiamanagements_path+"?id=#{field.id}"%>"><img src="/assets/edit.gif" alt="<%= t('olympiamanagement.edit') %>" align="top" width="24"><%= t('olympiamanagement.edit') %></a> <a href="<%=add_sign_up_student_data_olympiamanagements_path+"?id=#{field.id}"%>"><img src="/assets/edit.gif" alt="<%= t('olympiamanagement.edit') %>" align="top" width="24"><%= t('olympiamanagement.edit') %></a>
<a href="<%=updata_student_data_olympiamanagements_path+"?id=#{field.id}&type=delete_student_data"%>"><img src="/assets/trash.gif" alt="<%= t('olympiamanagement.delete') %>" align="top" width="24"><%= t('olympiamanagement.delete') %></a> <a href="<%=update_student_data_olympiamanagements_path+"?id=#{field.id}&type=delete_student_data"%>"><img src="/assets/trash.gif" alt="<%= t('olympiamanagement.delete') %>" align="top" width="24"><%= t('olympiamanagement.delete') %></a>
</td> </td>
<% end %> <% end %>
<% end %> <% end %>

View File

@ -1,5 +1,6 @@
en: en:
olympiamanagement: olympiamanagement:
scan_file_of_certificate: Scan file of certificate
sign_up_title: International Junior Science Olympiad First Stage Online Sign UP sign_up_title: International Junior Science Olympiad First Stage Online Sign UP
error_msg: Error message error_msg: Error message
id_number_error: ID Number error id_number_error: ID Number error

View File

@ -1,5 +1,6 @@
zh_tw: zh_tw:
olympiamanagement: olympiamanagement:
scan_file_of_certificate: 獎狀掃描
sign_up_title: 國中科學奧林匹亞競賽初選線上報名 sign_up_title: 國中科學奧林匹亞競賽初選線上報名
error_msg: 錯誤訊息 error_msg: 錯誤訊息
id_number_error: 身分證字號錯誤 id_number_error: 身分證字號錯誤

View File

@ -21,6 +21,10 @@ Rails.application.routes.draw do
get 'olympiamanagements/update_sign_up_data' , to: 'olympiamanagements#update_sign_up_data' get 'olympiamanagements/update_sign_up_data' , to: 'olympiamanagements#update_sign_up_data'
get 'olympiamanagements/download_import_file' , to: 'olympiamanagements#download_import_file' get 'olympiamanagements/download_import_file' , to: 'olympiamanagements#download_import_file'
get 'olympiamanagements/sign_up_student_data_list' , to: 'olympiamanagements#sign_up_student_data_list' get 'olympiamanagements/sign_up_student_data_list' , to: 'olympiamanagements#sign_up_student_data_list'
get 'olympiamanagements/add_sign_up_student_data' , to: 'olympiamanagements#add_sign_up_student_data'
get 'olympiamanagements/update_student_data' , to: 'olympiamanagements#update_student_data'
post 'olympiamanagements/update_student_data' , to: 'olympiamanagements#update_student_data'
patch 'olympiamanagements/update_student_data' , to: 'olympiamanagements#update_student_data'
resources :olympiamanagements resources :olympiamanagements
end end
resource 'olympiamanagements' do resource 'olympiamanagements' do