finish email reminder
This commit is contained in:
parent
04bbebe1ed
commit
4f9cd8e40f
|
@ -0,0 +1,11 @@
|
|||
# encoding: utf-8
|
||||
class Admin::VenueAdminController < OrbitAdminController
|
||||
#alias_method :org_datetime_picker, :datetime_picker
|
||||
#include OrbitFormHelper
|
||||
def initialize(*)
|
||||
super
|
||||
ActionView::Helpers::FormBuilder.send(:prepend,VenueAdminHelper)
|
||||
@venue = 'venue'
|
||||
end
|
||||
|
||||
end
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Admin::VenueManagementContractsController < OrbitAdminController
|
||||
class Admin::VenueManagementContractsController < Admin::VenueAdminController
|
||||
include Admin::VenueManagementsHelper
|
||||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
before_action :set_venue_management_contract, only: [:edit, :update, :destroy]
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class Admin::VenueManagementInvitingsController < OrbitAdminController
|
||||
class Admin::VenueManagementInvitingsController < Admin::VenueAdminController
|
||||
include Admin::VenueManagementsHelper
|
||||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
before_action :set_venue_management_inviting, only: [:edit, :update, :destroy]
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Admin::VenueManagementMemorabiliasController < OrbitAdminController
|
||||
class Admin::VenueManagementMemorabiliasController < Admin::VenueAdminController
|
||||
include Admin::VenueManagementsHelper
|
||||
before_action ->(module_app = @app_title) { set_variables module_app }
|
||||
before_action :set_venue_management_memorabilia, only: [:edit, :update, :destroy]
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
# encoding: utf-8
|
||||
class Admin::VenueManagementsController < OrbitAdminController
|
||||
class Admin::VenueManagementsController < Admin::VenueAdminController
|
||||
|
||||
require 'axlsx'
|
||||
helper Admin::VenueManagementsFieldHelper
|
||||
|
|
|
@ -0,0 +1,26 @@
|
|||
module VenueAdminHelper
|
||||
include OrbitFormHelper
|
||||
alias :org_datetime_picker :datetime_picker
|
||||
def datetime_picker(*arg,**args)
|
||||
tp = org_datetime_picker(*arg,**args)
|
||||
venue = @template.instance_variable_get(:@venue)
|
||||
if !venue.nil?
|
||||
style_attr = ''
|
||||
if !@object.send(arg[0].to_s+'_reminder')
|
||||
style_attr = " style=\"display: none;\""
|
||||
end
|
||||
onclick_func = "function reminder_switch(ele){
|
||||
if ($(ele).prop('checked')){
|
||||
$(ele).parents('.controls').find('.email_reminder').show()
|
||||
}else{
|
||||
$(ele).parents('.controls').find('.email_reminder').hide()
|
||||
}
|
||||
};reminder_switch(this)"
|
||||
tp2 = content_tag(:div, :style => "float: left;flex-wrap: wrap;display: inline-flex;margin-left: 1em;align-items: center;") do
|
||||
self.check_box((arg[0].to_s+'_reminder').to_sym,:onclick => onclick_func) + "寄送Email提醒<div class=\"email_reminder\"#{style_attr}>: 提前#{self.number_field((arg[0].to_s+'_reminder_day').to_sym, :class => 'input-mini')}天寄送</div>".html_safe
|
||||
end
|
||||
tp = content_tag(:div, tp , :style=>"float: left;")+ tp2
|
||||
end
|
||||
tp
|
||||
end
|
||||
end
|
|
@ -1,6 +1,18 @@
|
|||
module VenueLinkFile
|
||||
extend ActiveSupport::Concern
|
||||
module VenueMethod
|
||||
def get_trans(field)
|
||||
class_name = self.class.to_s
|
||||
if class_name == 'VenueManagementMain'
|
||||
I18n.t("venue_management.#{field}")
|
||||
else
|
||||
class_name = class_name.underscore.gsub('venue_management','vm')
|
||||
I18n.t("#{class_name}.#{field}")
|
||||
end
|
||||
end
|
||||
end
|
||||
included do
|
||||
self.include VenueMethod
|
||||
tmp = self.to_s.underscore.to_sym
|
||||
VenueManagementFile.send(:belongs_to,tmp, :class_name => self.to_s, :foreign_key => "#{tmp}_id")
|
||||
VenueManagementLink.send(:belongs_to,tmp, :class_name => self.to_s, :foreign_key => "#{tmp}_id")
|
||||
|
@ -8,5 +20,48 @@ module VenueLinkFile
|
|||
self.accepts_nested_attributes_for :venue_management_files, :allow_destroy => true
|
||||
self.has_many :venue_management_links, :autosave => true, :dependent => :destroy
|
||||
self.accepts_nested_attributes_for :venue_management_links, :allow_destroy => true
|
||||
self.fields.values.each do|v|
|
||||
if v.type==Date || v.type==DateTime
|
||||
self.field v.name+'_reminder', type: Boolean,default: false
|
||||
self.field v.name+'_reminder_day', type: Integer
|
||||
end
|
||||
end
|
||||
self.has_many :venue_management_emails, :autosave => true, :dependent => :destroy
|
||||
self.accepts_nested_attributes_for :venue_management_emails, :allow_destroy => true
|
||||
VenueManagementEmail.send(:belongs_to,tmp, :class_name => self.to_s, :foreign_key => "#{tmp}_id")
|
||||
self.before_save do
|
||||
self.venue_management_emails.each do |venue_mail|
|
||||
email = venue_mail.email
|
||||
if !email.nil?
|
||||
email.destroy
|
||||
end
|
||||
end
|
||||
self.venue_management_emails = []
|
||||
venue_main = self.class.to_s == 'VenueManagementMain' ? self : VenueManagementMain.find(self.venue_management_main_id)
|
||||
manager_emails = venue_main.manager_emails
|
||||
self.fields.values.each do|v|
|
||||
if v.type==Date || v.type==DateTime
|
||||
if self.send(v.name+'_reminder')
|
||||
title = venue_main.title + ' ' + self.case_no.to_s + ' ' + self.get_trans(v.name)
|
||||
send_time = self.send(v.name)-self.send(v.name+'_reminder_day').day rescue nil
|
||||
if !send_time.nil?
|
||||
new_email = Email.create(mail_to: manager_emails,
|
||||
module_app_key:"venue_management",
|
||||
template:"email/reminder_email.html.erb",
|
||||
mail_sentdate: send_time,
|
||||
mail_subject: title,
|
||||
template_data:{'title'=>title,'send_time'=>send_time,'locale'=>I18n.locale})
|
||||
self.venue_management_emails << VenueManagementEmail.new(email_id: new_email.id)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
Email.before_destroy do
|
||||
email = VenueManagementEmail.where(:email_id=>self.id).first
|
||||
if !email.nil?
|
||||
email.destroy
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class VenueManagementEmail
|
||||
include Mongoid::Document
|
||||
include Mongoid::Timestamps
|
||||
|
||||
field :email_id
|
||||
def email
|
||||
Email.find(self.email_id) rescue nil
|
||||
end
|
||||
end
|
|
@ -57,6 +57,9 @@ class VenueManagementMain
|
|||
accepts_nested_attributes_for :venue_management_email_sets, :allow_destroy => true
|
||||
accepts_nested_attributes_for :venue_management_signup_field_customs, :allow_destroy => true
|
||||
include VenueLinkFile
|
||||
def manager_emails
|
||||
MemberProfile.where(:id.in => self.manager_ids).collect{|v| v.email}
|
||||
end
|
||||
def self.time_range(date1 = null, date2 = null)
|
||||
|
||||
if !date1.blank?
|
||||
|
@ -88,5 +91,7 @@ class VenueManagementMain
|
|||
value = values.detect {|value| value.venue_management_signup_field_id == field_id} rescue nil
|
||||
value ? value : nil
|
||||
end
|
||||
|
||||
def case_no
|
||||
''
|
||||
end
|
||||
end
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
<%= @data['title'] %>
|
||||
<br>
|
||||
<%= @data['send_time'].strftime("%Y/%m/%d") %>
|
Loading…
Reference in New Issue