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 @@ Manufacture UID Batch No Asset Type - Created At - Updated At + Barcode + Created At @@ -79,8 +79,8 @@ <%= item.manufacture_uid rescue '' %> <%= item.batch_name rescue '' %> <%= item.asset_type rescue '' %> - <%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %> - <%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %> + <%= item.barcode rescue '' %> + <%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %> <% end %> diff --git a/app/views/users/Find Results b/app/views/users/Find Results new file mode 100644 index 0000000..11a2f4a --- /dev/null +++ b/app/views/users/Find Results @@ -0,0 +1,21 @@ +Searching 838 files for "page_no" + +0 matches + +Searching 838 files for "check_box" + +/Users/nda/Documents/projectX/nemo_encoder/app/views/devise/sessions/new.html.erb: + 15 <% if devise_mapping.rememberable? -%> + 16
+ 17: <%= f.check_box :remember_me %> + 18 <%= f.label :remember_me %> + 19
+ +/Users/nda/Documents/projectX/nemo_encoder/app/views/users/_form.html.erb: + 58
+ 59 + 60: <%= check_box "Monday", "yes" %> + 61
+ 62 <% end %> + +2 matches across 2 files diff --git a/db/migrate/20180726080303_add_barcode_128_in_batch_line_items.rb b/db/migrate/20180726080303_add_barcode_128_in_batch_line_items.rb new file mode 100644 index 0000000..baf31fc --- /dev/null +++ b/db/migrate/20180726080303_add_barcode_128_in_batch_line_items.rb @@ -0,0 +1,5 @@ +class AddBarcode128InBatchLineItems < ActiveRecord::Migration[5.0] + def change + add_column :batch_line_items, :barcode_format, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 10b1ee5..45f9d62 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20180724072431) do +ActiveRecord::Schema.define(version: 20180726080303) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -30,6 +30,7 @@ ActiveRecord::Schema.define(version: 20180724072431) do t.string "barcode" t.boolean "is_activated", default: false t.datetime "activated_date" + t.string "barcode_format" t.index ["batch_id"], name: "index_batch_line_items_on_batch_id", using: :btree end