157 lines
6.7 KiB
Plaintext
157 lines
6.7 KiB
Plaintext
<% OrbitHelper.render_css_in_head(["basic/bootstrap-datetimepicker.css"]) %>
|
|
<%= javascript_include_tag "lib/bootstrap-datetimepicker" %>
|
|
<%= javascript_include_tag "lib/datetimepicker/datetimepicker.js" %>
|
|
<%= javascript_include_tag "validator.js" %>
|
|
<%
|
|
data = action_data
|
|
hire = data["hire"]
|
|
property = data["property"]
|
|
url = data["page"]
|
|
current_user = data["current_user"]
|
|
%>
|
|
<% if !property.can_be_hired %>
|
|
<script type="text/javascript">
|
|
alert("This property is unavailable for hire.");
|
|
window.location.href = "<%= "/" + I18n.locale.to_s + url %>";
|
|
</script>
|
|
<% end %>
|
|
<% if current_user.nil? %>
|
|
<script type="text/javascript">
|
|
alert("Please login before you hire.");
|
|
window.location.href = "<%= "/" + I18n.locale.to_s + url %>";
|
|
</script>
|
|
<% else %>
|
|
<h3><%= property.title %></h3>
|
|
<% if session["hire-save-msg"].present? %>
|
|
<div id="property-unavaialable-alert" class="alert alert-danger" role="alert"><b>Sorry! </b><span> <%= session["hire-save-msg"] %></span></div>
|
|
<% session.delete("hire-save-msg") %>
|
|
<% end %>
|
|
<%= form_for hire, :url => "/xhr/property_hires/make_booking", html: { class: "form-horizontal" } do |f| %>
|
|
<div class="form-group">
|
|
<%= f.label :start_time, t("property_hires.start_time"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-10">
|
|
<%= f.datetime_picker :start_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "start", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<%= f.label :end_time, t("property_hires.end_time"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-10">
|
|
<%= f.datetime_picker :end_time, :no_label => true, :new_record => hire.new_record?, :data=>{"picker-type" => "range", "range" => "end", "fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-sm-offset-2 col-sm-5">
|
|
<div id="property-avaialable-alert" style="margin-bottom: 5px; padding: 10px; display: none;" class="alert alert-success" role="alert"><b>Hooray! </b>This property is available.</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>
|
|
<% if property.set_unavailibility %>
|
|
<div class="col-sm-offset-2 col-sm-5">
|
|
<b>Unavailibility Schedule</b>
|
|
<div>
|
|
This property is unavaliable <%= !property.start_date.nil? ? " from " + property.start_date.strftime("%Y-%m-%d") : "" %> <%= !property.end_date.nil? ? " to " + property.end_date.strftime("%Y-%m-%d") : "" %> every
|
|
<% property.weekdays.each_with_index do |d,i| %>
|
|
<% if i < (property.weekdays.count - 1) %>
|
|
<%= Property::WEEKDAYS[d.to_i] + ", " %>
|
|
<% else %>
|
|
<%= Property::WEEKDAYS[d.to_i] %>
|
|
<% end %>
|
|
<% end %>
|
|
between <%= property.start_time %> & <%= property.end_time %>.
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
</div>
|
|
|
|
<div class="form-group">
|
|
<label for="" class="col-sm-2 control-label"></label>
|
|
<div class="col-sm-10">
|
|
<a href="/xhr/property_hires/check_availability" id="check-avail-btn" class="btn btn-primary">Check Availibility</a>
|
|
<img style="display: none;" width="40" src="/assets/spin.gif" id="spinner" />
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<%= f.label :hiring_person_email, t("property_hires.hiring_person_email"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-5">
|
|
<%= f.text_field :hiring_person_email, :class => "form-control", :value => current_user.member_profile.email, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<%= f.label :hiring_person_number, t("property_hires.hiring_person_number"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-5">
|
|
<%= f.text_field :hiring_person_number, :class => "form-control", :value => current_user.member_profile.mobile_no, :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<%= f.label :hiring_person_name, t("property_hires.hiring_person_name"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-5">
|
|
<%= f.text_field :hiring_person_name, :class => "form-control", :value => (current_user.name rescue ""), :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
<%= f.hidden_field :hiring_person_id, :value => (current_user.member_profile.id.to_s rescue "") %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<%= f.label :reason_for_hire, t("property_hires.reason_for_hire"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-5">
|
|
<%= f.text_field :reason_for_hire, :class => "form-control", :data => {"fv-validation" => "required;", "fv-messages" => "Cannot be empty;"} %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<%= f.label :note_for_hire, t("property_hires.note_for_hire"), :class => "col-sm-2 control-label" %>
|
|
<div class="col-sm-5">
|
|
<%= f.text_area :note_for_hire, :class => "form-control" %>
|
|
</div>
|
|
</div>
|
|
<div class="form-group">
|
|
<div class="col-sm-offset-2 col-sm-10">
|
|
<%= 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="0" data-fv-validation="checkForDates;" data-fv-messages="Please make sure first if dates are available.;">
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<div style="height: 50px;"></div>
|
|
<script type="text/javascript">
|
|
var property_id = "<%= property.id.to_s %>";
|
|
$("#check-avail-btn").on("click",function(){
|
|
var el = $(this),
|
|
url = $(this).attr("href"),
|
|
spinner = $("#spinner");
|
|
el.hide();
|
|
spinner.show();
|
|
$(".alert").hide();
|
|
$.ajax({
|
|
"url" : url,
|
|
"type" : "post",
|
|
"data" : {"stime" : $("#p_hire_start_time").val(), "etime" : $("#p_hire_end_time").val(), "property_id" : property_id},
|
|
"dataType" : "json"
|
|
}).done(function(data){
|
|
if(data.success){
|
|
$("#property-avaialable-alert").show();
|
|
$("#dates_validated").val("1");
|
|
}else{
|
|
$("#property-unavaialable-alert").find("span").text(data.msg);
|
|
$("#property-unavaialable-alert").show();
|
|
}
|
|
spinner.hide();
|
|
el.show();
|
|
})
|
|
return false;
|
|
})
|
|
|
|
$("#unavailable-schedule").on("click",function(){
|
|
|
|
})
|
|
|
|
var hireForm = new FormValidator($("#new_p_hire"));
|
|
hireForm.validate_functions.checkForDates = function(value,element){
|
|
return value == "1";
|
|
}
|
|
</script>
|
|
<% end %>
|
|
|
|
|
|
|
|
|
|
|
|
|