From c3c4773bac052fde1cc58e5f65f24b09f07d4b5a Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Wed, 5 Feb 2020 09:49:35 +0800 Subject: [PATCH] fix --- app/assets/images/gif.gif | Bin 0 -> 189 bytes .../admin/olympiamanagements_controller.rb | 205 +++++++++++++++--- .../olympiamanagements_controller.rb | 13 +- .../olympiamanagements/_image_form.html.erb | 34 +++ .../add_sign_up_student_data.html.erb | 68 ++++++ .../add_student_data.html.erb | 68 ++++++ .../import_error_msg.html.erb | 2 +- .../sign_up_student_data_list.html.erb | 16 +- .../_add_student_data.html.erb | 16 +- .../_edit_school_data.html.erb | 2 +- .../_import_error_msg.html.erb | 2 +- .../_student_data_list.html.erb | 2 +- ...a.html.erb => update_school_data.html.erb} | 0 ....html.erb => update_student_data.html.erb} | 0 config/locales/en.yml | 1 + config/locales/zh_tw.yml | 1 + config/routes.rb | 4 + 17 files changed, 389 insertions(+), 45 deletions(-) create mode 100644 app/assets/images/gif.gif create mode 100644 app/views/admin/olympiamanagements/_image_form.html.erb create mode 100644 app/views/admin/olympiamanagements/add_sign_up_student_data.html.erb create mode 100644 app/views/admin/olympiamanagements/add_student_data.html.erb rename app/views/olympiamanagements/{updata_school_data.html.erb => update_school_data.html.erb} (100%) rename app/views/olympiamanagements/{updata_student_data.html.erb => update_student_data.html.erb} (100%) diff --git a/app/assets/images/gif.gif b/app/assets/images/gif.gif new file mode 100644 index 0000000000000000000000000000000000000000..5aa8d463e75b45184fea98cc67690eecc670d5f8 GIT binary patch literal 189 zcmZ?wbhEHb6k!ly*!-UX2>$>0&+vnRp`M|>o&hLO&%kitz=8ey_tyjY7(nqS3nK#q zJA)2L24scV<6Bs1ILVL9gBx0^7 WxHWlJ@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} - zip_path = "tmp/student_images/#{@sign_up_setting_id}/" - tmp_filename = '' - FileUtils.rm_r(zip_path, :force => true) if Dir.exist?(zip_path) - FileUtils.mkdir_p zip_path #create dir for storing tmp_file - @student_data_image_path_arr.each do |image_path| - @pathname = Pathname.new(image_path) - @temp_name = @pathname.basename - Dir.chdir(@pathname.dirname.to_s) do - @index = 1 - @original_filename =@pathname.basename.to_s - @new_pathname = Pathname.new("#{Rails.root}/#{zip_path}#{@original_filename}") - while @new_pathname.exist? do - @new_pathname = Pathname.new(@new_pathname.to_s.insert(@new_pathname.to_s.rindex('.'),"-#{@index}")) - @index += 1 + 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_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}/" + tmp_filename = '' + FileUtils.rm_r(zip_path, :force => true) if Dir.exist?(zip_path) + FileUtils.mkdir_p zip_path #create dir for storing tmp_file + @student_data_image_path_arr.each do |image_path| + @pathname = Pathname.new(image_path) + @temp_name = @pathname.basename + Dir.chdir(@pathname.dirname.to_s) do + @index = 1 + @original_filename =@pathname.basename.to_s + @new_pathname = Pathname.new("#{Rails.root}/#{zip_path}#{@original_filename}") + while @new_pathname.exist? do + @new_pathname = Pathname.new(@new_pathname.to_s.insert(@new_pathname.to_s.rindex('.'),"-#{@index}")) + @index += 1 + end + #a[0...b].concat('-1').concat(a[b..-1]) + FileUtils.cp(@original_filename,@new_pathname) end - #a[0...b].concat('-1').concat(a[b..-1]) - FileUtils.cp(@original_filename,@new_pathname) + end + @filename = Pathname.new(zip_path).parent.to_s+"/#{Time.now.strftime('%Y_%m_%d')}_student_images.zip" + zip_file= ZipFileGenerator.new(zip_path,@filename) + begin + zip_file.write + rescue + File.delete(@filename) + zip_file.write + end + tmp_filename_data = File.read(@filename) + send_data(tmp_filename_data, type: 'application/zip', disposition: 'attachment', filename: Pathname.new(@filename).basename.to_s) + 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 - @filename = Pathname.new(zip_path).parent.to_s+"/#{Time.now.strftime('%Y_%m_%d')}_student_images.zip" - zip_file= ZipFileGenerator.new(zip_path,@filename) - begin - zip_file.write - rescue - File.delete(@filename) - zip_file.write + if !@flag + I18n.t('olympiamanagement.please_set_school_connect_data') + @error_msg << "

#{I18n.t('olympiamanagement.please_set_school_connect_data')}

" + 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 - tmp_filename_data = File.read(@filename) - send_data(tmp_filename_data, type: 'application/zip', disposition: 'attachment', filename: Pathname.new(@filename).basename.to_s) end def import_editing_number_of_school_class @olympia_school_data_field = OlympiaSchoolDataFields.new @@ -301,4 +378,78 @@ class Admin::OlympiamanagementsController < OrbitAdminController 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") 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 \ No newline at end of file diff --git a/app/controllers/olympiamanagements_controller.rb b/app/controllers/olympiamanagements_controller.rb index 5092667..80fb947 100644 --- a/app/controllers/olympiamanagements_controller.rb +++ b/app/controllers/olympiamanagements_controller.rb @@ -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}) render_contents_in_index_page(@breadcumb+@page_content.html_safe) end - #if @flag = false end end def sign_up_student_data_list @@ -532,7 +531,7 @@ class OlympiamanagementsController < ApplicationController end format_date(final_html_for_render,(original_view == "home" ? "home" : page.module)) rescue final_html_for_render end - def updata_school_data + def update_school_data @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 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 #render_contents_in_index_page(@olympia_school_data_field.attributes.to_s) end - def updata_student_data + def update_student_data if params[:type] == 'add_student_data' @error_msg = [] @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]} 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}個欄位值" @@ -592,7 +598,6 @@ class OlympiamanagementsController < ApplicationController else render :html => '404' end - #render :html => '123' end def checkid(id_number) @ALP_STR = "ABCDEFGHJKLMNPQRSTUVXYWZIO" diff --git a/app/views/admin/olympiamanagements/_image_form.html.erb b/app/views/admin/olympiamanagements/_image_form.html.erb new file mode 100644 index 0000000..5ec1217 --- /dev/null +++ b/app/views/admin/olympiamanagements/_image_form.html.erb @@ -0,0 +1,34 @@ +
+
+ +
+ <% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false) %> +
+ <%= image_tag( image_form.send(image_field_name).last.send(field_name), :size=>"120x120") %> +
+ <% end %> +
+ <% if(image_form.send(image_field_name).last.send(field_name).file.present? rescue false)%> + + <%= 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 %> + + <%= f.check_box(:remove_image,{:checked=>false},"true","false") %> + <%= t(:remove) %> <%= (I18n.locale.to_s == 'en') ? ' this image' : '該圖片' %> + <%else%> + + <%= 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 %> + + <%end%> + +
+
+
\ No newline at end of file diff --git a/app/views/admin/olympiamanagements/add_sign_up_student_data.html.erb b/app/views/admin/olympiamanagements/add_sign_up_student_data.html.erb new file mode 100644 index 0000000..889b670 --- /dev/null +++ b/app/views/admin/olympiamanagements/add_sign_up_student_data.html.erb @@ -0,0 +1,68 @@ + + +<%= stylesheet_link_tag "lib/fileupload"%> +<%= javascript_include_tag 'lib/bootstrap-fileupload' %> + +
+ <%=t('olympiamanagement.'+(!@olympia_student_data.new_record? ? 'edit_sign_up_student_data' : 'add_sign_up_student_data'))%> + <%=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| %> +
+ <% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%> + <% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%> + <%if !["StudentBirthYear","StudentBirthMonth","StudentBirthDay"].include?(field.keys[0]) %> +
  • <%= @extra_text+t('olympiamanagement.'+field.keys[0]) %>
  • + <%elsif field.keys[0]=="StudentBirthYear"%> +
  • <%= @extra_text+t('olympiamanagement.birth_date') %>
  • + <%end%> +
  • + <% if field.values[0][:type] == 'String' %> + " 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." %> + + <%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." %> + + <%=t('olympiamanagement.year')%> + <% elsif field.values[0][:type] == 'select_string' %> + <% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %> + + <% elsif field.values[0][:type] == 'radio' %> + <%field.values[0][:choices].each_with_index do |choice,i|%> + " id="<%="#{field.keys[0]}_#{choice}"%>" class="required" value="<%=choice%>" <%= (@olympia_student_data[field.keys[0]].to_s== choice.to_s) ? 'checked=checked' : '' %>> + + <% 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 %> +
  • + <% if !field.values[0][:hint][I18n.locale.to_s].blank? %> + <%=field.values[0][:hint][I18n.locale.to_s]%> + <% end %> +
    + <% end %> +
    + + + <% end %> +
    \ No newline at end of file diff --git a/app/views/admin/olympiamanagements/add_student_data.html.erb b/app/views/admin/olympiamanagements/add_student_data.html.erb new file mode 100644 index 0000000..5175af8 --- /dev/null +++ b/app/views/admin/olympiamanagements/add_student_data.html.erb @@ -0,0 +1,68 @@ + + +<%= stylesheet_link_tag "lib/fileupload"%> +<%= javascript_include_tag 'lib/bootstrap-fileupload' %> + +
    + <%=t('olympiamanagement.'+(!@olympia_student_data.new_record? ? 'edit_sign_up_student_data' : 'add_sign_up_student_data'))%> + <%=form_for @olympia_student_data ,:url=>{:controller=>"olympiamanagements" ,:action=>"updata_student_date",:type=>"add_student_data",:id=>params[:id]}, :html => {:multipart => true} do |form|%> + + <% @student_data_field.student_data_fields.each do |field| %> +
    + <% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%> + <% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%> + <%if !["StudentBirthYear","StudentBirthMonth","StudentBirthDay"].include?(field.keys[0]) %> +
  • <%= @extra_text+t('olympiamanagement.'+field.keys[0]) %>
  • + <%elsif field.keys[0]=="StudentBirthYear"%> +
  • <%= @extra_text+t('olympiamanagement.birth_date') %>
  • + <%end%> +
  • + <% if field.values[0][:type] == 'String' %> + " 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." %> + + <%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." %> + + <%=t('olympiamanagement.year')%> + <% elsif field.values[0][:type] == 'select_string' %> + <% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %> + + <% elsif field.values[0][:type] == 'radio' %> + <%field.values[0][:choices].each_with_index do |choice,i|%> + " id="<%="#{field.keys[0]}_#{choice}"%>" class="required" value="<%=choice%>" <%= (@olympia_student_data[field.keys[0]].to_s== choice.to_s) ? 'checked=checked' : '' %>> + + <% 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 %> +
  • + <% if !field.values[0][:hint][I18n.locale.to_s].blank? %> + <%=field.values[0][:hint][I18n.locale.to_s]%> + <% end %> +
    + <% end %> +
    + + + <% end %> +
    \ No newline at end of file diff --git a/app/views/admin/olympiamanagements/import_error_msg.html.erb b/app/views/admin/olympiamanagements/import_error_msg.html.erb index 3837e03..5131a03 100644 --- a/app/views/admin/olympiamanagements/import_error_msg.html.erb +++ b/app/views/admin/olympiamanagements/import_error_msg.html.erb @@ -11,4 +11,4 @@ -<%= link_to t('back'), :back, :class => 'btn' %> \ No newline at end of file + \ No newline at end of file diff --git a/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb b/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb index 18e4922..2526ce9 100644 --- a/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb +++ b/app/views/admin/olympiamanagements/sign_up_student_data_list.html.erb @@ -1,7 +1,7 @@ -<% th_name_list = ['StudentIdentity','StudentName','StudentClass','StudentArea','StudentPhone','action']%> +<% th_name_list = ['StudentName','StudentSex','StudentClass','birth_date','StudentIdentity','StudentArea','scan_file_of_certificate','action']%> @@ -14,7 +14,15 @@ <% @student_fields.each do |field| %> <% th_name_list.each do |th_name|%> - <%if th_name != 'action'%> + <%if th_name == 'birth_date'%> + + <% elsif th_name == 'scan_file_of_certificate'%> + <% if !field.olympia_student_images.map{|image| image.student_file.file}.select { |file| file.present?}.empty? %> + + <% else %> + + <% end %> + <%elsif th_name != 'action'%> <% @value = field[th_name] %> <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%> <% if !@index.nil? %> @@ -23,8 +31,8 @@ <% else %> <% end %> <% end %> diff --git a/app/views/olympiamanagements/_add_student_data.html.erb b/app/views/olympiamanagements/_add_student_data.html.erb index ac09d73..b5818a4 100644 --- a/app/views/olympiamanagements/_add_student_data.html.erb +++ b/app/views/olympiamanagements/_add_student_data.html.erb @@ -5,7 +5,7 @@
    <%=t('olympiamanagement.'+(!@olympia_student_data.new_record? ? 'edit_sign_up_student_data' : 'add_sign_up_student_data'))%> - <%=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| %>
    <% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%> @@ -38,12 +38,16 @@ <%=t('olympiamanagement.year')%> <% elsif field.values[0][:type] == 'select_string' %> - <% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %> - " id="<%=field.keys[0]%>" class="required" value="<%= @olympia_student_data[field.keys[0]] %>" style="width: auto;"> + <% field.values[0]["values"][I18n.locale.to_s].each_with_index do |value,i| %> + <%= ('').html_safe %> + <% end %> + <% end %> - <% elsif field.values[0][:type] == 'radio' %> <%field.values[0][:choices].each_with_index do |choice,i|%> " id="<%="#{field.keys[0]}_#{choice}"%>" class="required" value="<%=choice%>" <%= (@olympia_student_data[field.keys[0]].to_s== choice.to_s) ? 'checked=checked' : '' %>> diff --git a/app/views/olympiamanagements/_edit_school_data.html.erb b/app/views/olympiamanagements/_edit_school_data.html.erb index 3903d50..cf8caef 100644 --- a/app/views/olympiamanagements/_edit_school_data.html.erb +++ b/app/views/olympiamanagements/_edit_school_data.html.erb @@ -3,7 +3,7 @@
    <%=t('olympiamanagement.school_connection_data')%> - <%=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| %>
    <% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%> diff --git a/app/views/olympiamanagements/_import_error_msg.html.erb b/app/views/olympiamanagements/_import_error_msg.html.erb index 51740db..4abddca 100644 --- a/app/views/olympiamanagements/_import_error_msg.html.erb +++ b/app/views/olympiamanagements/_import_error_msg.html.erb @@ -5,5 +5,5 @@ <% end %>

    - <%= link_to t('back'), :back, :class => 'btn' %> +

    \ No newline at end of file diff --git a/app/views/olympiamanagements/_student_data_list.html.erb b/app/views/olympiamanagements/_student_data_list.html.erb index 18e4922..1cd4668 100644 --- a/app/views/olympiamanagements/_student_data_list.html.erb +++ b/app/views/olympiamanagements/_student_data_list.html.erb @@ -24,7 +24,7 @@ <% else %>
    <% end %> <% end %> diff --git a/app/views/olympiamanagements/updata_school_data.html.erb b/app/views/olympiamanagements/update_school_data.html.erb similarity index 100% rename from app/views/olympiamanagements/updata_school_data.html.erb rename to app/views/olympiamanagements/update_school_data.html.erb diff --git a/app/views/olympiamanagements/updata_student_data.html.erb b/app/views/olympiamanagements/update_student_data.html.erb similarity index 100% rename from app/views/olympiamanagements/updata_student_data.html.erb rename to app/views/olympiamanagements/update_student_data.html.erb diff --git a/config/locales/en.yml b/config/locales/en.yml index e25e66a..36330cf 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -1,5 +1,6 @@ en: olympiamanagement: + scan_file_of_certificate: Scan file of certificate sign_up_title: International Junior Science Olympiad First Stage Online Sign UP error_msg: Error message id_number_error: ID Number error diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 1579683..a960538 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -1,5 +1,6 @@ zh_tw: olympiamanagement: + scan_file_of_certificate: 獎狀掃描 sign_up_title: 國中科學奧林匹亞競賽初選線上報名 error_msg: 錯誤訊息 id_number_error: 身分證字號錯誤 diff --git a/config/routes.rb b/config/routes.rb index 6e11371..5ce6c7b 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -21,6 +21,10 @@ Rails.application.routes.draw do get 'olympiamanagements/update_sign_up_data' , to: 'olympiamanagements#update_sign_up_data' 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/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 end resource 'olympiamanagements' do
    <%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %><%= "#{field.StudentName}.gif" %><%= "> <%= @value %> - "><%= t('olympiamanagement.edit') %><%= t('olympiamanagement.edit') %> - "><%= t('olympiamanagement.delete') %><%= t('olympiamanagement.delete') %> + "><%= t('olympiamanagement.edit') %><%= t('olympiamanagement.edit') %> + "><%= t('olympiamanagement.delete') %><%= t('olympiamanagement.delete') %> "><%= t('olympiamanagement.edit') %><%= t('olympiamanagement.edit') %> - "><%= t('olympiamanagement.delete') %><%= t('olympiamanagement.delete') %> + "><%= t('olympiamanagement.delete') %><%= t('olympiamanagement.delete') %>