diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb
index 3f68848..628c987 100644
--- a/app/controllers/seminars_controller.rb
+++ b/app/controllers/seminars_controller.rb
@@ -3,7 +3,7 @@ class SeminarsController < ApplicationController
include MemberHelper
include ActionView::Context #vary important (only add this can access @@session from view)
include Admin::SeminarsHelper
- FrontendMethods = ["show_privacy", "show_data", "check_email", "check_availability", "signup_ok", "add_file", "edit_file", "con_login", "con_upload", "con_logout","confirm_email_page","reset_password_page"]
+ FrontendMethods = ["show_privacy", "show_data", "check_email", "check_availability", "signup_ok", "add_file", "edit_file", "con_login", "con_upload", "con_logout","confirm_email_page","reset_password_page","edit_login_seminar_signup"]
# include SimpleCaptcha::ControllerHelpers
def index
@@ -520,6 +520,29 @@ class SeminarsController < ApplicationController
end
+ def update_signup_form
+ params = OrbitHelper.params
+ @seminar_signup = SeminarSignup.find(params[:signup_id])
+ @seminar_signup.update_attributes(seminar_signup_params)
+
+ if !params[:seminar_signup_values].nil?
+ params[:seminar_signup_values].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[:id], field_value)
+ end
+ seminar_reviews = SeminarReview.where(:seminar_main_id=>@seminar_signup.seminar_main_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}
+ @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
+ end
+ redirect_to "#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=con_upload"
+ end
+
def signup_ok
params = OrbitHelper.params
msg = SeminarMain.where(:uid => params[:seminar]).first.signup_success
@@ -706,6 +729,16 @@ class SeminarsController < ApplicationController
seminar_signup = SeminarSignup.find_by(_id: @@session[:seminar_signup_id], seminar_main_id: @@session[:seminar_main_id] ) rescue nil
+ show = true
+ seminar.seminar_submission_field_sets.each do |ssf|
+ if ssf.disabled && ssf.hidden
+ show = false
+ else
+ show = true
+ break
+ end
+ end
+
else
seminar = {}
@@ -716,11 +749,32 @@ class SeminarsController < ApplicationController
{
'time_now' => time_now,
'seminar' => seminar,
- 'seminar_signup' => seminar_signup
+ 'seminar_signup' => seminar_signup,
+ "show" => show
}
end
+ def edit_login_seminar_signup
+ 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
+ module_app = ModuleApp.where(:key => "seminar").first
+
+ categories = module_app.categories
+
+ time_now = Time.now
+ {
+ "seminar" => seminar,
+ "seminar_signup" => seminar_signup,
+ "time_now" => time_now
+ }
+ end
+
def con_logout
# redirect_to page_for_seminar_url
@@ -770,6 +824,7 @@ class SeminarsController < ApplicationController
if(!signup.nil?)
signup.token = nil
signup.is_confirmed = true
+ signup.is_confirmed_date = DateTime.now
signup.save
confirm = true
end
@@ -845,8 +900,11 @@ class SeminarsController < ApplicationController
extra_text += "
#{t("seminar.click_here_to_confirm")}"
end
send_mail(params[:type], seminar_signup.email, @seminar.id.to_s, extra_text)
+ seminar_signup.emails_sent << params[:type]
+ seminar_signup.save
end
render :json => {
+ "type" => t("seminar.#{params[:type]}"),
"success" => true
}.to_json
end
diff --git a/app/helpers/admin/seminars_field_helper.rb b/app/helpers/admin/seminars_field_helper.rb
index 21ffe5c..942df54 100644
--- a/app/helpers/admin/seminars_field_helper.rb
+++ b/app/helpers/admin/seminars_field_helper.rb
@@ -50,14 +50,14 @@ module Admin::SeminarsFieldHelper
def render_checkbox
@prefiled_value ||=[]
- control_group_wrapper_for_sm do
+ control_group_wrapper_for_sm do
a = self.typeE[:option_list].collect do |key,value|
label_tag("#{get_basic_field_name_org}_#{self.id}_#{key}",check_box_tag(get_field_name_base+"[#{key}]", true , (@prefiled_value.include?(key) ? true : false), { :id=>"#{get_basic_field_name_org}_#{self.id}_#{key}"})+value[I18n.locale.to_s],@markup_options.merge(:class=>"checkbox inline"))
end.join.html_safe rescue ""
end
end
- def render_date
+ def render_date
d = DateTime.now()
if date_is_range?
@@ -81,13 +81,13 @@ module Admin::SeminarsFieldHelper
when 'format3'
fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y/%m")
fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y/%m/")
- buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM')
+ buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy/MM')
buf << ' ~ '
buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy/MM')
when 'format4'
fill_from = (@prefiled_value && @prefiled_value["from"] ) ? @prefiled_value["from"] : d.strftime("%Y")
fill_to = (@prefiled_value && @prefiled_value["to"] ) ? @prefiled_value["to"] : d.strftime("%Y")
- buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy')
+ buf = datetime_picker(get_field_name_base+'[from]', fill_from, 'yyyy')
buf << ' ~ '
buf << datetime_picker(get_field_name_base+'[to]', fill_to, 'yyyy')
end
@@ -107,13 +107,13 @@ module Admin::SeminarsFieldHelper
when 'format2'
tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m/%d")), 'yyyy/MM/dd')
when 'format3'
- tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m")), 'yyyy/MM')
+ tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y/%m")), 'yyyy/MM')
when 'format4'
- tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y")), 'yyyy')
+ tmp = datetime_picker(get_field_name_base, (@prefiled_value ? @prefiled_value : d.strftime("%Y")), 'yyyy')
end
-
- control_group_wrapper_for_sm{tmp}
- # control_group_wrapper_for_sm{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
+
+ control_group_wrapper_for_sm{tmp}
+ # control_group_wrapper_for_sm{date_select(get_field_name_base,nil,@markup_options.merge(:default=>@prefiled_value),:class=>"input-small")}
end
end
@@ -131,7 +131,7 @@ module Admin::SeminarsFieldHelper
end
def render_date_durnation #Need re-write low priority
-
+
end
def render_radio_button
@@ -179,7 +179,7 @@ module Admin::SeminarsFieldHelper
place_holder= typeA["placeholder"][key_field] rescue ''
name1 = can_muti_lang_input_for_sm? ? ([get_field_name_base,add_more_blank,"[#{key_field}]"].join) : ([get_field_name_base,add_more_blank].join)
text_field_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control'))
- end
+ end
end
def render_file_field
@@ -192,16 +192,16 @@ module Admin::SeminarsFieldHelper
#{I18n.t('file.upload')}
#{value}".html_safe
- end
+ end
end
def date_is_range?
is_range = "false"
data = get_data
if !data.nil?
- is_range = data['is_range'] if data.has_key? "is_range"
+ is_range = data['is_range'] if data.has_key? "is_range"
end
- is_range == "true"
+ is_range == "true"
end
protected
@@ -239,7 +239,7 @@ protected
div_class << (key == I18n.locale ? " active in" : '')
content_tag(:div,yield(key,value), :id=>div_id,:class=>div_class)
end# of VALID_LOCALES.collect for tabed input
- tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
+ tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
buff2 = valid_locales.each.collect do |key|
# link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}"
if @show_set_field_for_sm && @markup=='text_area'
@@ -262,7 +262,7 @@ protected
else
# tmp = content_tag :div,:class=> (add_more || self.markup=='address') ? "input-append" : "tab-content" do
- tmp1 =
+ tmp1 =
content_tag :div,:class=> "tab-content" do
buff = valid_locales.collect do |key|
@@ -289,7 +289,7 @@ protected
end
- tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
+ tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
buff2 = valid_locales.each.collect do |key|
# link_entry = self.add_more ? "#{add_more_tab(:tab_btn,loop_counter,key)}" : "#tab"+id.to_s+"_#{key}"
link_entry_ary = ["##{get_pairing_tab_class({})}","_#{key}"]
@@ -304,7 +304,7 @@ protected
end # of content ul
-
+
tmp = content_tag :div,:class=> "input-append" do
tmp1 << tmp2
end
@@ -319,8 +319,8 @@ protected
add_more_counter = ""
if can_add_more
- add_more_counter = add_more_params[0][:counter]
- add_more_value = add_more_params[0][:value]
+ add_more_counter = add_more_params[0][:counter]
+ add_more_value = add_more_params[0][:value]
end
if can_muti_lang_input_for_sm?
@@ -330,7 +330,7 @@ protected
else #cross lang field
case can_add_more
when true
- value = add_more_params[0][:value]
+ value = add_more_params[0][:value]
result << content_tag(:div,:class=>"input-append"){yield(nil,value) + link_to((content_tag :i,'',:class=>'icon-trash'),"#",:class=>"btn remove-input") }
# result << add_more_unt
else
@@ -346,7 +346,7 @@ protected
end # of def controls_wrapper_for_sm(&block)
- def control_group_wrapper_for_sm(&block)
+ def control_group_wrapper_for_sm(&block)
div_class = can_muti_lang_input_for_sm? ? "col-sm-10 controls" : "col-sm-10 controls"
# div_class = can_muti_lang_input_for_sm? ? "control-group language-swich" : "control-group"
result = ""
@@ -357,7 +357,7 @@ protected
if can_add_more
- multipleInputs =
+ multipleInputs =
content_tag(:div,:class=>"add-target") do
@attribute_value.add_more_counter.times.collect do |t|
controls_wrapper_for_sm(:value=>(@prefiled_value[t] rescue nil),:counter=>t,&block)
@@ -366,8 +366,8 @@ protected
temp = content_tag(:div, multipleInputs + add_more_unt, :class=>'add-input')
-
- result = form_label + content_tag(:div,temp,:class=>div_class)
+
+ result = form_label + content_tag(:div,temp,:class=>div_class)
# result = label + multipleInputs + add_more_unt
# result = label + 一堆的輸入框(要用 multipleInput editMore 包起來) + add_more btn + hidden_fields
@@ -393,7 +393,7 @@ protected
end
- def add_more_unt
+ def add_more_unt
temp_field_name = get_basic_field_name_base + '[temp]'
add_more = content_tag :p,:class=> 'add-btn' do
content = link_to (content_tag :i,I18n.t(:add),:class=>"icon-plus"),"#","data-roles"=>"role_a",:class=>"trigger #{can_muti_lang_input_for_sm? ? 'textLengInput' : 'textInput' } btn btn-small btn-primary"
@@ -432,7 +432,7 @@ protected
prefix = opts[:prefix]
suffix = opts[:suffix]
str = get_basic_field_name_base.gsub("[","_").gsub("]",'')
- str = prefix.nil? ? str : prefix+ str
+ str = prefix.nil? ? str : prefix+ str
suffix.nil? ? str : str + suffix
end
@@ -454,7 +454,8 @@ protected
def form_label
if self.markup == "text_area"
- plc = typeD["placeholder"][I18n.locale].to_s.blank? ? nil : "(#{typeD["placeholder"][I18n.locale]})"
+ # plc = typeD["placeholder"][I18n.locale].to_s.blank? ? nil : "(#{typeD["placeholder"][I18n.locale]})"
+ plc = nil
label_tag(key, '' , :class=>"col-sm-2 control-label muted") do
concat (!@require.blank? ? '*'+title : title)
if plc
@@ -471,7 +472,7 @@ protected
if self.markup == "address"
return true
else
- $seminar_list[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true")
+ $seminar_list[:markups][markup]["muti_lang_input_supprt"] and !(get_data["cross_lang"] == "true")
end
end
@@ -538,7 +539,7 @@ protected
if markup=='text_field'
if key_field == 'seminar_email_sets'
inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value,:class=>'input-medium form-control')
- else
+ else
inside = text_field_tag([get_field_name_base,"[#{key}]"].join,value)
end
else
@@ -552,4 +553,4 @@ protected
@show_set_field_for_sm = nil
return a.html_safe
end
-end
\ No newline at end of file
+end
diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb
index 7e8c060..7df930c 100644
--- a/app/models/seminar_signup.rb
+++ b/app/models/seminar_signup.rb
@@ -11,6 +11,9 @@ class SeminarSignup
field :token
field :is_confirmed, type: Boolean, default: false # for email confirmation
field :signup_confirmed, type: Boolean, default: false
+ field :is_confirmed_date, type: DateTime
+ field :signup_confirmed_date, type: DateTime
+ field :emails_sent, type: Array, default: []
field :name # become Last Name for TICC
field :tel, type: String # become First Name for TICC
field :unit, localize: true #Only localize for preserving old record
@@ -54,9 +57,10 @@ class SeminarSignup
[l, (tmp ? tmp : unit)]
end.to_h
if self.serial_number.nil?
- last_serial_number = SeminarMain.where(:id=>self.seminar_main_id).max(:last_serial_number).to_i
- self.serial_number = last_serial_number + 1
- SeminarMain.where(:id=>self.seminar_main_id).update_all({"$inc"=>{"last_serial_number"=>1}})
+ # last_serial_number = SeminarMain.where(:id=>self.seminar_main_id).max(:last_serial_number).to_i
+ # self.serial_number = last_serial_number + 1
+ # SeminarMain.where(:id=>self.seminar_main_id).update_all({"$inc"=>{"last_serial_number"=>1}})
+ self.serial_number = DateTime.now.to_i
end
self.token = SecureRandom.hex(5)
end
diff --git a/app/models/seminar_signup_field.rb b/app/models/seminar_signup_field.rb
index 2025454..1cbd39e 100644
--- a/app/models/seminar_signup_field.rb
+++ b/app/models/seminar_signup_field.rb
@@ -15,9 +15,9 @@ class SeminarSignupField
field :built_in, type: Boolean, default: false
field :disabled, type: Boolean, default: false
# field :to_delete, type: Boolean, default: false
-
+
field :to_require,type: Boolean, default: true
-
+
field :typeA, type: Hash, default: {cross_lang: false}
field :typeB, type: Hash, default: {}
field :typeC, type: Hash, default: {calendar: "west_calendar", format: "format3"}
@@ -57,8 +57,8 @@ class SeminarSignupField
def option_list
if self_defined_markup_options?
- #Class need to have corresponding field and value agent
- # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function
+ #Class need to have corresponding field and value agent
+ # Ex: For "status" the class must have field called "statuses" for the relation and "statuses_for_select" for the select function
method = self.seminar.method(self[:key].pluralize+"_for_"+markup)
return (method.call rescue {})
elsif self[:option_list].nil? || (self[:option_list].empty?)
@@ -103,7 +103,7 @@ class SeminarSignupField
def is_built_in?
self.built_in
end
-
+
def is_disabled?
self.disabled
end
@@ -131,7 +131,7 @@ class SeminarSignupField
if self[field]["cross_lang"] != var["cross_lang"]
case var["cross_lang"]
when "true" #from no-add_more to add_more
- cross_lang_convert(:to_cross_lang)
+ cross_lang_convert(:to_cross_lang)
else #from add_more to no-add_more
cross_lang_convert(:to_no_cross_lang)
end # of case
@@ -142,23 +142,23 @@ class SeminarSignupField
if self["typeA"]["add_more"] != var["add_more"]
case var["add_more"]
when "true" #from no-add_more to add_more
- add_more_convert(:to_add_more)
+ add_more_convert(:to_add_more)
else #from add_more to no-add_more
add_more_convert(:to_no_add_more)
end # of case
end # of if
end
- def cross_lang_convert(opt)
-
+ def cross_lang_convert(opt)
+
end
def check_option_list
self[:option_list] = self[panel]["option_list"] rescue nil
end
- def add_more_convert(opt)
+ def add_more_convert(opt)
end
-end
\ No newline at end of file
+end
diff --git a/app/views/admin/seminar_signups/edit.html.erb b/app/views/admin/seminar_signups/edit.html.erb
index 1928537..bc5f1c0 100644
--- a/app/views/admin/seminar_signups/edit.html.erb
+++ b/app/views/admin/seminar_signups/edit.html.erb
@@ -1,4 +1,4 @@
-<%= form_for @seminar_signup, url: admin_seminar_signup_path(@seminar_signup), html: {class: "form-horizontal main-forms"} do |f| %>
+<%= form_for @seminar_signup, url: admin_seminar_signup_path(@seminar_signup), html: {class: "form-horizontal main-forms", multipart: true} do |f| %>