updated lot of features

This commit is contained in:
rulingcom 2024-07-11 15:42:16 +08:00
parent 4d02ff8729
commit 7080cf7d4d
12 changed files with 420 additions and 211 deletions

View File

@ -104,8 +104,7 @@ window.getDateString = function(date, format,is_chinese) {
} }
return formattedDate; return formattedDate;
}; };
var Calendar = function(dom,property_id,currentView,display_hire_event){ var Calendar = function(dom, property_id, valid_range, currentView, display_hire_event){
var c = this; var c = this;
display_hire_event = (display_hire_event == undefined ? true : display_hire_event); display_hire_event = (display_hire_event == undefined ? true : display_hire_event);
this.title = $("#current_title"); this.title = $("#current_title");
@ -136,6 +135,7 @@ var Calendar = function(dom,property_id,currentView,display_hire_event){
editable: false, editable: false,
selectable: true, selectable: true,
width: "100%", width: "100%",
validRange: valid_range,
events: function(args, success_callback, fail_callback) { events: function(args, success_callback, fail_callback) {
var start = args.start; var start = args.start;
var end = args.end; var end = args.end;
@ -276,6 +276,10 @@ var Calendar = function(dom,property_id,currentView,display_hire_event){
if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;} if(c.currentView == "agenda"){toggleViews("agenda");loadeventsonviewchange = true;}
}; };
this.destroy = function () {
c.calendar_dom.fullCalendar("destroy");
}
this.renderEvent = function(eventStick){ this.renderEvent = function(eventStick){
if(eventStick.recurring === true) if(eventStick.recurring === true)
c.calendar_dom.calendar.refetchEvents(); c.calendar_dom.calendar.refetchEvents();

View File

@ -248,7 +248,7 @@ class Admin::PropertyHiresController < OrbitAdminController
def custom_fields def custom_fields
@field_name = 'property' @field_name = 'property'
uid = params[:id].split("-").last uid = params[:id].split("-").last
@attribute = Property.find_by(:uid=>uid) @attribute = Property.find_by(:uid=>uid)
@attribute_type = 'property' @attribute_type = 'property'
@class = 'properties' @class = 'properties'
end end
@ -262,7 +262,7 @@ class Admin::PropertyHiresController < OrbitAdminController
params.require(:property_location).permit! params.require(:property_location).permit!
end end
def phire_params def phire_params
p_hire_params = params.require(:p_hire).permit! p_hire_params = params.require(:p_hire).permit!
property = (@phire ? @phire.property : Property.find(params[:p_hire][:property_id]) rescue nil) property = (@phire ? @phire.property : Property.find(params[:p_hire][:property_id]) rescue nil)
if(property.enable_notes_selector rescue false) if(property.enable_notes_selector rescue false)
note_texts = "" note_texts = ""
@ -274,7 +274,7 @@ class Admin::PropertyHiresController < OrbitAdminController
value_text = p_hire_params["notes_selector"][index.to_s].to_a.map{|i| values[i.to_i]}.join(",") rescue "" value_text = p_hire_params["notes_selector"][index.to_s].to_a.map{|i| values[i.to_i]}.join(",") rescue ""
value_text = I18n.t("property_hire.none") if value_text.blank? value_text = I18n.t("property_hire.none") if value_text.blank?
note_texts += (name + ":"+value_text) note_texts += (name + ":"+value_text)
note_texts += "<br>".html_safe note_texts += "<br>".html_safe
end end
p_hire_params["note_for_hire"] = note_texts p_hire_params["note_for_hire"] = note_texts
p_hire_params.delete("notes_selector") p_hire_params.delete("notes_selector")
@ -319,4 +319,4 @@ class Admin::PropertyHiresController < OrbitAdminController
@email_set << email_set @email_set << email_set
end end
end end
end end

View File

@ -22,39 +22,44 @@ class PropertyHiresController < ApplicationController
{ {
"properties" => data, "properties" => data,
"headers" => headers, "headers" => headers,
"extras" => {
"first_property_id" => data.first["id"]
},
"manage_booking_btn" => (OrbitHelper.current_user.nil? ? false : true),
"manage_booking" => t("property_hire.manage_booking"),
"manage_booking_url" => "/" + OrbitHelper.get_site_locale.to_s + "/admin/property_hires/my_bookings",
"total_pages" => (properties.total_pages rescue 1) "total_pages" => (properties.total_pages rescue 1)
} }
end end
def index_data(properties, url) def index_data(properties, url)
data = properties.collect do |property| data = properties.collect do |property|
actions = [] actions = []
url_to_show = "#{url}/#{property.to_param}" url_to_show = "#{url}/#{property.to_param}?method=hire"
hire_url = nil hire_url = nil
if property.can_be_hired_frontend if property.can_be_hired_frontend && property.can_reserve
hire_url = url_to_show + "?method=hire" hire_url = url_to_show
actions << { actions << {
"text" => t("property_hire.hire"), "text" => t("property_hire.hire"),
"btn-class" => "btn-primary", "btn-class" => "btn-primary",
"link" => hire_url "link" => hire_url
} }
end end
if !property.disable_view_calendar_page && property.can_be_show_frontend if !property.disable_view_calendar_page && property.can_be_show_frontend && property.can_reserve
actions << { actions << {
"text" => t("property_hire.view_calendar"), "text" => t("property_hire.view_calendar"),
"btn-class" => "btn-info", "btn-class" => "btn-info",
"link" => url_to_show + "?method=view_calendar" "link" => url_to_show
} }
end end
if property.disable_content_page if property.disable_content_page
if hire_url if hire_url
url_to_show = hire_url url_to_show = hire_url
elsif !property.disable_view_calendar_page && property.can_be_show_frontend
url_to_show += "?method=view_calendar"
end end
end end
{ {
"title" => property.title, "title" => property.title,
"id" => property.id.to_s,
"image" => (property.image.url.blank? ? '" style="display: none;' : property.image.url), "image" => (property.image.url.blank? ? '" style="display: none;' : property.image.url),
"image-thumb" => (property.image.thumb.url.blank? ? '" style="display: none;' : property.image.thumb.url), "image-thumb" => (property.image.thumb.url.blank? ? '" style="display: none;' : property.image.thumb.url),
"url_to_show" => url_to_show, "url_to_show" => url_to_show,
@ -65,7 +70,7 @@ class PropertyHiresController < ApplicationController
end end
def widget def widget
properties = Property.filter_by_widget_categories.sort_order properties = Property.filter_by_widget_categories.sort_order.can_display
url = OrbitHelper.get_current_widget.get_read_more_page_url url = OrbitHelper.get_current_widget.get_read_more_page_url
data = index_data(properties, url) data = index_data(properties, url)
headers = [ headers = [
@ -114,7 +119,7 @@ class PropertyHiresController < ApplicationController
"header" => t("property_hire.property_number"), "header" => t("property_hire.property_number"),
"value" => property.property_number "value" => property.property_number
} }
end end
data << { data << {
"header" => t("property_hire.can_be_hired"), "header" => t("property_hire.can_be_hired"),
"value" => (property.can_be_hired ? "<span class='label label-success'>Yes</span>" : "<span class='label label-danger'>No</span>") "value" => (property.can_be_hired ? "<span class='label label-success'>Yes</span>" : "<span class='label label-danger'>No</span>")
@ -159,7 +164,7 @@ class PropertyHiresController < ApplicationController
"header" => t("property_hire.location"), "header" => t("property_hire.location"),
"value" => property.get_location_name "value" => property.get_location_name
} }
end end
actions = [] actions = []
url_to_show = OrbitHelper.url_to_show(property.to_param) url_to_show = OrbitHelper.url_to_show(property.to_param)
if property.can_be_hired_frontend if property.can_be_hired_frontend
@ -185,7 +190,7 @@ class PropertyHiresController < ApplicationController
"back_url" => page.url "back_url" => page.url
} }
} }
end end
def view_calendar def view_calendar
@ -357,8 +362,11 @@ class PropertyHiresController < ApplicationController
events = events.map{|e| e.as_json} events = events.map{|e| e.as_json}
allevents = events.inject(re, :<<) allevents = events.inject(re, :<<)
allevents = allevents.sort_by{|e| e[:start]} allevents = allevents.sort_by{|e| e[:start]}
Rails.logger.info allevents
@need_check_events = allevents.map{|e| [e[:date],e[:s_id]]} @need_check_events = allevents.map{|e| [e[:date],e[:s_id]]}
if property.set_availability && params[:display_hire_event] @special_unavailable_dates = property.special_unavailable_dates.map{|dt| Date.parse(dt)}
if property.set_availability && params[:display_hire_event] == "true"
check_setting = property.set_unavailibility && (property.property_day_settings.where(:enable=>false).count != 0) check_setting = property.set_unavailibility && (property.property_day_settings.where(:enable=>false).count != 0)
@check_start_time = property.start_time.blank? ? "00:00" : property.start_time @check_start_time = property.start_time.blank? ? "00:00" : property.start_time
@check_end_time = property.end_time.blank? ? "24:00" : property.end_time @check_end_time = property.end_time.blank? ? "24:00" : property.end_time
@ -379,9 +387,15 @@ class PropertyHiresController < ApplicationController
get_end_time = [time_now + (property.can_hire_before_months).send("month"),edt].min get_end_time = [time_now + (property.can_hire_before_months).send("month"),edt].min
end end
end end
allevents += generate_all_reserve_buttons(get_start_time,get_end_time,all_day_settings,check_setting) if property.can_reserve
allevents += generate_all_reserve_buttons(get_start_time,get_end_time,all_day_settings,check_setting)
end
end end
end end
if @special_unavailable_dates.count > 0
allevents += special_unavailable_dates_labels(property)
end
end end
end end
respond_to do |format| respond_to do |format|
@ -389,8 +403,20 @@ class PropertyHiresController < ApplicationController
format.json { render json: allevents.to_json } format.json { render json: allevents.to_json }
end end
end end
def special_unavailable_dates_labels(property)
events = []
@special_unavailable_dates.each_with_index do |dt, idx|
events << {:title=>property.special_unavailable_dates_title[idx][OrbitHelper.get_site_locale], :start=>dt.to_s, :end => (dt + 1.day).to_s, :allDay => true, :color => "#d33535", :classNames=>["special_unavailable_btn"], :note => ""}
end
events
end
def reserve_calendar_event(date,title,allow_times) def reserve_calendar_event(date,title,allow_times)
available = true available = true
if @special_unavailable_dates.include?(date)
available = false
end
if @check_setting && allow_times.select{|a| !a[5]}.count != 0 if @check_setting && allow_times.select{|a| !a[5]}.count != 0
available = (date > @check_end_date rescue false) || (date < @check_start_date rescue false) available = (date > @check_end_date rescue false) || (date < @check_start_date rescue false)
unless available unless available
@ -420,7 +446,7 @@ class PropertyHiresController < ApplicationController
endt = endt.in_time_zone(Time.zone) endt = endt.in_time_zone(Time.zone)
start_wday = startt.wday start_wday = startt.wday
start_date = startt.to_date start_date = startt.to_date
@start_date = start_date @start_date = start_date
end_date = endt.to_date end_date = endt.to_date
@end_date = end_date @end_date = end_date
@first_check_time = startt.strftime("%H:%M") @first_check_time = startt.strftime("%H:%M")
@ -481,7 +507,7 @@ class PropertyHiresController < ApplicationController
end end
else else
@all_day_settings.each do |wday_str,settings| @all_day_settings.each do |wday_str,settings|
tmp_date = @start_date + wday_str.to_i.send("day") tmp_date = @start_date + wday_str.to_i.send("day")
i = @need_check_events.index{|e| e[0] > tmp_date} i = @need_check_events.index{|e| e[0] > tmp_date}
if i.nil? if i.nil?
if @need_check_events.length != 0 && @need_check_events[-1][0] <= tmp_date if @need_check_events.length != 0 && @need_check_events[-1][0] <= tmp_date
@ -535,7 +561,7 @@ class PropertyHiresController < ApplicationController
private private
def booking_params def booking_params
p_hire_params = params.require(:p_hire).permit! p_hire_params = params.require(:p_hire).permit!
property = Property.find(params[:p_hire][:property_id]) rescue Property.last property = Property.find(params[:p_hire][:property_id]) rescue Property.last
if(property.enable_notes_selector rescue false) if(property.enable_notes_selector rescue false)
note_texts = "" note_texts = ""
@ -547,7 +573,7 @@ class PropertyHiresController < ApplicationController
value_text = p_hire_params["notes_selector"][index.to_s].to_a.map{|i| values[i.to_i]}.join(",") rescue "" value_text = p_hire_params["notes_selector"][index.to_s].to_a.map{|i| values[i.to_i]}.join(",") rescue ""
value_text = I18n.t("property_hire.none") if value_text.blank? value_text = I18n.t("property_hire.none") if value_text.blank?
note_texts += (name + ":"+value_text) note_texts += (name + ":"+value_text)
note_texts += "<br>".html_safe note_texts += "<br>".html_safe
end end
p_hire_params["note_for_hire"] = note_texts p_hire_params["note_for_hire"] = note_texts
p_hire_params.delete("notes_selector") p_hire_params.delete("notes_selector")
@ -556,8 +582,3 @@ class PropertyHiresController < ApplicationController
end end
end end

View File

@ -53,9 +53,11 @@ class PHire
if options[:recurring] if options[:recurring]
recurring = options[:recurring] recurring = options[:recurring]
end end
title = startt.strftime("%H:%M") + " ~ " + endt.strftime("%H:%M") + " " + self.hiring_person_name
{ {
:id => self.id.to_s, :id => self.id.to_s,
:title => (self.reason_for_hire.to_s + " "+ self.tmp_reason_for_hire.to_s).html_safe, # :title => (self.reason_for_hire.to_s + " "+ self.tmp_reason_for_hire.to_s).html_safe,
:title => title,
:hiring_person_id => self.hiring_person_id, :hiring_person_id => self.hiring_person_id,
:hiring_person_name => self.hiring_person_name, :hiring_person_name => self.hiring_person_name,
:note => self.note_for_hire || "", :note => self.note_for_hire || "",
@ -189,4 +191,4 @@ class PHire
end while (start_time += step_interval) <= recurring_end_date end while (start_time += step_interval) <= recurring_end_date
end end
end end

View File

@ -26,8 +26,13 @@ class Property
field :owner_phone field :owner_phone
field :price field :price
field :other_location field :other_location
field :p_hire_start_time, type: DateTime
mount_uploader :image, ImageUploader field :p_hire_end_time, type: DateTime
field :p_open_start_time, type: DateTime
field :p_open_end_time, type: DateTime
field :recurring_enable, type: Boolean, :default => false
mount_uploader :image, ImageUploader
# unavailibility fields # unavailibility fields
field :can_hire_before_months, type: Integer, default: 0 field :can_hire_before_months, type: Integer, default: 0
@ -36,6 +41,8 @@ class Property
field :start_time field :start_time
field :end_time field :end_time
field :weekdays, type: Array, default: [] field :weekdays, type: Array, default: []
field :special_unavailable_dates, type: Array, default: []
field :special_unavailable_dates_title, type: Array, default: []
field :start_date, type: DateTime field :start_date, type: DateTime
field :end_date, type: DateTime field :end_date, type: DateTime
field :description, :localize => true field :description, :localize => true
@ -77,7 +84,8 @@ class Property
accepts_nested_attributes_for :property_files, :allow_destroy => true accepts_nested_attributes_for :property_files, :allow_destroy => true
has_many :property_links, :autosave => true, :dependent => :destroy has_many :property_links, :autosave => true, :dependent => :destroy
accepts_nested_attributes_for :property_links, :allow_destroy => true accepts_nested_attributes_for :property_links, :allow_destroy => true
scope :sort_order, ->{order_by([:order_position,:asc],[:created_at,:desc])} scope :sort_order, ->{order_by([:created_at,:desc],[:order_position,:asc])}
scope :can_display, ->{any_of({:p_hire_start_time.lt=>Time.now, :p_hire_end_time.gt=>Time.now},{:p_hire_start_time.lt=>Time.now, :p_hire_end_time=>nil},{:p_hire_start_time=>nil, :p_hire_end_time=>nil})}
WEEKDAYS = [ WEEKDAYS = [
"Sunday", "Sunday",
"Monday", "Monday",
@ -133,6 +141,13 @@ class Property
after_save do after_save do
self.change_day_setting_status self.change_day_setting_status
end end
def can_reserve
start_time = self.p_hire_start_time || Time.now
end_time = self.p_hire_end_time || Time.now
return Time.now >= start_time && end_time >= Time.now
end
def p_hire_fields_enabled def p_hire_fields_enabled
self.p_hire_fields.where(disabled: false) self.p_hire_fields.where(disabled: false)
end end
@ -255,6 +270,9 @@ class Property
message += hint1 message += hint1
end end
end end
if property.special_unavailable_dates.count > 1
message += " And on " + property.special_unavailable_dates.join(", ")
end
if property.need_hire_before != 0 if property.need_hire_before != 0
if message != "" if message != ""
message += "<br>" message += "<br>"
@ -291,6 +309,13 @@ class Property
if self.need_hire_before != 0 if self.need_hire_before != 0
return 3 if (time_now + (self.need_hire_before).send(self.need_hire_before_unit) > stime) return 3 if (time_now + (self.need_hire_before).send(self.need_hire_before_unit) > stime)
end end
self.special_unavailable_dates.each do |dt|
unavailable_date = Date.parse(dt)
cd = (stime..etime) & (unavailable_date..unavailable_date)
if !cd.nil?
return 0
end
end
startt = self.start_date.nil? ? stime : self.start_date startt = self.start_date.nil? ? stime : self.start_date
endt = self.end_date.nil? ? etime : self.end_date endt = self.end_date.nil? ? etime : self.end_date
available = 1 if (startt > stime && endt > etime) available = 1 if (startt > stime && endt > etime)
@ -475,7 +500,7 @@ class Property
else else
b_datas = [] b_datas = []
end end
end end
break if available == false break if available == false
end end
end end
@ -665,7 +690,7 @@ class Property
tmp_relations_fields << k tmp_relations_fields << k
else else
org_k = k.to_s org_k = k.to_s
result = other_has_many_class.map do |k| result = other_has_many_class.map do |k|
belongs_to_class = k.classify.constantize.relations.select{|kk,v| v.macro == :belongs_to}.keys belongs_to_class = k.classify.constantize.relations.select{|kk,v| v.macro == :belongs_to}.keys
has_many_class = k.classify.constantize.relations.select{|kk,v| v.macro.to_s.start_with?('has') }.keys has_many_class = k.classify.constantize.relations.select{|kk,v| v.macro.to_s.start_with?('has') }.keys
if (belongs_to_class - tmp_singularize_relations_fields - [org_k]).count == 0 if (belongs_to_class - tmp_singularize_relations_fields - [org_k]).count == 0
@ -810,4 +835,4 @@ class Property
return new_object, clone_target return new_object, clone_target
end end
end end
end end

View File

@ -132,9 +132,35 @@
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
<%= f.label :can_be_hired, t("property_hire.can_be_hired"), :class => "control-label muted" %> <%= f.label :p_hire_start_time, t("property_hire.p_hire_start_time"), :class => "control-label muted" %>
<div class="controls"> <div class="controls">
<%= f.check_box :can_be_hired %> <%= f.datetime_picker :p_hire_start_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "start"}, :format => "yyyy/MM/dd hh:mm" %>
</div>
</div>
<div class="control-group">
<%= f.label :p_hire_end_time, t("property_hire.p_hire_end_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :p_hire_end_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "end"}, :format => "yyyy/MM/dd hh:mm" %>
</div>
</div>
<div class="control-group">
<%= f.label :recurring_enable, t("property_hire.recurring_enable"), :class => "control-label muted" %>
<div class="controls">
<%= f.check_box :recurring_enable %>
</div>
</div>
<div id="open-time" >
<div class="control-group">
<%= f.label :p_open_start_time, t("property_hire.p_open_start_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :p_open_start_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "start"}, :format => "yyyy/MM/dd" %>
</div>
</div>
<div class="control-group">
<%= f.label :p_open_end_time, t("property_hire.p_open_end_time"), :class => "control-label muted" %>
<div class="controls">
<%= f.datetime_picker :p_open_end_time, :picker_type => "date", :no_label => true, :new_record => @property.new_record?, :data=>{"picker-type" => "range", "range" => "end"}, :format => "yyyy/MM/dd" %>
</div>
</div> </div>
</div> </div>
<div class="control-group"> <div class="control-group">
@ -371,6 +397,35 @@
<% end %> <% end %>
</div> </div>
</div> </div>
<div class="control-group">
<label class="control-label muted"><%=t("property_hire.special_unavailable_date")%></label>
<div class="controls" id="special_unavailable_date_holder">
<% @property.special_unavailable_dates.each_with_index do |dt, idx| %>
<div class="temp_date_holder" style="margin-bottom:5px;">
<div class="date_picker input-append" style="margin-bottom:3px;">
<input placeholder="yyyy/MM/dd" class="input-large" data-format="yyyy/MM/dd" type="text" name="property[special_unavailable_dates][]" title="yyyy/MM/dd" autocomplete="off" value="<%= dt %>">
<span class="add-on clearDate"><i class="icons-cross-3"></i></span>
<span class="add-on deleteDate"><i class="icon-trash"></i></span>
</div>
<div class="tab-panel">
<div class="tab-content active" id="special_unavailable_title_<%= idx %>_en">
<input type="text" name="property[special_unavailable_dates_title][][en]" value="<%= @property.special_unavailable_dates_title[idx]["en"] %>">
</div>
<div class="tab-content" id="special_unavailable_title_<%= idx %>_zh_tw">
<input type="text" name="property[special_unavailable_dates_title][][zh_tw]" value="<%= @property.special_unavailable_dates_title[idx]["zh_tw"] %>">
</div>
<div class="btn-group" data-toggle="buttons-radio">
<a data-toggle="tab" class="btn active" for="en" href="#special_unavailable_title_<%= idx %>_en" aria-expanded="true" aria-pressed="true"><%= t("en") %></a>
<a data-toggle="tab" class="btn" for="zh_tw" href="#special_unavailable_title_<%= idx %>_zh_tw" aria-expanded="true" aria-pressed="true"><%= t("zh_tw") %></a>
</div>
</div>
</div>
<% end %>
</div>
<div class="controls">
<button class="primary" id="add_special_unavailable_date">Add</button>
</div>
</div>
<div class="control-group"> <div class="control-group">
<%= f.label :start_date, t("property_hire.start_date"), :class => "control-label muted" %> <%= f.label :start_date, t("property_hire.start_date"), :class => "control-label muted" %>
<div class="controls"> <div class="controls">
@ -900,6 +955,55 @@
$(this).parents('.image_group').remove(); $(this).parents('.image_group').remove();
} }
}); });
// $(document).on("click", "#property_can_be_hired", function () {
// if($(this).is(":checked")){
// $("#open-time").attr("class","show");
// }else{
// $("#open-time").attr("class","hide");
// $("#open-time").find("input").val("");
// }
// })
var special_unavailable_title_counter = <%= @property.special_unavailable_dates.count %>;
$(document).on("click","#add_special_unavailable_date", function(){
var datepicker = $('<div class="date_picker input-append" style="margin-bottom:3px;"> \
<input placeholder="yyyy/MM/dd" class="input-large" data-format="yyyy/MM/dd" type="text" name="property[special_unavailable_dates][]" title="yyyy/MM/dd" autocomplete="off"> \
<span class="add-on clearDate"><i class="icons-cross-3"></i></span> \
<span class="add-on deleteDate"><i class="icon-trash"></i></span> \
</div>');
var id = "special_unavailable_title_" + special_unavailable_title_counter;
var title = $('<div class="tab-panel"> \
<div class="tab-content active" id="' + id + '_en"> \
<input type="text" name="property[special_unavailable_dates_title][][en]" value=""> \
</div> \
<div class="tab-content" id="' + id + '_zh_tw"> \
<input type="text" name="property[special_unavailable_dates_title][][zh_tw]" value=""> \
</div> \
<div class="btn-group" data-toggle="buttons-radio"> \
<a data-toggle="tab" class="btn active" for="en" href="#' + id + '_en" aria-expanded="true" aria-pressed="true"><%= t("en") %></a> \
<a data-toggle="tab" class="btn" for="zh_tw" href="#' + id + '_zh_tw" aria-expanded="true" aria-pressed="true"><%= t("zh_tw") %></a> \
</div> \
</div>');
datepicker.find('input').datepicker({
dateFormat : "yy/mm/dd"
});
var html = $('<div class="temp_date_holder" style="margin-bottom:5px;"></div>');
html.append(datepicker);
html.append(title);
$("#special_unavailable_date_holder").append(html);
special_unavailable_title_counter++;
return false;
})
$(document).on("click","#special_unavailable_date_holder .clearDate", function (params) {
$(this).parents('.default_picker,.time_picker,.date_picker').eq(-1).find('input').val('')
$(this).parents('.default_picker,.time_picker,.date_picker').eq(-1).find('input').trigger('change')
})
$(document).on("click","#special_unavailable_date_holder .deleteDate", function (params) {
$(this).parents('#special_unavailable_date_holder .temp_date_holder').eq(-1).remove();
})
</script> </script>

View File

@ -32,7 +32,7 @@
<%= property.get_location_name %> <%= property.get_location_name %>
</td> </td>
<td> <td>
<% if property.can_be_hired %> <% if property.can_reserve %>
<span class="badge badge-success">Yes</span> <span class="badge badge-success">Yes</span>
<% else %> <% else %>
<span class="badge badge-important">No</span> <span class="badge badge-important">No</span>

View File

@ -33,7 +33,11 @@
<% end %> <% end %>
</td> </td>
<td> <td>
<a href="<%= show_booking_details_admin_property_hire_path(p_hire, :page => params[:page]) %>" class="btn btn-info">View</a> <%
=begin%>
<a href="<%= show_booking_details_admin_property_hire_path(p_hire, :page => params[:page]) %>" class="btn btn-info">View</a>
<%
=end%>
<a href="<%= delete_booking_details_admin_property_hire_path(p_hire, :page => params[:page]) %>" class="btn btn-danger" data-method="delete" data-confirm="Are you sure?">Delete</a> <a href="<%= delete_booking_details_admin_property_hire_path(p_hire, :page => params[:page]) %>" class="btn btn-danger" data-method="delete" data-confirm="Are you sure?">Delete</a>
</td> </td>
</tr> </tr>

View File

@ -23,6 +23,7 @@
input_col -= 2 input_col -= 2
end end
%> %>
<style type="text/css"> <style type="text/css">
.full-size-img img { .full-size-img img {
width: 100%; width: 100%;
@ -171,7 +172,7 @@
margin-left: 0; margin-left: 0;
} }
</style> </style>
<% if !property.can_be_hired_frontend %> <% if !property.can_be_hired %>
<script type="text/javascript"> <script type="text/javascript">
alert("This property is unavailable for hire."); alert("This property is unavailable for hire.");
window.location.href = "<%= "/" + I18n.locale.to_s + url %>"; window.location.href = "<%= "/" + I18n.locale.to_s + url %>";
@ -319,7 +320,14 @@
<div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div> <div id="event_quick_view" class="modal" style="width: 300px; display:none; margin:0 0 0 0;"></div>
<script type="text/javascript"> <script type="text/javascript">
var property_id = "<%= property.id.to_s %>"; var property_id = "<%= property.id.to_s %>";
var calendar = new Calendar("#calendar",property_id); var valid_range = {}
<% if property.p_open_start_time %>
valid_range["start"] = "<%= property.p_open_start_time.strftime("%Y-%m-%d") %>"
<% end %>
<% if property.p_open_end_time %>
valid_range["end"] = "<%= (property.p_open_end_time + 1.day).strftime("%Y-%m-%d") %>"
<% end %>
var calendar = new Calendar("#calendar", property_id, valid_range);
function pick_hire_date(date,allow_times){ function pick_hire_date(date,allow_times){
if(window.processing_hire) if(window.processing_hire)
return; return;
@ -443,179 +451,182 @@
</script> </script>
<% end %> <% end %>
<div class="col-lg-<%=right_col%>"> <div class="col-lg-<%=right_col%>">
<%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal", id: "hire_form" } do |f| %> <% if property.can_reserve === true %>
<% if property.set_availability %> <%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal", id: "hire_form" } do |f| %>
<div class="form-group"> <% if property.set_availability %>
<%= f.label :date, "*"+t("property_hire.date"), :class => "col-sm-#{label_col} control-label" %> <div class="form-group">
<div class="col-sm-<%=input_col%>" id="date_target_block"> <%= f.label :date, "*"+t("property_hire.date"), :class => "col-sm-#{label_col} control-label" %>
<% if calendar_type == 0 %> <div class="col-sm-<%=input_col%>" id="date_target_block">
<%= f.text_field :date, :value=>(recover ? f.object.date.to_s : t("property_hire.please_choose_date")),:readonly=>"",:onclick=>"goto_calendar()" %> <% if calendar_type == 0 %>
<%= f.text_field :date, :value=>(recover ? f.object.date.to_s : t("property_hire.please_choose_date")),:readonly=>"",:onclick=>"goto_calendar()" %>
<% else %>
<%= f.datetime_picker :date, :no_label => true, :new_record => hire.new_record? && !recover ,:class => "pull-left", :picker_type => "date", :format=>"yyyy/MM/dd", :data=>{ "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
<% end %>
</div>
</div>
<div class="form-group">
<%= f.label :time, "*"+t("property_hire.time"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>" id="hire_time_range_block">
<% property_day_setting = recover ? hire.property_day_setting : nil %>
<% if property_day_setting %>
<%= select_tag "#{f.object_name}[time]", options_for_select([[t("property_hire.please_select"),""],[property_day_setting.title,property_day_setting.id.to_s]],hire.property_day_setting_id), :required=>"required" %>
<% else %>
<% if property.calendar_type == 0 %>
<%= f.text_field :time, :value=>t("property_hire.please_choose_date"),:readonly=>"",:onclick=>"goto_calendar()" %>
<% else %>
<%= select_tag "#{f.object_name}[time]", options_for_select([[t("property_hire.please_choose_date"),""]]), :required=>"required" %>
<% end %>
<% end %>
</div>
</div>
<% else %> <% else %>
<%= f.datetime_picker :date, :no_label => true, :new_record => hire.new_record? && !recover ,:class => "pull-left", :picker_type => "date", :format=>"yyyy/MM/dd", :data=>{ "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %> <div class="form-group">
<% end %> <%= f.label :start_time, "*"+t("property_hire.start_time"), :class => "col-sm-#{label_col} control-label" %>
</div> <% if property.calendar_type == 0 %>
</div> <div class="col-sm-<%=input_col%>">
<div class="form-group"> <%= f.datetime_picker :start_time, :no_label => true, :new_record => hire.new_record? && !recover, :class => "pull-left", :data=>{"picker-type" => "range", "range" => "start", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
<%= f.label :time, "*"+t("property_hire.time"), :class => "col-sm-#{label_col} control-label" %> <button type="button" id="pick_start_date" onclick="change_pick(this)" class="btn btn-primary btn-sm pull-left" style="margin-left: 1em;"><%=t("property_hire.pick_from_calendar")%></button>
<div class="col-sm-<%=input_col%>" id="hire_time_range_block"> </div>
<% property_day_setting = recover ? hire.property_day_setting : nil %>
<% if property_day_setting %>
<%= select_tag "#{f.object_name}[time]", options_for_select([[t("property_hire.please_select"),""],[property_day_setting.title,property_day_setting.id.to_s]],hire.property_day_setting_id), :required=>"required" %>
<% else %>
<% if property.calendar_type == 0 %>
<%= f.text_field :time, :value=>t("property_hire.please_choose_date"),:readonly=>"",:onclick=>"goto_calendar()" %>
<% else %>
<%= select_tag "#{f.object_name}[time]", options_for_select([[t("property_hire.please_choose_date"),""]]), :required=>"required" %>
<% end %>
<% end %>
</div>
</div>
<% else %>
<div class="form-group">
<%= f.label :start_time, "*"+t("property_hire.start_time"), :class => "col-sm-#{label_col} control-label" %>
<% if property.calendar_type == 0 %>
<div class="col-sm-<%=input_col%>">
<%= f.datetime_picker :start_time, :no_label => true, :new_record => hire.new_record? && !recover,:class => "pull-left", :data=>{"picker-type" => "range", "range" => "start","fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
<button type="button" id="pick_start_date" onclick="change_pick(this)" class="btn btn-primary btn-sm pull-left" style="margin-left: 1em;"><%=t("property_hire.pick_from_calendar")%></button>
</div>
<% end %>
</div>
<div class="form-group">
<%= f.label :end_time, "*"+t("property_hire.end_time"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>">
<%= f.datetime_picker :end_time, :no_label => true, :new_record => hire.new_record? && !recover,:class => "pull-left", :data=>{"picker-type" => "range", "range" => "end","fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
<button type="button" id="pick_end_date" onclick="change_pick(this)" class="btn btn-primary btn-sm pull-left" style="margin-left: 1em;"><%=t("property_hire.pick_from_calendar")%></button>
</div>
</div>
<% end %>
<!-- ############# recurring ############# -->
<div class="form-group">
<%= f.label :recurring, t("property_hire.recurring"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-1">
<%= f.check_box :recurring %>
</div>
</div>
<div id="recurring-block" <%= hire.recurring ? "" : "style=display:none;" %>>
<div class="form-group">
<%= f.label :recurring_interval, t("property_hire.recurring_interval"), :class => "col-sm-#{label_col} control-label" %>
<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;"}} %>
</div>
</div>
<div class="form-group">
<%= f.label :recurring_end_date, "*"+t("property_hire.recurring_end_date"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>">
<%= f.datetime_picker :recurring_end_date, :no_label => true, :new_record => hire.new_record? && !recover, :class=>"pull-left", :data=>{"fv-validation" => "requiredifrecurring;", "fv-messages" => "Cannot be empty;"} %>
<% if calendar_type == 0 %>
<button type="button" id="pick_recurring_end_date" onclick="change_pick(this)" class="btn btn-primary btn-sm pull-left" style="margin-left: 1em;"><%=t("property_hire.pick_from_calendar")%></button>
<% end %>
</div>
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-<%=label_col%> col-sm-<%=input_col%>">
<div id="property-avaialable-alert" style="margin-bottom: 5px; padding: 10px;<%= 'display: none;' unless recover %>" class="alert alert-success" role="alert"><%=t("property_hire.this_property_is_available",:default=>"<b>Hooray! </b>This property is available.").html_safe%></div>
<div id="property-unavaialable-alert" style="margin-bottom: 5px; padding: 10px; display: none;" class="alert alert-danger" role="alert"><b>Sorry! </b><span> This property is available.</span></div>
<div id="values-alert" style="margin-bottom: 5px; padding: 10px; display: none;" class="alert alert-warning" role="alert">
<% hint1 = t("property_hire.please_select_recurring_interval_and_recurring_end_time",:default=>"") %>
<% if hint1 == ""%>
<b>Please! </b><span> Select an interval time and recurring event end date.</span>
<% else %>
<span><b><%=hint1%></b></span>
<% end %>
</div>
</div>
<% if property.set_unavailibility %>
<div class="col-sm-offset-<%=label_col%> col-sm-<%=input_col%>">
<b><%= t("property_hire.Unavailibility_Schedule") %></b>
<div>
<%= property.render_unavailable_message%>
</div>
</div>
<% end %>
</div>
<div class="form-group">
<label for="" class="col-sm-<%=label_col%> control-label"></label>
<div class="col-sm-<%=input_col%>">
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary"><%= t('property_hire.check_availibility') %></a>
<img style="display: none;" width="40" src="/assets/spin.gif" id="spinner" />
</div>
</div>
<% default_values = {"hiring_person_email" => ( current_user.member_profile.email rescue ""),
"hiring_person_number" => ( current_user.member_profile.mobile_no rescue ""),
"hiring_person_name" => ( current_user.name rescue "")
} %>
<% if recover
default_values = default_values.merge(Property::FIELDSNAME.map{|f| [f,hire.send(f)]}.to_h)
end %>
<%= f.hidden_field :hiring_person_id, :value => (current_user.member_profile.id.to_s rescue "") %>
<% custom_field_inputs = {} %>
<% custom_field_type = {"note_for_hire"=>"text_area"} %>
<% if(property.enable_notes_selector rescue false) %>
<% custom_field_inputs["note_for_hire"] = render(:partial=>"property_hires/notes_selector",:locals=>{:f=>f,:property=>property,:label_col=>label_col,:input_col=>input_col,:hire=>nil}) %>
<% end %>
<% fields_name = property.get_all_fields %>
<% has_p_hire_fields = property.p_hire_fields_enabled.count != 0
p_hire_fields = {}
if has_p_hire_fields
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
end
%>
<% @form_index = 0 %>
<% fields_name.each do |field_name| %>
<% if has_p_hire_fields && field_name.include?("p_hire_fields") %>
<div class="form-group">
<% rf = p_hire_fields[field_name.sub("p_hire_fields.",'')] %>
<% next if rf.nil? %>
<%= rf.block_helper(property,@form_index,false,"p_hire",hire, rf.to_require,label_col) %>
</div>
<% @form_index = @form_index +1 %>
<% else %>
<% if(property[field_name]["enable"] == "1" rescue true) %>
<% required = (property[field_name]["required"] == "true" rescue false) %>
<% if custom_field_inputs[field_name] %>
<%= custom_field_inputs[field_name] %>
<% else %>
<div class="form-group">
<%= f.label field_name, (required ? "*" : "") + property.custom_text(field_name,"name"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>">
<% placeholder = property.custom_text(field_name,"placeholder") %>
<% if custom_field_type[field_name] %>
<%= f.send(custom_field_type[field_name], field_name , {:class => "form-control", :placeholder => placeholder, :value => default_values[field_name], :required=>(required ? 'required' : nil)}) %>
<% else %>
<%= f.text_field field_name, :class => "form-control", :placeholder => placeholder, :value => default_values[field_name], :required=>(required ? 'required' : nil) %>
<% end %>
</div>
</div>
<% end %> <% end %>
</div>
<div class="form-group">
<%= f.label :end_time, "*"+t("property_hire.end_time"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>">
<%= f.datetime_picker :end_time, :no_label => true, :new_record => hire.new_record? && !recover,:class => "pull-left", :data=>{"picker-type" => "range", "range" => "end","fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
<button type="button" id="pick_end_date" onclick="change_pick(this)" class="btn btn-primary btn-sm pull-left" style="margin-left: 1em;"><%=t("property_hire.pick_from_calendar")%></button>
</div>
</div>
<% end %>
<% if property.recurring_enable %>
<!-- ############# recurring ############# -->
<div class="form-group">
<%= f.label :recurring, t("property_hire.recurring"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-1">
<%= f.check_box :recurring %>
</div>
</div>
<div id="recurring-block" <%= hire.recurring ? "" : "style=display:none;" %>>
<div class="form-group">
<%= f.label :recurring_interval, t("property_hire.recurring_interval"), :class => "col-sm-#{label_col} control-label" %>
<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;"}} %>
</div>
</div>
<div class="form-group">
<%= f.label :recurring_end_date, "*"+t("property_hire.recurring_end_date"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>">
<%= f.datetime_picker :recurring_end_date, :no_label => true, :new_record => hire.new_record? && !recover, :class=>"pull-left", :data=>{"fv-validation" => "requiredifrecurring;", "fv-messages" => "Cannot be empty;"} %>
<% if calendar_type == 0 %>
<button type="button" id="pick_recurring_end_date" onclick="change_pick(this)" class="btn btn-primary btn-sm pull-left" style="margin-left: 1em;"><%=t("property_hire.pick_from_calendar")%></button>
<% end %>
</div>
</div>
</div>
<% end %>
<div class="form-group">
<div class="col-sm-offset-<%=label_col%> col-sm-<%=input_col%>">
<div id="property-avaialable-alert" style="margin-bottom: 5px; padding: 10px;<%= 'display: none;' unless recover %>" class="alert alert-success" role="alert"><%=t("property_hire.this_property_is_available",:default=>"<b>Hooray! </b>This property is available.").html_safe%></div>
<div id="property-unavaialable-alert" style="margin-bottom: 5px; padding: 10px; display: none;" class="alert alert-danger" role="alert"><b>Sorry! </b><span> This property is available.</span></div>
<div id="values-alert" style="margin-bottom: 5px; padding: 10px; display: none;" class="alert alert-warning" role="alert">
<% hint1 = t("property_hire.please_select_recurring_interval_and_recurring_end_time",:default=>"") %>
<% if hint1 == ""%>
<b>Please! </b><span> Select an interval time and recurring event end date.</span>
<% else %>
<span><b><%=hint1%></b></span>
<% end %>
</div>
</div>
<% if property.set_unavailibility %>
<div class="col-sm-offset-<%=label_col%> col-sm-<%=input_col%>">
<b><%= t("property_hire.Unavailibility_Schedule") %></b>
<div>
<%= property.render_unavailable_message%>
</div>
</div>
<% end %>
</div>
<div class="form-group">
<label for="" class="col-sm-<%=label_col%> control-label"></label>
<div class="col-sm-<%=input_col%>">
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary"><%= t('property_hire.check_availibility') %></a>
<img style="display: none;" width="40" src="/assets/spin.gif" id="spinner" />
</div>
</div>
<% default_values = {"hiring_person_email" => ( current_user.member_profile.email rescue ""),
"hiring_person_number" => ( current_user.member_profile.mobile_no rescue ""),
"hiring_person_name" => ( current_user.name rescue "")
} %>
<% if recover
default_values = default_values.merge(Property::FIELDSNAME.map{|f| [f,hire.send(f)]}.to_h)
end %>
<%= f.hidden_field :hiring_person_id, :value => (current_user.member_profile.id.to_s rescue "") %>
<% custom_field_inputs = {} %>
<% custom_field_type = {"note_for_hire"=>"text_area"} %>
<% if(property.enable_notes_selector rescue false) %>
<% custom_field_inputs["note_for_hire"] = render(:partial=>"property_hires/notes_selector",:locals=>{:f=>f,:property=>property,:label_col=>label_col,:input_col=>input_col,:hire=>nil}) %>
<% end %>
<% fields_name = property.get_all_fields %>
<% has_p_hire_fields = property.p_hire_fields_enabled.count != 0
p_hire_fields = {}
if has_p_hire_fields
p_hire_fields = property.p_hire_fields_enabled.map{|rf| [rf.id.to_s,rf]}.to_h
end
%>
<% @form_index = 0 %>
<% fields_name.each do |field_name| %>
<% if has_p_hire_fields && field_name.include?("p_hire_fields") %>
<div class="form-group">
<% rf = p_hire_fields[field_name.sub("p_hire_fields.",'')] %>
<% next if rf.nil? %>
<%= rf.block_helper(property,@form_index,false,"p_hire",hire, rf.to_require,label_col) %>
</div>
<% @form_index = @form_index +1 %>
<% else %>
<% if(property[field_name]["enable"] == "1" rescue true) %>
<% required = (property[field_name]["required"] == "true" rescue false) %>
<% if custom_field_inputs[field_name] %>
<%= custom_field_inputs[field_name] %>
<% else %>
<div class="form-group">
<%= f.label field_name, (required ? "*" : "") + property.custom_text(field_name,"name"), :class => "col-sm-#{label_col} control-label" %>
<div class="col-sm-<%=input_col%>">
<% placeholder = property.custom_text(field_name,"placeholder") %>
<% if custom_field_type[field_name] %>
<%= f.send(custom_field_type[field_name], field_name , {:class => "form-control", :placeholder => placeholder, :value => default_values[field_name], :required=>(required ? 'required' : nil)}) %>
<% else %>
<%= f.text_field field_name, :class => "form-control", :placeholder => placeholder, :value => default_values[field_name], :required=>(required ? 'required' : nil) %>
<% end %>
</div>
</div>
<% end %>
<% end %>
<% end %> <% end %>
<% end %> <% end %>
<% end %> <% if allow_no_logins_user && current_user.nil? %>
<% if allow_no_logins_user && current_user.nil? %> <!-- 驗證碼 -->
<!-- 驗證碼 --> <div class="form-group">
<label for="note" class="col-sm-<%=label_col%> control-label"><%= t('property_hire.recaptcha.recaptcha') %></label>
<div class="col-sm-<%=input_col%>">
<%= gotcha_error %>
<%= gotcha %>
</div>
</div>
<% end %>
<div class="form-group"> <div class="form-group">
<label for="note" class="col-sm-<%=label_col%> control-label"><%= t('property_hire.recaptcha.recaptcha') %></label> <div class="col-sm-offset-<%=label_col%> col-sm-<%=input_col%>">
<div class="col-sm-<%=input_col%>"> <% if f.object.id.present? %>
<%= gotcha_error %> <%= f.hidden_field :id %>
<%= gotcha %> <% end %>
<div class="nano"><div class="content"></div></div>
<%= f.submit t("property_hire.save"), :class => "btn btn-primary" %>
<%= f.hidden_field :property_id, :value => property.id %>
<input type="hidden" name="url" value="<%= url %>" />
<input type="hidden" id="dates_validated" name="dates_validated" value="<%=recover ? 1 : 0 %>" data-fv-validation="checkForDates;" data-fv-messages="Please make sure first if dates are available.;">
</div> </div>
</div> </div>
<% end %> <% end %>
<div class="form-group">
<div class="col-sm-offset-<%=label_col%> col-sm-<%=input_col%>">
<% if f.object.id.present? %>
<%= f.hidden_field :id %>
<% end %>
<div class="nano"><div class="content"></div></div>
<%= f.submit t("property_hire.save"), :class => "btn btn-primary" %>
<%= f.hidden_field :property_id, :value => property.id %>
<input type="hidden" name="url" value="<%= url %>" />
<input type="hidden" id="dates_validated" name="dates_validated" value="<%=recover ? 1 : 0 %>" data-fv-validation="checkForDates;" data-fv-messages="Please make sure first if dates are available.;">
</div>
</div>
<% end %> <% end %>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
@ -627,6 +638,7 @@
if(timezone[0] != "-"){ if(timezone[0] != "-"){
timezone = "+" + timezone; timezone = "+" + timezone;
} }
$("#p_hire_date").on("change",function(){ $("#p_hire_date").on("change",function(){
var _this = $(this); var _this = $(this);
var date = new Date(_this.val()); var date = new Date(_this.val());
@ -783,4 +795,18 @@
} }
}) })
</script> </script>
<script>
$(document).ready(function(){
<% if property.p_hire_start_time %>
$("#p_hire_start_time").datepicker('option', 'minDate', new Date("<%= property.p_open_start_time.strftime("%Y-%m-%d") %>"));
$("#p_hire_end_time").datepicker('option', 'minDate', new Date("<%= property.p_open_start_time.strftime("%Y-%m-%d") %>"));
$("#p_hire_recurring_end_date").datepicker('option', 'minDate', new Date("<%= property.p_open_start_time.strftime("%Y-%m-%d") %>"));
<% end %>
<% if property.p_hire_end_time %>
$("#p_hire_start_time").datepicker('option', 'maxDate', new Date("<%= property.p_open_end_time.strftime("%Y-%m-%d") %>"));
$("#p_hire_end_time").datepicker('option', 'maxDate', new Date("<%= property.p_open_end_time.strftime("%Y-%m-%d") %>"));
$("#p_hire_recurring_end_date").datepicker('option', 'maxDate', new Date("<%= property.p_open_end_time.strftime("%Y-%m-%d") %>"));
<% end %>
})
</script>
<% end %> <% end %>

View File

@ -1 +1,10 @@
<%= render_view %> <% OrbitHelper.render_css_in_head(["property_hire_fullcalendar.css","property_hire_calendar"]) %>
<script type="text/javascript" src="/assets/property_hire_fullcalendar.min.js"></script>
<script type="text/javascript" src="/assets/property_hire_calendar_frontend.js"></script>
<% data = action_data %>
<% if data["manage_booking_btn"] %>
<div class="pull-right">
<a href="<%= data["manage_booking_url"] %>" class="btn btn-primary" target="_blank"><%= data["manage_booking"] %>
</div>
<% end %>
<%= render_view %>

View File

@ -137,6 +137,10 @@ en:
set_unavailibility: Set Unavailability set_unavailibility: Set Unavailability
limit_start_time: Limit start time limit_start_time: Limit start time
limit_end_time: Limit end time limit_end_time: Limit end time
p_hire_start_time: Start Date
p_hire_end_time: End Date
p_open_start_time: Open Date
p_open_end_time: Close Date
start_time: Start Time start_time: Start Time
end_time: End Time end_time: End Time
weekdays: Unavailable days in a week weekdays: Unavailable days in a week
@ -174,4 +178,7 @@ en:
tel_of_contact_person: Tel. of contact person tel_of_contact_person: Tel. of contact person
mobile_phone_of_contact_person: Mobile phone of contact person mobile_phone_of_contact_person: Mobile phone of contact person
contact_person_Email: Contact person Email contact_person_Email: Contact person Email
contact_person_department: Contact person department contact_person_department: Contact person department
special_unavailable_date: Special Unavailable Date
manage_booking: Manage Bookings
recurring_enable: Enable Recurring

View File

@ -164,6 +164,10 @@ zh_tw:
weekdays: 每週不開放預約日 weekdays: 每週不開放預約日
start_date: 套用限制開始日期 start_date: 套用限制開始日期
end_date: 套用限制結束日期 end_date: 套用限制結束日期
p_hire_start_time: 上架日期
p_hire_end_time: 下架日期
p_open_start_time: 開放日期
p_open_end_time: 截止日期
description: Unavailability Description description: Unavailability Description
unavailibility_note: Unavailability Note unavailibility_note: Unavailability Note
property_location: Property Location property_location: Property Location
@ -196,4 +200,7 @@ zh_tw:
tel_of_contact_person: 聯絡人聯絡電話 tel_of_contact_person: 聯絡人聯絡電話
mobile_phone_of_contact_person: 聯絡人行動電話 mobile_phone_of_contact_person: 聯絡人行動電話
contact_person_Email: 聯絡Email contact_person_Email: 聯絡Email
contact_person_department: 聯絡人服務單位 contact_person_department: 聯絡人服務單位
special_unavailable_date: 特定不開放預約⽇
manage_booking: 管理我的預約
recurring_enable: 啟用週期性預約