fix and finish print registration from

This commit is contained in:
BOHUNG 2020-02-04 19:51:05 +08:00
parent a9617de263
commit 991f2dd71f
3 changed files with 31 additions and 17 deletions

View File

@ -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+'<h3 style="margin: 20px 0px 10px; padding: 0px; color: rgb(0, 153, 153); font-variant-numeric: normal; font-variant-east-asian: normal; font-weight: bold; font-stretch: normal; font-size: 0.9375em; line-height: 20px; font-family: 微軟正黑體, sans-serif;">'+t('olympiamanagement.sign_up_hint')+'</h3>'
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'

View File

@ -3,7 +3,7 @@
<script src="/assets/admin/olympiamanagement.js"></script>
<fieldset class="fieldset_block sign_up_setting_block">
<legend class="fieldset_title"><%=t('olympiamanagement.sign_up_setting')%></legend>
<%=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|%>
<a href="#" onclick="if( window.confirm('Please confirm deletion.?') ) { window.location='<%=admin_olympiamanagements_update_sign_up_data_path + '?type=delete_old_data'%>'; }" onkeypress="if( window.confirm('Please confirm deletion.?') ) { window.location='<%=admin_olympiamanagements_update_sign_up_data_path + '?type=delete_old_data'%>'; }">
<img src="/assets/trash.gif" alt="<%=t('olympiamanagement.delete_all_sign_up_data')%>" align="top" width="24"><%=t('olympiamanagement.delete_all_sign_up_data')%></a>
<hr style="border-color: black;border-top: 0em;">

View File

@ -1,3 +1,9 @@
<!DOCTYPE html>
<html>
<head>
<%=@head%>
</head>
<body>
<div id="main1"><div id="main2"><div id="main">
<%=@breadcumb%>
<table class="print_contest1"><tbody>
@ -6,7 +12,7 @@
<tr>
<% record_block.each do |record_item| %>
<td <%=((i==@record_fields.count-1) ? "style=line-height:80px;" : "")%>><%=t('olympiamanagement.'+record_item.to_s)%></td>
<td <%=((i==@record_fields.count-1) ? "style=line-height:80px;" : "")%>><%=(@school_data[record_item.to_s].nil? ? '&nbsp;' : @school_data[record_item.to_s]) %></td>
<td <%=((i==@record_fields.count-1) ? "style=line-height:80px;" : "")%>><%=(@school_data[record_item.to_s].nil? ? '&nbsp;'.html_safe : @school_data[record_item.to_s]) %></td>
<% end %>
</tr>
<% end %>
@ -24,15 +30,21 @@
<td><%=t('olympiamanagement.'+field_name.to_s)%></td>
<% end %>
</tr>
<% @student_data_list.each do |field| %>
<% @student_data_list.each_with_index do |field,i| %>
<tr>
<% 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' %>
<td><%= "#{i+1}" %></td>
<%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 %>
<td><%= @value %></td>
<% else %>
<td><%= "#{field.StudentBirthYear}-#{field.StudentBirthMonth}-#{field.StudentBirthDay}" %></td>
<% end %>
<td><%= @value %></td>
<% end %>
</tr>
<%end%>
@ -45,4 +57,6 @@
print(text)
}
</script>
</div></div></div></div></div></div></div>
</div></div></div></div></div></div></div>
</body>
</html>>