Compare commits
6 Commits
3f51e89566
...
18a591d1f2
Author | SHA1 | Date |
---|---|---|
|
18a591d1f2 | |
|
d2edc29945 | |
|
3caa63bb46 | |
|
a4db1fcd2f | |
|
ee69221b8f | |
|
b10a11075b |
|
@ -6,6 +6,9 @@ class Admin::AsksController < OrbitAdminController
|
|||
before_action :set_askquestion, only: [:edit, :destroy, :update, :print]
|
||||
layout :compute_layout
|
||||
helper_method :ask_thead
|
||||
def show
|
||||
@ask_status_histories = @ask_question.ask_status_histories.reverse
|
||||
end
|
||||
def compute_layout
|
||||
if action_name=='print'
|
||||
false
|
||||
|
@ -389,9 +392,9 @@ class Admin::AsksController < OrbitAdminController
|
|||
temp_params['custom_values'][to_save[0]] = [temp_params['custom_values'][to_save[0]].original_filename ,to_save[1].file.url]
|
||||
end
|
||||
end
|
||||
temp_params = temp_params.merge({reviewer: current_user.member_profile, review_time: DateTime.now})
|
||||
temp_params = temp_params.merge({reviewer: current_user.member_profile, review_time: DateTime.now, user: current_user})
|
||||
@ask_question.update_attributes(temp_params)
|
||||
if @ask_question.send_email
|
||||
if @ask_question.send_email?
|
||||
build_email(@ask_question)
|
||||
end
|
||||
|
||||
|
@ -410,6 +413,12 @@ class Admin::AsksController < OrbitAdminController
|
|||
site = Site.first
|
||||
mail_from = site.title_translations[site['default_locale']]
|
||||
|
||||
new_history = email_er.new_history
|
||||
host_url = Site.first.root_url rescue "http://"
|
||||
if host_url == "http://"
|
||||
host_url = request.protocol + request.host_with_port
|
||||
end
|
||||
|
||||
email_er.email.update_attributes(
|
||||
:mail_lang=> site['default_locale'],
|
||||
:create_user=>current_user,
|
||||
|
@ -419,7 +428,9 @@ class Admin::AsksController < OrbitAdminController
|
|||
:mail_subject=>mail_from+" #{t('ask.reply')}:",
|
||||
:template=>'admin/asks/email',
|
||||
:template_data=>{
|
||||
"reply" => email_er.reply
|
||||
"host_url" => host_url,
|
||||
"reply" => email_er.reply,
|
||||
"attachment" => (new_history ? new_history.file.url : nil)
|
||||
}
|
||||
)
|
||||
end
|
||||
|
|
|
@ -198,10 +198,16 @@ class AsksController < ApplicationController
|
|||
temp_params = create_params
|
||||
all_to_save = []
|
||||
ask_setting = AskCategorySetting.enabled.where(category_id: params['ask_question']['category_id']).first
|
||||
override_sort_number = nil
|
||||
if ask_setting.use_default
|
||||
override_sort_number = ask_setting.default_sort_number
|
||||
ask_setting = nil
|
||||
end
|
||||
if ask_setting.nil?
|
||||
ask_setting = AskSetting.first
|
||||
ask_setting = AskSetting.create() if ask_setting.nil?
|
||||
end
|
||||
@ask_setting = ask_setting
|
||||
check_fields = ask_setting.default_setting.select{|k,v| v}.keys & ask_setting.default_setting_required.select{|k,v| v}.keys - AskSetting::No_required
|
||||
flag = true
|
||||
check_fields.each do |f|
|
||||
|
@ -263,10 +269,20 @@ class AsksController < ApplicationController
|
|||
end
|
||||
end
|
||||
if (email_regex ? ::Regexp.new(email_regex).match(temp_params["mail"].to_s) : true) && flag
|
||||
@disp_fields_infos = AskSetting.get_disp_fields_infos(true, ask_setting, true, nil, true)
|
||||
@disp_fields_infos = AskSetting.get_disp_fields_infos(true, ask_setting, true, override_sort_number, true)
|
||||
@usage_rule = ask_setting.usage_rule
|
||||
if temp_params['mail'].blank?
|
||||
temp_params = temp_params.merge({
|
||||
situation: AskTicketStatus::DefaultKeys[1]
|
||||
})
|
||||
end
|
||||
@ask_question.update_attributes(temp_params)
|
||||
build_email(@ask_question)
|
||||
if ask_setting.validate_enable && AskSafeEmail.where(:email=> @ask_question.mail).count == 0
|
||||
build_verification_email(@ask_question)
|
||||
else
|
||||
@ask_question.update(:situation => AskTicketStatus::DefaultKeys[1])
|
||||
build_email(@ask_question)
|
||||
end
|
||||
redirect_to "#{params[:referer_url]}?method=thank"
|
||||
else
|
||||
redirect_to "#{params[:referer_url]}?method=sorry"
|
||||
|
@ -284,15 +300,70 @@ class AsksController < ApplicationController
|
|||
{}
|
||||
end
|
||||
|
||||
def render_404
|
||||
render :file => "#{Rails.root}/app/views/errors/404", :layout => false, :status => :not_found, :formats => [:html]
|
||||
end
|
||||
|
||||
def verify_email
|
||||
@ask_question = AskQuestion.where(:id=>params[:id]).first
|
||||
if @ask_question.nil?
|
||||
render_404 and return
|
||||
elsif @ask_question.situation != AskTicketStatus::DefaultKeys[0]
|
||||
@already_verify = true
|
||||
else
|
||||
@already_verify = false
|
||||
@ask_question.update(:situation => AskTicketStatus::DefaultKeys[1])
|
||||
AskSafeEmail.create(:email=> @ask_question.mail)
|
||||
build_email(@ask_question)
|
||||
end
|
||||
end
|
||||
|
||||
def build_verification_email(email_er)
|
||||
email = Email.new
|
||||
email.save
|
||||
email_er.email_id = email.id
|
||||
email_er.save
|
||||
|
||||
group_mail = email_er.mail
|
||||
manager_emails = email_er.reviewer_emails
|
||||
mail_sentdate = DateTime.now
|
||||
|
||||
site = current_site rescue Site.first
|
||||
mail_from = site.title_translations[site.default_locale]
|
||||
host_url = Site.first.root_url rescue "http://"
|
||||
if host_url == "http://"
|
||||
host_url = request.protocol + request.host_with_port
|
||||
end
|
||||
verify_url = "#{host_url}/#{I18n.locale}/xhr/asks/verify_email/#{email_er.id}"
|
||||
verify_link = "<a title=\"#{t('ask.verify_link')}\" href=\"#{verify_url}\" target=\"_blank\">#{verify_url}</a>"
|
||||
mail_subject = mail_from+": #{t('ask.email_verification_notification')}"
|
||||
email_er.email.update_attributes(
|
||||
:mail_lang=> site.default_locale,
|
||||
:create_user=>(current_user rescue nil),
|
||||
:mail_sentdate=>mail_sentdate,
|
||||
:module_app=>@module_app,
|
||||
:mail_to=>group_mail,
|
||||
:mail_subject=>mail_subject,
|
||||
:template=>'asks/email_verification',
|
||||
:template_data=>{
|
||||
"validation_email_content" => @ask_setting.validation_email_content,
|
||||
"verify_link" => verify_link,
|
||||
"site_host" => host_url,
|
||||
},
|
||||
:mail_reply_to => (manager_emails.empty? ? nil : manager_emails)
|
||||
)
|
||||
# email_er.email.deliver
|
||||
end
|
||||
|
||||
def build_email(email_er)
|
||||
email = Email.new
|
||||
email.save
|
||||
email_er.email_id = email.id
|
||||
email_er.save
|
||||
|
||||
@group_mail = email_er.mail
|
||||
@manager_emails = email_er.reviewer_emails
|
||||
@mail_sentdate = DateTime.now
|
||||
group_mail = email_er.mail
|
||||
manager_emails = email_er.reviewer_emails
|
||||
mail_sentdate = DateTime.now
|
||||
|
||||
site = current_site rescue Site.first
|
||||
mail_from = site.title_translations[site.default_locale]
|
||||
|
@ -304,9 +375,9 @@ class AsksController < ApplicationController
|
|||
email_er.email.update_attributes(
|
||||
:mail_lang=> site.default_locale,
|
||||
:create_user=>(current_user rescue nil),
|
||||
:mail_sentdate=>@mail_sentdate,
|
||||
:mail_sentdate=>mail_sentdate,
|
||||
:module_app=>@module_app,
|
||||
:mail_to=>@group_mail,
|
||||
:mail_to=>group_mail,
|
||||
:mail_subject=>mail_subject,
|
||||
:template=>'asks/email',
|
||||
:template_data=>{
|
||||
|
@ -323,16 +394,16 @@ class AsksController < ApplicationController
|
|||
"site_host" => host_url,
|
||||
"usage_rule" => @usage_rule
|
||||
},
|
||||
:mail_reply_to => (@manager_emails.empty? ? nil : @manager_emails)
|
||||
:mail_reply_to => (manager_emails.empty? ? nil : manager_emails)
|
||||
)
|
||||
if !@manager_emails.empty?
|
||||
if !manager_emails.empty?
|
||||
Email.new(
|
||||
:mail_lang=> site.default_locale,
|
||||
:create_user=>(current_user rescue nil),
|
||||
:mail_sentdate=>@mail_sentdate,
|
||||
:mail_sentdate=>mail_sentdate,
|
||||
:module_app=>@module_app,
|
||||
:mail_to=>@manager_emails,
|
||||
:mail_subject=>mail_subject+" #{@group_mail}",
|
||||
:mail_to=>manager_emails,
|
||||
:mail_subject=>mail_subject+" #{group_mail}",
|
||||
:template=>'asks/email',
|
||||
:template_data=>{
|
||||
# "title" => email_er.title,
|
||||
|
|
|
@ -142,6 +142,12 @@ class AskCategorySetting
|
|||
tmp = nil if !(self.email_regex_enable) || ((self.default_setting[:mail] == false) rescue false)
|
||||
tmp
|
||||
end
|
||||
|
||||
field :email_regex_enable, type: Boolean, default: false
|
||||
field :email_regex, type: String, default: '\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z'
|
||||
field :validate_enable, type: Boolean, default: false
|
||||
field :validation_email_content, type: String, localize: true
|
||||
|
||||
field :tmp_sort_number, type: Hash, default: {} # For Frontend
|
||||
field :sort_number, type: Hash, default: {}
|
||||
field :default_sort_number, type: Hash, default: {}
|
||||
|
@ -149,15 +155,18 @@ class AskCategorySetting
|
|||
field :default_setting_required, type: Hash,default: {title:true,ask_category_id: true,name: true,sex: true,mail: true,phone: false,appointment: false,recaptcha: true,agree_show: false,agree_usage: true}
|
||||
field :default_setting_field_name, type: Hash,default: {}
|
||||
field :default_setting_prompt_word, type: Hash,default: {}
|
||||
field :use_default, type: Boolean, default: false
|
||||
|
||||
field :custom_fields, type: Hash,default: {}
|
||||
field :usage_rule, type: String, default: ''
|
||||
field :category_id, type: String
|
||||
field :title_layout, type: Integer, default: 0
|
||||
field :email_regex_enable, type: Boolean, default: false
|
||||
field :email_regex, type: String, default: '\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z'
|
||||
|
||||
field :need_check_customs, type: Array, default: [] #From AskSetting
|
||||
field :reject_customs, type: Array, default: [] #From AskSetting
|
||||
field :agree_customs, type: Array, default: [] #From AskSetting
|
||||
|
||||
field :category_id, type: String
|
||||
field :use_default, type: Boolean, default: false
|
||||
|
||||
scope :enabled, ->{any_of([{:use_default.ne=>true}, {:use_default=>true, :default_sort_number.nin=>[nil, {}]}])}
|
||||
end
|
||||
scope :custom_enabled, ->{where({:use_default.ne=>true})}
|
||||
end
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
class AskFile
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
mount_uploader :file, AssetUploader
|
||||
field :ask_question_id
|
||||
mount_uploader :file, AssetUploader
|
||||
field :ask_question_id
|
||||
end
|
|
@ -3,9 +3,9 @@ class AskQuestion
|
|||
include Mongoid::Timestamps
|
||||
# include ActiveModel::Validations
|
||||
include OrbitCategory::Categorizable
|
||||
# include OrbitTag::Taggable
|
||||
include OrbitTag::Taggable
|
||||
|
||||
# 欄位
|
||||
# 欄位定義
|
||||
field :serial_number, type: Integer
|
||||
field :ip, type: String
|
||||
field :name, type: String
|
||||
|
@ -15,32 +15,53 @@ class AskQuestion
|
|||
field :fax, type: String
|
||||
field :title, type: String
|
||||
field :content, type: String
|
||||
field :appointment, type:DateTime
|
||||
field :appointment, type: DateTime
|
||||
field :sex
|
||||
|
||||
field :reply, type: String
|
||||
field :comment, type: String
|
||||
field :situation, type: String, default: "is_waiting" #預設待處理
|
||||
field :send_email, type: Boolean, default: false
|
||||
field :situation, type: String, default: "is_email_not_confirmed" # 預設email未驗證
|
||||
field :send_email, type: Integer, default: 0
|
||||
field :email_id
|
||||
field :custom_values, type: Hash,default: {}
|
||||
field :agree_show,type: Boolean,default: false
|
||||
field :agree_usage,type: Boolean,default: false
|
||||
field :verify_email_id
|
||||
field :custom_values, type: Hash, default: {}
|
||||
field :agree_show, type: Boolean, default: false
|
||||
field :agree_usage, type: Boolean, default: false
|
||||
|
||||
field :review_time, type: DateTime
|
||||
belongs_to :reviewer , :class_name=>"MemberProfile", :foreign_key => :reviewer_id
|
||||
belongs_to :reviewer, class_name: "MemberProfile", foreign_key: :reviewer_id
|
||||
has_many :ask_status_histories
|
||||
|
||||
attr_accessor :release_comment, :release_file, :user
|
||||
|
||||
# validates_presence_of :name, :identity, :mail, :title, :content
|
||||
before_create do
|
||||
last_serial_number = AskSetting.update_last_serial_number
|
||||
self.serial_number = last_serial_number
|
||||
end
|
||||
def email
|
||||
mail = Email.find(self.email_id) rescue nil
|
||||
|
||||
before_save :create_ask_status_history
|
||||
|
||||
def release_comment=(v)
|
||||
@changed = true
|
||||
@release_comment = v
|
||||
end
|
||||
|
||||
def release_file=(v)
|
||||
@changed = true
|
||||
@release_file = v
|
||||
end
|
||||
|
||||
def email
|
||||
mail = Email.where(:id=>self.email_id).first
|
||||
end
|
||||
|
||||
def verify_email
|
||||
verify_email = Email.where(:id=>self.verify_email_id).first
|
||||
end
|
||||
|
||||
def reviewer_emails
|
||||
email_address = AskAdmin.or(:category_ids.in => [self.category_id, [], nil]).pluck(:email).select{|s| s.present?}.uniq rescue []
|
||||
authorizes = Authorization.where(:module_app_id=>ModuleApp.where(:key=>'ask').first.id).to_a rescue []
|
||||
email_address = AskAdmin.or(:category_ids.in => [self.category_id, [], nil]).pluck(:email).select { |s| s.present? }.uniq rescue []
|
||||
authorizes = Authorization.where(module_app_id: ModuleApp.where(key: 'ask').first.id).to_a rescue []
|
||||
authorizes.each do |a|
|
||||
if a.category_id
|
||||
next if a.category_id != self.category_id
|
||||
|
@ -49,7 +70,7 @@ class AskQuestion
|
|||
u = a.user
|
||||
email_address << u.email if u && u.email
|
||||
elsif a.role_id
|
||||
email_address = email_address + MemberProfile.where(:role_ids=>a.role_id).pluck(:email).select{|s| s.present?}.uniq
|
||||
email_address = email_address + MemberProfile.where(role_ids: a.role_id).pluck(:email).select { |s| s.present? }.uniq
|
||||
else
|
||||
a.destroy
|
||||
end
|
||||
|
@ -57,6 +78,7 @@ class AskQuestion
|
|||
email_address = email_address.flatten
|
||||
email_address.uniq
|
||||
end
|
||||
|
||||
def get_serial_number(last_serial_number=nil, display_length=nil)
|
||||
if display_length.nil? && last_serial_number.nil?
|
||||
can_update_shared_hash = (defined?(OrbitHelper::SharedHash) && OrbitHelper::SharedHash)
|
||||
|
@ -65,7 +87,32 @@ class AskQuestion
|
|||
display_length = [last_serial_number.to_s.length + 1, 4].max if display_length.nil?
|
||||
display_format_string(self.serial_number, display_length)
|
||||
end
|
||||
|
||||
def display_format_string(num, str_length)
|
||||
return format("%0#{str_length}d", num)
|
||||
format("%0#{str_length}d", num)
|
||||
end
|
||||
|
||||
def send_email?
|
||||
self.send_email == 1
|
||||
end
|
||||
|
||||
def new_history
|
||||
@new_history
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def create_ask_status_history
|
||||
if changed? || @changed
|
||||
@new_history = AskStatusHistory.create(
|
||||
ask_question: self,
|
||||
status: self.situation,
|
||||
comment: @release_comment,
|
||||
file: @release_file,
|
||||
user: @user
|
||||
)
|
||||
else
|
||||
@new_history = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
class AskSafeEmail
|
||||
include Mongoid::Document
|
||||
field :email, type: String
|
||||
index({email: 1}, { unique: false, background: true })
|
||||
end
|
|
@ -93,6 +93,9 @@ class AskSetting
|
|||
end
|
||||
field :email_regex_enable, type: Boolean, default: false
|
||||
field :email_regex, type: String, default: '\A[^@\s]+@([^@.\s]+\.)+[^@.\s]+\z'
|
||||
field :validate_enable, type: Boolean, default: false
|
||||
field :validation_email_content, type: String, localize: true
|
||||
|
||||
field :tmp_sort_number, type: Hash, default: {}
|
||||
field :sort_number, type: Hash, default: {}
|
||||
field :default_setting, type: Hash,default: {title:true,ask_category_id: true,name: true,sex: true,mail: true,phone: true,appointment: true,recaptcha: true,agree_show: true,agree_usage: true}
|
||||
|
@ -143,7 +146,8 @@ class AskSetting
|
|||
ask_setting = nil
|
||||
if cat_is_record
|
||||
ask_setting = cat
|
||||
is_cat_record = !(override_sort_number.nil?) || cat.class == AskCategorySetting
|
||||
is_cat_record = (cat.class == AskCategorySetting)
|
||||
is_cat_record2 = is_cat_record || !(override_sort_number.nil?)
|
||||
else
|
||||
if cat.present?
|
||||
ask_setting = AskCategorySetting.enabled.where(:category_id=>cat).first
|
||||
|
@ -200,10 +204,10 @@ class AskSetting
|
|||
disp_fields_infos[tmp_k] = sort_number[tmp_k]
|
||||
end
|
||||
ask_category_settings = []
|
||||
if is_cat_record
|
||||
if is_cat_record2
|
||||
ask_category_settings = []
|
||||
else
|
||||
ask_category_settings = AskCategorySetting.enabled.to_a
|
||||
ask_category_settings = AskCategorySetting.custom_enabled.to_a
|
||||
end
|
||||
ask_category_settings.each do |c|
|
||||
category = Category.find(c.category_id) rescue nil
|
||||
|
@ -243,7 +247,8 @@ class AskSetting
|
|||
ask_setting = nil
|
||||
if cat_is_record
|
||||
ask_setting = cat
|
||||
is_cat_record = !(override_sort_number.nil?) || cat.class == AskCategorySetting
|
||||
is_cat_record = (cat.class == AskCategorySetting)
|
||||
is_cat_record2 = is_cat_record || !(override_sort_number.nil?)
|
||||
else
|
||||
if cat.present?
|
||||
ask_setting = AskCategorySetting.enabled.where(:category_id=>cat).first
|
||||
|
@ -308,10 +313,10 @@ class AskSetting
|
|||
disp_fields_infos[tmp_k] = {"trans"=>trans,"sort_number"=>sort_number[tmp_k],"key"=>k,"type"=>v["type"],"options"=>v["options"],"instructions"=>v["instructions"]}
|
||||
end
|
||||
ask_category_settings = []
|
||||
if is_cat_record
|
||||
if is_cat_record2
|
||||
ask_category_settings = []
|
||||
else
|
||||
ask_category_settings = AskCategorySetting.enabled.to_a
|
||||
ask_category_settings = AskCategorySetting.custom_enabled.to_a
|
||||
end
|
||||
ask_category_settings.each do |c|
|
||||
category = Category.find(c.category_id) rescue nil
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
class AskStatusHistory
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :status, type: String
|
||||
field :comment, type: String
|
||||
belongs_to :user
|
||||
belongs_to :ask_question
|
||||
|
||||
mount_uploader :file, AssetUploader
|
||||
|
||||
def modified_by_name
|
||||
if user.present? && user.member_profile.present?
|
||||
user.member_profile.name
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
class AskTicketStatus
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
DefaultKeys = ["is_waiting", "is_processed", "is_referral", "is_published"]
|
||||
DefaultKeys = ["is_email_not_confirmed" , "is_waiting", "is_processed", "is_referral", "is_published"]
|
||||
field :title, type: String, localize: true
|
||||
field :is_default, type: Boolean, default: false # if true => cannot delete
|
||||
field :key, type: String
|
||||
|
@ -39,4 +39,8 @@ class AskTicketStatus
|
|||
end
|
||||
trans
|
||||
end
|
||||
|
||||
def self.default_sorting
|
||||
self.all.sort_by{|a| [a.is_default ? 0 : 1, DefaultKeys.index(a.key)] }
|
||||
end
|
||||
end
|
|
@ -174,6 +174,25 @@
|
|||
<%= f.text_field :email_regex, {:id=>"ask_email_regex", :style => "width: 30em;"}.merge(f.object.email_regex_enable ? {} : {:disabled=>"disabled"}) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label for="ask_email_regex"><%= t("ask.validation_email_content") %>:</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label id="<%= "#{f.object_name}_validate_enable" %>"><%= f.check_box :validate_enable %><%= t('ask.enable') %></label>
|
||||
<div style="clear: both;"></div>
|
||||
<%= multiple_lang_tag_for_ask(
|
||||
nil,
|
||||
'text_area',
|
||||
'validation_email_content_translations',
|
||||
f.object.validation_email_content_translations,
|
||||
{
|
||||
class: 'ckeditor'
|
||||
}) %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
$("#email_regex_enable").click(function(){
|
||||
if($(this).prop("checked")){
|
||||
|
@ -196,6 +215,22 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="control-label">
|
||||
<label for="ask_email_regex"><%= t("ask.validation_email_content") %>:</label>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<label id="<%= "#{f.object_name}_validate_enable" %>"><%= f.check_box :validate_enable %><%= t('ask.enable') %></label>
|
||||
<%= multiple_lang_tag_for_ask(
|
||||
nil,
|
||||
'text_area',
|
||||
'validation_email_content_translations',
|
||||
f.object.validation_email_content_translations,
|
||||
{
|
||||
class: 'ckeditor'
|
||||
}) %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<table class="table layoutfix_table">
|
||||
<thead>
|
||||
|
|
|
@ -41,77 +41,180 @@
|
|||
})
|
||||
})
|
||||
</script>
|
||||
|
||||
<div class="input-area">
|
||||
<div id="ask-asks">
|
||||
<table class="table">
|
||||
<tr>
|
||||
<td><%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %></td>
|
||||
<!-- <td><%# AskQuestion.human_attribute_name(:identity) %>:
|
||||
<%# Tag.where({:id => @ask_question[:identity]}).each do |tag| %>
|
||||
<%# tag.name %>
|
||||
<%# end %>
|
||||
</td> -->
|
||||
<td><%= AskQuestion.human_attribute_name(:mail) %>:<%= @ask_question.mail %></td>
|
||||
<td><%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %></td>
|
||||
<!-- <td><%# AskQuestion.human_attribute_name(:fax) %>:<%# @ask_question.fax %></td> -->
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= t('ask.serial_number') %>:<%= @ask_question.get_serial_number %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= t('ask.ip') %>:<%= @ask_question.ip %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= t('title') %>:<%= @ask_question.title %></td>
|
||||
</tr>
|
||||
<% if ask_setting.default_setting['appointment'] %>
|
||||
<tr>
|
||||
<td colspan="5"><%= AskQuestion.human_attribute_name(:appointment) %>:<%= @ask_question.appointment.strftime("%Y-%m-%d %H:%M") rescue nil %></td>
|
||||
<!-- <td colspan="5"><%# AskQuestion.human_attribute_name(:name) %>:<%# @ask_question.name %></td> -->
|
||||
</tr>
|
||||
<% end %>
|
||||
<tr>
|
||||
<!-- <td colspan="5"><%# AskQuestion.human_attribute_name(:name) %>:<br/><%# @ask_question.name.gsub(/[(\n)(\r)]/, "\n" => "<br/>", "\r" => "" ).html_safe %></td> -->
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<%= f.label :reply %>
|
||||
<br/> <%= f.text_area :reply, rows: 10, style: 'width: 500px' %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<%= f.label :comment %>
|
||||
<br/> <%= @ask_question.comment %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= f.label :agree_show %><%= @ask_question.agree_show ? t('ask.yes') : t('ask.no') %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="5"><%= f.label t('situation') %>
|
||||
<%= f.select :situation, AskTicketStatus.all.map{|a| [a.title, a.key]} %>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<tr>
|
||||
<td colspan="5">
|
||||
<%= f.label :send_email %><%= f.radio_button :send_email, 1, checked: @ask_question.send_email? %><%= t('ask.yes') %>
|
||||
|
||||
<%= f.radio_button :send_email, 0, checked: !@ask_question.send_email? %><%= t('ask.no') %>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<%= ask_setting.custom_fields.collect do |k,v|
|
||||
required_pattern = v['required']=='true' ? '*' : ''
|
||||
"<div class=\"control-group\">
|
||||
<label class=\"control-label\">#{required_pattern}#{v['field'][I18n.locale]}</label>
|
||||
<div class=\"controls\">
|
||||
#{show_on_front(k,v,@ask_question,true)}
|
||||
<div class="row-fluid">
|
||||
<div id="ask-asks" class="span8">
|
||||
<div class="row-fluid">
|
||||
<div class="span4"><%= AskQuestion.human_attribute_name(:name) %>:<%= @ask_question.name %></div>
|
||||
<div class="span4"><%= AskQuestion.human_attribute_name(:mail) %>:<%= @ask_question.mail %></div>
|
||||
<div class="span4"><%= AskQuestion.human_attribute_name(:phone) %>:<%= @ask_question.phone %></div>
|
||||
</div>
|
||||
<% ask_setting.custom_fields.each do |k,v| %>
|
||||
<%
|
||||
required_pattern = v['required']=='true' ? '*' : ''
|
||||
%>
|
||||
<div class="control-group">
|
||||
<label class="control-label">
|
||||
<%= required_pattern %>
|
||||
<%= v['field'][I18n.locale] %>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= show_on_front(k,v,@ask_question,true) %>
|
||||
</div>
|
||||
</div>"
|
||||
end.join.html_safe %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t('ask.serial_number') %></label>
|
||||
<div class="controls">
|
||||
<%= @ask_question.get_serial_number %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t('ask.ip') %></label>
|
||||
<div class="controls">
|
||||
<%= @ask_question.ip %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t('title') %></label>
|
||||
<div class="controls">
|
||||
<%= @ask_question.title %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<% if ask_setting.default_setting['appointment'] %>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted">
|
||||
<%= AskQuestion.human_attribute_name(:appointment) %>
|
||||
</label>
|
||||
<div class="controls">
|
||||
<%= @ask_question.appointment.strftime("%Y-%m-%d %H:%M") if @ask_question.appointment %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% if !@ask_question.comment.blank? %>
|
||||
<div class="control-group">
|
||||
<%= f.label :comment, class: "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= @ask_question.comment %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<div class="control-group">
|
||||
<%= f.label :agree_show, class: "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= @ask_question.agree_show ? t('ask.yes') : t('ask.no') %>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<%= f.label t('situation'), class: "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.select :situation, AskTicketStatus.default_sorting.map{|a| [a.title, a.key] } %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:tags) %></label>
|
||||
<%= select_tags(f, @module_app) %>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<%= f.label :send_email, class: "control-label muted" %>
|
||||
|
||||
<div class="controls">
|
||||
<label class="radio inline">
|
||||
<%= f.radio_button :send_email, 1 %>
|
||||
<%= t('ask.system_Email') %>
|
||||
</label>
|
||||
|
||||
<label class="radio inline">
|
||||
<%= f.radio_button :send_email, 0 %>
|
||||
<%= t('ask.no') %>
|
||||
</label>
|
||||
|
||||
<label class="radio inline">
|
||||
<%= f.radio_button :send_email, 2 %>
|
||||
<%= t('ask.phone') %>
|
||||
</label>
|
||||
|
||||
<label class="radio inline">
|
||||
<%= f.radio_button :send_email, 3 %>
|
||||
<%= t('ask.fax') %>
|
||||
</label>
|
||||
|
||||
<label class="radio inline">
|
||||
<%= f.radio_button :send_email, 4 %>
|
||||
<%= t('ask.paper') %>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<%= f.label :reply, class: "control-label muted" %>
|
||||
<div class="controls">
|
||||
<%= f.text_area :reply, rows: 10, style: 'max-width: 500px; width: 100%;' %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= f.label :comment %></label>
|
||||
<div class="controls">
|
||||
<%= f.text_area :release_comment, :id => "#{f.object_name}_comment" %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t(:file_) %></label>
|
||||
<div class="controls">
|
||||
<%= f.file_field :release_file %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="span4">
|
||||
<!-- 顯示歷史紀錄 -->
|
||||
<div class="history-records">
|
||||
<h3><%= t('history_records') %></h3>
|
||||
<% if f.object.ask_status_histories.present? %>
|
||||
<% status_mapping = AskTicketStatus.default_sorting.map{|a| [a.key, a.title]}.to_h %>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th><%= t('status') %></th>
|
||||
<th><%= t('ask.modified_by') %></th>
|
||||
<th><%= t('ask.remark') %></th>
|
||||
<th><%= t('ask.attachment') %></th>
|
||||
<th><%= t('ask.updated_at') %></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% f.object.ask_status_histories.each do |ask_status_history| %>
|
||||
<tr>
|
||||
<td>
|
||||
<%= status_mapping[ask_status_history.status] %>
|
||||
</td>
|
||||
<td>
|
||||
<%= ask_status_history.modified_by_name %>
|
||||
</td>
|
||||
<td>
|
||||
<%= ask_status_history.comment %>
|
||||
</td>
|
||||
<td>
|
||||
<%= link_to(ask_status_history[:file], ask_status_history.file.url) if ask_status_history.file.present? %>
|
||||
</td>
|
||||
<td>
|
||||
<%= ask_status_history.created_at.strftime("%Y-%m-%d %H:%M:%S") %>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<% else %>
|
||||
<p><%= t('no_history_records') %></p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<%
|
||||
|
|
|
@ -182,7 +182,6 @@
|
|||
situation_class_relation = {
|
||||
"is_waiting"=>"label-important",
|
||||
"is_processed"=>"label-warning",
|
||||
"is_referral"=>"",
|
||||
"is_published"=>"label-success"
|
||||
}
|
||||
situation_trans = AskTicketStatus.all.map{|a| [a.key, a.title]}.to_h
|
||||
|
@ -203,7 +202,7 @@
|
|||
<% when 'serial_number' %>
|
||||
<%= b.get_serial_number(last_serial_number, display_length) %>
|
||||
<% when 'situation' %>
|
||||
<span class='label <%=situation_class_relation[b.situation]%>'><%= situation_trans[b.situation] %></span>
|
||||
<span class='label <%= situation_class_relation[b.situation].to_s %>'><%= situation_trans[b.situation] %></span>
|
||||
<% when 'ask_category_id' %>
|
||||
<%= b.category.title rescue 'category not set' %>
|
||||
<% when 'sex' %>
|
||||
|
|
|
@ -31,6 +31,16 @@
|
|||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><%= t("ask.validation_email_content") %>:</td>
|
||||
<td>
|
||||
<%= check_box_tag :validate_enable, @default_ask_setting.validate_enable , nil, {:id=>"",:disabled=>'disabled'} %><%= t("ask.enable") %>
|
||||
<div style="clear: both;"></div>
|
||||
<div class="show_field">
|
||||
<%= @default_ask_setting.validation_email_content %>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>
|
||||
<%= t('ask.field') %>
|
||||
|
|
|
@ -7,7 +7,15 @@
|
|||
<p>
|
||||
<%= @data['reply'].to_s.gsub(/[(\n)(\r)]/, "\n" => "<br/>", "\r" => "" ).html_safe %>
|
||||
</p>
|
||||
<% attachment = @data['attachment']
|
||||
if attachment.present? %>
|
||||
<% filename = File.basename(attachment) %>
|
||||
<p>
|
||||
<%= t('ask.attachment') %>:
|
||||
<a title="<%= filename %>" target="_blank" href="<%= @data['host_url'] + attachment %>"><%= filename %></a>
|
||||
</p>
|
||||
<% end %>
|
||||
<br />
|
||||
<p>此為系統自動發信,請勿直接回覆</p>
|
||||
<p><%= t('ask.email_automation_hint') %></p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,15 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
|
||||
</head>
|
||||
<body>
|
||||
<p>
|
||||
<%= @data['validation_email_content'].to_s.gsub(/[(\n)(\r)]/, "\n" => "<br/>", "\r" => "" ).html_safe %>
|
||||
</p>
|
||||
<br />
|
||||
<%= @data['verify_link'].html_safe %>
|
||||
<br />
|
||||
<p><%= t('ask.email_automation_hint') %></p>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<style>
|
||||
.error_msg {
|
||||
color: red;
|
||||
}
|
||||
.success_msg {
|
||||
color: green;
|
||||
}
|
||||
</style>
|
||||
<% if @already_verify %>
|
||||
<div class="error_msg"><%= t('ask.this_link_has_expired') %></div>
|
||||
<% else %>
|
||||
<div class="success_msg"><%= t('ask.verify_success') %></div>
|
||||
<% end %>
|
|
@ -47,6 +47,10 @@ en:
|
|||
please_check_email_format: "Please check email format!"
|
||||
enable: Enable
|
||||
email_regex: Email validation regex
|
||||
verify_link: Verify link
|
||||
validation_email_content: Validation Email Content
|
||||
email_verification_notification: Email verification notification
|
||||
email_automation_hint: "This is an automatic email sent by the system, please do not reply directly."
|
||||
please_save: Please click "Save Order" button when you done.
|
||||
save_order: Save Order
|
||||
order_fields: Order Fields
|
||||
|
@ -88,12 +92,17 @@ en:
|
|||
upload_image: Upload Image
|
||||
no_index_page: There are no page for ask module created at site struture.
|
||||
thank_text: We will reply as soon as posible,thank you.
|
||||
is_email_not_confirmed: Email Not Confirmed
|
||||
is_waiting: Pending
|
||||
is_processed: Processed
|
||||
is_referral: Rreferral
|
||||
is_published: Processed and Published
|
||||
'yes': 'Yes'
|
||||
'no': 'No'
|
||||
system_Email: System Email
|
||||
phone: Phone
|
||||
fax: Fax
|
||||
paper: Paper
|
||||
required: Required
|
||||
datepicker: Select a Date
|
||||
enable_range_setting: Enable Time Range Setting
|
||||
|
@ -122,6 +131,12 @@ en:
|
|||
acknowledgements: Thank You
|
||||
admins: Administrator
|
||||
new_question: New question
|
||||
verify_success: "Verify Successfully!"
|
||||
this_link_has_expired: "This Link has been clicked and expired!"
|
||||
modified_by: Modified by
|
||||
remark: Remark
|
||||
attachment: Attachment
|
||||
updated_at: Updated at
|
||||
|
||||
mongoid:
|
||||
attributes:
|
||||
|
|
|
@ -51,6 +51,10 @@ zh_tw:
|
|||
please_check_email_format: "請檢察email是否正確!"
|
||||
enable: 啟用
|
||||
email_regex: Email驗證regex
|
||||
verify_link: 驗證連結
|
||||
validation_email_content: 驗證信內容
|
||||
email_verification_notification: 電子郵件驗證通知
|
||||
email_automation_hint: "此為系統自動發信,請勿直接回覆"
|
||||
please_save: 調整完後, 請點選"儲存順序"
|
||||
save_order: 儲存順序
|
||||
order_fields: 排序欄位
|
||||
|
@ -91,12 +95,17 @@ zh_tw:
|
|||
upload_image: 上傳圖片
|
||||
no_index_page: 前台頁面尚未被建立,請前往網站架構設定,謝謝。
|
||||
thank_text: 我們已經收到您的預約,期待您的蒞臨,謝謝
|
||||
is_email_not_confirmed: Email未驗證
|
||||
is_waiting: 待處理
|
||||
is_processed: 已處理
|
||||
is_referral: 轉介其他單位
|
||||
is_published: 已處理並發佈網頁
|
||||
'yes': 是
|
||||
'no': 否
|
||||
system_Email: 系統發信
|
||||
phone: 電話
|
||||
fax: 傳真
|
||||
paper: 回覆函
|
||||
required: 必填
|
||||
datepicker: 選擇日期
|
||||
enable_range_setting: 啟用時間區段設定
|
||||
|
@ -132,6 +141,12 @@ zh_tw:
|
|||
acknowledgements: 感謝詞
|
||||
admins: 管理者
|
||||
new_question: 新的發問
|
||||
verify_success: "驗證成功"
|
||||
this_link_has_expired: "此連結已經點選並已失效!"
|
||||
modified_by: 修改者
|
||||
remark: 備註
|
||||
attachment: 附件
|
||||
updated_at: 更新時間
|
||||
|
||||
mongoid:
|
||||
attributes:
|
||||
|
|
|
@ -5,7 +5,7 @@ Rails.application.routes.draw do
|
|||
AskPrintSetting.create() if AskPrintSetting.count == 0
|
||||
s = OrbitHelper::SharedHash['current_site']['site'] rescue Site.first
|
||||
update_flag = s.respond_to?(:tmp_flags)
|
||||
need_update = !update_flag || !(s.tmp_flags.include?('askf1'))
|
||||
need_update = !update_flag || !(s.tmp_flags.include?('askf4'))
|
||||
need_update2 = !update_flag || !(s.tmp_flags.include?('askf3'))
|
||||
if need_update
|
||||
ask_setting = AskSetting.first
|
||||
|
@ -31,7 +31,7 @@ Rails.application.routes.draw do
|
|||
ask_setting.save
|
||||
end
|
||||
default_keys = AskTicketStatus::DefaultKeys
|
||||
if AskTicketStatus.count < default_keys.count
|
||||
if AskTicketStatus.where(:key.in => default_keys).count < default_keys.count
|
||||
default_keys.each do |k|
|
||||
ticket_status = AskTicketStatus.where(:is_default=>true,:key=>k).first
|
||||
if ticket_status.nil?
|
||||
|
@ -45,7 +45,7 @@ Rails.application.routes.draw do
|
|||
a.save
|
||||
end
|
||||
if update_flag
|
||||
Site.update_all("$push"=>{"tmp_flags"=>'askf1'})
|
||||
Site.update_all("$push"=>{"tmp_flags"=>'askf4'})
|
||||
end
|
||||
elsif need_update2
|
||||
([AskSetting.first] + AskCategorySetting.all.to_a).each do |a|
|
||||
|
@ -96,6 +96,7 @@ Rails.application.routes.draw do
|
|||
resources :ask_admins
|
||||
end
|
||||
resources :asks #fronted
|
||||
get "/xhr/asks/verify_email/:id" => "asks#verify_email"
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -112,6 +112,8 @@ module Ask
|
|||
end
|
||||
end
|
||||
fix_reviewer
|
||||
AskQuestion.where(send_email: false).update_all(send_email: 0)
|
||||
AskQuestion.where(send_email: true).update_all(send_email: 1)
|
||||
OrbitApp.registration "Ask", :type => "ModuleApp" do
|
||||
module_label "ask.ask"
|
||||
base_url File.expand_path File.dirname(__FILE__)
|
||||
|
@ -122,7 +124,7 @@ module Ask
|
|||
end
|
||||
widget_methods ["widget"]
|
||||
widget_settings [{"data_count"=>10}]
|
||||
# taggable "AskQuestion"
|
||||
taggable "AskQuestion"
|
||||
begin
|
||||
show_option_items data_item
|
||||
rescue => e
|
||||
|
@ -144,13 +146,6 @@ module Ask
|
|||
:priority=>1,
|
||||
:active_for_action=>{'admin/asks'=>'index'},
|
||||
:available_for => 'users'
|
||||
# context_link 'tags',
|
||||
# :link_path=>"admin_module_app_tags_path" ,
|
||||
# :link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ask').id}",
|
||||
# :priority=>4,
|
||||
# :active_for_action=>{'admin/ask'=>'tags'},
|
||||
# :active_for_tag => 'Ask',
|
||||
# :available_for => 'managers'
|
||||
context_link 'ask.setting',
|
||||
:link_path=>"setting_admin_asks_path" ,
|
||||
:priority=>2,
|
||||
|
@ -183,6 +178,13 @@ module Ask
|
|||
:active_for_action=>{'admin/asks'=>'categories'},
|
||||
:active_for_category => 'Ask',
|
||||
:available_for => 'managers'
|
||||
context_link 'tags',
|
||||
:link_path=>"admin_module_app_tags_path" ,
|
||||
:link_arg=>"{:module_app_id=>ModuleApp.find_by(:key=>'ask').id}",
|
||||
:priority=>7,
|
||||
:active_for_action=>{'admin/ask'=>'tags'},
|
||||
:active_for_tag => 'Ask',
|
||||
:available_for => 'managers'
|
||||
context_link 'ask.acknowledgements',
|
||||
:link_path=>"admin_ask_acknowledgements_path" ,
|
||||
:priority=>8,
|
||||
|
|
Loading…
Reference in New Issue