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 @@
<%= MemberProfile.find(reviewer_id).name rescue "" %>
- - <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.all_seminar_signup_ids) %> + <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.all_seminar_signup_ids).sort_ordered %> <% @seminar_signups = @seminar_signups.page(params["page_no#{count}"]).per(5) %> <% @seminar_signups = @seminar_signups.page(0) if @seminar_signups.to_a.count == 0 %> <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups,:@drag => true,:@include_blank=>true,:@reviewer_id=>seminar_review.id.to_s} %> @@ -43,6 +43,7 @@ %>
+
<%= t('seminar.submitter_without_reviewer') %>
<%= render :partial => "seminar_signup_render_table" %>
<%= diff --git a/app/views/admin/seminars/_seminar_signup_render_table.html.erb b/app/views/admin/seminars/_seminar_signup_render_table.html.erb index 7de0537..86051c5 100644 --- a/app/views/admin/seminars/_seminar_signup_render_table.html.erb +++ b/app/views/admin/seminars/_seminar_signup_render_table.html.erb @@ -87,6 +87,8 @@ <% end %> <% elsif names[0] == "seminar_submission_fields" %> <% val = seminar_signup.seminar_signup_contributes.collect{|s| (s.seminar_submission_values.where(:key=>names[1]).first.get_value_by_locale(I18n.locale) rescue "")} %> + <% elsif names[0] == "seminar_signup" %> + <% val = (seminar_signup.send("display_"+names[1]) rescue seminar_signup.send(names[1])) rescue nil %> <% end %> <% vals << val %> <% end %> diff --git a/app/views/admin/seminars/export.xlsx.axlsx b/app/views/admin/seminars/export.xlsx.axlsx index 38ba346..15b7269 100644 --- a/app/views/admin/seminars/export.xlsx.axlsx +++ b/app/views/admin/seminars/export.xlsx.axlsx @@ -6,6 +6,8 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet| row = [t('seminar_signup.signup_time')] + row << t('seminar_signup.serial_number') + row << t('seminar_signup.name') row << t('seminar_signup.unit') @@ -35,10 +37,12 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet| sheet.add_row row @seminar_signups.each do |signup| - + types = {} row2 = [] row2 << "#{signup.created_at} " + types[1] = :string + row2 << "#{signup.display_serial_number}" row2 << "#{signup[:name]} " row2 << "#{signup.unit} " row2 << "#{signup[:tel]} " @@ -57,8 +61,8 @@ wb.add_worksheet(name: (@seminar.title.to_s[0..27]+'...')) do |sheet| row2 << nl2br(show_attribute_value(@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' ' end end - - sheet.add_row row2 + types = (0...row2.count).map{|i| types[i]} + sheet.add_row row2 , :types => types end diff --git a/app/views/admin/seminars/get_reviewer_block.html.erb b/app/views/admin/seminars/get_reviewer_block.html.erb index 5400b54..9728091 100644 --- a/app/views/admin/seminars/get_reviewer_block.html.erb +++ b/app/views/admin/seminars/get_reviewer_block.html.erb @@ -3,7 +3,7 @@
<%= MemberProfile.find(@reviewer_id).name rescue "" %>
- - <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.all_seminar_signup_ids) %> + <% @seminar_signups = SeminarSignup.where(:id.in=>seminar_review.all_seminar_signup_ids).sort_ordered %> <%= render :partial => "seminar_signup_render_table",:locals=>{:@seminar_signups=>@seminar_signups.page(params[:page]).per(5),:@drag => true,:@include_blank=>true,:@reviewer_id=>seminar_review.id.to_s} %> <%= content_tag :div, class: "bottomnav clearfix", style: "position: static;" do diff --git a/app/views/email/signup_email.html.erb b/app/views/email/signup_email.html.erb index eb6a9a0..a595543 100644 --- a/app/views/email/signup_email.html.erb +++ b/app/views/email/signup_email.html.erb @@ -5,4 +5,5 @@ <% end %> <% else %> <%= t('seminar.email_signup_content') %> -<% end %> \ No newline at end of file +<% end %> +<%= (@data['extra_text'] rescue "").html_safe %> \ No newline at end of file diff --git a/app/views/email/submission_email.html.erb b/app/views/email/submission_email.html.erb index d3b4041..d2b1665 100644 --- a/app/views/email/submission_email.html.erb +++ b/app/views/email/submission_email.html.erb @@ -5,4 +5,5 @@ <% end %> <% else %> <%= t('seminar.email_submission_content') %> -<% end %> \ No newline at end of file +<% end %> +<%= (@data['extra_text'] rescue "").html_safe %> \ No newline at end of file diff --git a/app/views/seminars/con_upload.html.erb b/app/views/seminars/con_upload.html.erb index d7e357b..a0f47a3 100644 --- a/app/views/seminars/con_upload.html.erb +++ b/app/views/seminars/con_upload.html.erb @@ -19,7 +19,7 @@ <% if @seminar.contribute_start_date <= @time_now and ( @seminar.contribute_end_date.nil? or @seminar.contribute_end_date+1 >= @time_now ) %> <% begin %> <% if !session[:seminar_signup_id].blank? %> - + <%=t('seminar_signup.serial_number') %>: <%=@seminar_signup.serial_number rescue ""%> <%= t('seminar_signup.logout') %> diff --git a/app/views/seminars/signup_ok.html.erb b/app/views/seminars/signup_ok.html.erb index 0dcc17a..999558a 100644 --- a/app/views/seminars/signup_ok.html.erb +++ b/app/views/seminars/signup_ok.html.erb @@ -4,6 +4,8 @@ %> <%= t('seminar_signup.success_message') %> +
+<%=t('seminar_signup.serial_number') %>: <%=data["serial_number"] rescue ""%> <% if !params['status'].nil? %>
diff --git a/config/locales/en.yml b/config/locales/en.yml index c7e2b35..92f2cd0 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -19,6 +19,7 @@ en: verification_failed: Verification Failed #驗證碼錯誤 seminar: + submitter_without_reviewer: Submitter without reviewer are_you_want_to_remove: "Are you really want to remove?" add_assign_fields: Add assign fields assign_fields: Assign fields @@ -115,6 +116,7 @@ en: content: Content #內容 seminar_signup: + serial_number: Sign-up No. status: Attendee Role title: File Name description: Summary diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index f2e812e..0f9aa1d 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -19,6 +19,7 @@ zh_tw: verification_failed: 驗證碼錯誤 seminar: + submitter_without_reviewer: 未分派審查委員報名者 are_you_want_to_remove: 你確定要刪除? add_assign_fields: 新增分派欄位 assign_fields: 分派欄位 @@ -115,6 +116,7 @@ zh_tw: content: 內容 seminar_signup: + serial_number: 註冊編號 status: 報名身分 title: 稿件名稱 description: 摘要