update shift close alert

This commit is contained in:
Aung Myo
2018-07-24 17:48:26 +06:30
parent 01c0f96e87
commit 500384416f
7 changed files with 97 additions and 18 deletions

View File

@@ -184,7 +184,7 @@
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
<!-- Temporary Disabled -->
<button id="close_cashier" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<button id="close_cashier" type="button" data-count="<%= @occupied_table %>" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
<%end%>
</div>
</div>
@@ -319,19 +319,26 @@ $('#cash_out').on('click',function(){
$('#close_cashier').on('click',function(e){
e.preventDefault(); // Prevent the href from redirecting directly
var linkURL = '/origami/shift/cashier/close';
warnBeforeRedirect(linkURL);
occupied_count = $(this).data("count");
warnBeforeRedirect(linkURL,occupied_count);
})
$('#back').on('click',function(){
window.location.href = '/origami/dashboard';
})
function warnBeforeRedirect(linkURL) {
function warnBeforeRedirect(linkURL,occupied_count) {
if (occupied_count>0) {
text = "<h5><span style=\"color: #CC0000\"> We have "+occupied_count+" occupied table </span> </h5>.<br>Are you sure you want to close cashier? ";
}else{
text = "Are you sure you want to close cashier?";
}
swal({
title: "Alert!",
text: "Are you sure you want to close cashier?",
text: text,
type: "warning",
showCancelButton: true
showCancelButton: true,
html: true
}, function() {
// Redirect the user
window.location.href = linkURL;