Fix bug.(Add date and time displayed in email when choosing set availability)

This commit is contained in:
BoHung Chiu 2021-10-26 18:45:14 +08:00
parent e98009f659
commit 12eea8b58e
5 changed files with 30 additions and 9 deletions

View File

@ -139,20 +139,31 @@ module Admin::PropertyHiresHelper
title = property['title'].collect{|k,v| v}.select{|v| !v.to_s.empty?}.join('/') title = property['title'].collect{|k,v| v}.select{|v| !v.to_s.empty?}.join('/')
note = property['note'].collect{|k,v| v}.select{|v| !v.to_s.empty?}.join('/') note = property['note'].collect{|k,v| v}.select{|v| !v.to_s.empty?}.join('/')
content = "title:#{title}<br>note:#{note}" content = "title:#{title}<br>note:#{note}"
mail_subject = I18n.t("property_hire.email_#{field_name}_success")
email_set_content = nil
enable = false
if email_set.length==0 if email_set.length==0
mail = Email.create(mail_to: Array(email), enable = true
module_app_key:"property_hire",
template:"email/#{field_name}_email.html.erb",
mail_sentdate: send_date || Time.current,
mail_subject: I18n.t("property_hire.email_#{field_name}_success"),
template_data:{'property_id'=>property_id,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id})
elsif !(email_set[0].disabled) elsif !(email_set[0].disabled)
enable = true
mail_subject = email_set[0].title[I18n.locale]
email_set_content = email_set[0].content.to_yaml
end
if field_name == "p_hire" && (property.set_availability rescue false)
hire = PHire.find(hire_id) rescue nil
if hire
mail_subject += " (#{I18n.t("property_hire.hire_time")}: #{hire.date.to_s.gsub("-","/")} #{hire.time})"
end
end
if enable
mail = Email.create(mail_to: Array(email), mail = Email.create(mail_to: Array(email),
module_app_key:"property_hire", module_app_key:"property_hire",
template:"email/#{field_name}_email.html.erb", template:"email/#{field_name}_email.html.erb",
mail_sentdate: send_date || Time.current, mail_sentdate: send_date || Time.current,
mail_subject: email_set[0].title[I18n.locale], mail_subject: mail_subject,
template_data:{'property_id'=>property_id,'email_set_content'=>email_set[0].content.to_yaml,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id}) template_data:{'property_id'=>property_id,'email_set_content'=>email_set_content,'content'=>content,'locale'=>I18n.locale.to_s,'hire_id'=>hire_id,'user_id'=>user_id})
else
return false
end end
begin begin
mail.deliver mail.deliver

View File

@ -33,6 +33,9 @@ class PHire
def property_day_setting def property_day_setting
PropertyDaySetting.find(self.property_day_setting_id) rescue nil PropertyDaySetting.find(self.property_day_setting_id) rescue nil
end end
def time
property_day_setting.title rescue nil
end
def as_json(options = {}) def as_json(options = {})
startt = self.start_time startt = self.start_time
endt = self.end_time endt = self.end_time

View File

@ -28,7 +28,12 @@
<% <%
p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h p_hire_fields = property.p_hire_fields.map{|rf| [rf.id.to_s,rf]}.to_h
fields_name = property.get_all_fields fields_name = property.get_all_fields
basic_keys = ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed'] basic_keys = []
if (property.set_availability rescue false)
basic_keys = ['date','time','hiring_person_name','hiring_person_email','recurring','recurring_interval','recurring_end_date','passed']
else
basic_keys = ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed']
end
fields_name = fields_name - basic_keys fields_name = fields_name - basic_keys
keys = basic_keys + fields_name keys = basic_keys + fields_name
keys = keys.select{|field_name| (property[field_name]["enable"] == "1" rescue true) } keys = keys.select{|field_name| (property[field_name]["enable"] == "1" rescue true) }

View File

@ -5,6 +5,7 @@ en:
restful_actions: restful_actions:
fields_display_order: "Fields display order" fields_display_order: "Fields display order"
property_hire: property_hire:
hire_time: Reservation time
back_to_hire_page: "Back to Reserve Page" back_to_hire_page: "Back to Reserve Page"
apply_default_time_settings: Apply default time settings apply_default_time_settings: Apply default time settings
default_time_settings: Default time settings default_time_settings: Default time settings

View File

@ -5,6 +5,7 @@ zh_tw:
restful_actions: restful_actions:
fields_display_order: "欄位顯示順序" fields_display_order: "欄位顯示順序"
property_hire: property_hire:
hire_time: 預約時間
back_to_hire_page: "回到預約頁面" back_to_hire_page: "回到預約頁面"
apply_default_time_settings: 套用預設時段設定 apply_default_time_settings: 套用預設時段設定
default_time_settings: 預設時段設定 default_time_settings: 預設時段設定