nfc add customer fixed

This commit is contained in:
yarzar_code
2020-09-02 17:16:01 +06:30
parent f8b56cf48a
commit fa630fd527
6 changed files with 241 additions and 256 deletions

View File

@@ -262,10 +262,7 @@
$("#paypar_account_no").on('focus', function(e){ $("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){ if($(this).val() == ''){
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo();
$("#sxModal").hide();
},100);
} }
}); });
@@ -283,6 +280,7 @@
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
$("#sxModal").hide();
check_member = localStorage.getItem("member_card"); check_member = localStorage.getItem("member_card");
if(cardNo.length == 16){ if(cardNo.length == 16){
if(check_member == "true"){ if(check_member == "true"){

View File

@@ -173,11 +173,7 @@
localStorage.setItem("member_card",true); localStorage.setItem("member_card",true);
var cardNo = ""; var cardNo = "";
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo();
$("#sxModal").hide();
$("#filter_form").submit();
},100);
}); });

View File

@@ -396,10 +396,7 @@
$("#paypar_account_no").on('focus', function(e){ $("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){ if($(this).val() == ''){
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo();
$("#sxModal").hide();
},100);
} }
}); });
@@ -416,37 +413,34 @@
var sale_id = $("#sale_id").val() || 0; var sale_id = $("#sale_id").val() || 0;
var customer_mamber_card_no = 0; var customer_mamber_card_no = 0;
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo(); customer_mamber_card_no = $("#search").val();
$("#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);
}
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:*/ /*new customer UI func:*/
@@ -495,12 +489,14 @@
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
$("#sxModal").hide();
check_member = localStorage.getItem("member_card"); check_member = localStorage.getItem("member_card");
if(cardNo.length == 16){ if(cardNo.length == 16){
if(check_member == "true"){ if(check_member == "true"){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
$("#search").val(cardNo); $("#search").val(cardNo);
$("#type").val("card"); $("#type").val("card");
$("#filter_form").submit();
}else{ }else{
if($.inArray(cardNo, paypar_account_no) !== -1){ if($.inArray(cardNo, paypar_account_no) !== -1){
swal({ swal({

View File

@@ -262,65 +262,62 @@
var customer_mamber_card_no = 0; var customer_mamber_card_no = 0;
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo(); customer_mamber_card_no = $("#paypar_account_no").val();
$("#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);
$.ajax({ if(sale_id != 0 && customer_mamber_card_no != 0){
type: "POST", $.ajax({
url: "<%=origami_payment_dinga_path%>", type: "POST",
data: {payment_amount:payment_amount,membership_id:0,sale_id:sale_id,transaction_ref:data.transaction_ref,account_no :customer_mamber_card_no}, url: "/origami/"+sale_id+"/send_account" ,
success: function(result){ data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
console.log(result) dataType: "json",
if(result.status == true){ success: function(data) {
swal({ console.log(data)
title: "Information!", if (data.status == true) {
text: result.message, var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
html: true, $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
});
}else{ $.ajax({
swal ( "Opps",result.message ,"warning" ); 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 // Read NFC card no from java
@@ -330,6 +327,7 @@
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
$("#sxModal").hide();
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
} }

View File

@@ -247,8 +247,8 @@
}); });
// Read Card Reader // Read Card Reader
$(".btn_member").on('click', function(){ $(".btn_member").on('click', function(){
var cardNo = ""; var cardNo = "";
var sale_id = $("#sale_id").text() || 0; var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || ""; var receipt_no = $("#receipt_no").val() || "";
@@ -256,67 +256,66 @@
var payment_amount = parseFloat($("#used_amount").text()); var payment_amount = parseFloat($("#used_amount").text());
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo(); $("#sxModal").hide();
$("#sxModal").hide(); customer_mamber_card_no = $("#paypar_account_no").val();
customer_mamber_card_no = $("#paypar_account_no").val(); if (customer_mamber_card_no == 0) {
if (customer_mamber_card_no == 0) { customer_mamber_card_no = $("#membership_id").text() || 0;
customer_mamber_card_no = $("#membership_id").text() || 0; }
} if(sale_id != 0 && customer_mamber_card_no !=0){
if(sale_id != 0 && customer_mamber_card_no !=0){ $.ajax({
$.ajax({ type: "POST",
type: "POST", url: "/origami/"+sale_id+"/send_account" ,
url: "/origami/"+sale_id+"/send_account" , data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, dataType: "json",
dataType: "json", success: function(data) {
success: function(data) { if (data.status == true) {
if (data.status == true) { var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<%=origami_payment_paymal_path%>", 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}, 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){ success: function(result){
if(result.status == true){ if(result.status == true){
swal({ swal({
title: "Information!", title: "Information!",
text: result.message, text: result.message,
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
}); });
}else{ }else{
swal ( "Opps",result.message ,"warning" ); 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{ }else{
swal("Opp","Please Check Member","warning") swal("Opp","Please Check Member","warning")
} }
},100);
}); });
// Read NFC card no from java // Read NFC card no from java
@@ -326,6 +325,7 @@
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
$("#sxModal").hide();
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
} }

View File

@@ -1119,32 +1119,30 @@ $(document).ready(function(){
$("#is_memberModal").hide(); $("#is_memberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo(); $("#sxModal").hide();
$("#sxModal").hide(); customer_mamber_card_no = $("#paypar_account_no").val();
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);
}
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 // Read NFC card no from java
@@ -1156,6 +1154,7 @@ $(document).ready(function(){
// get CardNo from Java // get CardNo from Java
function setCardNo(cardNo){ function setCardNo(cardNo){
$("#sxModal").hide();
if(cardNo.length == 16){ if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo); $("#paypar_account_no").val(cardNo);
} }
@@ -1530,85 +1529,83 @@ $(document).ready(function(){
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
setTimeout(function(){ getCardNo();
getCardNo(); $("#sxModal").hide();
$("#sxModal").hide(); customer_mamber_card_no = $("#paypar_account_no").val();
customer_mamber_card_no = $("#paypar_account_no").val(); if (customer_mamber_card_no == 0) {
if (customer_mamber_card_no == 0) { customer_mamber_card_no = $("#membership_id").text() || 0;
customer_mamber_card_no = $("#membership_id").text() || 0; }
} if(sale_id != 0 && customer_mamber_card_no !=0){
if(sale_id != 0 && customer_mamber_card_no !=0){ $.ajax({
$.ajax({ type: "POST",
type: "POST", url: "/origami/"+sale_id+"/send_account" ,
url: "/origami/"+sale_id+"/send_account" , data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no}, dataType: "json",
dataType: "json", success: function(data) {
success: function(data) { if (data.status == true) {
if (data.status == true) { var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount); // $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
// $("#valid_amount").val((valid_amount > 0) ? parseFloat(valid_amount) : 0);
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "<%=origami_payment_paymal_path%>", 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}, 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){ success: function(result){
if(result.status == true){ if(result.status == true){
swal({ swal({
title: "Information!", title: "Information!",
text: result.message, text: result.message,
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment"; window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/payment";
}); });
}else{ }else{
swal({ swal({
title: 'Oops', title: 'Oops',
text: result.message, text: result.message,
type: 'warning', type: 'warning',
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
}); });
} }
} }
}); });
}else{ }else{
swal({ swal({
title: 'Oops', title: 'Oops',
text: data.message.toString(), text: data.message.toString(),
type: 'error', type: 'error',
html: true, html: true,
closeOnConfirm: false, closeOnConfirm: false,
closeOnCancel: false, closeOnCancel: false,
allowOutsideClick: false allowOutsideClick: false
}, function () { }, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
}); });
}
} }
}); }
}else{ });
swal({ }else{
title: 'Oops', swal({
text: 'Please Check Member', title: 'Oops',
type: 'warning', text: 'Please Check Member',
html: true, type: 'warning',
closeOnConfirm: false, html: true,
closeOnCancel: false, closeOnConfirm: false,
allowOutsideClick: false closeOnCancel: false,
}, function () { allowOutsideClick: false
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment"; }, function () {
}); window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
} });
},100); }
}); });
// QR Code Reader // QR Code Reader