Add serial number to signups.

This commit is contained in:
BoHung Chiu 2021-03-29 22:27:08 +08:00
parent 5aaf112325
commit f66d45cfab
16 changed files with 74 additions and 19 deletions

View File

@ -113,7 +113,7 @@ class Admin::SeminarsController < OrbitAdminController
@seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>"enquiry_for_applicants") @seminar_signup_admin_setting = SeminarSignupAdminSetting.create(:seminar_main_id=>"enquiry_for_applicants")
end end
if params[:name].present? 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 else
@seminar_signups = [] @seminar_signups = []
end 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) 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 end
end end
@ -388,7 +388,11 @@ class Admin::SeminarsController < OrbitAdminController
def seminar_signup def seminar_signup
@seminar_signups = [] @seminar_signups = []
if params[:type] == "table" if params[:type] == "table"
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]}/) @seminar_signups = @seminar.seminar_signups.where(:name=>/#{params[:search]}/)
end
else else
@seminar_signups = SeminarSignup.where(:id.in => @seminar.unassigned_seminar_signup_ids, :name=>/#{params[:search]}/) @seminar_signups = SeminarSignup.where(:id.in => @seminar.unassigned_seminar_signup_ids, :name=>/#{params[:search]}/)
end 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_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) @seminar_signups = @seminar.seminar_signups.where(:id.in=>@seminar_review.all_seminar_signup_ids)
end end
@seminar_signups = @seminar_signups.page(params[:page]).per(10) @seminar_signups = @seminar_signups.sort_ordered.page(params[:page]).per(10)
if request.xhr? if request.xhr?
render :layout => false render :layout => false
end end

View File

@ -163,14 +163,15 @@ class SeminarsController < ApplicationController
@seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s @seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s
@seminar.save @seminar.save
end end
extra_text = "<br>#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.serial_number}"
if params['seminar_signup']['status']=='C' if params['seminar_signup']['status']=='C'
status_param = '&status=' 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 else
status_param = '' 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 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 else
if !@signup.blank? if !@signup.blank?
redirect_to "#{params[:referer_url]}", :notice => 'mail已存在' redirect_to "#{params[:referer_url]}", :notice => 'mail已存在'
@ -185,6 +186,8 @@ class SeminarsController < ApplicationController
end end
def signup_ok def signup_ok
params = OrbitHelper.params
{"serial_number"=> params[:serial_number]}
end end
def add_file_proc def add_file_proc
@ -416,7 +419,7 @@ class SeminarsController < ApplicationController
def seminar_signup_values_params def seminar_signup_values_params
params.require(:seminar_signup_values).permit! params.require(:seminar_signup_values).permit!
end 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} email_set = @seminar.seminar_email_sets.select{|v| v.field_name == field_name}
if email_set.length==0 if email_set.length==0
mail = Email.create(mail_to:[email], mail = Email.create(mail_to:[email],
@ -424,14 +427,14 @@ class SeminarsController < ApplicationController
template:"email/#{field_name}_email.html.erb", template:"email/#{field_name}_email.html.erb",
mail_sentdate:Time.current, mail_sentdate:Time.current,
mail_subject: t("seminar.email_#{field_name}_success"), 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) elsif !(email_set[0].disabled)
mail = Email.create(mail_to:[email], mail = Email.create(mail_to:[email],
module_app_key:"seminar", module_app_key:"seminar",
template:"email/#{field_name}_email.html.erb", template:"email/#{field_name}_email.html.erb",
mail_sentdate:Time.current, mail_sentdate:Time.current,
mail_subject: email_set[0].title[I18n.locale], 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 end
begin begin
mail.deliver mail.deliver

View File

@ -1,4 +1,7 @@
module Admin::SeminarsHelper 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) def page_for_seminar(seminar)
ann_page = nil ann_page = nil
pages = Page.where(:module=>'seminar') pages = Page.where(:module=>'seminar')

View File

@ -39,6 +39,7 @@ class SeminarMain
field :unassigned_seminar_signup_ids field :unassigned_seminar_signup_ids
field :review_start_date, :type => Date field :review_start_date, :type => Date
field :review_end_date, :type => Date field :review_end_date, :type => Date
field :last_serial_number, :type => Integer, :default => 0
belongs_to :seminar_item belongs_to :seminar_item
belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id belongs_to :organizer , :class_name=>"MemberProfile", :foreign_key => :organizer_id
has_many :seminar_links, :autosave => true, :dependent => :destroy 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} self.unassigned_seminar_signup_ids = self.seminar_signup_ids.map{|s| s.to_s}
save_flag = true save_flag = true
end 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 self.save if save_flag
end end
end end

View File

@ -14,6 +14,7 @@ class SeminarSignup
field :address, localize: true field :address, localize: true
field :password field :password
field :note, localize: true field :note, localize: true
field :serial_number
belongs_to :seminar_main 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_values, allow_destroy: true
accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true accepts_nested_attributes_for :seminar_signup_contributes, allow_destroy: true
scope :sort_ordered, ->{ order_by(:created_at=>1) }
before_create do before_create do
unit = self.unit_translations.values.select{|v| v.present?}.first unit = self.unit_translations.values.select{|v| v.present?}.first
self.unit_translations = I18n.available_locales.map{|l| [l.to_s,unit]}.to_h 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 end
after_destroy do after_destroy do
seminar_main = self.seminar_main seminar_main = self.seminar_main
@ -42,5 +49,10 @@ class SeminarSignup
seminar_main.save seminar_main.save
end end
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 end

View File

@ -1,6 +1,13 @@
<% @field_names = [] %> <% @field_names = [] %>
<% @field_name_translations = [] %> <% @field_name_translations = [] %>
<% default_hidden = [] %> <% 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.present? %>
<% if @seminar.seminar_signup_field_sets.count != 0 %> <% if @seminar.seminar_signup_field_sets.count != 0 %>
<% @seminar.seminar_signup_field_sets.each do |field_set| %> <% @seminar.seminar_signup_field_sets.each do |field_set| %>

View File

@ -17,7 +17,7 @@
<div class="reviewer_block" data-id="<%=seminar_review.id.to_s%>" data-count="<%=count%>"> <div class="reviewer_block" data-id="<%=seminar_review.id.to_s%>" data-count="<%=count%>">
<h5><%= MemberProfile.find(reviewer_id).name rescue "" %></h5> <h5><%= MemberProfile.find(reviewer_id).name rescue "" %></h5>
<span class="zoom_out_btn">-</span> <span class="zoom_out_btn">-</span>
<% @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(params["page_no#{count}"]).per(5) %>
<% @seminar_signups = @seminar_signups.page(0) if @seminar_signups.to_a.count == 0 %> <% @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} %> <%= 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 @@
%> %>
<div style="float: right;width: 50%;" data-count="<%=count+=1%>"> <div style="float: right;width: 50%;" data-count="<%=count+=1%>">
<div id="main-table" style="overflow: scroll;"> <div id="main-table" style="overflow: scroll;">
<h5><%= t('seminar.submitter_without_reviewer') %></h5>
<%= render :partial => "seminar_signup_render_table" %> <%= render :partial => "seminar_signup_render_table" %>
</div> </div>
<%= <%=

View File

@ -87,6 +87,8 @@
<% end %> <% end %>
<% elsif names[0] == "seminar_submission_fields" %> <% 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 "")} %> <% 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 %> <% end %>
<% vals << val %> <% vals << val %>
<% end %> <% end %>

View File

@ -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.signup_time')]
row << t('seminar_signup.serial_number')
row << t('seminar_signup.name') row << t('seminar_signup.name')
row << t('seminar_signup.unit') 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 sheet.add_row row
@seminar_signups.each do |signup| @seminar_signups.each do |signup|
types = {}
row2 = [] row2 = []
row2 << "#{signup.created_at} " row2 << "#{signup.created_at} "
types[1] = :string
row2 << "#{signup.display_serial_number}"
row2 << "#{signup[:name]} " row2 << "#{signup[:name]} "
row2 << "#{signup.unit} " row2 << "#{signup.unit} "
row2 << "#{signup[:tel]} " 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 ' ' row2 << nl2br(show_attribute_value(@seminar.get_attribute_value(rf,signup.id).get_value_by_locale(I18n.locale))) rescue ' '
end end
end end
types = (0...row2.count).map{|i| types[i]}
sheet.add_row row2 sheet.add_row row2 , :types => types
end end

View File

@ -3,7 +3,7 @@
<div class="reviewer_block" data-id="<%=seminar_review.id.to_s%>"> <div class="reviewer_block" data-id="<%=seminar_review.id.to_s%>">
<h5><%= MemberProfile.find(@reviewer_id).name rescue "" %></h5> <h5><%= MemberProfile.find(@reviewer_id).name rescue "" %></h5>
<span class="zoom_out_btn">-</span> <span class="zoom_out_btn">-</span>
<% @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} %> <%= 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 content_tag :div, class: "bottomnav clearfix", style: "position: static;" do

View File

@ -6,3 +6,4 @@
<% else %> <% else %>
<%= t('seminar.email_signup_content') %> <%= t('seminar.email_signup_content') %>
<% end %> <% end %>
<%= (@data['extra_text'] rescue "").html_safe %>

View File

@ -6,3 +6,4 @@
<% else %> <% else %>
<%= t('seminar.email_submission_content') %> <%= t('seminar.email_submission_content') %>
<% end %> <% end %>
<%= (@data['extra_text'] rescue "").html_safe %>

View File

@ -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 ) %> <% if @seminar.contribute_start_date <= @time_now and ( @seminar.contribute_end_date.nil? or @seminar.contribute_end_date+1 >= @time_now ) %>
<% begin %> <% begin %>
<% if !session[:seminar_signup_id].blank? %> <% if !session[:seminar_signup_id].blank? %>
<%=t('seminar_signup.serial_number') %>: <%=@seminar_signup.serial_number rescue ""%>
<a href="<%= OrbitHelper.url_to_show(@seminar.to_param) %>?method=con_logout&con_no=<%= @seminar.id %>" class='btn btn-primary'><%= t('seminar_signup.logout') %></a> <a href="<%= OrbitHelper.url_to_show(@seminar.to_param) %>?method=con_logout&con_no=<%= @seminar.id %>" class='btn btn-primary'><%= t('seminar_signup.logout') %></a>
<table class="table table-hover table-striped seminar-index"> <table class="table table-hover table-striped seminar-index">

View File

@ -4,6 +4,8 @@
%> %>
<%= t('seminar_signup.success_message') %> <%= t('seminar_signup.success_message') %>
<br>
<%=t('seminar_signup.serial_number') %>: <%=data["serial_number"] rescue ""%>
<% if !params['status'].nil? %> <% if !params['status'].nil? %>
<br> <br>
<a href="<%= OrbitHelper.url_to_show(params[:slug]) %>?method=con_login"> <a href="<%= OrbitHelper.url_to_show(params[:slug]) %>?method=con_login">

View File

@ -19,6 +19,7 @@ en:
verification_failed: Verification Failed #驗證碼錯誤 verification_failed: Verification Failed #驗證碼錯誤
seminar: seminar:
submitter_without_reviewer: Submitter without reviewer
are_you_want_to_remove: "Are you really want to remove?" are_you_want_to_remove: "Are you really want to remove?"
add_assign_fields: Add assign fields add_assign_fields: Add assign fields
assign_fields: Assign fields assign_fields: Assign fields
@ -115,6 +116,7 @@ en:
content: Content #內容 content: Content #內容
seminar_signup: seminar_signup:
serial_number: Sign-up No.
status: Attendee Role status: Attendee Role
title: File Name title: File Name
description: Summary description: Summary

View File

@ -19,6 +19,7 @@ zh_tw:
verification_failed: 驗證碼錯誤 verification_failed: 驗證碼錯誤
seminar: seminar:
submitter_without_reviewer: 未分派審查委員報名者
are_you_want_to_remove: 你確定要刪除? are_you_want_to_remove: 你確定要刪除?
add_assign_fields: 新增分派欄位 add_assign_fields: 新增分派欄位
assign_fields: 分派欄位 assign_fields: 分派欄位
@ -115,6 +116,7 @@ zh_tw:
content: 內容 content: 內容
seminar_signup: seminar_signup:
serial_number: 註冊編號
status: 報名身分 status: 報名身分
title: 稿件名稱 title: 稿件名稱
description: 摘要 description: 摘要