oxen_printer 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +15 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +31 -0
- data/Rakefile +8 -0
- data/app/controllers/oxen/print_jobs_controller.rb +10 -0
- data/app/controllers/oxen/printers_controller.rb +33 -0
- data/app/jobs/background_printer_job.rb +14 -0
- data/app/models/ox_print_job.rb +47 -0
- data/app/models/ox_printable.rb +17 -0
- data/app/models/ox_printer.rb +36 -0
- data/app/policies/oxen/print_job_policy.rb +51 -0
- data/app/views/oxen/print_jobs/_form.html.haml +45 -0
- data/app/views/oxen/print_jobs/_print_job.html.haml +3 -0
- data/app/views/oxen/print_jobs/_print_jobs.html.haml +11 -0
- data/app/views/oxen/print_jobs/_printer_print_job.html.haml +12 -0
- data/app/views/oxen/print_jobs/_printer_print_jobs.html.haml +11 -0
- data/app/views/oxen/print_jobs/_show.html.haml +0 -0
- data/app/views/oxen/printers/_account_printer.html.haml +11 -0
- data/app/views/oxen/printers/_account_printers.html.haml +14 -0
- data/app/views/oxen/printers/_form.html.haml +31 -0
- data/app/views/oxen/printers/_new.html.haml +68 -0
- data/app/views/oxen/printers/_printer.html.haml +3 -0
- data/app/views/oxen/printers/_printers.html.haml +11 -0
- data/app/views/oxen/printers/_user_printer.html.haml +18 -0
- data/app/views/oxen/printers/_user_printers.html.haml +14 -0
- data/app/views/oxen/printers/create.html.haml +5 -0
- data/bin/rails +12 -0
- data/config/locales/da.yml +7 -0
- data/config/routes.rb +47 -0
- data/lib/action_printer.rb +90 -0
- data/lib/c4_label_print_provider.rb +215 -0
- data/lib/generators/printer/install_generator.rb +14 -0
- data/lib/generators/printer/printer_generator.rb +27 -0
- data/lib/generators/printer/templates/print_job.rb +21 -0
- data/lib/generators/printer/templates/printable.rb +13 -0
- data/lib/generators/printer/templates/printer.rb +15 -0
- data/lib/java_pdf/LICENSE +71 -0
- data/lib/java_pdf/LICENSE-LGPL-2.1.txt +504 -0
- data/lib/java_pdf/LICENSE-W3C-TEST +28 -0
- data/lib/java_pdf/README +92 -0
- data/lib/java_pdf/about.jar +0 -0
- data/lib/java_pdf/barbecue-1.5-beta1.jar +0 -0
- data/lib/java_pdf/barcodeprinter.jar +0 -0
- data/lib/java_pdf/browser.jar +0 -0
- data/lib/java_pdf/core-renderer-minimal.jar +0 -0
- data/lib/java_pdf/core-renderer.jar +0 -0
- data/lib/java_pdf/docbook.jar +0 -0
- data/lib/java_pdf/iText-2.0.8.jar +0 -0
- data/lib/java_pdf/itext-paulo-155.jar +0 -0
- data/lib/java_pdf/lib/LICENSE +71 -0
- data/lib/java_pdf/lib/LICENSE-LGPL-2.1.txt +504 -0
- data/lib/java_pdf/lib/LICENSE-W3C-TEST +28 -0
- data/lib/java_pdf/lib/README +92 -0
- data/lib/java_pdf/lib/core-renderer-minimal.jar +0 -0
- data/lib/java_pdf/lib/core-renderer.jar +0 -0
- data/lib/java_pdf/lib/iText-2.0.8.jar +0 -0
- data/lib/java_pdf/lib/itext-paulo-155.jar +0 -0
- data/lib/java_pdf/lib/minium.jar +0 -0
- data/lib/java_pdf/minium.jar +0 -0
- data/lib/java_pdf/pd4ml_demo.jar +0 -0
- data/lib/java_pdf/ss_css2.jar +0 -0
- data/lib/java_pdf/svg.jar +0 -0
- data/lib/oxen_printer.rb +8 -0
- data/lib/oxen_printer/cab_printer.rb +101 -0
- data/lib/oxen_printer/csv_printer.rb +12 -0
- data/lib/oxen_printer/engine.rb +19 -0
- data/lib/oxen_printer/html_printer.rb +12 -0
- data/lib/oxen_printer/label_printer.rb +12 -0
- data/lib/oxen_printer/pdf_printer.rb +66 -0
- data/lib/oxen_printer/version.rb +3 -0
- data/lib/print_drivers.rb +94 -0
- data/lib/print_engine.rb +135 -0
- data/lib/tasks/oxen_printer_tasks.rake +4 -0
- data/oxen_printer.gemspec +25 -0
- metadata +163 -0
@@ -0,0 +1,68 @@
|
|
1
|
+
.card-panel
|
2
|
+
= simple_form_for(:printer) do |f|
|
3
|
+
= f.error_notification
|
4
|
+
|
5
|
+
.form-inputs
|
6
|
+
-# - if current_user.admin? and params[:controller] =~ /service/
|
7
|
+
-# / %input{ name: 'parent_id', collection: policy_scope(Account), class: :validate}
|
8
|
+
-# - else
|
9
|
+
%input{ type: :hidden, name: 'parent', value: 'Account' }
|
10
|
+
%input{ type: :hidden, name: 'parent_id', value: resource.id }
|
11
|
+
|
12
|
+
.row
|
13
|
+
= f.input :name
|
14
|
+
|
15
|
+
.row
|
16
|
+
= f.input :cups_printer, placeholder: t('.cups_printer'), required: true, disabled: @disabled
|
17
|
+
|
18
|
+
.row
|
19
|
+
= f.input :command, placeholder: t('.cups_cmd'), required: true, disabled: @disabled
|
20
|
+
|
21
|
+
.row
|
22
|
+
= f.input :paper, placeholder: t('.paper'), required: true, disabled: @disabled
|
23
|
+
|
24
|
+
.row
|
25
|
+
.input-field.col.s4
|
26
|
+
%label{ style: "margin-top: -20px"}= t('.service_active')
|
27
|
+
.switch
|
28
|
+
%label
|
29
|
+
= t(:passive)
|
30
|
+
=f.check_box :active, disabled: @disabled
|
31
|
+
%span.lever
|
32
|
+
= t(:active)
|
33
|
+
|
34
|
+
|
35
|
+
%br
|
36
|
+
%br
|
37
|
+
.row
|
38
|
+
/ = f.input :last_monitored_at, disabled: true
|
39
|
+
|
40
|
+
|
41
|
+
%ul
|
42
|
+
%li tidsstyring
|
43
|
+
%li
|
44
|
+
|
45
|
+
- unless @disabled
|
46
|
+
.row
|
47
|
+
.form-actions.right-align
|
48
|
+
= f.button :submit, t('.account_printer_submit'), class: "printer_commit"
|
49
|
+
|
50
|
+
:coffeescript
|
51
|
+
|
52
|
+
$ ->
|
53
|
+
$(document.body).on 'click', 'input.printer_commit', (e) ->
|
54
|
+
e.preventDefault()
|
55
|
+
e.stopPropagation()
|
56
|
+
$form = $(e.target).closest('form')
|
57
|
+
data = $form.serialize()
|
58
|
+
jqxhr = $.ajax
|
59
|
+
url: '/admin/printers.js',
|
60
|
+
type: 'post',
|
61
|
+
data: data,
|
62
|
+
dataType: 'html'
|
63
|
+
jqxhr.done (response) ->
|
64
|
+
$('#account_printers').prepend(response)
|
65
|
+
fadeItOut $('.message_container .alert-success')
|
66
|
+
jqxhr.fail (response) ->
|
67
|
+
$('body').append(response)
|
68
|
+
fadeItOut $('.message_container .alert-danger'), 5000
|
@@ -0,0 +1,11 @@
|
|
1
|
+
.row
|
2
|
+
.col.s12
|
3
|
+
%table.responsive-table.hoverable.striped.resources_table
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%th{ :"data-field"=>"name"}= t('.name')
|
7
|
+
%th= t(:delete)
|
8
|
+
|
9
|
+
%tbody#printers.resources_list
|
10
|
+
- resources.each do |printer|
|
11
|
+
= render partial: 'printer', locals: { resource: printer }
|
@@ -0,0 +1,18 @@
|
|
1
|
+
%tr{ id: "tr-#{printer.id}"}
|
2
|
+
%td= link_to printer.name, printer
|
3
|
+
%td= show_resource_delete_icon printer, '/admin/printers'
|
4
|
+
- if parent?
|
5
|
+
%td
|
6
|
+
- if user.printers.include? printer
|
7
|
+
= link_to detach_url( user,printer), class: 'attached green-text', title: t('detach_printers') do
|
8
|
+
%i.material-icons layers
|
9
|
+
- else
|
10
|
+
= link_to attach_url( user,printer), class: 'detached red-text', title: t('attach_printers') do
|
11
|
+
%i.material-icons layers_clear
|
12
|
+
%td
|
13
|
+
- if user.printers.preferred_printer.include? printer
|
14
|
+
-#= link_to defer_url( user,printer), class: 'preferred green-text', title: t('defer_printers') do
|
15
|
+
%i.preferred.material-icons.green-text{ data: { id: printer.id }} bookmark
|
16
|
+
- else
|
17
|
+
= link_to prefer_url( user,printer), class: 'deferred grey-text', data: { id: printer.id },title: t('prefer_printers') do
|
18
|
+
%i.material-icons bookmark_border
|
@@ -0,0 +1,14 @@
|
|
1
|
+
.row
|
2
|
+
.col.s12{ style: "height: 250px; overflow: scroll"}
|
3
|
+
%table.responsive-table.hoverable.striped.resources_table
|
4
|
+
%thead
|
5
|
+
%tr
|
6
|
+
%th{ :"data-field"=>"name"}= t('.name')
|
7
|
+
%th= t(:delete)
|
8
|
+
- if parent?
|
9
|
+
%th= t('attach_detach_printer')
|
10
|
+
%th= t('prefer_printer')
|
11
|
+
|
12
|
+
%tbody#account_printers.resources_list
|
13
|
+
- resource.account.printers.each do |printer|
|
14
|
+
= render partial: 'printers/user_printer', locals: { printer: printer, user: resource, parent: resource.account, parent_id: resource.account.id }
|
data/bin/rails
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
|
3
|
+
|
4
|
+
ENGINE_ROOT = File.expand_path('../..', __FILE__)
|
5
|
+
ENGINE_PATH = File.expand_path('../../lib/oxen_printer/engine', __FILE__)
|
6
|
+
|
7
|
+
# Set up gems listed in the Gemfile.
|
8
|
+
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
9
|
+
require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
|
10
|
+
|
11
|
+
require 'rails/all'
|
12
|
+
require 'rails/engine/commands'
|
@@ -0,0 +1,7 @@
|
|
1
|
+
da:
|
2
|
+
oxen:
|
3
|
+
printers:
|
4
|
+
new:
|
5
|
+
cups_printer: 'Angiv navnet på den CUPS printer, der skal håndtere print'
|
6
|
+
cups_cmd: 'Indfør den kommando som skal starte printjobbet ("lp -d $1 -o media=$2 $3" eller "lp -d $1 -o raw $2")'
|
7
|
+
paper: 'Angiv papirformatet - exvis Letter, A4, 30x57mm, eller lignende'
|
data/config/routes.rb
ADDED
@@ -0,0 +1,47 @@
|
|
1
|
+
Rails.application.routes.draw do
|
2
|
+
|
3
|
+
concern :printing do
|
4
|
+
member do
|
5
|
+
get 'print'
|
6
|
+
get 'slip'
|
7
|
+
end
|
8
|
+
collection do
|
9
|
+
get 'print'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# prefer and defer elements (setting preferred true|false)
|
14
|
+
concern :preferring do
|
15
|
+
member do
|
16
|
+
get 'prefer'
|
17
|
+
get 'defer'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
# attach and detach the route in question to its 'parent'
|
22
|
+
concern :attaching do
|
23
|
+
member do
|
24
|
+
get 'attach'
|
25
|
+
get 'detach'
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
# activate and passify the route in question
|
30
|
+
concern :activating do
|
31
|
+
member do
|
32
|
+
get 'activate'
|
33
|
+
get 'deactivate'
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
scope '/admin' do
|
39
|
+
resources :services
|
40
|
+
resources :printables
|
41
|
+
resources :print_jobs, concerns: :printing
|
42
|
+
resources :printers, concerns: [:activating, :attaching, :printing] do
|
43
|
+
resources :users, concerns: :attaching
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
class ActionPrinter < ActionView::Base #AbstractController::Base
|
3
|
+
|
4
|
+
# previously
|
5
|
+
# include AbstractController::Rendering
|
6
|
+
# include AbstractController::Helpers
|
7
|
+
# include AbstractController::Translation
|
8
|
+
# include AbstractController::AssetPaths
|
9
|
+
# include Rails.application.routes.url_helpers
|
10
|
+
|
11
|
+
# helper ApplicationHelper
|
12
|
+
# self.view_paths = "app/views"
|
13
|
+
|
14
|
+
# prepend_view_path ViewTemplate::Resolver.instance
|
15
|
+
|
16
|
+
attr_accessor :printer, :paper
|
17
|
+
|
18
|
+
def initialize(printer,paper)
|
19
|
+
@printer=printer
|
20
|
+
@paper=paper
|
21
|
+
super(Rails.configuration.paths['app/views'])
|
22
|
+
end
|
23
|
+
|
24
|
+
def command
|
25
|
+
@printer.command
|
26
|
+
end
|
27
|
+
|
28
|
+
# def printer
|
29
|
+
# @printer
|
30
|
+
# end
|
31
|
+
#
|
32
|
+
# def printer=value
|
33
|
+
# @printer = value
|
34
|
+
# end
|
35
|
+
|
36
|
+
|
37
|
+
|
38
|
+
#
|
39
|
+
# build a temp file with the HTML string rendered and provided as argument str
|
40
|
+
def html_file str, type='html'
|
41
|
+
f = Tempfile.new(['print', ".#{type}"])
|
42
|
+
f.puts str
|
43
|
+
f.close
|
44
|
+
Rails.logger.info "oxen: wrote #{f.path}"
|
45
|
+
f
|
46
|
+
end
|
47
|
+
|
48
|
+
def text_file str
|
49
|
+
html_file str, 'label'
|
50
|
+
end
|
51
|
+
|
52
|
+
def file_path
|
53
|
+
raise "must be implemented on the driver!!"
|
54
|
+
end
|
55
|
+
|
56
|
+
def label_file_path
|
57
|
+
@label_file_path ||= `mktemp -t lblXXXX`[0..-2]
|
58
|
+
end
|
59
|
+
|
60
|
+
def pdf_file_path
|
61
|
+
@pdf_file_path ||= `mktemp -t pdfXXXX`[0..-2]
|
62
|
+
end
|
63
|
+
|
64
|
+
def get_file_type
|
65
|
+
raise "you must implement this on the driver!!"
|
66
|
+
end
|
67
|
+
|
68
|
+
def send_print_file context
|
69
|
+
context.send_file pdf_file_path, filename: 'oxen_file', type: get_file_type, disposition: "attachment"
|
70
|
+
# context.cookies['fileDownload'] = 'true'
|
71
|
+
# File.open(pdf_file_path, 'r') do |fp|
|
72
|
+
# context.send_data fp.read.force_encoding('BINARY'), filename: 'oxen_file', type: "application/pdf", disposition: "attachment"
|
73
|
+
# end
|
74
|
+
end
|
75
|
+
|
76
|
+
def logit( log_type, msg )
|
77
|
+
Rails.logger.send(log_type, "[OXEN] #{Time.now} [#{log_type.to_s}] #{msg}")
|
78
|
+
end
|
79
|
+
|
80
|
+
# class Pushable
|
81
|
+
# def initialize(channel, pushtext)
|
82
|
+
# @channel = channel
|
83
|
+
# @pushtext = pushtext
|
84
|
+
# end
|
85
|
+
#
|
86
|
+
# def push
|
87
|
+
# Pusher[@channel].trigger('rjs_push', @pushtext )
|
88
|
+
# end
|
89
|
+
# end
|
90
|
+
end
|
@@ -0,0 +1,215 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
module C4LabelPrintProvider
|
3
|
+
|
4
|
+
#
|
5
|
+
#
|
6
|
+
#
|
7
|
+
def self.included(klass)
|
8
|
+
klass.extend ClassMethods
|
9
|
+
# klass.logger.debug "*** extending Class #{klass.class_name} with say_c4_label"
|
10
|
+
klass.class_eval do
|
11
|
+
include InstanceMethods
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
#
|
16
|
+
#
|
17
|
+
#
|
18
|
+
module ClassMethods
|
19
|
+
|
20
|
+
end
|
21
|
+
|
22
|
+
#
|
23
|
+
#
|
24
|
+
#
|
25
|
+
module InstanceMethods
|
26
|
+
|
27
|
+
|
28
|
+
|
29
|
+
#
|
30
|
+
#
|
31
|
+
#
|
32
|
+
def say_c4_label nbr_labels=2, label_printer=""
|
33
|
+
kvast_strings = []
|
34
|
+
product_label = []
|
35
|
+
stock_or_customer_sign = provide_customer_or_stock_label
|
36
|
+
ft_profil = ""
|
37
|
+
if self.product.name =~ /FT Profil \D*/
|
38
|
+
# profil_nr ="FT Profil %s" % self.product.name.gsub(/^.* FT Profil (\d*).*$/, "\\1")
|
39
|
+
# ft_profil = "
|
40
|
+
# T :text2;8,135,0,3,pt25;#{profil_nr}"
|
41
|
+
end
|
42
|
+
props=self.product.name.split(" ")
|
43
|
+
props=props[0..props.size-2] if props.at(-1) =~ /\d*\/\d/
|
44
|
+
if props.size > 6
|
45
|
+
product_label[0] = props[0..6].join(" ")
|
46
|
+
product_label[1] = props[7..props.size].join(" ") #[ltw..self.product.name.size]
|
47
|
+
else
|
48
|
+
product_label[0] = props.join(" ")
|
49
|
+
product_label[1] = ""
|
50
|
+
end
|
51
|
+
if self.stock_items.size > 0
|
52
|
+
kvasts = self.stock_items.collect { |si| "%i/%0.2f" % [si.quantity.to_i,si.product.length.to_f] }
|
53
|
+
kvast_strings << kvasts[0..6].join(" :: ").gsub(/\./,",")
|
54
|
+
kvast_strings << ((kvasts.size > 6) ? kvasts[7..kvasts.size].join(" :: ").gsub(/\./,",") : "")
|
55
|
+
product_label[0] = product_label[0].gsub(/KVAST .*/, "")
|
56
|
+
product_label[1] = product_label[1].gsub(/KVAST .*/, "KVAST")
|
57
|
+
else
|
58
|
+
kvast_strings = []
|
59
|
+
kvast_strings << ""
|
60
|
+
kvast_strings << ""
|
61
|
+
end
|
62
|
+
supplier_colli_barcode_number = self.supplier_barcode_number ||= ""
|
63
|
+
if (width==0.0 or width.blank?)
|
64
|
+
thick_height = "ø#{self.product.height.to_i}"
|
65
|
+
else
|
66
|
+
thick_height = "#{self.product.height.to_i} x #{self.product.width.to_i}"
|
67
|
+
end
|
68
|
+
# old barcode: B 11.51,125.12,90,e,14.25,0.25;#{self.barcode_number.to_s}
|
69
|
+
# B 5, 5,0,CODE128, 12,.3;ABC123
|
70
|
+
cmd="J
|
71
|
+
H175,+0
|
72
|
+
O R
|
73
|
+
I :image1;8,55,90;LOGOGREY
|
74
|
+
S l1;0,0,145,149,104;label
|
75
|
+
G 4.13,6.88,0;R:95.09,131.13,1.00,1.00[F:100%]
|
76
|
+
B 18,125.12,90,CODE128,25,0.5;#{self.barcode_number.to_s}
|
77
|
+
T :bc_label;15,125,90,5,pt36;#{self.barcode_number.to_s}
|
78
|
+
#{stock_or_customer_sign}
|
79
|
+
T :text0;64,125,90,3,pt10;#{product_label[0]}
|
80
|
+
T :text1;68,125,90,3,pt10;#{product_label[1]}#{ft_profil}
|
81
|
+
T :thick_height;60,125,90,5,pt46;#{thick_height}
|
82
|
+
T :quantity_length;80,125,90,5,pt36;#{self.quantity.to_i.to_s} stk/ #{self.product.length.to_s.gsub(/\./,",")}m
|
83
|
+
T :pieces0;83,125,90,5,pt8;#{kvast_strings[0]}
|
84
|
+
T :pieces1;87,125,90,5,pt8;#{kvast_strings[1]}
|
85
|
+
T :supplier_colli_barcode_number;96,135.12,90,3,pt8;#{supplier_colli_barcode_number}
|
86
|
+
T :cubic;96,30,90,3,pt8;#{self.cubic.to_s}m3
|
87
|
+
T :label_print_dato;96,8,180,3,pt10;#{ Time.now.strftime('%d-%m-%Y')}
|
88
|
+
A #{nbr_labels}
|
89
|
+
"
|
90
|
+
# CHANGED 2009-01-15 use quantity from self - #{self.product.casing.split(" ")[0].to_s} stk/ #{self.product.length.to_s}m
|
91
|
+
return cmd if label_printer==""
|
92
|
+
upload_logo label_printer
|
93
|
+
File.open("#{RAILS_ROOT}/public/documents/label", "w") do |f|
|
94
|
+
f.write(cmd)
|
95
|
+
end
|
96
|
+
|
97
|
+
%x(lp -d #{label_printer} -o raw #{RAILS_ROOT}public/documents)
|
98
|
+
|
99
|
+
rescue
|
100
|
+
""
|
101
|
+
end
|
102
|
+
|
103
|
+
#
|
104
|
+
# provide the sign for labels - either a customer or a stock sign (two-digit year)
|
105
|
+
def provide_customer_or_stock_label
|
106
|
+
|
107
|
+
# does this stock_item task belong to any particular customer order?
|
108
|
+
unless (self.purchase_task.blank? or self.purchase_task.customer_partner.blank?)
|
109
|
+
return "
|
110
|
+
T :customer_name;31,70,90,5,pt12;#{ self.purchase_task.customer_partner.name.strip[0..25] }
|
111
|
+
T :customer_zip;39,70,90,5,pt12;#{ zipcode_and_order_nr self.purchase_task }"
|
112
|
+
else
|
113
|
+
# perhaps the entire pick_list is a customer order?!
|
114
|
+
unless self.purchase_picklist.blank?
|
115
|
+
customer = self.purchase_picklist.customer_partner
|
116
|
+
unless customer.blank?
|
117
|
+
return "
|
118
|
+
T :customer_name;31,70,90,5,pt12;#{ customer.name.strip[0..25] }
|
119
|
+
T :customer_zip;39,70,90,5,pt12;#{ zipcode_and_order_nr self.purchase_picklist }"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
# this is most definately a stock order - tell them!
|
123
|
+
return "T :year_big;40,58,90,5,pt66;#{ Time.now.strftime('%y') }"
|
124
|
+
end
|
125
|
+
|
126
|
+
end
|
127
|
+
|
128
|
+
#
|
129
|
+
# build zipcode and order number
|
130
|
+
def zipcode_and_order_nr element
|
131
|
+
"box: #{element.customer_partner.zipcode.strip[0..8]} ordrenr.: #{element.customer_project_number.strip[0..6]}"
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
#
|
136
|
+
#
|
137
|
+
#
|
138
|
+
#
|
139
|
+
#
|
140
|
+
#
|
141
|
+
def upload_logo printer
|
142
|
+
unless File.exist?("#{RAILS_ROOT}/tmp/lbl_logo.dat")
|
143
|
+
esc_byte = "\e"
|
144
|
+
buff = ""
|
145
|
+
buff <<
|
146
|
+
"e GIF;*
|
147
|
+
d GIF;LOGOGREY
|
148
|
+
" + esc_byte + "."
|
149
|
+
File.open("#{RAILS_ROOT}/public/forms/labels/logogrey.gif", "r") do |f|
|
150
|
+
f.each_byte {|b| b==27 ? buff<< b << b : buff << b}
|
151
|
+
end
|
152
|
+
buff << esc_byte + "."
|
153
|
+
File.open("#{RAILS_ROOT}/tmp/lbl_logo.dat", "w") do |f|
|
154
|
+
f.write(buff)
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
value = `lp -d #{printer} -o raw #{RAILS_ROOT}/tmp/lbl_logo.dat`
|
159
|
+
true
|
160
|
+
rescue
|
161
|
+
false
|
162
|
+
end
|
163
|
+
|
164
|
+
def label_test
|
165
|
+
kvast_strings = []
|
166
|
+
product_label = []
|
167
|
+
# if self.stock_items.size > 0
|
168
|
+
# kvasts = self.stock_items.collect { |si| "#{si.quantity} / #{si.product.length}" }
|
169
|
+
# kvast_strings << kvasts[0..6].join(" :: ")
|
170
|
+
# kvast_strings << ((kvasts.size > 6) ? kvasts[7..kvasts.size].join(" :: ") : "")
|
171
|
+
# product_label[0] = self.product.name.gsub(/KVAST .*/, "")
|
172
|
+
# product_label[1] = self.product.name.gsub(/.* KVAST/, "KVAST")
|
173
|
+
# else
|
174
|
+
kvast_strings = []
|
175
|
+
kvast_strings << ""
|
176
|
+
kvast_strings << ""
|
177
|
+
product_label[0] = "16x100 fyr ru tørret 12-15% æøåÆØÅ"
|
178
|
+
product_label[1] = "KVAST 201/3.454"
|
179
|
+
# end
|
180
|
+
supplier_colli_barcode_number = "" # TODO 2008-09-09 add supplier barcode number to picklist input
|
181
|
+
# old barcode: B 11.51,125.12,90,e,14.25,0.25;#{self.barcode_number.to_s}
|
182
|
+
# B 5, 5,0,CODE128, 12,.3;ABC123
|
183
|
+
|
184
|
+
# CHANGED 2008-09-12: from
|
185
|
+
# S l1;0,0,144,149,103;label
|
186
|
+
# B 11.51,125.12,90,CODE128,14.25,0.25;9201123123
|
187
|
+
# T :bc_label;35.51,125.25,90,5,pt36;9201123123
|
188
|
+
|
189
|
+
|
190
|
+
cmd = "J
|
191
|
+
H175,+0,D
|
192
|
+
O R, T
|
193
|
+
S l1;0,0,145,149,104;label
|
194
|
+
G 4.13,6.88,0;R:95.09,131.13,1.00,1.00[F:100%]
|
195
|
+
B 18,125.12,90,CODE128,25,0.5;9201123123
|
196
|
+
T :bc_label;15,125,90,5,pt36;123123
|
197
|
+
T :text0;64,125,90,3,pt10;#{product_label[0]}
|
198
|
+
T :text1;68,125,90,3,pt10;#{product_label[1]}
|
199
|
+
T :thick_height;60,125,90,5,pt46;16 x 100
|
200
|
+
T :quantity_length;80,125,90,5,pt36;201 stk/ 3.454m
|
201
|
+
T :pieces0;83,125,90,5,pt8;#{kvast_strings[0]}
|
202
|
+
T :pieces1;87,125,90,5,pt8;#{kvast_strings[1]}
|
203
|
+
T :supplier_colli_barcode_number;96,135.12,90,3,pt8;#{supplier_colli_barcode_number}
|
204
|
+
T :cubic;96,30,90,3,pt8;1.456m3
|
205
|
+
T :label_print_dato;96,8,180,3,pt10;#{ Time.now.strftime('%d-%m-%Y')}
|
206
|
+
A 1
|
207
|
+
"
|
208
|
+
File.open("#{RAILS_ROOT}/tmp/label", "w") do |f|
|
209
|
+
f.write(cmd)
|
210
|
+
end
|
211
|
+
|
212
|
+
%x(lp -d label -o raw #{RAILS_ROOT}/tmp/label)
|
213
|
+
end
|
214
|
+
end
|
215
|
+
end
|