change js format for localStorage
This commit is contained in:
@@ -145,7 +145,7 @@ $(document).on('turbolinks:load', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* start check first bill or not funs: */
|
/* start check first bill or not funs: */
|
||||||
function checkReceiptNoInFirstBillData(receipt_no,payment=null) {
|
function checkReceiptNoInFirstBillData(receipt_no,payment) {
|
||||||
// localStorage.removeItem('receipt_lists');
|
// localStorage.removeItem('receipt_lists');
|
||||||
var status = false;
|
var status = false;
|
||||||
if((receipt_no!=undefined) && (receipt_no!="")){
|
if((receipt_no!=undefined) && (receipt_no!="")){
|
||||||
@@ -169,26 +169,26 @@ function checkReceiptNoInFirstBillData(receipt_no,payment=null) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createReceiptNoInFirstBillData(receipt_no,payment=null) {
|
function createReceiptNoInFirstBillData(receipt_no,payment) {
|
||||||
var arr_data = [];
|
var arr_data = [];
|
||||||
var json_data = [];
|
var json_data = [];
|
||||||
if(localStorage.hasOwnProperty("receipt_lists")===true){
|
if(localStorage.hasOwnProperty("receipt_lists") === true){
|
||||||
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||||
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||||
if (payment) {
|
if (payment) {
|
||||||
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||||
jdata.push({receipt_no:receipt_no, payment:payment});
|
jdata.push({'receipt_no':receipt_no,'payment':payment});
|
||||||
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
|
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
|
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
|
||||||
arr_data.push({receipt_no:receipt_no, payment:payment});
|
arr_data.push({'receipt_no':receipt_no,'payment':payment});
|
||||||
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
|
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function deleteReceiptNoInFirstBillData(receipt_no) {
|
function deleteReceiptNoInFirstBillData(receipt_no) {
|
||||||
if(localStorage.hasOwnProperty("receipt_lists")===true){
|
if(localStorage.hasOwnProperty("receipt_lists") ===true ){
|
||||||
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
var arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||||
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||||
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
|
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
|
||||||
|
|||||||
@@ -444,7 +444,7 @@
|
|||||||
receipt_no = ($("#receipt_no").html()).trim();
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
}
|
}
|
||||||
// console.log(checkReceiptNoInFirstBillData(receipt_no));
|
// console.log(checkReceiptNoInFirstBillData(receipt_no));
|
||||||
if(checkReceiptNoInFirstBillData(receipt_no)){
|
if(checkReceiptNoInFirstBillData(receipt_no,"")){
|
||||||
$("#pay").show();
|
$("#pay").show();
|
||||||
}else{
|
}else{
|
||||||
$("#pay").hide();
|
$("#pay").hide();
|
||||||
@@ -574,7 +574,7 @@
|
|||||||
success: function (result) {
|
success: function (result) {
|
||||||
receipt_no = ($("#receipt_no").html()).trim();
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
if((receipt_no!=undefined) && (receipt_no!=""))
|
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||||
createReceiptNoInFirstBillData(receipt_no);
|
createReceiptNoInFirstBillData(receipt_no,"");
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
@@ -657,7 +657,7 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#move').on('click', function () {
|
$('#move').on('click', function () {
|
||||||
var dining_id = "<%= @dining.id %>"
|
var dining_id = "<%= @dining.id %>";
|
||||||
window.location.href = '/origami/table/' + dining_id + "/movetable";
|
window.location.href = '/origami/table/' + dining_id + "/movetable";
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -783,7 +783,7 @@
|
|||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'POST',
|
type: 'POST',
|
||||||
data: {dining_id : dining_id},
|
data: {'dining_id' : dining_id},
|
||||||
datatype: 'JSON',
|
datatype: 'JSON',
|
||||||
url: '/origami/check_in',
|
url: '/origami/check_in',
|
||||||
success: function(data) {
|
success: function(data) {
|
||||||
|
|||||||
@@ -397,23 +397,23 @@
|
|||||||
$('#pay').click(function() {
|
$('#pay').click(function() {
|
||||||
sub_total = $('#sub-total').text();
|
sub_total = $('#sub-total').text();
|
||||||
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
|
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
|
||||||
swal("Opps","Please Pay with MPU Payment","warning")
|
swal("Opps","Please Pay with MPU Payment","warning");
|
||||||
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
|
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
|
||||||
swal("Opps","Please Pay with Redeem Payment","warning")
|
swal("Opps","Please Pay with Redeem Payment","warning");
|
||||||
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
|
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
|
||||||
swal("Opps","Please Pay with Visa Payment","warning")
|
swal("Opps","Please Pay with Visa Payment","warning");
|
||||||
|
|
||||||
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
|
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
|
||||||
swal("Opps","Please Pay with jcb Payment","warning")
|
swal("Opps","Please Pay with jcb Payment","warning");
|
||||||
}
|
}
|
||||||
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
|
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
|
||||||
swal("Opps","Please Pay with Master Payment","warning")
|
swal("Opps","Please Pay with Master Payment","warning");
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
$( "#loading_wrapper").show();
|
$( "#loading_wrapper").show();
|
||||||
if($('#balance').text() > 0){
|
if($('#balance').text() > 0){
|
||||||
swal ( "Oops" , "Insufficient Amount!" , "error" );
|
swal ( "Oops", "Insufficient Amount!" , "error" );
|
||||||
$( "#loading_wrapper").hide();
|
$("#loading_wrapper").hide();
|
||||||
}else{
|
}else{
|
||||||
$(this).off("click");
|
$(this).off("click");
|
||||||
var sale_id = $('#sale_id').text();
|
var sale_id = $('#sale_id').text();
|
||||||
|
|||||||
@@ -455,7 +455,7 @@ $(document).ready(function(){
|
|||||||
receipt_no = ($("#receipt_no").html()).trim();
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
}
|
}
|
||||||
// console.log(checkReceiptNoInFirstBillData(receipt_no));
|
// console.log(checkReceiptNoInFirstBillData(receipt_no));
|
||||||
if(checkReceiptNoInFirstBillData(receipt_no)){
|
if(checkReceiptNoInFirstBillData(receipt_no,"")){
|
||||||
$("#pay").show();
|
$("#pay").show();
|
||||||
}else{
|
}else{
|
||||||
$("#pay").hide();
|
$("#pay").hide();
|
||||||
@@ -586,7 +586,7 @@ $("#first_bill").on('click', function(){
|
|||||||
success:function(result){
|
success:function(result){
|
||||||
receipt_no = ($("#receipt_no").html()).trim();
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
if((receipt_no!=undefined) && (receipt_no!=""))
|
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||||
createReceiptNoInFirstBillData(receipt_no);
|
createReceiptNoInFirstBillData(receipt_no,"");
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user