check first bill or not
This commit is contained in:
@@ -15,8 +15,6 @@
|
|||||||
//= require BSBMaterial/demo.js
|
//= require BSBMaterial/demo.js
|
||||||
//= require custom.js
|
//= require custom.js
|
||||||
|
|
||||||
var _FIRST_BILL_ = "";
|
|
||||||
|
|
||||||
$(document).on('turbolinks:load', function() {
|
$(document).on('turbolinks:load', function() {
|
||||||
$('.datetimepicker').bootstrapMaterialDatePicker({
|
$('.datetimepicker').bootstrapMaterialDatePicker({
|
||||||
format: 'DD-MM-YYYY - HH:mm',
|
format: 'DD-MM-YYYY - HH:mm',
|
||||||
@@ -145,3 +143,42 @@ $(document).on('turbolinks:load', function() {
|
|||||||
return false;
|
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: */
|
||||||
@@ -157,7 +157,6 @@
|
|||||||
Receipt No: <span id="receipt_no">
|
Receipt No: <span id="receipt_no">
|
||||||
<% if @status_sale == 'sale' %>
|
<% if @status_sale == 'sale' %>
|
||||||
<%= @sale_array[0].receipt_no rescue '' %>
|
<%= @sale_array[0].receipt_no rescue '' %>
|
||||||
|
|
||||||
<% end %>
|
<% end %>
|
||||||
</span>
|
</span>
|
||||||
<br>
|
<br>
|
||||||
@@ -439,6 +438,18 @@
|
|||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
|
/* start check first bill or not*/
|
||||||
|
var receipt_no = "";
|
||||||
|
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||||
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
}
|
||||||
|
// console.log(checkReceiptNoInFirstBillData(receipt_no));
|
||||||
|
if(checkReceiptNoInFirstBillData(receipt_no)){
|
||||||
|
$("#pay").show();
|
||||||
|
}else{
|
||||||
|
$("#pay").hide();
|
||||||
|
}
|
||||||
|
/* end check first bill or not*/
|
||||||
|
|
||||||
$('.invoicedetails').on('click', function () {
|
$('.invoicedetails').on('click', function () {
|
||||||
var dining_id = "<%= @dining.id %>";
|
var dining_id = "<%= @dining.id %>";
|
||||||
@@ -556,10 +567,15 @@
|
|||||||
$("#first_bill").on('click', function () {
|
$("#first_bill").on('click', function () {
|
||||||
var sale_id = $('#sale_id').val();
|
var sale_id = $('#sale_id').val();
|
||||||
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
|
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
|
||||||
|
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "GET",
|
type: "GET",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||||
|
createReceiptNoInFirstBillData(receipt_no);
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -625,6 +641,7 @@
|
|||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
// data: 'order_id='+ order_id,
|
// data: 'order_id='+ order_id,
|
||||||
success: function (result) {
|
success: function (result) {
|
||||||
|
|
||||||
if (!result.status) {
|
if (!result.status) {
|
||||||
swal("Information!", result.error_message);
|
swal("Information!", result.error_message);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,6 +405,12 @@
|
|||||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||||
async: false,
|
async: false,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
/* start delete receipt no in first bill*/
|
||||||
|
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||||
|
var receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
deleteReceiptNoInFirstBillData(receipt_no);
|
||||||
|
}
|
||||||
|
/* end delete receipt no in first bill*/
|
||||||
|
|
||||||
localStorage.removeItem("cash");
|
localStorage.removeItem("cash");
|
||||||
if (result.status) {
|
if (result.status) {
|
||||||
|
|||||||
@@ -447,6 +447,19 @@ $(document).ready(function(){
|
|||||||
// window.location.href = '/origami/order/' + order_id;
|
// window.location.href = '/origami/order/' + order_id;
|
||||||
// })
|
// })
|
||||||
|
|
||||||
|
/* start check first bill or not*/
|
||||||
|
var receipt_no = "";
|
||||||
|
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||||
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
}
|
||||||
|
// console.log(checkReceiptNoInFirstBillData(receipt_no));
|
||||||
|
if(checkReceiptNoInFirstBillData(receipt_no)){
|
||||||
|
$("#pay").show();
|
||||||
|
}else{
|
||||||
|
$("#pay").hide();
|
||||||
|
}
|
||||||
|
/* end check first bill or not*/
|
||||||
|
|
||||||
$('.invoicedetails').on('click',function(){
|
$('.invoicedetails').on('click',function(){
|
||||||
var dining_id = "<%= @room.id %>";
|
var dining_id = "<%= @room.id %>";
|
||||||
var sale_id = this.id;
|
var sale_id = this.id;
|
||||||
@@ -569,6 +582,10 @@ $("#first_bill").on('click', function(){
|
|||||||
type: "GET",
|
type: "GET",
|
||||||
url: ajax_url,
|
url: ajax_url,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||||
|
createReceiptNoInFirstBillData(receipt_no);
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user