commit by nda
This commit is contained in:
@@ -73,5 +73,93 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
else
|
||||
@out=false,'Sorry!Unauthorized user!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def generate_card_account_items
|
||||
# Generate Code
|
||||
batch_id=params[:id]
|
||||
client_id=""
|
||||
qty = params[:qty]
|
||||
total_count=0
|
||||
|
||||
# check_member= Member.authenticate_session_token(session_token)
|
||||
# if !check_member.nil?
|
||||
encrypt_key=""
|
||||
asset_identity=""
|
||||
|
||||
find_batch = Batch.find_by_id(batch_id)
|
||||
if !find_batch.nil?
|
||||
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)
|
||||
|
||||
if !find_product_category.nil?
|
||||
product_type=find_product_category.product_type_id
|
||||
|
||||
find_user=Client.find_by_id(find_batch.client_id)
|
||||
if !find_user.nil?
|
||||
encrypt_key=find_user.secrect_key
|
||||
location_code=find_user.location_code
|
||||
|
||||
client_id=find_user.id
|
||||
|
||||
if !encrypt_key.nil?
|
||||
arr = Array.new
|
||||
# Generate with qty
|
||||
qty.to_i.times do |i|
|
||||
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
|
||||
|
||||
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)
|
||||
item = out[2]
|
||||
total_count+=1
|
||||
arr.push(item)
|
||||
end
|
||||
@out =true,'Success',arr
|
||||
# Generate with qty
|
||||
|
||||
else
|
||||
@out=false,'Invalid User!'
|
||||
end
|
||||
else
|
||||
@out=false,"Client doesn't exist!"
|
||||
end
|
||||
else
|
||||
@out=false,"Product Category doesn't exist!"
|
||||
end
|
||||
else
|
||||
@out=false,"Batch doesn't exist!"
|
||||
end
|
||||
# else
|
||||
# @out=false,'Sorry!Unauthorized user!'
|
||||
# end
|
||||
# Generate Code
|
||||
end
|
||||
def update_manufacture_uid
|
||||
account_no = params[:account_no]
|
||||
manufacture_uid = params[:manufacture_uid]
|
||||
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
||||
if !batch_line_item.nil?
|
||||
puts 'he'
|
||||
batch_line_item.manufacture_uid = manufacture_uid
|
||||
batch_line_item.save
|
||||
|
||||
@out = true,"success"
|
||||
else
|
||||
@out = false,"error"
|
||||
end
|
||||
end
|
||||
|
||||
def get_item_by_batch
|
||||
batch_id = params[:batch_id]
|
||||
session_token = params[:session_token]
|
||||
get_batch = BatchLineItem.where("batch_id=?",batch_id)
|
||||
if !get_batch.nil?
|
||||
@out = true,get_batch
|
||||
else
|
||||
@out = false,"no batch"
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user