diff --git a/app/assets/images/property_hire/AAAAAA.png b/app/assets/images/property_hire/AAAAAA.png
new file mode 100644
index 0000000..772a39b
Binary files /dev/null and b/app/assets/images/property_hire/AAAAAA.png differ
diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb
index 02d428d..15f759a 100644
--- a/app/controllers/admin/property_hires_controller.rb
+++ b/app/controllers/admin/property_hires_controller.rb
@@ -12,6 +12,17 @@ class Admin::PropertyHiresController < OrbitAdminController
@properties = search_data(@properties,[:title]).page(params[:page]).per(10)
end
+ def fields_display_order
+ uid = params[:id].split("-").last
+ @property = Property.find_by(:uid=>uid)
+ end
+ def update_fields_display_order
+ uid = params[:id].split("-").last
+ @property = Property.find_by(:uid=>uid)
+ prop = params.require(:property).permit!
+ @property.update_attributes(prop)
+ redirect_to params[:referer_url]
+ end
def order
@properties = Property.all.sort_order
end
@@ -84,18 +95,13 @@ class Admin::PropertyHiresController < OrbitAdminController
end
flash.now[:notice] = "Updated Fields"
property.p_hire_fields.each{|t| t.destroy if t["to_delete"] == true}
- redirect_to admin_property_hires_path(:locale => params[:locale]) and return
else
property.update_attributes(@property_params)
email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue []
email = User.all.select{|v| v.is_admin? && v.user_name != 'rulingcom'}.collect{|v| v.member_profile.email} if email.length == 0
Admin::PropertyHiresHelper::HireMethod.send_mail('edit',email,property.id,nil,nil,current_user.id)
- if params[:page]
- redirect_to admin_property_hires_path(:page => params[:page],:locale => params[:locale])
- else
- redirect_to admin_property_hires_path(:locale => params[:locale])
- end
end
+ redirect_to params[:referer_url]
end
def create
diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb
index 985ad57..5bd762d 100644
--- a/app/controllers/property_hires_controller.rb
+++ b/app/controllers/property_hires_controller.rb
@@ -221,7 +221,8 @@ class PropertyHiresController < ApplicationController
email = Array(MemberProfile.find(property.owners)).collect{|v| v.email} rescue []
email = User.all.select{|v| v.is_admin? && v.user_name != 'rulingcom'}.collect{|v| v.member_profile.email} if email.length == 0
email << hire.hiring_person_email
- Admin::PropertyHiresHelper::HireMethod.send_mail('p_hire',email,property.id,nil,hire.id)
+ email = email.select{|e| e.present?}
+ Admin::PropertyHiresHelper::HireMethod.send_mail('p_hire',email,property.id,nil,hire.id,(current_user.id rescue nil))
end
redirect_to index_page
else
diff --git a/app/models/p_hire_field.rb b/app/models/p_hire_field.rb
index 6ba34df..060e8fb 100644
--- a/app/models/p_hire_field.rb
+++ b/app/models/p_hire_field.rb
@@ -27,7 +27,24 @@ class PHireField
has_many :p_hire_field_values, autosave: true, dependent: :destroy
accepts_nested_attributes_for :p_hire_field_values, :allow_destroy => true
before_save :check_option_list
-
+ before_destroy do
+ @property = self.property
+ if @property && @property.custom_field_names
+ @property.custom_field_names.delete("p_hire_fields.#{self.id}")
+ @property.save
+ end
+ end
+ after_save do
+ unless self.disabled
+ @property = self.property
+ if @property && @property.custom_field_names
+ if self.new_record? || !(@property.custom_field_names.include?("p_hire_fields.#{self.id}"))
+ @property.custom_field_names << "p_hire_fields.#{self.id}"
+ @property.save
+ end
+ end
+ end
+ end
def markup_value
get_data["option_list"]
end
diff --git a/app/models/property.rb b/app/models/property.rb
index 544fec0..1117b48 100644
--- a/app/models/property.rb
+++ b/app/models/property.rb
@@ -4,6 +4,8 @@ class Property
include OrbitTag::Taggable
include OrbitCategory::Categorizable
include Slug
+
+ FIELDSNAME=["hiring_person_email","hiring_person_number","hiring_person_name","reason_for_hire","note_for_hire","organization" ,"person_in_charge" ,"tel_of_person_in_charge" ,"department" ,"contact_person" ,"tel_of_contact_person" , "mobile_phone_of_contact_person" ,"contact_person_Email" ,"contact_person_department"]
field :custom_calendar_type, type: Integer, default: 0 #0=>預設, 1=> 顯示, 2=> 不顯示
field :custom_carousel_image_width, type: String, default: ""
field :display_img, :type => Boolean, :default => false
@@ -34,7 +36,12 @@ class Property
field :start_date, type: DateTime
field :end_date, type: DateTime
field :description, :localize => true
- field :unavailibility_note, :localize => true
+ field :unavailibility_note, :localize => true
+ field :hiring_person_email, type: Hash, default: {"enable"=>"1","required"=>"true"}
+ field :hiring_person_number, type: Hash, default: {"enable"=>"1","required"=>"true"}
+ field :hiring_person_name, type: Hash, default: {"enable"=>"1","required"=>"true"}
+ field :reason_for_hire, type: Hash, default: {"enable"=>"1","required"=>"true"}
+ field :note_for_hire
field :organization
field :person_in_charge
field :tel_of_person_in_charge
@@ -46,6 +53,9 @@ class Property
field :contact_person_department
field :enable_notes_selector , type: Boolean, default: false
field :notes_selector ,type: Hash, default: {}
+ field :enable_fields_sort , type: Boolean, default: false
+ field :custom_field_names, type: Array
+ field :default_field_names, type: Array
belongs_to :property_location
has_many :p_hires
has_many :hire_email_sets, :autosave => true, :dependent => :destroy, :inverse_of => :property
@@ -73,10 +83,40 @@ class Property
"Saturday"
]
CAlENDARTYPE = ["default","display","not_display"]
+ after_initialize do
+ unless self.new_record?
+ save_flag = false
+ @no_validate = true
+ if self.default_field_names.nil?
+ self.default_field_names = self.get_all_fields(true)
+ save_flag = true
+ end
+ if self.custom_field_names.nil?
+ self.custom_field_names = self.get_all_fields(true)
+ save_flag = true
+ end
+ if save_flag
+ self.save
+ end
+ end
+ end
before_create do
max_position = self.class.max(:order_position)
max_position = -1 if max_position.nil?
self.order_position = max_position + 1
+ @no_validate = true
+ self.default_field_names = self.get_all_fields(true)
+ self.custom_field_names = self.get_all_fields(true)
+ end
+ before_save do
+ unless @no_validate
+ self.default_field_names = self.get_all_fields(true)
+ self.class::FIELDSNAME.each do |f|
+ if((self.send(f)["enable"] == "1" rescue true) && !(self.custom_field_names.include?(f)))
+ self.custom_field_names << f
+ end
+ end
+ end
end
after_save do
self.change_day_setting_status
@@ -123,7 +163,7 @@ class Property
def disable_view_calendar_page
@@disable_view_calendar_page
end
- def custom_text(field_name,type,locale=nil)
+ def custom_text(field_name,type="name",locale=nil)
locale = locale || I18n.locale
default_text = I18n.with_locale(locale){I18n.t("property_hire.#{field_name}")}
if (self.send(field_name)[type][locale.to_s].present? rescue false)
@@ -432,11 +472,33 @@ class Property
end
def get_attribute_values(attribute_type=nil)
- @attribute_values = attribute_type.seminar_signup_values rescue nil
+ @attribute_values = attribute_type.p_hire_field_values rescue nil
end
def get_value_from_field_id(field_id,attribute_type=nil)
values = get_attribute_values(attribute_type)
- value = values.detect {|value| value.seminar_signup_field_id == field_id} rescue nil
+ value = values.detect {|value| value.p_hire_field_id == field_id} rescue nil
value ? value : nil
end
+ def get_basic_fields
+ basic_fields = self.class::FIELDSNAME
+ basic_fields = basic_fields.select{|f| (self.send(f)["enable"] == "1" rescue true)}
+ end
+ def get_all_fields(get_default=false)
+ @default_field_names = nil if @default_field_names.nil?
+ if get_default
+ if @default_field_names.nil?
+ basic_fields = self.get_basic_fields
+ custom_fields = []
+ self.p_hire_fields.each do |p_hire_field|
+ unless p_hire_field.disabled
+ custom_fields << "p_hire_fields.#{p_hire_field.id}"
+ end
+ end
+ @default_field_names = basic_fields + custom_fields
+ end
+ return @default_field_names
+ else
+ self.enable_fields_sort ? self.custom_field_names : self.default_field_names
+ end
+ end
end
\ No newline at end of file
diff --git a/app/views/admin/property_hires/_form.html.erb b/app/views/admin/property_hires/_form.html.erb
index 0ec200c..083d917 100644
--- a/app/views/admin/property_hires/_form.html.erb
+++ b/app/views/admin/property_hires/_form.html.erb
@@ -201,7 +201,7 @@
<% if @property.image.file %>
<%= image_tag @property.image %>
<% else %>
-
+
<% end %>
@@ -54,15 +80,6 @@ | |
<%=field_info["title"]%>: | -<%=field_info["value"]%> | -