diff --git a/app/controllers/admin/seminars_controller.rb b/app/controllers/admin/seminars_controller.rb
index b994219..096c632 100644
--- a/app/controllers/admin/seminars_controller.rb
+++ b/app/controllers/admin/seminars_controller.rb
@@ -113,7 +113,7 @@ class Admin::SeminarsController < OrbitAdminController
@seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>"enquiry_for_applicants")
end
if params[:name].present?
- @seminar_signups = SeminarSignup.where(:name => /#{params[:name]}/).page(params[:page]).per(10)
+ @seminar_signups = SeminarSignup.where(:name => /#{params[:name]}/).sort_ordered.page(params[:page]).per(10)
else
@seminar_signups = []
end
@@ -126,7 +126,7 @@ class Admin::SeminarsController < OrbitAdminController
ids2 = SeminarSignup.where(:seminar_main_id.in=> SeminarMain.where(:organizer_id=>current_user.member_profile_id).pluck(:id)).pluck(:id)
- @seminar_signups = @seminar_signups.where(:id.in=>all_seminar_signup_ids + ids2).page(params[:page]).per(10)
+ @seminar_signups = @seminar_signups.where(:id.in=>all_seminar_signup_ids + ids2).sort_ordered.page(params[:page]).per(10)
end
end
end
@@ -388,7 +388,11 @@ class Admin::SeminarsController < OrbitAdminController
def seminar_signup
@seminar_signups = []
if params[:type] == "table"
- @seminar_signups = @seminar.seminar_signups.where(:name=>/#{params[:search]}/)
+ 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
else
@seminar_signups = SeminarSignup.where(:id.in => @seminar.unassigned_seminar_signup_ids, :name=>/#{params[:search]}/)
end
@@ -405,7 +409,7 @@ class Admin::SeminarsController < OrbitAdminController
@seminar_review = @seminar.seminar_reviews.where(:reviewer_id => current_user.member_profile_id.to_s).first
@seminar_signups = @seminar.seminar_signups.where(:id.in=>@seminar_review.all_seminar_signup_ids)
end
- @seminar_signups = @seminar_signups.page(params[:page]).per(10)
+ @seminar_signups = @seminar_signups.sort_ordered.page(params[:page]).per(10)
if request.xhr?
render :layout => false
end
diff --git a/app/controllers/seminars_controller.rb b/app/controllers/seminars_controller.rb
index 3143012..af34445 100644
--- a/app/controllers/seminars_controller.rb
+++ b/app/controllers/seminars_controller.rb
@@ -163,14 +163,15 @@ class SeminarsController < ApplicationController
@seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s
@seminar.save
end
+ extra_text = "
#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.serial_number}"
if params['seminar_signup']['status']=='C'
status_param = '&status='
- send_mail('submission',params[:seminar_signup][:email],params[:seminar_signup][:seminar_main_id])
+ 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])
+ 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}"
+ redirect_to "#{params[:referer_url]}/?method=signup_ok#{status_param}&serial_number=#{@seminar_signup.serial_number}"
else
if !@signup.blank?
redirect_to "#{params[:referer_url]}", :notice => 'mail已存在'
@@ -185,6 +186,8 @@ class SeminarsController < ApplicationController
end
def signup_ok
+ params = OrbitHelper.params
+ {"serial_number"=> params[:serial_number]}
end
def add_file_proc
@@ -416,7 +419,7 @@ class SeminarsController < ApplicationController
def seminar_signup_values_params
params.require(:seminar_signup_values).permit!
end
- def send_mail(field_name,email,seminar_id)
+ 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],
@@ -424,14 +427,14 @@ class SeminarsController < ApplicationController
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})
+ 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})
+ template_data:{'seminar_id'=>seminar_id,'locale'=>I18n.locale,'extra_text'=> extra_text})
end
begin
mail.deliver
diff --git a/app/helpers/admin/seminars_helper.rb b/app/helpers/admin/seminars_helper.rb
index bf3c72e..15f3dfd 100644
--- a/app/helpers/admin/seminars_helper.rb
+++ b/app/helpers/admin/seminars_helper.rb
@@ -1,4 +1,7 @@
module Admin::SeminarsHelper
+ def display_format_string(num, str_length)
+ return format("%0#{str_length}d", num % (10^str_length))
+ end
def page_for_seminar(seminar)
ann_page = nil
pages = Page.where(:module=>'seminar')
diff --git a/app/models/seminar_main.rb b/app/models/seminar_main.rb
index cf7d3f2..b1488c6 100644
--- a/app/models/seminar_main.rb
+++ b/app/models/seminar_main.rb
@@ -39,6 +39,7 @@ class SeminarMain
field :unassigned_seminar_signup_ids
field :review_start_date, :type => Date
field :review_end_date, :type => Date
+ field :last_serial_number, :type => Integer, :default => 0
belongs_to :seminar_item
belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id
has_many :seminar_links, :autosave => true, :dependent => :destroy
@@ -139,6 +140,16 @@ class SeminarMain
self.unassigned_seminar_signup_ids = self.seminar_signup_ids.map{|s| s.to_s}
save_flag = true
end
+ unless self.last_serial_number_changed_from_default?
+ self.seminar_signups.sort_ordered.each do |ss|
+ if ss.serial_number.nil?
+ self.last_serial_number += 1
+ ss.serial_number = self.last_serial_number
+ ss.save(:validate=>false)
+ save_flag = true
+ end
+ end
+ end
self.save if save_flag
end
end
diff --git a/app/models/seminar_signup.rb b/app/models/seminar_signup.rb
index baa912e..fd91db6 100644
--- a/app/models/seminar_signup.rb
+++ b/app/models/seminar_signup.rb
@@ -14,6 +14,7 @@ class SeminarSignup
field :address, localize: true
field :password
field :note, localize: true
+ field :serial_number
belongs_to :seminar_main
@@ -22,9 +23,15 @@ class SeminarSignup
accepts_nested_attributes_for :seminar_signup_values, allow_destroy: true
accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true
+ scope :sort_ordered, ->{ order_by(:created_at=>1) }
+
before_create do
unit = self.unit_translations.values.select{|v| v.present?}.first
self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h
+ s = SeminarMain.find(self.seminar_main)
+ s.last_serial_number += 1
+ self.serial_number = s.last_serial_number
+ s.save(:validate=>false)
end
after_destroy do
seminar_main = self.seminar_main
@@ -42,5 +49,10 @@ class SeminarSignup
seminar_main.save
end
end
-
+ def display_serial_number
+ display_format_string(self.serial_number,4)
+ end
+ def display_format_string(num, str_length)
+ return format("%0#{str_length}d", num)
+ end
end
diff --git a/app/views/admin/seminars/_get_display_fields.html.erb b/app/views/admin/seminars/_get_display_fields.html.erb
index 5114ca2..f66e307 100644
--- a/app/views/admin/seminars/_get_display_fields.html.erb
+++ b/app/views/admin/seminars/_get_display_fields.html.erb
@@ -1,6 +1,13 @@
<% @field_names = [] %>
<% @field_name_translations = [] %>
<% default_hidden = [] %>
+<%
+ default_seminar_signup_fields = ["serial_number"]
+ default_seminar_signup_fields.each do |f|
+ @field_names << "seminar_signup.#{f}"
+ @field_name_translations << t("seminar_signup.#{f}")
+ end
+%>
<% if @seminar.present? %>
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% @seminar.seminar_signup_field_sets.each do |field_set| %>
diff --git a/app/views/admin/seminars/_seminar_signup_dashboard.html.erb b/app/views/admin/seminars/_seminar_signup_dashboard.html.erb
index 2f97dee..8da13bd 100644
--- a/app/views/admin/seminars/_seminar_signup_dashboard.html.erb
+++ b/app/views/admin/seminars/_seminar_signup_dashboard.html.erb
@@ -17,7 +17,7 @@