add paymal and dinga with account no

This commit is contained in:
phyusin
2018-04-11 16:18:42 +06:30
parent 8261a3453a
commit 0413d56a83
8 changed files with 585 additions and 288 deletions

View File

@@ -13,6 +13,7 @@
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card m-l-10 m-t-10" style="padding:0px 20px;">
<div class="rebate-form">
<input type="hidden" name="receipt_no" id="receipt_no" value="<%= @receipt_no%>">
<div class="row">
<div class="form-group col-lg-12 col-md-12 col-sm-12">
<label class="">You can pay up to </label>
@@ -108,11 +109,12 @@
</div>
<!-- customer light box -->
<div class="modal fade" id="is_memberModal" tabindex="-1" role="dialog">
<div class="modal fade" id="is_paymemberModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="is_memberModalLabel">Are you Member?</h1>
<h1 class="modal-title" id="is_paymemberModalLabel">Are you Member?</h1>
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
</div>
<div class="modal-body">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
@@ -191,18 +193,18 @@
sale_id = $("#valid_amount").attr('data-value');
membership_id = $("#valid_amount").attr('data-member-value');
payment_amount = parseFloat($("#used_amount").text());
if(payment_amount<=0 ){
swal ( "Oops" , "Please type valid amount!" , "warning" );
}else if(valid_amount< payment_amount){
swal ( "Oops" , "Insufficient Amount!" , "warning" );
}else{
if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){
if((membership_id!=undefined) && (membership_id!="") && (membership_id > 0)){
if(payment_amount<=0 ){
swal ( "Oops" , "Please type valid amount!" , "warning" );
}else if(valid_amount< payment_amount){
swal ( "Oops" , "Insufficient Amount!" , "warning" );
}else{
if(payment_amount <= "<%= @payment_prices %>"){
$(this).off("click");
$.ajax({
type: "POST",
url: "<%=origami_payment_paymal_path%>",
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id},
data: {payment_amount:payment_amount,membership_id:membership_id,sale_id:sale_id,transaction_ref:""},
success: function(result){
if(result.status == true){
swal({
@@ -224,23 +226,21 @@
}else {
swal ( "Oops" , "Payment Amount is over!" , "warning" );
}
}else{
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
}
}else{
$("#is_paymemberModal").modal({show : true, backdrop: false, keyboard : false});
}
});
// Read Card Reader
$(".btn_member").on('click', function(){
var cardNo = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || "";
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#used_amount").text());
$("#is_memberModal").hide();
$("#is_paymemberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
@@ -250,18 +250,48 @@
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"},
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[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
if (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount));
$.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},
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 ( "Information" , result.message);
}
}
});
}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);
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";
});
}
}
@@ -284,31 +314,59 @@
// QR Code Reader
$(".btn_qr_code").on('click', function(e){
$("#is_memberModal").hide();
var code = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
$("#is_paymemberModal").hide();
var code = "";
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").val() || "";
var payment_amount = parseFloat($("#used_amount").text());
setTimeout(function(){
code=getQRCode();
if(sale_id != 0 && code != ""){
$.ajax({
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : code ,type :"card"},
url: "/origami/"+sale_id+"/send_account" ,
data: { account_no : code, amount : payment_amount, receipt_no : receipt_no},
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 (data.status == true) {
var valid_amount = parseFloat(data.old_balance_amount) - parseFloat(data.reload_amount);
$("#valid_amount").val(parseFloat(valid_amount));
$.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},
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 ( "Information" , result.message);
}
}
});
}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";
});
}
}
});
}
@@ -321,42 +379,6 @@
$("#qr_code").val(code);
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {
var customer="";
if(customer_name != ""){
customer = '(' + customer_name + ')';
}
swal({
title: "Confirmation !",
text: 'Are You Sure to assign this customer' + customer + '!',
showCancelButton: true,
confirmButtonColor: "green",
confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger',
closeOnConfirm: false,
}, function () {
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
//change customer detail
$("#customer_name").html(customer_name);
$("#membership_id").html(membership_id);
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
swal("Alert!", "Record not found!", "error");
location.reload();
}
}
});
});
}
$("#sxModal .btn_cancel").on('click',function(){
$("#sxModal").hide();
});