diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index a8174bbd..1ed96cea 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -72,34 +72,7 @@ function showConfirmMessage() { }); } - - - $(function(){ - $('.delete').click(function(){ - var currentForm = $(this).closest("form"); - console.log(currentForm); - swal({ - title: "Are you sure?", - text: "You will not be able to recover this imaginary file!", - type: "warning", - showCancelButton: true, - confirmButtonColor: "#DD6B55", - confirmButtonText: "Yes, delete it!", - cancelButtonText: "No, cancel plx!", - closeOnConfirm: false, - closeOnCancel: false - }, function (isConfirm) { - console.log(isConfirm); - if (isConfirm) { - console.log("hi") - currentForm.submit(); - } else { - swal("Cancelled", "Your imaginary file is safe :)", "error"); - } - }); - }); - $('body').bootstrapMaterialDesign(); var height = ($(window).height() - ($('.legal').outerHeight() + $('.user-info').outerHeight() + $('.navbar').innerHeight())); @@ -162,10 +135,60 @@ $(function(){ '\n', } }); + + $('.delete').click(function(){ + var method = $(this).attr('data-method'); + var url = $(this).attr('data-ref'); + var html = $(this).siblings.html(); + console.log(html); + swal({ + title: "Confirmation", + text: $(this).children().children('#delete_text').html(), + type: "warning", + showCancelButton: true, + confirmButtonColor: "#DD6B55", + html: true + }, function (isConfirm) { + if (isConfirm) { + $.ajax({ + type: method, + url: url , + success: function(data) { + } + }); + } else { + swal("Cancelled", "Your imaginary file is safe :)", "error"); + } + }); + }); + + $('.dddddddd').click(function(){ + var currentForm = $(this).closest("form"); + bootbox.confirm({ + title: 'Confirmation', + message: $('#delete_text').html(), + buttons: { + 'cancel': { + label: 'No', + className: 'btn green col-md-4 pull-left' + }, + 'confirm': { + label: 'Yes', + className: 'btn red col-md-4 pull-right' + } + }, + callback: function(result) { + if (result) { + currentForm.submit(); + } + } + }); + }); + }); - $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ - $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); +$(document).on("focus", "[data-behaviour~='datepicker']", function(e){ + $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); $('.dropdown-toggle').dropdown(); }); diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 8473ecf6..c9479d2d 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -131,7 +131,6 @@ $(function() { var code = ""; setTimeout(function(){ var hi=getQRCode(); - alert(hi); },100); }); @@ -231,39 +230,31 @@ $(document).on('click',".customer_tr",function(){ }) function update_sale(customer_id,sale_id) { - $.confirm({ - title: 'Confirm!', - content: 'Are You Sure to assign this customer!', - buttons: { + swal({ + title: "Confirmation", + text: "Are You Sure to assign this customer!", + type: "success", + showCancelButton: true, + confirmButtonColor: "green", + confirmButtonText: "Yes, delete it!", + closeOnConfirm: false + }, function () { + $.ajax({ + type: "POST", + url: "update_sale/" , + data: {customer_id:customer_id,sale_id:sale_id}, + dataType: "json", + success: function(data) { + if(data.status == true) + { + window.location.href = '/origami' + }else{ + swal("Alert!", "Record not found!", "error"); + location.reload(); + } - cancel: function () { - - }, - confirm: { - text: 'Confirm', - btnClass: 'btn-green', - keys: ['enter', 'shift'], - action: function(){ - $.ajax({ - type: "POST", - url: "update_sale/" , - data: {customer_id:customer_id,sale_id:sale_id}, - dataType: "json", - success: function(data) { - if(data.status == true) - { - window.location.href = '/origami' - }else{ - alert('Record not found!'); - location.reload(); - } - - } - }); - } - } - - } + } + }); }); } diff --git a/app/views/crm/dining_queues/assign.html.erb b/app/views/crm/dining_queues/assign.html.erb index cc36e1a9..9b2ca4a8 100644 --- a/app/views/crm/dining_queues/assign.html.erb +++ b/app/views/crm/dining_queues/assign.html.erb @@ -57,56 +57,32 @@ $(document).on('click',".assign_table",function(){ if (status == "available") { assign_table(queue_id,table_id,url); } else { - $.confirm({ - title: 'Alert!', - content: 'You cannot assign this table', - buttons: { - - confirm: { - text: 'Ok', - btnClass: 'btn-green', - - } - } - }); + swal ( "Alert!" , "You cannot assign this table!" , "warning" ); } }) function assign_table(id,table_id,url) { - $.confirm({ - title: 'Confirm!', - content: 'Are You Sure to assign this customer!', - buttons: { - - cancel: function () { - - }, - confirm: { - text: 'Confirm', - btnClass: 'btn-green', - keys: ['enter', 'shift'], - action: function(){ - $.ajax({ - type: "POST", - url: url , - data: {id:id,table_id:table_id}, - dataType: "json", - success: function(data) { - if(data.status == true) - { - window.location.href = '<%=crm_dining_queues_path%>' - }else{ - alert('Record not found!'); - location.reload(); - } - - } - }); - } - } - + swal({ + title: "Confirm!", + text: "Are You Sure to assign this customer!", + }, function () { + $.ajax({ + type: "POST", + url: url , + data: {id:id,table_id:table_id}, + dataType: "json", + success: function(data) { + if(data.status == true) + { + window.location.href = '<%=crm_dining_queues_path%>' + }else{ + swal ( "Alert!" , "Record not found!" , "warning" ); + location.reload(); } + + } }); + }); } diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb index 12714fc0..da7dac6b 100644 --- a/app/views/crm/dining_queues/index.html.erb +++ b/app/views/crm/dining_queues/index.html.erb @@ -91,35 +91,24 @@ $('#cancel').click(function() { function cancel_queue(id,url) { - $.confirm({ - title: 'Confirm!', - content: 'Are You Sure to cancel this Queue!', - buttons: { - cancel: function () { - }, - confirm: { - text: 'Confirm', - btnClass: 'btn-green', - keys: ['enter', 'shift'], - action: function(){ - $.ajax({ - type: "POST", - url: url , - data: {id:id}, - dataType: "json", - success: function(data) { - if(data.status == true) - { - location.reload(); - } + swal({ + title: "Confirm!", + text: "Are You Sure to cancel this Queue!", + }, function () { + $.ajax({ + type: "POST", + url: url , + data: {id:id}, + dataType: "json", + success: function(data) { + if(data.status == true) + { + location.reload(); + } - } - }); - } - } - - } - }); + } + }); + }); } diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 80c2f065..d60e6892 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -1,4 +1,4 @@ - +Search Bar --> + + + +