fix nfc add customer flow

This commit is contained in:
Thein Lin Kyaw
2020-09-05 13:28:01 +06:30
parent fa630fd527
commit febb398605
8 changed files with 513 additions and 533 deletions

View File

@@ -30,49 +30,48 @@ 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
end @obj_order = booking.orders.first
end
if booking.sale_id if (booking = @dining.current_checkout_booking)
@sale_array.push(booking.sale) @booking = booking
@obj_sale = booking.sale
@sale_taxes = @obj_sale.sale_taxes
@status_sale = 'sale'
end
if @obj_sale.blank? if @obj_sale || @customer.blank?
@obj_sale = booking.sale if obj = @obj_sale || @obj_order
@sale_taxes = @obj_sale.sale_taxes @customer = obj.customer
@status_sale = 'sale' @date = obj.created_at
end
else
@order_items += booking.order_items
@obj_order = booking.orders.first
end
if @obj_sale || @customer.blank?
if obj = @obj_sale || @obj_order
@customer = obj.customer
@date = obj.created_at
end
end
if @obj_sale
@status_order = 'sale'
else
@status_order = 'order'
end
if (@obj_sale || @account_arr.blank?) && @customer
@account_arr = TaxProfile.find_by(id: @customer.tax_profiles)
end end
end end
if @obj_sale
@status_order = 'sale'
else
@status_order = 'order'
end
if (@obj_sale || @account_arr.blank?) && @customer
@account_arr = TaxProfile.find_by(id: @customer.tax_profiles)
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')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time') @checkout_alert_time = Lookup.collection_of('checkout_alert_time')

View File

@@ -58,9 +58,9 @@ 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)
if !bookings.nil? if !bookings.nil?

View File

@@ -57,7 +57,7 @@
<div class="col-sm-12 col-md-12 col-lg-12"> <div class="col-sm-12 col-md-12 col-lg-12">
<%= f.input :name, :class => "form-control name", :required => true %> <%= f.input :name, :class => "form-control name", :required => true %>
<% flash.each do |test, msg| %> <% flash.each do |test, msg| %>
<% <%
str="[\"#{msg['name']}\"]" str="[\"#{msg['name']}\"]"
str.gsub!('["', '') str.gsub!('["', '')
str.gsub!('"]', '') %> str.gsub!('"]', '') %>
@@ -94,7 +94,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12" align="right"> <div class="col-sm-12 col-md-12 col-lg-12" align="right">
<button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button> <button type="button" class="btn btn-md bg-blue btn-info-full next-step">Next</button>
</div> </div>
</div> </div>
</div> </div>
<div class="tab-pane" role="tabpanel" id="complete"> <div class="tab-pane" role="tabpanel" id="complete">
@@ -107,12 +107,12 @@
<% if f.object.image_path? %> <% if f.object.image_path? %>
<p><%= f.object.name %></p> <p><%= f.object.name %></p>
<%= image_tag f.object.image_path.url, :class => "img-thumbnail" %> <%= image_tag f.object.image_path.url, :class => "img-thumbnail" %>
<% else %> <% else %>
<%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %> <%= image_tag "/image/menu_images/default.png", :class => "img-thumbnail" %>
<% end %> <% end %>
</div> </div>
<%= f.file_field :image_path, :class => "img-thumbnail" %> <%= f.file_field :image_path, :class => "img-thumbnail" %>
</div> </div>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -160,7 +160,7 @@
<option value="<%= ct.value %>"> <option value="<%= ct.value %>">
<%= ct.name %></option> <%= ct.name %></option>
<%end %> <%end %>
</select> </select>
</div> </div>
</div> </div>
@@ -185,7 +185,7 @@
<div class="form-group"> <div class="form-group">
<div class="col-sm-12 col-md-12 col-lg-12"> <div class="col-sm-12 col-md-12 col-lg-12">
<label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label> <label class="control-label"><%= t("views.right_panel.detail.paypar_account_no") %>:</label>
<div class="-group"> <div class="-group">
<input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/> <input type="text" class="form-control" id="paypar_account_no" name="customer[paypar_account_no]" readonly/>
<div class="input-group-addon"><span class="fa fa-credit-card"></span></div> <div class="input-group-addon"><span class="fa fa-credit-card"></span></div>
</div> </div>
@@ -201,7 +201,7 @@
<option value="<%= member.value %>"> <option value="<%= member.value %>">
<%= member.name %></option> <%= member.name %></option>
<%end %> <%end %>
</select> </select>
</div> </div>
</div> </div>
<div class="form-group"> <div class="form-group">
@@ -212,7 +212,7 @@
<button type="submit" class="btn btn-primary" id="submit_customer"><%= t("views.btn.submit") %></button> <button type="submit" class="btn btn-primary" id="submit_customer"><%= t("views.btn.submit") %></button>
<button type="submit" class="btn btn-info" disabled id="update_customer"><%= t("views.btn.update") %></button> <button type="submit" class="btn btn-info" disabled id="update_customer"><%= t("views.btn.update") %></button>
<button type="button" class="btn btn-danger" id="reset"><%= t("views.btn.reset") %></button> <button type="button" class="btn btn-danger" id="reset"><%= t("views.btn.reset") %></button>
</div> </div>
</div> </div>
</div> </div>
<div class="clearfix"></div> <div class="clearfix"></div>
@@ -259,7 +259,7 @@
console.log(paypar_account_no); console.log(paypar_account_no);
// Read Card Reader // Read Card Reader
$("#paypar_account_no").on('focus', function(e){ $("#paypar_account_no").on('focus', function(e){
if($(this).val() == ''){ if($(this).val() == ''){
$("#sxModal").show(); $("#sxModal").show();
getCardNo(); getCardNo();
@@ -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,9 +307,10 @@
} }
} }
} }
$("#sxModal").hide();
} }
$("#sxModal .btn_cancel").on('click',function(){ $("#sxModal .btn_cancel").on('click',function(){
$("#sxModal").hide(); $("#sxModal").hide();
}); });
</script> </script>

View File

@@ -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 = "";
@@ -236,88 +227,85 @@
/*customer UI tab btn*/ /*customer UI tab btn*/
$(document).on('click',".customer_tr",function(){ $(document).on('click',".customer_tr",function(){
// if(this.checked){ // if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true ); $(this).closest('tr').find('.checkbox_check').prop( "checked", true );
//$( "#checkbox_check" ).prop( "checked", true ); //$( "#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');
if(sale_id != 0){ if(sale_id != 0){
// var url = "/"+customer_id; // var url = "/"+customer_id;
update_sale(customer_id,sale_id); update_sale(customer_id,sale_id);
}else{ }else{
var url = "customers/" + customer_id + "/edit"; var url = "customers/" + customer_id + "/edit";
} }
$("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'}); $("#customer_tax_profiles").children().removeAttr("selected").css({'color':'#000','background':'none'});
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: url, url: url,
data: {}, data: {},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
// Selected for Taxes // Selected for Taxes
var taxes = JSON.stringify(data.tax_profiles); var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes); var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){ $.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'}); $("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected").css({'color':'#fff','background':'#215d9c'});
}); });
$('#customer_id').val(data.id); $('#customer_id').val(data.id);
$('#customer_name').val(data.name); $('#customer_name').val(data.name);
$('#customer_company').val(data.company); $('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no); $('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email); $('#customer_email').val(data.email);
$('#customer_salutation').val(data.salutation); $('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no); $('#customer_nrc_no').val(data.nrc_no);
$('#customer_card_no').val(data.card_no); $('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type); $('#customer_type').val(data.customer_type);
$('#paypar_account_no').val(data.paypar_account_no); $('#paypar_account_no').val(data.paypar_account_no);
$('#customer_address').val(data.address); $('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth); $('#customer_date_of_birth').val(data.date_of_birth);
if(data.image_path.url!=undefined && data.image_path.url!=null){ if(data.image_path.url!=undefined && data.image_path.url!=null){
$('.menu-item-img .img-thumbnail').attr('src',data.image_path.url); $('.menu-item-img .img-thumbnail').attr('src',data.image_path.url);
} }
$('#customer_membership_type').val(data.membership_type); $('#customer_membership_type').val(data.membership_type);
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected'); $('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
if (data.gender == 'Male') { if (data.gender == 'Male') {
$('.male').prop( "checked", true ) $('.male').prop( "checked", true )
}else{ }else{
$('.female').prop( "checked", true ) $('.female').prop( "checked", true )
} }
if(data.salutation == 'Mr') { if(data.salutation == 'Mr') {
$('.mr').prop( "checked", true ) $('.mr').prop( "checked", true )
}else if(data.salutation == 'Miss') { }else if(data.salutation == 'Miss') {
$('.miss').prop( "checked", true ) $('.miss').prop( "checked", true )
}else if(data.salutation == 'Mrs'){ }else if(data.salutation == 'Mrs'){
$('.mrs').prop( "checked", true ) $('.mrs').prop( "checked", true )
}else{ }else{
$('.mdm').prop( "checked", true ) $('.mdm').prop( "checked", true )
} }
$('.membership_authentication_code').val(data.membership_authentication_code); $('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val(''); $('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update'); $('#update_customer').attr('value', 'Update');
$('#submit_customer').attr('disabled','disabled'); $('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer'); $("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+customer_id; var id = "edit_customer_"+customer_id;
$("#new_customer").attr('id', id); $("#new_customer").attr('id', id);
$(".edit_customer").attr('id', id); $(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").html('<input type="hidden" name="_method" value="patch">'); $(".patch_method").html('<input type="hidden" name="_method" value="patch">');
//$(".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) {

View File

@@ -82,7 +82,7 @@
<td> <td>
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td> <input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td> <td>
<% if crm_customer.customer_id != "" && crm_customer.customer_id != "" %> <% if crm_customer.customer_id != "" && crm_customer.customer_id != "" %>
<%= @i += 1 %> <%= @i += 1 %>
<%else%> <%else%>
- -
@@ -354,12 +354,12 @@
</div> </div>
</div> </div>
</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">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button> <button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
</div> </div>
</div> </div>
</div> </div>
@@ -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');
@@ -474,29 +440,30 @@
/*customer UI tab btn*/ /*customer UI tab btn*/
function nextTab(elem) { function nextTab(elem) {
$(elem).parent().next().find('a[data-toggle="tab"]').click(); $(elem).parent().next().find('a[data-toggle="tab"]').click();
} }
function prevTab(elem) { function prevTab(elem) {
$(elem).parent().prev().find('a[data-toggle="tab"]').click(); $(elem).parent().prev().find('a[data-toggle="tab"]').click();
} }
/*customer UI tab btn*/ /*customer UI tab btn*/
// Read NFC card no from java // Read NFC card no from java
function getCardNo(){ function getCardNo(){
code2lab.readNFC(); if (typeof code2lab != 'undefined') {
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,47 +484,76 @@
} }
} }
} }
$("#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
$("#qr_code").on('click', function(e){ $("#qr_code").on('click', function(e){
var code = ""; var code = "";
var customer_id = ''; var customer_id = '';
var customer_name = ''; var customer_name = '';
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;
setTimeout(function(){ setTimeout(function(){
code=getQRCode(); code=getQRCode();
setQRCode(code); setQRCode(code);
}, 100); }, 100);
customer_mamber_card_no = $("#search").val(); customer_mamber_card_no = $("#search").val();
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+"/get_customer" , url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"}, data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
if (data[0].customer_id == false) { if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error"); swal("Alert!", data[0].message, "error");
// $.alert({ // $.alert({
// title: 'Alert!', // title: 'Alert!',
// content: data[0].message, // content: data[0].message,
// type: 'red', // type: 'red',
// typeAnimated: true, // typeAnimated: true,
// btnClass: 'btn-danger', // btnClass: 'btn-danger',
// }); // });
}else{ }else{
customer_id = data[0].customer_id; customer_id = data[0].customer_id;
customer_name = data[0].name; customer_name = data[0].name;
update_sale(customer_id, customer_name,sale_id); update_sale(customer_id, customer_name,sale_id);
}
} }
}); }
} });
}
}); });
// Read qrcode from java // Read qrcode from java
@@ -572,81 +568,75 @@
} }
$(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){
// var url = "/"+customer_id;
update_sale(customer_id, customer_name,sale_id);
}else{
var url = "customers/"+customer_id; if(sale_id != 0){
} update_sale(customer_id, customer_name,sale_id);
}else{
var url = "customers/"+customer_id;
}
// Need To Clean? // Need To Clean?
$.ajax({ $.ajax({
type: "GET", type: "GET",
url: url, url: url,
data: {}, data: {},
dataType: "json", dataType: "json",
success: function(data) { success: function(data) {
var taxes = JSON.stringify(data.tax_profiles); var taxes = JSON.stringify(data.tax_profiles);
var parse_taxes = JSON.parse(taxes); var parse_taxes = JSON.parse(taxes);
$.each(parse_taxes, function(i, value){ $.each(parse_taxes, function(i, value){
$("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected"); $("#customer_tax_profiles option[value='" + value + "']").attr("selected","selected");
}); });
$('#customer_id').val(data.id); $('#customer_id').val(data.id);
$('#customer_name').val(data.name); $('#customer_name').val(data.name);
$('#customer_company').val(data.company); $('#customer_company').val(data.company);
$('#customer_contact_no').val(data.contact_no); $('#customer_contact_no').val(data.contact_no);
$('#customer_email').val(data.email); $('#customer_email').val(data.email);
$('#customer_date_of_birth').val(data.date_of_birth); $('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type); $('#customer_membership_type').val(data.membership_type);
$('.select > option[value="'+data.membership_id+'"]').attr('selected','selected'); $('.select > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code); $('.membership_authentication_code').val(data.membership_authentication_code);
$('#customer_card_no').val(data.card_no); $('#customer_card_no').val(data.card_no);
$('#customer_type').val(data.customer_type); $('#customer_type').val(data.customer_type);
$('#customer_salutation').val(data.salutation); $('#customer_salutation').val(data.salutation);
$('#customer_nrc_no').val(data.nrc_no); $('#customer_nrc_no').val(data.nrc_no);
$('#paypar_account_no').val(data.paypar_account_no); $('#paypar_account_no').val(data.paypar_account_no);
if (data.gender == 'Male') { if (data.gender == 'Male') {
$('.male').prop( "checked", true ) $('.male').prop( "checked", true )
}else{ }else{
$('.female').prop( "checked", true ) $('.female').prop( "checked", true )
} }
if (data.salutation == 'Mr') { if (data.salutation == 'Mr') {
$('.mr').prop( "checked", true ) $('.mr').prop( "checked", true )
} else if(data.salutation == 'Miss') { } else if(data.salutation == 'Miss') {
$('.miss').prop( "checked", true ) $('.miss').prop( "checked", true )
}else if(data.salutation == 'Mrs'){ }else if(data.salutation == 'Mrs'){
$('.mrs').prop( "checked", true ) $('.mrs').prop( "checked", true )
}else{ }else{
$('.mdm').prop( "checked", true ) $('.mdm').prop( "checked", true )
} }
$('#update_customer').removeAttr('disabled').val(''); $('#update_customer').removeAttr('disabled').val('');
$('#update_customer').attr('value', 'Update'); $('#update_customer').attr('value', 'Update');
// $('#submit_customer').attr('disabled','disabled'); // $('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer'); $("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+$('#customer_id').val(); var id = "edit_customer_"+$('#customer_id').val();
$("#new_customer").attr('id', id); $("#new_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").append('<input type="hidden" name="_method" value="patch">'); $(".patch_method").append('<input type="hidden" name="_method" value="patch">');
//$(".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) {
var customer=""; var customer="";

View File

@@ -106,19 +106,14 @@
<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-Content"><h3>Card Tap</h3></div> <div id="sxModal">
<div class="m-r-20" align="right"> <div id="sxModal-Content"><h3>Card Tap</h3></div>
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button> <div class="m-r-20" align="right">
</div> <button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
</div> </div>
</div>
</div> </div>
<!-- customer light box --> <!-- customer light box -->
@@ -145,10 +140,10 @@
<div class="modal-footer"></div> <div class="modal-footer"></div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var cashier_type = "<%= @cashier_type %>"; var cashier_type = "<%= @cashier_type %>";
$(document).ready(function() { $(document).ready(function() {
setHeaderBreadCrumb(_DINGA_); setHeaderBreadCrumb(_DINGA_);
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){} if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
@@ -251,20 +246,35 @@
}); });
// Read Card Reader // Read Card Reader
$(".btn_member").on('click', function(){ $(".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").text() || 0;
var customer_mamber_card_no = 0;
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
getCardNo(); getCardNo();
customer_mamber_card_no = $("#paypar_account_no").val(); });
// 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 customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var receipt_no = $("#receipt_no").text() || 0;
var 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,74 +287,59 @@
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({
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";
});
$.ajax({ }else{
type: "POST", swal ( "Opps",result.message ,"warning" );
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{ }else{
swal ( "Opps",result.message ,"warning" ); 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";
});
}
}
});
} }
});
// 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
$(".btn_qr_code").on('click', function(e){ $(".btn_qr_code").on('click', function(e){
$("#is_memberModal").hide(); $("#is_memberModal").hide();
var code = ""; var code = "";
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 receipt_no = $("#receipt_no").text() || 0; var receipt_no = $("#receipt_no").text() || 0;
setTimeout(function(){ setTimeout(function(){
code=getQRCode(); code=getQRCode();
if(sale_id != 0 && code != ""){ if(sale_id != 0 && code != ""){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/origami/"+sale_id+"/send_account" , url: "/origami/"+sale_id+"/send_account" ,
@@ -392,15 +387,15 @@
}); });
} }
} }
}); });
} }
},100); },100);
}); });
// Read qrcode from java // Read qrcode from java
function getQRCode(){ function getQRCode(){
return code2lab.readQRCode(); return code2lab.readQRCode();
$("#qr_code").val(code); $("#qr_code").val(code);
} }
function update_sale(membership_id, customer_id, customer_name, sale_id) { function update_sale(membership_id, customer_id, customer_name, sale_id) {
@@ -435,7 +430,7 @@
location.reload(); location.reload();
} }
} }
}); });
}); });
} }

View File

@@ -110,11 +110,11 @@
</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">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button> <button type="button" class="btn btn-lg btn-link bg-red waves-effect btn_cancel">Cancel</button>
</div> </div>
</div> </div>
</div> </div>
<!-- customer light box --> <!-- customer light box -->
@@ -141,10 +141,10 @@
<div class="modal-footer"></div> <div class="modal-footer"></div>
</div> </div>
</div> </div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
var cashier_type = "<%= @cashier_type %>"; var cashier_type = "<%= @cashier_type %>";
$(document).ready(function() { $(document).ready(function() {
setHeaderBreadCrumb(_PAYMAL_); setHeaderBreadCrumb(_PAYMAL_);
if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){} if(localStorage.getItem("cash") == null || localStorage.getItem("cash") == 'null'){}
@@ -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",
@@ -274,73 +288,58 @@
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{ }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/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
$(".btn_qr_code").on('click', function(e){ $(".btn_qr_code").on('click', function(e){
$("#is_paymemberModal").hide(); $("#is_paymemberModal").hide();
var code = ""; var code = "";
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() || "";
var payment_amount = parseFloat($("#used_amount").text()); var payment_amount = parseFloat($("#used_amount").text());
setTimeout(function(){ setTimeout(function(){
code=getQRCode(); code=getQRCode();
if(sale_id != 0 && code != ""){ if(sale_id != 0 && code != ""){
$.ajax({ $.ajax({
type: "POST", type: "POST",
url: "/origami/"+sale_id+"/send_account" , url: "/origami/"+sale_id+"/send_account" ,
@@ -387,15 +386,15 @@
}); });
} }
} }
}); });
} }
},100); },100);
}); });
// Read qrcode from java // Read qrcode from java
function getQRCode(){ function getQRCode(){
return code2lab.readQRCode(); return code2lab.readQRCode();
$("#qr_code").val(code); $("#qr_code").val(code);
} }
$("#sxModal .btn_cancel").on('click',function(){ $("#sxModal .btn_cancel").on('click',function(){

View File

@@ -1109,21 +1109,42 @@ $(document).ready(function(){
// Read Card Reader // Read Card Reader
$(".btn_member").on('click', function(){ $(".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 customer_mamber_card_no = 0;
$("#is_memberModal").hide(); $("#is_memberModal").hide();
$("#sxModal").show(); $("#sxModal").show();
getCardNo(); 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(); $("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val(); }
function get_customer() {
var cardNo = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var 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();
} }
}); });
} }
});
// Read NFC card no from java
function getCardNo(){
if(typeof code2lab != 'undefined'){
code2lab.readNFC();
}
} }
// get CardNo from Java function send_account() {
function setCardNo(cardNo){ var cardNo = "";
$("#sxModal").hide(); var sale_id = $("#sale_id").text() || 0;
if(cardNo.length == 16){ var receipt_no = "";
$("#paypar_account_no").val(cardNo);
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";
});
}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";
});
} }
} }
@@ -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