finish print registration form
This commit is contained in:
parent
6a93c393df
commit
a9617de263
|
@ -1,3 +1,96 @@
|
||||||
|
function checkid(it){
|
||||||
|
var ALP_STR = "ABCDEFGHJKLMNPQRSTUVXYWZIO";
|
||||||
|
var NUM_STR = "0123456789";
|
||||||
|
function CheckPID(it) {
|
||||||
|
var sMsg = "";
|
||||||
|
var sPID = it.value;
|
||||||
|
if (sPID == '') {
|
||||||
|
sMsg = "請輸入身分證字號";
|
||||||
|
} else if (sPID.length != 10) {
|
||||||
|
sMsg = "身分證字號長度應為 10 !";
|
||||||
|
} else {
|
||||||
|
sPID = sPID.toUpperCase().trim();
|
||||||
|
if (!chkPID_CHAR(sPID)) return;
|
||||||
|
|
||||||
|
var iChkNum = getPID_SUM(sPID);
|
||||||
|
|
||||||
|
if (iChkNum % 10 != 0) {
|
||||||
|
var iLastNum = sPID.substr(9, 1) * 1;
|
||||||
|
for (i = 0; i < 10; i++) {
|
||||||
|
var xRightAlpNum = iChkNum - iLastNum + i;
|
||||||
|
if ((xRightAlpNum % 10) == 0) {
|
||||||
|
sMsg = "身分證字號最後一個數應為:" + i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sMsg.length != 0) {
|
||||||
|
//alert(sMsg);
|
||||||
|
alert((I18n.locale != "en") ? "身分證字號錯誤" : "ID Number error");
|
||||||
|
it.select();
|
||||||
|
return false;
|
||||||
|
}else{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 身分證字號檢查器 - 檢查合法字元
|
||||||
|
function chkPID_CHAR(sPID) {
|
||||||
|
var sMsg = "";
|
||||||
|
//sPID = trim(sPID.toUpperCase());
|
||||||
|
var iPIDLen = String(sPID).length;
|
||||||
|
|
||||||
|
var sChk = ALP_STR + NUM_STR;
|
||||||
|
for (i = 0; i < iPIDLen; i++) {
|
||||||
|
if (sChk.indexOf(sPID.substr(i, 1)) < 0) {
|
||||||
|
sMsg = "這個身分證字號含有不正確的字元!";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sMsg.length == 0) {
|
||||||
|
if (ALP_STR.indexOf(sPID.substr(0, 1)) < 0) {
|
||||||
|
sMsg = "身分證字號第 1 碼應為英文字母(A~Z)。";
|
||||||
|
} else if ((sPID.substr(1, 1) != "1") && (sPID.substr(1, 1) != "2")) {
|
||||||
|
sMsg = "身分證字號第 2 碼應為數字(1~2)。";
|
||||||
|
} else {
|
||||||
|
for (var i = 2; i < iPIDLen; i++) {
|
||||||
|
if (NUM_STR.indexOf(sPID.substr(i, 1)) < 0) {
|
||||||
|
sMsg = "第 " + (i + 1) + " 碼應為數字(0~9)。";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sMsg.length != 0) {
|
||||||
|
//alert(sMsg);
|
||||||
|
alert((I18n.locale != "en") ? "身分證字號錯誤" : "ID Number error");
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//身份證字號檢查器 - 累加檢查碼
|
||||||
|
function getPID_SUM(sPID) {
|
||||||
|
var iChkNum = 0;
|
||||||
|
|
||||||
|
// 第 1 碼
|
||||||
|
iChkNum = ALP_STR.indexOf(sPID.substr(0, 1)) + 10;
|
||||||
|
iChkNum = Math.floor(iChkNum / 10) + (iChkNum % 10 * 9);
|
||||||
|
|
||||||
|
// 第 2 - 9 碼
|
||||||
|
for (var i = 1; i < sPID.length - 1; i++) {
|
||||||
|
iChkNum += sPID.substr(i, 1) * (9 - i);
|
||||||
|
}
|
||||||
|
|
||||||
|
// 第 10 碼
|
||||||
|
iChkNum += sPID.substr(9, 1) * 1;
|
||||||
|
|
||||||
|
return iChkNum;
|
||||||
|
}
|
||||||
|
return CheckPID(it);
|
||||||
|
};
|
||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
$('.class_setting_block input[type="reset"]').off('click').on('click',function(){
|
$('.class_setting_block input[type="reset"]').off('click').on('click',function(){
|
||||||
$('.col_input').val('');
|
$('.col_input').val('');
|
||||||
|
@ -33,11 +126,22 @@ $(document).ready(function(){
|
||||||
if($('.fieldset_block .required.errFld').length != 0)
|
if($('.fieldset_block .required.errFld').length != 0)
|
||||||
return false;
|
return false;
|
||||||
else
|
else
|
||||||
return true;
|
if($('#StudentIDNO').length != 0)
|
||||||
|
try{return checkid(document.getElementById('StudentIDNO'));
|
||||||
|
}catch(e){console.log(e);return false;};
|
||||||
})
|
})
|
||||||
var $el = $('.fieldset_block select');
|
var $el = $('.fieldset_block select');
|
||||||
for(var i = 0 ; i < $el.length ; i++)
|
for(var i = 0 ; i < $el.length ; i++)
|
||||||
if($el.eq(i).attr('value') != "" && $el.eq(i).attr('value') != undefined)
|
if($el.eq(i).attr('value') != "" && $el.eq(i).attr('value') != undefined)
|
||||||
$el.eq(i).find('option[value='+$el.eq(i).attr('value')+']').attr('selected','selected');
|
$el.eq(i).find('option[value='+$el.eq(i).attr('value')+']').attr('selected','selected');
|
||||||
CKEDITOR.replaceAll();
|
try{CKEDITOR.replaceAll()}catch(e){console.log(e)};
|
||||||
|
if($('#StudentIdentity').val() != '1')
|
||||||
|
$('#StudentFile').removeClass('required');
|
||||||
|
$('#StudentIdentity').click(function(){
|
||||||
|
if(this.value != '1'){
|
||||||
|
$('#StudentFile').removeClass('required');
|
||||||
|
}else{
|
||||||
|
$('#StudentFile').addClass('required');
|
||||||
|
};
|
||||||
|
});
|
||||||
});
|
});
|
|
@ -3,6 +3,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
before_action :set_sign_up_setting,:create_first_fields
|
before_action :set_sign_up_setting,:create_first_fields
|
||||||
prepend_view_path "app/templates" #for_render_pages
|
prepend_view_path "app/templates" #for_render_pages
|
||||||
layout :get_layout #for_render_pages
|
layout :get_layout #for_render_pages
|
||||||
|
helper Admin::OlympiamanagementsHelper
|
||||||
before_action :check_login, except: :login
|
before_action :check_login, except: :login
|
||||||
def initialize
|
def initialize
|
||||||
super
|
super
|
||||||
|
@ -49,7 +50,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
{:url=>'/olympiamanagements/edit_password',:name=>t('olympiamanagement.edit_password')},
|
{:url=>'/olympiamanagements/edit_password',:name=>t('olympiamanagement.edit_password')},
|
||||||
{:url=>'/olympiamanagements/print_registration_form',:name=>t('olympiamanagement.print_registration_form')},
|
{:url=>'/olympiamanagements/print_registration_form',:name=>t('olympiamanagement.print_registration_form')},
|
||||||
{:url=>'/olympiamanagements/logout',:name=>t('olympiamanagement.logout')}]
|
{:url=>'/olympiamanagements/logout',:name=>t('olympiamanagement.logout')}]
|
||||||
@breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr})
|
@breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.sign_up_title')})
|
||||||
end
|
end
|
||||||
def index
|
def index
|
||||||
uid = OrbitHelper.params[:uid] rescue ""
|
uid = OrbitHelper.params[:uid] rescue ""
|
||||||
|
@ -83,7 +84,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
data_arr = @page.child_page.map{|page| {:url=>"/#{I18n.locale}#{page.url}",:name=>page.name}}
|
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})
|
@breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.sign_up_title')})
|
||||||
@olympiamanagement_instruction = @breadcumb + @olympiamanagement_instruction.html_safe
|
@olympiamanagement_instruction = @breadcumb + @olympiamanagement_instruction.html_safe
|
||||||
else
|
else
|
||||||
if !@instructions_pages.empty?
|
if !@instructions_pages.empty?
|
||||||
|
@ -139,7 +140,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
@instructions_pages.each{|page| page.destroy}
|
@instructions_pages.each{|page| page.destroy}
|
||||||
end
|
end
|
||||||
data_arr = @page.child_page.map{|page| {:url=>"/#{I18n.locale}#{page.url}",:name=>page.name}}
|
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})
|
@breadcumb = render_to_string(:formats=> [:html] ,:partial=>'breadcumb',:locals=>{:data_arr=>data_arr,:@title=>I18n.t('olypiamanagement.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 = @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
|
end
|
||||||
{
|
{
|
||||||
|
@ -196,7 +197,7 @@ class OlympiamanagementsController < ApplicationController
|
||||||
render_contents_in_index_page(@breadcumb+"<p><a href=#{school_connection_data_olympiamanagements_path}>#{I18n.t('olympiamanagement.please_set_school_connect_data')}</a></p>".html_safe)
|
render_contents_in_index_page(@breadcumb+"<p><a href=#{school_connection_data_olympiamanagements_path}>#{I18n.t('olympiamanagement.please_set_school_connect_data')}</a></p>".html_safe)
|
||||||
else
|
else
|
||||||
@student_data_field = StudentDataField.first
|
@student_data_field = StudentDataField.first
|
||||||
@olympia_student_data = (OlympiaStudentDataFields.find(params[:id]) rescue OlympiaStudentDataFields.new)
|
@olympia_student_data = (OlympiaStudentDataField.find(params[:id]) rescue OlympiaStudentDataField.new)
|
||||||
@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
|
||||||
|
@ -204,8 +205,11 @@ class OlympiamanagementsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def sign_up_student_data_list
|
def sign_up_student_data_list
|
||||||
|
page_num = params[:page] || 1
|
||||||
@field_infos = StudentDataField.first.student_data_fields
|
@field_infos = StudentDataField.first.student_data_fields
|
||||||
@student_fields = OlympiaStudentDataFields.all
|
@olympia_school_data_fields_id = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first.id
|
||||||
|
@sign_up_setting_id = SignUpSetting.last.id
|
||||||
|
@student_fields = OlympiaStudentDataField.where(:olympia_school_data_fields_id=>@olympia_school_data_fields_id,:sign_up_setting_id=>@sign_up_setting_id).asc(:id).page(page_num).per(10)
|
||||||
@page_content = render_to_string(:formats=> [:html] ,:partial=>'student_data_list.html',:locals=>{:@student_fields=>(@student_fields rescue [])}).html_safe
|
@page_content = render_to_string(:formats=> [:html] ,:partial=>'student_data_list.html',:locals=>{:@student_fields=>(@student_fields rescue [])}).html_safe
|
||||||
render_contents_in_index_page(@breadcumb+@page_content)
|
render_contents_in_index_page(@breadcumb+@page_content)
|
||||||
end
|
end
|
||||||
|
@ -237,6 +241,20 @@ class OlympiamanagementsController < ApplicationController
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
def print_registration_form
|
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')})
|
||||||
|
@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
|
||||||
|
@record_fields = [['school_name','school_code'],['school_address'],['class_number','enrollment_limited'],
|
||||||
|
['office_tel_number','fax'],['mobile_number','email'],['principal_signature','dean_signature']]
|
||||||
|
@student_fields = ['serial_number','StudentName','StudentSex','StudentClass','StudentIDNO','birth_date','StudentArea','StudentIdentity']
|
||||||
|
@field_infos = StudentDataField.first.student_data_fields
|
||||||
|
@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
|
||||||
end
|
end
|
||||||
def logout
|
def logout
|
||||||
session[:olympia_login_id] = ""
|
session[:olympia_login_id] = ""
|
||||||
|
@ -529,13 +547,125 @@ class OlympiamanagementsController < ApplicationController
|
||||||
end
|
end
|
||||||
def updata_student_data
|
def updata_student_data
|
||||||
if params[:type] == 'add_student_data'
|
if params[:type] == 'add_student_data'
|
||||||
@student_params = params.require(:add_student_data).permit(:StudentIdentity,:StudentName,:StudentSex,:StudentIDNO,:StudentBirthMonth,:StudentBirthDay,:StudentClass,:StudentPhone,:StudentCode,:StudentAddress,:StudentArea,:StudentFile)
|
@error_msg = []
|
||||||
@olympia_student_data = OlympiaStudentDataFields.find(params[:id]) rescue nil
|
@student_params = params.require(:add_student_data).permit!
|
||||||
@olympia_student_data.nil? ? OlympiaStudentDataFields.create(@student_params) : @olympia_student_data.update_attributes(@student_params)
|
@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 << I18n.t('olympiamanagement.id_number_error')
|
||||||
|
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.where(:account_number=>session[:olympia_login_id]).first
|
||||||
|
@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=>@olympia_school_data_field.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 sign_up_student_data_list_olympiamanagements_path
|
redirect_to sign_up_student_data_list_olympiamanagements_path
|
||||||
|
else
|
||||||
|
@page_content = render_to_string(:formats=>[:html],:partial=>'import_error_msg.html',:locals=>{:@error_msg=>@error_msg})
|
||||||
|
render_contents_in_index_page(@page_content)
|
||||||
|
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
|
else
|
||||||
render :html => '404'
|
render :html => '404'
|
||||||
end
|
end
|
||||||
#render :html => '123'
|
#render :html => '123'
|
||||||
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
|
|
@ -3,6 +3,7 @@ module Admin::OlympiamanagementsHelper
|
||||||
page = 1 if page == 0
|
page = 1 if page == 0
|
||||||
per_page_num = 10.0
|
per_page_num = 10.0
|
||||||
all_page_num = (fields.count / per_page_num).ceil
|
all_page_num = (fields.count / per_page_num).ceil
|
||||||
|
all_page_num = 1 if all_page_num == 0
|
||||||
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "第 #{page} 頁" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "共 #{all_page_num} 頁" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
|
pagination = '<div class="PageDetails">'+((I18n.locale.to_s == 'zh_tw') ? "第 #{page} 頁" : "page #{page}") +'/'+ ((I18n.locale.to_s == 'zh_tw') ? "共 #{all_page_num} 頁" : "Total #{all_page_num} page(s)")+'<ol class="PageList">'+
|
||||||
((page == 1) ? '<li>['+t('olympiamanagement.prev_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page-1).to_s+'"> ['+t('olympiamanagement.prev_page')+'] </a></li>')
|
((page == 1) ? '<li>['+t('olympiamanagement.prev_page')+']</li>' : '<li><a href="'+(extra_params.blank? ? '?' : "?#{extra_params}&")+'page='+(page-1).to_s+'"> ['+t('olympiamanagement.prev_page')+'] </a></li>')
|
||||||
if all_page_num > 7
|
if all_page_num > 7
|
||||||
|
|
|
@ -1,18 +1,19 @@
|
||||||
# encoding: utf-8
|
# encoding: utf-8
|
||||||
require 'carrierwave/processing/mime_types'
|
require 'carrierwave/processing/mime_types'
|
||||||
|
require 'carrierwave/orm/activerecord'
|
||||||
class OlympiaImagesUploader < CarrierWave::Uploader::Base
|
class OlympiaImagesUploader < CarrierWave::Uploader::Base
|
||||||
|
|
||||||
include CarrierWave::MimeTypes
|
include CarrierWave::MimeTypes
|
||||||
|
|
||||||
process :set_content_type
|
process :set_content_type
|
||||||
|
include CarrierWave::MiniMagick
|
||||||
|
include CarrierWave::MimeTypes
|
||||||
# Include RMagick or ImageScience support:
|
# Include RMagick or ImageScience support:
|
||||||
# include CarrierWave::RMagick
|
# include CarrierWave::RMagick
|
||||||
# include CarrierWave::ImageScience
|
# include CarrierWave::ImageScience
|
||||||
|
|
||||||
# Choose what kind of storage to use for this uploader:
|
# Choose what kind of storage to use for this uploader:
|
||||||
# storage :file
|
storage :file
|
||||||
# storage :s3
|
# storage :s3
|
||||||
|
|
||||||
# Override the directory where uploaded files will be stored.
|
# Override the directory where uploaded files will be stored.
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
class OlympiaStudentDataFields
|
class OlympiaStudentDataField
|
||||||
include Mongoid::Document
|
include Mongoid::Document
|
||||||
include Mongoid::Timestamps
|
include Mongoid::Timestamps
|
||||||
include OrbitModel::Status
|
include OrbitModel::Status
|
||||||
|
@ -18,9 +18,12 @@ class OlympiaStudentDataFields
|
||||||
field :StudentCode , type: String , default: ''
|
field :StudentCode , type: String , default: ''
|
||||||
field :StudentAddress , type: String , default: ''
|
field :StudentAddress , type: String , default: ''
|
||||||
field :StudentArea , type: String , default: ''
|
field :StudentArea , type: String , default: ''
|
||||||
mount_uploader :StudentFile, OlympiaImagesUploader
|
field :remove_image , type: Boolean , default: false
|
||||||
field :approved , type: Boolean , default: true
|
field :approved , type: Boolean , default: true
|
||||||
field :olympia_school_data_fields_id , type: String , default: ''
|
field :olympia_school_data_fields_id , type: String , default: ''
|
||||||
|
field :sign_up_setting_id , type: String , default: ''
|
||||||
|
has_many :olympia_student_images , :dependent => :destroy , autosave: true
|
||||||
|
after_save :check_file
|
||||||
after_initialize do
|
after_initialize do
|
||||||
if !self.new_record?
|
if !self.new_record?
|
||||||
if self.approved.nil?
|
if self.approved.nil?
|
||||||
|
@ -29,4 +32,11 @@ class OlympiaStudentDataFields
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
def check_file
|
||||||
|
if self.remove_image
|
||||||
|
self.olympia_student_images = []
|
||||||
|
self.remove_image = false
|
||||||
|
self.save
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -0,0 +1,11 @@
|
||||||
|
class OlympiaStudentImage
|
||||||
|
include Mongoid::Document
|
||||||
|
include Mongoid::Timestamps
|
||||||
|
include OrbitModel::Status
|
||||||
|
include OrbitModel::Impression
|
||||||
|
# encoding: utf-8
|
||||||
|
include OrbitTag::Taggable
|
||||||
|
include OrbitCategory::Categorizable
|
||||||
|
mount_uploader :student_file, OlympiaImagesUploader
|
||||||
|
belongs_to :olympia_student_data_fields
|
||||||
|
end
|
|
@ -1,6 +1,8 @@
|
||||||
<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>
|
<%= stylesheet_link_tag "lib/fileupload"%>
|
||||||
|
<%= javascript_include_tag 'lib/bootstrap-fileupload' %>
|
||||||
|
<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=>"updata_student_data",:type=>"add_student_data",:id=>params[:id]}, :html => {:multipart => true} do |form|%>
|
||||||
|
@ -48,7 +50,9 @@
|
||||||
<label for="<%="#{field.keys[0]}_#{choice}"%>"><%=field.values[0][:values][I18n.locale.to_s][i]%></label>
|
<label for="<%="#{field.keys[0]}_#{choice}"%>"><%=field.values[0][:values][I18n.locale.to_s][i]%></label>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% elsif field.values[0][:type] == 'File' %>
|
<% elsif field.values[0][:type] == 'File' %>
|
||||||
<input type="file" name="<%="[add_student_data][#{field.keys[0]}]"%>" value="<%= @olympia_student_data[field.keys[0]] %>" size="<%=field.values[0][:size]%>" id="<%= field.keys[0] %>" style="margin-top: 1em;" class="col_input<%= @extra_class%>"/>
|
<%= 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 %>
|
<% end %>
|
||||||
</li>
|
</li>
|
||||||
<% if !field.values[0][:hint][I18n.locale.to_s].blank? %>
|
<% if !field.values[0][:hint][I18n.locale.to_s].blank? %>
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
<div class="sitemenu-wrap sitemenu-horizontal">
|
<div class="sitemenu-wrap sitemenu-horizontal">
|
||||||
|
<% if(!@title.to_s.blank? rescue false) %>
|
||||||
|
<h2><span><%=@title%></span></h2>
|
||||||
|
<% end %>
|
||||||
<ul data-list="pages" class="sitemenu-list level-1 list-unstyled" data-level="0">
|
<ul data-list="pages" class="sitemenu-list level-1 list-unstyled" data-level="0">
|
||||||
<% data_arr.each do |data|%>
|
<% data_arr.each do |data|%>
|
||||||
<li class="sitemenu-item level-1">
|
<li class="sitemenu-item level-1">
|
||||||
|
|
|
@ -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).first.send(field_name).file.present? rescue false) %>
|
||||||
|
<div class="fileupload-new thumbnail pull-left">
|
||||||
|
<%= image_tag( image_form.send(image_field_name).first.send(field_name), :size=>"120x120") %>
|
||||||
|
</div>
|
||||||
|
<% end %>
|
||||||
|
<div class="fileupload-preview fileupload-exists thumbnail pull-left"></div>
|
||||||
|
<% if(image_form.send(image_field_name).first.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).first.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>
|
|
@ -0,0 +1,9 @@
|
||||||
|
<h2 align="center"><img style="height: 1em;" alt="<%= t('olympiamanagement.error_msg')%>" src="/assets/warning.gif"><%= t('olympiamanagement.error_msg')%></h2>
|
||||||
|
<ul align="center">
|
||||||
|
<% @error_msg.each do |a| %>
|
||||||
|
<li style="width: fit-content;margin: auto;"><%= a %></li>
|
||||||
|
<% end %>
|
||||||
|
</ul>
|
||||||
|
<p align="center">
|
||||||
|
<%= link_to t('back'), :back, :class => 'btn' %>
|
||||||
|
</p>
|
|
@ -0,0 +1,48 @@
|
||||||
|
<div id="main1"><div id="main2"><div id="main">
|
||||||
|
<%=@breadcumb%>
|
||||||
|
<table class="print_contest1"><tbody>
|
||||||
|
<tr><th colspan="4"><font face="標楷體, cursive"><font size="6" style="font-size: 1.67em;"><%=@record_form_title%></font></font></th></tr>
|
||||||
|
<% @record_fields.each_with_index do |record_block,i| %>
|
||||||
|
<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? ? ' ' : @school_data[record_item.to_s]) %></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% end %>
|
||||||
|
</tbody></table>
|
||||||
|
|
||||||
|
<table class="print_contest2">
|
||||||
|
<tbody>
|
||||||
|
<tr><td><%=@remark_texts%><br></td></tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<table class="print_contest3"><tbody>
|
||||||
|
<tr>
|
||||||
|
<% @student_fields.each do |field_name| %>
|
||||||
|
<td><%=t('olympiamanagement.'+field_name.to_s)%></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<% @student_data_list.each do |field| %>
|
||||||
|
<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))%>
|
||||||
|
<% end %>
|
||||||
|
<td><%= @value %></td>
|
||||||
|
<% end %>
|
||||||
|
</tr>
|
||||||
|
<%end%>
|
||||||
|
</tbody></table>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
window.onload = function ()
|
||||||
|
{
|
||||||
|
text=document
|
||||||
|
print(text)
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</div></div></div></div></div></div></div>
|
|
@ -1,5 +1,9 @@
|
||||||
en:
|
en:
|
||||||
olympiamanagement:
|
olympiamanagement:
|
||||||
|
sign_up_title: International Junior Science Olympiad First Stage Online Sign UP
|
||||||
|
error_msg: Error message
|
||||||
|
id_number_error: ID Number error
|
||||||
|
already_exceed_enrollment_limited: Already exceed enrollment available
|
||||||
olympiamanagement: Olympia competition management
|
olympiamanagement: Olympia competition management
|
||||||
add_school_data: Add school data
|
add_school_data: Add school data
|
||||||
edit_school_data: Edit school data
|
edit_school_data: Edit school data
|
||||||
|
@ -56,6 +60,9 @@ en:
|
||||||
office_tel_number: Office Tel No.
|
office_tel_number: Office Tel No.
|
||||||
department_job_title: Department job title
|
department_job_title: Department job title
|
||||||
school_contact_person_name: School contact person's name
|
school_contact_person_name: School contact person's name
|
||||||
|
principal_signature: Principal (Signature)
|
||||||
|
dean_signature: Director Of Academic Affairs (Signature)
|
||||||
|
serial_number: Serial number
|
||||||
prev_page: Previous page
|
prev_page: Previous page
|
||||||
next_page: Next page
|
next_page: Next page
|
||||||
download_import_file: Download import file
|
download_import_file: Download import file
|
||||||
|
|
|
@ -1,5 +1,9 @@
|
||||||
zh_tw:
|
zh_tw:
|
||||||
olympiamanagement:
|
olympiamanagement:
|
||||||
|
sign_up_title: 國中科學奧林匹亞競賽初選線上報名
|
||||||
|
error_msg: 錯誤訊息
|
||||||
|
id_number_error: 身分證字號錯誤
|
||||||
|
already_exceed_enrollment_limited: 已超過可報名人數
|
||||||
olympiamanagement: 奧林匹亞競賽 Management
|
olympiamanagement: 奧林匹亞競賽 Management
|
||||||
add_school_data: 新增學校資料
|
add_school_data: 新增學校資料
|
||||||
edit_school_data: 編輯學校資料
|
edit_school_data: 編輯學校資料
|
||||||
|
@ -56,6 +60,9 @@ zh_tw:
|
||||||
office_tel_number: 聯絡電話
|
office_tel_number: 聯絡電話
|
||||||
department_job_title: 單位職稱
|
department_job_title: 單位職稱
|
||||||
school_contact_person_name: 學校聯絡人姓名
|
school_contact_person_name: 學校聯絡人姓名
|
||||||
|
principal_signature: 校長(簽章)
|
||||||
|
dean_signature: 教務主任 (簽章)
|
||||||
|
serial_number: 序號
|
||||||
prev_page: 上一頁
|
prev_page: 上一頁
|
||||||
next_page: 下一頁
|
next_page: 下一頁
|
||||||
download_import_file: 下載匯入檔案
|
download_import_file: 下載匯入檔案
|
||||||
|
|
|
@ -36,6 +36,7 @@ Rails.application.routes.draw do
|
||||||
get 'edit_password'
|
get 'edit_password'
|
||||||
get 'print_registration_form'
|
get 'print_registration_form'
|
||||||
get 'logout'
|
get 'logout'
|
||||||
|
post 'login'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue