update payment and memberdiscoun
This commit is contained in:
@@ -145,30 +145,45 @@ $(document).on('turbolinks:load', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
/* start check first bill or not funs: */
|
/* start check first bill or not funs: */
|
||||||
function checkReceiptNoInFirstBillData(receipt_no) {
|
function checkReceiptNoInFirstBillData(receipt_no,payment=null) {
|
||||||
|
// localStorage.removeItem('receipt_lists');
|
||||||
var status = false;
|
var status = false;
|
||||||
if((receipt_no!=undefined) && (receipt_no!="")){
|
if((receipt_no!=undefined) && (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"));
|
||||||
|
console.log(arr_data)
|
||||||
|
if (payment) {
|
||||||
|
var json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||||
|
}else{
|
||||||
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 });
|
||||||
|
}
|
||||||
|
|
||||||
if((arr_data.length) > (json_data.length)){
|
if((arr_data.length) > (json_data.length)){
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (payment) {
|
||||||
|
return json_data[0]["payment"];
|
||||||
|
}else{
|
||||||
return status;
|
return status;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function createReceiptNoInFirstBillData(receipt_no) {
|
function createReceiptNoInFirstBillData(receipt_no,payment=null) {
|
||||||
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) {
|
||||||
|
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||||
|
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))){
|
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
|
||||||
arr_data.push({'receipt_no':receipt_no});
|
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));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -596,7 +596,7 @@
|
|||||||
$( "#loading_wrapper" ).hide();
|
$( "#loading_wrapper" ).hide();
|
||||||
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,type);
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -290,6 +290,21 @@
|
|||||||
|
|
||||||
<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();
|
||||||
|
}
|
||||||
|
|
||||||
|
payment_type = checkReceiptNoInFirstBillData(receipt_no,"payment")
|
||||||
|
if(payment_type=="Cash"){
|
||||||
|
$("#card_payment").hide();
|
||||||
|
$("#credit_payment").hide();
|
||||||
|
}else if(payment_type=="Credit"){
|
||||||
|
$("#card_payment").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
/* end check first bill or not*/
|
||||||
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
|
var dining_id = "<%= @sale_data.bookings[0].dining_facility_id %>";
|
||||||
|
|
||||||
$("#back").on('click', function() {
|
$("#back").on('click', function() {
|
||||||
@@ -380,9 +395,22 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#pay').click(function() {
|
$('#pay').click(function() {
|
||||||
// $('#pay').text("Processing, Please wait!")
|
sub_total = $('#sub-total').text();
|
||||||
$( "#loading_wrapper").show();
|
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
|
||||||
|
swal("Opps","Please Pay with MPU Payment","warning")
|
||||||
|
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
|
||||||
|
swal("Opps","Please Pay with Redeem Payment","warning")
|
||||||
|
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
|
||||||
|
swal("Opps","Please Pay with Visa Payment","warning")
|
||||||
|
|
||||||
|
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
|
||||||
|
swal("Opps","Please Pay with jcb Payment","warning")
|
||||||
|
}
|
||||||
|
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
|
||||||
|
swal("Opps","Please Pay with Master Payment","warning")
|
||||||
|
}else{
|
||||||
|
|
||||||
|
$( "#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();
|
||||||
@@ -447,6 +475,7 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#void').on('click',function () {
|
$('#void').on('click',function () {
|
||||||
|
|||||||
@@ -356,6 +356,7 @@
|
|||||||
<!-- <button type="button" class="btn bg-blue btn-block" disabled >Edit</button> -->
|
<!-- <button type="button" class="btn bg-blue btn-block" disabled >Edit</button> -->
|
||||||
<!-- <button type="button" id="discount" class="btn bg-blue btn-block" disabled >Discount</button> -->
|
<!-- <button type="button" id="discount" class="btn bg-blue btn-block" disabled >Discount</button> -->
|
||||||
<!-- <button type="button" id="other-charges" class="btn bg-blue btn-block" disabled>Charges</button> -->
|
<!-- <button type="button" id="other-charges" class="btn bg-blue btn-block" disabled>Charges</button> -->
|
||||||
|
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
|
||||||
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
|
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
|
||||||
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
|
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
|
||||||
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
|
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
|
||||||
@@ -607,7 +608,7 @@ $(".choose_payment").on('click', function () {
|
|||||||
$( "#loading_wrapper" ).hide();
|
$( "#loading_wrapper" ).hide();
|
||||||
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,type);
|
||||||
|
|
||||||
location.reload();
|
location.reload();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user