edit ticket controller
This commit is contained in:
@@ -3,8 +3,7 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
def register
|
||||
batch_id=params[:batch_id]
|
||||
session_token=params[:session_token]
|
||||
manufacture_uid = params[:card_manufacture]
|
||||
# card_type = params[:card_type]
|
||||
manufacture_uid = params[:card_manufacture]
|
||||
user_id=""
|
||||
|
||||
check_member= Member.authenticate_session_token(session_token)
|
||||
@@ -15,44 +14,51 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
encrypt_key=find_user.secrect_key
|
||||
user_id=find_user.id
|
||||
end
|
||||
if !encrypt_key.nil?
|
||||
serial_no=BatchLineItem.generate_serial_no(user_id.to_s)
|
||||
str="manufacture_uid="+manufacture_uid.to_s+"&serial_no="+serial_no.to_s
|
||||
|
||||
if !encrypt_key.nil?
|
||||
check_manufacture = BatchLineItem.find_by_manufacture_uid(manufacture_uid)
|
||||
if check_manufacture.nil?
|
||||
serial_no=BatchLineItem.generate_serial_no(user_id.to_s)
|
||||
str="manufacture_uid="+manufacture_uid.to_s+"&serial_no="+serial_no.to_s
|
||||
|
||||
digest_data= Digest::MD5.hexdigest(str)
|
||||
hex_data=digest_data.hex
|
||||
hex_str=hex_data.to_s
|
||||
wristband_code=hex_str[0..15]
|
||||
digest_data= Digest::MD5.hexdigest(str)
|
||||
hex_data=digest_data.hex
|
||||
hex_str=hex_data.to_s
|
||||
wristband_code=hex_str[0..15]
|
||||
check_wirstband=BatchLineItem.find_by_wristband_code(wristband_code)
|
||||
|
||||
if check_wirstband.nil?
|
||||
puts 'Check Wristband'
|
||||
card_type=""
|
||||
find_batch= Batch.find_by_id(batch_id)
|
||||
if !find_batch.nil?
|
||||
card_type=find_batch.adult_or_child.upcase
|
||||
end
|
||||
batchLineItem=BatchLineItem.new
|
||||
batchLineItem.wristband_code=wristband_code
|
||||
batchLineItem.serial_no=serial_no
|
||||
batchLineItem.batch_id=batch_id
|
||||
batchLineItem.manufacture_uid = manufacture_uid
|
||||
batchLineItem.card_type = card_type
|
||||
|
||||
if batchLineItem.save
|
||||
lookup=Lookup.find_by_name('generate_serial_no')
|
||||
max_serail_no=lookup.max_value
|
||||
lookup.max_value=max_serail_no.to_i+1
|
||||
lookup.save
|
||||
|
||||
check_manufacture = BatchLineItem.find_by_manufacture_uid_and_wristband_code(manufacture_uid,wristband_code)
|
||||
if check_manufacture.nil?
|
||||
card_type=""
|
||||
find_batch= Batch.find_by_id(batch_id)
|
||||
if !find_batch.nil?
|
||||
card_type=find_batch.adult_or_child.upcase
|
||||
end
|
||||
batchLineItem=BatchLineItem.new
|
||||
batchLineItem.wristband_code=wristband_code
|
||||
batchLineItem.serial_no=serial_no
|
||||
batchLineItem.batch_id=batch_id
|
||||
batchLineItem.manufacture_uid = manufacture_uid
|
||||
batchLineItem.card_type = card_type
|
||||
|
||||
if batchLineItem.save
|
||||
lookup=Lookup.find_by_name('generate_serial_no')
|
||||
max_serail_no=lookup.max_value
|
||||
lookup.max_value=max_serail_no.to_i+1
|
||||
lookup.save
|
||||
|
||||
@out = true,batchLineItem.serial_no,batchLineItem.wristband_code
|
||||
@out = true,batchLineItem.serial_no,batchLineItem.wristband_code
|
||||
else
|
||||
@out=false,'Error occurs in registration encoder!'
|
||||
end
|
||||
else
|
||||
@out=false,'Error occurs in registration encoder!'
|
||||
end
|
||||
@out=false,'Wristband is already registered!'
|
||||
end
|
||||
else
|
||||
@out=false,'Wristband code is already exists!'
|
||||
@out=false,'Wristband is already registered!'
|
||||
end
|
||||
else
|
||||
@out=false,'Invalid Encryption Key!'
|
||||
@out=false,'Invalid User!'
|
||||
end
|
||||
else
|
||||
@out=false,'Sorry!Unauthorized user!'
|
||||
|
||||
Reference in New Issue
Block a user