Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
spen | 8af795e2ac |
|
@ -7,6 +7,7 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
|
|||
|
||||
|
||||
def preview_and_approve
|
||||
email_group_data
|
||||
@email_er = EmailEr.find params[:email_er_id]
|
||||
end
|
||||
|
||||
|
@ -72,23 +73,39 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
|
|||
|
||||
@user = User.find(email_er.create_user_id)
|
||||
|
||||
@group_mail = MailCron.get_send_group_mail( email_er.email_user_ids , email_er.other_mailaddress )
|
||||
email_group_data
|
||||
|
||||
@group_mail = Array.new
|
||||
|
||||
email_er.email_group.each do |egroup|
|
||||
|
||||
if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
|
||||
|
||||
@group_mail << @email_group_data[egroup]["email"]
|
||||
|
||||
elsif @email_group_data.include?(egroup) and egroup == 'e_4'
|
||||
|
||||
@group_mail << email_er.other_mailaddress
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
if !@group_mail.join.blank?
|
||||
|
||||
@mail_content = {
|
||||
"lang" => I18n.locale,
|
||||
"text" => email_er.mail_content
|
||||
}
|
||||
|
||||
@mail_cron = {
|
||||
:mail_from_app => 'er_email',
|
||||
# :mail_from => @user.email,
|
||||
# :mail_reply_to => @user.email,
|
||||
:mail_from => @user.email,
|
||||
:mail_reply_to => @user.email,
|
||||
:mail_subject => email_er.mail_subject,
|
||||
:mail_to => @group_mail.join(','),
|
||||
:mail_content => @mail_content ,
|
||||
:mail_sentdate => email_er.mail_sentdate,
|
||||
# :mail_sentdate => email_er.mail_sentdate,
|
||||
:mail_sentdate => DateTime.now,
|
||||
:create_user_id => email_er.create_user_id,
|
||||
:update_user_id => email_er.create_user_id
|
||||
}
|
||||
|
@ -114,7 +131,15 @@ class Panel::ErEmail::BackEnd::ApprovalsController < OrbitBackendController
|
|||
|
||||
@mail_cron.save
|
||||
|
||||
end
|
||||
MailCron.send_mail_now(@mail_cron.id)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def email_group_data
|
||||
|
||||
@email_group_data = EmailEr.email_group_data
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
end
|
||||
|
||||
def index
|
||||
email_group_data
|
||||
|
||||
@categories = get_categories_for_index
|
||||
@statuses = get_statuses
|
||||
|
@ -41,6 +42,8 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
|
||||
def show
|
||||
|
||||
email_group_data
|
||||
|
||||
@item = Page.find(params[:page_id]) rescue nil
|
||||
if params[:preview] == "true"
|
||||
preview_content
|
||||
|
@ -70,6 +73,8 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
# GET /email_ers/new.xml
|
||||
def new
|
||||
|
||||
email_group_data
|
||||
|
||||
@email_er = EmailEr.new(:mail_sentdate => DateTime.now)
|
||||
|
||||
respond_to do |format|
|
||||
|
@ -81,13 +86,13 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
# GET /email_ers/1/edit
|
||||
def edit
|
||||
|
||||
@email_er = EmailEr.find(params[:id])
|
||||
email_group_data
|
||||
|
||||
@email_users = @email_er.get_email_users
|
||||
@email_er = EmailEr.find(params[:id])
|
||||
|
||||
is_authorized_sub_manager = @email_er.category.auth_sub_manager.authorized_user_ids rescue nil
|
||||
|
||||
if !(is_manager? || is_admin? || is_authorized_sub_manager.include?(current_user.id))
|
||||
if !(is_manager? || is_admin? || (is_authorized_sub_manager.include?(current_user.id) and @email_er.create_user_id == current_user.id))
|
||||
redirect_to :action => :index
|
||||
else
|
||||
# @summary_variable = @bulletin.summary_variable
|
||||
|
@ -103,8 +108,7 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
# POST /email_ers.xml
|
||||
def create
|
||||
|
||||
params[:email_er][:email_user_ids] = params[:email_er][:email_user_ids].uniq
|
||||
params[:email_er][:email_user_ids].delete('')
|
||||
email_group_data
|
||||
|
||||
@email_er = EmailEr.new(params[:email_er])
|
||||
@email_er.create_user_id = current_user.id
|
||||
|
@ -147,10 +151,9 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
# PUT /email_ers/1.xml
|
||||
def update
|
||||
|
||||
@email_er = EmailEr.find(params[:id])
|
||||
email_group_data
|
||||
|
||||
params[:email_er][:email_user_ids] = params[:email_er][:email_user_ids].uniq
|
||||
params[:email_er][:email_user_ids].delete('')
|
||||
@email_er = EmailEr.find(params[:id])
|
||||
|
||||
@email_er.update_user_id = current_user.id
|
||||
|
||||
|
@ -232,33 +235,45 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
|
||||
if !test_send
|
||||
|
||||
@group_mail = MailCron.get_send_group_mail( email_er.email_user_ids , email_er.other_mailaddress )
|
||||
email_group_data
|
||||
|
||||
@mail_sentdate = email_er.mail_sentdate
|
||||
@group_mail = Array.new
|
||||
|
||||
email_er.email_group.each do |egroup|
|
||||
|
||||
if @email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
|
||||
|
||||
@group_mail << @email_group_data[egroup]["email"]
|
||||
|
||||
elsif @email_group_data.include?(egroup) and egroup == 'e_4'
|
||||
|
||||
@group_mail << email_er.other_mailaddress
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
|
||||
@group_mail = [@user.email]
|
||||
|
||||
@mail_sentdate = DateTime.now
|
||||
|
||||
end
|
||||
|
||||
if !@group_mail.join.blank?
|
||||
|
||||
@mail_content = {
|
||||
"lang" => I18n.locale,
|
||||
"text" => email_er.mail_content
|
||||
}
|
||||
|
||||
@mail_cron = {
|
||||
:mail_from_app => 'er_email',
|
||||
# :mail_from => @user.email,
|
||||
# :mail_reply_to => @user.email,
|
||||
:mail_from => @user.email,
|
||||
:mail_reply_to => @user.email,
|
||||
:mail_subject => email_er.mail_subject,
|
||||
:mail_to => @group_mail.join(','),
|
||||
:mail_content => @mail_content ,
|
||||
:mail_sentdate => @mail_sentdate,
|
||||
# :mail_sentdate => email_er.mail_sentdate,
|
||||
:mail_sentdate => DateTime.now,
|
||||
:create_user_id => email_er.create_user_id,
|
||||
:update_user_id => email_er.create_user_id
|
||||
}
|
||||
|
@ -284,7 +299,7 @@ class Panel::ErEmail::BackEnd::EmailErsController < OrbitBackendController
|
|||
|
||||
@mail_cron.save
|
||||
|
||||
MailCron.send_mail_now(@mail_cron.id) if test_send
|
||||
MailCron.send_mail_now(@mail_cron.id)
|
||||
|
||||
end
|
||||
|
||||
|
|
|
@ -18,9 +18,6 @@ class EmailEr
|
|||
field :mail_sentdate , :type => DateTime
|
||||
field :mail_content
|
||||
|
||||
field :email_user_ids
|
||||
field :other_mailaddress
|
||||
|
||||
field :create_user_id
|
||||
field :update_user_id
|
||||
|
||||
|
@ -30,6 +27,9 @@ class EmailEr
|
|||
|
||||
field :not_checked_reason
|
||||
|
||||
field :email_group, :type => Array, default: []
|
||||
field :other_mailaddress
|
||||
|
||||
scope :can_display,where(is_hidden: false)
|
||||
|
||||
has_many :email_er_files, :autosave => true, :dependent => :destroy
|
||||
|
@ -71,6 +71,33 @@ class EmailEr
|
|||
!self.is_pending && self.is_rejected && (self.is_rejected == true)
|
||||
end
|
||||
|
||||
def get_email_group_data(email_group_data)
|
||||
|
||||
group_mail = Array.new
|
||||
|
||||
self.email_group.each do |egroup|
|
||||
|
||||
if email_group_data.include?(egroup) and (egroup == 'e_0' or egroup == 'e_1' or egroup == 'e_2' or egroup == 'e_3')
|
||||
|
||||
#group_mail << "#{email_group_data[egroup]["email"]}(#{email_group_data[egroup]["name"]})"
|
||||
group_mail << "#{email_group_data[egroup]["name"]}"
|
||||
|
||||
elsif email_group_data.include?(egroup) and egroup == 'e_4'
|
||||
|
||||
self.other_mailaddress.split(",").each do |otmail|
|
||||
|
||||
group_mail << "#{otmail}(#{email_group_data[egroup]["name"]})"
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
group_mail.join("<br />").html_safe
|
||||
|
||||
end
|
||||
|
||||
def to_preview
|
||||
preview_object = Preview.new(:expired_at=>DateTime.now+30.minutes,:preview_at_link=>"panel_er_email_back_end_email_er_path",:object_class_type=>"EmailEr")
|
||||
|
||||
|
@ -82,8 +109,18 @@ class EmailEr
|
|||
preview_object
|
||||
end
|
||||
|
||||
def get_email_users
|
||||
User.find(self.email_user_ids) rescue []
|
||||
protected
|
||||
|
||||
def self.email_group_data
|
||||
|
||||
@email_group_data = {
|
||||
'e_0'=> {"name"=>I18n.t('er_email.email_group_data_0'), "email"=>"alluser@tea.ntue.edu.tw"},
|
||||
'e_1'=> {"name"=>I18n.t('er_email.email_group_data_1'), "email"=>"allstu@tea.ntue.edu.tw"},
|
||||
'e_2'=> {"name"=>I18n.t('er_email.email_group_data_2'), "email"=>"allgrad@tea.ntue.edu.tw"},
|
||||
'e_3'=> {"name"=>I18n.t('er_email.email_group_data_3'), "email"=>"allad@tea.ntue.edu.tw"},
|
||||
'e_4'=> {"name"=>I18n.t('er_email.email_group_data_4')}
|
||||
}
|
||||
|
||||
end
|
||||
|
||||
end
|
|
@ -15,9 +15,9 @@
|
|||
<br />
|
||||
<% end %>
|
||||
|
||||
<% if !@email_er.email_user_ids.blank? || !@email_er.other_mailaddress.blank? %>
|
||||
<%= label_tag t('er_email.mail_to') %>
|
||||
<%= MailCron.get_send_group_mail(@email_er.email_user_ids , @email_er.other_mailaddress).join("<br />").html_safe %>
|
||||
<% if !@email_er.email_group.blank? %>
|
||||
<%= label_tag 'group_mail' %>
|
||||
<%= @email_er.get_email_group_data(@email_group_data) %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="modal-right">
|
||||
|
|
|
@ -5,13 +5,10 @@
|
|||
<%= stylesheet_link_tag "lib/main-list" %>
|
||||
<% end %>
|
||||
<% content_for :page_specific_javascript do %>
|
||||
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
||||
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
||||
<%= javascript_include_tag "lib/bootstrap-fileupload" %>
|
||||
<%= javascript_include_tag "lib/modal-preview" %>
|
||||
<%= javascript_include_tag "lib/file-type" %>
|
||||
<%= javascript_include_tag "lib/module-area" %>
|
||||
<%= javascript_include_tag "member-selection" %>
|
||||
<% end %>
|
||||
|
||||
<%= f.error_messages %>
|
||||
|
@ -26,6 +23,9 @@
|
|||
<li class="active">
|
||||
<a href="#basic" data-toggle="tab"><%= t(:basic) %></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="#mail-group" data-toggle="tab"><%= t('er_email.email_group')%></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Module -->
|
||||
|
@ -42,19 +42,25 @@
|
|||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mail Sentdate -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("er_email.mail_sentdate") %></label>
|
||||
<div class="controls">
|
||||
<%= f.datetime_picker :mail_sentdate, :no_label => true %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Mail Group Module -->
|
||||
<div class="tab-pane fade" id="mail-group">
|
||||
|
||||
<!-- Mail Group -->
|
||||
<div class="control-group">
|
||||
<label class="control-label muted"><%= t("er_email.mail_to") %></label>
|
||||
<label class="control-label muted"><%= t("er_email.email_group") %></label>
|
||||
<div class="controls">
|
||||
<%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'email_er[email_user_ids][]', users: @email_users} %>
|
||||
|
||||
<% @email_group_data.collect do |k,v| %>
|
||||
|
||||
<label class="checkbox inline">
|
||||
<%= check_box_tag 'email_er[email_group][]', k, (@email_er.email_group.nil? ? false : @email_er.email_group.include?(k)), :id => "field-#{k}" %> <%= v["name"] %>
|
||||
<%= hidden_field_tag 'email_er[email_group][]', '' %>
|
||||
</label>
|
||||
|
||||
<% end if !@email_group_data.blank? %>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
|
|
|
@ -7,7 +7,6 @@
|
|||
objects @email_ers
|
||||
quick_edit_link type: 'edit',
|
||||
link: 'edit_panel_er_email_back_end_email_er_path'
|
||||
quick_edit_link type: 'detail'
|
||||
quick_edit_link type: 'test_send_email',
|
||||
define_link: 'test_send_email_panel_er_email_back_end_email_ers_path(:id=>object.id)',
|
||||
condition_option: 'object.is_pending',
|
||||
|
@ -18,7 +17,7 @@
|
|||
quick_edit_link type: 'email_resend',
|
||||
define_link: 'email_resend_panel_er_email_back_end_email_ers_path(:id=>object.id)',
|
||||
condition_option: 'object.is_checked and !object.is_rejected',
|
||||
translation: 'er_email.mail_resend'
|
||||
translation: 'er_email.email_resend'
|
||||
quick_edit_link type: 'approval',
|
||||
link: 'panel_er_email_back_end_email_er_approval_preview_path'
|
||||
quick_edit_link type: 'reject_reason'
|
||||
|
@ -26,32 +25,23 @@
|
|||
db_field: @statuses,
|
||||
translation: 'status',
|
||||
hide: 'phone',
|
||||
sort: 'status',
|
||||
header_class: 'span2'
|
||||
sort: 'status'
|
||||
field type: 'associated',
|
||||
db_field: 'category',
|
||||
model_field: 'title',
|
||||
translation: 'category',
|
||||
hide: 'phone',
|
||||
sort: 'category',
|
||||
header_class: 'span2'
|
||||
sort: 'category'
|
||||
field db_field: 'mail_subject',
|
||||
translation: 'er_email.mail_subject',
|
||||
sort: 'mail_subject',
|
||||
quick_edit: true,
|
||||
header_class: 'span8'
|
||||
field db_field: 'email_user_ids',
|
||||
hide: 'all',
|
||||
translation: 'er_email.mail_to',
|
||||
display_option: '"<br />#{MailCron.get_send_group_mail(object.email_user_ids , object.other_mailaddress).join(", ").html_safe}"',
|
||||
sort: 'email_user_ids'
|
||||
field type: 'id',
|
||||
db_field: 'create_user_id',
|
||||
model: User,
|
||||
model_field: 'name',
|
||||
translation: 'er_email.created_user',
|
||||
header_class: 'span5'
|
||||
field db_field: 'email_group',
|
||||
translation: 'er_email.email_group',
|
||||
display_option: 'object.get_email_group_data(@email_group_data)',
|
||||
hide: 'phone',
|
||||
sort: 'create_user_id'
|
||||
sort: 'email_group'
|
||||
|
||||
footer link: 'new_panel_er_email_back_end_email_er_path'
|
||||
end %>
|
||||
|
|
|
@ -10,14 +10,18 @@ en:
|
|||
approve_email_er_fail: Approval Fail
|
||||
approve_email_er_success: Approve Successfully
|
||||
create_email_er_success: Create Successfully
|
||||
mail_resend: Resend
|
||||
email_resend: Resend
|
||||
test_send_email: Test Send Email
|
||||
mail_subject: Mail Subject
|
||||
mail_content: Mail Content
|
||||
mail_sentdate: Email Time
|
||||
mail_to: Email To
|
||||
email_group: Email Group
|
||||
email_group_data_0: All Faculty
|
||||
email_group_data_1: Undergraduates
|
||||
email_group_data_2: Postgraduates
|
||||
email_group_data_3: Continuing Ed. Postgraduates
|
||||
email_group_data_4: Other
|
||||
other_mailaddress: Other Email
|
||||
other_mailaddress_note: Divide different email accounts with ","
|
||||
other_mailaddress_note_limit: maximum 1000 characters
|
||||
email_file_limit: File upload size is limited to 1MB
|
||||
created_user: Creator
|
|
@ -10,14 +10,18 @@ zh_tw:
|
|||
approve_email_er_fail: 審核失敗
|
||||
approve_email_er_success: 審核成功
|
||||
create_email_er_success: 建立資料成功
|
||||
mail_resend: 重新寄送
|
||||
email_resend: 重新寄送
|
||||
test_send_email: 測試寄信
|
||||
mail_subject: 主旨
|
||||
mail_content: 信件內容
|
||||
mail_sentdate: 寄送時間
|
||||
mail_to: 寄送對象
|
||||
email_group: 寄送群組
|
||||
other_mailaddress: 其他Mail
|
||||
other_mailaddress_note: 輸入多組mail時,請用","逗號隔開
|
||||
other_mailaddress_note_limit: 限制1000字元以內
|
||||
email_group_data_0: 全校教職員
|
||||
email_group_data_1: 大學部學生
|
||||
email_group_data_2: 日間部研究生
|
||||
email_group_data_3: 進修部研究生
|
||||
email_group_data_4: 其他
|
||||
email_file_limit: 檔案上傳容量限制為10MB
|
||||
created_user: 建立者
|
Loading…
Reference in New Issue