2020-01-27 14:30:23 +00:00
|
|
|
class Admin::OlympiamanagementsController < OrbitAdminController
|
2020-01-29 11:26:44 +00:00
|
|
|
helper Admin::OlympiamanagementsHelper
|
2020-01-22 14:03:38 +00:00
|
|
|
def index
|
|
|
|
end
|
|
|
|
def add_school_data
|
2020-01-29 11:26:44 +00:00
|
|
|
SchoolDataFields.create if SchoolDataFields.all.count == 0
|
|
|
|
@SchoolDataField = SchoolDataFields.first
|
|
|
|
@olympia_school_data_field = (params[:id].nil? ? OlympiaSchoolDataFields.new : ((OlympiaSchoolDataFields.find(params[:id]).nil? rescue true) ? OlympiaSchoolDataFields.new : OlympiaSchoolDataFields.find(params[:id])))
|
|
|
|
end
|
|
|
|
def update_school_data
|
|
|
|
if params[:type] == 'class_setting'
|
|
|
|
@ClassSettingField = (params[:id].nil? ? ClassSettingFields.new : ((ClassSettingFields.find(params[:id]).nil? rescue true) ? ClassSettingFields.new : ClassSettingFields.find(params[:id])))
|
|
|
|
@ClassSettingField.class_number_range = params[:class_number_range].map{|num| num.to_i}
|
|
|
|
@ClassSettingField.enrollment_available = params[:enrollment_available].to_i
|
|
|
|
@ClassSettingField.save
|
|
|
|
render :json => {'success'=>true} and return
|
|
|
|
elsif params[:type] == 'delete_class_setting'
|
|
|
|
if !params[:id].to_s.blank?
|
|
|
|
begin
|
|
|
|
ClassSettingFields.find(params[:id]).destroy
|
|
|
|
rescue
|
|
|
|
puts 'not_found id='+params[:id]+' in ClassSettingFields'
|
|
|
|
end
|
|
|
|
redirect_to :back
|
|
|
|
end
|
|
|
|
elsif params[:type] == 'delete_school_data'
|
|
|
|
if !params[:id].to_s.blank?
|
|
|
|
begin
|
|
|
|
OlympiaSchoolDataFields.find(params[:id]).destroy
|
|
|
|
rescue
|
|
|
|
puts 'not_found id='+params[:id]+' in OlympiaSchoolDataFields'
|
|
|
|
end
|
|
|
|
redirect_to :back
|
|
|
|
end
|
|
|
|
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|
|
|
|
|
@olympia_school_data_field[field] = params['add_school_data'][field]
|
|
|
|
end
|
|
|
|
@olympia_school_data_field.save
|
|
|
|
redirect_to admin_olympiamanagements_school_data_list_path
|
|
|
|
end
|
2020-01-22 14:03:38 +00:00
|
|
|
end
|
|
|
|
def school_data_list
|
2020-01-29 11:26:44 +00:00
|
|
|
@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("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)
|
2020-01-22 14:03:38 +00:00
|
|
|
end
|
|
|
|
def class_setting
|
2020-01-29 11:26:44 +00:00
|
|
|
page_num = params[:page] || 1
|
|
|
|
@class_setting_list = ClassSettingFields.all.asc(:enrollment_available).page(page_num).per(10)
|
|
|
|
@ClassSettingField = (params[:id].nil? ? nil : ((ClassSettingFields.find(params[:id]).nil? rescue true) ? nil : ClassSettingFields.find(params[:id])))
|
2020-01-22 14:03:38 +00:00
|
|
|
end
|
|
|
|
def sign_up_setting
|
|
|
|
end
|
|
|
|
def export_school_connection_data
|
|
|
|
end
|
|
|
|
def export_sign_up_student_data
|
|
|
|
end
|
|
|
|
def download_scan_file_of_certificate
|
|
|
|
end
|
|
|
|
def import_editing_number_of_school_class
|
|
|
|
end
|
|
|
|
end
|