Files
openfoodnetwork/app/views/spree/admin/orders/ticket.html.haml
Pierre de Lacroix 70707969f3 Add Qz integration
2017-03-15 15:06:28 +11:00

80 lines
2.9 KiB
Plaintext

!!! Basic
%html
%head
<meta content="text/html;charset=ansi" http-equiv="Content-Type">
= javascript_include_tag "shared/jquery-1.8.0.js"
= javascript_include_tag "qz/qz-tray.js"
= javascript_include_tag "qz/sha-256.min.js"
= javascript_include_tag "qz/rsvp-3.1.0.min.js"
= javascript_include_tag "qz/jsrsasign-latest-all-min.js"
:javascript
var printData = [
'\x1B' + '\x40', // init
'\x1B' + '\x74' + '\x10',
'\x1B' + '\x61' + '\x31', // center align
'\x1B' + '\x21' + '\x30', // em mode on
'#{@order.distributor.name}' + '\x0A',
'\x1B' + '\x21' + '\x0A' + '\x1B' + '\x45' + '\x0A', // em mode off
'\x0A',
'#{@order.distributor.address.address_part1}' + '\x0A', // text and line break
'#{@order.distributor.address.address_part2}' + '\x0A',
'#{@order.distributor.email}' + '\x0A',
'\x0A', // line break
'\x1B' + '\x61' + '\x32', // right align
'#{l Time.zone.now.to_date}' + '\x0A',
'#{@order.number}' + '\x0A',
'\x1B' + '\x61' + '\x30', // left align
'\x0A',
'\x1B' + '\x4D' + '\x31', // small text
"#{'%6s %-23s%12s%12s' %
[t(:ticket_column_qty),
t(:ticket_column_item),
t(:ticket_column_unit_price),
t(:ticket_column_total_price)]}",
'\x0A',
'\x1B' + '\x4D' + '\x30', // normal text
'__________________________________________' + '\x0A',
"#{@order.line_items
.sort_by{ |line_item| line_item.product.name }
.map { |line_item| '%5d %-19.19s%8.8s%8.8s' %
[line_item.quantity,
line_item.product.name,
line_item.single_display_amount_with_adjustments.money.format(symbol: false),
line_item.display_amount_with_adjustments.money.format(symbol: false)] }
.join('" + \'\x0A\' + "')}",
'\x0A',
"#{checkout_adjustments_for(@order, exclude: [:line_item])
.reject{ |a| a.amount == 0 }
.reverse.map { |adjustment| '%5s %-27.27s%8.8s' %
["",
raw(adjustment.label),
display_adjustment_amount(adjustment).money.format(symbol: false)] }
.join('" + \'\x0A\' + "')}",
'\x0A',
'__________________________________________' + '\x0A',
'\x0A',
'\x1B' + '\x45' + '\x0D', // bold on
"#{'%31s%10s' %
[t(:total_incl_tax),
@order.display_total]}",
'\x1B' + '\x45' + '\x0A', // bold off
'\x0A',
"#{display_checkout_taxes_hash(@order).map { |tax_rate, tax_value|
'%31s%10s' %
[t(:tax_total, rate: tax_rate),
tax_value] }
.join('" + \'\x0A\' + "')}",
'\x0A',
"#{'%31s%10s' %
[t(:total_excl_tax),
display_checkout_total_less_tax(@order)]}",
'\x0A',
'\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A' + '\x0A',
'\x1B' + '\x69', // cut paper
];
= javascript_include_tag "qz/ticket-popup.js"
%body
%div#printer-list