display qr code on second screen on qrpay
This commit is contained in:
1
Gemfile
1
Gemfile
@@ -144,3 +144,4 @@ gem 'select2-rails' # for multi-select and auto-complete select box
|
|||||||
gem "chartkick" #chart lib
|
gem "chartkick" #chart lib
|
||||||
gem 'myanmar-tools'
|
gem 'myanmar-tools'
|
||||||
gem 'rabbit-mm'
|
gem 'rabbit-mm'
|
||||||
|
gem 'rqrcode', '2.1.2'
|
||||||
|
|||||||
@@ -192,5 +192,9 @@ App.checkin = App.cable.subscriptions.create('SecondDisplayViewChannel', {
|
|||||||
$('#s_grand_total').empty();
|
$('#s_grand_total').empty();
|
||||||
$('#s_grand_total').append(fixed_grand_total);
|
$('#s_grand_total').append(fixed_grand_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (data.qr_svg) {
|
||||||
|
document.querySelector("#qrpay_svg").innerHTML = data.qr_svg;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
class Foodcourt::QrpayController < BaseFoodcourtController
|
class Foodcourt::QrpayController < BaseFoodcourtController
|
||||||
|
require 'rqrcode'
|
||||||
|
|
||||||
def init
|
def init
|
||||||
@cash_exist = PaymentMethodSetting.cash_exist
|
@cash_exist = PaymentMethodSetting.cash_exist
|
||||||
@credit_exist = PaymentMethodSetting.credit_exist
|
@credit_exist = PaymentMethodSetting.credit_exist
|
||||||
@@ -210,6 +212,34 @@ class Foodcourt::QrpayController < BaseFoodcourtController
|
|||||||
@giftvouchercount += spay.payment_amount
|
@giftvouchercount += spay.payment_amount
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
qr_str = "00020101021226480015com.mmqrpay.www0115223743000377032020600000052045814530310454075000.005802MM5908Code2LAB6006Yangon61051101062730125ORDER_1747826957_5ae9cb900523MMQR1075L175919500000010813PAY_BY_QRCODE64300002MY0109ကုဒ်တူလက်0207ရန်ကုန်6304AD40";
|
||||||
|
@string_to_encode = qr_str
|
||||||
|
|
||||||
|
qrcode = RQRCode::QRCode.new(@string_to_encode)
|
||||||
|
|
||||||
|
@qr_svg = qrcode.as_svg(
|
||||||
|
color: "000", # Hex color for the QR code modules (black)
|
||||||
|
shape_rendering: "crispEdges", # Renders sharp edges
|
||||||
|
module_size: 2, # Size of each module (dot/square)
|
||||||
|
standalone: true, # Outputs a complete SVG document
|
||||||
|
use_path: true # Modern SVG path rendering
|
||||||
|
)
|
||||||
|
|
||||||
|
png_data = qrcode.as_png(
|
||||||
|
bit_depth: 1,
|
||||||
|
border_modules: 4,
|
||||||
|
color_mode: ChunkyPNG::COLOR_GRAYSCALE,
|
||||||
|
color: 'black',
|
||||||
|
file: nil,
|
||||||
|
fill: 'white',
|
||||||
|
module_px_size: 8, # Pixel size of each module
|
||||||
|
resize_exactly_to: false,
|
||||||
|
resize_gte_to: false,
|
||||||
|
size: 240 # Approximate size of the image in pixels (e.g., 240x240)
|
||||||
|
).to_s
|
||||||
|
|
||||||
|
ActionCable.server.broadcast('second_display_view_channel', { data: qr_str, qr_svg: @qr_svg })
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ class KbzMerchant
|
|||||||
method: 'kbz.payment.precreate',
|
method: 'kbz.payment.precreate',
|
||||||
timestamp: Time.now.utc.to_i.to_s,
|
timestamp: Time.now.utc.to_i.to_s,
|
||||||
nonce_str: SecureRandom.hex(16),
|
nonce_str: SecureRandom.hex(16),
|
||||||
notify_url: @payment_method.notify_url,
|
notify_url: "http://localhost:3000/notify",
|
||||||
sign_type: 'SHA256',
|
sign_type: 'SHA256',
|
||||||
version: '1.0',
|
version: '1.0',
|
||||||
biz_content: {
|
biz_content: {
|
||||||
|
|||||||
@@ -800,6 +800,7 @@ $(document).on('click','#mmqr_btn', function(event){
|
|||||||
let table_id = $("#table_id").text();
|
let table_id = $("#table_id").text();
|
||||||
let booking_id = $("#booking_id").text();
|
let booking_id = $("#booking_id").text();
|
||||||
let customer_id = $("#customer_id").text();
|
let customer_id = $("#customer_id").text();
|
||||||
|
let second_display_lookup = $("#display_type").val();
|
||||||
|
|
||||||
|
|
||||||
let params = {
|
let params = {
|
||||||
@@ -823,7 +824,7 @@ $(document).on('click','#mmqr_btn', function(event){
|
|||||||
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init#`
|
window.location.href = `/foodcourt/${result.sale_id}/qrpay/init#`
|
||||||
// `/foodcourt/sale/${result.sale_id}/${cashier_type}/payment`;
|
// `/foodcourt/sale/${result.sale_id}/${cashier_type}/payment`;
|
||||||
if ($("#server_mode").val() != "cloud" && second_display_lookup == 2) {
|
if ($("#server_mode").val() != "cloud" && second_display_lookup == 2) {
|
||||||
customer_display_view(null, "reload");
|
// customer_display_view(null, "reload");
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
error: function (XMLHttpRequest, textStatus, errorThrown) {
|
||||||
@@ -902,6 +903,7 @@ function create_order(data,paymentMethod = "") {
|
|||||||
window.location.href = "/origami/room/" + table_id;
|
window.location.href = "/origami/room/" + table_id;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($("#server_mode").val() != "cloud" && second_display_lookup == 2) {
|
if ($("#server_mode").val() != "cloud" && second_display_lookup == 2) {
|
||||||
customer_display_view(null, "reload");
|
customer_display_view(null, "reload");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,4 +50,8 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="col-lg-6 col-md-6 col-sm-6 h-100">
|
||||||
|
<div id="qrpay_svg" style="background-color: #ddd;">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -148,7 +148,7 @@
|
|||||||
<%if current_login_employee.role =="cashier"%>
|
<%if current_login_employee.role =="cashier"%>
|
||||||
<li>
|
<li>
|
||||||
<p class="waves-effect waves-block p-l-30 m-b-5">
|
<p class="waves-effect waves-block p-l-30 m-b-5">
|
||||||
<a href="/origami/second_display" onclick="window.open('/origami/second_display', 'newwindow', 'width=700,height=500'); return false;" style="text-decoration: none;">
|
<a href="/origami/second_display" onclick="window.open('/foodcourt/second_display', 'newwindow', 'width=700,height=500'); return false;" style="text-decoration: none;">
|
||||||
<i class="material-icons font-7 logout_icon shopinfo">info</i>
|
<i class="material-icons font-7 logout_icon shopinfo">info</i>
|
||||||
<span class="font-15 shopinfo" >Second Display</span>
|
<span class="font-15 shopinfo" >Second Display</span>
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user