diff --git a/app/assets/javascripts/origami.js b/app/assets/javascripts/origami.js index 802d676e..c11df647 100755 --- a/app/assets/javascripts/origami.js +++ b/app/assets/javascripts/origami.js @@ -15,8 +15,6 @@ //= require BSBMaterial/demo.js //= require custom.js -var _FIRST_BILL_ = ""; - $(document).on('turbolinks:load', function() { $('.datetimepicker').bootstrapMaterialDatePicker({ format: 'DD-MM-YYYY - HH:mm', @@ -145,3 +143,42 @@ $(document).on('turbolinks:load', function() { return false; }); }); + +/* start check first bill or not funs: */ +function checkReceiptNoInFirstBillData(receipt_no) { + var status = false; + if((receipt_no!=undefined) && (receipt_no!="")){ + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + if((arr_data!=undefined) && (arr_data!=null)){ + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + if((arr_data.length) > (json_data.length)){ + status = true; + } + } + } + + return status; +} + +function createReceiptNoInFirstBillData(receipt_no) { + var arr_data = []; + var json_data = []; + var receipt_lists = localStorage.getItem("receipt_lists"); + if((receipt_lists!=undefined) && (receipt_lists!=null) && (receipt_lists!="")){ + arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no }); + } + if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){ + arr_data.push({receipt_no}); + localStorage.setItem("receipt_lists",JSON.stringify(arr_data)); + } +} + +function deleteReceiptNoInFirstBillData(receipt_no) { + var arr_data = JSON.parse(localStorage.getItem("receipt_lists")); + if((arr_data!=undefined) && (arr_data!=null)){ + var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no }); + localStorage.setItem("receipt_lists",JSON.stringify(json_data)); + } +} +/* end check first bill or not funs: */ \ No newline at end of file diff --git a/app/views/origami/home/show.html.erb b/app/views/origami/home/show.html.erb index b65deb7d..68c43ad8 100755 --- a/app/views/origami/home/show.html.erb +++ b/app/views/origami/home/show.html.erb @@ -156,8 +156,7 @@