add customer at first

This commit is contained in:
yarzar_code
2020-08-07 18:36:06 +06:30
parent 82925881f7
commit b24e34534c
10 changed files with 376 additions and 483 deletions

View File

@@ -37,7 +37,9 @@
<strong>Customer :</strong>
<% if @cashier_type == 'quick_service' || @cashier_type == 'food_court' %>
<button type="button" class="btn bg-info waves-effect" id='customer_name'><%= @sale_data.customer.name%></button>
<input type="hidden" name="paypar_account_no" id="paypar_account_no" value='<%=@sale_data.customer.paypar_account_no%>' />
<% else %>
<input type="hidden" name="paypar_account_no" id="paypar_account_no" value='<%=@sale_data.customer.paypar_account_no%>' />
<span id="customer_name"><%= @sale_data.customer.name%></span>
<% end %>
<span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
@@ -281,35 +283,6 @@
</div>
</div>
<!-- pdf light box -->
<div class="modal fade" id="pdfModal" tabindex="-1" role="dialog" >
<div class="modal-dialog modal-md " role="document">
<div class="modal-content">
<div class="modal-header">
<h6 class="modal-title">
<span id="pdfModalLabel"></span>
<span id="changed_amount" class="p-l-120"></span>
</h6>
</div>
<div class="modal-body" style="height: 400px;">
<input type="hidden" name="sale_receipt_no" id="sale_receipt_no">
<input type="hidden" name="filename" id="filename">
<input type="hidden" name="printer_name" id="printer_name">
<div class="text-center">
<iframe id="receipt_pdf" src="" class="pdf-iframe" scrolling="no"></iframe>
</div>
</div>
<div class="modal-footer">
<button type="button" class="mr-2 m-t-5 btn-lg btn-block bg-red waves-effect print_receipt" id="print_receipt"> Print
</button>
<button type="button" class="btn-lg btn-block bg-blue waves-effect btn_pdf_close" data-dismiss="modal">
CLOSE
</button>
</div>
</div>
</div>
</div>
<!-- customer light box -->
<div class="modal fade" id="is_memberModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
@@ -318,7 +291,6 @@
<h1 class="modal-title" id="is_memberModalLabel">Are you Member?</h1>
</div>
<div class="modal-body">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="row text-center m-t-20">
<% if !@customer_lists.nil? %>
@@ -453,29 +425,6 @@
</div>
</div>
<!-- customer light box -->
<div class="modal fade m-t-40" 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_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" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="row text-center m-t-20" align="center">
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3"></div>
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<button type="button" class="btn btn-lg btn-link bg-primary btn_paymal_member">Card</button>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<script type="text/javascript">
// //control borwser back
window.location.hash="no-back-button";
@@ -489,8 +438,8 @@ var trans_flag = <%= @trans_flag %>;
var paymalcount = <%= @paymalcount %>;
// console.log(pdf_view)
$(document).ready(function(){
localStorage.removeItem('sale_id')
$("#sxModal").hide();
/* replace url type*/
if(!trans_flag){
localStorage.setItem("trans_flag", trans_flag);
@@ -542,105 +491,6 @@ $(document).ready(function(){
// Disable click event cash to prevent
$(".payment .cash-color").off('click');
$('#card_payment').click(function() {
localStorage.setItem("cash",$('#cash').text() );
var sale_id = $('#sale_id').text();
var url_param = "payment";
if(location.pathname.includes("credit_payment")){
url_param = "credit_payment";
}
if(cashier_type != "food_court"){
window.location.href = '/foodcourt/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
return false;
}else{
if(paymalcount == 0.0){
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
}
}
});
$('#pay').click(function() {
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
$( "#loading_wrapper").show();
if($('#balance').text() > 0){
swal ( "Oops", "Insufficient Amount!" , "error" );
$("#loading_wrapper").hide();
}else{
$(this).off("click");
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
if (result.status) {
var msg = result.message;
}
else{
var msg = '';
}
$("#loading_wrapper" ).hide();
if(location.pathname.includes("credit_payment")){
payment_success_alert();
}else{
//PDF lightbox data
var pdfPath = "/en/pdfjs/minimal?file=" + result.filename.substring(6);
$("#sale_receipt_no").val(result.receipt_no);
$("#filename").val(result.filename);
$("#printer_name").val(result.printer_name);
$("#receipt_pdf").attr("src", pdfPath);
$("#changed_amount").text("");
if($('#balance').text() < 0){
<% if precision.to_i > 0 %>
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)).toFixed(<%= precision %>));
<% else %>
$("#changed_amount").text('Changed amount ' + parseFloat($('#balance').text() * (-1)));
<% end %>
}
if (pdf_view == 1) {
$("#pdfModal").modal({show : true, backdrop : false, keyboard : false});
$("#pdfModalLabel").text("Sale Completed");
}else{
//PDF lightbox data
print_receipt();
}
}
}
});
}
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
window.customer_display_view = function(data,status) {
url = '/foodcourt/customer_view';
$.ajax({
@@ -842,6 +692,7 @@ $(document).ready(function(){
}
function calculate_member_discount(sale_id,tax_type) {
alert('function called')
var sub_total = $('#sub-total').text();
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
@@ -862,101 +713,6 @@ $(document).ready(function(){
});
}
}
//print pdf function
// $(".print_receipt").on('click',function(){
$("#print_receipt").on('click touchstart', function(event){
$(this).off("click touchstart touchend");
print_receipt();
});
function print_receipt() {
if($('#pay').is(":visible")) {
$('#pay').prop("disabled",true);
}
var sale_id = $('#sale_id').text();
var filename = $("#filename").val();
var printer_name = $("#printer_name").val();
var receipt_no = $("#sale_receipt_no").val();
var params = { 'filename':filename, 'receipt_no':receipt_no, 'printer_name':printer_name };
$.ajax({
type: "POST",
url: "/foodcourt/sale/"+sale_id+"/"+cashier_type+"/payment/print",
data: params,
success:function(result){
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
if (pdf_view ==1) {
var flag = localStorage.getItem("trans_flag");
localStorage.removeItem("trans_flag");
if((flag!=null) && (flag != "true")){
window.location.href = "/transactions/sales/"+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/foodcourt';
}else{
window.location.href = '/foodcourt/'+cashier_type;
customer_display_view(null,"reload");
}
}
}else{
payment_success_alert();
}
}
});
}
function payment_success_alert(){
var title = "Payment Successful!";
if($('#balance').text() < 0){
var text = 'Changed amount ' + $('#balance').text() * (-1);
}else{
$('#pay').text("Pay");
var text = 'Thank You !';
}
var sale_id = $('#sale_id').text();
swal({
title: "Payment Successful!",
text: text,
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
var flag = localStorage.getItem("trans_flag");
localStorage.removeItem("trans_flag");
customer_display_view(null,"reload");
if((flag!=null) && (flag != "true")){
window.location.href = '/transactions/sales/'+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/foodcourt';
}else {
window.location.href = '/foodcourt/'+cashier_type;
}
}
});
}
$(".btn_pdf_close").on('click',function(){
var flag = localStorage.getItem("trans_flag");
if((flag!=null) && (flag != "true")){
var sale_id = $('#sale_id').text();
window.location.href = "/transactions/sales/"+sale_id;
}else{
if (cashier_type=="cashier") {
window.location.href = '/foodcourt';
}else{
window.location.href = '/foodcourt/'+cashier_type;
}
}
});
$(".btn_customer_yes").on('click',function(){
var sale_id = $('#sale_id').text();
@@ -980,125 +736,122 @@ $(document).ready(function(){
var customer_mamber_card_no = 0;
var payment_amount = parseFloat($("#grand_total").text());
customer_mamber_card_no = cardNo;
if (customer_mamber_card_no == 0) {
customer_mamber_card_no = $("#membership_id").text() || 0;
}
if(sale_id != 0 && customer_mamber_card_no !=0){
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+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: "<%=foodcourt_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,
type: 'success',
html: true,
closeOnConfirm: true,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
$('.confirm').attr("disabled","disabled");
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
$("#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){
$("#loading_wrapper").show();
$.ajax({
type: "POST",
url: "/foodcourt/"+sale_id+"/send_account" ,
data: { account_no : customer_mamber_card_no, amount : payment_amount, receipt_no : receipt_no},
dataType: "json",
success: function(data) {
$("#loading_wrapper").hide();
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: "<%=foodcourt_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,
type: 'success',
html: true,
closeOnConfirm: true,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
$('.confirm').attr("disabled","disabled");
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').text();
// var item_row = $('.is_card');
// payment
var cash = $('#cash').text();
var credit = $('#credit').text();
var card = $('#card').text();
var kbz_amt = "<%= @kbz_pay_amount %>";
var is_kbz = false;
if (kbz_amt > 0) {
is_kbz = true
}
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
window.location.href = "<%= foodcourt_food_court_path %>";
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
// calculate_member_discount(sale_id,tax_type);
/* check credit payment or not*/
var url = "<%= foodcourt_payment_cash_path %>";
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type + "&is_kbz=" + is_kbz+"&account_no="+customer_mamber_card_no,
success:function(result){
/* start delete receipt no in first bill*/
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
var receipt_no = ($("#receipt_no").html()).trim();
deleteReceiptNoInFirstBillData(receipt_no);
}
});
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
/* end delete receipt no in first bill*/
localStorage.removeItem("cash");
window.location.href = "<%= foodcourt_food_court_path %>";
}
});
var second_display_lookup = $("#display_type").val();
if ($('#server_mode').val() != "cloud" && second_display_lookup == 2){
customer_display_view(null,"reload");
}
});
}else{
swal({
title: 'Oops',
text: result.message,
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}else{
swal({
title: 'Oops',
text: data.message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/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 = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
$("#loading_wrapper").hide();
}
});
}else{
swal({
title: 'Oops',
text: data.message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/foodcourt/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 = '/foodcourt/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 = '/foodcourt/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
function member_card(cardNo) {
@@ -1447,19 +1200,16 @@ $(document).ready(function(){
$("#customer_name").on("click",function(){
//start customer modal popup
if((cashier_type=='quick_service' || cashier_type=='food_court') && (customer_id!=undefined) && (customer_id!=null) && (customer_id!="")){
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
// }
$("#sxModal").attr('data-for', 'member');
$("#sxModal").show();
getCardNo();
}
});
// Read Card Reader - Paymal payment for FoodCourt
$(".btn_paymal_member").on('click', function (){
console.log('btn_paymal_member');
$("#is_paymemberModal").hide();
$("#sxModal").attr('data-for', 'payment');
$("#sxModal").show();
getCardNo();
$(this).off('click');
pay_with_card($("#paypar_account_no").val())
});
// QR Code Reader