add new files
This commit is contained in:
36
app/controllers/batch_line_items_controller.rb
Normal file
36
app/controllers/batch_line_items_controller.rb
Normal file
@@ -0,0 +1,36 @@
|
||||
class BatchLineItemsController < ApplicationController
|
||||
require "csv"
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_action :authenticate_member!
|
||||
def index
|
||||
@batches=Batch.all
|
||||
@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 create
|
||||
batch_list=params[:batch]
|
||||
if ! batch_list.nil?
|
||||
batch_list.each do |batch|
|
||||
find_batch=Batch.find_by_id(batch)
|
||||
if !find_batch.nil?
|
||||
export_count=find_batch.export_count
|
||||
find_batch.export_count=export_count.to_i+1
|
||||
find_batch.save
|
||||
end
|
||||
end
|
||||
@batchLineItems = BatchLineItem.where('batch_id in (?) ',batch_list).select('*')
|
||||
else
|
||||
user_id=current_member.user_id
|
||||
batches=Batch.all
|
||||
batches.each do |batch|
|
||||
export_count=batch.export_count
|
||||
batch.export_count=export_count.to_i+1
|
||||
batch.save
|
||||
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" }
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user