property_hire/app/views/admin/property_hires/index.html.erb

74 lines
2.4 KiB
Plaintext
Raw Permalink Normal View History

2022-11-24 09:31:30 +00:00
<%= render_filter @filter_fields, "index_table" %>
<span id="index_table">
<%= render 'index'%>
2024-10-23 07:33:50 +00:00
</span>
<div id="downloadModal" data-backdrop="static" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="downloadModalLabel" aria-hidden="true">
<div class="modal-header">
<h3 id="downloadModalLabel">Download</h3>
</div>
<div class="modal-body">
<p id="wait-zone" style="text-align: center;">
Please wait while we prepare your download. This may take a while.
<br />
<img src="/assets/spin.gif" />
</p>
<p id="link-zone" style="display: none; text-align: center;">
Please click the link below to download.
<br />
<a href="" id="download-link" target="_blank">Download</a>
</p>
</div>
<div class="modal-footer">
<button class="btn" id="modal-close-btn" style="display:none;" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
<script type="text/javascript" src="/assets/lib/process.manager.js"></script>
<script type="text/javascript">
var downloadModal = $("#downloadModal"),
checkForThread = null,
waitZone = $("#wait-zone"),
linkZone = $("#link-zone"),
downloadLink = $("a#download-link"),
modalBtn = $("#modal-close-btn"),
processManager = new ProcessManager();
$(document).on("click", ".export-xls", function(){
var link = $(this).attr("href"),
title = null,
id = $(this).data("property-id");
linkZone.hide();
waitZone.show();
modalBtn.hide();
$.ajax({
url : link,
type : "get",
dataType : "json"
}).done(function(data){
title = data.title;
checkForThread = new Process(function(){
$.ajax({
url : "/admin/property_hires/checkforthread",
type : "get",
data : {"property_id" : id, "property_title" : title},
dataType : "json"
}).done(function(data){
if(!data.status){
downloadLink.attr("href", "/uploads/reservation_export/" + id + "/" + title + ".xlsx");
waitZone.hide();
linkZone.show();
modalBtn.show();
checkForThread.kill();
}
})
})
checkForThread.setTimeInterval(1000);
checkForThread.setRepeat(Process.CONSTANTS.REPEAT_INFINITE);
processManager.queue(checkForThread);
})
downloadModal.modal("show");
return false;
})
</script>