edit
This commit is contained in:
@@ -3,8 +3,8 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
def register
|
def register
|
||||||
batch_id=params[:batch_id]
|
batch_id=params[:batch_id]
|
||||||
session_token=params[:session_token]
|
session_token=params[:session_token]
|
||||||
manufacture_uid = params[:card_manufacture]
|
manufacture_uid = params[:card_manufacture]
|
||||||
|
card_account_no=params[:card_account_no]
|
||||||
client_id=""
|
client_id=""
|
||||||
|
|
||||||
check_member= Member.authenticate_session_token(session_token)
|
check_member= Member.authenticate_session_token(session_token)
|
||||||
@@ -13,12 +13,12 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
asset_identity=""
|
asset_identity=""
|
||||||
|
|
||||||
find_batch = Batch.find_by_id(batch_id)
|
find_batch = Batch.find_by_id(batch_id)
|
||||||
if !find_batch.nil?
|
if !find_batch.nil?
|
||||||
card_type=find_batch.adult_or_child.upcase
|
card_type=find_batch.adult_or_child.upcase
|
||||||
product_category_id=find_batch.product_category_id
|
product_category_id=find_batch.product_category_id
|
||||||
find_product_category=ProductCategory.find_by_id(product_category_id)
|
find_product_category=ProductCategory.find_by_id(product_category_id)
|
||||||
|
|
||||||
if !find_product_category.nil?
|
if !find_product_category.nil?
|
||||||
product_type=find_product_category.product_type_id
|
product_type=find_product_category.product_type_id
|
||||||
|
|
||||||
find_user=Client.find_by_id(find_batch.client_id)
|
find_user=Client.find_by_id(find_batch.client_id)
|
||||||
@@ -27,10 +27,9 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
location_code=find_user.location_code
|
location_code=find_user.location_code
|
||||||
|
|
||||||
client_id=find_user.id
|
client_id=find_user.id
|
||||||
|
if !encrypt_key.nil?
|
||||||
if !encrypt_key.nil?
|
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
||||||
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
if check_manufacture.nil?
|
||||||
if check_manufacture.nil?
|
|
||||||
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
|
serial_no=BatchLineItem.generate_serial_no(client_id.to_s)
|
||||||
|
|
||||||
if product_type ==1 #CARD
|
if product_type ==1 #CARD
|
||||||
@@ -49,20 +48,24 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
if check_asset.nil?
|
if check_asset.nil?
|
||||||
@out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
@out=BatchLineItem.create_product(asset_identity,serial_no,batch_id,manufacture_uid,card_type)
|
||||||
else
|
else
|
||||||
@out=false,'Asset Identity is already registered!'
|
@out=false,'Asset Identity is already registered!',nil
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Manufacture UID is already registered!'
|
if check_manufacture.asset_identity !=card_account_no
|
||||||
|
@out=false,"Error",check_manufacture
|
||||||
|
else
|
||||||
|
@out=false,'Manufacture UID is already registered!',nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,'Invalid User!'
|
@out=false,'Invalid User!',nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,"Client doesn't exist!"
|
@out=false,"Client doesn't exist!",nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,"Product Category doesn't exist!"
|
@out=false,"Product Category doesn't exist!",nil
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
@out=false,"Batch doesn't exist!"
|
@out=false,"Batch doesn't exist!"
|
||||||
@@ -70,5 +73,5 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
else
|
else
|
||||||
@out=false,'Sorry!Unauthorized user!'
|
@out=false,'Sorry!Unauthorized user!'
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -5,4 +5,5 @@
|
|||||||
else
|
else
|
||||||
json.set! :status, @out[0]
|
json.set! :status, @out[0]
|
||||||
json.set! :message,@out[1]
|
json.set! :message,@out[1]
|
||||||
|
json.set! :data,@out[2]
|
||||||
end
|
end
|
||||||
Reference in New Issue
Block a user