forked from spen/seminar
Add serial number to signups.
This commit is contained in:
parent
5aaf112325
commit
f66d45cfab
|
@ -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"
|
||||
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
|
||||
|
|
|
@ -163,14 +163,15 @@ class SeminarsController < ApplicationController
|
|||
@seminar.unassigned_seminar_signup_ids << @seminar_signup.id.to_s
|
||||
@seminar.save
|
||||
end
|
||||
extra_text = "<br>#{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
|
||||
|
|
|
@ -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')
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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| %>
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
<div class="reviewer_block" data-id="<%=seminar_review.id.to_s%>" data-count="<%=count%>">
|
||||
<h5><%= MemberProfile.find(reviewer_id).name rescue "" %></h5>
|
||||
<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(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 @@
|
|||
%>
|
||||
<div style="float: right;width: 50%;" data-count="<%=count+=1%>">
|
||||
<div id="main-table" style="overflow: scroll;">
|
||||
<h5><%= t('seminar.submitter_without_reviewer') %></h5>
|
||||
<%= render :partial => "seminar_signup_render_table" %>
|
||||
</div>
|
||||
<%=
|
||||
|
|
|
@ -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 %>
|
||||
|
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
<div class="reviewer_block" data-id="<%=seminar_review.id.to_s%>">
|
||||
<h5><%= MemberProfile.find(@reviewer_id).name rescue "" %></h5>
|
||||
<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} %>
|
||||
<%=
|
||||
content_tag :div, class: "bottomnav clearfix", style: "position: static;" do
|
||||
|
|
|
@ -6,3 +6,4 @@
|
|||
<% else %>
|
||||
<%= t('seminar.email_signup_content') %>
|
||||
<% end %>
|
||||
<%= (@data['extra_text'] rescue "").html_safe %>
|
|
@ -6,3 +6,4 @@
|
|||
<% else %>
|
||||
<%= t('seminar.email_submission_content') %>
|
||||
<% end %>
|
||||
<%= (@data['extra_text'] rescue "").html_safe %>
|
|
@ -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 ""%>
|
||||
<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">
|
||||
|
|
|
@ -4,6 +4,8 @@
|
|||
%>
|
||||
|
||||
<%= t('seminar_signup.success_message') %>
|
||||
<br>
|
||||
<%=t('seminar_signup.serial_number') %>: <%=data["serial_number"] rescue ""%>
|
||||
<% if !params['status'].nil? %>
|
||||
<br>
|
||||
<a href="<%= OrbitHelper.url_to_show(params[:slug]) %>?method=con_login">
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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: 摘要
|
||||
|
|
Loading…
Reference in New Issue