From 11b8466e104780466ab65175e32c5f57d0a3d7b1 Mon Sep 17 00:00:00 2001 From: phyusin Date: Thu, 21 Dec 2017 15:11:11 +0630 Subject: [PATCH] check first bill or not --- app/assets/javascripts/origami.js | 41 ++++++++++++++++++++++-- app/views/origami/home/show.html.erb | 41 +++++++++++++++++------- app/views/origami/payments/show.html.erb | 6 ++++ app/views/origami/rooms/show.html.erb | 17 ++++++++++ 4 files changed, 91 insertions(+), 14 deletions(-) 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 @@
  Receipt No: <% if @status_sale == 'sale' %> - <%= @sale_array[0].receipt_no rescue '' %> - + <%= @sale_array[0].receipt_no rescue '' %> <% end %>
@@ -439,6 +438,18 @@