From 625ee9bd34e807fdcdaa0447fe9918750e0a96c8 Mon Sep 17 00:00:00 2001 From: San Wai Lwin Date: Wed, 7 Feb 2018 13:23:01 +0630 Subject: [PATCH] For add alert box for Close Cashier --- app/views/origami/home/index.html.erb | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/app/views/origami/home/index.html.erb b/app/views/origami/home/index.html.erb index a81c5bf9..f40cb3b3 100755 --- a/app/views/origami/home/index.html.erb +++ b/app/views/origami/home/index.html.erb @@ -235,10 +235,25 @@ $('#cash_out').on('click',function(){ window.location.href = '/origami/cash_outs/new'; }) -$('#close_cashier').on('click',function(){ - window.location.href = '/origami/shift/close'; +$('#close_cashier').on('click',function(e){ + e.preventDefault(); // Prevent the href from redirecting directly + var linkURL = '/origami/shift/close'; + warnBeforeRedirect(linkURL); }) + $('#back').on('click',function(){ window.location.href = '/dashboard'; }) + +function warnBeforeRedirect(linkURL) { + swal({ + title: "Oops", + text: "Are you sure you want to Logout ?", + type: "warning", + showCancelButton: true + }, function() { + // Redirect the user + window.location.href = linkURL; + }); + }