From 991f2dd71f670e463140c71ed983642bc8e88003 Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Tue, 4 Feb 2020 19:51:05 +0800 Subject: [PATCH] fix and finish print registration from --- .../olympiamanagements_controller.rb | 14 ++++---- .../sign_up_setting.html.erb | 2 +- .../print_registration_form.html.erb | 32 +++++++++++++------ 3 files changed, 31 insertions(+), 17 deletions(-) diff --git a/app/controllers/olympiamanagements_controller.rb b/app/controllers/olympiamanagements_controller.rb index 19979ed..5092667 100644 --- a/app/controllers/olympiamanagements_controller.rb +++ b/app/controllers/olympiamanagements_controller.rb @@ -50,7 +50,7 @@ class OlympiamanagementsController < ApplicationController {:url=>'/olympiamanagements/edit_password',:name=>t('olympiamanagement.edit_password')}, {:url=>'/olympiamanagements/print_registration_form',:name=>t('olympiamanagement.print_registration_form')}, {:url=>'/olympiamanagements/logout',:name=>t('olympiamanagement.logout')}] - @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.sign_up_title')}) + @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olympiamanagement.sign_up_title')}) end def index uid = OrbitHelper.params[:uid] rescue "" @@ -84,7 +84,7 @@ class OlympiamanagementsController < ApplicationController end end data_arr = @page.child_page.map{|page| {:url=>"/#{I18n.locale}#{page.url}",:name=>page.name}} - @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.sign_up_title')}) + @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olympiamanagement.sign_up_title')}) @olympiamanagement_instruction = @breadcumb + @olympiamanagement_instruction.html_safe else if !@instructions_pages.empty? @@ -140,7 +140,7 @@ class OlympiamanagementsController < ApplicationController @instructions_pages.each{|page| page.destroy} end data_arr = @page.child_page.map{|page| {:url=>"/#{I18n.locale}#{page.url}",:name=>page.name}} - @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.sign_up_title')}) + @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olympiamanagement.sign_up_title')}) @page_content = @breadcumb+'

'+t('olympiamanagement.sign_up_hint')+'

' end { @@ -242,8 +242,8 @@ class OlympiamanagementsController < ApplicationController end def print_registration_form @page = Page.where(:layout=>"olympia_managements_index",:parent_page_id=>(Page.where(:name=> ((I18n.locale.to_s == "en") ? "Home" : "首頁")).first.id)).first - data_arr = @page.child_page.map{|page| {:url=>"/#{I18n.locale}#{page.url}",:name=>page.name}} - @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.sign_up_title')}) + data_arr = @page.child_page.map{|page| {:url=>"#{request.protocol}#{request.host_with_port}/#{I18n.locale}#{page.url}",:name=>page.name}} + @breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olympiamanagement.sign_up_title')}) @remark_texts =SignUpSetting.last.remark_field[I18n.locale.to_s].html_safe @record_form_title = ((I18n.locale.to_s == "zh_tw") ? "#{Time.now.year}年國中科學奧林匹亞競賽國家代表隊選拔初選報名表" : "#{Time.now.year} Year International Junior Science Olympiad National Team Selection First Stage Sign up Form") @school_data = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first @@ -254,7 +254,7 @@ class OlympiamanagementsController < ApplicationController @olympia_school_data_fields_id = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first.id @sign_up_setting_id = SignUpSetting.last.id @student_data_list = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_fields_id,:sign_up_setting_id=>@sign_up_setting_id) - render :html => @student_data_list.to_a + @head = render_to_string(:formats=>[:html],:file=>"#{Rails.root}/app/templates/#{@key}/partial/_head.html") end def logout session[:olympia_login_id] = "" @@ -277,7 +277,7 @@ class OlympiamanagementsController < ApplicationController end def download_school_code @OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id) - dir_path = 'tmp/olypiamanagement/' + dir_path = 'tmp/olympiamanagement/' #FileUtils.rm_r(dir_path, :force => true) if Dir.exist?(dir_path) FileUtils.mkdir dir_path if !Dir.exist?(dir_path) #create dir for storing tmp_file if dir doesn't exist @filename = 'download_school_code.xlsx' diff --git a/app/views/admin/olympiamanagements/sign_up_setting.html.erb b/app/views/admin/olympiamanagements/sign_up_setting.html.erb index df32b3b..6725ae8 100644 --- a/app/views/admin/olympiamanagements/sign_up_setting.html.erb +++ b/app/views/admin/olympiamanagements/sign_up_setting.html.erb @@ -3,7 +3,7 @@
<%=t('olympiamanagement.sign_up_setting')%> - <%=form_for @sign_up_setting ,:url=>{:controller=>"olympiamanagements" ,:action=>"update_school_data",:type=>"sign_up_setting",:id=>params[:id]} do |form|%> + <%=form_for @sign_up_setting ,:url=>{:controller=>"olympiamanagements" ,:action=>"update_school_data",:type=>"sign_up_setting",:id=>@sign_up_setting.id} do |form|%> <%=t('olympiamanagement.delete_all_sign_up_data')%><%=t('olympiamanagement.delete_all_sign_up_data')%>
diff --git a/app/views/olympiamanagements/print_registration_form.html.erb b/app/views/olympiamanagements/print_registration_form.html.erb index 2a26bad..c216146 100644 --- a/app/views/olympiamanagements/print_registration_form.html.erb +++ b/app/views/olympiamanagements/print_registration_form.html.erb @@ -1,3 +1,9 @@ + + + + <%=@head%> + +
<%=@breadcumb%> @@ -6,7 +12,7 @@ <% record_block.each do |record_item| %> - + <% end %> <% end %> @@ -24,15 +30,21 @@ <% end %> - <% @student_data_list.each do |field| %> + <% @student_data_list.each_with_index do |field,i| %> - <% student_fields.each do |th_name|%> - <% @value = field[th_name] %> - <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%> - <% if !@index.nil? %> - <% (['String','Year','select_num','File'].include?(@field_infos.map{|hash| hash.values[0]}[@index]['type'])) ? (nil) : (@value=(@field_infos.map{|hash| hash.values[0]}[@index]['values'][I18n.locale.to_s][@value.to_i].to_s rescue @value))%> + <% @student_fields.each do |th_name|%> + <% if th_name == 'serial_number' %> + + <%elsif th_name != 'birth_date'%> + <% @value = field[th_name] %> + <% @index = @field_infos.map{|hash| hash.keys[0]}.index(th_name) rescue nil%> + <% if !@index.nil? %> + <% (['String','Year','select_num','File'].include?(@field_infos.map{|hash| hash.values[0]}[@index]['type'])) ? (nil) : (@value=(@field_infos.map{|hash| hash.values[0]}[@index]['values'][I18n.locale.to_s][@value.to_i].to_s rescue @value))%> + <% end %> + + <% else %> + <% end %> - <% end %> <%end%> @@ -45,4 +57,6 @@ print(text) } - \ No newline at end of file + + +> \ No newline at end of file