diff --git a/app/views/crm/customers/_new_form.html.erb b/app/views/crm/customers/_new_form.html.erb index e401aef6..7971ba72 100644 --- a/app/views/crm/customers/_new_form.html.erb +++ b/app/views/crm/customers/_new_form.html.erb @@ -262,10 +262,7 @@ $("#paypar_account_no").on('focus', function(e){ if($(this).val() == ''){ $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - },100); + getCardNo(); } }); @@ -283,6 +280,7 @@ // get CardNo from Java function setCardNo(cardNo){ + $("#sxModal").hide(); check_member = localStorage.getItem("member_card"); if(cardNo.length == 16){ if(check_member == "true"){ diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 815335f2..a5462b1d 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -173,11 +173,7 @@ localStorage.setItem("member_card",true); var cardNo = ""; $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - $("#filter_form").submit(); - },100); + getCardNo(); }); diff --git a/app/views/origami/customers/index.html.erb b/app/views/origami/customers/index.html.erb index fb1e7e14..fb804f5b 100644 --- a/app/views/origami/customers/index.html.erb +++ b/app/views/origami/customers/index.html.erb @@ -396,10 +396,7 @@ $("#paypar_account_no").on('focus', function(e){ if($(this).val() == ''){ $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - },100); + getCardNo(); } }); @@ -416,37 +413,34 @@ var sale_id = $("#sale_id").val() || 0; var customer_mamber_card_no = 0; $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#search").val(); - - if(sale_id != 0 && customer_mamber_card_no != 0){ - $.ajax({ - type: "POST", - url: "/origami/"+sale_id+"/get_customer" , - data: { filter : customer_mamber_card_no ,type :"card"}, - dataType: "json", - success: function(data) { - if (data[0].customer_id == false) { - swal("Alert!", data[0].message, "error"); - // $.alert({ - // title: 'Alert!', - // content: data[0].message, - // type: 'red', - // typeAnimated: true, - // btnClass: 'btn-danger', - // }); - }else{ - customer_id = data[0].customer_id; - customer_name = data[0].name; - update_sale(customer_id, customer_name,sale_id); - } + getCardNo(); + customer_mamber_card_no = $("#search").val(); + if(sale_id != 0 && customer_mamber_card_no != 0){ + $.ajax({ + type: "POST", + url: "/origami/"+sale_id+"/get_customer" , + data: { filter : customer_mamber_card_no ,type :"card"}, + dataType: "json", + success: function(data) { + if (data[0].customer_id == false) { + swal("Alert!", data[0].message, "error"); + // $.alert({ + // title: 'Alert!', + // content: data[0].message, + // type: 'red', + // typeAnimated: true, + // btnClass: 'btn-danger', + // }); + }else{ + customer_id = data[0].customer_id; + customer_name = data[0].name; + update_sale(customer_id, customer_name,sale_id); } - }); - } - },100); + + } + }); + } }); /*new customer UI func:*/ @@ -495,12 +489,14 @@ // get CardNo from Java function setCardNo(cardNo){ + $("#sxModal").hide(); check_member = localStorage.getItem("member_card"); if(cardNo.length == 16){ if(check_member == "true"){ $("#paypar_account_no").val(cardNo); $("#search").val(cardNo); $("#type").val("card"); + $("#filter_form").submit(); }else{ if($.inArray(cardNo, paypar_account_no) !== -1){ swal({ diff --git a/app/views/origami/dinga/index.html.erb b/app/views/origami/dinga/index.html.erb index 8c326ac2..fbefb5be 100644 --- a/app/views/origami/dinga/index.html.erb +++ b/app/views/origami/dinga/index.html.erb @@ -262,65 +262,62 @@ var customer_mamber_card_no = 0; $("#is_paymemberModal").hide(); - $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); - - if(sale_id != 0 && customer_mamber_card_no != 0){ - $.ajax({ - type: "POST", - url: "/origami/"+sale_id+"/send_account" , - data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, - dataType: "json", - success: function(data) { - console.log(data) - if (data.status == true) { - var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); - $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); + $("#sxModal").show(); + getCardNo(); + customer_mamber_card_no = $("#paypar_account_no").val(); - $.ajax({ - type: "POST", - url: "<%=origami_payment_dinga_path%>", - data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no :customer_mamber_card_no}, - success: function(result){ - console.log(result) - if(result.status == true){ - swal({ - title: "Information!", - text: result.message, - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); + if(sale_id != 0 && customer_mamber_card_no != 0){ + $.ajax({ + type: "POST", + url: "/origami/"+sale_id+"/send_account" , + data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, + dataType: "json", + success: function(data) { + console.log(data) + if (data.status == true) { + var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); + $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); - }else{ - swal ( "Opps",result.message ,"warning" ); - } + $.ajax({ + type: "POST", + url: "<%=origami_payment_dinga_path%>", + data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no :customer_mamber_card_no}, + success: function(result){ + console.log(result) + if(result.status == true){ + swal({ + title: "Information!", + text: result.message, + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); + + }else{ + swal ( "Opps",result.message ,"warning" ); + } + } + }); + }else{ + swal({ + title: 'Oops', + text: data.message.toString(), + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA"; + }); } - }); - }else{ - swal({ - title: 'Oops', - text: data.message.toString(), - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA"; - }); - } - } - }); - } - },100); + } + }); + } }); // Read NFC card no from java @@ -330,6 +327,7 @@ // get CardNo from Java function setCardNo(cardNo){ + $("#sxModal").hide(); if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); } diff --git a/app/views/origami/paymal/index.html.erb b/app/views/origami/paymal/index.html.erb index 802c1ce4..82dae2de 100644 --- a/app/views/origami/paymal/index.html.erb +++ b/app/views/origami/paymal/index.html.erb @@ -247,8 +247,8 @@ }); // Read Card Reader - $(".btn_member").on('click', function(){ - var cardNo = ""; + $(".btn_member").on('click', function(){ + var cardNo = ""; var sale_id = $("#sale_id").text() || 0; var receipt_no = $("#receipt_no").val() || ""; @@ -256,67 +256,66 @@ var payment_amount = parseFloat($("#used_amount").text()); $("#is_paymemberModal").hide(); - $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); - if (customer_mamber_card_no == 0) { - customer_mamber_card_no = $("#membership_id").text() || 0; - } - if(sale_id != 0 && customer_mamber_card_no !=0){ - $.ajax({ - type: "POST", - url: "/origami/"+sale_id+"/send_account" , - data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, - dataType: "json", - success: function(data) { - if (data.status == true) { - var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); - $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); + $("#sxModal").show(); + getCardNo(); + $("#sxModal").hide(); + customer_mamber_card_no = $("#paypar_account_no").val(); + if (customer_mamber_card_no == 0) { + customer_mamber_card_no = $("#membership_id").text() || 0; + } + if(sale_id != 0 && customer_mamber_card_no !=0){ + $.ajax({ + type: "POST", + url: "/origami/"+sale_id+"/send_account" , + data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, + dataType: "json", + success: function(data) { + if (data.status == true) { + var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); + $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); - $.ajax({ - type: "POST", - url: "<%=origami_payment_paymal_path%>", - data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no}, - success: function(result){ - if(result.status == true){ - swal({ - title: "Information!", - text: result.message, - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); + $.ajax({ + type: "POST", + url: "<%=origami_payment_paymal_path%>", + data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no}, + success: function(result){ + if(result.status == true){ + swal({ + title: "Information!", + text: result.message, + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); - }else{ - swal ( "Opps",result.message ,"warning" ); - } + }else{ + swal ( "Opps",result.message ,"warning" ); + } + } + }); + }else{ + swal({ + title: 'Oops', + text: data.message.toString(), + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/PAYMAL"; + }); } - }); - }else{ - swal({ - title: 'Oops', - text: data.message.toString(), - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/PAYMAL"; - }); - } - } - }); - }else{ - swal("Opp","Please Check Member","warning") - } - },100); + } + }); + }else{ + swal("Opp","Please Check Member","warning") + } + }); // Read NFC card no from java @@ -326,6 +325,7 @@ // get CardNo from Java function setCardNo(cardNo){ + $("#sxModal").hide(); if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); } diff --git a/app/views/origami/payments/show.html.erb b/app/views/origami/payments/show.html.erb index 20bf09e2..ad2591c9 100755 --- a/app/views/origami/payments/show.html.erb +++ b/app/views/origami/payments/show.html.erb @@ -1119,32 +1119,30 @@ $(document).ready(function(){ $("#is_memberModal").hide(); $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); - - if(sale_id != 0 && customer_mamber_card_no != 0){ - $.ajax({ - type: "POST", - url: "/origami/"+sale_id+"/get_customer" , - data: { filter : customer_mamber_card_no ,type :"card"}, - dataType: "json", - success: function(data) { - if (data[0].customer_id == false) { - swal("Alert!", data[0].message, "error"); - }else{ - customer_id = data[0].customer_id; - customer_name = data[0].name; - membership_id = data[0].membership_id; - membership_type = data[0].membership_type; - update_sale(membership_id, customer_id, customer_name,sale_id); - } + getCardNo(); + $("#sxModal").hide(); + customer_mamber_card_no = $("#paypar_account_no").val(); + if(sale_id != 0 && customer_mamber_card_no != 0){ + $.ajax({ + type: "POST", + url: "/origami/"+sale_id+"/get_customer" , + data: { filter : customer_mamber_card_no ,type :"card"}, + dataType: "json", + success: function(data) { + if (data[0].customer_id == false) { + swal("Alert!", data[0].message, "error"); + }else{ + customer_id = data[0].customer_id; + customer_name = data[0].name; + membership_id = data[0].membership_id; + membership_type = data[0].membership_type; + update_sale(membership_id, customer_id, customer_name,sale_id); } - }); - } - },100); + + } + }); + } }); // Read NFC card no from java @@ -1156,6 +1154,7 @@ $(document).ready(function(){ // get CardNo from Java function setCardNo(cardNo){ + $("#sxModal").hide(); if(cardNo.length == 16){ $("#paypar_account_no").val(cardNo); } @@ -1530,85 +1529,83 @@ $(document).ready(function(){ $("#is_paymemberModal").hide(); $("#sxModal").show(); - setTimeout(function(){ - getCardNo(); - $("#sxModal").hide(); - customer_mamber_card_no = $("#paypar_account_no").val(); - if (customer_mamber_card_no == 0) { - customer_mamber_card_no = $("#membership_id").text() || 0; - } - if(sale_id != 0 && customer_mamber_card_no !=0){ - $.ajax({ - type: "POST", - url: "/origami/"+sale_id+"/send_account" , - data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, - dataType: "json", - success: function(data) { - if (data.status == true) { - var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); - // $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); + getCardNo(); + $("#sxModal").hide(); + customer_mamber_card_no = $("#paypar_account_no").val(); + if (customer_mamber_card_no == 0) { + customer_mamber_card_no = $("#membership_id").text() || 0; + } + if(sale_id != 0 && customer_mamber_card_no !=0){ + $.ajax({ + type: "POST", + url: "/origami/"+sale_id+"/send_account" , + data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, + dataType: "json", + success: function(data) { + if (data.status == true) { + var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); + // $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0); - $.ajax({ - type: "POST", - url: "<%=origami_payment_paymal_path%>", - data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no}, - success: function(result){ - if(result.status == true){ - swal({ - title: "Information!", - text: result.message, - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; - }); + $.ajax({ + type: "POST", + url: "<%=origami_payment_paymal_path%>", + data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no:customer_mamber_card_no}, + success: function(result){ + if(result.status == true){ + swal({ + title: "Information!", + text: result.message, + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; + }); - }else{ - swal({ - title: 'Oops', - text: result.message, - type: 'warning', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; - }); - } - } - }); - }else{ - swal({ - title: 'Oops', - text: data.message.toString(), - type: 'error', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; - }); - } + }else{ + swal({ + title: 'Oops', + text: result.message, + type: 'warning', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; + }); + } + } + }); + }else{ + swal({ + title: 'Oops', + text: data.message.toString(), + type: 'error', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; + }); } - }); - }else{ - swal({ - title: 'Oops', - text: 'Please Check Member', - type: 'warning', - html: true, - closeOnConfirm: false, - closeOnCancel: false, - allowOutsideClick: false - }, function () { - window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; - }); - } - },100); + } + }); + }else{ + swal({ + title: 'Oops', + text: 'Please Check Member', + type: 'warning', + html: true, + closeOnConfirm: false, + closeOnCancel: false, + allowOutsideClick: false + }, function () { + window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; + }); + } }); // QR Code Reader