diff --git a/Gemfile b/Gemfile
index 4f61880..a71a9c5 100644
--- a/Gemfile
+++ b/Gemfile
@@ -44,6 +44,7 @@ gem 'bcrypt', '~> 3.1.7'
gem 'simple_form'
gem 'kaminari'
gem 'to_csv-rails'
+gem 'barby'
# gem 'bootstrap-multiselect-rails'
group :development, :test do
diff --git a/Gemfile.lock b/Gemfile.lock
index 16b8529..04d4920 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -41,6 +41,7 @@ GEM
airbrussh (1.3.0)
sshkit (>= 1.6.1, != 1.7.0)
arel (7.1.4)
+ barby (0.6.5)
bcrypt (3.1.12)
bindex (0.5.0)
builder (3.2.3)
@@ -223,6 +224,7 @@ PLATFORMS
ruby
DEPENDENCIES
+ barby
bcrypt (~> 3.1.7)
byebug
capistrano
diff --git a/app/controllers/api/batch_line_items_controller.rb b/app/controllers/api/batch_line_items_controller.rb
index e321dec..9cd3a1d 100644
--- a/app/controllers/api/batch_line_items_controller.rb
+++ b/app/controllers/api/batch_line_items_controller.rb
@@ -81,9 +81,6 @@ class Api::BatchLineItemsController < ApplicationController
client_id=""
qty = params[:qty]
total_count=0
- puts batch_id
- puts 'ello'
- puts params[:id]
# check_member= Member.authenticate_session_token(session_token)
# if !check_member.nil?
encrypt_key=""
@@ -264,5 +261,5 @@ class Api::BatchLineItemsController < ApplicationController
@out = false,"Not Authorized"
end
end
-
+
end
\ No newline at end of file
diff --git a/app/controllers/batch_line_items_controller.rb b/app/controllers/batch_line_items_controller.rb
index 575c083..b1fe17b 100644
--- a/app/controllers/batch_line_items_controller.rb
+++ b/app/controllers/batch_line_items_controller.rb
@@ -3,6 +3,11 @@ class BatchLineItemsController < ApplicationController
skip_before_filter :verify_authenticity_token
before_action :authenticate_member!
require 'digest/md5'
+ require 'barby'
+ require 'barby/barcode/code_128'
+ require 'barby/outputter/ascii_outputter'
+ require 'barby/outputter/svg_outputter'
+
def index
# user_id=current_member.user_id
@@ -129,6 +134,9 @@ class BatchLineItemsController < ApplicationController
client_id=""
qty = params[:qty]
total_count=0
+ check = params[:barcode]
+
+
# check_member= Member.authenticate_session_token(session_token)
# if !check_member.nil?
@@ -137,7 +145,6 @@ class BatchLineItemsController < ApplicationController
find_batch = Batch.find_by_id(batch_id)
if !find_batch.nil?
- puts 'hkjfklasj'
card_type=find_batch.adult_or_child.upcase
product_category_id=find_batch.product_category_id
find_product_category=ProductCategory.find_by_id(product_category_id)
@@ -159,6 +166,14 @@ class BatchLineItemsController < ApplicationController
asset_identity=BatchLineItem.generate_account_no(location_code)
security_code=BatchLineItem.generate_security_code
out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,"","",security_code)
+ if check.present?
+ barcode = BatchLineItem.generate_barcode
+ update_barcode = BatchLineItem.find_by_asset_identity(out[2])
+ update_barcode.barcode = barcode
+ barcode_128 = Barby::Code128.new(barcode)
+ update_barcode.barcode_format = barcode_128
+ update_barcode.save
+ end
total_count+=1
end
respond_to do |format|
diff --git a/app/models/batch_line_item.rb b/app/models/batch_line_item.rb
index 08c27f4..0ef0693 100644
--- a/app/models/batch_line_item.rb
+++ b/app/models/batch_line_item.rb
@@ -39,6 +39,17 @@ class BatchLineItem < ApplicationRecord
end
return security_code
end
+ def self.generate_barcode
+
+ o = [('0'..'9')].map { |i| i.to_a }.flatten
+ barcode = (0...10).map { o[rand(o.length)] }.join
+ find_account_no = BatchLineItem.find_by_barcode(barcode)
+ if !find_account_no.nil?
+ o = [('0'..'9')].map { |i| i.to_a }.flatten
+ barcode = (0...10).map { o[rand(o.length)] }.join
+ end
+ return barcode
+ end
def self.generate_serial_no(client_id)
find_lookup=Lookup.find_by_name('generate_serial_no')
if !find_lookup.nil?
diff --git a/app/views/batch_line_items/generate_cards.html.erb b/app/views/batch_line_items/generate_cards.html.erb
index 6622c2a..135acfd 100644
--- a/app/views/batch_line_items/generate_cards.html.erb
+++ b/app/views/batch_line_items/generate_cards.html.erb
@@ -11,6 +11,9 @@
<%= hidden_field_tag 'id', params[:id] %>
<%= label_tag(:qty, "Qty:") %>
<%= text_field_tag :qty, "", class: 'adjust_height' %>
+
+ Barcode
+
<%= submit_tag("Generate", :class=>"btn btn-primary btn_height") %>
<% end %>
diff --git a/app/views/batches/show.html.erb b/app/views/batches/show.html.erb
index 4db6bc2..fc09003 100644
--- a/app/views/batches/show.html.erb
+++ b/app/views/batches/show.html.erb
@@ -67,8 +67,8 @@