fix error

This commit is contained in:
邱博亞 2023-10-10 22:49:16 +08:00
parent 6c3b5ca75f
commit e6d4227b71
14 changed files with 378 additions and 150 deletions

View File

@ -60,16 +60,7 @@ class Admin::SeminarSignupsController < OrbitAdminController
@seminar_signup.destroy
redirect_to "/admin/seminars/#{@seminar_main_id}/seminar_signup"
end
def get_predefined_text
seminar = SeminarMain.find(params[:seminar_id])
text = seminar.seminar_email_sets.where(:field_name => params[:type]).first.content[I18n.locale]
render :json => {
"success" => true,
"html" => text
}
redirect_to "/admin/seminars/#{@seminar_main_id}/seminar_signup?type=table"
end
private

View File

@ -699,6 +699,38 @@ class Admin::SeminarsController < OrbitAdminController
redirect_to admin_seminars_path
end
def send_notifying_email
sent_time = DateTime.now
@seminar = SeminarMain.find_by(:id => params[:seminar_id])
seminar_signup = @seminar.seminar_signups.where(:email => params[:email]).first
if !seminar_signup.blank?
extra_text = "<p> #{nl2br(params[:text])} </p>"
if params[:type] == "reset_password"
seminar_signup.status = 'C'
token = seminar_signup.generate_token
extra_text += "<br><a href='#{request.protocol + request.host_with_port + "/" + I18n.locale.to_s + "/seminar/" + @seminar.to_param}/?method=reset_password_page&token=#{token}&cid=#{seminar_signup.id.to_s}'>#{t("seminar.click_here_to_confirm")}</a>"
end
send_mail(params[:type], seminar_signup.email, @seminar.id.to_s, extra_text)
seminar_signup.emails_sent << params[:type]
seminar_signup.emails_sent_time << sent_time
seminar_signup.save
end
render :json => {
"type" => t("seminar.#{params[:type]}"),
"sent_time" => sent_time.strftime("%Y/%m/%d %H:%M"),
"success" => true
}.to_json
end
def get_predefined_text
seminar = SeminarMain.find(params[:seminar_id])
text = seminar.seminar_email_sets.where(:field_name => params[:type]).first.content[I18n.locale]
render :json => {
"success" => true,
"html" => text
}
end
private
def set_seminar

View File

@ -295,7 +295,7 @@ class SeminarsController < ApplicationController
if last_path.include?("?")
referer_url = split_path[0...-1].join('/') + '/' + last_path.split('?')[0]
uri_query = last_path.split("?")[1..-1].join('?')
uri_query.gsub!(/notice=[^&]*/,'').gsub!(/&+$/,'')
uri_query = uri_query.gsub(/notice=[^&]*/,'').gsub(/&+$/,'')
if uri_query.blank?
referer_url = referer_url + "?notice=#{notice_words}"
else
@ -379,7 +379,20 @@ class SeminarsController < ApplicationController
seminar_signup = SeminarSignup.new
time_now = Time.now
time_now = Time.now
referer_url = OrbitHelper.request.referer
if (referer_url.nil? || referer_url.match(/(\?|&)method=show_privacy/).nil?) && !OrbitHelper.request.flash[:notice]
return {
"seminar" => seminar,
"seminar_signup" => seminar_signup,
"time_now" => time_now,
"redirect_to" => "#{OrbitHelper.url_to_show(seminar.to_param)}?method=show_privacy"
}
end
{
"seminar" => seminar,
"seminar_signup" => seminar_signup,
@ -420,6 +433,11 @@ class SeminarsController < ApplicationController
end
def create
referer_url = request.referer
if referer_url
params[:url] = URI.parse(referer_url).path.sub(/\/[^\/]*$/, '').sub(/^\/#{I18n.locale}/, '')
end
OrbitHelper.set_params(params, current_user)
seminar_id = params[:seminar_signup][:seminar_main_id]
@seminar = SeminarMain.where(id: seminar_id).first
if @seminar.enable_recaptcha && (!gotcha_valid?)
@ -522,9 +540,9 @@ class SeminarsController < ApplicationController
def update_signup_form
params = OrbitHelper.params
tmp_seminar_signup_params = seminar_signup_params
@seminar_signup = SeminarSignup.find(params[:signup_id])
@seminar_signup.update_attributes(seminar_signup_params)
@seminar_signup.update_attributes(tmp_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?
@ -540,6 +558,20 @@ class SeminarsController < ApplicationController
@seminar.unassigned_seminar_signup_ids = unassigned_seminar_signup_ids
@seminar.save
end
extra_text = "<br>#{I18n.t('seminar_signup.serial_number')}: #{@seminar_signup.display_serial_number}"
if tmp_seminar_signup_params['status']=='C'
status_param = '&status='
if(@seminar.seminar_email_sets.where(:field_name => "signup").first.is_confirmation)
extra_text += "<br><div><a href='#{request.protocol + request.host_with_port + OrbitHelper.url_to_show(@seminar.to_param)}?method=confirm_email_page&token=#{@seminar_signup.token}&cid=#{@seminar_signup.id.to_s}'>" + t("seminar.click_here_to_confirm") + "</a></div>"
end
send_mail('signup',tmp_seminar_signup_params[:email],tmp_seminar_signup_params[:seminar_main_id],extra_text)
else
status_param = ''
if(@seminar.seminar_email_sets.where(:field_name => "signup").first.is_confirmation)
extra_text += "<br><div><a href='#{request.protocol + request.host_with_port + OrbitHelper.url_to_show(@seminar.to_param)}?method=confirm_email_page&token=#{@seminar_signup.token}&cid=#{@seminar_signup.id.to_s}'>" + t("seminar.click_here_to_confirm") + "</a></div>"
end
send_mail('signup',tmp_seminar_signup_params[:email],tmp_seminar_signup_params[:seminar_main_id],extra_text)
end
redirect_to "#{params[:referer_url].to_s.chomp('/').gsub(/\/([^\/?#]+)(|[^\/]+)$/){|f| '/'+$1}}?method=con_upload"
end
@ -755,7 +787,7 @@ class SeminarsController < ApplicationController
end
def edit_login_seminar_signup
def edit_login_seminar_signup #copy from show
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
@ -818,7 +850,11 @@ class SeminarsController < ApplicationController
def confirm_email_page
confirm = false
params = OrbitHelper.params
seminar = SeminarMain.where(:uid => params[:uid]).first
uid = params[:uid]
if uid.nil?
uid = params[:page].split('-').last
end
seminar = SeminarMain.where(:uid => uid).first
if(!seminar.nil?)
signup = seminar.seminar_signups.where(:id => params[:cid], :token => params[:token], :is_confirmed => false).first
if(!signup.nil?)
@ -890,44 +926,7 @@ class SeminarsController < ApplicationController
params.require(:seminar_signup_contribute).permit!
end
def send_notifying_email
@seminar = SeminarMain.find_by(:id => params[:seminar_id])
seminar_signup = @seminar.seminar_signups.where(:email => params[:email]).first
if !seminar_signup.blank?
extra_text = "<p> #{params[:text]} </p>"
if params[:type] == "reset_password"
token = seminar_signup.generate_token
extra_text += "<br><a href='#{request.protocol + request.host_with_port + "/" + I18n.locale.to_s + "/seminar/" + @seminar.to_param}/?method=reset_password_page&token=#{token}&cid=#{seminar_signup.id.to_s}'>#{t("seminar.click_here_to_confirm")}</a>"
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
def seminar_signup_values_params
params.require(:seminar_signup_values).permit!
end
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],
module_app_key:"seminar",
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,'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,'extra_text'=> extra_text})
end
end
end

View File

@ -7,6 +7,7 @@ module Admin::SeminarsFieldHelper
include ActionView::Helpers::RenderingHelper
include ActionView::Context
include OrbitBasis::RenderAnywhere
include ::MemberHelper
include OrbitFormHelper
@ -168,7 +169,9 @@ module Admin::SeminarsFieldHelper
key = can_muti_lang_input_for_sm? ? "#{key}" : I18n.locale
place_holder= typeD["placeholder"][key] rescue ''
name1 = can_muti_lang_input_for_sm? ? (get_field_name_base + "[#{key}]") : get_field_name_base
text_area_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'ckeditor input-medium form-control'))
text_area_tag(name1, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control', :maxlength=> 300)) + (content_tag :p do
"(#{I18n.t("seminar.text_area_hint")})"
end)
end
end
@ -187,14 +190,32 @@ module Admin::SeminarsFieldHelper
add_more_blank = can_add_more ? "[]" : ""
key_field = can_muti_lang_input? ? "[#{key}]" : ""
field_name = [get_field_name_base,add_more_blank,key_field].join
file_required =@require ? 'required="required"' : ''
file_required =@require && !value ? 'required="required"' : ''
"<div class=\"file-selector\"><label class=\"ui-button\">
<input style=\"position: absolute;width:0.1em;opacity: 0;padding: 0;border: 0;opacity: 0;left: 50%;top: 0;\" class=\"upload\" name=\"#{field_name}\" #{file_required} type=\"file\" />
<input style=\"position: absolute;width:0.1em;opacity: 0;padding: 0;border: 0;opacity: 0;left: 50%;top: 0;\" class=\"upload\" name=\"#{field_name}\" #{file_required} type=\"file\" accept=\".pdf,.png,.jpg,.odf\" onchange=\"if(this.files[0].size > 1048576*20){alert('#{I18n.t("seminar.file_limit_hint")}');this.value = '';}else{var ext = this.value.match(/\.([^\.]+)$/)[1];if (!['pdf','png','jpg','odf'].includes(ext)){alert('#{I18n.t("seminar.file_format_hint")}');this.value='';}}\" />
<i class=\"fa fa-file\"></i> #{I18n.t('file.upload')}
</label><div class=\"filename\"></div></div>#{value}".html_safe
end
end
def render_email
a = control_group_wrapper_for_sm do |key,value|
place_holder= typeA["placeholder"][I18n.locale] rescue ''
email_field_tag(get_field_name_base, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control', title: I18n.t("seminar.email_hint"))) +
(content_tag :div,:class=>"loader" do
end)
end
end
def render_phone
a = control_group_wrapper_for_sm do |key,value|
place_holder= typeA["placeholder"][I18n.locale] rescue ''
text_field_tag(get_field_name_base, value, @markup_options.merge(:placeholder=>place_holder,:class=>'input-medium form-control', pattern: "[\\d\\+\\-\\(\\)]+", title: I18n.t("seminar.phone_hint"))) + (content_tag :p do
"(#{I18n.t("seminar.phone_hint")})"
end)
end
end
def date_is_range?
is_range = "false"
data = get_data

View File

@ -50,6 +50,24 @@ module Admin::SeminarsHelper
end
# return "/#{I18n.locale}#{page.url}/#{seminar.to_param}"
end
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],
module_app_key:"seminar",
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,'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,'extra_text'=> extra_text})
end
end
module MultiLang
extend self
extend ActionView::Helpers::FormTagHelper

View File

@ -14,6 +14,7 @@ class SeminarSignup
field :is_confirmed_date, type: DateTime
field :signup_confirmed_date, type: DateTime
field :emails_sent, type: Array, default: []
field :emails_sent_time, 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
@ -190,4 +191,8 @@ class SeminarSignup
return all_fields
end
end
def emails_sent_groups
emails_sent.zip([nil]*(emails_sent.length-emails_sent_time.length) + emails_sent_time.collect{|v| v.in_time_zone})
end
end

View File

@ -14,7 +14,15 @@
<%= javascript_include_tag "lib/file-type" %>
<%= javascript_include_tag "lib/module-area" %>
<% end %>
<style type="text/css">
.emails_sent_groups{
display: inline-block;
}
.emails_sent_time{
min-height: 1em;
display: inline-block;
}
</style>
<!-- Input Area -->
<div class="input-area">
@ -127,8 +135,18 @@
<div class="controls">
<label for="" class="control-label muted"><%= t("seminar_signup.emails_already_sent") %></label>
<div class="controls" id="emails_sent">
<% @seminar_signup.emails_sent.each do |em| %>
<span class="label label-success"><%= t("seminar.#{em}") %></span>
<% @seminar_signup.emails_sent_groups.each do |em, em_date| %>
<span class="emails_sent_groups">
<span class="label label-success">
<%= t("seminar.#{em}") %>
</span>
<br />
<span class="emails_sent_time">
<% if em_date %>
<%= em_date.strftime("%Y/%m/%d %H:%M") %>
<% end %>
</span>
</span>
<% end %>
</div>
</div>
@ -246,11 +264,14 @@ $(document).ready(function(){
if($(this).val() != ""){
let type = $(this).val();
$.ajax({
url : "/admin/seminar_signups/get_predefined_text",
url : "/admin/seminars/get_predefined_text",
data : {"type" : type, "seminar_id": "<%= @seminar.id %>"},
dataType : "json",
type : "get",
success : function(data){
if (type === 'reset_password'){
$('#seminar_signup_status_c').click();
}
if( data.success == true ){
$("#predefined_text").html(data.html);
}
@ -265,7 +286,7 @@ $(document).ready(function(){
}
if($("#send_email").val() != ""){
$.ajax({
url : "/xhr/seminars/send_notifying_email",
url : "/admin/seminars/send_notifying_email",
data : {
"type" : $("#send_email").val(),
"email" : $("#seminar_signup_email").val(),
@ -277,7 +298,7 @@ $(document).ready(function(){
success : function(data){
if( data.success == true ){
alert("Email Sent");
$("#emails_sent").append('<span class="label label-success">'+ data.type +'</span>');
$("#emails_sent").append('<span class="emails_sent_groups"><span class="label label-success">'+ data.type +'</span><br/><span class="emails_sent_time">' +data.sent_time +'</span></span>');
}
}
})

View File

@ -52,8 +52,12 @@
val += "<div class=\"quick-edit\">
<ul class=\"nav nav-pills\">"
if @can_edit
val += "<li><a href=\"/admin/seminar_signups/#{seminar_signup.id}/edit\">#{t(:edit)}</a></li>
<li><a href=\"#{admin_seminar_signup_path(seminar_signup.id)}\" class=\"delete text-error\" rel=\"nofollow\" data-method=\"delete\" data-confirm=\"Are you sure?\">#{t(:delete_)}</a></li>"
val += content_tag :li do
link_to t(:edit), edit_admin_seminar_signup_path(seminar_signup.id)
end
val += content_tag :li do
link_to t(:delete_), admin_seminar_signup_path(seminar_signup.id), class: "text-error", method: :delete, "data-confirm" => "Are you sure?"
end
end
val += "</ul>
</div>"
@ -83,8 +87,12 @@
val += "<div class=\"quick-edit\">
<ul class=\"nav nav-pills\">"
if @can_edit
val += "<li><a href=\"/admin/seminar_signups/#{seminar_signup.id}/edit\">#{t(:edit)}</a></li>
<li><a href=\"#{admin_seminar_signup_path(seminar_signup.id)}\" class=\"delete text-error\" rel=\"nofollow\" data-method=\"delete\" data-confirm=\"Are you sure?\">#{t(:delete_)}</a></li>"
val += content_tag :li do
link_to t(:edit), edit_admin_seminar_signup_path(seminar_signup.id)
end
val += content_tag :li do
link_to t(:delete_), admin_seminar_signup_path(seminar_signup.id), class: "text-error", method: :delete, "data-confirm" => "Are you sure?"
end
end
val += "</ul>
</div>"

View File

@ -1,8 +1,8 @@
<%
data = action_data
@seminar = data["seminar"]
@seminar_signup = data["seminar_signup"]
@time_now = data["time_now"]
data = action_data
@seminar = data["seminar"]
@seminar_signup = data["seminar_signup"]
@time_now = data["time_now"]
@form_index = 0
if data["prefix_url"]
prefix_url = data["prefix_url"]
@ -58,7 +58,7 @@
margin: 0;
}
</style>
<%= form_for @seminar_signup, url: update_signup_form_seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup", multipart: true} do |f| %>
<%= form_for @seminar_signup, url: (@seminar_signup.new_record? ? seminars_path : update_signup_form_seminars_path), html: {class: "content form-horizontal" , :id=>"new-seminar-signup", multipart: true} do |f| %>
<fieldset>
<!-- Title -->
@ -81,7 +81,7 @@
</div>
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% @seminar.seminar_signup_field_sets.each do |signup_field| %>
<% if !(signup_field.disabled) && signup_field.field_name != 'recaptcha' %>
<% if !(signup_field.disabled) && signup_field.field_name != 'recaptcha' && signup_field.field_name != 'password' %>
<div class="form-group<%= (@seminar.registration_status[0] == 'G' && (signup_field.field_name == 'password' || signup_field.field_name == "status")) ? ' hide' : '' %>" id="<%= signup_field.field_name == 'password' ? 'registration_status' : '' %>">
<label for="<%= signup_field['name'][I18n.locale] %>" class="col-sm-2 control-label">
<% if !(['address','note'].include? signup_field.field_name) %>
@ -155,6 +155,11 @@
</div>
</div>
</div>
<% elsif signup_field.field_name == 'tel' %>
<div class="col-sm-10">
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> signup_field.placeholder[I18n.locale], :required => true, pattern: "[\\d\\+\\-\\(\\)]+", title: t("seminar.phone_hint") %>
<p>(<%= t("seminar.phone_hint") %>)</p>
</div>
<% else %>
<div class="col-sm-10">
<%= f.text_field signup_field['field_name'], :class=>"input-medium form-control", :id=>signup_field['field_name'], :placeholder=> signup_field.placeholder[I18n.locale], :required => true %>
@ -192,7 +197,7 @@
<div class="form-group">
<label for="tel" class="col-sm-2 control-label">*<%= t('seminar_signup.tel') %></label>
<div class="col-sm-10">
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.tel'), :required => true %>
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.tel'), :required => true, pattern: "[\\d\\+\\-\\(\\)]+" %>
</div>
</div>
@ -200,7 +205,7 @@
<div class="form-group">
<label for="email" class="col-sm-2 control-label">*<%= t(:email) %></label>
<div class="col-sm-10">
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> t(:email), :required => true %> <a href="#" onclick="window.open(' <%= prefix_url %>?method=check_email&no=<%=@seminar.id%>&layout=false&email='+ $('input[type=email]').val() , 'check mail', config='height=100,width=300');" class="btn btn-primary">check mail</a>
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> t(:email), :required => true %>
</div>
</div>
@ -224,7 +229,11 @@
<% end %>
<% if(idx % 5 == 0) && idx != 0 %>
<% group += 1 %>
<% if @seminar_signup.seminar_signup_values[@form_index] && !@seminar_signup.seminar_signup_values[@form_index].value.blank? %>
<div id="group<%= group %>">
<% else %>
<div id="group<%= group %>" style="display:none;">
<% end %>
<% end %>
<% counter += 1 %>
<div class="form-group">
@ -249,7 +258,7 @@
</div>
<!-- 驗證碼 -->
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% if @seminar.seminar_signup_field_sets.count != 0 && @seminar_signup.new_record? %>
<% if !(@seminar.seminar_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled) %>
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= t('seminar_signup.recaptcha') %></label>
@ -271,8 +280,8 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<label>
<input id="agree" name="agree" value="1" type="checkbox" required="required" checked="checked">
<a href="<%= prefix_url %>?method=show_privacy" target="_blank" style="color: black;"><%= t("seminar_signup.agree")%></a>
<input id="agree" name="agree" value="1" type="checkbox" required="required" <% if !@seminar_signup.new_record? %>checked="checked"<%end%>>
<a href="<%= prefix_url %>?method=show_privacy" target="_blank" style="color: black;"><%= t("seminar_signup.agree")%></a>
</label>
</div>
</div>
@ -281,7 +290,9 @@
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last rescue "/" %>">
<input type="hidden" name="seminar_signup[seminar_main_id]" value="<%= @seminar.id %>">
<input type="hidden" name="signup_id" value="<%= @seminar_signup.id %>">
<% if !@seminar_signup.new_record? %>
<input type="hidden" name="signup_id" value="<%= @seminar_signup.id %>">
<% end %>
<%= f.submit "Submit", class: 'btn btn-primary', :id => 'button-mail' %>
<%= f.button "Delete", type: 'reset', class: 'btn' %>
</div>
@ -293,12 +304,42 @@
<script type="text/javascript">
(function(){
function check_repeat_value() {
var validated = true;
var all_values = $.map($('input[name^="seminar_signup_values"]:visible'), function(v) {
return [[v, $(v).val()]];
}).filter(function(v){
return v[1] != ''
});
var values = [];
for (var i=0;i< all_values.length;i++){
if (values.includes(all_values[i][1])){
all_values[i][0].setCustomValidity("<%= t('seminar.repeat_hint') %>");
all_values[i][0].reportValidity();
validated = false;
window.setTimeout(function(){
all_values[i][0].setCustomValidity("");
}, 500);
break;
}
values.push(all_values[i][1]);
}
return validated;
}
$(".rucaptcha-image").siblings("input[type=\"text\"]").attr("placeholder","Verification");
var validated = false,
chks = false,
pwd = $('#seminar_signup_password')
$("form.content").submit(function(event) {
if (!check_repeat_value()){
return false;
}
if ($('*[name^="seminar_signup_values"]:visible')){
$('input[name^="seminar_signup_values"]:visible').map(function(k, v) {
return $(v).val();
});
}
if ($('#seminar_signup_status_c:checked').val() == 'C'){
@ -337,35 +378,42 @@
});
$(".availibility").blur(function(){
$('input[type="email"]').blur(function(){
var type = $(this).attr("id"),
loader = $(this).parent().find('.loader'),
elem = $(this),
value = $(this).val() || null;
var checkAvailability = function(){
$.ajax({
url : "<%= "/xhr/seminars/check_email/#{@seminar.id}" %>",
data : {"type" : type, "email" : value},
dataType : "json",
type : "get",
success : function(data){
if( data.success == true ){
loader.removeClass("error");
}else{
loader.addClass("error");
}
loader.text(data.result);
var checkAvailability = function(){
$.ajax({
url : "<%= "/xhr/seminars/check_email/#{@seminar.id}" %>",
data : {"type" : type, "email" : value},
dataType : "json",
type : "get",
success : function(data){
if( data.success == true ){
loader.removeClass("error");
}else{
loader.addClass("error");
}
})
}
if( value ){
if(type == "seminar_signup_email"){
loader.text("Checking...")
checkAvailability();
loader.text(data.result);
}
});
};
if( value ){
if (!this.checkValidity()){
loader.addClass("error");
loader.text("<%= t("seminar.email_hint") %>");
return;
}else{
loader.removeClass("error");
loader.text("");
}
})
if(type == "seminar_signup_email"){
loader.text("Checking...")
checkAvailability();
}
}
});
$(".upload").on("change",function(){
let filenamedom = $(this).parent().parent().find(".filename");
let filenameA = $(this).val().split('\\');
@ -380,14 +428,18 @@ $(".availibility").blur(function(){
// $("#seminar_signup_values_3_value").removeAttr("placeholder");
let currentGroup = 1;
let currentGroup = 1 + $("#new-seminar-signup div[id^=group]:visible").length;
if (currentGroup > 1){
$("#remove-member").show();
}
$("#add-member").on("click",function () {
if(currentGroup < 5){
$("#remove-member").show();
currentGroup++;
$("#group" + currentGroup).show();
$("#group" + currentGroup + " .fake-clean-file").remove();
if(currentGroup == 5){
$(this).attr("disabled","disabled").hide();
$(this).hide();
}
}
$("#group" + currentGroup + " input").attr("required", true);
@ -395,10 +447,14 @@ $(".availibility").blur(function(){
return false;
})
$("#remove-member").on("click",function () {
$("#add-member").show();
if(currentGroup > 0){
$("#group" + currentGroup).hide();
$("#group" + currentGroup + " input").attr("required", false);
$("#group" + currentGroup + " input").val("");
$("#group" + currentGroup + " input[type!=hidden]").val("");
$.each($("#group" + currentGroup + " input[type=file]"), function(k, v) {
$(v).after("<input class=\"fake-clean-file\" type=\"hidden\" name=\""+$(v).attr('name')+"\" value=\"\">");
});
$("#group" + currentGroup + " textarea").attr("required", false);
$("#group" + currentGroup + " textarea").val("");
currentGroup--;

View File

@ -1,8 +1,8 @@
<%
data = action_data
@seminar = data["seminar"]
@seminar_signup = data["seminar_signup"]
@time_now = data["time_now"]
data = action_data
@seminar = data["seminar"]
@seminar_signup = data["seminar_signup"]
@time_now = data["time_now"]
@form_index = 0
if data["prefix_url"]
prefix_url = data["prefix_url"]
@ -58,7 +58,7 @@
margin: 0;
}
</style>
<%= form_for @seminar_signup, url: seminars_path, html: {class: "content form-horizontal" , :id=>"new-seminar-signup", multipart: true} do |f| %>
<%= form_for @seminar_signup, url: (@seminar_signup.new_record? ? seminars_path : update_signup_form_seminars_path), html: {class: "content form-horizontal" , :id=>"new-seminar-signup", multipart: true} do |f| %>
<fieldset>
<!-- Title -->
@ -81,7 +81,7 @@
</div>
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% @seminar.seminar_signup_field_sets.each do |signup_field| %>
<% if !(signup_field.disabled) && signup_field.field_name != 'recaptcha' %>
<% if !(signup_field.disabled) && signup_field.field_name != 'recaptcha' && signup_field.field_name != 'password' %>
<div class="form-group<%= (@seminar.registration_status[0] == 'G' && (signup_field.field_name == 'password' || signup_field.field_name == "status")) ? ' hide' : '' %>" id="<%= signup_field.field_name == 'password' ? 'registration_status' : '' %>">
<label for="<%= signup_field['name'][I18n.locale] %>" class="col-sm-2 control-label">
<% if !(['address','note'].include? signup_field.field_name) %>
@ -155,6 +155,11 @@
</div>
</div>
</div>
<% elsif signup_field.field_name == 'tel' %>
<div class="col-sm-10">
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> signup_field.placeholder[I18n.locale], :required => true, pattern: "[\\d\\+\\-\\(\\)]+", title: t("seminar.phone_hint") %>
<p>(<%= t("seminar.phone_hint") %>)</p>
</div>
<% else %>
<div class="col-sm-10">
<%= f.text_field signup_field['field_name'], :class=>"input-medium form-control", :id=>signup_field['field_name'], :placeholder=> signup_field.placeholder[I18n.locale], :required => true %>
@ -192,7 +197,7 @@
<div class="form-group">
<label for="tel" class="col-sm-2 control-label">*<%= t('seminar_signup.tel') %></label>
<div class="col-sm-10">
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.tel'), :required => true %>
<%= f.text_field :tel, :class=>"input-medium form-control", :placeholder=> t('seminar_signup.tel'), :required => true, pattern: "[\\d\\+\\-\\(\\)]+" %>
</div>
</div>
@ -200,7 +205,7 @@
<div class="form-group">
<label for="email" class="col-sm-2 control-label">*<%= t(:email) %></label>
<div class="col-sm-10">
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> t(:email), :required => true %> <a href="#" onclick="window.open(' <%= prefix_url %>?method=check_email&no=<%=@seminar.id%>&layout=false&email='+ $('input[type=email]').val() , 'check mail', config='height=100,width=300');" class="btn btn-primary">check mail</a>
<%= f.email_field :email, :class=>"input-medium form-control availibility", :placeholder=> t(:email), :required => true %>
</div>
</div>
@ -224,7 +229,11 @@
<% end %>
<% if(idx % 5 == 0) && idx != 0 %>
<% group += 1 %>
<% if @seminar_signup.seminar_signup_values[@form_index] && !@seminar_signup.seminar_signup_values[@form_index].value.blank? %>
<div id="group<%= group %>">
<% else %>
<div id="group<%= group %>" style="display:none;">
<% end %>
<% end %>
<% counter += 1 %>
<div class="form-group">
@ -249,7 +258,7 @@
</div>
<!-- 驗證碼 -->
<% if @seminar.seminar_signup_field_sets.count != 0 %>
<% if @seminar.seminar_signup_field_sets.count != 0 && @seminar_signup.new_record? %>
<% if !(@seminar.seminar_signup_field_sets.select{|v| v.field_name=='recaptcha'}[0].disabled) %>
<div class="form-group">
<label for="note" class="col-sm-2 control-label"><%= t('seminar_signup.recaptcha') %></label>
@ -271,8 +280,8 @@
<div class="form-group">
<div class="col-sm-offset-2 col-sm-10">
<label>
<input id="agree" name="agree" value="1" type="checkbox" required="required">
<a href="<%= prefix_url %>?method=show_privacy" target="_blank" style="color: black;"><%= t("seminar_signup.agree")%></a>
<input id="agree" name="agree" value="1" type="checkbox" required="required" <% if !@seminar_signup.new_record? %>checked="checked"<%end%>>
<a href="<%= prefix_url %>?method=show_privacy" target="_blank" style="color: black;"><%= t("seminar_signup.agree")%></a>
</label>
</div>
</div>
@ -281,6 +290,9 @@
<div class="col-sm-offset-2 col-sm-10">
<input type="hidden" name="referer_url" value="<%= request.original_url.split(request.env["HTTP_HOST"]).last rescue "/" %>">
<input type="hidden" name="seminar_signup[seminar_main_id]" value="<%= @seminar.id %>">
<% if !@seminar_signup.new_record? %>
<input type="hidden" name="signup_id" value="<%= @seminar_signup.id %>">
<% end %>
<%= f.submit "Submit", class: 'btn btn-primary', :id => 'button-mail' %>
<%= f.button "Delete", type: 'reset', class: 'btn' %>
</div>
@ -292,12 +304,42 @@
<script type="text/javascript">
(function(){
function check_repeat_value() {
var validated = true;
var all_values = $.map($('input[name^="seminar_signup_values"]:visible'), function(v) {
return [[v, $(v).val()]];
}).filter(function(v){
return v[1] != ''
});
var values = [];
for (var i=0;i< all_values.length;i++){
if (values.includes(all_values[i][1])){
all_values[i][0].setCustomValidity("<%= t('seminar.repeat_hint') %>");
all_values[i][0].reportValidity();
validated = false;
window.setTimeout(function(){
all_values[i][0].setCustomValidity("");
}, 500);
break;
}
values.push(all_values[i][1]);
}
return validated;
}
$(".rucaptcha-image").siblings("input[type=\"text\"]").attr("placeholder","Verification");
var validated = false,
chks = false,
pwd = $('#seminar_signup_password')
$("form.content").submit(function(event) {
if (!check_repeat_value()){
return false;
}
if ($('*[name^="seminar_signup_values"]:visible')){
$('input[name^="seminar_signup_values"]:visible').map(function(k, v) {
return $(v).val();
});
}
if ($('#seminar_signup_status_c:checked').val() == 'C'){
@ -336,35 +378,42 @@
});
$(".availibility").blur(function(){
$('input[type="email"]').blur(function(){
var type = $(this).attr("id"),
loader = $(this).parent().find('.loader'),
elem = $(this),
value = $(this).val() || null;
var checkAvailability = function(){
$.ajax({
url : "<%= "/xhr/seminars/check_email/#{@seminar.id}" %>",
data : {"type" : type, "email" : value},
dataType : "json",
type : "get",
success : function(data){
if( data.success == true ){
loader.removeClass("error");
}else{
loader.addClass("error");
}
loader.text(data.result);
var checkAvailability = function(){
$.ajax({
url : "<%= "/xhr/seminars/check_email/#{@seminar.id}" %>",
data : {"type" : type, "email" : value},
dataType : "json",
type : "get",
success : function(data){
if( data.success == true ){
loader.removeClass("error");
}else{
loader.addClass("error");
}
})
}
if( value ){
if(type == "seminar_signup_email"){
loader.text("Checking...")
checkAvailability();
loader.text(data.result);
}
});
};
if( value ){
if (!this.checkValidity()){
loader.addClass("error");
loader.text("<%= t("seminar.email_hint") %>");
return;
}else{
loader.removeClass("error");
loader.text("");
}
})
if(type == "seminar_signup_email"){
loader.text("Checking...")
checkAvailability();
}
}
});
$(".upload").on("change",function(){
let filenamedom = $(this).parent().parent().find(".filename");
let filenameA = $(this).val().split('\\');
@ -379,14 +428,18 @@ $(".availibility").blur(function(){
// $("#seminar_signup_values_3_value").removeAttr("placeholder");
let currentGroup = 1;
let currentGroup = 1 + $("#new-seminar-signup div[id^=group]:visible").length;
if (currentGroup > 1){
$("#remove-member").show();
}
$("#add-member").on("click",function () {
if(currentGroup < 5){
$("#remove-member").show();
currentGroup++;
$("#group" + currentGroup).show();
$("#group" + currentGroup + " .fake-clean-file").remove();
if(currentGroup == 5){
$(this).attr("disabled","disabled").hide();
$(this).hide();
}
}
$("#group" + currentGroup + " input").attr("required", true);
@ -394,11 +447,14 @@ $(".availibility").blur(function(){
return false;
})
$("#remove-member").on("click",function () {
$("#add-member").show();
if(currentGroup > 0){
$("#group" + currentGroup).hide();
$("#group" + currentGroup + " input").attr("required", false);
$("#group" + currentGroup + " input[type='text']").val("");
$("#group" + currentGroup + " input[type='file']").val("");
$("#group" + currentGroup + " input[type!=hidden]").val("");
$.each($("#group" + currentGroup + " input[type=file]"), function(k, v) {
$(v).after("<input class=\"fake-clean-file\" type=\"hidden\" name=\""+$(v).attr('name')+"\" value=\"\">");
});
$("#group" + currentGroup + " textarea").attr("required", false);
$("#group" + currentGroup + " textarea").val("");
currentGroup--;

View File

@ -45,3 +45,7 @@ markups:
ext_support: false
panel: typeF
display_only: seminar_submission_field
email:
panel: typeA
phone:
panel: typeA

View File

@ -6,6 +6,8 @@ en:
lists:
markups:
seminar_preferred_session: Preferred Session
email: Email
phone: Phone
restful_actions:
edit_seminar_review: Review
copy: Copy
@ -27,6 +29,12 @@ en:
abstract_number: Abstract number
presentation_type: Presentation
seminar:
repeat_hint: Input text must unique!
phone_hint: Can only include number, +, -, and ()!
email_hint: Email is not complete!
text_area_hint: Limit 300 characters
file_limit_hint: File Size cannot larger than 20MB!
file_format_hint: only support .pdf, .png, .jpg, .odf extensions!
signup_limit: Signup Limit
participant_list: Participant list
back: Back
@ -111,9 +119,7 @@ en:
email_special_reminder_success: Special Reminder
is_confirmation: Confirmation Email
select_email_type: Select Email Type
send_email_text: Additional text to send
send_email_button: Send email
predefined_text: Predifined email text
click_here_to_confirm: Please click this link / 請點選此連結
confirm_ok: Email confirmed
confirm_not_ok: Email cannot be confirmed
@ -256,3 +262,5 @@ en:
signup_confirmed_date: Signup confirmed time
add_member: Add Member
remove_member: Remove Member
send_email_text: Additional text to send
predefined_text: Predifined email text

View File

@ -6,7 +6,8 @@ zh_tw:
lists:
markups:
seminar_preferred_session: Preferred Session
email: 電子信箱
phone: 電話
restful_actions:
edit_seminar_review: 審查
copy: 複製
@ -28,6 +29,12 @@ zh_tw:
abstract_number: 摘要編號
presentation_type: 發表方式
seminar:
repeat_hint: 輸入內容不能重複
phone_hint: 僅可輸入數字及+ - ()
email_hint: Email信箱不完整
text_area_hint: 字數最多只能300個字
file_limit_hint: 檔案不能超過20MB!
file_format_hint: 只能上傳.pdf, .png, .jpg, .odf格式
signup_limit: 報名限制人數
participant_list: 參加者名單
back: 回上一頁
@ -115,8 +122,6 @@ zh_tw:
confirm_ok: 認證通過
confirm_not_ok: 連結已失效
select_email_type: 選擇Email種類
send_email_text: 附加額外文字內容
predefined_text: 預設郵件內容
send_email_button: 寄送Email
validator: 驗證
click_to_contribute: 按此登入投稿
@ -256,3 +261,5 @@ zh_tw:
remove_member: 移除加組員
is_confirmed_date: Email認證時間
signup_confirmed_date: 註冊查核確認時間
send_email_text: 附加額外文字內容
predefined_text: 預設郵件內容

View File

@ -83,6 +83,10 @@ Rails.application.routes.draw do
patch 'update_template_setting'
get 'sub_page_setting'
end
collection do
post "send_notifying_email"
get "get_predefined_text"
end
end
get 'seminar/enquiry_for_applicants' => "seminars#enquiry_for_applicants"
post 'seminar/update_seminar_review' => "seminars#update_seminar_review"
@ -91,7 +95,6 @@ Rails.application.routes.draw do
post 'delete_items'
end
end
get "seminar_signups/get_predefined_text" => "seminar_signups#get_predefined_text"
resources :seminar_agreements
resources :seminar_signups
resources :seminar_submission_values
@ -112,7 +115,6 @@ Rails.application.routes.draw do
patch 'update_signup_form', to: 'seminars#update_signup_form'
end
end
post "/xhr/seminars/send_notifying_email" => "seminars#send_notifying_email"
get "/xhr/seminars/check_email/:no" => "seminars#check_email"
end