diff --git a/app/assets/javascripts/property_hire_calendar_frontend.js b/app/assets/javascripts/property_hire_calendar_frontend.js index ede39cb..a7771d6 100644 --- a/app/assets/javascripts/property_hire_calendar_frontend.js +++ b/app/assets/javascripts/property_hire_calendar_frontend.js @@ -104,8 +104,7 @@ window.getDateString = function(date, format,is_chinese) { } 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; display_hire_event = (display_hire_event == undefined ? true : display_hire_event); this.title = $("#current_title"); @@ -136,6 +135,7 @@ var Calendar = function(dom,property_id,currentView,display_hire_event){ editable: false, selectable: true, width: "100%", + validRange: valid_range, events: function(args, success_callback, fail_callback) { var start = args.start; 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;} }; + this.destroy = function () { + c.calendar_dom.fullCalendar("destroy"); + } + this.renderEvent = function(eventStick){ if(eventStick.recurring === true) c.calendar_dom.calendar.refetchEvents(); diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 901c9b5..7e96b3d 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -248,7 +248,7 @@ class Admin::PropertyHiresController < OrbitAdminController def custom_fields @field_name = 'property' uid = params[:id].split("-").last - @attribute = Property.find_by(:uid=>uid) + @attribute = Property.find_by(:uid=>uid) @attribute_type = 'property' @class = 'properties' end @@ -262,7 +262,7 @@ class Admin::PropertyHiresController < OrbitAdminController params.require(:property_location).permit! end 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) if(property.enable_notes_selector rescue false) 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 = I18n.t("property_hire.none") if value_text.blank? note_texts += (name + ":"+value_text) - note_texts += "
".html_safe + note_texts += "
".html_safe end p_hire_params["note_for_hire"] = note_texts p_hire_params.delete("notes_selector") @@ -319,4 +319,4 @@ class Admin::PropertyHiresController < OrbitAdminController @email_set << email_set end end -end \ No newline at end of file +end diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 7c31282..4664840 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -22,39 +22,44 @@ class PropertyHiresController < ApplicationController { "properties" => data, "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) } end def index_data(properties, url) data = properties.collect do |property| - actions = [] - url_to_show = "#{url}/#{property.to_param}" + actions = [] + url_to_show = "#{url}/#{property.to_param}?method=hire" hire_url = nil - if property.can_be_hired_frontend - hire_url = url_to_show + "?method=hire" + if property.can_be_hired_frontend && property.can_reserve + hire_url = url_to_show actions << { "text" => t("property_hire.hire"), "btn-class" => "btn-primary", "link" => hire_url } 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 << { "text" => t("property_hire.view_calendar"), "btn-class" => "btn-info", - "link" => url_to_show + "?method=view_calendar" + "link" => url_to_show } end if property.disable_content_page if 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 { "title" => property.title, + "id" => property.id.to_s, "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), "url_to_show" => url_to_show, @@ -65,7 +70,7 @@ class PropertyHiresController < ApplicationController end 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 data = index_data(properties, url) headers = [ @@ -114,7 +119,7 @@ class PropertyHiresController < ApplicationController "header" => t("property_hire.property_number"), "value" => property.property_number } - end + end data << { "header" => t("property_hire.can_be_hired"), "value" => (property.can_be_hired ? "Yes" : "No") @@ -159,7 +164,7 @@ class PropertyHiresController < ApplicationController "header" => t("property_hire.location"), "value" => property.get_location_name } - end + end actions = [] url_to_show = OrbitHelper.url_to_show(property.to_param) if property.can_be_hired_frontend @@ -185,7 +190,7 @@ class PropertyHiresController < ApplicationController "back_url" => page.url } } - + end def view_calendar @@ -357,8 +362,11 @@ class PropertyHiresController < ApplicationController events = events.map{|e| e.as_json} allevents = events.inject(re, :<<) allevents = allevents.sort_by{|e| e[:start]} + Rails.logger.info allevents @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_start_time = property.start_time.blank? ? "00:00" : property.start_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 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 + if @special_unavailable_dates.count > 0 + allevents += special_unavailable_dates_labels(property) + end end end respond_to do |format| @@ -389,8 +403,20 @@ class PropertyHiresController < ApplicationController format.json { render json: allevents.to_json } 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) available = true + if @special_unavailable_dates.include?(date) + available = false + end if @check_setting && allow_times.select{|a| !a[5]}.count != 0 available = (date > @check_end_date rescue false) || (date < @check_start_date rescue false) unless available @@ -420,7 +446,7 @@ class PropertyHiresController < ApplicationController endt = endt.in_time_zone(Time.zone) start_wday = startt.wday start_date = startt.to_date - @start_date = start_date + @start_date = start_date end_date = endt.to_date @end_date = end_date @first_check_time = startt.strftime("%H:%M") @@ -481,7 +507,7 @@ class PropertyHiresController < ApplicationController end else @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} if i.nil? if @need_check_events.length != 0 && @need_check_events[-1][0] <= tmp_date @@ -535,7 +561,7 @@ class PropertyHiresController < ApplicationController private 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 if(property.enable_notes_selector rescue false) 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 = I18n.t("property_hire.none") if value_text.blank? note_texts += (name + ":"+value_text) - note_texts += "
".html_safe + note_texts += "
".html_safe end p_hire_params["note_for_hire"] = note_texts p_hire_params.delete("notes_selector") @@ -556,8 +582,3 @@ class PropertyHiresController < ApplicationController end end - - - - - diff --git a/app/models/p_hire.rb b/app/models/p_hire.rb index e5f2130..f82ee6b 100644 --- a/app/models/p_hire.rb +++ b/app/models/p_hire.rb @@ -53,9 +53,11 @@ class PHire if options[:recurring] recurring = options[:recurring] end + title = startt.strftime("%H:%M") + " ~ " + endt.strftime("%H:%M") + " " + self.hiring_person_name { :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_name => self.hiring_person_name, :note => self.note_for_hire || "", @@ -189,4 +191,4 @@ class PHire end while (start_time += step_interval) <= recurring_end_date end -end \ No newline at end of file +end diff --git a/app/models/property.rb b/app/models/property.rb index c397c11..5d77347 100644 --- a/app/models/property.rb +++ b/app/models/property.rb @@ -26,8 +26,13 @@ class Property field :owner_phone field :price field :other_location - - mount_uploader :image, ImageUploader + field :p_hire_start_time, type: DateTime + 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 field :can_hire_before_months, type: Integer, default: 0 @@ -36,6 +41,8 @@ class Property field :start_time field :end_time 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 :end_date, type: DateTime field :description, :localize => true @@ -77,7 +84,8 @@ class Property accepts_nested_attributes_for :property_files, :allow_destroy => true has_many :property_links, :autosave => true, :dependent => :destroy 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 = [ "Sunday", "Monday", @@ -133,6 +141,13 @@ class Property after_save do self.change_day_setting_status 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 self.p_hire_fields.where(disabled: false) end @@ -255,6 +270,9 @@ class Property message += hint1 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 message != "" message += "
" @@ -291,6 +309,13 @@ class Property if self.need_hire_before != 0 return 3 if (time_now + (self.need_hire_before).send(self.need_hire_before_unit) > stime) 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 endt = self.end_date.nil? ? etime : self.end_date available = 1 if (startt > stime && endt > etime) @@ -475,7 +500,7 @@ class Property else b_datas = [] end - end + end break if available == false end end @@ -665,7 +690,7 @@ class Property tmp_relations_fields << k else 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 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 @@ -810,4 +835,4 @@ class Property return new_object, clone_target end end -end \ No newline at end of file +end diff --git a/app/views/admin/property_hires/_form.html.erb b/app/views/admin/property_hires/_form.html.erb index 2ccea8d..8fc3e55 100644 --- a/app/views/admin/property_hires/_form.html.erb +++ b/app/views/admin/property_hires/_form.html.erb @@ -132,9 +132,35 @@
- <%= 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" %>
- <%= 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" %> +
+
+
+ <%= f.label :p_hire_end_time, t("property_hire.p_hire_end_time"), :class => "control-label muted" %> +
+ <%= 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" %> +
+
+
+ <%= f.label :recurring_enable, t("property_hire.recurring_enable"), :class => "control-label muted" %> +
+ <%= f.check_box :recurring_enable %> +
+
+
+
+ <%= f.label :p_open_start_time, t("property_hire.p_open_start_time"), :class => "control-label muted" %> +
+ <%= 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" %> +
+
+
+ <%= f.label :p_open_end_time, t("property_hire.p_open_end_time"), :class => "control-label muted" %> +
+ <%= 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" %> +
@@ -371,6 +397,35 @@ <% end %>
+
+ +
+ <% @property.special_unavailable_dates.each_with_index do |dt, idx| %> +
+
+ + + +
+
+
+ "> +
+
+ "> +
+ +
+
+ <% end %> +
+
+ +
+
<%= f.label :start_date, t("property_hire.start_date"), :class => "control-label muted" %>
@@ -900,6 +955,55 @@ $(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 = $('
\ + \ + \ + \ +
'); + + var id = "special_unavailable_title_" + special_unavailable_title_counter; + var title = $('
\ +
\ + \ +
\ +
\ + \ +
\ + \ +
'); + + datepicker.find('input').datepicker({ + dateFormat : "yy/mm/dd" + }); + var html = $('
'); + 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(); + }) + diff --git a/app/views/admin/property_hires/_index.html.erb b/app/views/admin/property_hires/_index.html.erb index 0b43334..6b53e1c 100644 --- a/app/views/admin/property_hires/_index.html.erb +++ b/app/views/admin/property_hires/_index.html.erb @@ -32,7 +32,7 @@ <%= property.get_location_name %> - <% if property.can_be_hired %> + <% if property.can_reserve %> Yes <% else %> No diff --git a/app/views/admin/property_hires/my_bookings.html.erb b/app/views/admin/property_hires/my_bookings.html.erb index f4b3036..3f309d3 100644 --- a/app/views/admin/property_hires/my_bookings.html.erb +++ b/app/views/admin/property_hires/my_bookings.html.erb @@ -33,7 +33,11 @@ <% end %> - View + <% +=begin%> + View +<% +=end%> Delete diff --git a/app/views/property_hires/hire.html.erb b/app/views/property_hires/hire.html.erb index ca9cfa7..29ba2a7 100644 --- a/app/views/property_hires/hire.html.erb +++ b/app/views/property_hires/hire.html.erb @@ -23,6 +23,7 @@ input_col -= 2 end %> + -<% if !property.can_be_hired_frontend %> +<% if !property.can_be_hired %> <% end %>
-<%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal", id: "hire_form" } do |f| %> - <% if property.set_availability %> -
- <%= f.label :date, "*"+t("property_hire.date"), :class => "col-sm-#{label_col} control-label" %> -
- <% 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()" %> +<% if property.can_reserve === true %> + <%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal", id: "hire_form" } do |f| %> + <% if property.set_availability %> +
+ <%= f.label :date, "*"+t("property_hire.date"), :class => "col-sm-#{label_col} control-label" %> +
+ <% 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 %> +
+
+
+ <%= f.label :time, "*"+t("property_hire.time"), :class => "col-sm-#{label_col} control-label" %> +
+ <% 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 %> +
+
<% 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 %> -
-
-
- <%= f.label :time, "*"+t("property_hire.time"), :class => "col-sm-#{label_col} control-label" %> -
- <% 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 %> -
-
- <% else %> -
- <%= f.label :start_time, "*"+t("property_hire.start_time"), :class => "col-sm-#{label_col} control-label" %> - <% if property.calendar_type == 0 %> -
- <%= 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;"} %> - -
- <% end %> -
-
- <%= f.label :end_time, "*"+t("property_hire.end_time"), :class => "col-sm-#{label_col} control-label" %> -
- <%= 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;"} %> - -
-
- <% end %> - -
- <%= f.label :recurring, t("property_hire.recurring"), :class => "col-sm-#{label_col} control-label" %> -
- <%= f.check_box :recurring %> -
-
-
> -
- <%= f.label :recurring_interval, t("property_hire.recurring_interval"), :class => "col-sm-#{label_col} control-label" %> -
- <%= 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.label :recurring_end_date, "*"+t("property_hire.recurring_end_date"), :class => "col-sm-#{label_col} control-label" %> -
- <%= 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 %> - - <% end %> -
-
-
- -
-
- - - -
- <% if property.set_unavailibility %> -
- <%= t("property_hire.Unavailibility_Schedule") %> -
- <%= property.render_unavailable_message%> -
-
- <% end %> -
- - - <% 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") %> -
- <% 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) %> -
- <% @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 %> -
- <%= f.label field_name, (required ? "*" : "") + property.custom_text(field_name,"name"), :class => "col-sm-#{label_col} control-label" %> -
- <% 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 %> -
-
+
+ <%= f.label :start_time, "*"+t("property_hire.start_time"), :class => "col-sm-#{label_col} control-label" %> + <% if property.calendar_type == 0 %> +
+ <%= 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;"} %> + +
<% end %> +
+
+ <%= f.label :end_time, "*"+t("property_hire.end_time"), :class => "col-sm-#{label_col} control-label" %> +
+ <%= 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;"} %> + +
+
+ <% end %> + <% if property.recurring_enable %> + +
+ <%= f.label :recurring, t("property_hire.recurring"), :class => "col-sm-#{label_col} control-label" %> +
+ <%= f.check_box :recurring %> +
+
+
> +
+ <%= f.label :recurring_interval, t("property_hire.recurring_interval"), :class => "col-sm-#{label_col} control-label" %> +
+ <%= 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.label :recurring_end_date, "*"+t("property_hire.recurring_end_date"), :class => "col-sm-#{label_col} control-label" %> +
+ <%= 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 %> + + <% end %> +
+
+
+ <% end %> +
+
+ + + +
+ <% if property.set_unavailibility %> +
+ <%= t("property_hire.Unavailibility_Schedule") %> +
+ <%= property.render_unavailable_message%> +
+
+ <% end %> +
+ + + <% 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") %> +
+ <% 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) %> +
+ <% @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 %> +
+ <%= f.label field_name, (required ? "*" : "") + property.custom_text(field_name,"name"), :class => "col-sm-#{label_col} control-label" %> +
+ <% 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 %> +
+
+ <% end %> + <% end %> <% end %> <% end %> - <% end %> - <% if allow_no_logins_user && current_user.nil? %> - + <% if allow_no_logins_user && current_user.nil? %> + +
+ +
+ <%= gotcha_error %> + <%= gotcha %> +
+
+ <% end %>
- -
- <%= gotcha_error %> - <%= gotcha %> +
+ <% if f.object.id.present? %> + <%= f.hidden_field :id %> + <% end %> +
+ <%= f.submit t("property_hire.save"), :class => "btn btn-primary" %> + <%= f.hidden_field :property_id, :value => property.id %> + +
<% end %> -
-
- <% if f.object.id.present? %> - <%= f.hidden_field :id %> - <% end %> -
- <%= f.submit t("property_hire.save"), :class => "btn btn-primary" %> - <%= f.hidden_field :property_id, :value => property.id %> - - -
-
<% end %>
@@ -627,6 +638,7 @@ if(timezone[0] != "-"){ timezone = "+" + timezone; } + $("#p_hire_date").on("change",function(){ var _this = $(this); var date = new Date(_this.val()); @@ -783,4 +795,18 @@ } }) + <% end %> \ No newline at end of file diff --git a/app/views/property_hires/index.html.erb b/app/views/property_hires/index.html.erb index 648b75c..02de2f7 100644 --- a/app/views/property_hires/index.html.erb +++ b/app/views/property_hires/index.html.erb @@ -1 +1,10 @@ -<%= render_view %> \ No newline at end of file +<% OrbitHelper.render_css_in_head(["property_hire_fullcalendar.css","property_hire_calendar"]) %> + + +<% data = action_data %> +<% if data["manage_booking_btn"] %> + +<% end %> +<%= render_view %> diff --git a/config/locales/en.yml b/config/locales/en.yml index 605e326..f7ea1e7 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -137,6 +137,10 @@ en: set_unavailibility: Set Unavailability limit_start_time: Limit start 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 end_time: End Time weekdays: Unavailable days in a week @@ -174,4 +178,7 @@ en: 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 \ No newline at end of file + contact_person_department: Contact person department + special_unavailable_date: Special Unavailable Date + manage_booking: Manage Bookings + recurring_enable: Enable Recurring \ No newline at end of file diff --git a/config/locales/zh_tw.yml b/config/locales/zh_tw.yml index 467665d..6b81433 100644 --- a/config/locales/zh_tw.yml +++ b/config/locales/zh_tw.yml @@ -164,6 +164,10 @@ zh_tw: weekdays: 每週不開放預約日 start_date: 套用限制開始日期 end_date: 套用限制結束日期 + p_hire_start_time: 上架日期 + p_hire_end_time: 下架日期 + p_open_start_time: 開放日期 + p_open_end_time: 截止日期 description: Unavailability Description unavailibility_note: Unavailability Note property_location: Property Location @@ -196,4 +200,7 @@ zh_tw: tel_of_contact_person: 聯絡人聯絡電話 mobile_phone_of_contact_person: 聯絡人行動電話 contact_person_Email: 聯絡Email - contact_person_department: 聯絡人服務單位 \ No newline at end of file + contact_person_department: 聯絡人服務單位 + special_unavailable_date: 特定不開放預約⽇ + manage_booking: 管理我的預約 + recurring_enable: 啟用週期性預約 \ No newline at end of file