finish logout and edit password and school_connect_data and part of add_student_data pages

This commit is contained in:
BOHUNG 2020-02-02 19:25:42 +08:00
parent 4e461d47f1
commit 35fc18f501
10 changed files with 262 additions and 95 deletions

View File

@ -39,5 +39,5 @@ $(document).ready(function(){
for(var i = 0 ; i < $el.length ; i++)
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');
CKEDITOR.replaceAll();
try{CKEDITOR.replaceAll()}catch(e){console.log(e)};
});

View File

@ -46,10 +46,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
elsif params[:type] == 'add_school_data'
@olympia_school_data_field = (params[:id].nil? ? OlympiaSchoolDataFields.new : ((OlympiaSchoolDataFields.find(params[:id]).nil? rescue true) ? OlympiaSchoolDataFields.new : OlympiaSchoolDataFields.find(params[:id])))
params['add_school_data'].keys.each do |field|
#if
@olympia_school_data_field[field] = params['add_school_data'][field]
#elsif
#ClassSettingFields.all.select{|field| field.class_number_range[0]<6 && field.class_number_range[1] > 6}
end
@olympia_school_data_field.save
redirect_to admin_olympiamanagements_school_data_list_path
@ -213,7 +210,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
@site_locales.insert(0,I18n.locale)
end
def export_school_connection_data
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
dir_path = 'tmp/olypiamanagement/'
#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
@ -227,7 +224,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
send_data(tmp_filename_data, type: 'application/xlsx', disposition: 'attachment', filename: @filename)
end
def export_sign_up_student_data
# @OlympiaSchoolDataFields = OlympiaSchoolDataFields.all
# @OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
# dir_path = 'tmp/olypiamanagement/'
# #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
@ -246,7 +243,7 @@ class Admin::OlympiamanagementsController < OrbitAdminController
@olympia_school_data_field = OlympiaSchoolDataFields.new
end
def download_import_file
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
dir_path = 'tmp/olypiamanagement/'
#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

View File

@ -21,78 +21,97 @@ class OlympiamanagementsController < PagesController
uid = OrbitHelper.params[:uid] rescue ""
tags = OrbitHelper.widget_tags
categories = OrbitHelper.widget_categories || []
@sign_up_setting = SignUpSetting.last
set_sign_up_setting
@time_arr = ["year","month","day","o_clock","minute"]
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")
@instructions_name = {}
Site.first.in_use_locales.each do |locale|
I18n.with_locale(locale) do
@instructions_name[locale.to_s] = I18n.t('olympiamanagement.registration_instructions')
end
end
@page = Page.where(:layout=>"olympia_managements_index",:parent_page_id=>(Page.where(:name=> ((I18n.locale.to_s == "en") ? "Home" : "首頁")).first.id)).first
@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"
@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)
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)
end
if !OrbitHelper.current_user.nil?
@edit_link = '/admin/olympiamanagements/sign_up_setting#registration_instructions'
@edit_text = (I18n.locale.to_s == "zh_tw") ? "編輯" : "Edit"
if !OrbitHelper.current_user.nil?
@olympiamanagement_instruction += '<p class="admin-edit text-right"><a class="btn btn-primary" href="'+@edit_link+'" title="'+@edit_text+'"><i class="icon-edit"></i> '+@edit_text+'</a></p>'
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})
@olympiamanagement_instruction = @breadcumb + @olympiamanagement_instruction.html_safe
else
if !@instructions_pages.empty?
@instructions_pages.each{|page| page.destroy}
end
@olympiamanagement_instruction = '<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
@edit_link = '/admin/olympiamanagements/sign_up_setting#registration_instructions'
@edit_text = (I18n.locale.to_s == "zh_tw") ? "編輯" : "Edit"
if !OrbitHelper.current_user.nil?
@olympiamanagement_instruction += '<p class="admin-edit text-right"><a class="btn btn-primary" href="'+@edit_link+'" title="'+@edit_text+'"><i class="icon-edit"></i> '+@edit_text+'</a></p>'
end
#sign_up_hint
{
"olympiamanagement" => [],
"extras"=>{"instructions"=> @olympiamanagement_instruction}
}
when "olympia_managements_index"
@time_arr = ["year","month","day","o_clock","minute"]
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
@error = nil
@page_content
if !OrbitHelper.params[:login_id].to_s.blank?
if OlympiaSchoolDataFields.where(:account_number=>OrbitHelper.params[:login_id]).length == 0
@error = "no_account"
else
if OlympiaSchoolDataFields.where(:account_number=>OrbitHelper.params[:login_id]).first.password != OrbitHelper.params[:login_pw]
@error = "password_error"
else
@@session[:olympia_login_id] = OrbitHelper.params[:login_id]
end
end
end
if @@session[:olympia_login_id].to_s.blank?
@page_content = render_to_string(:formats=> [:html] ,:partial=>'login')
else
@page_content = @breadcumb
end
{
"olympiamanagement" => [],
"extras"=>{"instructions"=> @page_content}
}
else
#@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>'
@error = nil
@page_content
if !OrbitHelper.params[:login_id].to_s.blank?
if OlympiaSchoolDataFields.where(:account_number=>OrbitHelper.params[:login_id]).length == 0
@error = "no_account"
else
if OlympiaSchoolDataFields.where(:account_number=>OrbitHelper.params[:login_id]).first.password != OrbitHelper.params[:login_pw]
@error = "password_error"
else
@@session[:olympia_login_id] = OrbitHelper.params[:login_id]
end
end
end
if @@session[:olympia_login_id].to_s.blank?
@page_content = render_to_string(:formats=> [:html] ,:partial=>'login')
else
@page_content = @breadcumb
end
{
"olympiamanagement" => [],
"extras"=>{"page_content"=> @page_content}
}
if Page.where(:parent_page_id=>@page.id,:name=>@page.name).length == 0
@newpage = Page.create(:layout=> @page.layout,:data_count=>@page.data_count,:parent_page_id=>@page.id,:url=>@page.url,
:menu_enabled_for=>@page.menu_enabled_for,:enabled_for_sitemap=>@page.enabled_for_sitemap,:enabled_for=>@page.enabled_for,:module=>@page[:module],:page_id=>@page.page_id)
@newpage.name_translations = @page.name_translations
@newpage.save
@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')
@newpage.name_translations = @instructions_name
@newpage.save
end
@error = nil
@page_content
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')
@newpage.name_translations = @instructions_name
@newpage.save
elsif @instructions_pages.length != 1
@instructions_pages.slice(1,@instructions_pages.length).each{|page| page.destroy}
end
if !OrbitHelper.params[:login_id].to_s.blank?
if OlympiaSchoolDataFields.where(:account_number=>OrbitHelper.params[:login_id]).length == 0
@error = "no_account"
else
if OlympiaSchoolDataFields.where(:account_number=>OrbitHelper.params[:login_id]).first.password != OrbitHelper.params[:login_pw]
@error = "password_error"
else
@@session[:olympia_login_id] = OrbitHelper.params[:login_id]
end
end
end
if @@session[:olympia_login_id].to_s.blank?
@page_content = render_to_string(:formats=> [:html] ,:partial=>'login')
else
@page_content = @breadcumb
end
else
if !@instructions_pages.empty?
@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})
@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
{
"olympiamanagement" => [],
"extras"=>{"page_content"=> @page_content}
}
end
end
def school_connection_data
@ -101,11 +120,23 @@ class OlympiamanagementsController < PagesController
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?
render_contents_in_index_page#redirect_to :back
@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"}},
{'school_address'=>{'type'=>'String','size'=>'40','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
{'class_number'=>{'type'=>'String','size'=>'5','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
{'enrollment_limited'=>{'type'=>'Fixnum','size'=>'5','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true",'readonly'=>"readonly"}},
{'school_contact_person_name'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
{'department_job_title'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
{'office_tel_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
{'fax'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
{'mobile_number'=>{'type'=>'String','size'=>'20','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}},
{'email'=>{'type'=>'String','size'=>'40','hint'=>{'zh_tw'=>'','en'=>''},'required'=>"true"}}]
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
@page_content = render_to_string(:formats=> [:html] ,:partial=>'edit_school_data.html',:locals=>{:@school_data_fields=>@school_data_fields,:@olympia_school_data_field=>@olympia_school_data_field})
render_contents_in_index_page(@breadcumb+@page_content)#redirect_to :back
else
if params[:type].to_s == "update_school_data"
redirect_to :back
end
redirect_to :back
end
end
def add_sign_up_student_data
@ -113,10 +144,10 @@ class OlympiamanagementsController < PagesController
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) || session[:olympia_login_id].to_s.blank?)
redirect_to :back
else
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>@@session[:olympia_login_id]).first
@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
@ -126,18 +157,50 @@ class OlympiamanagementsController < PagesController
break
end
end
if !@flag
I18n.t('olympiamanagement.please_set_school_connect_data')
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
render_contents_in_index_page(@breadcumb)
end
#if @flag = false
end
end
def sign_up_student_data_list
end
def edit_password
if !session[:olympia_login_id].to_s.blank?
if params[:confirm_password].nil? && params[:new_password].nil?
@page_content = render_to_string(:formats=> [:html] ,:partial=>'edit_password.html',:locals=>{:@error=>(@@error rescue nil)})
render_contents_in_index_page(@breadcumb+@page_content)
else
@@error = nil
if params[:confirm_password].to_s != params[:new_password].to_s
@@error = "confirm_password_error"
elsif params[:confirm_password].to_s.blank? && params[:new_password].to_s.blank?
@@error = "password_all_empty"
elsif params[:confirm_password].to_s.blank?
@@error = "confirm_password_empty"
elsif params[:new_password].to_s.blank?
@@error = "new_password_empty"
else
@olympia_school_data_field = OlympiaSchoolDataFields.where(:account_number=>session[:olympia_login_id]).first
@olympia_school_data_field.password = params[:new_password]
@olympia_school_data_field.save
end
redirect_to edit_password_olympiamanagements_path
end
else
@page = Page.where(:layout=>"olympia_managements_index",:parent_page_id=>(Page.where(:name=> ((I18n.locale.to_s == "en") ? "Home" : "首頁")).first.id)).first
redirect_to "/#{I18n.locale}#{@page.url}"
end
end
def print_registration_form
end
def logout
session[:olympia_login_id] = ""
redirect_to :back
@page = Page.where(:layout=>"olympia_managements_index",:parent_page_id=>(Page.where(:name=> ((I18n.locale.to_s == "en") ? "Home" : "首頁")).first.id)).first
redirect_to "/#{I18n.locale}#{@page.url}"#render :html => session.to_hash
end
def widget
uid = OrbitHelper.params[:uid] rescue ""
@ -154,7 +217,7 @@ class OlympiamanagementsController < PagesController
}
end
def download_school_code
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:school_code)
@OlympiaSchoolDataFields = OlympiaSchoolDataFields.all.asc(:id)
dir_path = 'tmp/olypiamanagement/'
#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
@ -170,15 +233,21 @@ class OlympiamanagementsController < PagesController
def render_contents_in_index_page(contents=@breadcumb)
doc = Nokogiri::HTML(render_final_page("page",Page.where(:layout=>"olympia_managements_index").first,true), nil, "UTF-8")
viewarea = doc.css("*[data-content='true']")[0]
viewarea.inner_html = @breadcumb
viewarea.inner_html = contents
render :html => doc.to_html.html_safe
end
def updata_school_data
# doc = Nokogiri::HTML(render_final_page("page",Page.where(:layout=>"olympia_managements_index").first,true), nil, "UTF-8")
# viewarea = doc.css("*[data-content='true']")[0]
# viewarea.inner_html = "123"
# render :html => doc.to_html.html_safe
render_contents_in_index_page('123')
@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?
params['add_school_data'].keys.each do |field|
if !@readonly_fields.include?(field)
@olympia_school_data_field[field] = params['add_school_data'][field]
end
end
@olympia_school_data_field.save
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
#render :html => '123'

View File

@ -19,22 +19,26 @@ class OlympiaSchoolDataFields
field :fax , type: String , default: ''
field :mobile_number , type: String , default: ''
field :email , type: String , default: ''
field :enrollment , type: String , default: 0
field :enrollment , type: Fixnum , default: 0
field :approved , type: Boolean , default: true
field :sign_up_setting_id , type: String , default: SignUpSetting.last.id.to_s
after_initialize do
if !self.new_record?
if self.approved.nil?
self.approved = true
self.save
self.save!
end
if self.enrollment.nil?
if self.enrollment.nil? || self.enrollment.class != Fixnum
self.enrollment = 0
self.save
self.save!
end
if self.enrollment_limited.nil?
self.enrollment_limited = 0
self.save!
end
if self.sign_up_setting_id.nil?
self.sign_up_setting_id = SignUpSetting.last.id.to_s
self.save
self.save!
end
sign_up_setting = SignUpSetting.find(self.sign_up_setting_id) rescue nil
if sign_up_setting.nil?

View File

@ -10,7 +10,7 @@
<% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%>
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.'+field.keys[0]) %></li><li class="col_r">
<% if field.values[0][:type] != 'select' %>
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&@olympia_school_data_field[field.keys[0]]== 0 ) ? "" : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0][:size]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>"/>
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 0) ) ? "" : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0][:size]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>"/>
<% else%>
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
<select name="<%="[add_school_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_school_data_field[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>

View File

@ -0,0 +1,58 @@
<h3 align="center"><span><%=t('olympiamanagement.edit_password')%></span></h3>
<form name="login_form" id="login_form" method="get">
<p align="center">
<label for="new_password"><%=t('olympiamanagement.new_password')%>:</label><input name="new_password" type="password" id="new_password" size="25">
<br>
<label for="confirm_password"><%=t('olympiamanagement.confirm_password')%>:</label><input name="confirm_password" type="password" id="confirm_password" size="25">
</p>
<p align="center">
<input id="submit_button" type="submit" name="Submit" value="<%=t('olympiamanagement.submit')%>">
<input id="submit_button" type="button" name="goback" value="<%=t('olympiamanagement.back_to_previous_page')%>" onkeypress="window.history.go(-1);" onclick="window.history.go(-1);">
<input type="hidden" name="PreviousPage" value="<%= OrbitHelper.request.original_url.split(OrbitHelper.request.env["HTTP_HOST"]).last.split('?').first rescue "/"%>">
</p>
</form>
<%if !@error.nil?%>
<script>
<%case @error %>
<% when "confirm_password_error"%>
alert('<%=(I18n.locale.to_s=="zh_tw") ? "確認密碼錯誤!" : "Confirm password error!"%>')
<% when "password_all_empty"%>
alert('<%=(I18n.locale.to_s=="zh_tw") ? "新密碼和確認密碼為空!請填入值在這兩個欄位" : "New password and confirm password are empty!Please fill some value in them."%>')
<% when "new_password_empty"%>
alert('<%=(I18n.locale.to_s=="zh_tw") ? "新密碼為空!請填入值在這個欄位" : "New password is empty!Please fill some value in it."%>')
<% when "confirm_password_empty"%>
alert('<%=(I18n.locale.to_s=="zh_tw") ? "確認密碼為空!請填入值在這個欄位" : "Confirm password is empty!Please fill some value in it."%>')
<%end%>
</script>
<%end%>
<script>
$('#submit_button').click(function(){
var error = "",flag = false , new_password = $('#new_password').val(),confirm_password = $('#confirm_password').val();
if(new_password == "" && confirm_password == "")
error = "password_all_empty";
else if(new_password == "")
error = "new_password_empty";
else if(confirm_password == "")
error = "confirm_password_empty";
else if(new_password != confirm_password)
error = "confirm_password_error";
switch (error) {
case "confirm_password_error":
alert('<%=(I18n.locale.to_s=="zh_tw") ? "確認密碼錯誤!" : "Confirm password error!"%>');
break;
case "password_all_empty":
alert('<%=(I18n.locale.to_s=="zh_tw") ? "新密碼和確認密碼為空!請填入值在這兩個欄位" : "New password and confirm password are empty!Please fill some value in them."%>');
break;
case "new_password_empty":
alert('<%=(I18n.locale.to_s=="zh_tw") ? "新密碼為空!請填入值在這個欄位" : "New password is empty!Please fill some value in it."%>');
break;
case "confirm_password_empty":
alert('<%=(I18n.locale.to_s=="zh_tw") ? "確認密碼為空!請填入值在這個欄位" : "Confirm password is empty!Please fill some value in it."%>');
break;
default:
flag = true;
}
return flag;
});
</script>

View File

@ -0,0 +1,32 @@
<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>
<fieldset class="fieldset_block">
<legend class="fieldset_title"><%=t('olympiamanagement.school_connection_data')%></legend>
<%=form_for @olympia_school_data_field ,:url=>{:controller=>"olympiamanagements" ,:action=>"updata_school_data",:olympia_user_name=>(session[:olympia_login_id] rescue "")} do |form|%>
<% @school_data_fields.each do |field| %>
<div class="col_text">
<% @extra_class = ((field.values[0]["required"] == "true")? " required" : "")%>
<% @extra_text = ((field.values[0]["required"] == "true")? "*" : "")%>
<li class="col<%=@extra_class%>" for="<%=field.keys[0]%>"><%= @extra_text+t('olympiamanagement.'+field.keys[0]) %></li><li class="col_r">
<% if field.values[0]["type"] != 'select' %>
<input name="<%="[add_school_data][#{field.keys[0]}]"%>" value="<%= (field.keys[0]=="enrollment_limited"&&(@olympia_school_data_field[field.keys[0]].nil? || @olympia_school_data_field[field.keys[0]] == 0) ) ? ClassSettingFields.all.select{|class_setting_field| class_setting_field.class_number_range[0] <= @olympia_school_data_field.class_number && class_setting_field.class_number_range[1] >= @olympia_school_data_field.class_number}.first.enrollment_available.to_s : @olympia_school_data_field[field.keys[0]] %>" size="<%=field.values[0]["size"]%>" type="text" id="<%= field.keys[0] %>" class="col_input<%= @extra_class%>" <%=field.values[0]["readonly"]%>/>
<% else%>
<% @please_choice = (I18n.locale.to_s == "zh_tw") ? "請選擇" : "Please select." %>
<select name="<%="[add_school_data][#{field.keys[0]}]"%>" id="<%=field.keys[0]%>" class="required" value="<%= @olympia_school_data_field[field.keys[0]] %>" style="width: auto;"><option value=""><%=@please_choice%></option>
<% for @num in field.values[0]["range"][0] .. field.values[0]["range"][1] %>
<%= ('<option value="' + @num.to_s + '">' + @num.to_s + field.values[0][:unit][I18n.locale.to_s] + '</option>').html_safe %>
<% end %>
</select>
<% end %>
</li>
<% if(!field.values[0]["hint"][I18n.locale.to_s].blank? rescue false) %>
<span id="-H" class="field-hint-inactive"><%=field.values[0][:hint][I18n.locale.to_s]%></span>
<% end %>
</div>
<% end %>
<div style="clear:both;"></div>
<input type="submit" name="Submit" value="<%=t('olympiamanagement.confirm')%>">
<input type="reset" name="Submit" value="<%=t('olympiamanagement.cancel')%>">
<% end %>
</fieldset>

View File

@ -1,3 +1,2 @@
<% @@session = session %>
<%#=render :partial=>'login'%>
<%= render_view %>

View File

@ -60,6 +60,10 @@ en:
o_clock: o'clock
minute: Min.
remark: Remarks
registration_instructions: Online registration instructions
print_registration_form: Print registration form
sign_up_hint: Sign-up doesn't start yet or already close.
registration_instructions: Online sign up instructions
print_registration_form: Print sign up form
sign_up_hint: Sign-up doesn't start yet or already close.
please_set_school_connect_data: Please set school connect data first!
new_password: New password
confirm_password: Confirm password
back_to_previous_page: Back to previous page

View File

@ -62,4 +62,8 @@ zh_tw:
remark: 注意事項
registration_instructions: 線上報名說明
print_registration_form: 列印報名表
sign_up_hint: 報名時間尚未開始或已經結束
sign_up_hint: 報名時間尚未開始或已經結束
please_set_school_connect_data: 請先設定學校聯絡資料!
new_password: 新密碼
confirm_password: 確認密碼
back_to_previous_page: 回上一頁