food court and Booking ID for order and receipt

This commit is contained in:
phyusin
2018-10-08 17:41:22 +06:30
parent 5535a5db81
commit 03fd7c79b8
44 changed files with 1155 additions and 378 deletions

View File

@@ -35,7 +35,7 @@
<div class="row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
<strong>Customer :</strong>
<% if @cashier_type == 'quick_service' %>
<% 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>
<% else %>
<span id="customer_name"><%= @sale_data.customer.name%></span>
@@ -193,7 +193,7 @@
<%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>
</div>
</div>
<% if @sale_payment.nil? %>
<% if @sale_payment.nil? && @cashier_type != "food_court" %>
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
<div class="col-md-8">Credit</div>
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
@@ -209,7 +209,7 @@
</div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="other_payment_amount">
<%= number_with_precision(@other_payment, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %>
@@ -432,7 +432,7 @@
<% end %>
<% end %>
<% if @cashier_type=="quick_service" && @sale_payment.nil? %>
<% if (@cashier_type=="quick_service" || @cashier_type=="food_court") && @sale_payment.nil? %>
<hr>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
@@ -669,6 +669,32 @@
</div>
</div>
<!-- customer light box -->
<div class="modal fade" id="is_paymemberModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="is_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">
<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 waves-effect btn_paymal_member">Card Member</button>
</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 waves-effect btn_paymal_qr_code">QR Code</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";
@@ -681,6 +707,9 @@ var pdf_view = '<%=@pdf_view%>';
var trans_flag = <%= @trans_flag %>;
// console.log(pdf_view)
$(document).ready(function(){
<%if @cashier_type == "food_court" && @paymalcount == 0.0 %>
$("#is_paymemberModal").modal({show : true, backdrop : false, keyboard : false});
<% end %>
setHeaderBreadCrumb(_PAYMENTS_);
/* replace url type*/
@@ -743,7 +772,7 @@ var trans_flag = <%= @trans_flag %>;
if (cashier_type=="cashier") {
window.location.href = '/origami/table/'+ dining_id;
}else{
window.location.href = '/origami/quick_service/pending_order/'+sale_id;
window.location.href = '/origami/'+cashier_type+'/pending_order/'+sale_id;
}
}
@@ -775,124 +804,130 @@ var trans_flag = <%= @trans_flag %>;
if(location.pathname.includes("credit_payment")){
url_param = "credit_payment";
}
window.location.href = '/origami/sale/'+ sale_id + "/"+cashier_type+"/"+url_param+"/others_payment";
return false;
if(cashier_type != "food_court"){
window.location.href = '/origami/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});
<% end %>
}
});
$('#pay').click(function() {
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
// console.log(member)
if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) {
swal("Oops","Please Pay with MPU Payment","warning");
}else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(parseInt(jQuery.inArray("VISA", payment_type)) != -1 && $('#visacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Visa Payment","warning");
}else if(parseInt(jQuery.inArray("JCB", payment_type)) != -1 && $('#jcbcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(parseInt(jQuery.inArray("Master", payment_type)) != -1 && $('#mastercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Alipay Payment","warning");
}
else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Credit Payment","warning");
}else if(parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 && $('#paymalcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Paymal Payment","warning");
}else if(parseInt(jQuery.inArray("DINGA", payment_type)) != -1 && $('#dingacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Dinga Payment","warning");
}else if(parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1 && $('#giftvouchercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Gift Voucher","warning");
}else{
$( "#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 tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
calculate_member_discount(sale_id,tax_type);
}
// $("#pdfModal").on('shown.bs.modal', function () {
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
/* check credit payment or not*/
if(location.pathname.includes("credit_payment")){
var url = "<%= origami_credit_payment_cash_path %>";
}else{
var url = "<%= origami_payment_cash_path %>";
}
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
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();
}
}
}
});
}
if (parseInt(jQuery.inArray("MPU", payment_type)) != -1 && $('.mpu').text() == 0 && sub_total != 0.0 && member) {
swal("Oops","Please Pay with MPU Payment","warning");
}else if(parseInt(jQuery.inArray("Redeem", payment_type)) != -1 && $('#ppamount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(parseInt(jQuery.inArray("VISA", payment_type)) != -1 && $('#visacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Visa Payment","warning");
}else if(parseInt(jQuery.inArray("JCB", payment_type)) != -1 && $('#jcbcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(parseInt(jQuery.inArray("Master", payment_type)) != -1 && $('#mastercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(parseInt(jQuery.inArray("Alipay", payment_type)) != -1 && $('#alipaycount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Alipay Payment","warning");
}
else if(parseInt(jQuery.inArray("JUNCTIONPAY", payment_type)) != -1 && $('#junctionpaycount').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with JUNCTIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Credit Payment","warning");
}else if(parseInt(jQuery.inArray("PAYMAL", payment_type)) != -1 && $('#paymalcount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Paymal Payment","warning");
}else if(parseInt(jQuery.inArray("DINGA", payment_type)) != -1 && $('#dingacount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Dinga Payment","warning");
}else if(parseInt(jQuery.inArray("GiftVoucher", payment_type)) != -1 && $('#giftvouchercount').text()== 0 && sub_total != 0.0 && member){
swal("Oops","Please Pay with Gift Voucher","warning");
}else{
$( "#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 tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if (credit <= 0 && (!location.pathname.includes("credit_payment"))) {
calculate_member_discount(sale_id,tax_type);
}
// $("#pdfModal").on('shown.bs.modal', function () {
// $('#pdfModal').focus() }).modal({show : true, backdrop : false, keyboard : false});
/* check credit payment or not*/
if(location.pathname.includes("credit_payment")){
var url = "<%= origami_credit_payment_cash_path %>";
}else{
var url = "<%= origami_payment_cash_path %>";
}
$.ajax({type: "POST",
url: url,
data: "cash="+ cash + "&sale_id=" + sale_id + "&type=" + cashier_type + "&tax_type=" + tax_type,
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();
}
}
}
});
}
}
});
// $('#void').on('click',function () {
@@ -1160,8 +1195,10 @@ var trans_flag = <%= @trans_flag %>;
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
window.location.href = '/origami/'+cashier_type;
if (cashier_type=="quick_service"){
customer_display_view(null,"reload");
}
}
}
}else{
@@ -1195,10 +1232,12 @@ var trans_flag = <%= @trans_flag %>;
}else{
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
}
}else {
window.location.href = '/origami/'+cashier_type;
if(cashier_type=="quick_service"){
customer_display_view(null,"reload");
}
}
}
});
}
@@ -1213,7 +1252,7 @@ var trans_flag = <%= @trans_flag %>;
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
window.location.href = '/origami/'+cashier_type;
}
}
@@ -1452,7 +1491,7 @@ var trans_flag = <%= @trans_flag %>;
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
window.location.href = '/origami/'+cashier_type;
}
}
});
@@ -1497,7 +1536,7 @@ var trans_flag = <%= @trans_flag %>;
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
window.location.href = '/origami/'+cashier_type;
}
}
}
@@ -1539,8 +1578,10 @@ var trans_flag = <%= @trans_flag %>;
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
customer_display_view(null,"reload");
window.location.href = '/origami/'+cashier_type;
if(cashier_type=="quick_service"){
customer_display_view(null,"reload");
}
}
}
}
@@ -1611,10 +1652,178 @@ var trans_flag = <%= @trans_flag %>;
/* customer light-box */
$("#customer_name").on("click",function(){
//start customer modal popup
if((cashier_type=='quick_service') && (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!="")){
// if((customer_id == 'CUS-000000000001') && (customer_name == 'WALK-IN')){
$("#is_memberModal").modal({show : true, backdrop: false, keyboard : false});
// }
}
});
// Read Card Reader
$(".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();
$("#sxModal").show();
setTimeout(function(){
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";
});
}
},100);
});
// QR Code Reader
$(".btn_paymal_qr_code").on('click', function(e){
$("#is_paymemberModal").hide();
var code = "";
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());
setTimeout(function(){
code=getQRCode();
if(sale_id != 0 && code != ""){
$.ajax({
type: "POST",
url: "/origami/"+sale_id+"/send_account" ,
data: { account_no : code, 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:code},
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: 'Please Check Member',
type: 'warning',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/origami/sale/'+ sale_id +"/"+cashier_type + "/payment";
});
}
}
});
}
},100);
});
</script>