fix
This commit is contained in:
parent
61a8db592c
commit
ca31360f65
|
@ -123,6 +123,9 @@ ol {
|
|||
.lleft{
|
||||
float: left;
|
||||
}
|
||||
.red_text{
|
||||
color: red;
|
||||
}
|
||||
li{
|
||||
display: block;
|
||||
}
|
|
@ -7,6 +7,9 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
helper Admin::OlympiamanagementsHelper
|
||||
load File.expand_path(__dir__)+'/zipgenerator.rb'
|
||||
def index
|
||||
page_num = params[:page] || 1
|
||||
@sign_up_settings = SignUpSetting.all.desc(:id)
|
||||
@sign_up_settings = @sign_up_settings.page(page_num).per(10)
|
||||
end
|
||||
def add_school_data
|
||||
SchoolDataFields.create if SchoolDataFields.all.count == 0
|
||||
|
@ -15,9 +18,34 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
end
|
||||
def update_sign_up_data
|
||||
if params[:type] == "delete_old_data"
|
||||
|
||||
@students = OlympiaStudentDataField.where(:sign_up_setting_id=>@sign_up_setting.id)
|
||||
@error_msg = []
|
||||
if @students.length !=0
|
||||
@students.destroy_all
|
||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? "已刪除#{@students.length}筆學生資料" : "Already delete #{@students.length} student data.")
|
||||
else
|
||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? "尚無學生資料" : "There is no student data yet.")
|
||||
end
|
||||
render 'error_message'
|
||||
elsif params[:type] == "active"
|
||||
@sign_up_setting = SignUpSetting.find(params[:id]) rescue nil
|
||||
if !@sign_up_setting.nil?
|
||||
@sign_up_setting.active = true
|
||||
@sign_up_setting.save
|
||||
end
|
||||
redirect_to :back
|
||||
elsif params[:type] == "view"
|
||||
@sign_up_setting = SignUpSetting.find(params[:id]) rescue nil
|
||||
if !@sign_up_setting.nil?
|
||||
session[:sign_up_setting_id] = params[:id]
|
||||
redirect_to admin_olympiamanagements_school_data_list_path
|
||||
else
|
||||
@error_msg = []
|
||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? "查無資料" : "Not found.")
|
||||
render 'error_message'
|
||||
end
|
||||
else
|
||||
render :html => params and return
|
||||
render :html => '404' and return
|
||||
end
|
||||
end
|
||||
def update_school_data
|
||||
|
@ -77,15 +105,19 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
redirect_to :back
|
||||
end
|
||||
elsif params[:type] == 'sign_up_setting'
|
||||
@sign_up_setting = SignUpSetting.find(params[:id]) rescue SignUpSetting.where(:active=>true).last
|
||||
if @sign_up_setting.nil?
|
||||
render_404_html
|
||||
else
|
||||
params["sign_up_setting"].each do |key,value|
|
||||
@sign_up_setting[key] = value
|
||||
end
|
||||
@sign_up_setting.save
|
||||
@sign_up_params = params.require(:sign_up_setting).permit!
|
||||
if params[:new_sign_up] == "true"
|
||||
#render :html => @sign_up_params and return
|
||||
SignUpSetting.create(@sign_up_params)
|
||||
redirect_to :back
|
||||
else
|
||||
@sign_up_setting = SignUpSetting.find(params[:id]) rescue SignUpSetting.where(:active=>true).last
|
||||
if @sign_up_setting.nil?
|
||||
render_404_html
|
||||
else
|
||||
@sign_up_setting.update_attributes(@sign_up_params)
|
||||
redirect_to :back
|
||||
end
|
||||
end
|
||||
else
|
||||
render :html => params and return
|
||||
|
@ -98,7 +130,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
@SchoolDataField = SchoolDataFields.first
|
||||
@SchoolDataname = @SchoolDataField.school_data_fields.map{|field| field.keys[0]}
|
||||
page_num = params[:page] || 1
|
||||
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
|
||||
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.where(:sign_up_setting_id=>@sign_up_setting.id).asc(:id)
|
||||
@OlympiaSchoolDataFields = @OlympiaSchoolDataFields.where("school_name" => /#{params[:school_name]}/) if !params[:school_name].to_s.blank?
|
||||
@OlympiaSchoolDataFields = @OlympiaSchoolDataFields.where("school_code" => /#{params[:school_code]}/) if !params[:school_code].to_s.blank?
|
||||
@OlympiaSchoolDataFields = @OlympiaSchoolDataFields.page(page_num).per(10)
|
||||
|
@ -127,17 +159,14 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
@filename = filename.nil? ? tempfile.path : filename
|
||||
workbook = RubyXL::Parser.parse(tempfile)
|
||||
sheet = workbook[0].sheet_data.rows
|
||||
first_index = 0
|
||||
flag = 1
|
||||
sheet.each_with_index do |raw_row,index|
|
||||
row = raw_row.cells.map{ |cell| cell.value rescue nil}
|
||||
if row.nil? && first_index != -1
|
||||
first_index += 1
|
||||
next
|
||||
elsif row.nil?
|
||||
row = raw_row.cells.map{ |cell| (cell.nil?) ? '' : cell.value } rescue nil
|
||||
if row.nil?
|
||||
next
|
||||
end
|
||||
if index == first_index || first_index != -1
|
||||
first_index = -1
|
||||
if flag == 1
|
||||
flag = 0
|
||||
else
|
||||
#@error_msg << @row_index_hash and return false
|
||||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:school_code=> row[@row_index_hash["school_code"]]).first
|
||||
|
@ -163,20 +192,18 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
return @error_msg
|
||||
end
|
||||
sheet = workbook[0].sheet_data.rows
|
||||
first_index = 0
|
||||
flag = 1
|
||||
sheet.each_with_index do |raw_row,index|
|
||||
begin
|
||||
row = raw_row.cells.map{ |cell| cell.value rescue nil}
|
||||
row = raw_row.cells.map{ |cell| (cell.nil?) ? '' : cell.value } rescue nil
|
||||
rescue
|
||||
@error_msg << filename+'格式錯誤'
|
||||
return @error_msg
|
||||
end
|
||||
if row.nil? && first_index != -1
|
||||
next
|
||||
elsif row.nil?
|
||||
if row.nil?
|
||||
next
|
||||
end
|
||||
if index == first_index || first_index != -1
|
||||
if flag == 1
|
||||
@field_data = row
|
||||
delete_array = []
|
||||
@profile_data_row.each do |row_key|
|
||||
|
@ -187,11 +214,16 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
end
|
||||
end
|
||||
delete_array.each{|element| @profile_data_row.delete(element)}
|
||||
first_index = -1
|
||||
flag = 0
|
||||
else
|
||||
#@error_msg << @row_index_hash and return
|
||||
if row[@row_index_hash["school_code"]] == ""
|
||||
@error_msg << @filename+"中#{make_alpha_from_numbers(@row_index_hash['school_code'])}#{index+1}欄位學校代碼不符(該欄位值不可為空)。"
|
||||
if(row[@row_index_hash["school_code"]] == "" rescue true)
|
||||
begin
|
||||
@error_msg << @filename+"中#{make_alpha_from_numbers(@row_index_hash['school_code'])}#{index+1}欄位學校代碼不符(該欄位值不可為空)。"
|
||||
rescue
|
||||
@error_msg << "#{@filename}檔案格式錯誤"
|
||||
return
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -227,7 +259,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
def sign_up_student_data_list
|
||||
page_num = params[:page] || 1
|
||||
@field_infos = StudentDataField.first.student_data_fields
|
||||
@sign_up_setting_id = SignUpSetting.id
|
||||
@sign_up_setting_id = @sign_up_setting.id
|
||||
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>params[:olympia_school_id],:sign_up_setting_id=>@sign_up_setting_id).asc(:id).page(page_num).per(10)
|
||||
end
|
||||
def export_sign_up_student_data
|
||||
|
@ -262,14 +294,20 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
@student_data_list << @tmp_student_data
|
||||
end
|
||||
#render :html => @student_data_list and return
|
||||
@filename = 'student_export.xlsx'
|
||||
Dir.chdir(dir_path) do
|
||||
File.open(@filename, 'w') do |f|
|
||||
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'student_export.xlsx',:locals=> {:@student_data_list=>@student_data_list,:@fields=>@fields} )
|
||||
if @student_data_list.empty?
|
||||
@error_msg = []
|
||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? "尚無學生資料" : "There is no student data yet.")
|
||||
render 'error_message'
|
||||
else
|
||||
@filename = 'student_export.xlsx'
|
||||
Dir.chdir(dir_path) do
|
||||
File.open(@filename, 'w') do |f|
|
||||
f.write render_to_string( :handlers=> [:axlsx], :formats=> [:xlsx] ,:partial=> 'student_export.xlsx',:locals=> {:@student_data_list=>@student_data_list,:@fields=>@fields} )
|
||||
end
|
||||
end
|
||||
tmp_filename_data = File.read(dir_path +@filename)
|
||||
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
|
||||
end
|
||||
tmp_filename_data = File.read(dir_path +@filename)
|
||||
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
|
||||
end
|
||||
def download_scan_file_of_certificate
|
||||
@sign_up_setting_id = @sign_up_setting.id
|
||||
|
@ -299,20 +337,25 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
@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
|
||||
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 !@student_data_image_path_arr.empty?
|
||||
@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)
|
||||
else
|
||||
@error_msg = []
|
||||
@error_msg << ((I18n.locale.to_s == "zh_tw") ? "尚無學生獎狀掃描檔案。" : 'There is no scan file of certificate yet.' )
|
||||
render 'error_message'
|
||||
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
|
||||
|
@ -329,7 +372,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
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'
|
||||
render 'error_message'
|
||||
else
|
||||
@student_data_field = StudentDataField.first
|
||||
@olympia_student_data = (OlympiaStudentDataField.find(params[:id]) rescue OlympiaStudentDataField.new)
|
||||
|
@ -372,7 +415,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
end
|
||||
redirect_to admin_olympiamanagements_sign_up_student_data_list_path+"?olympia_school_id=#{params[:school_id]}"
|
||||
else
|
||||
render 'import_error_msg'
|
||||
render 'error_message'
|
||||
end
|
||||
elsif params[:type] == 'delete_student_data'
|
||||
@olympia_student_data = OlympiaStudentDataField.find(params[:id]) rescue nil
|
||||
|
@ -389,7 +432,13 @@ class Admin::OlympiamanagementsController < OrbitAdminController
|
|||
StudentDataField.create if StudentDataField.all.length == 0
|
||||
SchoolDataFields.create if SchoolDataFields.all.length == 0
|
||||
SignUpSetting.create if SignUpSetting.all.length == 0
|
||||
@sign_up_setting = SignUpSetting.where(:active=>true).last
|
||||
@sign_up_setting
|
||||
if session[:sign_up_setting_id].blank?
|
||||
@sign_up_setting = SignUpSetting.where(:active=>true).last
|
||||
else
|
||||
@sign_up_setting = SignUpSetting.find(session[:sign_up_setting_id]) rescue nil
|
||||
@sign_up_setting = SignUpSetting.where(:active=>true).last if @sign_up_setting.nil?
|
||||
end
|
||||
end
|
||||
def download_import_file
|
||||
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
|
||||
|
|
|
@ -11,6 +11,9 @@ class OlympiamanagementsController < ApplicationController
|
|||
end
|
||||
def create_first_fields
|
||||
StudentDataField.create if StudentDataField.all.length == 0
|
||||
SchoolDataFields.create if SchoolDataFields.all.length == 0
|
||||
SignUpSetting.create if SignUpSetting.all.length == 0
|
||||
@sign_up_setting = SignUpSetting.where(:active=>true).last
|
||||
end
|
||||
def check_login
|
||||
begin
|
||||
|
@ -72,7 +75,7 @@ class OlympiamanagementsController < ApplicationController
|
|||
@instructions_pages = Page.where(:parent_page_id=>@page.id).select{|page| page.name_translations==@instructions_name}
|
||||
case OrbitHelper.params[:layout_type]
|
||||
when "olympia_managements_instructions_index"
|
||||
if !(time_now_str <= end_time_str && time_now_str >= start_time_str)
|
||||
if (time_now_str <= end_time_str && time_now_str >= start_time_str)
|
||||
@olympiamanagement_instruction = @sign_up_setting.registration_instructions[I18n.locale.to_s].to_s
|
||||
@sign_up_setting.attributes.to_h.each do |key,value|
|
||||
@olympiamanagement_instruction = @olympiamanagement_instruction.gsub("{{#{key}}}",value.to_s)
|
||||
|
@ -110,7 +113,7 @@ class OlympiamanagementsController < ApplicationController
|
|||
end
|
||||
@error = @@error rescue nil
|
||||
@page_content
|
||||
if !(time_now_str <= end_time_str && time_now_str >= start_time_str)
|
||||
if (time_now_str <= end_time_str && time_now_str >= start_time_str)
|
||||
if @instructions_pages.empty?
|
||||
@newpage = Page.create(:layout=> "olympia_managements_instructions_index",:data_count=>@page.data_count,:parent_page_id=>@page.id,:url=>"/olympia_instructions",
|
||||
:menu_enabled_for=>@page.menu_enabled_for,:enabled_for_sitemap=>@page.enabled_for_sitemap,:enabled_for=>@page.enabled_for,:module=>@page[:module],:page_id=>'olympia_instructions')
|
||||
|
@ -119,18 +122,8 @@ class OlympiamanagementsController < ApplicationController
|
|||
elsif @instructions_pages.length != 1
|
||||
@instructions_pages.slice(1,@instructions_pages.length).each{|page| page.destroy}
|
||||
end
|
||||
if !(OrbitHelper.params || params)[:login_id].to_s.blank? && @@session[:olympia_login_id].to_s.blank?
|
||||
if OlympiaSchoolDataFields.where(:account_number=>(OrbitHelper.params || params)[:login_id]).length == 0
|
||||
@error = "no_account"
|
||||
else
|
||||
if OlympiaSchoolDataFields.where(:account_number=>(OrbitHelper.params || params)[:login_id]).first.password != (OrbitHelper.params || params)[:login_pw]
|
||||
@error = "password_error"
|
||||
else
|
||||
@@session[:olympia_login_id] = (OrbitHelper.params || params)[:login_id]
|
||||
end
|
||||
end
|
||||
end
|
||||
if @@session[:olympia_login_id].to_s.blank?
|
||||
@school = OlympiaSchoolDataFields.where(:account_number=>@@session[:olympia_login_id],:approved=>true).first rescue nil
|
||||
if @school.nil?
|
||||
@page_content = render_to_string(:formats=> [:html] ,:partial=>'login',:locals=>{:@error=>@error})
|
||||
else
|
||||
@@error = nil
|
||||
|
@ -156,7 +149,7 @@ class OlympiamanagementsController < ApplicationController
|
|||
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('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>'
|
||||
@page_content = '<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
|
||||
{
|
||||
"olympiamanagement" => [],
|
||||
|
@ -169,7 +162,7 @@ class OlympiamanagementsController < ApplicationController
|
|||
start_time_str = @time_arr.map{|t| @sign_up_setting["start_"+t]}.join(' ')
|
||||
end_time_str = @time_arr.map{|t| @sign_up_setting["end_"+t]}.join(' ')
|
||||
time_now_str = Time.now.strftime("%Y %m %d %H %M")
|
||||
if !(time_now_str <= end_time_str && time_now_str >= start_time_str) || session[:olympia_login_id].to_s.blank?
|
||||
if (time_now_str <= end_time_str && time_now_str >= start_time_str)
|
||||
@school_data_fields = [{'account_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||
{'school_name'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||
{'school_code'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
|
||||
|
@ -194,7 +187,7 @@ class OlympiamanagementsController < ApplicationController
|
|||
start_time_str = @time_arr.map{|t| @sign_up_setting["start_"+t]}.join(' ')
|
||||
end_time_str = @time_arr.map{|t| @sign_up_setting["end_"+t]}.join(' ')
|
||||
time_now_str = Time.now.strftime("%Y %m %d %H %M")
|
||||
if !(!(time_now_str <= end_time_str && time_now_str >= start_time_str) || session[:olympia_login_id].to_s.blank?)
|
||||
if !(time_now_str <= end_time_str && time_now_str >= start_time_str)
|
||||
redirect_to :back
|
||||
else
|
||||
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
|
||||
|
|
|
@ -19,11 +19,17 @@ class OlympiaSchoolDataFields
|
|||
field :fax , type: String , default: ''
|
||||
field :mobile_number , type: String , default: ''
|
||||
field :email , type: String , default: ''
|
||||
field :enrollment , type: Fixnum , default: 0
|
||||
field :enrollment , type: Hash , default: 0
|
||||
field :approved , type: Boolean , default: true
|
||||
field :sign_up_setting_id , type: String , default: SignUpSetting.where(:active=>true).last.id.to_s
|
||||
after_destroy do |record|
|
||||
OlympiaStudentDataField.where(:olympia_school_data_fields_id => record.id,:sign_up_setting_id=>SignUpSetting.where(:active=>true).last.id).destroy_all
|
||||
OlympiaStudentDataField.where(:olympia_school_data_fields_id => record.id).destroy_all
|
||||
end
|
||||
after_save do |record|
|
||||
if record.account_number.blank? && !record.school_code.blank?
|
||||
record.account_number = record.school_code
|
||||
record.save
|
||||
end
|
||||
end
|
||||
after_initialize do
|
||||
if !self.new_record?
|
||||
|
@ -35,10 +41,6 @@ class OlympiaSchoolDataFields
|
|||
self.enrollment = 0
|
||||
self.save!
|
||||
end
|
||||
if self.enrollment == 0 #check enrollment student number
|
||||
self.enrollment = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>self.id,:sign_up_setting_id=>SignUpSetting.where(:active=>true).last.id).length
|
||||
self.save!
|
||||
end
|
||||
if self.enrollment_limited.nil?
|
||||
self.enrollment_limited = 0
|
||||
self.save!
|
||||
|
|
|
@ -21,14 +21,14 @@ class OlympiaStudentDataField
|
|||
field :remove_image , type: Boolean , default: false
|
||||
field :approved , type: Boolean , default: true
|
||||
field :olympia_school_data_fields_id , type: String , default: ''
|
||||
field :sign_up_setting_id , type: String , default: ''
|
||||
field :sign_up_setting_id , type: String , default: SignUpSetting.where(:active=>true).last.id.to_s
|
||||
has_many :olympia_student_images , :dependent => :destroy , autosave: true
|
||||
after_save :check_file
|
||||
after_create do |record|
|
||||
if !record.olympia_school_data_fields_id.blank?
|
||||
@school = OlympiaSchoolDataFields.find(record.olympia_school_data_fields_id) rescue nil
|
||||
if !@school.nil?
|
||||
@school.enrollment = @school.enrollment + 1
|
||||
@school.enrollment += 1
|
||||
@school.save
|
||||
end
|
||||
end
|
||||
|
@ -37,7 +37,7 @@ class OlympiaStudentDataField
|
|||
if !record.olympia_school_data_fields_id.blank?
|
||||
@school = OlympiaSchoolDataFields.find(record.olympia_school_data_fields_id) rescue nil
|
||||
if !@school.nil?
|
||||
@school.enrollment = @school.enrollment - 1
|
||||
@school.enrollment -= 1
|
||||
@school.save
|
||||
end
|
||||
end
|
||||
|
|
|
@ -18,16 +18,31 @@ class SignUpSetting
|
|||
field :end_minute , type: String , default: Time.now.strftime("%M")
|
||||
field :default_password , type: String , default: ""
|
||||
field :set_default_password , type: Boolean , default: false
|
||||
field :remark_field , type: Hash , default: {:zh_tw=>"<strong><span style="font-size: 14pt"><span style="font-family: arial, helvetica, sans-serif">注意事項:</span></span></strong><span style="font-size: 14pt"><br />
|
||||
請於<strong><span style="color: rgb(255,0,0)">2019年5月3日前</span></strong>(以郵戳為憑),將本報名表正本(需核章)以掛號方式郵寄至【<strong><span style="color: rgb(0,0,255)">11677台北市文山區汀州路4段88號科教中心,收件人: IJSO選訓委員會</span></strong>】,逾期概不受理報名。 <br />
|
||||
<br type="_moz" />
|
||||
</span><br />",:en=>""}
|
||||
field :registration_instructions , type: Hash , default: {:zh_tw=>"",:en=>""}
|
||||
field :remark_field , type: Hash , default: {:zh_tw=>'<strong><span style="font-size: 14pt"><span style="font-family: arial, helvetica, sans-serif">注意事項:</span></span></strong><span style="font-size: 14pt"><br />
|
||||
請於<strong><span style="color: rgb(255,0,0)">{{end_year}}年{{end_month}}月{{end_day}}日前</span></strong>(以郵戳為憑),將本報名表正本(需核章)以掛號方式郵寄至【<strong><span style="color: rgb(0,0,255)">11677台北市文山區汀州路4段88號科教中心,收件人: IJSO選訓委員會</span></strong>】,逾期概不受理報名。 <br />
|
||||
<br type="_moz" /></span><br />',:en=>""}
|
||||
field :registration_instructions , type: Hash , default: {:zh_tw=>'<p class="MsoListParagraph" style="margin-left: 18pt; text-indent: -18pt; mso-list: l0 level1 lfo2"><span lang="EN-US" style="font-size: 9pt; color: #333333"><span style="color: rgb(255, 0, 0);"><span style="font-size: 16pt;">報名日期:{{start_year}}/{{start_month}}/{{start_day}}~{{end_year}}/{{end_month}}/{{end_day}}</span></span></span><br />
|
||||
<br /><span style="font-size: 10pt;"><span lang="EN-US" style="color: rgb(51, 51, 51);">1.<span style="font-family: "Times New Roman"; font-stretch: normal;"> </span></span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">線上報名系統之各校登入帳號為學校代碼,密碼隨公文發至各校。</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(</span></span><b><span lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: blue; background-size: initial; background-origin: initial; background-clip: initial"><span lang="EN-US" style="text-decoration: none; font-family: "新細明體",serif; color: #333333; mso-ascii-font-family: Arial; mso-hansi-font-family: Arial; text-underline: none"><span lang="EN-US"><span style="font-size: 10pt;"><a href="/olympiamanagements/download_school_code">學校代碼查詢</a></span></span></span></span></b><span style="font-size: 10pt;"><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">)</span></span><br />
|
||||
<br /><span lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: rgb(51,51,51); background-size: initial; background-origin: initial; background-clip: initial"><o:p></o:p></span><span style="font-size: 10pt;"><!--[if !supportLists]--><span lang="EN-US" style="color: rgb(51, 51, 51);">2.<span style="font-family: "Times New Roman"; font-stretch: normal;"> </span></span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">登入系統後,請先填</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">「<span style="color: rgb(255, 0, 0);">學校聯絡資料</span>」</span></span><br />
|
||||
<br /><span lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: rgb(51,51,51); background-size: initial; background-origin: initial; background-clip: initial"><o:p></o:p></span><span style="font-size: 10pt;"><!--[if !supportLists]--><span lang="EN-US" style="color: rgb(51, 51, 51);">3.<span style="font-family: "Times New Roman"; font-stretch: normal;"> </span></span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">新增報名學生資料:</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(1)</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">學生姓名</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(2)</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">性別</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(3)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">身份證字號</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(4)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">出生年月日</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(5)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">班級</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(6)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">聯絡電話</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(7)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">郵遞區號</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(8)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">地址</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(9)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">身份</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51);">(</span><span style="color: rgb(51, 51, 51);">一般身份、科展得獎者</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51);">) : </span><span style="color: rgb(51, 51, 51);">科展得獎者需要上傳獎狀掃描檔</span><br />
|
||||
<span lang="EN-US" style="font-family: "Segoe UI Symbol", sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">(10)</span><span lang="EN-US" style="color: rgb(51, 51, 51);"> </span><span style="color: rgb(51, 51, 51);">考區</span><br />
|
||||
<br /><span lang="EN-US" style="color: rgb(51, 51, 51);">4.<span style="font-family: "Times New Roman"; font-stretch: normal;"> </span></span><span style="color: rgb(255, 0, 0);"><span style="background-size: initial; background-origin: initial; background-clip: initial;">列印報名表,由校長及教務主任核章後</span></span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">,以掛號郵寄至【</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">11677</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">台北市文山區汀州路</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">4</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">段</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">88</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">號科教中心,收件人:</span><span lang="EN-US" style="font-family: Arial, sans-serif; color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">IJSO</span><span style="color: rgb(51, 51, 51); background-size: initial; background-origin: initial; background-clip: initial;">選訓委員會】。</span></span><span lang="EN-US" style="font-size: 9pt; font-family: Arial, sans-serif; color: rgb(51,51,51); background-size: initial; background-origin: initial; background-clip: initial"><o:p></o:p></span></p>',
|
||||
:en=>""}
|
||||
field :active , type: Boolean , default: true
|
||||
after_save :change_all_password , :check_active
|
||||
after_create :auto_create_schools
|
||||
def change_all_password
|
||||
if self.set_default_password
|
||||
OlympiaSchoolDataFields.all.each do |school_field|
|
||||
if self.set_default_password && !self.default_password.blank?
|
||||
OlympiaSchoolDataFields.where(:sign_up_setting_id=>self.id).each do |school_field|
|
||||
school_field.password = self.default_password
|
||||
school_field.save
|
||||
end
|
||||
|
@ -35,11 +50,19 @@ class SignUpSetting
|
|||
self.save
|
||||
end
|
||||
end
|
||||
def auto_create_schools
|
||||
@sign_up_setting = SignUpSetting.where(:id.ne=>self.id).last
|
||||
@schools = OlympiaSchoolDataFields.where(:sign_up_setting_id=>@sign_up_setting.id)
|
||||
@schools.each do |school|
|
||||
OlympiaSchoolDataFields.create(school.attributes.except(*['_id','enrollment']))
|
||||
end
|
||||
end
|
||||
def check_active
|
||||
if self.active
|
||||
SignUpSetting.where.not(:id=>self.id).each do |setting|
|
||||
setting.active = false
|
||||
setting.save!
|
||||
SignUpSetting.where(:id.ne=>self.id).each do |setting|
|
||||
setting_copy = setting
|
||||
setting_copy.active = false
|
||||
setting_copy.save!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<div class="required <%=extra_class%>">
|
||||
<input name="<%=params_name%>" type="hidden" value="0">
|
||||
<input <%=is_checked ? "checked=checked" : "" %> class="checkbox" id="<%=id%>" name="<%=params_name%>" style="float:left;" type="checkbox" value="1">
|
||||
<label class="checklabel" for="<%=name%>" style="float:right;"><%=name%></label>
|
||||
<input name="<%=params_name%>" type="hidden" value="false">
|
||||
<input <%=is_checked ? "checked=checked" : "" %> class="checkbox" id="<%=id%>" name="<%=params_name%>" style="float:left;" type="checkbox" value="true">
|
||||
<label class="checklabel" for="<%=id%>" style="float:right;"><%=name%></label>
|
||||
</div>
|
|
@ -0,0 +1,13 @@
|
|||
<h2><%= (I18n.locale.to_s == "zh_tw") ? '錯誤提示' : 'Error message' %></h2>
|
||||
|
||||
<ul>
|
||||
<% @error_msg.each do |a| %>
|
||||
|
||||
<li><%= a %></li>
|
||||
|
||||
<% end %>
|
||||
|
||||
</ul>
|
||||
|
||||
|
||||
<input name="goback" type="button" onclick="window.history.go(-1);" onkeypress="window.history.go(-1);" value="<%=t('back')%>">
|
|
@ -0,0 +1,42 @@
|
|||
<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>
|
||||
<% th_name_list = ['sign_up_start_time','sign_up_end_time','enrollment','status','action']%>
|
||||
<% time = ['year','month','day'] %>
|
||||
<h3><%=t('olympiamanagement.history_contest')%></h3>
|
||||
<table class="ts_rowsonly" width="100%">
|
||||
<thead><tr>
|
||||
<% th_name_list.each do |th_name| %>
|
||||
<th><%=t('olympiamanagement.'+th_name) %></th>
|
||||
<% end %>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<% @sign_up_settings.each do |sign_up_setting| %>
|
||||
<tr>
|
||||
<td><%= time.map{|td| sign_up_setting["start_#{td}"]}.join('-') %></td>
|
||||
<td><%= time.map{|td| sign_up_setting["end_#{td}"]}.join('-') %></td>
|
||||
<td><%= @student_number = OlympiaStudentDataField.where(:sign_up_setting_id=>sign_up_setting.id).length %></td>
|
||||
<td>
|
||||
<% if sign_up_setting.active%>
|
||||
<span>
|
||||
<img alt="<%=t('olympiamanagement.active')%>" src="/assets/ok.gif">
|
||||
<%=t('olympiamanagement.active')%></img>
|
||||
</span>
|
||||
<% else %>
|
||||
<span>
|
||||
<img alt="<%=t('olympiamanagement.inactive')%>" src="/assets/close.gif">
|
||||
<%=t('olympiamanagement.inactive')%></img>
|
||||
</span>
|
||||
<% end %>
|
||||
</td>
|
||||
<td>
|
||||
<% if !sign_up_setting.active%>
|
||||
<a href='<%= admin_olympiamanagements_update_sign_up_data_path + "?type=active&id=#{sign_up_setting.id}"%>'><%=t('olympiamanagement.active')%></a>
|
||||
<% end %>
|
||||
<a href='<%= admin_olympiamanagements_update_sign_up_data_path + "?type=view&id=#{sign_up_setting.id}"%>'><%=t('olympiamanagement.view')%></a>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<%=create_pagination(params[:page].to_i,SignUpSetting.all).html_safe%>
|
|
@ -28,13 +28,13 @@
|
|||
<% @OlympiaSchoolDataFields.each do |field| %>
|
||||
<tr>
|
||||
<% th_name_list.each do |th_name|%>
|
||||
<%if th_name != 'action'%>
|
||||
<% if th_name != 'action'%>
|
||||
<td><%= field[th_name]%></td>
|
||||
<% else %>
|
||||
<td>
|
||||
<a href="<%=admin_olympiamanagements_add_school_data_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_sign_up_student_data_list_path+"?olympia_school_id=#{field.id}"%>"><img src="/assets/view.gif" alt="<%= t('olympiamanagement.sign_up_student_data') %>" align="top" width="24"><%= t('olympiamanagement.sign_up_student_data') %></a>
|
||||
<a href="<%=admin_olympiamanagements_update_school_data_path+"?id=#{field.id}&type=delete_school_data"%>"><img src="/assets/trash.gif" alt="<%= t('olympiamanagement.delete') %>" align="top" width="24"><%= t('olympiamanagement.delete') %></a>
|
||||
<a href="#" onclick="if( window.confirm('<%=t('olympiamanagement.please_confirm_delete')%>') ) { window.location='<%=admin_olympiamanagements_update_school_data_path+"?id=#{field.id}&type=delete_school_data"%>'; }" onkeypress="if( window.confirm('<%=t('olympiamanagement.please_confirm_delete')%>') ) { window.location='<%=admin_olympiamanagements_update_school_data_path+"?id=#{field.id}&type=delete_school_data"%>'; }"><img src="/assets/trash.gif" alt="<%= t('olympiamanagement.delete') %>" align="top" width="24"><%= t('olympiamanagement.delete') %></a>
|
||||
<%if field.approved%>
|
||||
<a href="<%=admin_olympiamanagements_update_school_data_path+"?id=#{field.id}&type=unapproved"%>"><img src="/assets/close.gif" alt="<%= t('olympiamanagement.unapproved') %>" align="top" width="24"><%= t('olympiamanagement.unapproved') %></a>
|
||||
<% else %>
|
||||
|
|
|
@ -4,9 +4,13 @@
|
|||
<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=>@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'%>'; }">
|
||||
<a href="#" onclick="if( window.confirm('<%=t('olympiamanagement.please_confirm_delete')%>') ) { window.location='<%=admin_olympiamanagements_update_sign_up_data_path + '?type=delete_old_data'%>'; }" onkeypress="if( window.confirm('<%=t('olympiamanagement.please_confirm_delete')%>') ) { 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;">
|
||||
<div style="clear: both;"></div>
|
||||
<%=render :partial=>'checkbox',:locals=>{:name=>t('olympiamanagement.new_sign_up'),:params_name=>'new_sign_up',:id=>'new_sign_up',:extra_class=>'lleft red_text',:is_checked=>nil}%>
|
||||
<div style="clear: both;"></div>
|
||||
<hr style="border-color: black;border-top: 0em;">
|
||||
<div class="col_text">
|
||||
<li class="col" for="start_time"><%= t('olympiamanagement.sign_up_start_time')%></li>
|
||||
<li class="col_r" id="start_time">
|
||||
|
|
|
@ -1,5 +1,12 @@
|
|||
en:
|
||||
olympiamanagement:
|
||||
new_sign_up: Create new Sign up
|
||||
view: View
|
||||
history_contest: History Contest
|
||||
active: Active
|
||||
inactive: Inactive
|
||||
status: Status
|
||||
please_confirm_delete: Please confirm deletion.?
|
||||
scan_file_of_certificate: Scan file of certificate
|
||||
sign_up_title: International Junior Science Olympiad First Stage Online Sign UP
|
||||
error_msg: Error message
|
||||
|
|
|
@ -1,5 +1,13 @@
|
|||
zh_tw:
|
||||
olympiamanagement:
|
||||
new_sign_up: 建立新的報名
|
||||
view: 查看
|
||||
add_sign_up_setting: 增加報名設定
|
||||
history_contest: 歷屆比賽
|
||||
active: 啟用
|
||||
inactive: 停用
|
||||
status: 狀態
|
||||
please_confirm_delete: 請確認是否刪除?
|
||||
scan_file_of_certificate: 獎狀掃描
|
||||
sign_up_title: 國中科學奧林匹亞競賽初選線上報名
|
||||
error_msg: 錯誤訊息
|
||||
|
|
|
@ -15,7 +15,11 @@ module Olympiamanagement
|
|||
available_for "users"
|
||||
active_for_controllers (['admin/olympiamanagement'])
|
||||
head_link_path "admin_olympiamanagements_school_data_list_path"
|
||||
|
||||
context_link 'olympiamanagement.history_contest',
|
||||
:link_path=>"admin_olympiamanagements_path" ,
|
||||
:priority=>1,
|
||||
:active_for_action=>{'admin/olympiamanagements'=>'index'},
|
||||
:available_for => 'users'
|
||||
context_link 'olympiamanagement.add_school_data',
|
||||
:link_path=>"admin_olympiamanagements_add_school_data_path" ,
|
||||
:priority=>1,
|
||||
|
|
Loading…
Reference in New Issue