update shift close alert
This commit is contained in:
@@ -11,6 +11,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
|
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
@shop = shop_detail
|
@shop = shop_detail
|
||||||
|
@occupied_table = DiningFacility.where("status='occupied'").count;
|
||||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -6,12 +6,17 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@order = Sale.pending_order
|
@order = Sale.pending_order
|
||||||
@completed = Sale.completed_sale("quick_service")
|
@completed = Sale.completed_sale("quick_service")
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
|
@occupied_table = @sale.count.length + @order.count.length
|
||||||
end
|
end
|
||||||
def show
|
def show
|
||||||
@sales = Sale.pending_sale
|
@sales = Sale.pending_sale
|
||||||
@orders = Sale.pending_order
|
@orders = Sale.pending_order
|
||||||
@completed = Sale.completed_sale("quick_service")
|
@completed = Sale.completed_sale("quick_service")
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
|
@occupied_table = @sales.count.length + @orders.count.length
|
||||||
|
|
||||||
@id = params[:sale_id]
|
@id = params[:sale_id]
|
||||||
if(@id[0,3] == "SAL")
|
if(@id[0,3] == "SAL")
|
||||||
@sale = Sale.find(@id)
|
@sale = Sale.find(@id)
|
||||||
@@ -50,6 +55,9 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@orders = Sale.pending_order
|
@orders = Sale.pending_order
|
||||||
@completed = Sale.completed_sale("quick_service")
|
@completed = Sale.completed_sale("quick_service")
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
|
@occupied_table = @sales.count.length + @orders.count.length
|
||||||
|
|
||||||
@id = params[:sale_id]
|
@id = params[:sale_id]
|
||||||
|
|
||||||
@sale = Sale.find(@id)
|
@sale = Sale.find(@id)
|
||||||
@@ -78,6 +86,9 @@ class Origami::PendingOrderController < BaseOrigamiController
|
|||||||
@sales = Sale.pending_sale
|
@sales = Sale.pending_sale
|
||||||
@orders = Sale.pending_order
|
@orders = Sale.pending_order
|
||||||
@completed = Sale.completed_sale("quick_service")
|
@completed = Sale.completed_sale("quick_service")
|
||||||
|
|
||||||
|
@occupied_table = @sales.count.length + @orders.count.length
|
||||||
|
|
||||||
@id = params[:sale_id]
|
@id = params[:sale_id]
|
||||||
@customers = Customer.pluck("customer_id, name")
|
@customers = Customer.pluck("customer_id, name")
|
||||||
|
|
||||||
|
|||||||
@@ -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>
|
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
||||||
<!-- Temporary Disabled -->
|
<!-- 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%>
|
<%end%>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -319,19 +319,26 @@ $('#cash_out').on('click',function(){
|
|||||||
$('#close_cashier').on('click',function(e){
|
$('#close_cashier').on('click',function(e){
|
||||||
e.preventDefault(); // Prevent the href from redirecting directly
|
e.preventDefault(); // Prevent the href from redirecting directly
|
||||||
var linkURL = '/origami/shift/cashier/close';
|
var linkURL = '/origami/shift/cashier/close';
|
||||||
warnBeforeRedirect(linkURL);
|
occupied_count = $(this).data("count");
|
||||||
|
warnBeforeRedirect(linkURL,occupied_count);
|
||||||
})
|
})
|
||||||
|
|
||||||
$('#back').on('click',function(){
|
$('#back').on('click',function(){
|
||||||
window.location.href = '/origami/dashboard';
|
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({
|
swal({
|
||||||
title: "Alert!",
|
title: "Alert!",
|
||||||
text: "Are you sure you want to close cashier?",
|
text: text,
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true
|
showCancelButton: true,
|
||||||
|
html: true
|
||||||
}, function() {
|
}, function() {
|
||||||
// Redirect the user
|
// Redirect the user
|
||||||
window.location.href = linkURL;
|
window.location.href = linkURL;
|
||||||
|
|||||||
@@ -224,7 +224,7 @@
|
|||||||
<button type="button" id="reprint" class="btn bg-blue btn-block">Reprint</button>
|
<button type="button" id="reprint" class="btn bg-blue btn-block">Reprint</button>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<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>
|
||||||
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
||||||
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -337,8 +337,30 @@ $(document).ready(function(){
|
|||||||
$('#close_cashier').on('click',function(e){
|
$('#close_cashier').on('click',function(e){
|
||||||
e.preventDefault(); // Prevent the href from redirecting directly
|
e.preventDefault(); // Prevent the href from redirecting directly
|
||||||
var linkURL = '/origami/shift/quick_service/close';
|
var linkURL = '/origami/shift/quick_service/close';
|
||||||
warnBeforeRedirect(linkURL);
|
occupied_count = $(this).data("count");
|
||||||
|
warnBeforeRedirect(linkURL,occupied_count);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function warnBeforeRedirect(linkURL,occupied_count) {
|
||||||
|
|
||||||
|
if (occupied_count>0) {
|
||||||
|
text = "<h5><span style=\"color: #CC0000\"> We have "+occupied_count+" pending orders and sales</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: text,
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
html: true
|
||||||
|
}, function() {
|
||||||
|
// Redirect the user
|
||||||
|
window.location.href = linkURL;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
$('#cash_in').on('click',function(){
|
$('#cash_in').on('click',function(){
|
||||||
window.location.href = '/origami/quick_service/cash_ins';
|
window.location.href = '/origami/quick_service/cash_ins';
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -215,7 +215,7 @@
|
|||||||
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
|
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
|
||||||
<% if current_user.role != "waiter" %>
|
<% if current_user.role != "waiter" %>
|
||||||
<button type="button" class="btn bg-blue btn-block waves-effect" id='pay'>Pay</button>
|
<button type="button" class="btn bg-blue btn-block waves-effect" id='pay'>Pay</button>
|
||||||
<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>
|
||||||
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
||||||
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -255,7 +255,9 @@ $(document).ready(function(){
|
|||||||
$('#close_cashier').on('click',function(e){
|
$('#close_cashier').on('click',function(e){
|
||||||
e.preventDefault(); // Prevent the href from redirecting directly
|
e.preventDefault(); // Prevent the href from redirecting directly
|
||||||
var linkURL = '/origami/shift/quick_service/close';
|
var linkURL = '/origami/shift/quick_service/close';
|
||||||
warnBeforeRedirect(linkURL);
|
occupied_count = $(this).data("count");
|
||||||
|
|
||||||
|
warnBeforeRedirect(linkURL,occupied_count);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cash_in').on('click',function(){
|
$('#cash_in').on('click',function(){
|
||||||
@@ -270,5 +272,25 @@ $(document).ready(function(){
|
|||||||
var sale_id = '<%= @sale.sale_id %>';
|
var sale_id = '<%= @sale.sale_id %>';
|
||||||
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/credit_payment";
|
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/credit_payment";
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function warnBeforeRedirect(linkURL,occupied_count) {
|
||||||
|
|
||||||
|
if (occupied_count>0) {
|
||||||
|
text = "<h5><span style=\"color: #CC0000\"> We have "+occupied_count+" pending orders and sales</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: text,
|
||||||
|
type: "warning",
|
||||||
|
showCancelButton: true,
|
||||||
|
html: true
|
||||||
|
}, function() {
|
||||||
|
// Redirect the user
|
||||||
|
window.location.href = linkURL;
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -91,7 +91,7 @@
|
|||||||
<%= t("views.btn.back") %>
|
<%= t("views.btn.back") %>
|
||||||
</button>
|
</button>
|
||||||
<% if current_user.role != "waiter" %>
|
<% if current_user.role != "waiter" %>
|
||||||
<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>
|
||||||
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
<button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
||||||
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -135,7 +135,8 @@
|
|||||||
$('#close_cashier').on('click',function(e){
|
$('#close_cashier').on('click',function(e){
|
||||||
e.preventDefault(); // Prevent the href from redirecting directly
|
e.preventDefault(); // Prevent the href from redirecting directly
|
||||||
var linkURL = '/origami/shift/quick_service/close';
|
var linkURL = '/origami/shift/quick_service/close';
|
||||||
warnBeforeRedirect(linkURL);
|
occupied_count = $(this).data("count");
|
||||||
|
warnBeforeRedirect(linkURL,occupied_count);
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#cash_in').on('click',function(){
|
$('#cash_in').on('click',function(){
|
||||||
@@ -147,11 +148,18 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
function warnBeforeRedirect(linkURL) {
|
function warnBeforeRedirect(linkURL,occupied_count) {
|
||||||
|
|
||||||
|
if (occupied_count>0) {
|
||||||
|
text = "<h5><span style=\"color: #CC0000\"> We have "+occupied_count+" pending orders and sales</span> </h5>.<br>Are you sure you want to close cashier? ";
|
||||||
|
}else{
|
||||||
|
text = "Are you sure you want to close cashier?";
|
||||||
|
}
|
||||||
swal({
|
swal({
|
||||||
title: "Alert!",
|
title: "Alert!",
|
||||||
text: "Are you sure you want to close cashier?",
|
text: text,
|
||||||
type: "warning",
|
type: "warning",
|
||||||
|
html: true,
|
||||||
showCancelButton: true
|
showCancelButton: true
|
||||||
}, function() {
|
}, function() {
|
||||||
// Redirect the user
|
// Redirect the user
|
||||||
|
|||||||
@@ -224,7 +224,7 @@
|
|||||||
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
|
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
|
||||||
<%end%>
|
<%end%>
|
||||||
<% if current_user.role != "waiter" %>
|
<% if current_user.role != "waiter" %>
|
||||||
<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>
|
||||||
<!-- <button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
<!-- <button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
||||||
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button> -->
|
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button> -->
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -353,15 +353,23 @@ $(document).ready(function(){
|
|||||||
$('#close_cashier').on('click',function(e){
|
$('#close_cashier').on('click',function(e){
|
||||||
e.preventDefault(); // Prevent the href from redirecting directly
|
e.preventDefault(); // Prevent the href from redirecting directly
|
||||||
var linkURL = '/origami/shift/quick_service/close';
|
var linkURL = '/origami/shift/quick_service/close';
|
||||||
warnBeforeRedirect(linkURL);
|
occupied_count = $(this).data("count");
|
||||||
|
warnBeforeRedirect(linkURL,occupied_count);
|
||||||
});
|
});
|
||||||
|
|
||||||
function warnBeforeRedirect(linkURL) {
|
function warnBeforeRedirect(linkURL,occupied_count) {
|
||||||
|
|
||||||
|
if (occupied_count>0) {
|
||||||
|
text = "<h5><span style=\"color: #CC0000\"> We have "+occupied_count+" pending orders and sales</span> </h5>.<br>Are you sure you want to close cashier? ";
|
||||||
|
}else{
|
||||||
|
text = "Are you sure you want to close cashier?";
|
||||||
|
}
|
||||||
swal({
|
swal({
|
||||||
title: "Alert!",
|
title: "Alert!",
|
||||||
text: "Are you sure you want to close cashier?",
|
text: text,
|
||||||
type: "warning",
|
type: "warning",
|
||||||
showCancelButton: true
|
showCancelButton: true,
|
||||||
|
html: true
|
||||||
}, function() {
|
}, function() {
|
||||||
// Redirect the user
|
// Redirect the user
|
||||||
window.location.href = linkURL;
|
window.location.href = linkURL;
|
||||||
|
|||||||
Reference in New Issue
Block a user