add function for member card and qr code in payment

This commit is contained in:
phyusin
2018-03-08 14:57:45 +06:30
parent d9a7e341fa
commit 23be4771fd
9 changed files with 213 additions and 67 deletions

View File

@@ -34,12 +34,14 @@
<input type="text" name="filter" style="margin-right:10px" id="search" placeholder="Search" class="form-control input-sm col-md-12">
</div>
<div class="col-lg-2 col-md-2 col-sm-2 col-xs-12">
<button type="submit" class="btn bg-blue waves-effect waves-effect">Search</button>
</div>
<!-- <div class="col-lg-2 col-md-2 col-sm-2 col-xs-12"> -->
<button type="submit" class="btn bg-blue waves-effect waves-effect" style="height: 30%;margin-right: 10px;">Search</button>
<!-- </div> -->
<button type="button" id="member_acc_no" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;">Member Card</button>
<button type="button" id="qr_code" class="btn bg-green btn-sm waves-effect" style="height: 30%;margin-right: 10px;"><%= t("views.btn.qr_code") %></button>
</div>
<% end %>
</div>
@@ -114,6 +116,8 @@
<span class="patch_method"></span>
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<input type="hidden" id="type" name="type" value="<%= @cashier_type %>" />
<input type="hidden" id="page" name="page" value="<%= @page %>" />
<%if !@dining_facility.nil?%>
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
@@ -262,7 +266,8 @@
</div>
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
var cashier_type = "<%= @cashier_type %>";
var page = "<%= @page %>";
$(function() {
/*$('.datepicker').datepicker({
setDate: '12-12-1999',
@@ -295,22 +300,23 @@
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#search").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "get_customer" ,
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) {
$.alert({
title: 'Alert!',
content: data[0].message,
type: 'red',
typeAnimated: true,
btnClass: 'btn-danger',
});
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;
@@ -339,13 +345,33 @@
}
}
// QR Code Reader
$("#qr_code").on('click', function(e){
var code = "";
setTimeout(function(){
code=getQRCode();
setQRCode(code);
},100);
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
}
// get QRCode from Java
function setQRCode(code){
$("#qr_code").text(code);
$("#search").val(code);
}
$(document).on('click',".customer_tr",function(){
// if(this.checked){
$(this).closest('tr').find('.checkbox_check').prop( "checked", true );
var sale_id = $("#sale_id").val() || 0;
var customer_id = $(this).attr('data-ref');
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);
@@ -433,7 +459,7 @@
}, function () {
$.ajax({
type: "POST",
url: "update_sale" ,
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
@@ -442,12 +468,16 @@
var id = $("#table_id").val();
var type = $("#type").val();
if (cashier_type == "quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/customers/payment/';
}else{
if (type=="Table") {
window.location.href = '/origami/table/'+id
if(page == "payment"){
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/customers/payment/';
}else{
window.location.href = '/origami/room/'+id
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
}
}
}else{
@@ -460,17 +490,22 @@
}
$('#back').on('click',function(){
var id = $("#table_id").val()
var type = $("#type").val()
var sale_id = $("#sale_id").val()
var id = $("#table_id").val();
var type = $("#type").val();
var sale_id = $("#sale_id").val();
if (cashier_type == "quick_service") {
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if (type=="Table") {
window.location.href = '/origami/table/'+id
if(page == "payment"){
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
if (type=="Table") {
window.location.href = '/origami/table/'+id;
}else{
window.location.href = '/origami/room/'+id
}
window.location.href = '/origami/room/'+id;
}
}
}
})

View File

@@ -544,7 +544,7 @@
</div>
</div>
<script>
cashier_type = "cashier"
var cashier_type = "cashier";
$(document).ready(function () {
/* start check first bill or not*/
var receipt_no = "";
@@ -627,7 +627,7 @@
}
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers"
window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers/normal";
});

View File

@@ -33,7 +33,7 @@
</div>
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Customer :</strong> <%= @sale_data.customer.name%> <span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<div class="col-lg-6 col-md-6 col-sm-6"><strong>Customer :</strong> <span id="customer_name"> <%= @sale_data.customer.name%></span> <span class="hidden" id="membership_id"><%= @sale_data.customer.membership_id%></span>
<span class="hidden" id="member_discount"><%= @member_discount%></span></div>
<div class="col-lg-6 col-md-6 col-sm-6 text-left"><strong>Checkin Time : </strong> <%if !@checkin_time.nil?%><%= @checkin_time.utc.getlocal.strftime("%I:%M %p") %>
<%end%></div>
@@ -424,46 +424,50 @@
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="is_memberModalLabel">Is Member?</h4>
<h3 class="modal-title" id="is_memberModalLabel">Are you Member?</h3>
</div>
<div class="modal-body">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-4">
<button type="button" class="btn btn-link bg-green waves-effect">Yes</button>
<div class="row text-center">
<input type="hidden" name="paypar_account_no" id="paypar_account_no" />
<input type="hidden" name="qr_code" id="qr_code" />
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-green waves-effect btn_customer_yes">Yes</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-link bg-red waves-effect" data-dismiss="modal">No</button>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-red waves-effect" data-dismiss="modal">No</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-link bg-primary waves-effect">Member</button>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_member">Member</button>
</div>
<div class="col-md-4">
<button type="button" class="btn btn-link bg-primary waves-effect">QR</button>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<button type="button" class="btn btn-lg btn-link bg-primary waves-effect btn_qr_code">QR</button>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
</div>
<div id="sxModal">
<div id="sxModal-Content"><h3>Card Tap</h3></div>
</div>
<script type="text/javascript">
var cashier_type = "<%= @cashier_type %>";
var customer_id = "<%= @customer.id %>";
var customer_name = "<%= @customer.name %>";
$(document).ready(function(){
console.log(customer_name);
console.log(customer_id);
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
// $("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
// }
//start customer modal popup
if((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});
}
}
/* start check first bill or not*/
var member_id = $('#membership_id').text();
var member_discount = $('#member_discount').text();
@@ -970,4 +974,112 @@ var customer_name = "<%= @customer.name %>";
window.location.href = '/origami/quick_service';
}
});
$(".btn_customer_yes").on('click',function(){
var sale_id = $('#sale_id').text();
window.location.href = "/origami/"+sale_id+"/"+cashier_type+"/customers/payment";
});
// Read Card Reader
$(".btn_member").on('click', function(){
var cardNo = "";
var customer_id = '';
var customer_name = '';
var membership_id = '';
var membership_type = '';
var sale_id = $("#sale_id").text() || 0;
var customer_mamber_card_no = 0;
$("#is_memberModal").hide();
$("#sxModal").show();
setTimeout(function(){
getCardNo();
$("#sxModal").hide();
customer_mamber_card_no = $("#paypar_account_no").val();
if(sale_id != 0 && customer_mamber_card_no != 0){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/get_customer" ,
data: { filter : customer_mamber_card_no ,type :"card"},
dataType: "json",
success: function(data) {
if (data[0].customer_id == false) {
swal("Alert!", data[0].message, "error");
}else{
customer_id = data[0].customer_id;
customer_name = data[0].name;
membership_id = data[0].membership_id;
membership_type = data[0].membership_type;
update_sale(membership_id, customer_id, customer_name,sale_id);
}
}
});
}
},100);
});
// Read NFC card no from java
function getCardNo(){
code2lab.readNFC();
}
// get CardNo from Java
function setCardNo(cardNo){
if(cardNo.length == 16){
$("#paypar_account_no").val(cardNo);
}
}
// QR Code Reader
$(".btn_qr_code").on('click', function(e){
$("#is_memberModal").hide();
var code = "";
setTimeout(function(){
code=getQRCode();
$("#qr_code").val(code);
},100);
});
// Read qrcode from java
function getQRCode(){
return code2lab.readQRCode();
}
function update_sale(membership_id, customer_id, customer_name, sale_id) {
var customer="";
if(customer_name != ""){
customer = '(' + customer_name + ')';
}
swal({
title: "Confirmation !",
text: 'Are You Sure to assign this customer' + customer + '!',
showCancelButton: true,
confirmButtonColor: "green",
confirmButtonText: "Yes!",
cancelButtonClass: 'btn btn-danger',
closeOnConfirm: false,
}, function () {
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/"+cashier_type+"/customers/update_sale" ,
data: {customer_id:customer_id,sale_id:sale_id},
dataType: "json",
success: function(data) {
if(data.status == true)
{
//change customer detail
$("#customer_name").html(customer_name);
$("#membership_id").html(membership_id);
window.location.href = '/origami/sale/'+sale_id+'/'+cashier_type+'/payment/';
}else{
swal("Alert!", "Record not found!", "error");
location.reload();
}
}
});
});
}
</script>

View File

@@ -486,6 +486,7 @@
</div>
</div>
<script>
var cashier_type = "cashier";
$(document).ready(function(){
// $(".tables").on('click', function(){
// var customer_id=$(".customer-id").text();
@@ -593,7 +594,7 @@ $(document).ready(function(){
}
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/'+ sale_id + "/customers"
window.location.href = '/origami/' + sale_id+"/"+cashier_type + "/customers/normal";
});