Compare commits
No commits in common. "master" and "revert-e1e90a83" have entirely different histories.
master
...
revert-e1e
|
@ -77,7 +77,7 @@ var Calendar = function(dom,property_id){
|
||||||
c.modeBtns.each(function(){
|
c.modeBtns.each(function(){
|
||||||
if ($(this).data("mode") == view)
|
if ($(this).data("mode") == view)
|
||||||
$(this).addClass("active");
|
$(this).addClass("active");
|
||||||
});
|
})
|
||||||
if(view != "agenda"){
|
if(view != "agenda"){
|
||||||
if(c.currentView == "agenda"){
|
if(c.currentView == "agenda"){
|
||||||
// $("#sec1").addClass("span3").removeClass("span7");
|
// $("#sec1").addClass("span3").removeClass("span7");
|
||||||
|
@ -97,23 +97,23 @@ var Calendar = function(dom,property_id){
|
||||||
c.calendar.fullCalendar("refetchEvents");
|
c.calendar.fullCalendar("refetchEvents");
|
||||||
loadeventsonviewchange = false;
|
loadeventsonviewchange = false;
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
|
||||||
|
|
||||||
};
|
}
|
||||||
|
|
||||||
this.renderEvent = function(eventStick){
|
this.renderEvent = function(eventStick){
|
||||||
if(eventStick.recurring === true)
|
if(eventStick.recurring == true)
|
||||||
c.calendar.fullCalendar("refetchEvents");
|
c.calendar.fullCalendar("refetchEvents");
|
||||||
else
|
else
|
||||||
c.calendar.fullCalendar("renderEvent",eventStick);
|
c.calendar.fullCalendar("renderEvent",eventStick);
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
c.initialize();
|
c.initialize();
|
||||||
});
|
});
|
||||||
};
|
}
|
||||||
|
|
||||||
var EventDialog = function(calendar,event){
|
var EventDialog = function(calendar,event){
|
||||||
_t = this;
|
_t = this;
|
||||||
|
@ -153,7 +153,8 @@ var EventDialog = function(calendar,event){
|
||||||
'<h3>' + _event.title + '</h3>' +
|
'<h3>' + _event.title + '</h3>' +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="modal-body">' +
|
'<div class="modal-body">' +
|
||||||
'<div class="event_summary">' + time_string + '</br>' + _event.hiring_person_name + '</div>' + _event.note +
|
'<div class="event_summary">' + time_string + '<br>' + _event.hiring_person_name + '</div>'
|
||||||
|
_event.note +
|
||||||
'</div>' +
|
'</div>' +
|
||||||
'<div class="modal-footer" />' +
|
'<div class="modal-footer" />' +
|
||||||
'</div>';
|
'</div>';
|
||||||
|
@ -564,3 +565,33 @@ var AgendaView = function(calendar){
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,12 +1,13 @@
|
||||||
class Admin::PropertyHiresController < OrbitAdminController
|
class Admin::PropertyHiresController < OrbitAdminController
|
||||||
include Admin::PropertyHiresHelper
|
|
||||||
def index
|
def index
|
||||||
@tags = @module_app.tags
|
@tags = @module_app.tags
|
||||||
@categories = @module_app.categories.enabled
|
@categories = @module_app.categories.enabled
|
||||||
@filter_fields = filter_fields(@categories, @tags)
|
@filter_fields = filter_fields(@categories, @tags)
|
||||||
@table_fields = ["property_hire.title", :category, "property_hire.location", "property_hire.available_for_hire"]
|
@table_fields = ["property_hire.title", :category, "property_hire.location", "property_hire.available_for_hire"]
|
||||||
|
|
||||||
@properties = Property.order_by(sort)
|
@properties = Property.where(:title.ne => "")
|
||||||
|
.order_by(sort)
|
||||||
.with_categories(filters("category"))
|
.with_categories(filters("category"))
|
||||||
.with_tags(filters("tag"))
|
.with_tags(filters("tag"))
|
||||||
|
|
||||||
|
@ -14,20 +15,18 @@ class Admin::PropertyHiresController < OrbitAdminController
|
||||||
end
|
end
|
||||||
|
|
||||||
def my_bookings
|
def my_bookings
|
||||||
@table_fields = ["property_hire.title","property_hire.hiring_person_name", "property_hire.reason_for_hire", "property_hire.hiring_person_number", "property_hire.period", "property_hire.passed", :actions]
|
@table_fields = ["property_hire.hiring_person_name", "property_hire.reason_for_hire", "property_hire.hiring_person_number", "property_hire.period", "property_hire.passed", :actions]
|
||||||
@bookings = PHire.where(:hiring_person_id => current_user.member_profile.id.to_s).desc(:created_at).page(params[:page]).per(10)
|
@bookings = PHire.where(:hiring_person_id => current_user.member_profile.id.to_s).desc(:created_at).page(params[:page]).per(10)
|
||||||
end
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
@property = Property.new
|
@property = Property.new
|
||||||
create_set (false)
|
|
||||||
@locations = PropertyLocation.all.desc(:created_at).collect{|loc| [loc.title, loc.id.to_s]}
|
@locations = PropertyLocation.all.desc(:created_at).collect{|loc| [loc.title, loc.id.to_s]}
|
||||||
@locations << ["Other", "other_location"]
|
@locations << ["Other", "other_location"]
|
||||||
end
|
end
|
||||||
|
|
||||||
def edit
|
def edit
|
||||||
@property = Property.where(:uid => params[:id].split("-").last).first rescue nil
|
@property = Property.where(:uid => params[:id].split("-").last).first rescue nil
|
||||||
create_set (true)
|
|
||||||
@locations = PropertyLocation.all.desc(:created_at).collect{|loc| [loc.title, loc.id.to_s]}
|
@locations = PropertyLocation.all.desc(:created_at).collect{|loc| [loc.title, loc.id.to_s]}
|
||||||
@locations << ["Other", "other_location"]
|
@locations << ["Other", "other_location"]
|
||||||
end
|
end
|
||||||
|
@ -40,9 +39,6 @@ class Admin::PropertyHiresController < OrbitAdminController
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
property = Property.find(params[:id]) rescue nil
|
property = Property.find(params[:id]) rescue nil
|
||||||
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('delete',email,property.id,nil,nil,current_user.id)
|
|
||||||
property.destroy if !property.nil?
|
property.destroy if !property.nil?
|
||||||
if params[:page]
|
if params[:page]
|
||||||
redirect_to admin_property_hires_path(:page => params[:page])
|
redirect_to admin_property_hires_path(:page => params[:page])
|
||||||
|
@ -55,18 +51,16 @@ class Admin::PropertyHiresController < OrbitAdminController
|
||||||
property = Property.where(:uid => params[:id].split("-").last).first rescue nil
|
property = Property.where(:uid => params[:id].split("-").last).first rescue nil
|
||||||
redirect_to admin_property_hires_path and return if property.nil?
|
redirect_to admin_property_hires_path and return if property.nil?
|
||||||
property.update_attributes(property_params)
|
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]
|
if params[:page]
|
||||||
redirect_to admin_property_hires_path(:page => params[:page],:locale => params[:locale])
|
redirect_to admin_property_hires_path(:page => params[:page])
|
||||||
else
|
else
|
||||||
redirect_to admin_property_hires_path(:locale => params[:locale])
|
redirect_to admin_property_hires_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
if Property.create(property_params)
|
property = Property.new(property_params)
|
||||||
|
if property.save
|
||||||
redirect_to admin_property_hires_path
|
redirect_to admin_property_hires_path
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -184,28 +178,5 @@ class Admin::PropertyHiresController < OrbitAdminController
|
||||||
prop.delete(:property_location) if prop[:property_location] == "other"
|
prop.delete(:property_location) if prop[:property_location] == "other"
|
||||||
prop
|
prop
|
||||||
end
|
end
|
||||||
def create_set (save_flag)
|
|
||||||
@email_set = []
|
|
||||||
['p_hire','edit','delete'].each do |field_name|
|
|
||||||
email_set = @property.hire_email_sets.select{|v| v.field_name==field_name}
|
|
||||||
if email_set.length==0
|
|
||||||
title = Hash.new
|
|
||||||
content = Hash.new
|
|
||||||
I18n.available_locales.each do |locale|
|
|
||||||
I18n.with_locale(locale) do
|
|
||||||
title[locale] = t("property_hire.email_#{field_name}_success")
|
|
||||||
content[locale] = t("property_hire.email_#{field_name}_content")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
if save_flag
|
|
||||||
email_set = @property.hire_email_sets.create(field_name:field_name,title:title,content:content)
|
|
||||||
else
|
|
||||||
email_set = @property.hire_email_sets.new(field_name:field_name,title:title,content:content)
|
|
||||||
end
|
|
||||||
else
|
|
||||||
email_set = email_set[0]
|
|
||||||
end
|
|
||||||
@email_set << email_set
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -18,8 +18,8 @@ class PropertyHiresController < ApplicationController
|
||||||
end
|
end
|
||||||
{
|
{
|
||||||
"title" => property.title,
|
"title" => property.title,
|
||||||
"image" => (property.image.url.blank? ? '" style="display: none;' : property.image.url),
|
"image" => property.image.url,
|
||||||
"image-thumb" => (property.image.thumb.url.blank? ? '" style="display: none;' : property.image.thumb.url),
|
"image-thumb" => property.image.thumb.url,
|
||||||
"url_to_show" => OrbitHelper.url_to_show(property.to_param),
|
"url_to_show" => OrbitHelper.url_to_show(property.to_param),
|
||||||
"location" => property.get_location_name,
|
"location" => property.get_location_name,
|
||||||
"actions" => actions
|
"actions" => actions
|
||||||
|
@ -30,7 +30,7 @@ class PropertyHiresController < ApplicationController
|
||||||
"column" => t("property_hire.title")
|
"column" => t("property_hire.title")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"column" => ""
|
"column" => t("property_hire.image")
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"column" => t("property_hire.location")
|
"column" => t("property_hire.location")
|
||||||
|
@ -165,12 +165,6 @@ class PropertyHiresController < ApplicationController
|
||||||
hire = PHire.new(booking_p)
|
hire = PHire.new(booking_p)
|
||||||
hire.passed = true if PropertyHireSetting.auto_approve_enabled?
|
hire.passed = true if PropertyHireSetting.auto_approve_enabled?
|
||||||
hire.save
|
hire.save
|
||||||
if !property.nil?
|
|
||||||
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)
|
|
||||||
end
|
|
||||||
redirect_to params[:url]
|
redirect_to params[:url]
|
||||||
else
|
else
|
||||||
session["hire-save-msg"] = data["msg"]
|
session["hire-save-msg"] = data["msg"]
|
||||||
|
|
|
@ -3,21 +3,9 @@ module Admin::PropertyHiresHelper
|
||||||
def check_for_availability(stime, etime, pid, interval=nil, recurring_end_date=nil)
|
def check_for_availability(stime, etime, pid, interval=nil, recurring_end_date=nil)
|
||||||
property = Property.find(pid)
|
property = Property.find(pid)
|
||||||
return {"success" => false, "msg" => "Values are not ok."} if property.nil? || stime.blank? || etime.blank?
|
return {"success" => false, "msg" => "Values are not ok."} if property.nil? || stime.blank? || etime.blank?
|
||||||
if !stime.blank?
|
|
||||||
stime = DateTime.parse(stime + Time.zone.to_s) rescue nil
|
stime = DateTime.parse(stime + Time.zone.to_s) rescue nil
|
||||||
else
|
|
||||||
stime = nil
|
|
||||||
end
|
|
||||||
if !etime.blank?
|
|
||||||
etime = DateTime.parse(etime + Time.zone.to_s) rescue nil
|
etime = DateTime.parse(etime + Time.zone.to_s) rescue nil
|
||||||
else
|
|
||||||
etime = nil
|
|
||||||
end
|
|
||||||
if !recurring_end_date.blank?
|
|
||||||
recurring_end_date = DateTime.parse(recurring_end_date + Time.zone.to_s) rescue nil
|
recurring_end_date = DateTime.parse(recurring_end_date + Time.zone.to_s) rescue nil
|
||||||
else
|
|
||||||
recurring_end_date = nil
|
|
||||||
end
|
|
||||||
data = {}
|
data = {}
|
||||||
return {"success" => false, "msg" => "Starting time cannot be greater than ending time."} if stime > etime
|
return {"success" => false, "msg" => "Starting time cannot be greater than ending time."} if stime > etime
|
||||||
if property.is_available_for_hire?(stime, etime)
|
if property.is_available_for_hire?(stime, etime)
|
||||||
|
@ -31,78 +19,5 @@ module Admin::PropertyHiresHelper
|
||||||
end
|
end
|
||||||
return data
|
return data
|
||||||
end
|
end
|
||||||
module HireMethod
|
|
||||||
extend ActionView::Helpers::UrlHelper
|
|
||||||
extend ActionView::Helpers::TagHelper
|
|
||||||
extend ActionView::Context
|
|
||||||
extend ActionView::Helpers::FormTagHelper
|
|
||||||
def self.set_input_name(input_name)
|
|
||||||
@input_name = input_name
|
|
||||||
end
|
|
||||||
def self.get_input_name
|
|
||||||
@input_name
|
|
||||||
end
|
|
||||||
def self.create_lang_panel(field)
|
|
||||||
tmp2 = content_tag(:div,:class => 'btn-group', :data=>{:toggle=>"buttons-radio"}) do
|
|
||||||
I18n.available_locales.collect do |key|
|
|
||||||
link_entry_ary = ["##{field}","_#{key}"]
|
|
||||||
link_entry = link_entry_ary.join
|
|
||||||
link_to(I18n.t(key),link_entry,:data=>{:toggle=>"tab"},:class=>"btn #{(key == I18n.locale ? "active" : nil)}",:for=>key)
|
|
||||||
end.join.html_safe
|
|
||||||
end
|
|
||||||
end
|
|
||||||
def self.multiple_lang_tag(index1,type_of_tag,field,value=nil,custom_options={},combine_element='',exteral_options={},panel_in_first=false)
|
|
||||||
content_tag(:div,{:class => "tab-panel"}.merge(exteral_options)) do
|
|
||||||
all_field = (get_input_name + "[#{index1}][#{field}][parant]").gsub(/\[/,'_').gsub(/\]/,'')
|
|
||||||
tmp = I18n.available_locales.collect do |locale|
|
|
||||||
active_flag = ((locale == I18n.locale) ? ' active' : '')
|
|
||||||
content_tag(:div,:class => "tab-content#{active_flag}",:id=>"#{all_field}_#{locale}") do
|
|
||||||
value_locale = ((value[locale] || value[locale.to_s]) rescue nil)
|
|
||||||
self.__send__("#{type_of_tag}_tag","#{get_input_name}[#{index1}][#{field}][#{locale}]",value_locale,custom_options)
|
|
||||||
end
|
|
||||||
end.join
|
|
||||||
if panel_in_first
|
|
||||||
tmp = create_lang_panel(all_field).html_safe + tmp.html_safe + combine_element
|
|
||||||
else
|
|
||||||
tmp = tmp.html_safe + create_lang_panel(all_field).html_safe + combine_element
|
|
||||||
end
|
|
||||||
tmp
|
|
||||||
end
|
|
||||||
end
|
|
||||||
def self.show_set_field(id,field_sets,key_field,key_index,field,markup='text_field',with_id=true)
|
|
||||||
end_block = with_id ? hidden_field_tag("property[#{key_field}][#{key_index}]"+"[id]",id) : ''
|
|
||||||
custom_options = markup == 'text_area' ? {:class => 'ckeditor'} : {}
|
|
||||||
a = multiple_lang_tag(key_field,markup,"#{key_index}][#{field}",field_sets,custom_options,end_block,{},markup=='text_area')
|
|
||||||
a.html_safe
|
|
||||||
end
|
|
||||||
def self.send_mail(field_name,email,property_id,send_date=nil,hire_id=nil,user_id=nil)
|
|
||||||
property = Property.where(id: property_id).first
|
|
||||||
if !property.nil?
|
|
||||||
email_set = property.hire_email_sets.select{|v| v.field_name == field_name}
|
|
||||||
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('/')
|
|
||||||
content = "title:#{title}<br>note:#{note}"
|
|
||||||
if email_set.length==0
|
|
||||||
mail = Email.create(mail_to: Array(email),
|
|
||||||
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)
|
|
||||||
mail = Email.create(mail_to: Array(email),
|
|
||||||
module_app_key:"property_hire",
|
|
||||||
template:"email/#{field_name}_email.html.erb",
|
|
||||||
mail_sentdate: send_date || Time.current,
|
|
||||||
mail_subject: email_set[0].title[I18n.locale],
|
|
||||||
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})
|
|
||||||
end
|
|
||||||
begin
|
|
||||||
mail.deliver
|
|
||||||
rescue => e
|
|
||||||
puts ["email can't deliver",e]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
|
@ -1,10 +0,0 @@
|
||||||
class HireEmailSet
|
|
||||||
include Mongoid::Document
|
|
||||||
include Mongoid::Timestamps
|
|
||||||
|
|
||||||
field :field_name, type: String
|
|
||||||
field :title
|
|
||||||
field :content
|
|
||||||
field :disabled, type: Boolean, default: false
|
|
||||||
belongs_to :property
|
|
||||||
end
|
|
|
@ -16,15 +16,7 @@ class PHire
|
||||||
field :recurring, type: Boolean, :default => false
|
field :recurring, type: Boolean, :default => false
|
||||||
field :recurring_end_date, type: DateTime
|
field :recurring_end_date, type: DateTime
|
||||||
field :recurring_interval
|
field :recurring_interval
|
||||||
field :organization
|
|
||||||
field :person_in_charge
|
|
||||||
field :tel_of_person_in_charge
|
|
||||||
field :department
|
|
||||||
field :contact_person
|
|
||||||
field :tel_of_contact_person
|
|
||||||
field :mobile_phone_of_contact_person
|
|
||||||
field :contact_person_Email
|
|
||||||
field :contact_person_department
|
|
||||||
belongs_to :property
|
belongs_to :property
|
||||||
|
|
||||||
def as_json(options = {})
|
def as_json(options = {})
|
||||||
|
@ -72,7 +64,7 @@ class PHire
|
||||||
@end_date += 7
|
@end_date += 7
|
||||||
end
|
end
|
||||||
if @start_date < re.recurring_end_date
|
if @start_date < re.recurring_end_date
|
||||||
@recurring << {:id => re.id.to_s, :hiring_person_name => re.hirer_name ,:title=>re.reason_for_hire, :note=>re.reason_for_hire, :start=>@start_date, :end => @end_date, :allDay => false, :recurring => re.recurring, :color => "#FC4040"}
|
@recurring << {:id => re.id.to_s, :title=>re.reason_for_hire, :note=>re.reason_for_hire, :start=>@start_date, :end => @end_date, :allDay => false, :recurring => re.recurring, :color => "#FC4040"}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
when "month"
|
when "month"
|
||||||
|
|
|
@ -30,19 +30,10 @@ class Property
|
||||||
field :end_date, type: DateTime
|
field :end_date, type: DateTime
|
||||||
field :description, :localize => true
|
field :description, :localize => true
|
||||||
field :unavailibility_note, :localize => true
|
field :unavailibility_note, :localize => true
|
||||||
field :organization
|
|
||||||
field :person_in_charge
|
|
||||||
field :tel_of_person_in_charge
|
|
||||||
field :department
|
|
||||||
field :contact_person
|
|
||||||
field :tel_of_contact_person
|
|
||||||
field :mobile_phone_of_contact_person
|
|
||||||
field :contact_person_Email
|
|
||||||
field :contact_person_department
|
|
||||||
belongs_to :property_location
|
belongs_to :property_location
|
||||||
has_many :p_hires
|
has_many :p_hires
|
||||||
has_many :hire_email_sets, :autosave => true, :dependent => :destroy, :inverse_of => :property
|
|
||||||
accepts_nested_attributes_for :hire_email_sets, :allow_destroy => true
|
|
||||||
WEEKDAYS = [
|
WEEKDAYS = [
|
||||||
"Sunday",
|
"Sunday",
|
||||||
"Monday",
|
"Monday",
|
||||||
|
@ -91,72 +82,45 @@ class Property
|
||||||
end
|
end
|
||||||
|
|
||||||
def is_already_hired?(stime, etime, interval, recurring_end_date)
|
def is_already_hired?(stime, etime, interval, recurring_end_date)
|
||||||
phires = self.p_hires
|
bookings = self.p_hires.where(:end_time.gte => stime, :recurring => false)
|
||||||
bookings_count = phires.where(:start_time.lte => stime,:end_time.gte => stime,:recurring => false).count
|
|
||||||
+ phires.where(:start_time.gte => stime,:end_time.lte => etime,:recurring => false).count
|
|
||||||
+phires.where(:start_time.lte => etime,:end_time.gte => etime,:recurring => false).count
|
|
||||||
available = true
|
available = true
|
||||||
if bookings_count != 0
|
bookings.each do |booking|
|
||||||
|
common_time = (booking.start_time..booking.end_time) & (stime..etime)
|
||||||
|
if !common_time.nil?
|
||||||
available = false
|
available = false
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
if available
|
if available
|
||||||
bookings = phires.where(:recurring_end_date.gte => stime, :recurring => true) + phires.where(:recurring => false,:recurring_end_date => nil) + phires.where(:recurring => false,:recurring_end_date.gte => stime)
|
|
||||||
case interval
|
case interval
|
||||||
when 'week'
|
when "week"
|
||||||
d_step = 1.week
|
stepu = 1.week
|
||||||
when 'month'
|
when "month"
|
||||||
d_step = 1.month
|
stepu = 1.month
|
||||||
else
|
else
|
||||||
d_step = 0
|
stepu = 0
|
||||||
end
|
end
|
||||||
|
bookings = self.p_hires.where(:recurring_end_date.gte => stime, :recurring => true)
|
||||||
bookings.each do |booking|
|
bookings.each do |booking|
|
||||||
stime_tp = stime
|
booking.time_iterate do |st,et|
|
||||||
etime_tp = etime
|
tst = stime
|
||||||
b_interval = booking.recurring_interval
|
tet = etime
|
||||||
if (b_interval == 'month' || b_interval == 'week') && booking.recurring_end_date.nil?
|
if stepu != 0
|
||||||
b_interval = nil
|
begin
|
||||||
end
|
common_time = (tst..tet) & (st..et)
|
||||||
while true
|
available = false if !common_time.nil?
|
||||||
if b_interval == 'month'
|
tet += stepu
|
||||||
diff_month = booking.end_time.month - booking.start_time.month
|
break if !available
|
||||||
diff_month = diff_month + 12 if diff_month < 0
|
break if tst > st
|
||||||
e_month = stime_tp.month + diff_month
|
end while (tst += stepu) <= recurring_end_date
|
||||||
e_year = stime_tp.year + (booking.end_time.year-booking.start_time.year)
|
|
||||||
e_month = e_month - 12 if e_month >12
|
|
||||||
b_sdata = Time.local(stime_tp.year,stime_tp.month,booking.start_time.day,booking.start_time.hour,booking.start_time.minute).to_datetime
|
|
||||||
b_edata = Time.local(e_year,e_month,booking.end_time.day,booking.end_time.hour,booking.end_time.minute).to_datetime
|
|
||||||
elsif b_interval == 'week'
|
|
||||||
diff_day = booking.end_time - booking.start_time
|
|
||||||
if (booking.end_time.wday <= booking.start_time.wday && diff_day>1) || diff_day > 7
|
|
||||||
over_one_week = true
|
|
||||||
end
|
|
||||||
b_sdata_tp = stime_tp - stime_tp.wday.day + booking.start_time.wday.day
|
|
||||||
b_sdata = Time.local(b_sdata_tp.year,b_sdata_tp.month,b_sdata_tp.day,booking.start_time.hour,booking.start_time.minute).to_datetime
|
|
||||||
if over_one_week && etime_tp.wday <= booking.start_time.wday
|
|
||||||
b_sdata = b_sdata - 7.day
|
|
||||||
end
|
|
||||||
now_diff_day = etime_tp - stime_tp
|
|
||||||
if (etime_tp.wday <= stime_tp.wday && now_diff_day>1) || now_diff_day > 7
|
|
||||||
b_sdata = b_sdata + 7.day
|
|
||||||
end
|
|
||||||
b_edata_tp = b_sdata + (booking.end_time - booking.start_time).to_i.day
|
|
||||||
b_edata = Time.local(b_edata_tp.year,b_edata_tp.month,b_edata_tp.day,booking.end_time.hour,booking.end_time.minute).to_datetime
|
|
||||||
else
|
else
|
||||||
b_sdata = booking.start_time
|
common_time = (tst..tet) & (st..et)
|
||||||
b_edata = booking.end_time
|
available = false if !common_time.nil?
|
||||||
|
break if !available
|
||||||
end
|
end
|
||||||
sdata = stime_tp
|
break if !available
|
||||||
edata = etime_tp
|
|
||||||
if etime_tp > booking.start_time
|
|
||||||
if (sdata <= b_sdata && edata >= b_sdata) || (sdata >= b_sdata && edata <= b_edata) || (sdata <= b_edata && edata >= b_edata)
|
|
||||||
available = false
|
|
||||||
end
|
end
|
||||||
end
|
break if !available
|
||||||
stime_tp = stime_tp + d_step
|
|
||||||
etime_tp = etime_tp + d_step
|
|
||||||
break if recurring_end_date.blank? || d_step==0 || recurring_end_date < stime_tp
|
|
||||||
end
|
|
||||||
break if available == false
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return available
|
return available
|
||||||
|
@ -169,3 +133,11 @@ class Property
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,6 @@ class PropertyHireSetting
|
||||||
field :auto_approve, type: Boolean, :default => false
|
field :auto_approve, type: Boolean, :default => false
|
||||||
|
|
||||||
def self.auto_approve_enabled?
|
def self.auto_approve_enabled?
|
||||||
self.first.auto_approve rescue false
|
self.first.auto_approve
|
||||||
end
|
end
|
||||||
end
|
end
|
|
@ -1,19 +1,3 @@
|
||||||
<%
|
|
||||||
hire_method = Admin::PropertyHiresHelper::HireMethod
|
|
||||||
hire_method.set_input_name('property')
|
|
||||||
%>
|
|
||||||
<style type="text/css">
|
|
||||||
.tab-panel > .tab-content{
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
.tab-panel > .tab-content.active{
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
.tab-panel{
|
|
||||||
display: flex;
|
|
||||||
flex-wrap: wrap;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
<% content_for :page_specific_css do %>
|
<% content_for :page_specific_css do %>
|
||||||
<%= stylesheet_link_tag "lib/main-forms" %>
|
<%= stylesheet_link_tag "lib/main-forms" %>
|
||||||
<%= stylesheet_link_tag "lib/fileupload" %>
|
<%= stylesheet_link_tag "lib/fileupload" %>
|
||||||
|
@ -37,8 +21,6 @@
|
||||||
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
|
<li><a href="#tag" data-toggle="tab"><%= t(:tags) %></a></li>
|
||||||
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
|
<li><a href="#imageupload" data-toggle="tab"><%= t(:image) %></a></li>
|
||||||
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailability')%></a></li>
|
<li><a href="#unavailability" data-toggle="tab"><%= t('property_hire.unavailability')%></a></li>
|
||||||
<li><a href="#auto_send_email_set" data-toggle="tab"><%= t('property_hire.auto_send_email_set') %></a></li>
|
|
||||||
<li><a href="#settings" data-toggle="tab"><%= t('property_hire.settings') %></a></li>
|
|
||||||
</ul>
|
</ul>
|
||||||
<!-- Module -->
|
<!-- Module -->
|
||||||
<div class="tab-content module-area">
|
<div class="tab-content module-area">
|
||||||
|
@ -155,66 +137,7 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- Email Set Module -->
|
|
||||||
<div class="tab-pane fade" id="auto_send_email_set" style="padding: 1.2em;">
|
|
||||||
<ul class="nav nav-pills module-nav">
|
|
||||||
<li class="active">
|
|
||||||
<a href="#email_set0" data-toggle="tab">
|
|
||||||
<%= t('property_hire.hire') %>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="#email_set1" data-toggle="tab">
|
|
||||||
<%= t('property_hire.edit') %>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
<li class="">
|
|
||||||
<a href="#email_set2" data-toggle="tab">
|
|
||||||
<%= t('property_hire.delete') %>
|
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</ul>
|
|
||||||
<div class="tab-content">
|
|
||||||
<% (0..2).each do |index1| %>
|
|
||||||
<% active_email_set = index1==0 ? ' active' : '' %>
|
|
||||||
<div class="tab-pane<%= active_email_set %>" id="email_set<%= index1 %>" style="padding: 1.2em;">
|
|
||||||
<table style="width:100%;">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= t('disable') %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<input type="hidden" class="field_set" name='<%= "property[hire_email_sets][#{index1}][disabled]" %>' value="false">
|
|
||||||
<%= check_box_tag("property[hire_email_sets][#{index1}][disabled]", true ,@email_set[index1].disabled) %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= t('property_hire.email_title') %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['title'],'hire_email_sets',index1,'title','text_field',action_name != 'new') %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= t('property_hire.email_content') %>
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= hire_method.show_set_field(@email_set[index1].id,@email_set[index1]['content'],'hire_email_sets',index1,'content','text_area',action_name != 'new') %>
|
|
||||||
</div>
|
|
||||||
<%= hidden_field_tag("property[hire_email_sets][#{index1}][field_name]",@email_set[index1]['field_name']) %>
|
|
||||||
<%= hidden_field_tag("property[hire_email_sets][#{index1}][property_id]",@property.id) %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- unavailability -->
|
<!-- unavailability -->
|
||||||
<div class="tab-pane fade" id="unavailability">
|
<div class="tab-pane fade" id="unavailability">
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
|
@ -292,7 +215,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% @site_in_use_locales.each do |locale| %>
|
<% @site_in_use_locales.each do |locale| %>
|
||||||
<%= f.fields_for :unavailibility_note_translations do |f| %>
|
<%= f.fields_for :unavailibility_note do |f| %>
|
||||||
<div class="control-group">
|
<div class="control-group">
|
||||||
<label class="control-label muted" for="note_<%= locale.to_s %>"><%= t(:note) + " (#{t(locale.to_s)})" %></label>
|
<label class="control-label muted" for="note_<%= locale.to_s %>"><%= t(:note) + " (#{t(locale.to_s)})" %></label>
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
|
@ -303,29 +226,6 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="tab-pane fade" id="settings">
|
|
||||||
<% fields_name = ["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"] %>
|
|
||||||
<% fields_name.each do |field_name| %>
|
|
||||||
<div class="control-group">
|
|
||||||
<label class="control-label muted"><%= t("property_hire.#{field_name}") %></label>
|
|
||||||
<div class="controls">
|
|
||||||
<label for="act_enabled_name" class="checkbox inline">
|
|
||||||
<%= hidden_field_tag "property[#{field_name}][enable]", "0" %>
|
|
||||||
<%= f.check_box_tag "property[#{field_name}][enable]", "1" , (@property[field_name]["enable"] == "1" rescue false) %>
|
|
||||||
Enable
|
|
||||||
</label>
|
|
||||||
</div>
|
|
||||||
<div class="controls required">
|
|
||||||
<label class="radio inline"><%= t("property_hire.required") %></label>
|
|
||||||
<%= f.fields_for field_name do |sub_f|%>
|
|
||||||
<label class="radio inline"><%= sub_f.radio_button "required", "true", checked: ((@property[field_name]["required"] rescue "false") == "true") %><%= t(:yes_) %></label>
|
|
||||||
<label class="radio inline"><%= sub_f.radio_button "required", "false", checked: ((@property[field_name]["required"] rescue "false") == "false") %><%= t(:no_) %></label>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Language Tabs -->
|
<!-- Language Tabs -->
|
||||||
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
<div class="nav-name"><strong><%= t(:language) %></strong></div>
|
||||||
|
@ -368,12 +268,12 @@
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
<!-- Form Actions -->
|
<!-- Form Actions -->
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<% if params[:page] %>
|
<% if params[:page] %>
|
||||||
<input type="hidden" name="page" value="<%= params[:page] %>" />
|
<input type="hidden" name="page" value="<%= params[:page] %>" />
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= hidden_field_tag("property[id]",@property.id) %>
|
|
||||||
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
<%= f.submit t('submit'), class: 'btn btn-primary' %>
|
||||||
<%= link_to t('cancel'), admin_property_hires_path, :class=>"btn" %>
|
<%= link_to t('cancel'), admin_property_hires_path, :class=>"btn" %>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= property.category.title rescue nil %>
|
<%= property.category.title %>
|
||||||
</td>
|
</td>
|
||||||
<td>
|
<td>
|
||||||
<%= property.get_location_name %>
|
<%= property.get_location_name %>
|
||||||
|
|
|
@ -61,7 +61,7 @@
|
||||||
<div class="bottomnav clearfix">
|
<div class="bottomnav clearfix">
|
||||||
<%= content_tag(:div, paginate(@locations), class: "pagination pagination-centered") %>
|
<%= content_tag(:div, paginate(@locations), class: "pagination pagination-centered") %>
|
||||||
<div class="pull-right">
|
<div class="pull-right">
|
||||||
<%= link_to t(:add), add_location_admin_property_hires_path, :id=>'create_new_location', :class => "btn btn-primary", :data => {"toggle" => "modal", "target" => "#location-modal"} %>
|
<%= link_to t(:add), add_location_admin_property_hires_path, :class => "btn btn-primary", :data => {"toggle" => "modal", "target" => "#location-modal"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@ -72,10 +72,4 @@
|
||||||
$("#edit-location-btn").on("click",function(){
|
$("#edit-location-btn").on("click",function(){
|
||||||
$("#edit-location-modal form").submit();
|
$("#edit-location-modal form").submit();
|
||||||
})
|
})
|
||||||
$("#create_new_location").on("click",function(){
|
|
||||||
var url = $(this).attr("href");
|
|
||||||
$.get(url).done(function(data){
|
|
||||||
$("#location-modal .modal-body").html(data);
|
|
||||||
})
|
|
||||||
})
|
|
||||||
</script>
|
</script>
|
|
@ -10,9 +10,6 @@
|
||||||
<tbody>
|
<tbody>
|
||||||
<% @bookings.each do |p_hire| %>
|
<% @bookings.each do |p_hire| %>
|
||||||
<tr>
|
<tr>
|
||||||
<td>
|
|
||||||
<%= p_hire.property.title rescue nil %>
|
|
||||||
</td>
|
|
||||||
<td>
|
<td>
|
||||||
<%= p_hire.hirer_name %>
|
<%= p_hire.hirer_name %>
|
||||||
</td>
|
</td>
|
||||||
|
|
|
@ -36,15 +36,6 @@
|
||||||
<td><%= t("property_hire.note_for_hire") %></td>
|
<td><%= t("property_hire.note_for_hire") %></td>
|
||||||
<td><%= @booking.note_for_hire %></td>
|
<td><%= @booking.note_for_hire %></td>
|
||||||
</tr>
|
</tr>
|
||||||
<% fields_name = ["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"] %>
|
|
||||||
<% fields_name.each do |field_name| %>
|
|
||||||
<% if(@booking.property[field_name]["enable"] == "1" rescue false) %>
|
|
||||||
<tr>
|
|
||||||
<td><%= t("property_hire.#{field_name}") %></td>
|
|
||||||
<td><%= @booking[field_name].to_s %></td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td><%= t("property_hire.passed") %></td>
|
<td><%= t("property_hire.passed") %></td>
|
||||||
<td>
|
<td>
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
<% if !@data['email_set_content'].nil? %>
|
|
||||||
<% email_set_content = YAML.load(@data['email_set_content'])
|
|
||||||
now_locale = @data['locale'] %>
|
|
||||||
<%= email_set_content[now_locale].html_safe rescue nil %>
|
|
||||||
<% end %>
|
|
||||||
<br>
|
|
||||||
<%= @data['content'].html_safe %>
|
|
||||||
|
|
||||||
<% property = Property.where(id: @data['property_id']).first %>
|
|
||||||
<% if !property.nil? %>
|
|
||||||
<h3><%= property['title'].collect{|k,v| v}.uniq.join('/') rescue nil %></h3>
|
|
||||||
<% I18n.with_locale(@data['locale']) do %>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% ['editor','property_usage','note','category','property_location','property_number','can_be_hired','purchase_date','owners','other_owner','owner_email','owner_phone','price'].each do |k| %>
|
|
||||||
<% v = property.send(k) rescue nil %>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= k=='category' ? t('category') : t("property_hire.#{k}") %>:
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<% if k == 'editor' %>
|
|
||||||
<%= User.find(user_id).name rescue nil %>
|
|
||||||
<% elsif ['purchase_date'].include?(k) %>
|
|
||||||
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
|
|
||||||
<% elsif ['property_usage','note'].include?(k) %>
|
|
||||||
<%= property[k].collect{|k,v| v}.uniq.join('/') rescue nil %>
|
|
||||||
<% elsif k=='owners' %>
|
|
||||||
<%= property.owner_profiles.collect{|v| v.name}.join(', ') %>
|
|
||||||
<% elsif ['category','property_location'].include?(k) %>
|
|
||||||
<%= v.title %>
|
|
||||||
<% elsif k == 'can_be_hired' %>
|
|
||||||
<%= v ? t('yes_') : t('no_') %>
|
|
||||||
<% else %>
|
|
||||||
<%= v %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
|
@ -1,47 +0,0 @@
|
||||||
<% property = Property.where(id: @data['property_id']).first %>
|
|
||||||
<% email_set = property.hire_email_sets.select{|v| v.field_name == 'edit'} %>
|
|
||||||
<% if email_set.length != 0 %>
|
|
||||||
<% if !(email_set[0].content.nil?) %>
|
|
||||||
<%= email_set[0].content[@data['locale']].html_safe %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<%= t('property_hire.email_edit_success') %>
|
|
||||||
<% end %>
|
|
||||||
<h3><%= property['title'].collect{|k,v| v}.uniq.join('/') rescue nil %></h3>
|
|
||||||
<% I18n.with_locale(@data['locale']) do %>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% ['editor','property_usage','note','category','property_location','property_number','can_be_hired','purchase_date','owners','other_owner','owner_email','owner_phone','price'].each do |k| %>
|
|
||||||
<% v = property.send(k) rescue nil %>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= k=='category' ? t('category') : t("property_hire.#{k}") %>:
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<% if k == 'editor' %>
|
|
||||||
<%= User.find(user_id).name rescue nil %>
|
|
||||||
<% elsif ['purchase_date'].include?(k) %>
|
|
||||||
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
|
|
||||||
<% elsif ['property_usage','note'].include?(k) %>
|
|
||||||
<%= property[k].collect{|k,v| v}.uniq.join('/') rescue nil %>
|
|
||||||
<% elsif k=='owners' %>
|
|
||||||
<%= property.owner_profiles.collect{|v| v.name}.join(', ') %>
|
|
||||||
<% elsif ['category','property_location'].include?(k) %>
|
|
||||||
<%= v.title %>
|
|
||||||
<% elsif k == 'can_be_hired' %>
|
|
||||||
<%= v ? t('yes_') : t('no_') %>
|
|
||||||
<% else %>
|
|
||||||
<%= v %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% end %>
|
|
|
@ -1,53 +0,0 @@
|
||||||
<% property = Property.where(id: @data['property_id']).first%>
|
|
||||||
<% email_set = property.hire_email_sets.select{|v| v.field_name == 'p_hire'} %>
|
|
||||||
<% if email_set.length != 0 %>
|
|
||||||
<% if !(email_set[0].content.nil?) %>
|
|
||||||
<%= email_set[0].content[@data['locale']].html_safe %>
|
|
||||||
<% end %>
|
|
||||||
<% else %>
|
|
||||||
<%= t('property_hire.email_p_hire_content') %>
|
|
||||||
<% end %>
|
|
||||||
<br>
|
|
||||||
<% I18n.with_locale(@data['locale']) do %>
|
|
||||||
<h3><%= property.title rescue nil %></h3>
|
|
||||||
<% if !@data['hire_id'].nil? %>
|
|
||||||
<% hire = PHire.where(id: @data['hire_id']).first %>
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<td></td>
|
|
||||||
<td></td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody>
|
|
||||||
<% extra_fields_name = ["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"] %>
|
|
||||||
<% keys = ['hiring_person_name','hiring_person_email','start_time','end_time','recurring','recurring_interval','recurring_end_date','passed','reason_for_hire','note_for_hire'] %>
|
|
||||||
<% used_extra_fields_name = extra_fields_name.select{|field_name| (property[field_name]["enable"] == "1" rescue false) } %>
|
|
||||||
<% keys.concat( used_extra_fields_name ) %>
|
|
||||||
<% keys.each do |k| %>
|
|
||||||
<% v = hire.send(k) %>
|
|
||||||
<% if !v.nil? && !(k.include?('recurring') && hire.recurring != true)%>
|
|
||||||
<tr>
|
|
||||||
<td>
|
|
||||||
<%= t("property_hire.#{k}") %>:
|
|
||||||
</td>
|
|
||||||
<td>
|
|
||||||
<% if ['start_time','end_time','recurring','recurring_interval','recurring_end_date','passed'].exclude?(k) %>
|
|
||||||
<%= v.to_s %>
|
|
||||||
<% elsif ['start_time','end_time','recurring_end_date'].include?(k) %>
|
|
||||||
<%= v.strftime('%Y/%m/%d %H:%M') rescue nil %>
|
|
||||||
<% elsif k == 'recurring_interval' %>
|
|
||||||
<%= t("property_hire.recurring_interval_types.#{v}") %>
|
|
||||||
<% elsif 'recurring' == k %>
|
|
||||||
<%= v ? t('property_hire.yes') : t('property_hire.no') %>
|
|
||||||
<% else %>
|
|
||||||
<%= v ? t('property_hire.yes') : t('property_hire.wait_for_permit') %>
|
|
||||||
<% end %>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
|
@ -28,34 +28,34 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
<%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal" } do |f| %>
|
<%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal" } do |f| %>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :start_time, "*"+t("property_hire.start_time"), :class => "col-sm-2 control-label" %>
|
<%= f.label :start_time, t("property_hires.start_time"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<%= f.datetime_picker :start_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "start", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.datetime_picker :start_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "start", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :end_time, "*"+t("property_hire.end_time"), :class => "col-sm-2 control-label" %>
|
<%= f.label :end_time, t("property_hires.end_time"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<%= f.datetime_picker :end_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "end", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.datetime_picker :end_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "end", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<!-- ############# recurring ############# -->
|
<!-- ############# recurring ############# -->
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :recurring, t("property_hire.recurring"), :class => "col-sm-2 control-label" %>
|
<%= f.label :recurring, t("property_hires.recurring"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<%= f.check_box :recurring %>
|
<%= f.check_box :recurring %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="recurring-block" <%= hire.recurring ? "" : "style=display:none;" %>>
|
<div id="recurring-block" <%= hire.recurring ? "" : "style=display:none;" %>>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :recurring_interval, t("property_hire.recurring_interval"), :class => "col-sm-2 control-label" %>
|
<%= f.label :recurring_interval, t("property_hires.recurring_interval"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-1">
|
<div class="col-sm-1">
|
||||||
<%= f.select :recurring_interval, PHire::INTERVALS.collect{|int| [t("property_hire.recurring_interval_types.#{int}"), int] }, {:prompt => t('property_hire.select_interval')}, {:data => {"fv-validation" => "requiredifrecurring;" , "fv-messages" => "Cannot be empty;"}} %>
|
<%= f.select :recurring_interval, PHire::INTERVALS.collect{|int| [t("property_hire.recurring_interval_types.#{int}"), int] }, {:prompt => "Select interval"}, {:data => {"fv-validation" => "requiredifrecurring;" , "fv-messages" => "Cannot be empty;"}} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :recurring_end_date, "*"+t("property_hire.recurring_end_date"), :class => "col-sm-2 control-label" %>
|
<%= f.label :recurring_end_date, t("property_hires.recurring_end_date"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<%= f.datetime_picker :recurring_end_date, :no_label => true, :new_record => hire.new_record?, :data=>{"fv-validation" => "requiredifrecurring;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.datetime_picker :recurring_end_date, :no_label => true, :new_record => hire.new_record?, :data=>{"fv-validation" => "requiredifrecurring;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
</div>
|
</div>
|
||||||
<% if property.set_unavailibility %>
|
<% if property.set_unavailibility %>
|
||||||
<div class="col-sm-offset-2 col-sm-5">
|
<div class="col-sm-offset-2 col-sm-5">
|
||||||
<b><%= t("property_hire.Unavailibility_Schedule") %></b>
|
<b>Unavailibility Schedule</b>
|
||||||
<div>
|
<div>
|
||||||
This property is unavaliable <%= !property.start_date.nil? ? " from " + property.start_date.strftime("%Y-%m-%d") : "" %> <%= !property.end_date.nil? ? " to " + property.end_date.strftime("%Y-%m-%d") : "" %> every
|
This property is unavaliable <%= !property.start_date.nil? ? " from " + property.start_date.strftime("%Y-%m-%d") : "" %> <%= !property.end_date.nil? ? " to " + property.end_date.strftime("%Y-%m-%d") : "" %> every
|
||||||
<% property.weekdays.each_with_index do |d,i| %>
|
<% property.weekdays.each_with_index do |d,i| %>
|
||||||
|
@ -89,57 +89,41 @@
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<label for="" class="col-sm-2 control-label"></label>
|
<label for="" class="col-sm-2 control-label"></label>
|
||||||
<div class="col-sm-10">
|
<div class="col-sm-10">
|
||||||
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary"><%= t('property_hire.check_availibility') %></a>
|
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary">Check Availibility</a>
|
||||||
<img style="display: none;" width="40" src="/assets/spin.gif" id="spinner" />
|
<img style="display: none;" width="40" src="/assets/spin.gif" id="spinner" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :hiring_person_email, "*"+t("property_hire.hiring_person_email"), :class => "col-sm-2 control-label" %>
|
<%= f.label :hiring_person_email, t("property_hires.hiring_person_email"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<%= f.text_field :hiring_person_email, :class => "form-control", :value => current_user.member_profile.email, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.text_field :hiring_person_email, :class => "form-control", :value => current_user.member_profile.email, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :hiring_person_number, "*"+t("property_hire.hiring_person_number"), :class => "col-sm-2 control-label" %>
|
<%= f.label :hiring_person_number, t("property_hires.hiring_person_number"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<%= f.text_field :hiring_person_number, :class => "form-control", :value => current_user.member_profile.mobile_no, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.text_field :hiring_person_number, :class => "form-control", :value => current_user.member_profile.mobile_no, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :hiring_person_name, "*"+t("property_hire.hiring_person_name"), :class => "col-sm-2 control-label" %>
|
<%= f.label :hiring_person_name, t("property_hires.hiring_person_name"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<%= f.text_field :hiring_person_name, :class => "form-control", :value => (current_user.name rescue ""), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.text_field :hiring_person_name, :class => "form-control", :value => (current_user.name rescue ""), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
<%= f.hidden_field :hiring_person_id, :value => (current_user.member_profile.id.to_s rescue "") %>
|
<%= f.hidden_field :hiring_person_id, :value => (current_user.member_profile.id.to_s rescue "") %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :reason_for_hire, "*"+t("property_hire.reason_for_hire"), :class => "col-sm-2 control-label" %>
|
<%= f.label :reason_for_hire, t("property_hires.reason_for_hire"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<%= f.text_field :reason_for_hire, :class => "form-control", :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
<%= f.text_field :reason_for_hire, :class => "form-control", :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<%= f.label :note_for_hire, t("property_hire.note_for_hire"), :class => "col-sm-2 control-label" %>
|
<%= f.label :note_for_hire, t("property_hires.note_for_hire"), :class => "col-sm-2 control-label" %>
|
||||||
<div class="col-sm-5">
|
<div class="col-sm-5">
|
||||||
<%= f.text_area :note_for_hire, :class => "form-control" %>
|
<%= f.text_area :note_for_hire, :class => "form-control" %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% fields_name = ["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"] %>
|
|
||||||
<% fields_name.each do |field_name| %>
|
|
||||||
<% if(property[field_name]["enable"] == "1" rescue false) %>
|
|
||||||
<% required = (property[field_name]["required"] == "true" rescue false) %>
|
|
||||||
<div class="form-group">
|
|
||||||
<%= f.label field_name, (required ? "*" : "") + t("property_hire.#{field_name}"), :class => "col-sm-2 control-label" %>
|
|
||||||
<div class="col-sm-5">
|
|
||||||
<% if required %>
|
|
||||||
<%= f.text_field field_name, :class => "form-control", :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
||||||
<% else %>
|
|
||||||
<%= f.text_field field_name, :class => "form-control" %>
|
|
||||||
<% end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<% end %>
|
|
||||||
<% end %>
|
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-sm-offset-2 col-sm-10">
|
<div class="col-sm-offset-2 col-sm-10">
|
||||||
<%= f.submit t("property_hire.save"), :class => "btn btn-primary" %>
|
<%= f.submit t("property_hire.save"), :class => "btn btn-primary" %>
|
||||||
|
|
|
@ -1,17 +1,5 @@
|
||||||
en:
|
en:
|
||||||
property_hire:
|
property_hire:
|
||||||
editor: Editor
|
|
||||||
email_p_hire_success: Hire Success
|
|
||||||
email_edit_success: 'Property Hire Module:Edit Success'
|
|
||||||
email_delete_success: 'Property Hire Module:Delete Success'
|
|
||||||
email_p_hire_content: Hire Success
|
|
||||||
email_edit_content: 'Property Hire Module:Edit Success'
|
|
||||||
email_delete_content: 'Property Hire Module:Delete Success'
|
|
||||||
edit: Edit
|
|
||||||
delete: Delete
|
|
||||||
auto_send_email_set: Auto Send Email Setting
|
|
||||||
email_title: Email Title
|
|
||||||
email_content: Email Content
|
|
||||||
recurring: Recurring
|
recurring: Recurring
|
||||||
recurring_interval: Recurring Interval
|
recurring_interval: Recurring Interval
|
||||||
recurring_interval_types:
|
recurring_interval_types:
|
||||||
|
@ -19,7 +7,7 @@ en:
|
||||||
week: Week
|
week: Week
|
||||||
recurring_end_date: Recurring End Date
|
recurring_end_date: Recurring End Date
|
||||||
save: Save
|
save: Save
|
||||||
property_hire: Manage of hire
|
property_hire: Property
|
||||||
my_bookings: My Bookings
|
my_bookings: My Bookings
|
||||||
settings: Settings
|
settings: Settings
|
||||||
auto_approve: Auto approve
|
auto_approve: Auto approve
|
||||||
|
@ -63,19 +51,3 @@ en:
|
||||||
note_for_hire: Note For Hire
|
note_for_hire: Note For Hire
|
||||||
period: Period
|
period: Period
|
||||||
passed: Accepted
|
passed: Accepted
|
||||||
'yes': 'Yes'
|
|
||||||
'no': 'No'
|
|
||||||
wait_for_permit: 'Wait for permit'
|
|
||||||
select_interval: Select interval
|
|
||||||
check_availibility: Check Availibility
|
|
||||||
Unavailibility_Schedule: Unavailibility Schedule
|
|
||||||
required: Required
|
|
||||||
organization: Organization
|
|
||||||
person_in_charge: Person in charge
|
|
||||||
tel_of_person_in_charge: Tel. of person in charge
|
|
||||||
department: Department
|
|
||||||
contact_person: Contact person
|
|
||||||
tel_of_contact_person: Tel. of contact person
|
|
||||||
mobile_phone_of_contact_person: Mobile phone of contact person
|
|
||||||
contact_person_Email: Contact person Email
|
|
||||||
contact_person_department: Contact person department
|
|
|
@ -1,81 +1,53 @@
|
||||||
zh_tw:
|
zh_tw:
|
||||||
property_hire:
|
property_hire:
|
||||||
editor: 編輯者
|
recurring: Recurring
|
||||||
email_p_hire_success: 借用成功
|
recurring_interval: Recurring Interval
|
||||||
email_edit_success: '租借模組:編輯成功'
|
|
||||||
email_delete_success: '租借模組:刪除成功'
|
|
||||||
email_p_hire_content: 借用成功
|
|
||||||
email_edit_content: '租借模組:編輯成功'
|
|
||||||
email_delete_content: '租借模組:刪除成功'
|
|
||||||
edit: 編輯
|
|
||||||
delete: 刪除
|
|
||||||
auto_send_email_set: 自動發信設定
|
|
||||||
email_title: 主旨
|
|
||||||
email_content: 內文
|
|
||||||
recurring: 週期性借用
|
|
||||||
recurring_interval: 借用週期
|
|
||||||
recurring_interval_types:
|
recurring_interval_types:
|
||||||
month: 月
|
month: Month
|
||||||
week: 周
|
week: Week
|
||||||
recurring_end_date: 週期結束時間
|
recurring_end_date: Recurring End Date
|
||||||
save: Save
|
save: Save
|
||||||
my_bookings: My Bookings
|
my_bookings: My Bookings
|
||||||
settings: 設定
|
settings: Settings
|
||||||
property_hire: 借用管理
|
property_hire: Property
|
||||||
manage_locations: Manage Locations
|
manage_locations: Manage Locations
|
||||||
location: 位置
|
location: Location
|
||||||
auto_approve: Auto approve
|
auto_approve: Auto approve
|
||||||
property_count: Property Count
|
property_count: Property Count
|
||||||
edit_location: Edit Location
|
edit_location: Edit Location
|
||||||
add_location: Add Location
|
add_location: Add Location
|
||||||
unavailability: 不可借用
|
unavailability: Unavailability
|
||||||
title: 名稱
|
title: Property Title
|
||||||
select_interval: 選則週期
|
property_usage: Usage for property
|
||||||
check_availibility: 檢查是否可借用
|
note: Note
|
||||||
property_usage: 用途
|
property_number: Property Number
|
||||||
note: 說明
|
can_be_hired: Available for hire
|
||||||
property_number: 編號
|
|
||||||
can_be_hired: 可供借用
|
|
||||||
purchase_date: Purchase Date
|
purchase_date: Purchase Date
|
||||||
owners: 管理人
|
owners: Owners
|
||||||
other_owner: 其他管理人
|
other_owner: Other Owner
|
||||||
owner_email: 管理人Email
|
owner_email: Owner Email
|
||||||
owner_phone: 管理人聯絡電話
|
owner_phone: Owner Phone
|
||||||
price: Price
|
price: Price
|
||||||
set_unavailibility: 設定為不可借用
|
set_unavailibility: Set Unavailability
|
||||||
start_time: 借用開始時間
|
start_time: Start Time
|
||||||
end_time: 借用結束時間
|
end_time: End Time
|
||||||
weekdays: Weekdays
|
weekdays: Weekdays
|
||||||
start_date: From Date
|
start_date: From Date
|
||||||
end_date: To Date
|
end_date: To Date
|
||||||
description: Unavailability Description
|
description: Unavailability Description
|
||||||
unavailibility_note: Unavailability Note
|
unavailibility_note: Unavailability Note
|
||||||
property_location: Property Location
|
property_location: Property Location
|
||||||
available_for_hire: 可供借用
|
available_for_hire: Available for hire
|
||||||
hire: 線上借用
|
hire: Hire
|
||||||
view_calendar: 查詢目前借用狀況
|
view_calendar: Calendar
|
||||||
image: Property Image
|
image: Property Image
|
||||||
actions: 操作
|
actions: Actions
|
||||||
start_time: 借用開始時間
|
start_time: Hire Start Time
|
||||||
end_time: 借用結束時間
|
end_time: Hire End Time
|
||||||
hiring_person_email: 借用人電子信箱
|
hiring_person_email: Hiring Person Email
|
||||||
hiring_person_number: 借用人聯絡電話
|
hiring_person_number: Hiring Person Number
|
||||||
hiring_person_name: 借用人姓名
|
hiring_person_name: Hiring Person
|
||||||
reason_for_hire: 使用用途
|
reason_for_hire: Reason For Hire
|
||||||
note_for_hire: 備註
|
note_for_hire: Note For Hire
|
||||||
period: Period
|
period: Period
|
||||||
passed: 借用允許
|
passed: Accepted
|
||||||
'yes': 是
|
|
||||||
'no': 否
|
|
||||||
wait_for_permit: 等待授權
|
|
||||||
Unavailibility_Schedule: 不提供借用時間
|
|
||||||
required: 必填
|
|
||||||
organization: 借用單位
|
|
||||||
person_in_charge: 單位負責人
|
|
||||||
tel_of_person_in_charge: 負責人聯絡電話
|
|
||||||
department: 服務單位
|
|
||||||
contact_person: 聯絡人
|
|
||||||
tel_of_contact_person: 聯絡人聯絡電話
|
|
||||||
mobile_phone_of_contact_person: 聯絡人行動電話
|
|
||||||
contact_person_Email: 聯絡Email
|
|
||||||
contact_person_department: 聯絡人服務單位
|
|
Loading…
Reference in New Issue