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"));
|
||||||
var json_data = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
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 });
|
||||||
|
}
|
||||||
|
|
||||||
if((arr_data.length) > (json_data.length)){
|
if((arr_data.length) > (json_data.length)){
|
||||||
status = true;
|
status = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (payment) {
|
||||||
return status;
|
return json_data[0]["payment"];
|
||||||
|
}else{
|
||||||
|
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,74 +395,88 @@
|
|||||||
});
|
});
|
||||||
|
|
||||||
$('#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")
|
||||||
if($('#balance').text() > 0){
|
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
|
||||||
swal ( "Oops" , "Insufficient Amount!" , "error" );
|
swal("Opps","Please Pay with Redeem Payment","warning")
|
||||||
$( "#loading_wrapper").hide();
|
}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{
|
}else{
|
||||||
$(this).off("click");
|
|
||||||
var sale_id = $('#sale_id').text();
|
|
||||||
// var item_row = $('.is_card');
|
|
||||||
|
|
||||||
// if (item_row.length < 1) {
|
$( "#loading_wrapper").show();
|
||||||
calculate_member_discount(sale_id);
|
if($('#balance').text() > 0){
|
||||||
// }
|
swal ( "Oops" , "Insufficient Amount!" , "error" );
|
||||||
|
$( "#loading_wrapper").hide();
|
||||||
// payment
|
}else{
|
||||||
var cash = $('#cash').text();
|
$(this).off("click");
|
||||||
var credit = $('#credit').text();
|
var sale_id = $('#sale_id').text();
|
||||||
var card = $('#card').text();
|
// var item_row = $('.is_card');
|
||||||
|
|
||||||
$.ajax({type: "POST",
|
|
||||||
url: "<%= origami_payment_cash_path %>",
|
|
||||||
data: "cash="+ cash + "&sale_id=" + sale_id,
|
|
||||||
async: false,
|
|
||||||
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");
|
// if (item_row.length < 1) {
|
||||||
if (result.status) {
|
calculate_member_discount(sale_id);
|
||||||
var msg = result.message;
|
// }
|
||||||
}
|
|
||||||
else{
|
// payment
|
||||||
var msg = '';
|
var cash = $('#cash').text();
|
||||||
}
|
var credit = $('#credit').text();
|
||||||
$( "#loading_wrapper" ).hide();
|
var card = $('#card').text();
|
||||||
if($('#balance').text() < 0){
|
|
||||||
swal({
|
$.ajax({type: "POST",
|
||||||
title: "Information!",
|
url: "<%= origami_payment_cash_path %>",
|
||||||
text: 'Changed amount ' + $('#balance').text() * (-1),
|
data: "cash="+ cash + "&sale_id=" + sale_id,
|
||||||
html: true,
|
async: false,
|
||||||
closeOnConfirm: false,
|
success:function(result){
|
||||||
closeOnCancel: false,
|
/* start delete receipt no in first bill*/
|
||||||
allowOutsideClick: false
|
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||||
}, function () {
|
var receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
deleteReceiptNoInFirstBillData(receipt_no);
|
||||||
|
}
|
||||||
|
/* end delete receipt no in first bill*/
|
||||||
|
|
||||||
|
localStorage.removeItem("cash");
|
||||||
|
if (result.status) {
|
||||||
|
var msg = result.message;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
var msg = '';
|
||||||
|
}
|
||||||
|
$( "#loading_wrapper" ).hide();
|
||||||
|
if($('#balance').text() < 0){
|
||||||
|
swal({
|
||||||
|
title: "Information!",
|
||||||
|
text: 'Changed amount ' + $('#balance').text() * (-1),
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
|
window.location.href = '/origami';
|
||||||
|
});
|
||||||
|
}else{
|
||||||
|
$('#pay').text("Pay");
|
||||||
|
swal({
|
||||||
|
title: "Information!",
|
||||||
|
text: 'Thank You !',
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
window.location.href = '/origami';
|
window.location.href = '/origami';
|
||||||
});
|
});
|
||||||
}else{
|
}
|
||||||
$('#pay').text("Pay");
|
|
||||||
swal({
|
|
||||||
title: "Information!",
|
|
||||||
text: 'Thank You !',
|
|
||||||
html: true,
|
|
||||||
closeOnConfirm: false,
|
|
||||||
closeOnCancel: false,
|
|
||||||
allowOutsideClick: false
|
|
||||||
}, function () {
|
|
||||||
window.location.href = '/origami';
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#void').on('click',function () {
|
$('#void').on('click',function () {
|
||||||
if ($(this).attr('active') === "true") {
|
if ($(this).attr('active') === "true") {
|
||||||
|
|||||||
@@ -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