diff --git a/app/controllers/admin/property_hires_controller.rb b/app/controllers/admin/property_hires_controller.rb index 1ee9d24..68f71df 100644 --- a/app/controllers/admin/property_hires_controller.rb +++ b/app/controllers/admin/property_hires_controller.rb @@ -60,6 +60,14 @@ class Admin::PropertyHiresController < OrbitAdminController def edit_hire @phire = PHire.find(params[:id]) end + def add_hire + @property = Property.find(params[:id]) + @phire = @property.p_hires.new + end + def memberdetails + member = MemberProfile.find(params[:userid]) + render :json => {"email" => member.email, "name" => member.name, "phone" => member.mobile_no}.to_json + end def update_hire @phire = PHire.find(params[:id]) @phire.update_attributes(phire_params) diff --git a/app/controllers/property_hires_controller.rb b/app/controllers/property_hires_controller.rb index 757d3f4..8d97a69 100644 --- a/app/controllers/property_hires_controller.rb +++ b/app/controllers/property_hires_controller.rb @@ -33,7 +33,7 @@ class PropertyHiresController < ApplicationController "today" => t("property_hire.today"), "day" => t("property_hire.day"), "week" => t("property_hire.week"), - "month" => t("property_hire.month"), + "month" => t("property_hire._month"), "language" => OrbitHelper.get_site_locale }, "manage_booking_btn" => (OrbitHelper.current_user.nil? ? false : true), diff --git a/app/views/admin/property_hires/_admin_hire.html.erb b/app/views/admin/property_hires/_admin_hire.html.erb new file mode 100644 index 0000000..8671fcc --- /dev/null +++ b/app/views/admin/property_hires/_admin_hire.html.erb @@ -0,0 +1,973 @@ + +<%= content_for :page_specific_css do %> + <% ["basic/bootstrap-datetimepicker.css","property_hire_fullcalendar.css","property_hire_calendar"].each do |css| %> + <%= stylesheet_link_tag css %> + <% end %> +<% end %> + + + + +<% + hire = @phire + property = @phire.property +%> +<% data = {"carousel_display_style"=>"width: #{property.carousel_image_width};"} + recover = true + allow_no_logins_user = false + calendar_type = property.calendar_type.to_i rescue 0 + right_col = 12 + label_col = 2 + input_col = 10 + if calendar_type == 0 + right_col -= 7 + label_col += 2 + input_col -= 2 + end + url = "admin" + all_day_settings = property.all_day_settings +%> + + +<% if !property.can_be_hired_frontend %> + +<% end %> +<% if !allow_no_logins_user && current_user.nil? %> + +<% else %> + +

<%= property.title.html_safe %>

+
+
+<% if property.display_img %> +
+ <%=property.title%> + <%=property.title.html_safe%> +
+<% end %> +

<%= property.property_usage.html_safe %>

+<% property_carousel_images = property.property_carousel_images %> +<% if property_carousel_images.count != 0 %> + +<% end %> +
<%= property.note.html_safe %>
+
+ +<% if session["hire-save-msg"].present? %> + + + <% session.delete("hire-save-msg") %> +<% end %> +
+<% if property.calendar_type == 0 %> +
+
+ +
+
+
+
+ + + +
+ +
+
+ + +
+
+
+

+
+
+
+
+
+ +
+ + <%= fields_for :timepicker do |f|%> + <%= f.time_picker :timepicker, :no_label => true, :new_record => hire.new_record? && !recover,:format=>"HH:mm", :class => "pull-left", :data=>{"picker-type" => "range", "range" => "end", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %> + <% end %> +
+ + +
+
+
+
+
+
+ + +<% 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()" %> + <% 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 %> +
+ +
+ + +
+
+
+ <%= render partial: 'admin/member_selects/email_selection_box', locals: {field: 'userid', email_members: []} %> +
+
+ <% 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=>hire}) %> + <% 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], :data => (required ? {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} : nil)}) %> + <% else %> + <%= f.text_field field_name, :class => "form-control", :placeholder => placeholder, :value => default_values[field_name], :data => (required ? {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} : nil) %> + <% end %> +
+
+ <% end %> + <% end %> + <% end %> + <% end %> + <% if allow_no_logins_user && current_user.nil? %> + +
+ +
+ <%= gotcha_error %> + <%= gotcha %> +
+
+ <% 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 %> +
+
+
+ + +<% end %> \ No newline at end of file diff --git a/app/views/admin/property_hires/add_hire.html.erb b/app/views/admin/property_hires/add_hire.html.erb new file mode 100644 index 0000000..52144e4 --- /dev/null +++ b/app/views/admin/property_hires/add_hire.html.erb @@ -0,0 +1 @@ +<%= render :partial => "admin_hire" %> \ No newline at end of file diff --git a/app/views/admin/property_hires/edit_hire.html.erb b/app/views/admin/property_hires/edit_hire.html.erb index faa1cf5..52144e4 100644 --- a/app/views/admin/property_hires/edit_hire.html.erb +++ b/app/views/admin/property_hires/edit_hire.html.erb @@ -1,940 +1 @@ - -<%= content_for :page_specific_css do %> - <% ["basic/bootstrap-datetimepicker.css","property_hire_fullcalendar.css","property_hire_calendar"].each do |css| %> - <%= stylesheet_link_tag css %> - <% end %> -<% end %> - - - - -<% - hire = @phire - property = @phire.property -%> -<% data = {"carousel_display_style"=>"width: #{property.carousel_image_width};"} - recover = true - allow_no_logins_user = false - calendar_type = property.calendar_type.to_i rescue 0 - right_col = 12 - label_col = 2 - input_col = 10 - if calendar_type == 0 - right_col -= 7 - label_col += 2 - input_col -= 2 - end - url = "admin" - all_day_settings = property.all_day_settings -%> - - -<% if !property.can_be_hired_frontend %> - -<% end %> -<% if !allow_no_logins_user && current_user.nil? %> - -<% else %> - -

<%= property.title.html_safe %>

-
-
-<% if property.display_img %> -
- <%=property.title%> - <%=property.title.html_safe%> -
-<% end %> -

<%= property.property_usage.html_safe %>

-<% property_carousel_images = property.property_carousel_images %> -<% if property_carousel_images.count != 0 %> - -<% end %> -
<%= property.note.html_safe %>
-
- -<% if session["hire-save-msg"].present? %> - - - <% session.delete("hire-save-msg") %> -<% end %> -
-<% if property.calendar_type == 0 %> -
-
- -
-
-
-
- - - -
- -
-
- - -
-
-
-

-
-
-
-
-
- -
- - <%= fields_for :timepicker do |f|%> - <%= f.time_picker :timepicker, :no_label => true, :new_record => hire.new_record? && !recover,:format=>"HH:mm", :class => "pull-left", :data=>{"picker-type" => "range", "range" => "end", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %> - <% end %> -
- - -
-
-
-
-
-
- - -<% 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()" %> - <% 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=>hire}) %> - <% 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], :data => (required ? {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} : nil)}) %> - <% else %> - <%= f.text_field field_name, :class => "form-control", :placeholder => placeholder, :value => default_values[field_name], :data => (required ? {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} : nil) %> - <% end %> -
-
- <% end %> - <% end %> - <% end %> - <% end %> - <% if allow_no_logins_user && current_user.nil? %> - -
- -
- <%= gotcha_error %> - <%= gotcha %> -
-
- <% 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 %> -
-
-
- -<% end %> \ No newline at end of file +<%= render :partial => "admin_hire" %> \ No newline at end of file diff --git a/app/views/admin/property_hires/show.html.erb b/app/views/admin/property_hires/show.html.erb index ae62aa5..aa8a23d 100644 --- a/app/views/admin/property_hires/show.html.erb +++ b/app/views/admin/property_hires/show.html.erb @@ -139,6 +139,7 @@
Back + <%= t("property_hire.admin_reserve") %> <%= content_tag(:div, paginate(@bookings), class: "pagination pagination-centered") %>
<% end %> \ No newline at end of file diff --git a/app/views/property_hires/hire.html.erb b/app/views/property_hires/hire.html.erb index 7599d65..abe253e 100644 --- a/app/views/property_hires/hire.html.erb +++ b/app/views/property_hires/hire.html.erb @@ -283,7 +283,7 @@
- +
- +