add printer brand and api and type
This commit is contained in:
@@ -79,7 +79,16 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
printer = Printer::ReceiptPrinter.new(print_settings)
|
||||
|
||||
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
filename, receipt_no, cashier_printer = printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
|
||||
|
||||
result = {
|
||||
:filepath => filename,
|
||||
:printer_model => print_settings.brand_name,
|
||||
:printer_url => print_settings.api_settings
|
||||
}
|
||||
|
||||
# Mobile Print
|
||||
render :json => result.to_json
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -64,6 +64,17 @@ class PrintSettingsController < ApplicationController
|
||||
end
|
||||
end
|
||||
|
||||
def get_printer_options
|
||||
printer_name = params[:printer_name]
|
||||
printer_options = Printer::PrinterWorker.printer_options(printer_name)
|
||||
options = {
|
||||
:url => printer_options['device-uri'],
|
||||
:model => printer_options['printer-info'],
|
||||
}
|
||||
|
||||
render :json => options.to_json
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_print_setting
|
||||
@@ -72,7 +83,7 @@ class PrintSettingsController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def print_setting_params
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
params.require(:print_setting).permit(:name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies,:precision,:delimiter,:heading_space)
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class PrintSetting < ApplicationRecord
|
||||
# validations
|
||||
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
|
||||
validates_presence_of :name, :unique_code, :printer_name, :brand_name, :api_settings, :page_width, :page_height, :print_copies
|
||||
|
||||
def self.get_precision_delimiter
|
||||
PrintSetting.find_by_unique_code("ReceiptBillPdf")
|
||||
|
||||
@@ -24,6 +24,11 @@ class Printer::PrinterWorker
|
||||
end
|
||||
end
|
||||
|
||||
# Options from printer name
|
||||
def self.printer_options(printer_name)
|
||||
Cups.options_for(printer_name)
|
||||
end
|
||||
|
||||
def self.printers()
|
||||
Cups.show_destinations
|
||||
end
|
||||
|
||||
@@ -176,7 +176,7 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
|
||||
#Use CUPS service
|
||||
#Generate PDF
|
||||
#Print
|
||||
#Print
|
||||
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
|
||||
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
|
||||
if !receipt_bill_a5_pdf.empty?
|
||||
@@ -202,14 +202,14 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
|
||||
|
||||
begin
|
||||
if count == 1
|
||||
filename = "/receipts/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf"
|
||||
pdf.render_file filename
|
||||
if printed_status != 'Paid'
|
||||
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
else
|
||||
filename = "/receipts/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
pdf.render_file directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
filename = directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf"
|
||||
pdf.render_file filename
|
||||
if printed_status != 'Paid'
|
||||
self.print(directory_name + "/receipt_bill_#{sale_data.receipt_no}_#{count}.pdf", cashier_terminal.printer_name)
|
||||
end
|
||||
|
||||
@@ -23,7 +23,7 @@ class ReceiptBillPdf < Prawn::Document
|
||||
# @double = @qty_width * 1.3
|
||||
# @half_qty = @qty_width / 2
|
||||
#setting page margin and width
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin])
|
||||
super(:margin => [printer_settings.heading_space, self.margin, self.margin, self.margin], :page_size => [self.page_width, self.page_height])
|
||||
|
||||
#precision checked
|
||||
if printer_settings.precision.to_i > 2
|
||||
@@ -121,15 +121,8 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
move_down line_move
|
||||
|
||||
y_position = cursor
|
||||
if sale_data.bookings[0].dining_facility_id.to_i > 0
|
||||
bounding_box([0,y_position], :width => self.label_width, :height => self.item_height) do
|
||||
text "#{ sale_data.bookings[0].dining_facility.type } - #{ sale_data.bookings[0].dining_facility.name }" , :size => self.item_font_size,:align => :left
|
||||
end
|
||||
end
|
||||
|
||||
bounding_box([self.label_width, y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
bounding_box([0, y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
text "W: #{sale_data.requested_by}" , :size => self.item_font_size, :align => :left
|
||||
end
|
||||
bounding_box([self.label_width - 2,y_position], :width =>self.label_width, :height => self.item_height) do
|
||||
@@ -493,8 +486,8 @@ class ReceiptBillPdf < Prawn::Document
|
||||
end
|
||||
|
||||
#individual payment per person
|
||||
def individual_payment(sale_data, precision, delimiter)
|
||||
per_person = sale_data.grand_total.to_i / sale_data.equal_persons.to_i
|
||||
def individual_payment(sale_data, survey, precision, delimiter)
|
||||
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
|
||||
stroke_horizontal_rule
|
||||
move_down line_move
|
||||
y_position = cursor
|
||||
|
||||
@@ -689,7 +689,9 @@
|
||||
receipt_no = ($("#receipt_no").html()).trim();
|
||||
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||
createReceiptNoInFirstBillData(receipt_no,"");
|
||||
|
||||
|
||||
// console.log(result);
|
||||
code2lab.printBill(result.filepath, result.printer_model, result.printer_url);
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
<%= f.input :template %>
|
||||
<%= f.input :font %>
|
||||
<%= f.input :printer_name, :as => :select, :collection => Printer::PrinterWorker.printers, include_blank: false %>
|
||||
<%= f.input :brand_name %>
|
||||
<%= f.input :printer_type %>
|
||||
<%= f.input :api_settings %>
|
||||
<%= f.input :page_width %>
|
||||
<%= f.input :page_height %>
|
||||
@@ -61,6 +63,22 @@
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
|
||||
// if selected printer change call and bind
|
||||
$("#print_setting_printer_name").on("change", function(){
|
||||
var printer_name = $(this).val();
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "/get_printer_options/"+printer_name,
|
||||
success:function(result){
|
||||
$("#print_setting_brand_name").val(result.model);
|
||||
$("#print_setting_api_settings").val(result.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
function isNumberKey(evt) {
|
||||
var charCode = (evt.which) ? evt.which : event.keyCode;
|
||||
if (charCode != 46 && charCode > 31 && (charCode < 48 || charCode > 57)) {
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
json.extract! print_setting, :id, :name, :unique_code, :template, :printer_name, :font, :api_settings, :page_width, :page_height, :print_copies, :created_at, :updated_at
|
||||
json.extract! print_setting, :id, :name, :unique_code, :template, :printer_name, :brand_name, :printer_type, :font, :api_settings, :page_width, :page_height, :print_copies, :created_at, :updated_at
|
||||
json.url print_setting_url(print_setting, format: :json)
|
||||
|
||||
@@ -30,6 +30,14 @@
|
||||
<th><%= t("views.right_panel.detail.printer_name") %></th>
|
||||
<td><%= @print_setting.printer_name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.brand_name") %></th>
|
||||
<td><%= @print_setting.brand_name %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.printer_type") %></th>
|
||||
<td><%= @print_setting.printer_type %></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th><%= t("views.right_panel.detail.font") %></th>
|
||||
<td><%= @print_setting.font rescue '-' %></td>
|
||||
|
||||
@@ -434,6 +434,8 @@ scope "(:locale)", locale: /en|mm/ do
|
||||
|
||||
#----------- Print Setup --------#
|
||||
resources :print_settings
|
||||
get '/get_printer_options/:printer_name' => 'print_settings#get_printer_options'
|
||||
|
||||
resources :commissioners
|
||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||
end
|
||||
|
||||
@@ -8,7 +8,7 @@ class CreatePrintSettings < ActiveRecord::Migration[5.1]
|
||||
t.string :printer_name, :null => false
|
||||
t.string :api_settings
|
||||
t.string :brand_name
|
||||
t.string :type
|
||||
t.string :printer_type
|
||||
t.decimal :page_width, :null => false, :default => 210
|
||||
t.decimal :page_height, :null => false, :default => 1450
|
||||
t.integer :print_copies, :null => false, :default => 1
|
||||
|
||||
Reference in New Issue
Block a user