edit
This commit is contained in:
@@ -3,7 +3,9 @@ class BatchLineItemsController < ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_action :authenticate_member!
|
||||
def index
|
||||
@batches=Batch.all
|
||||
user_id=current_member.user_id
|
||||
|
||||
@batches=Batch.where('user_id=?',user_id)
|
||||
@batchLineItems=BatchLineItem.joins('inner join batches on batches.id=batch_line_items.batch_id').select('batch_line_items.*,batches.order_ref as batch_name').page(params[:page]).per(2)
|
||||
end
|
||||
def export
|
||||
@@ -28,6 +30,7 @@ class BatchLineItemsController < ApplicationController
|
||||
end
|
||||
@batchLineItems = BatchLineItem.all.select('serial_no,wristband_code,batch_id,manufacture_uid,card_type')
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.csv { send_data @batchLineItems.to_csv(user_id), filename: "encoder-#{Date.today}.csv" }
|
||||
|
||||
@@ -31,7 +31,7 @@ class UsersController < ApplicationController
|
||||
cipher = OpenSSL::Cipher::Cipher.new("aes-256-cbc")
|
||||
key=cipher.random_key
|
||||
secrect_key= Base64.encode64(key)
|
||||
@user.secrect_key=secrect_key
|
||||
@user.secrect_key=secrect_key
|
||||
|
||||
respond_to do |format|
|
||||
if @user.save
|
||||
|
||||
@@ -24,12 +24,13 @@ class BatchLineItem < ApplicationRecord
|
||||
find_lookup=Lookup.find_by_name('generate_serial_no')
|
||||
if !find_lookup.nil?
|
||||
max_value=find_lookup.max_value
|
||||
max_value=max_value +1
|
||||
prefix=find_lookup.prefix
|
||||
max_length=find_lookup.max_length
|
||||
max_length=find_lookup.max_length
|
||||
|
||||
max_value=max_value +1
|
||||
sufix_len=max_length-prefix.length
|
||||
sufix_str="0" * sufix_len
|
||||
value_len= max_value.to_s.length
|
||||
|
||||
start=0
|
||||
ends=sufix_len-value_len-1
|
||||
sufix_str= sufix_str[start..ends]
|
||||
@@ -38,6 +39,13 @@ class BatchLineItem < ApplicationRecord
|
||||
|
||||
serial_no=prefix_str.to_s+sufix_str+max_value.to_s
|
||||
return serial_no
|
||||
else
|
||||
lookup= Lookup.new
|
||||
lookup.name="generate_serial_no"
|
||||
lookup.max_value=0
|
||||
lookup.prefix='0000'
|
||||
lookup.max_length=16
|
||||
lookup.save
|
||||
end
|
||||
end
|
||||
def self.to_csv(user_id)
|
||||
|
||||
Reference in New Issue
Block a user