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: */
|
||||
function checkReceiptNoInFirstBillData(receipt_no,payment=null) {
|
||||
function checkReceiptNoInFirstBillData(receipt_no,payment) {
|
||||
// localStorage.removeItem('receipt_lists');
|
||||
var status = false;
|
||||
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 json_data = [];
|
||||
if(localStorage.hasOwnProperty("receipt_lists")===true){
|
||||
if(localStorage.hasOwnProperty("receipt_lists") === true){
|
||||
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||
if (payment) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
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 json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(json_data));
|
||||
|
||||
Reference in New Issue
Block a user