fix nfc add customer flow
This commit is contained in:
@@ -30,30 +30,24 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
|
|
||||||
@status_order = ""
|
@status_order = ""
|
||||||
@status_sale = ""
|
@status_sale = ""
|
||||||
@sale_array = Array.new
|
|
||||||
|
|
||||||
@shop = shop_detail
|
@shop = shop_detail
|
||||||
@membership = MembershipSetting::MembershipSetting
|
@membership = MembershipSetting::MembershipSetting
|
||||||
@payment_methods = PaymentMethodSetting.all
|
@payment_methods = PaymentMethodSetting.all
|
||||||
|
|
||||||
@order_items = Array.new
|
@sale_array = @dining.current_sales
|
||||||
@dining.current_bookings.each do |booking|
|
if (booking = @dining.current_checkin_booking)
|
||||||
if @obj_sale || @booking.blank?
|
|
||||||
@booking = booking
|
@booking = booking
|
||||||
|
@order_items = booking.order_items
|
||||||
|
@obj_order = booking.orders.first
|
||||||
end
|
end
|
||||||
|
|
||||||
if booking.sale_id
|
if (booking = @dining.current_checkout_booking)
|
||||||
@sale_array.push(booking.sale)
|
@booking = booking
|
||||||
|
|
||||||
if @obj_sale.blank?
|
|
||||||
@obj_sale = booking.sale
|
@obj_sale = booking.sale
|
||||||
@sale_taxes = @obj_sale.sale_taxes
|
@sale_taxes = @obj_sale.sale_taxes
|
||||||
@status_sale = 'sale'
|
@status_sale = 'sale'
|
||||||
end
|
end
|
||||||
else
|
|
||||||
@order_items += booking.order_items
|
|
||||||
@obj_order = booking.orders.first
|
|
||||||
end
|
|
||||||
|
|
||||||
if @obj_sale || @customer.blank?
|
if @obj_sale || @customer.blank?
|
||||||
if obj = @obj_sale || @obj_order
|
if obj = @obj_sale || @obj_order
|
||||||
@@ -71,7 +65,12 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
if (@obj_sale || @account_arr.blank?) && @customer
|
if (@obj_sale || @account_arr.blank?) && @customer
|
||||||
@account_arr = TaxProfile.find_by(id: @customer.tax_profiles)
|
@account_arr = TaxProfile.find_by(id: @customer.tax_profiles)
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
# @dining.current_bookings.each do |booking|
|
||||||
|
# if @obj_sale || @booking.blank?
|
||||||
|
# @booking = booking
|
||||||
|
# end
|
||||||
|
# end
|
||||||
|
|
||||||
#for bank integration
|
#for bank integration
|
||||||
@checkout_time = Lookup.collection_of('checkout_time')
|
@checkout_time = Lookup.collection_of('checkout_time')
|
||||||
|
|||||||
@@ -58,8 +58,8 @@ class Booking < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scope :active, -> {where("booking_status != 'moved'")}
|
scope :active, -> { where('booking_status != ?', 'moved') }
|
||||||
scope :today, -> {where("created_at >= #{Time.now.utc}")}
|
scope :today, -> { where('created_at >= ?', Time.now) }
|
||||||
scope :assign, -> { where(booking_status: 'assign') }
|
scope :assign, -> { where(booking_status: 'assign') }
|
||||||
|
|
||||||
def self.sync_booking_records(bookings)
|
def self.sync_booking_records(bookings)
|
||||||
|
|||||||
@@ -280,13 +280,13 @@
|
|||||||
|
|
||||||
// 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({
|
||||||
@@ -307,6 +307,7 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$("#sxModal").hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
$("#sxModal .btn_cancel").on('click',function(){
|
$("#sxModal .btn_cancel").on('click',function(){
|
||||||
|
|||||||
@@ -161,22 +161,13 @@
|
|||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$("#oqs_loading_wrapper").show();
|
$("#oqs_loading_wrapper").show();
|
||||||
localStorage.setItem("member_card",false);
|
localStorage.setItem("member_card",false);
|
||||||
/*$('.datepicker').datepicker({
|
|
||||||
format : 'dd-mm-yyyy',
|
|
||||||
autoclose: true
|
|
||||||
});
|
|
||||||
$('.datepicker').attr('ReadOnly','true');
|
|
||||||
$('.datepicker').css('cursor','pointer');*/
|
|
||||||
|
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$("#member_acc_no").on('click', function(e){
|
$("#member_acc_no").on('click', function(e){
|
||||||
localStorage.setItem("member_card",true);
|
localStorage.setItem("member_card",true);
|
||||||
var cardNo = "";
|
|
||||||
$("#sxModal").show();
|
$("#sxModal").show();
|
||||||
getCardNo();
|
getCardNo();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
$("#qr_code").on('click', function(e){
|
$("#qr_code").on('click', function(e){
|
||||||
var code = "";
|
var code = "";
|
||||||
@@ -315,9 +306,6 @@
|
|||||||
//$(".edit_customer").attr('method', 'PATCH');
|
//$(".edit_customer").attr('method', 'PATCH');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// }else{
|
|
||||||
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function update_sale(customer_id,sale_id) {
|
function update_sale(customer_id,sale_id) {
|
||||||
|
|||||||
@@ -368,6 +368,8 @@
|
|||||||
var page = "<%= @page %>";
|
var page = "<%= @page %>";
|
||||||
var paypar_account_no = [];
|
var paypar_account_no = [];
|
||||||
$(function() {
|
$(function() {
|
||||||
|
setHeaderBreadCrumb(_CUSTOMERS_);
|
||||||
|
|
||||||
paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) {
|
paypar_account_no = JSON.parse('<%= @paypar_accountno.to_json.html_safe %>', function (key, value) {
|
||||||
var type;
|
var type;
|
||||||
if (value && typeof value === 'object') {
|
if (value && typeof value === 'object') {
|
||||||
@@ -378,7 +380,7 @@
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
});
|
});
|
||||||
console.log(paypar_account_no);
|
|
||||||
/* check webview loaded*/
|
/* check webview loaded*/
|
||||||
var webview = <%= @webview %>;
|
var webview = <%= @webview %>;
|
||||||
showHideNavbar(webview);
|
showHideNavbar(webview);
|
||||||
@@ -400,47 +402,11 @@
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).ready(function () {
|
|
||||||
setHeaderBreadCrumb(_CUSTOMERS_);
|
|
||||||
|
|
||||||
});
|
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$("#member_acc_no").on('click', function(e){
|
$("#member_acc_no").on('click', function(e){
|
||||||
localStorage.setItem("member_card",true);
|
localStorage.setItem("member_card",true);
|
||||||
var cardNo = "";
|
|
||||||
var customer_id = '';
|
|
||||||
var customer_name = '';
|
|
||||||
var sale_id = $("#sale_id").val() || 0;
|
|
||||||
var customer_mamber_card_no = 0;
|
|
||||||
$("#sxModal").show();
|
$("#sxModal").show();
|
||||||
getCardNo();
|
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
/*new customer UI func:*/
|
/*new customer UI func:*/
|
||||||
@@ -449,7 +415,6 @@
|
|||||||
|
|
||||||
//Wizard
|
//Wizard
|
||||||
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
|
$('a[data-toggle="tab"]').on('show.bs.tab', function (e) {
|
||||||
|
|
||||||
var $target = $(e.target);
|
var $target = $(e.target);
|
||||||
|
|
||||||
if ($target.parent().hasClass('disabled')) {
|
if ($target.parent().hasClass('disabled')) {
|
||||||
@@ -463,6 +428,7 @@
|
|||||||
nextTab($active);
|
nextTab($active);
|
||||||
$('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0});
|
$('.wizard .nav-tabs li.active .connecting-line').css({"border-bottom-left-radius": 0, "border-top-left-radius": 0});
|
||||||
});
|
});
|
||||||
|
|
||||||
$(".prev-step").click(function (e) {
|
$(".prev-step").click(function (e) {
|
||||||
|
|
||||||
var $active = $('.wizard .nav-tabs li a.active');
|
var $active = $('.wizard .nav-tabs li a.active');
|
||||||
@@ -484,19 +450,20 @@
|
|||||||
|
|
||||||
// Read NFC card no from java
|
// Read NFC card no from java
|
||||||
function getCardNo(){
|
function getCardNo(){
|
||||||
|
if (typeof code2lab != 'undefined') {
|
||||||
code2lab.readNFC();
|
code2lab.readNFC();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// 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();
|
get_customer();
|
||||||
}else{
|
}else{
|
||||||
if($.inArray(cardNo, paypar_account_no) !== -1){
|
if($.inArray(cardNo, paypar_account_no) !== -1){
|
||||||
swal({
|
swal({
|
||||||
@@ -517,6 +484,35 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$("#sxModal").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_customer() {
|
||||||
|
var cardNo = "";
|
||||||
|
var customer_id = '';
|
||||||
|
var customer_name = '';
|
||||||
|
var sale_id = $("#sale_id").val() || 0;
|
||||||
|
var customer_mamber_card_no = $("#search").val();
|
||||||
|
|
||||||
|
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||||
|
$('#loading_wrapper').show();
|
||||||
|
$.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;
|
||||||
|
update_sale(customer_id, customer_name,sale_id);
|
||||||
|
}
|
||||||
|
$('#loading_wrapper').hide();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
@@ -572,17 +568,14 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(document).on('click',".customer_tr",function(){
|
$(document).on('click',".customer_tr",function(){
|
||||||
// if(this.checked){
|
|
||||||
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
|
||||||
var sale_id = $("#sale_id").val() || 0;
|
var sale_id = $("#sale_id").val() || 0;
|
||||||
var customer_id = $(this).attr('data-ref');
|
var customer_id = $(this).attr('data-ref');
|
||||||
var customer_name = $(this).children("td:nth-child(3)").text();
|
var customer_name = $(this).children("td:nth-child(3)").text();
|
||||||
console.log(sale_id);
|
|
||||||
if(sale_id != 0){
|
if(sale_id != 0){
|
||||||
// var url = "/"+customer_id;
|
|
||||||
update_sale(customer_id, customer_name,sale_id);
|
update_sale(customer_id, customer_name,sale_id);
|
||||||
}else{
|
}else{
|
||||||
|
|
||||||
var url = "customers/"+customer_id;
|
var url = "customers/"+customer_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -643,9 +636,6 @@
|
|||||||
//$(".edit_customer").attr('method', 'PATCH');
|
//$(".edit_customer").attr('method', 'PATCH');
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// }else{
|
|
||||||
|
|
||||||
// }
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function update_sale(customer_id, customer_name, sale_id) {
|
function update_sale(customer_id, customer_name, sale_id) {
|
||||||
|
|||||||
@@ -106,13 +106,8 @@
|
|||||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||||
<button type="button" class="btn bg-default m-t-10 btn-lg btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
|
<button type="button" class="btn bg-default m-t-10 btn-lg btn-block" onclick="window.location.href = '/origami/sale/<%= @sale_id %>/<%= @cashier_type %>/payment/others_payment';"> <i class="material-icons m-t--5">reply</i>Back </button>
|
||||||
</div>
|
</div>
|
||||||
<div id="sxModal">
|
|
||||||
<div id="sxModal-Content"><h3>Card Tap</h3></div>
|
|
||||||
<div class="m-r-20" align="right">
|
|
||||||
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="sxModal">
|
<div id="sxModal">
|
||||||
<div id="sxModal-Content"><h3>Card Tap</h3></div>
|
<div id="sxModal-Content"><h3>Card Tap</h3></div>
|
||||||
<div class="m-r-20" align="right">
|
<div class="m-r-20" align="right">
|
||||||
@@ -252,6 +247,26 @@
|
|||||||
|
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$(".btn_member").on('click', function(){
|
$(".btn_member").on('click', function(){
|
||||||
|
$("#is_paymemberModal").hide();
|
||||||
|
$("#sxModal").show();
|
||||||
|
getCardNo();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Read NFC card no from java
|
||||||
|
function getCardNo(){
|
||||||
|
code2lab.readNFC();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get CardNo from Java
|
||||||
|
function setCardNo(cardNo){
|
||||||
|
if(cardNo.length == 16){
|
||||||
|
$("#paypar_account_no").val(cardNo);
|
||||||
|
send_account();
|
||||||
|
}
|
||||||
|
$("#sxModal").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_account() {
|
||||||
var cardNo = "";
|
var cardNo = "";
|
||||||
var customer_id = '';
|
var customer_id = '';
|
||||||
var customer_name = '';
|
var customer_name = '';
|
||||||
@@ -259,12 +274,7 @@
|
|||||||
var membership_type = '';
|
var membership_type = '';
|
||||||
var sale_id = $("#sale_id").text() || 0;
|
var sale_id = $("#sale_id").text() || 0;
|
||||||
var receipt_no = $("#receipt_no").text() || 0;
|
var receipt_no = $("#receipt_no").text() || 0;
|
||||||
var customer_mamber_card_no = 0;
|
var customer_mamber_card_no = $("#paypar_account_no").val();
|
||||||
|
|
||||||
$("#is_paymemberModal").hide();
|
|
||||||
$("#sxModal").show();
|
|
||||||
getCardNo();
|
|
||||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
|
||||||
|
|
||||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
@@ -277,7 +287,6 @@
|
|||||||
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_dinga_path%>",
|
url: "<%=origami_payment_dinga_path%>",
|
||||||
@@ -314,23 +323,9 @@
|
|||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA";
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/DINGA";
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
|
||||||
|
|
||||||
// Read NFC card no from java
|
|
||||||
function getCardNo(){
|
|
||||||
code2lab.readNFC();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get CardNo from Java
|
|
||||||
function setCardNo(cardNo){
|
|
||||||
$("#sxModal").hide();
|
|
||||||
if(cardNo.length == 16){
|
|
||||||
$("#paypar_account_no").val(cardNo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
|
|||||||
@@ -248,21 +248,35 @@
|
|||||||
|
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$(".btn_member").on('click', function(){
|
$(".btn_member").on('click', function(){
|
||||||
var cardNo = "";
|
|
||||||
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_paymemberModal").hide();
|
$("#is_paymemberModal").hide();
|
||||||
$("#sxModal").show();
|
$("#sxModal").show();
|
||||||
getCardNo();
|
getCardNo();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Read NFC card no from java
|
||||||
|
function getCardNo(){
|
||||||
|
code2lab.readNFC();
|
||||||
|
}
|
||||||
|
|
||||||
|
// get CardNo from Java
|
||||||
|
function setCardNo(cardNo){
|
||||||
|
if(cardNo.length == 16){
|
||||||
|
$("#paypar_account_no").val(cardNo);
|
||||||
|
}
|
||||||
$("#sxModal").hide();
|
$("#sxModal").hide();
|
||||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
}
|
||||||
|
|
||||||
|
function send_account() {
|
||||||
|
var cardNo = "";
|
||||||
|
var sale_id = $("#sale_id").text() || 0;
|
||||||
|
var receipt_no = $("#receipt_no").val() || "";
|
||||||
|
var payment_amount = parseFloat($("#used_amount").text());
|
||||||
|
var 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",
|
||||||
@@ -309,26 +323,11 @@
|
|||||||
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment/others_payment/PAYMAL";
|
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")
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
// Read NFC card no from java
|
|
||||||
function getCardNo(){
|
|
||||||
code2lab.readNFC();
|
|
||||||
}
|
|
||||||
|
|
||||||
// get CardNo from Java
|
|
||||||
function setCardNo(cardNo){
|
|
||||||
$("#sxModal").hide();
|
|
||||||
if(cardNo.length == 16){
|
|
||||||
$("#paypar_account_no").val(cardNo);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
|
|||||||
@@ -1109,21 +1109,42 @@ $(document).ready(function(){
|
|||||||
|
|
||||||
// Read Card Reader
|
// Read Card Reader
|
||||||
$(".btn_member").on('click', function(){
|
$(".btn_member").on('click', function(){
|
||||||
|
$("#is_memberModal").hide();
|
||||||
|
$("#sxModal").show();
|
||||||
|
getCardNo();
|
||||||
|
});
|
||||||
|
|
||||||
|
// Read NFC card no from java
|
||||||
|
function getCardNo(){
|
||||||
|
if(typeof code2lab != 'undefined'){
|
||||||
|
code2lab.readNFC();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// get CardNo from Java
|
||||||
|
function setCardNo(cardNo){
|
||||||
|
if(cardNo.length == 16){
|
||||||
|
$("#paypar_account_no").val(cardNo);
|
||||||
|
if (cashier_type == "food_court") {
|
||||||
|
send_account();
|
||||||
|
} else {
|
||||||
|
get_customer();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$("#sxModal").hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
function get_customer() {
|
||||||
var cardNo = "";
|
var cardNo = "";
|
||||||
var customer_id = '';
|
var customer_id = '';
|
||||||
var customer_name = '';
|
var customer_name = '';
|
||||||
var membership_id = '';
|
var membership_id = '';
|
||||||
var membership_type = '';
|
var membership_type = '';
|
||||||
var sale_id = $("#sale_id").text() || 0;
|
var sale_id = $("#sale_id").text() || 0;
|
||||||
var customer_mamber_card_no = 0;
|
var customer_mamber_card_no = $("#paypar_account_no").val();
|
||||||
|
|
||||||
$("#is_memberModal").hide();
|
|
||||||
$("#sxModal").show();
|
|
||||||
getCardNo();
|
|
||||||
$("#sxModal").hide();
|
|
||||||
customer_mamber_card_no = $("#paypar_account_no").val();
|
|
||||||
|
|
||||||
if(sale_id != 0 && customer_mamber_card_no != 0){
|
if(sale_id != 0 && customer_mamber_card_no != 0){
|
||||||
|
$('#loading_wrapper').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/"+sale_id+"/get_customer" ,
|
url: "/origami/"+sale_id+"/get_customer" ,
|
||||||
@@ -1139,24 +1160,97 @@ $(document).ready(function(){
|
|||||||
membership_type = data[0].membership_type;
|
membership_type = data[0].membership_type;
|
||||||
update_sale(membership_id, customer_id, customer_name,sale_id);
|
update_sale(membership_id, customer_id, customer_name,sale_id);
|
||||||
}
|
}
|
||||||
|
$('#loading_wrapper').hide();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function send_account() {
|
||||||
|
var cardNo = "";
|
||||||
|
var sale_id = $("#sale_id").text() || 0;
|
||||||
|
var receipt_no = "";
|
||||||
|
|
||||||
|
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
||||||
|
receipt_no = ($("#receipt_no").html()).trim();
|
||||||
|
}
|
||||||
|
|
||||||
|
var payment_amount = parseFloat($("#grand_total").text());
|
||||||
|
|
||||||
|
var 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";
|
||||||
});
|
});
|
||||||
|
|
||||||
// Read NFC card no from java
|
}else{
|
||||||
function getCardNo(){
|
swal({
|
||||||
if(typeof code2lab != 'undefined'){
|
title: 'Oops',
|
||||||
code2lab.readNFC();
|
text: result.message,
|
||||||
|
type: 'warning',
|
||||||
|
html: true,
|
||||||
|
closeOnConfirm: false,
|
||||||
|
closeOnCancel: false,
|
||||||
|
allowOutsideClick: false
|
||||||
|
}, function () {
|
||||||
|
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
});
|
||||||
// get CardNo from Java
|
}else{
|
||||||
function setCardNo(cardNo){
|
swal({
|
||||||
$("#sxModal").hide();
|
title: 'Oops',
|
||||||
if(cardNo.length == 16){
|
text: data.message.toString(),
|
||||||
$("#paypar_account_no").val(cardNo);
|
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";
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1215,6 +1309,7 @@ $(document).ready(function(){
|
|||||||
cancelButtonClass: 'btn btn-danger',
|
cancelButtonClass: 'btn btn-danger',
|
||||||
closeOnConfirm: false,
|
closeOnConfirm: false,
|
||||||
}, function () {
|
}, function () {
|
||||||
|
$('#loading_wrapper').show();
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: "POST",
|
type: "POST",
|
||||||
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
|
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
|
||||||
@@ -1510,102 +1605,15 @@ $(document).ready(function(){
|
|||||||
$("#customer_name").on("click",function(){
|
$("#customer_name").on("click",function(){
|
||||||
//start customer modal popup
|
//start customer modal popup
|
||||||
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
|
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
|
||||||
|
|
||||||
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
|
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// Read Card Reader - Paymal payment for FoodCourt
|
// Read Card Reader - Paymal payment for FoodCourt
|
||||||
$(".btn_paymal_member").on('click', function (){
|
$(".btn_paymal_member").on('click', function (){
|
||||||
var cardNo = "";
|
|
||||||
var sale_id = $("#sale_id").text() || 0;
|
|
||||||
var receipt_no = "";
|
|
||||||
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
|
|
||||||
receipt_no = ($("#receipt_no").html()).trim();
|
|
||||||
}
|
|
||||||
|
|
||||||
var customer_mamber_card_no = 0;
|
|
||||||
var payment_amount = parseFloat($("#grand_total").text());
|
|
||||||
|
|
||||||
$("#is_paymemberModal").hide();
|
$("#is_paymemberModal").hide();
|
||||||
$("#sxModal").show();
|
$("#sxModal").show();
|
||||||
getCardNo();
|
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";
|
|
||||||
});
|
|
||||||
|
|
||||||
}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";
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
// QR Code Reader
|
// QR Code Reader
|
||||||
|
|||||||
Reference in New Issue
Block a user