print settings ActionCable

This commit is contained in:
Thein Lin Kyaw
2020-08-18 16:11:17 +06:30
parent 583d7ee473
commit 5dfdc7353e
25 changed files with 1050 additions and 802 deletions

View File

@@ -380,7 +380,7 @@
<% end %></strong><br>
<%if !@webview && @changable_tax %>
<% if @current_user.role == 'cashier' %>
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
<button class="btn btn-link waves-effect bg-info access_modal" data-type = 'change_tax' >Change Tax</button>
<% else %>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
<% end %>
@@ -597,6 +597,8 @@
</div>
</div>
<%= print_settings %>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
@@ -973,13 +975,15 @@
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,"");
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
}
location.reload();
location.reload();
}
});
}
@@ -1004,80 +1008,82 @@
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
var sale_id = $('#sale_id').val();
// type = $('.payment_method').val();
type = get_selected_attributes('selected-payment');
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
if(!location.pathname.includes("credit_payment")){
calculate_member_discount(sale_id,"Card",tax_type);
}
}else{
if(!location.pathname.includes("credit_payment")){
calculate_member_discount(sale_id,"Cash",tax_type);
if(parseInt(jQuery.inArray("Credit", type)) == -1){
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
if(!location.pathname.includes("credit_payment")){
calculate_member_discount(sale_id,"Card",tax_type);
}
}else{
if(!location.pathname.includes("credit_payment")){
calculate_member_discount(sale_id,"Cash",tax_type);
}
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
}
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
location.reload();
}
});
location.reload();
}
});
});
function calculate_member_discount(sale_id,type,tax_type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){
}
});
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
} else {
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card,'cashier_type':'cashier','tax_type':tax_type },
async: false,
success:function(result){
}
});
}
$('#pay').on('click', function () {
var sale_id = $('#sale_id').val();
var data_order = $(this).data("order");
if (data_order) {
swal({
title: "Alert! This Receipt has another item",
text: "Are you sure want to pay this receipt !",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, Pay it !",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
}
});
}else{
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
}
var sale_id = $('#sale_id').val();
var data_order = $(this).data("order");
if (data_order) {
swal({
title: "Alert! This Receipt has another item",
text: "Are you sure want to pay this receipt !",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, Pay it !",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
}
});
} else {
window.location.href = '/origami/sale/' + sale_id + "/cashier/payment";
}
});
// $('#kbz_query').on('click', function(){
@@ -1106,33 +1112,33 @@
var current_checkin_induties_count =localStorage.getItem("current_checkin_induties_count");
localStorage.removeItem("current_checkin_induties_count");
if(order_id!=undefined && order_id!=null && order_id!=""){
if($('#request_bills').is(":visible")) {
if ($('#request_bills').is(":visible")) {
$('#request_bills').prop("disabled",true);
}
$.ajax({
type: "GET",
url: ajax_url,
data: {current_checkin_induties_count: current_checkin_induties_count},
success: function (result) {
if (!result.status) {
swal({
title: 'Oops',
text: result.error_message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
location.reload();
}
});
}
else {
type: "GET",
url: ajax_url,
data: {current_checkin_induties_count: current_checkin_induties_count},
success: function (result) {
if (!result.status) {
swal({
title: 'Oops',
text: result.error_message,
type: 'error',
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function (isConfirm) {
if(isConfirm){
location.reload();
}
});
}
else {
location.reload();
}
}
});
}else{
swal("Opps","There is no orders!","warning");
@@ -1158,32 +1164,32 @@
})
$('#add_invoice').on('click', function () {
$("#first_bill").prop('disabled',true);
$("#pay").prop('disabled',true);
var dining_id = "<%= @dining.id %>";
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
var ajax_url = "/origami/sale/append_order";
// var tax_type = localStorage.getItem("tax_type");
var tax_type = $("#check_tax").val();
$.ajax({
type: "POST",
url: ajax_url,
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id + "&tax_type=" + tax_type,
success: function (result) {
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
$("#first_bill").removeAttr('disabled');
$("#pay").removeAttr('disabled');
window.location.reload();
});
}
});
$("#first_bill").prop('disabled',true);
$("#pay").prop('disabled',true);
var dining_id = "<%= @dining.id %>";
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
var ajax_url = "/origami/sale/append_order";
// var tax_type = localStorage.getItem("tax_type");
var tax_type = $("#check_tax").val();
$.ajax({
type: "POST",
url: ajax_url,
data: 'dining_id=' + dining_id + "&sale_id=" + sale_id + "&tax_type=" + tax_type,
success: function (result) {
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
$("#first_bill").removeAttr('disabled');
$("#pay").removeAttr('disabled');
window.location.reload();
});
}
});
})
//show cusotmer rebate amount
@@ -1267,13 +1273,15 @@
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
success: function (result) {
if (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
}
}
window.location.href = '/origami/';
window.location.href = '/origami/';
}
});
}
@@ -1376,13 +1384,15 @@
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function (result) {
console.log(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 (!$('#print_settings').data('action-cable')) {
// For Server Print - from jade
if ($("#server_mode").val() == "cloud") {
if(typeof code2lab != 'undefined'){
code2lab.printFile(result.filepath.substr(6), result.printer_url);
}
}
}
}
window.location.href = '/origami/';
window.location.href = '/origami/';
}
});
}