738 lines
28 KiB
Ruby
738 lines
28 KiB
Ruby
class SeminarsController < ApplicationController
|
|
|
|
helper MemberHelper
|
|
include MemberHelper
|
|
include ActionView::Context #vary important (only add this can access @@session from view)
|
|
include Admin::SeminarsHelper
|
|
# include SimpleCaptcha::ControllerHelpers
|
|
def index
|
|
|
|
time_now = Time.now
|
|
|
|
seminars = SeminarMain.all.desc(:seminar_start_date).filter_by_categories
|
|
{
|
|
"seminars" => seminars,
|
|
'time_now' => time_now,
|
|
"total_pages" => seminars.total_pages
|
|
}
|
|
|
|
end
|
|
def widget
|
|
cats = OrbitHelper.widget_categories || []
|
|
widget_data_count = OrbitHelper.widget_data_count
|
|
seminars = SeminarMain.all.desc(:seminar_start_date).filter_by_categories(cats)
|
|
time_now = DateTime.now
|
|
session = OrbitHelper.request.session
|
|
seminars = seminars.map do |seminar|
|
|
link_url = OrbitHelper.url_to_show(seminar.to_param)
|
|
if !seminar.registration_status.blank? && (seminar.signup_start_date <= time_now rescue false) && ( seminar.signup_end_date.nil? || seminar.signup_end_date+1 >= time_now )
|
|
sign_up = ('<a href="'+ link_url + '" target="_blank">' + I18n.t('seminar.signup') + '</a>').html_safe
|
|
elsif seminar.registration_status.blank?
|
|
sign_up = I18n.t('seminar.sign_up_not_open')
|
|
elsif (seminar.signup_start_date > @time_now rescue false)
|
|
sign_up = I18n.t('seminar.sign_up_not_yet')
|
|
else
|
|
sign_up = I18n.t('seminar.sign_up_overdue')
|
|
end
|
|
if !seminar.registration_status.blank? && seminar.registration_status.include?('C') && (seminar.contribute_start_date <= time_now rescue false) && ( seminar.contribute_end_date.nil? || (seminar.contribute_end_date+1 >= time_now rescue false) )
|
|
sign_up += "<span style=\"margin-left: 1em;\">".html_safe
|
|
if !session[:seminar_signup_id].blank?
|
|
if session[:seminar_main_id] == seminar.id
|
|
sign_up += ('<a href="'+ link_url + '?method=con_upload">' + t('seminar_signup.uploads') + '</a>').html_safe
|
|
else
|
|
sign_up += ('<a href="'+ link_url + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
|
|
end
|
|
else
|
|
sign_up += ('<a href="'+ link_url + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
|
|
end
|
|
sign_up += "</span>".html_safe
|
|
end
|
|
files = seminar.seminar_files.map{|file| { "file_url" => file.file.url, "file_title" => (file.title.blank? ? File.basename(file.file.path) : file.title rescue '') } } rescue []
|
|
files.delete(nil)
|
|
links = seminar.seminar_links.map{|link| { "link_url" => link.url, "link_title" => (link.title.blank? ? link.url : link.title) } } rescue []
|
|
{"title" => seminar.title,
|
|
"subtitle" => sign_up,
|
|
"category" => (seminar.category.title rescue ""),
|
|
"link_to_show" => (link_url == "#" ? '' : link_url + "?method=show_data"),
|
|
"postdate" => seminar.seminar_start_date,
|
|
"statuses" => {},
|
|
"bulletin_links" => links,
|
|
"bulletin_files" => files
|
|
}
|
|
end
|
|
{
|
|
"seminars" => seminars,
|
|
"extras" => {
|
|
"date-head" => I18n.t("seminar.seminar_start_date"),
|
|
"category-head" => I18n.t(:category),
|
|
"title-head" => I18n.t("seminar.title")
|
|
}
|
|
}
|
|
end
|
|
def custom_frontend_data
|
|
params = OrbitHelper.params
|
|
seminar = SeminarMain.find_by(:uid=>params[:uid])
|
|
@seminar = seminar
|
|
@site_in_use_locales = Site.first.in_use_locales rescue I18n.available_locales
|
|
seminar_template_setting = seminar.seminar_template_setting
|
|
@seminar_template_setting = seminar_template_setting
|
|
home_page = Page.where(:parent_page_id=>seminar.id).first
|
|
OrbitHelper.set_page(home_page) rescue nil
|
|
prefix_url = OrbitHelper.request.path.split("-").first + "-#{params[:uid]}"
|
|
@prefix_url = prefix_url
|
|
@registration_postfix = "/home/registration"
|
|
header_data = "<a href=\"#{prefix_url}#{home_page.url}\">Home</a> | " +
|
|
"<a href=\"/\">Main Site</a>"
|
|
content_style = seminar_template_setting.content_style
|
|
background_style = seminar_template_setting.background_style
|
|
background_style_info = SeminarTemplateSetting.background_style_infos[background_style].to_h
|
|
content_style_info = SeminarTemplateSetting.content_style_infos[content_style].to_h
|
|
extra_css = content_style_info["css"].to_a + background_style_info["css"].to_a
|
|
extra_js = content_style_info["js"].to_a + background_style_info["js"].to_a
|
|
template_path = content_style_info["template"]
|
|
template_info = content_style_info["info"]
|
|
custom_footer = seminar_template_setting.footer_info
|
|
if seminar_template_setting.seminar_banner_images.count != 0 || background_style_info["default_logo"]
|
|
banner_title = seminar.title
|
|
external_link = prefix_url + "/home"
|
|
images = []
|
|
if seminar_template_setting.seminar_banner_images.count == 0
|
|
images = [{
|
|
"image_link" => background_style_info["default_logo"],
|
|
"image_alt" => banner_title,
|
|
"title" => "",
|
|
"alt_title" => banner_title,
|
|
"class" => "active",
|
|
"height" => 0,
|
|
"width" => 0,
|
|
"caption" => '<div class="cycle-overlay"></div><div class="cycle-pager"></div>',
|
|
"context" => "",
|
|
"link" => external_link,
|
|
"target" => ""
|
|
}]
|
|
else
|
|
images = seminar_template_setting.seminar_banner_images.map.with_index do |image,i|
|
|
caption = (i == 0 ? '<div class="cycle-overlay"></div><div class="cycle-pager"></div>' : "")
|
|
klass = (i == 0 ? "active" : "")
|
|
alt_title = image.description
|
|
context = ""
|
|
image_link = image.file.url
|
|
{
|
|
"image_link" => image_link,
|
|
"image_alt" => alt_title,
|
|
"title" => "",
|
|
"alt_title" => alt_title,
|
|
"class" => klass,
|
|
"height" => 0,
|
|
"width" => 0,
|
|
"caption" => caption,
|
|
"context" => context,
|
|
"link" => external_link,
|
|
"target" => ""
|
|
}
|
|
end
|
|
end
|
|
custom_banner = {
|
|
"extras" => {
|
|
"ad_fx" => "fade",
|
|
"speed" => 500,
|
|
"title" => banner_title,
|
|
"banner-height" => 0,
|
|
"banner-width" => 0,
|
|
"base_image" => 0,
|
|
"timeout" => (5 * 1000),
|
|
"more" => "More"
|
|
},
|
|
"images" => images
|
|
}
|
|
else
|
|
custom_banner = nil
|
|
end
|
|
@@session = OrbitHelper.request.session
|
|
@@session[:seminar_main_id] = @seminar.id
|
|
if params[:method].present?
|
|
main_content = render_other_method
|
|
elsif params[:current_page_module] == "seminars_home"
|
|
seminar = SeminarMain.where(uid: params[:uid]).first
|
|
time_now = Time.now
|
|
data = {
|
|
"seminar" => seminar,
|
|
"time_now" => time_now
|
|
}
|
|
@_request = OrbitHelper.request
|
|
if template_info["main_content"]
|
|
main_content = render_other_method("show_data",template_info["main_content"])
|
|
else
|
|
main_content = render_to_string("seminars/custom_home",:locals=>{:seminar=>seminar,
|
|
:params=>params,:session=>OrbitHelper.request.session},:layout=>false)
|
|
end
|
|
elsif params[:current_page_module] == "seminars_page"
|
|
time_now = Time.now
|
|
params = OrbitHelper.params
|
|
seminar = SeminarMain.find_by(uid: params[:uid])
|
|
if !seminar.registration_status.blank? && seminar.signup_start_date <= time_now && ( seminar.signup_end_date.nil? || seminar.signup_end_date+1 >= time_now )
|
|
sign_up = ('<a href="'+ prefix_url + @registration_postfix + '" target="_blank">' + t('seminar.signup') + '</a>').html_safe
|
|
elsif seminar.registration_status.blank?
|
|
sign_up = t('seminar.sign_up_not_open')
|
|
elsif seminar.signup_start_date > time_now
|
|
sign_up = t('seminar.sign_up_not_yet')
|
|
else
|
|
sign_up = t('seminar.sign_up_overdue')
|
|
end
|
|
if !seminar.registration_status.blank? && seminar.registration_status.include?('C') && seminar.contribute_start_date <= time_now && ( seminar.contribute_end_date.nil? || seminar.contribute_end_date+1 >= time_now )
|
|
if !@@session[:seminar_signup_id].blank?
|
|
if @@session[:seminar_main_id] == seminar.id
|
|
contribute_action = ('<a href="'+ prefix_url + '?method=con_upload">' + t('seminar_signup.uploads') + '</a>').html_safe
|
|
else
|
|
contribute_action = ('<a href="'+ prefix_url + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
|
|
end
|
|
else
|
|
contribute_action = ('<a href="'+ prefix_url + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
|
|
end
|
|
end
|
|
data = {
|
|
'seminar' => seminar,
|
|
'sign_up' => sign_up,
|
|
'contribute_action' => contribute_action,
|
|
'time_now' => time_now,
|
|
'contribute_time_range' => SeminarMain.time_range(seminar.contribute_start_date, seminar.contribute_end_date),
|
|
'sign_up_time_range' => SeminarMain.time_range(seminar.signup_start_date, seminar.signup_end_date),
|
|
'seminar_time_range' => SeminarMain.time_range(seminar.seminar_start_date, seminar.seminar_end_date)
|
|
}
|
|
@_request = OrbitHelper.request
|
|
main_content = render_to_string("seminars/show_data",:locals=>{:action_data=>data,
|
|
:request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash,
|
|
:params=>params,:session=>OrbitHelper.request.session},:layout=>false)
|
|
else
|
|
main_content = render_other_method("render_"+params[:current_page_module]) rescue nil
|
|
end
|
|
custom_datapp_data = {}
|
|
if custom_banner
|
|
custom_banner["custom_widget_type"] = "module_widget"
|
|
custom_banner["custom_widget_module"] = "ad_banner"
|
|
if custom_banner["images"].count > 1
|
|
custom_banner["custom_widget_file"] = "ad_banner_widget1"
|
|
else
|
|
custom_banner["custom_widget_file"] = "ad_banner_widget4"
|
|
end
|
|
custom_datapp_data["300"] = [custom_banner]
|
|
end
|
|
return {
|
|
"extra_body_class" => "seminar_custom_page background_style_#{background_style} content_style_#{content_style}",
|
|
"main_content"=>main_content,
|
|
"extra_css"=>extra_css,
|
|
"extra_js"=>extra_js,
|
|
"header_data" => header_data,
|
|
"prefix_url" => prefix_url,
|
|
"template_path" => template_path,
|
|
"custom_datapp_data" => custom_datapp_data,
|
|
"custom_footer" => (custom_footer.blank? ? nil : custom_footer)
|
|
}
|
|
end
|
|
def render_seminar_registration
|
|
action_data = show
|
|
@_request = OrbitHelper.request
|
|
action_data["prefix_url"] = @prefix_url
|
|
render_to_string("seminars/show",:locals=>{:action_data=>action_data,
|
|
:request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash,
|
|
:params=>params,:session=>OrbitHelper.request.session},:layout=>false)
|
|
end
|
|
def render_seminar_registered_participants
|
|
action_data = {"seminar"=>@seminar, "seminar_template_setting"=>@seminar_template_setting}
|
|
@_request = OrbitHelper.request
|
|
action_data["prefix_url"] = @prefix_url
|
|
render_to_string("seminars/registered_participants",:locals=>{:action_data=>action_data,
|
|
:request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash,
|
|
:params=>params,:session=>OrbitHelper.request.session},:layout=>false)
|
|
end
|
|
def render_other_method(render_method=nil,render_template=nil)
|
|
params = OrbitHelper.params
|
|
if render_method && render_template.nil?
|
|
return eval(render_method)
|
|
end
|
|
render_method = render_method || params[:method]
|
|
render_template = render_template || render_method
|
|
params = OrbitHelper.params
|
|
action_data = eval(render_method)
|
|
@seminar_main_url = @prefix_url + '/home/introduction'
|
|
if action_data
|
|
if render_method == "con_upload" || render_method == "signup_ok"
|
|
action_data["prefix_url"] = @prefix_url + '/home/submission'
|
|
else
|
|
action_data["prefix_url"] = @prefix_url
|
|
end
|
|
end
|
|
@_request = OrbitHelper.request
|
|
render_to_string("seminars/#{render_template}",:locals=>{:action_data=>action_data,
|
|
:request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash,
|
|
:params=>params,:session=>OrbitHelper.request.session},:layout=>false).html_safe
|
|
end
|
|
def render_seminar_submission
|
|
if @@session[:seminar_signup_id]
|
|
action_data = con_upload
|
|
action_data["prefix_url"] = @prefix_url + '/home/submission'
|
|
@_request = OrbitHelper.request
|
|
render_to_string("seminars/con_upload",:locals=>{:action_data=>action_data,
|
|
:request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash,
|
|
:params=>params,:session=>@@session},:layout=>false).html_safe
|
|
else
|
|
action_data = con_login
|
|
@_request = OrbitHelper.request
|
|
render_to_string("seminars/con_login",:locals=>{:action_data=>action_data,
|
|
:request=>OrbitHelper.request,:flash=>OrbitHelper.request.flash,
|
|
:params=>params,:session=>@@session},:layout=>false).html_safe
|
|
end
|
|
end
|
|
def show_privacy
|
|
|
|
params = OrbitHelper.params
|
|
|
|
seminar = SeminarMain.where(uid: params[:uid]).first
|
|
|
|
seminar_agreement = SeminarAgreement.first
|
|
|
|
{
|
|
'seminar' => seminar,
|
|
"seminar_agreement" => seminar_agreement
|
|
}
|
|
|
|
end
|
|
|
|
def show_data
|
|
|
|
time_now = Time.now
|
|
|
|
params = OrbitHelper.params
|
|
|
|
seminar = SeminarMain.find_by(uid: params[:uid])
|
|
|
|
if !seminar.registration_status.blank? && seminar.signup_start_date <= time_now && ( seminar.signup_end_date.nil? || seminar.signup_end_date+1 >= time_now )
|
|
sign_up = ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + @registration_postfix.to_s + '" target="_blank">' + t('seminar.signup') + '</a>').html_safe
|
|
elsif seminar.registration_status.blank?
|
|
sign_up = t('seminar.sign_up_not_open')
|
|
elsif seminar.signup_start_date > time_now
|
|
sign_up = t('seminar.sign_up_not_yet')
|
|
else
|
|
sign_up = t('seminar.sign_up_overdue')
|
|
end
|
|
|
|
if !seminar.registration_status.blank? && seminar.registration_status.include?('C') && seminar.contribute_start_date <= time_now && ( seminar.contribute_end_date.nil? || seminar.contribute_end_date+1 >= time_now )
|
|
if !@@session[:seminar_signup_id].blank?
|
|
if @@session[:seminar_main_id] == seminar.id
|
|
contribute_action = ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=con_upload">' + t('seminar_signup.uploads') + '</a>').html_safe
|
|
else
|
|
contribute_action = ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
|
|
end
|
|
else
|
|
contribute_action = ('<a href="'+ OrbitHelper.url_to_show(seminar.to_param) + '?method=con_login">' + t('seminar_signup.con_login') + '</a>').html_safe
|
|
end
|
|
end
|
|
|
|
|
|
|
|
{
|
|
'seminar' => seminar,
|
|
'sign_up' => sign_up,
|
|
'contribute_action' => contribute_action,
|
|
'time_now' => time_now,
|
|
'contribute_time_range' => SeminarMain.time_range(seminar.contribute_start_date, seminar.contribute_end_date),
|
|
'sign_up_time_range' => SeminarMain.time_range(seminar.signup_start_date, seminar.signup_end_date),
|
|
'seminar_time_range' => SeminarMain.time_range(seminar.seminar_start_date, seminar.seminar_end_date)
|
|
}
|
|
|
|
end
|
|
|
|
def show
|
|
|
|
params = OrbitHelper.params
|
|
|
|
module_app = ModuleApp.where(:key => "seminar").first
|
|
|
|
categories = module_app.categories
|
|
|
|
seminar = SeminarMain.where(uid: params[:uid]).first
|
|
|
|
seminar_signup = SeminarSignup.new
|
|
|
|
time_now = Time.now
|
|
{
|
|
"seminar" => seminar,
|
|
"seminar_signup" => seminar_signup,
|
|
"time_now" => time_now
|
|
}
|
|
|
|
end
|
|
|
|
def check_email
|
|
|
|
params = OrbitHelper.params
|
|
|
|
if !params[:email].blank?
|
|
count = SeminarSignup.where(:email => params[:email], :seminar_main_id => params[:no]).count
|
|
|
|
result = count > 0 ? t('seminar.already_used') : t('seminar.available')
|
|
else
|
|
result = t('seminar.please_enter_email')
|
|
end
|
|
|
|
{
|
|
"result" => result
|
|
}
|
|
|
|
end
|
|
|
|
def check_availability
|
|
|
|
params = OrbitHelper.params
|
|
|
|
response = {}
|
|
case params[:type]
|
|
when "seminar_signup_email"
|
|
|
|
response["success"] = SeminarSignup.where(:email => params[:value], :seminar_main_id => params[:no]).count > 0 ? false : true
|
|
end
|
|
render :json => response.to_json
|
|
end
|
|
|
|
def create
|
|
|
|
@signup = SeminarSignup.where(email: params[:seminar_signup][:email], seminar_main_id: params[:seminar_signup][:seminar_main_id] ).first
|
|
|
|
@seminar_signup = SeminarSignup.new(seminar_signup_params)
|
|
@seminar = SeminarMain.where(id:params[:seminar_signup][:seminar_main_id]).first
|
|
if @seminar.seminar_signup_field_sets.count!=0
|
|
flag = @seminar.seminar_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled
|
|
else
|
|
flag = false
|
|
end
|
|
if gotcha_valid? || flag
|
|
if @signup.blank? && @seminar_signup.save
|
|
# if gotcha_valid? && @seminar_signup.save
|
|
|
|
if !params[:seminar_signup_values].nil?
|
|
seminar_signup_values_params.each_with_index do |r,i|
|
|
field_value = r.last[:id].present?
|
|
@custom_field_value = SeminarSignupValue.put_field_values(@seminar_signup, r.last, r.last[:seminar_signup_field_id], field_value)
|
|
end
|
|
seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a
|
|
seminar_reviews.each{|sr| sr.save}
|
|
@seminar = @seminar_signup.seminar_main
|
|
unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s}
|
|
unassigned_seminar_signup_ids.push(@seminar_signup.id.to_s)
|
|
seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar.id).to_a
|
|
seminar_reviews.each do |sr|
|
|
unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids
|
|
end
|
|
@seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s
|
|
@seminar.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s
|
|
@seminar.save
|
|
else
|
|
@seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s
|
|
@seminar.unassigned_mode_1_seminar_signup_ids << @seminar_signup.id.to_s
|
|
@seminar.save
|
|
end
|
|
extra_text = "<br>#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.display_serial_number}"
|
|
extra_text += render_to_string("seminars/signup_email_contents",:locals=>{:seminar=>@seminar,
|
|
:seminar_signup=>@seminar_signup},:layout=>false)
|
|
if params['seminar_signup']['status']=='C'
|
|
status_param = '&status='
|
|
send_mail('submission',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text)
|
|
else
|
|
status_param = ''
|
|
send_mail('signup',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id],extra_text)
|
|
end
|
|
redirect_to "#{params[:referer_url]}/?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.display_serial_number}"
|
|
else
|
|
if !@signup.blank?
|
|
redirect_to "#{params[:referer_url]}", :notice => 'mail已存在'
|
|
else
|
|
referer_url = params[:referer_url].to_s
|
|
if referer_url.split("/").last.include?("?")
|
|
uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'')
|
|
if uri_query == ""
|
|
referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}"
|
|
else
|
|
referer_url = referer_url.split("?")[0...-1].join("?") + "¬ice=#{t('recaptcha.errors.verification_failed')}"
|
|
end
|
|
else
|
|
referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}"
|
|
end
|
|
redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed')
|
|
end
|
|
end
|
|
else
|
|
referer_url = params[:referer_url].to_s
|
|
if referer_url.split("/").last.include?("?")
|
|
uri_query = referer_url.split("?").last.gsub(/notice=[^&]*/,'')
|
|
if uri_query == ""
|
|
referer_url = referer_url.split("?")[0...-1].join("?") + "?notice=#{t('recaptcha.errors.verification_failed')}"
|
|
else
|
|
referer_url = referer_url.split("?")[0...-1].join("?") + "¬ice=#{t('recaptcha.errors.verification_failed')}"
|
|
end
|
|
else
|
|
referer_url = referer_url + "?notice=#{t('recaptcha.errors.verification_failed')}"
|
|
end
|
|
redirect_to referer_url, :notice => t('recaptcha.errors.verification_failed')
|
|
end
|
|
|
|
end
|
|
|
|
def signup_ok
|
|
params = OrbitHelper.params
|
|
{"serial_number"=> params[:serial_number]}
|
|
end
|
|
|
|
def add_file_proc
|
|
|
|
update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values'])
|
|
flag = true
|
|
update_params.permit!
|
|
if !update_params['seminar_submission_values'].nil?
|
|
if update_params['seminar_submission_values']['0']['value'].class==String
|
|
value = update_params['seminar_submission_values']['0']['value']
|
|
if !value.to_s.blank?
|
|
flag = false
|
|
end
|
|
else
|
|
update_params['seminar_submission_values']['0']['value'].each do |key,value|
|
|
if !value.to_s.blank?
|
|
flag = false
|
|
end
|
|
end
|
|
end
|
|
else
|
|
flag = false
|
|
end
|
|
if flag
|
|
update_params['seminar_submission_values']['0']['value']['en'] = ' '
|
|
end
|
|
@con = SeminarSignupContribute.new(update_params)
|
|
if @con.save
|
|
signup = SeminarSignup.where(id:update_params['seminar_signup_id']).first
|
|
seminar_id = signup.seminar_main_id
|
|
@seminar = SeminarMain.where(id:seminar_id).first
|
|
send_mail('add_file',signup.email,seminar_id)
|
|
seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a
|
|
seminar_reviews.each{|sr| sr.save}
|
|
@seminar = signup.seminar_main
|
|
unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s}
|
|
@seminar.seminar_reviews.each do |sr|
|
|
unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids
|
|
end
|
|
@seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids
|
|
@seminar.save
|
|
redirect_to "#{params[:referer_url]}/?method=con_upload"
|
|
else
|
|
redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed')
|
|
end
|
|
|
|
end
|
|
|
|
def update
|
|
@con = SeminarSignupContribute.find(params[:seminar_signup_contribute][:id])
|
|
update_params = seminar_signup_contribute_params.merge('seminar_submission_values'=>params['seminar_submission_values'])
|
|
flag = true
|
|
update_params.permit!
|
|
if update_params['seminar_submission_values']['0']['value'].class==String
|
|
value = update_params['seminar_submission_values']['0']['value']
|
|
if !value.to_s.blank?
|
|
flag = false
|
|
end
|
|
else
|
|
update_params['seminar_submission_values']['0']['value'].each do |key,value|
|
|
if !value.to_s.blank?
|
|
flag = false
|
|
end
|
|
end
|
|
end
|
|
|
|
if flag
|
|
update_params['seminar_submission_values']['0']['value']['en'] = ' '
|
|
end
|
|
@con.update_attributes(update_params)
|
|
if @con.save
|
|
signup = SeminarSignup.where(id:update_params['seminar_signup_id']).first
|
|
seminar_id = signup.seminar_main_id
|
|
@seminar = SeminarMain.where(id:seminar_id).first
|
|
send_mail('edit_file',signup.email,seminar_id)
|
|
seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a
|
|
seminar_reviews.each{|sr| sr.save}
|
|
@seminar = signup.seminar_main
|
|
unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s}
|
|
@seminar.seminar_reviews.each do |sr|
|
|
unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids
|
|
end
|
|
@seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids
|
|
@seminar.save
|
|
redirect_to "#{params[:referer_url]}/?method=con_upload"
|
|
else
|
|
redirect_to "#{params[:referer_url]}", :notice => t('recaptcha.errors.verification_failed')
|
|
end
|
|
|
|
end
|
|
|
|
def del_file
|
|
|
|
con = SeminarSignupContribute.find(params[:con_no])
|
|
|
|
# seminar_signup = SeminarSignup.find_by(_id: con.seminar_signup_id )
|
|
# seminar = SeminarMain.find_by(_id: seminar_signup.seminar_main_id )
|
|
signup = con.seminar_signup
|
|
con.destroy
|
|
|
|
seminar_reviews = SeminarReview.where(:seminar_main_id=>signup.seminar_main_id).to_a
|
|
seminar_reviews.each{|sr| sr.save}
|
|
@seminar = SeminarMain.find(signup.seminar_main_id)
|
|
unassigned_seminar_signup_ids = @seminar.seminar_signup_ids.map{|s| s.to_s}
|
|
@seminar.seminar_reviews.each do |sr|
|
|
unassigned_seminar_signup_ids = unassigned_seminar_signup_ids - sr.all_seminar_signup_ids
|
|
end
|
|
@seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids
|
|
@seminar.save
|
|
redirect_to "#{params[:referer_url]}/?method=con_upload"
|
|
|
|
end
|
|
|
|
def add_file
|
|
|
|
if !@@session[:seminar_main_id].blank?
|
|
|
|
seminar = SeminarMain.find_by(id: @@session[:seminar_main_id])
|
|
seminar_signup = SeminarSignup.find_by(_id: @@session[:seminar_signup_id], seminar_main_id: @@session[:seminar_main_id] )
|
|
|
|
else
|
|
|
|
seminar = {}
|
|
seminar_signup = {}
|
|
|
|
end
|
|
|
|
con = SeminarSignupContribute.new
|
|
|
|
{
|
|
'con' => con,
|
|
'seminar' => seminar,
|
|
'seminar_signup' => seminar_signup
|
|
}
|
|
|
|
end
|
|
|
|
def edit_file
|
|
|
|
params = OrbitHelper.params
|
|
if !@@session[:seminar_main_id].blank?
|
|
seminar = SeminarMain.find_by(id: @@session[:seminar_main_id])
|
|
seminar_signup = SeminarSignup.find_by(_id: @@session[:seminar_signup_id], seminar_main_id: @@session[:seminar_main_id] )
|
|
else
|
|
seminar = {}
|
|
seminar_signup = {}
|
|
end
|
|
con = SeminarSignupContribute.find(params[:con_no])
|
|
{
|
|
'con' => con,
|
|
'seminar' => seminar,
|
|
'seminar_signup' => seminar_signup
|
|
}
|
|
|
|
end
|
|
|
|
def con_upload
|
|
|
|
time_now = Time.now
|
|
|
|
if !@@session[:seminar_main_id].blank?
|
|
|
|
seminar = SeminarMain.find_by(id: @@session[:seminar_main_id])
|
|
|
|
seminar_signup = SeminarSignup.find_by(_id: @@session[:seminar_signup_id], seminar_main_id: @@session[:seminar_main_id] ) rescue nil
|
|
|
|
else
|
|
|
|
seminar = {}
|
|
seminar_signup = {}
|
|
|
|
end
|
|
|
|
{
|
|
'time_now' => time_now,
|
|
'seminar' => seminar,
|
|
'seminar_signup' => seminar_signup
|
|
}
|
|
|
|
end
|
|
|
|
def con_logout
|
|
|
|
# redirect_to page_for_seminar_url
|
|
|
|
end
|
|
|
|
def con_login
|
|
|
|
time_now = Time.now
|
|
|
|
params = OrbitHelper.params
|
|
|
|
seminar = SeminarMain.find_by(uid: params[:uid])
|
|
|
|
{
|
|
'seminar' => seminar,
|
|
'time_now' => time_now
|
|
}
|
|
|
|
end
|
|
|
|
def con_login_proc
|
|
|
|
seminar = SeminarMain.find_by(id: params[:seminar_signup][:seminar_main_id])
|
|
|
|
@seminar_signup = SeminarSignup.where(:status=>'C', :email=> params[:user_name], :password => params[:password], :seminar_main_id => params[:seminar_signup][:seminar_main_id]).first
|
|
|
|
if !@seminar_signup.blank?
|
|
|
|
session[:seminar_signup_id] = @seminar_signup.id
|
|
session[:seminar_main_id] = @seminar_signup.seminar_main_id
|
|
|
|
redirect_to "#{params[:referer_url]}/?method=con_upload"
|
|
else
|
|
redirect_to "#{params[:referer_url]}/?method=con_login", :notice => '登入失敗'
|
|
end
|
|
|
|
end
|
|
|
|
def seminar_signup_params
|
|
params.require(:seminar_signup).permit!
|
|
end
|
|
|
|
def seminar_signup_contribute_params
|
|
params.require(:seminar_signup_contribute).permit!
|
|
end
|
|
|
|
def seminar_signup_values_params
|
|
params.require(:seminar_signup_values).permit!
|
|
end
|
|
def send_mail(field_name,email,seminar_id,extra_text="")
|
|
email_set = @seminar.seminar_email_sets.select{|v| v.field_name == field_name}
|
|
if email_set.length==0
|
|
mail = Email.create(mail_to:[email],
|
|
module_app_key:"seminar",
|
|
template:"email/#{field_name}_email.html.erb",
|
|
mail_sentdate:Time.current,
|
|
mail_subject: t("seminar.email_#{field_name}_success"),
|
|
template_data:{'seminar_id'=>seminar_id,'locale'=>I18n.locale,'extra_text'=> extra_text})
|
|
elsif !(email_set[0].disabled)
|
|
mail = Email.create(mail_to:[email],
|
|
module_app_key:"seminar",
|
|
template:"email/#{field_name}_email.html.erb",
|
|
mail_sentdate:Time.current,
|
|
mail_subject: email_set[0].title[I18n.locale],
|
|
template_data:{'seminar_id'=>seminar_id,'locale'=>I18n.locale,'extra_text'=> extra_text})
|
|
end
|
|
begin
|
|
mail.deliver
|
|
rescue => e
|
|
puts ["email can't deliver",e]
|
|
end
|
|
end
|
|
end
|