2016-06-29 06:57:45 +00:00
|
|
|
# encoding: utf-8
|
|
|
|
class Admin::SeminarsController < OrbitAdminController
|
|
|
|
|
|
|
|
require 'axlsx'
|
2021-03-17 07:33:31 +00:00
|
|
|
include Admin::SeminarsHelper
|
2019-11-26 15:52:52 +00:00
|
|
|
helper Admin::SeminarsFieldHelper
|
2016-06-29 06:57:45 +00:00
|
|
|
before_action ->(module_app = @app_title) { set_variables module_app }
|
2021-06-17 10:07:43 +00:00
|
|
|
before_action :set_seminar, only: [:edit, :set_write_off, :seminar_signup, :destroy,:seminar_signup_admin_setting,:update_seminar_signup_admin_setting,:get_reviewer_block,:get_session_block,:update_seminar_review,:update_seminar_session,:reviewer_setting,:update_reviewer_setting,:template_setting,:update_template_setting,:sub_page_setting]
|
2021-04-03 16:23:52 +00:00
|
|
|
before_action :set_seminar_signup_admin_setting, only: [:seminar_signup,:seminar_signup_admin_setting,:update_seminar_signup_admin_setting,:get_reviewer_block,:get_session_block]
|
|
|
|
before_action :check_permission_for_seminar, only: [:seminar_signup,:get_reviewer_block,:get_session_block]
|
2021-06-17 10:07:43 +00:00
|
|
|
before_action :check_manager_for_seminar, only: [:seminar_signup_admin_setting,:update_seminar_signup_admin_setting,:update_seminar_review,:update_seminar_session,:reviewer_setting,:update_reviewer_setting,:template_setting,:update_template_setting]
|
2016-06-29 06:57:45 +00:00
|
|
|
def initialize
|
|
|
|
super
|
|
|
|
@app_title = "seminar"
|
|
|
|
end
|
|
|
|
|
|
|
|
def filter_fields(categories)
|
|
|
|
{
|
|
|
|
:category=>categories.map{|c| {:title=>(c.title.blank? ? " " : c.title), :id=>c.id}}
|
|
|
|
}
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
def check_manager_for_seminar
|
|
|
|
OrbitHelper.set_params(params,current_user)
|
2021-11-18 11:08:07 +00:00
|
|
|
OrbitHelper.set_this_module_app("seminar")
|
2021-03-17 07:33:31 +00:00
|
|
|
access_level = OrbitHelper.user_access_level?
|
|
|
|
if (access_level.nil? || access_level == "user") && (@seminar.organizer_id != current_user.member_profile_id rescue true)
|
|
|
|
render_401
|
2021-11-18 11:08:07 +00:00
|
|
|
elsif access_level == "sub_manager" && @seminar && !(OrbitHelper.user_can_edit(@seminar))
|
|
|
|
render_401
|
2021-03-17 07:33:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
def check_permission_for_seminar
|
|
|
|
OrbitHelper.set_params(params,current_user)
|
2021-11-18 11:33:41 +00:00
|
|
|
OrbitHelper.set_this_module_app("seminar")
|
2021-03-17 07:33:31 +00:00
|
|
|
access_level = OrbitHelper.user_access_level?
|
|
|
|
if (access_level.nil? || access_level == "user")
|
|
|
|
unless (@seminar.reviewer_ids.include?(current_user.member_profile_id.to_s) rescue false) || (@seminar.organizer_id == current_user.member_profile_id rescue false)
|
|
|
|
render_401
|
|
|
|
else
|
|
|
|
@user_authenticated_categories = ['all']
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-06-17 10:07:43 +00:00
|
|
|
def template_setting
|
|
|
|
@seminar_template_setting = @seminar.seminar_template_setting
|
|
|
|
if @seminar_template_setting.nil?
|
|
|
|
@seminar_template_setting = SeminarTemplateSetting.create(:seminar_main=>@seminar)
|
|
|
|
end
|
2021-07-14 04:57:47 +00:00
|
|
|
@seminar_page_root = Page.where(:parent_page_id=>params[:id]).first
|
2022-08-20 06:16:39 +00:00
|
|
|
if @seminar_page_root.nil?
|
|
|
|
@seminar_page_root = @seminar_template_setting.create_seminar_pages
|
|
|
|
end
|
2021-07-14 04:57:47 +00:00
|
|
|
display_menu = []
|
|
|
|
if @seminar_page_root
|
|
|
|
default_display_menu = SeminarTemplateSetting::DefaultMenu
|
|
|
|
default_display_menu.each do |page_id|
|
|
|
|
page = @seminar_page_root.child_page.where(:page_id=>page_id).first
|
|
|
|
if page
|
|
|
|
display_menu << page_id if page.enabled_for.length != 0
|
|
|
|
else
|
2021-11-30 02:07:29 +00:00
|
|
|
display_menu << page_id if page_id != "registered_participants"
|
2021-07-14 04:57:47 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@seminar_template_setting.update(:display_menu=>display_menu)
|
2021-06-17 10:07:43 +00:00
|
|
|
if (CustomBulletinConfig.where(:module=>"seminar").count == 0 rescue false)
|
|
|
|
CustomBulletinConfig.create(:module=>"seminar",:bind_model=>"SeminarMain",:custom_record_callback=>"manage_announcement_count")
|
|
|
|
end
|
|
|
|
if (CustomAlbumConfig.where(:module=>"seminar").count == 0 rescue false)
|
|
|
|
CustomAlbumConfig.create(:module=>"seminar",:bind_model=>"SeminarMain",:custom_record_callback=>"manage_album_count")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def update_template_setting
|
|
|
|
@seminar_template_setting = SeminarTemplateSetting.find(params[:id])
|
|
|
|
@seminar_template_setting.update_attributes(seminar_template_setting_params)
|
|
|
|
redirect_to admin_seminars_path
|
|
|
|
end
|
|
|
|
def sub_page_setting
|
|
|
|
@seminar_page_root = Page.where(:parent_page_id=>params[:id]).first
|
2022-12-19 05:18:45 +00:00
|
|
|
@seminar_template_setting = SeminarTemplateSetting.where(:seminar_main_id=>params[:id]).first
|
2021-07-14 04:57:47 +00:00
|
|
|
available_locales = Site.first.in_use_locales rescue I18n.available_locales
|
|
|
|
available_locales = available_locales.map{|l| l.to_s}
|
2021-06-17 10:07:43 +00:00
|
|
|
if @seminar_page_root.nil?
|
2022-08-20 06:16:39 +00:00
|
|
|
@seminar_page_root = @seminar_template_setting.create_seminar_pages
|
2022-12-19 04:20:03 +00:00
|
|
|
else
|
|
|
|
@seminar_template_setting.create_seminar_pages(false)
|
2021-06-17 10:07:43 +00:00
|
|
|
end
|
|
|
|
@items = @seminar_page_root.child_page
|
|
|
|
@parent_pages = []
|
|
|
|
# exceptions = ["personal_book","personal_conference","personal_diploma","personal_experience","personal_journal","personal_lab","personal_patent","personal_project","personal_research"]
|
|
|
|
exceptions = []
|
|
|
|
@modules = ModuleApp.where(:key.nin => exceptions).frontend_enabled.order_by(:key=>'asc')
|
|
|
|
@searchfilter = @modules.collect{|m|[t('module_name.'+m.key),m.key]}
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
def reviewer_setting
|
|
|
|
@seminar_reviews = @seminar.seminar_reviews
|
|
|
|
@fields = []
|
|
|
|
@fields_translations = []
|
|
|
|
access_markup = ["select","radio_button","checkbox"]
|
|
|
|
@fields_values = []
|
|
|
|
@seminar.seminar_signup_fields.each do |f|
|
|
|
|
next if f.disabled
|
|
|
|
if access_markup.include?(f.markup)
|
|
|
|
@fields << "seminar_signup_fields.#{f.id}"
|
|
|
|
@fields_translations << f.title
|
|
|
|
@fields_values << f.option_list
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@seminar.seminar_submission_fields.each do |f|
|
|
|
|
next if f.disabled
|
|
|
|
if access_markup.include?(f.markup)
|
|
|
|
@fields << "seminar_submission_fields.#{f.id}"
|
|
|
|
@fields_translations << f.title
|
|
|
|
@fields_values << f.option_list
|
|
|
|
end
|
|
|
|
end
|
2021-03-24 13:06:49 +00:00
|
|
|
if @seminar.enable_summary_choice
|
|
|
|
@fields << "seminar_signup_contributes.description"
|
2021-03-26 03:55:59 +00:00
|
|
|
begin
|
|
|
|
data2 = @seminar.seminar_submission_field_sets.select{|v| v.field_name=='description'}[0]
|
|
|
|
name2 = data2['name'][I18n.locale]
|
|
|
|
@fields_translations << (name2.present? ? name2 : I18n.t("seminar_signup.description"))
|
|
|
|
rescue
|
|
|
|
@fields_translations << I18n.t("seminar_signup.description")
|
|
|
|
end
|
2021-03-24 13:06:49 +00:00
|
|
|
@fields_values << @seminar.summary_chioices.map.with_index{|v,i| [i.to_s,{I18n.locale=>v}]}.to_h
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
@fields_values = @fields_values.collect.with_index{|fields_values,i| [i, fields_values.values.map{|v| v[I18n.locale]} ] }.to_h
|
|
|
|
end
|
|
|
|
def update_reviewer_setting
|
|
|
|
seminar_params[:seminar_reviews_attributes].keys.each do |i|
|
|
|
|
if seminar_params[:seminar_reviews_attributes][i][:default_topics].present?
|
|
|
|
seminar_params[:seminar_reviews_attributes][i][:default_topics] = [] if seminar_params[:seminar_reviews_attributes][i][:default_topics].nil?
|
|
|
|
default_topics_values = []
|
|
|
|
(0...seminar_params[:seminar_reviews_attributes][i][:default_topics].count).each do |ii|
|
|
|
|
default_topics_values << (Array(seminar_params[:seminar_reviews_attributes][i][:default_topics_values][ii.to_s]) rescue [])
|
|
|
|
end
|
|
|
|
seminar_params[:seminar_reviews_attributes][i][:default_topics_values] = default_topics_values
|
|
|
|
else
|
|
|
|
seminar_params[:seminar_reviews_attributes][i][:default_topics] = []
|
|
|
|
seminar_params[:seminar_reviews_attributes][i][:default_topics_values] = []
|
|
|
|
end
|
|
|
|
end
|
|
|
|
#render :html => seminar_params and return
|
|
|
|
@seminar.update_attributes(seminar_params)
|
|
|
|
unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s}
|
2021-04-03 16:23:52 +00:00
|
|
|
unassigned_mode_1_seminar_signup_ids = unassigned_seminar_signup_ids.dup
|
2021-03-17 07:33:31 +00:00
|
|
|
@seminar.seminar_reviews.each do |sr|
|
2021-04-03 16:23:52 +00:00
|
|
|
unassigned_mode_1_seminar_signup_ids = unassigned_mode_1_seminar_signup_ids - sr.get_all_seminar_signup_ids(1)
|
2021-03-17 07:33:31 +00:00
|
|
|
unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
@seminar.unassigned_mode_1_seminar_signup_ids = unassigned_mode_1_seminar_signup_ids
|
2021-03-17 07:33:31 +00:00
|
|
|
@seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids
|
|
|
|
@seminar.save
|
|
|
|
redirect_to admin_seminars_path
|
|
|
|
end
|
|
|
|
def enquiry_for_applicants
|
|
|
|
OrbitHelper.set_params(params,current_user)
|
|
|
|
@access_level = OrbitHelper.user_access_level?
|
|
|
|
@can_edit = true
|
|
|
|
if @access_level == "user" || @access_level.nil?
|
|
|
|
@can_edit = false
|
|
|
|
end
|
|
|
|
reviewer_id = current_user.member_profile_id.to_s
|
|
|
|
if !@can_edit && SeminarMain.where(:reviewer_ids=>reviewer_id).count == 0 && SeminarMain.where(:organizer_id=>reviewer_id).count == 0
|
|
|
|
render_401 and return
|
|
|
|
end
|
|
|
|
|
|
|
|
@seminar_signup_admin_setting = SeminarSignupAdminSetting.where(:seminar_main_id=>"enquiry_for_applicants").first
|
|
|
|
if @seminar_signup_admin_setting.nil?
|
|
|
|
@seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>"enquiry_for_applicants")
|
|
|
|
end
|
|
|
|
if params[:name].present?
|
2021-03-29 14:27:08 +00:00
|
|
|
@seminar_signups = SeminarSignup.where(:name => /#{params[:name]}/).sort_ordered.page(params[:page]).per(10)
|
2021-03-17 07:33:31 +00:00
|
|
|
else
|
|
|
|
@seminar_signups = []
|
|
|
|
end
|
|
|
|
unless @can_edit
|
|
|
|
if @seminar_signups.class != Array
|
2021-04-03 16:23:52 +00:00
|
|
|
seminar_review = SeminarReview.where(:reviewer_id=>reviewer_id)
|
|
|
|
seminar_signup_ids = seminar_review.pluck(:seminar_signup_ids).flatten
|
2021-04-24 10:41:50 +00:00
|
|
|
seminar_sessions = SeminarSession.where(:id.in=>seminar_review.pluck(:seminar_session_ids))
|
2021-04-03 16:23:52 +00:00
|
|
|
remove_seminar_signup_ids = seminar_review.pluck(:remove_seminar_signup_ids).flatten
|
|
|
|
assign_ids = []
|
|
|
|
seminars = SeminarMain.where(:id.in => seminar_review.pluck(:seminar_main_id))
|
2021-04-24 10:41:50 +00:00
|
|
|
final_assign_signup_ids = SeminarSession.where(:id.in=>seminar_review.pluck(:seminar_session_ids).flatten,:seminar_main_id.in=>seminars.where(:assign_mode.in=>[1,2]).pluck(:id)).pluck(:seminar_signup_ids,:default_seminar_signup_ids).flatten
|
2021-04-03 16:23:52 +00:00
|
|
|
default_seminar_signup_ids = seminar_review.where(:seminar_main_id.in=>seminars.where(:assign_mode=>0).pluck(:id)).pluck(:default_seminar_signup_ids).flatten
|
|
|
|
all_seminar_signup_ids = seminar_signup_ids - remove_seminar_signup_ids + final_assign_signup_ids + default_seminar_signup_ids
|
2021-03-17 07:33:31 +00:00
|
|
|
|
|
|
|
ids2 = SeminarSignup.where(:seminar_main_id.in=> SeminarMain.where(:organizer_id=>current_user.member_profile_id).pluck(:id)).pluck(:id)
|
2016-06-29 06:57:45 +00:00
|
|
|
|
2021-03-29 14:27:08 +00:00
|
|
|
@seminar_signups = @seminar_signups.where(:id.in=>all_seminar_signup_ids + ids2).sort_ordered.page(params[:page]).per(10)
|
2021-04-24 10:41:50 +00:00
|
|
|
@preferred_sessions = seminar_review.pluck(:session_ids).flatten
|
2021-03-17 07:33:31 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
def get_hide_session
|
|
|
|
seminar_main = SeminarMain.find(params[:id]) rescue nil
|
|
|
|
if seminar_main.nil?
|
|
|
|
render :nothing => true
|
|
|
|
else
|
|
|
|
@seminar = seminar_main
|
|
|
|
@seminar_sessions = @seminar.seminar_sessions
|
|
|
|
@hide_session_ids = (0...seminar_main.summary_chioices.count).to_a - Array(seminar_main.session_show_ids)
|
2021-04-24 10:41:50 +00:00
|
|
|
@hide_sessions = @hide_session_ids.zip(@hide_session_ids.map{|idx| seminar_main.summary_chioices[idx]}).to_h
|
2021-04-03 16:23:52 +00:00
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
def get_hide_reviewer
|
|
|
|
seminar_main = SeminarMain.find(params[:id]) rescue nil
|
|
|
|
if seminar_main.nil?
|
|
|
|
render :nothing => true
|
|
|
|
else
|
|
|
|
@hide_reviewer_ids = Array(seminar_main.reviewer_ids) - Array(seminar_main.reviewer_show_ids)
|
|
|
|
@hide_reviewers = MemberProfile.where(:id.in=>@hide_reviewer_ids)
|
2021-04-03 16:23:52 +00:00
|
|
|
@reviewers = seminar_main.seminar_reviews.where(:reviewer_id.in=>@hide_reviewer_ids).to_a
|
2021-03-17 07:33:31 +00:00
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
def get_session_block
|
|
|
|
@session_id = params[:session_id].to_i
|
2021-04-24 10:41:50 +00:00
|
|
|
@seminar_session = @seminar.seminar_sessions.where(:key=>@session_id).first
|
2021-04-03 16:23:52 +00:00
|
|
|
unless (@seminar.session_show_ids.include?(@session_id) rescue false)
|
|
|
|
@seminar.session_show_ids << @session_id
|
|
|
|
@seminar.save
|
|
|
|
end
|
|
|
|
render :layout => false
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
def get_reviewer_block
|
|
|
|
@reviewer_id = params[:reviewer_id]
|
|
|
|
unless (@seminar.reviewer_show_ids.include?(@reviewer_id) rescue false)
|
|
|
|
@seminar.reviewer_show_ids << @reviewer_id
|
|
|
|
@seminar.save
|
|
|
|
end
|
|
|
|
render :layout => false
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
def update_seminar_session
|
|
|
|
if @seminar.nil?
|
|
|
|
render :json => {:success => false}
|
|
|
|
else
|
|
|
|
seminar_main = @seminar
|
|
|
|
session_id = params[:session_id].to_i
|
|
|
|
seminar_main.save
|
|
|
|
seminar_session = @seminar.seminar_sessions.where(:key=>session_id).first
|
2021-04-24 10:41:50 +00:00
|
|
|
@seminar_submission_value = nil
|
|
|
|
extra_infos = {}
|
|
|
|
if params[:contribute_id].present?
|
|
|
|
seminar_signup_contribute = SeminarSignupContribute.find(params[:contribute_id])
|
|
|
|
seminar_submission_field = seminar_main.seminar_submission_fields.where(:markup=>"seminar_preferred_session").last
|
|
|
|
if seminar_submission_field
|
|
|
|
@seminar_submission_value = seminar_signup_contribute.seminar_submission_values.where(:seminar_submission_field_id=>seminar_submission_field.id).last
|
|
|
|
end
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
if params[:mode] == "append"
|
2021-04-24 10:41:50 +00:00
|
|
|
if @seminar_submission_value
|
|
|
|
@seminar_submission_value.val = session_id.to_s
|
|
|
|
@seminar_submission_value.save
|
|
|
|
extra_infos = {"edit" => {"target"=>"[data-id=\"#{@seminar_submission_value.id}\"]","text"=>@seminar_submission_value.get_value_by_locale(I18n.locale)}}
|
|
|
|
else
|
|
|
|
@seminar_signup.final_sessions << session_id
|
|
|
|
@seminar_signup.seminar_session_ids << seminar_session.id
|
|
|
|
@seminar_signup.seminar_session_ids = @seminar_signup.seminar_session_ids.uniq
|
|
|
|
@seminar_signup.save
|
|
|
|
seminar_session.seminar_signup_contribute_ids.append(params[:contribute_id])
|
|
|
|
seminar_signup_contribute.update(:final_session=>session_id) rescue nil
|
|
|
|
seminar_session.seminar_signup_ids << @seminar_signup.id.to_s
|
|
|
|
seminar_main.assign_mode = 1 if seminar_main.assign_mode != 2
|
|
|
|
seminar_session.save
|
|
|
|
seminar_main.unassigned_mode_1_seminar_signup_ids.delete(@seminar_signup.id.to_s)
|
|
|
|
end
|
|
|
|
elsif params[:mode] == "remove_contribute"
|
|
|
|
if @seminar_submission_value
|
|
|
|
@seminar_submission_value.val = nil
|
|
|
|
@seminar_submission_value.save
|
|
|
|
extra_infos = {"edit" => {"target"=>"[data-id=\"#{@seminar_submission_value.id}\"]","text"=>""}}
|
|
|
|
else
|
|
|
|
seminar_session.seminar_signup_contribute_ids.delete(params[:contribute_id])
|
|
|
|
seminar_signup_contribute.update(:final_session=>nil) rescue nil
|
|
|
|
seminar_session.save
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
elsif params[:mode] == "remove"
|
2021-04-24 10:41:50 +00:00
|
|
|
if @seminar_submission_value
|
|
|
|
@seminar_submission_value.val = nil
|
|
|
|
@seminar_submission_value.save
|
|
|
|
extra_infos = {"edit" => {"target"=>"[data-id=\"#{@seminar_submission_value.id}\"]","text"=>""}}
|
|
|
|
else
|
|
|
|
@seminar_signup.final_sessions.delete(session_id)
|
|
|
|
@seminar_signup.seminar_session_ids.delete(seminar_session.id)
|
|
|
|
seminar_session.seminar_signup_ids.delete(@seminar_signup.id.to_s)
|
|
|
|
seminar_session.seminar_signup_contribute_ids.delete(params[:contribute_id])
|
|
|
|
seminar_signup_contribute.update(:final_session=>nil) rescue nil
|
|
|
|
@seminar_signup.save
|
|
|
|
seminar_session.save
|
|
|
|
seminar_main.assign_mode = 0 if seminar_main.seminar_sessions.where(:seminar_signup_ids.ne=>[]).count == 0 && seminar_main.assign_mode != 2
|
|
|
|
seminar_main.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
elsif params[:mode] == "hide"
|
|
|
|
if seminar_main.session_show_ids.nil?
|
|
|
|
seminar_main.session_show_ids = (0...seminar_main.summary_chioices.count).to_a[0..1]
|
|
|
|
end
|
|
|
|
seminar_main.session_show_ids.delete(session_id)
|
|
|
|
elsif params[:mode] == "show"
|
|
|
|
seminar_main.session_show_ids = seminar_main.session_show_ids.to_a + Array(session_id)
|
|
|
|
else
|
|
|
|
render :json => {:success => false} and return
|
|
|
|
end
|
|
|
|
seminar_main.save
|
2021-04-24 10:41:50 +00:00
|
|
|
render :json => {:success => true}.merge(extra_infos)
|
2021-04-03 16:23:52 +00:00
|
|
|
end
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
def update_seminar_review
|
|
|
|
if @seminar_review.nil?
|
|
|
|
render :json => {:success => false}
|
|
|
|
else
|
|
|
|
seminar_main = @seminar_review.seminar_main
|
|
|
|
if params[:mode] == "append"
|
|
|
|
@seminar_review.seminar_signup_ids << params[:signup_id]
|
|
|
|
@seminar_review.remove_seminar_signup_ids.delete(params[:signup_id])
|
|
|
|
seminar_main.unassigned_seminar_signup_ids.delete(params[:signup_id])
|
2021-04-03 16:23:52 +00:00
|
|
|
seminar_main.unassigned_mode_1_seminar_signup_ids.delete(params[:signup_id])
|
2021-04-24 10:41:50 +00:00
|
|
|
if(params[:contribute_id].present?)
|
|
|
|
@seminar_review.seminar_signup_contribute_ids << params[:contribute_id]
|
|
|
|
@seminar_review.remove_seminar_signup_contribute_ids.delete(params[:contribute_id])
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
elsif params[:mode] == "remove"
|
|
|
|
@seminar_review.seminar_signup_ids.delete(params[:signup_id])
|
|
|
|
@seminar_review.remove_seminar_signup_ids << params[:signup_id]
|
|
|
|
seminar_main.unassigned_seminar_signup_ids << params[:signup_id]
|
2021-04-03 16:23:52 +00:00
|
|
|
seminar_main.unassigned_mode_1_seminar_signup_ids << params[:signup_id]
|
2021-04-24 10:41:50 +00:00
|
|
|
if(params[:contribute_id].present?)
|
|
|
|
@seminar_review.seminar_signup_contribute_ids.delete(params[:contribute_id])
|
|
|
|
@seminar_review.remove_seminar_signup_contribute_ids << params[:contribute_id]
|
|
|
|
end
|
|
|
|
elsif params[:mode] == "remove_contribute"
|
|
|
|
if(params[:contribute_id].present?)
|
|
|
|
@seminar_review.seminar_signup_contribute_ids.delete(params[:contribute_id])
|
|
|
|
@seminar_review.remove_seminar_signup_contribute_ids << params[:contribute_id]
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
elsif params[:mode] == "hide"
|
|
|
|
if seminar_main.reviewer_show_ids.nil?
|
|
|
|
seminar_main.reviewer_show_ids = seminar_main.reviewer_ids[0..1]
|
|
|
|
end
|
|
|
|
seminar_main.reviewer_show_ids = seminar_main.reviewer_show_ids - Array(@seminar_review.reviewer_id).flatten
|
|
|
|
elsif params[:mode] == "show"
|
|
|
|
seminar_main.reviewer_show_ids = seminar_main.reviewer_show_ids.to_a + Array(@seminar_review.reviewer_id).flatten
|
|
|
|
else
|
|
|
|
render :json => {:success => false} and return
|
|
|
|
end
|
|
|
|
seminar_main.save
|
|
|
|
@seminar_review.save
|
|
|
|
render :json => {:success => true}
|
|
|
|
end
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
def index
|
|
|
|
@categories = @module_app.categories.enabled
|
|
|
|
@filter_fields = filter_fields(@categories)
|
|
|
|
@table_fields = [:category, 'seminar.title', 'seminar.event_during', 'seminar.signup_during', 'seminar.signup_count', 'seminar.export']
|
|
|
|
|
|
|
|
if !params[:sort].blank?
|
|
|
|
if params[:sort] == 'event_during'
|
|
|
|
sort = {:seminar_start_date.to_sym=>params[:order]}
|
|
|
|
elsif params[:sort] == 'signup_during'
|
|
|
|
sort = {:signup_start_date.to_sym=>params[:order]}
|
|
|
|
else
|
|
|
|
sort = {params[:sort].to_sym=>params[:order]}
|
|
|
|
end
|
|
|
|
else
|
2021-04-03 16:23:52 +00:00
|
|
|
sort = {:signup_start_date=>"desc",:created_at=>"desc"}
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
@seminars = SeminarMain.all.order_by(sort).with_categories(filters("category"))
|
|
|
|
|
|
|
|
@seminars = search_data(@seminars,[:title]).page(params[:page]).per(10)
|
2021-03-17 07:33:31 +00:00
|
|
|
OrbitHelper.set_params(params,current_user)
|
2021-11-18 11:33:41 +00:00
|
|
|
OrbitHelper.set_this_module_app("seminar")
|
2021-03-17 07:33:31 +00:00
|
|
|
@access_level = OrbitHelper.user_access_level?
|
|
|
|
@can_edit = true
|
|
|
|
if @access_level == "user" || @access_level.nil?
|
|
|
|
@can_edit = false
|
|
|
|
end
|
|
|
|
unless @can_edit
|
|
|
|
reviewer_id = current_user.member_profile_id.to_s
|
|
|
|
ids1 = @seminars.where(:reviewer_ids=>reviewer_id).pluck(:id)
|
|
|
|
ids2 = @seminars.where(:organizer_id=>current_user.member_profile_id).pluck(:id)
|
|
|
|
@seminars = @seminars.where(:id.in=>ids1+ids2)
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
if request.xhr?
|
|
|
|
render :partial => "index"
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def export
|
|
|
|
|
|
|
|
@seminar = SeminarMain.find(params[:id])
|
|
|
|
@seminar_signups = SeminarSignup.where(:seminar_main_id => params[:id])
|
2016-08-04 07:58:35 +00:00
|
|
|
filename = @seminar.title.parameterize.underscore + "_export.xlsx"
|
2021-03-17 07:33:31 +00:00
|
|
|
if can_see_seminar_signup(@seminar)
|
|
|
|
if !admin_for_seminar(@seminar)
|
|
|
|
@seminar_review = @seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first
|
2021-04-03 16:23:52 +00:00
|
|
|
@seminar_signups = @seminar_signups.where(:id.in=>@seminar_review.get_all_seminar_signup_ids) rescue []
|
2021-03-17 07:33:31 +00:00
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
@seminar_signups = @seminar_signups.sort_ordered
|
2021-03-17 07:33:31 +00:00
|
|
|
respond_to do |format|
|
|
|
|
format.xlsx {
|
|
|
|
response.headers['Content-Disposition'] = 'attachment; filename="' + filename + '"'
|
|
|
|
}
|
|
|
|
end
|
|
|
|
else
|
|
|
|
render :nothing => true
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
def copy
|
|
|
|
@seminar = SeminarMain.find(params[:id]).clone_new
|
|
|
|
@member = MemberProfile.where(:id.in=>@seminar.reviewer_ids).to_a
|
|
|
|
@email_set = @seminar.seminar_email_sets
|
|
|
|
@signup_sets = @seminar.seminar_signup_field_sets
|
|
|
|
@submission_set = @seminar.seminar_submission_field_sets
|
|
|
|
@custom_set = @seminar.seminar_signup_field_customs
|
|
|
|
@seminar_items = SeminarItem.all
|
|
|
|
@review = @seminar.seminar_reviews.first
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
def new
|
2019-10-04 16:11:39 +00:00
|
|
|
@member = nil
|
2016-06-29 06:57:45 +00:00
|
|
|
@seminar = SeminarMain.new
|
2019-12-30 05:11:46 +00:00
|
|
|
create_set (false)
|
2019-11-26 15:52:52 +00:00
|
|
|
@signup_sets = @seminar.seminar_signup_field_sets
|
|
|
|
@submission_set = @seminar.seminar_submission_field_sets
|
|
|
|
@custom_set = @seminar.seminar_signup_field_customs
|
2016-06-29 06:57:45 +00:00
|
|
|
@seminar_items = SeminarItem.all
|
2019-10-04 16:11:39 +00:00
|
|
|
@review = @seminar.seminar_reviews.new()
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
|
|
|
|
if !seminar_params['seminar_links_attributes'].nil?
|
|
|
|
seminar_params['seminar_links_attributes'].each do |idx,link|
|
|
|
|
seminar_params['seminar_links_attributes'].delete(idx.to_s) if link['url'].blank?
|
|
|
|
end
|
|
|
|
end
|
2019-12-30 05:11:46 +00:00
|
|
|
seminar_main_params = seminar_params
|
2022-11-09 05:20:36 +00:00
|
|
|
if seminar_main_params[:copy_id]
|
2022-10-22 10:43:36 +00:00
|
|
|
seminar_signup_set_params = seminar_main_params['seminar_signup_field_sets_attributes']
|
|
|
|
seminar_submission_set_params = seminar_main_params['seminar_submission_field_sets_attributes']
|
|
|
|
seminar_email_sets_params = seminar_main_params['seminar_email_sets_attributes']
|
|
|
|
seminar_signup_field_customs_params = seminar_main_params["seminar_signup_field_customs_attributes"].to_h rescue {}
|
|
|
|
seminar_signup_field_customs_params.each do |k,v|
|
|
|
|
v.delete "title"
|
|
|
|
end
|
|
|
|
seminar_main_params.delete(:seminar_signup_field_sets_attributes)
|
|
|
|
seminar_main_params.delete(:seminar_submission_field_sets_attributes)
|
|
|
|
seminar_main_params.delete(:seminar_email_sets_attributes)
|
|
|
|
end
|
2019-12-30 05:11:46 +00:00
|
|
|
seminar = SeminarMain.new(seminar_main_params)
|
2016-06-29 06:57:45 +00:00
|
|
|
seminar.create_user_id = current_user.id
|
|
|
|
seminar.update_user_id = current_user.id
|
2021-04-03 16:23:52 +00:00
|
|
|
if seminar.copy_id && params["clone_signups"].blank?
|
2021-04-04 01:49:24 +00:00
|
|
|
seminar.except_clone_relations = ["seminar_signups","seminar_signup_values","seminar_signup_contributes","seminar_submission_values"]
|
2020-03-15 07:37:14 +00:00
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
seminar.save
|
2022-11-09 05:20:36 +00:00
|
|
|
if seminar_main_params[:copy_id]
|
2021-04-03 16:23:52 +00:00
|
|
|
seminar_signup_set_params.each do |key,value|
|
|
|
|
seminar.seminar_signup_field_sets[key.to_i].update_attributes(value) rescue nil
|
|
|
|
end
|
|
|
|
seminar_submission_set_params.each do |key,value|
|
|
|
|
seminar.seminar_submission_field_sets[key.to_i].update_attributes(value) rescue nil
|
|
|
|
end
|
|
|
|
seminar_email_sets_params.each do |key,value|
|
|
|
|
seminar.seminar_email_sets[key.to_i].update_attributes(value) rescue nil
|
|
|
|
end
|
|
|
|
seminar_signup_field_customs_params.each_with_index do |(key,value),i|
|
|
|
|
seminar.seminar_signup_field_customs[i].update(:seminar_signup_field_id => seminar.seminar_signup_fields.where(:title=>value["title"]).first.id) rescue nil
|
|
|
|
end
|
2020-03-15 07:37:14 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
redirect_to params['referer_url']
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@seminar_items = SeminarItem.all
|
2019-11-26 15:52:52 +00:00
|
|
|
@seminar = SeminarMain.where(id: params[:id]).first
|
2019-12-30 05:11:46 +00:00
|
|
|
create_set (true)
|
2019-11-26 15:52:52 +00:00
|
|
|
@signup_sets = @seminar.seminar_signup_field_sets
|
|
|
|
@submission_set = @seminar.seminar_submission_field_sets
|
|
|
|
@custom_set = @seminar.seminar_signup_field_customs
|
2021-03-17 07:33:31 +00:00
|
|
|
@member = MemberProfile.where(:id.in=>@seminar.reviewer_ids).to_a rescue []
|
|
|
|
if (@seminar.organizer_id == current_user.member_profile_id rescue false)
|
|
|
|
@user_authorized_categories = @module_app.categories.enabled.to_a
|
2019-10-04 16:11:39 +00:00
|
|
|
else
|
2021-03-17 07:33:31 +00:00
|
|
|
@user_authorized_categories = nil
|
2019-10-04 16:11:39 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
2021-08-22 08:48:49 +00:00
|
|
|
@seminar_params = seminar_params rescue {}
|
|
|
|
if @seminar_params.count != 0
|
|
|
|
@seminar_params[:registration_status] = (@seminar_params[:registration_status] ? @seminar_params[:registration_status] : [])
|
|
|
|
uid = params[:id].split('-').last
|
|
|
|
@seminar = SeminarMain.find_by(:uid=>uid)
|
|
|
|
if @seminar_params.has_key?("title_translations")
|
|
|
|
@seminar_params["reviewer_ids"] = [] if @seminar_params["reviewer_ids"].nil?
|
|
|
|
@seminar_params["organizer_id"] = nil if @seminar_params["organizer_id"].nil?
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
2023-01-11 09:44:40 +00:00
|
|
|
if @seminar_params[:seminar_signup_fields_attributes]
|
|
|
|
@seminar.update_attributes(@seminar_params.slice(:seminar_signup_fields_attributes))
|
2021-08-22 08:48:49 +00:00
|
|
|
flash.now[:notice] = "Updated Fields"
|
|
|
|
redirect_to admin_seminars_path and return
|
2023-01-11 09:44:40 +00:00
|
|
|
elsif @seminar_params[:seminar_submission_fields_attributes]
|
|
|
|
@seminar.update_attributes(@seminar_params.slice(:seminar_submission_fields_attributes))
|
2021-08-22 08:48:49 +00:00
|
|
|
flash.now[:notice] = "Updated Fields"
|
|
|
|
if @seminar.seminar_submission_fields.select{|sf| sf.markup == "seminar_preferred_session"}.count != 0
|
|
|
|
@seminar.update(:assign_mode => 2)
|
|
|
|
default_sort_number = SeminarSignup.fields['sort_number'].options[:default]
|
|
|
|
SeminarSignup.where(:sort_number=>nil).update_all(:sort_number=>default_sort_number)
|
|
|
|
SeminarSignupContribute.where(:sort_number=>nil).update_all(:sort_number=>default_sort_number)
|
|
|
|
preferred_session_field = @seminar.seminar_submission_fields.select{|sf| sf.markup == "seminar_preferred_session"}.first
|
|
|
|
if preferred_session_field.seminar_submission_values.count != 0
|
|
|
|
seminar_submission_values = preferred_session_field.seminar_submission_values.to_a
|
|
|
|
seminar_submission_values.each do |v|
|
|
|
|
if v.seminar_signup_contribute.nil?
|
|
|
|
v.destroy
|
|
|
|
next
|
|
|
|
end
|
|
|
|
next if v.val.to_i.to_s != v.val
|
|
|
|
seminar_session = @seminar.seminar_sessions.where(:key=>v.val.to_i).first
|
|
|
|
seminar_session.default_seminar_signup_ids << v.seminar_signup_contribute.seminar_signup_id.to_s
|
|
|
|
seminar_session.default_seminar_signup_ids = seminar_session.default_seminar_signup_ids.uniq
|
|
|
|
seminar_session.save
|
|
|
|
end
|
|
|
|
Thread.new do
|
|
|
|
SeminarMain.where(:update_old_flag=>false).each{|s| s.fix_old_data}
|
2021-04-24 11:28:46 +00:00
|
|
|
end
|
2021-04-24 10:41:50 +00:00
|
|
|
end
|
2021-08-22 08:48:49 +00:00
|
|
|
else
|
2021-11-15 11:25:38 +00:00
|
|
|
if @seminar.seminar_sessions.where(:seminar_signup_ids.ne=>[]).count == 0
|
2021-08-22 08:48:49 +00:00
|
|
|
@seminar.update(:assign_mode => 0)
|
|
|
|
else
|
|
|
|
@seminar.update(:assign_mode => 1)
|
2021-04-24 10:41:50 +00:00
|
|
|
end
|
|
|
|
end
|
2021-08-22 08:48:49 +00:00
|
|
|
redirect_to admin_seminars_path and return
|
2021-04-24 10:41:50 +00:00
|
|
|
else
|
2021-08-22 08:48:49 +00:00
|
|
|
if !seminar_params['seminar_links_attributes'].nil?
|
|
|
|
seminar_params['seminar_links_attributes'].each do |idx,link|
|
|
|
|
seminar_params['seminar_links_attributes'].delete(idx.to_s) if link['url'].blank?
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
@seminar.update_user_id = current_user.id
|
|
|
|
if @seminar.update_attributes(seminar_params)
|
2023-01-11 09:44:40 +00:00
|
|
|
@seminar.update_enable_recaptcha
|
2021-08-22 08:48:49 +00:00
|
|
|
@seminar.seminar_signup_fields.each{|t| t.destroy if t["to_delete"] == true}
|
|
|
|
redirect_to params['referer_url'] and return
|
|
|
|
else
|
|
|
|
flash.now[:error] = t('update.error.category')
|
|
|
|
render action: :edit and return
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-08-22 08:48:49 +00:00
|
|
|
redirect_to admin_seminars_path
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
def set_write_off
|
|
|
|
|
|
|
|
@seminar.donation_write_off_status = true
|
|
|
|
@seminar.save
|
|
|
|
|
|
|
|
redirect_to "/admin/seminars?page=#{params['page']}"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
|
|
|
|
@seminar.destroy
|
|
|
|
redirect_to "/admin/seminars"
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
def seminar_signup_field
|
|
|
|
@field_name = 'seminar_main'
|
|
|
|
@attribute = SeminarMain.find(params[:id])
|
|
|
|
@attribute_type = 'seminar'
|
|
|
|
@class = 'seminars'
|
|
|
|
end
|
|
|
|
|
2019-11-26 15:52:52 +00:00
|
|
|
def seminar_submission_field
|
|
|
|
@field_name = 'seminar_main'
|
|
|
|
@attribute = SeminarMain.find(params[:id])
|
|
|
|
@attribute_type = 'seminar'
|
|
|
|
@class = 'seminars'
|
|
|
|
end
|
|
|
|
|
2016-06-29 06:57:45 +00:00
|
|
|
def seminar_signup
|
2021-03-17 07:33:31 +00:00
|
|
|
@seminar_signups = []
|
2021-04-24 10:41:50 +00:00
|
|
|
@filter_fields = {}
|
|
|
|
@summary_chioices = @seminar.enable_summary_choice ? @seminar.summary_chioices : []
|
|
|
|
@enable_review_result = @seminar.enable_review_result
|
|
|
|
if @enable_review_result
|
|
|
|
@filter_fields["seminar.assigned_session"] = @summary_chioices.map.with_index{|summary_chioice,i| {:title=>summary_chioice, :id=>i}} rescue []
|
|
|
|
end
|
2021-03-17 07:33:31 +00:00
|
|
|
if params[:type] == "table"
|
2021-03-29 14:27:08 +00:00
|
|
|
if params[:search].to_i != 0
|
|
|
|
@seminar_signups = @seminar.seminar_signups.where(:serial_number=>params[:search].to_i)
|
|
|
|
else
|
|
|
|
@seminar_signups = @seminar.seminar_signups.where(:name=>/#{params[:search]}/)
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
elsif params[:type] == "session"
|
2021-04-24 10:41:50 +00:00
|
|
|
assigned_seminar_signups = @seminar.seminar_sessions.pluck(:seminar_signup_ids,:default_seminar_signup_ids).flatten
|
|
|
|
@seminar_signups = @seminar.seminar_signups.where(:id.nin=>assigned_seminar_signups)
|
2016-06-29 06:57:45 +00:00
|
|
|
else
|
2021-04-03 16:23:52 +00:00
|
|
|
unassigned_seminar_signup_ids = @seminar.unassigned_seminar_signup_ids
|
2021-04-24 10:41:50 +00:00
|
|
|
if @seminar.assign_mode != 0
|
2021-04-03 16:23:52 +00:00
|
|
|
unassigned_seminar_signup_ids = @seminar.unassigned_mode_1_seminar_signup_ids
|
|
|
|
end
|
|
|
|
@seminar_signups = @seminar.seminar_signups.where(:id.in => unassigned_seminar_signup_ids, :name=>/#{params[:search]}/)
|
2021-03-17 07:33:31 +00:00
|
|
|
end
|
|
|
|
OrbitHelper.set_params(params,current_user)
|
|
|
|
@access_level = OrbitHelper.user_access_level?
|
|
|
|
@can_edit = true
|
|
|
|
if @access_level == "user" || @access_level.nil?
|
|
|
|
@can_edit = false
|
|
|
|
end
|
|
|
|
unless @can_edit
|
|
|
|
@can_edit = (@seminar.organizer_id == current_user.member_profile_id rescue false)
|
|
|
|
end
|
|
|
|
unless @can_edit
|
|
|
|
@seminar_review = @seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first
|
2021-04-03 16:23:52 +00:00
|
|
|
@seminar_signups = @seminar.seminar_signups.where(:id.in=>@seminar_review.get_all_seminar_signup_ids)
|
2021-04-24 10:41:50 +00:00
|
|
|
@preferred_sessions = @seminar_review.session_ids
|
|
|
|
if @enable_review_result
|
|
|
|
@filter_fields["seminar.assigned_session"] = @filter_fields["seminar.assigned_session"].select{|h| @preferred_sessions.include?(h[:id])} rescue []
|
|
|
|
end
|
|
|
|
@append_contribute_ids = @seminar_review.seminar_signup_contribute_ids
|
|
|
|
@remove_contribute_ids = @seminar_review.remove_seminar_signup_contribute_ids
|
|
|
|
end
|
|
|
|
if params[:filters] && params[:filters][:assigned_session].present?
|
|
|
|
@preferred_sessions = params[:filters][:assigned_session].map{|s| s.to_i}
|
|
|
|
@seminar_signups = @seminar_signups.where(:preferred_sessions.in=> @preferred_sessions)
|
2021-03-17 07:33:31 +00:00
|
|
|
end
|
2021-03-29 14:27:08 +00:00
|
|
|
@seminar_signups = @seminar_signups.sort_ordered.page(params[:page]).per(10)
|
2021-03-17 07:33:31 +00:00
|
|
|
if request.xhr?
|
|
|
|
render :layout => false
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def seminar_signup_admin_setting
|
|
|
|
if @seminar.nil? && params[:id] != "enquiry_for_applicants"
|
|
|
|
redirect_to admin_seminars_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def update_seminar_signup_admin_setting
|
|
|
|
@seminar_signup_admin_setting.update_attributes(params.require(:seminar_signup_admin_setting).permit!)
|
|
|
|
if params[:id] != "enquiry_for_applicants"
|
2021-04-03 16:23:52 +00:00
|
|
|
redirect_to seminar_signup_admin_seminar_path(params[:id]) + "?type=#{params[:page]}"
|
2021-03-17 07:33:31 +00:00
|
|
|
else
|
|
|
|
redirect_to admin_seminar_enquiry_for_applicants_path
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def set_seminar_signup_admin_setting
|
2021-04-03 16:23:52 +00:00
|
|
|
page = params[:type] || params[:page]
|
2021-04-10 02:47:33 +00:00
|
|
|
if params[:action] == "seminar_signup"
|
|
|
|
page = params[:type]
|
|
|
|
end
|
2021-04-03 16:23:52 +00:00
|
|
|
page = nil if page.blank?
|
|
|
|
@seminar_signup_admin_setting = SeminarSignupAdminSetting.where(:seminar_main_id=>params[:id],:page=>page).first
|
2021-03-17 07:33:31 +00:00
|
|
|
if @seminar_signup_admin_setting.nil?
|
2021-04-03 16:23:52 +00:00
|
|
|
@seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>params[:id],:page=>page)
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
def edit_seminar_signup
|
|
|
|
@seminar_signup = SeminarSignup.find(params[:id])
|
|
|
|
@seminar = SeminarMain.find(@seminar_signup.seminar_main_id)
|
|
|
|
end
|
|
|
|
|
|
|
|
def delete_seminar_signup
|
|
|
|
|
|
|
|
@seminar_signup = SeminarSignup.find(params[:id])
|
|
|
|
|
|
|
|
@seminar_id = @seminar_signup.seminar_main_id
|
|
|
|
|
|
|
|
@seminar_signup.destroy
|
|
|
|
|
|
|
|
redirect_to "/admin/seminars/@seminar_id.to_s/seminar_signup"
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def set_seminar
|
2021-03-17 07:33:31 +00:00
|
|
|
@seminar = SeminarMain.find(params[:id]) rescue nil
|
|
|
|
if params[:action] == "update_seminar_review"
|
|
|
|
@seminar_review = SeminarReview.find(params[:id]) rescue nil
|
|
|
|
@seminar = @seminar_review.seminar_main
|
2021-04-03 16:23:52 +00:00
|
|
|
elsif params[:action] == "update_seminar_session"
|
|
|
|
@seminar_signup = SeminarSignup.find(params[:signup_id]) rescue nil
|
2021-03-17 07:33:31 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|
2021-06-17 10:07:43 +00:00
|
|
|
def seminar_template_setting_params
|
|
|
|
params.require(:seminar_template_setting).permit!
|
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
def seminar_params
|
|
|
|
params.require(:seminar_main).permit!
|
|
|
|
end
|
2019-12-30 05:11:46 +00:00
|
|
|
def create_set (save_flag)
|
2021-11-18 09:59:20 +00:00
|
|
|
except_attributes = SeminarSignup::HiddenFields
|
2022-06-14 08:13:28 +00:00
|
|
|
if @seminar.seminar_signup_field_sets.where(:field_name.in=>except_attributes).destroy != 0
|
|
|
|
@seminar = @seminar.reload
|
|
|
|
end
|
2022-06-14 08:17:58 +00:00
|
|
|
(SeminarSignup.attribute_names + ['recaptcha']).each do |attr_signup|
|
2021-04-24 10:41:50 +00:00
|
|
|
next if except_attributes.include?(attr_signup)
|
2021-11-18 09:59:20 +00:00
|
|
|
signup_set = @seminar.seminar_signup_field_sets.select{|v| v.field_name==attr_signup }
|
|
|
|
if signup_set.length==0
|
|
|
|
if SeminarSignup::DefaultEnableFields.include? attr_signup
|
|
|
|
disabled = false
|
|
|
|
else
|
|
|
|
disabled = true
|
|
|
|
end
|
|
|
|
if ['status','name','tel'].include? attr_signup
|
|
|
|
hidden = false
|
|
|
|
else
|
|
|
|
hidden = true
|
|
|
|
end
|
|
|
|
name1 = Hash.new
|
|
|
|
now_locale = I18n.locale
|
|
|
|
I18n.available_locales.each do |locale|
|
|
|
|
I18n.locale = locale
|
|
|
|
name1[locale] = t("seminar_signup.#{attr_signup}")
|
|
|
|
end
|
|
|
|
I18n.locale = now_locale
|
|
|
|
if save_flag
|
|
|
|
@seminar.seminar_signup_field_sets.create(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
|
|
|
|
else
|
|
|
|
@seminar.seminar_signup_field_sets.new(field_name:attr_signup,disabled:disabled,hidden:hidden,name:name1,placeholder:name1)
|
2019-11-26 15:52:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2021-11-18 09:59:20 +00:00
|
|
|
@seminar.seminar_submission_field_sets.where(:field_name.in=>except_attributes).destroy
|
2019-11-26 15:52:52 +00:00
|
|
|
SeminarSignupContribute.attribute_names.each do |attr_submission|
|
2021-04-24 10:41:50 +00:00
|
|
|
next if except_attributes.include?(attr_submission)
|
2021-11-18 09:59:20 +00:00
|
|
|
signup_set = @seminar.seminar_submission_field_sets.select{|v| v.field_name==attr_submission }
|
|
|
|
if signup_set.length==0
|
|
|
|
name1 = Hash.new
|
|
|
|
now_locale = I18n.locale
|
|
|
|
I18n.available_locales.each do |locale|
|
|
|
|
I18n.locale = locale
|
|
|
|
name1[locale] = t("seminar_signup.#{attr_submission}")
|
|
|
|
end
|
|
|
|
I18n.locale = now_locale
|
|
|
|
if save_flag
|
|
|
|
@seminar.seminar_submission_field_sets.create(field_name:attr_submission,name:name1,placeholder:name1)
|
|
|
|
else
|
|
|
|
@seminar.seminar_submission_field_sets.new(field_name:attr_submission,name:name1,placeholder:name1)
|
2019-11-26 15:52:52 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
@seminar.seminar_signup_fields.all.map{|v| v}.each do |field|
|
|
|
|
set = @seminar.seminar_signup_field_customs.select{|v| v.seminar_signup_field_id==field.id}
|
|
|
|
if set.length == 0
|
|
|
|
@seminar.seminar_signup_field_customs.create(seminar_signup_field_id:field.id)
|
|
|
|
end
|
|
|
|
end
|
2020-01-12 06:39:32 +00:00
|
|
|
@email_set = []
|
|
|
|
['signup','submission','add_file','edit_file'].each do |field_name|
|
|
|
|
email_set = @seminar.seminar_email_sets.select{|v| v.field_name==field_name}
|
|
|
|
if email_set.length==0
|
|
|
|
title = Hash.new
|
|
|
|
content = Hash.new
|
|
|
|
now_locale = I18n.locale
|
|
|
|
I18n.available_locales.each do |locale|
|
|
|
|
I18n.locale = locale
|
|
|
|
title[locale] = t("seminar.email_#{field_name}_success")
|
|
|
|
content[locale] = t("seminar.email_#{field_name}_content")
|
|
|
|
end
|
|
|
|
I18n.locale = now_locale
|
2020-03-11 04:01:52 +00:00
|
|
|
if save_flag
|
|
|
|
email_set = @seminar.seminar_email_sets.create(field_name:field_name,title:title,content:content)
|
|
|
|
else
|
|
|
|
email_set = @seminar.seminar_email_sets.new(field_name:field_name,title:title,content:content)
|
|
|
|
end
|
2020-01-12 06:39:32 +00:00
|
|
|
else
|
|
|
|
email_set = email_set[0]
|
|
|
|
end
|
|
|
|
@email_set << email_set
|
|
|
|
end
|
2019-11-26 15:52:52 +00:00
|
|
|
end
|
2016-06-29 06:57:45 +00:00
|
|
|
end
|