barcode update
This commit is contained in:
@@ -140,14 +140,17 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
# end
|
||||
# Generate Code
|
||||
end
|
||||
|
||||
def update_manufacture_uid
|
||||
account_no = params[:account_no]
|
||||
barcode = params[:barcode]
|
||||
manufacture_uid = params[:manufacture_uid]
|
||||
batch_line_item = BatchLineItem.find_by_asset_identity(account_no)
|
||||
if !batch_line_item.nil?
|
||||
batch_line_item.manufacture_uid = manufacture_uid
|
||||
batch_line_item.barcode = barcode
|
||||
batch_line_item.save
|
||||
|
||||
|
||||
# update batch
|
||||
batch = Batch.find_by_id(batch_line_item.batch_id)
|
||||
card_qty=batch.qty_processing.to_i
|
||||
@@ -172,6 +175,94 @@ class Api::BatchLineItemsController < ApplicationController
|
||||
else
|
||||
@out = false,"no batch"
|
||||
end
|
||||
end
|
||||
|
||||
def code_activate
|
||||
session_token = params[:session_token]
|
||||
barcode =params[:barcode]
|
||||
find_seller = Member.find_by_session_token(session_token)
|
||||
if !find_seller.nil?
|
||||
seller_id = find_seller.user_id
|
||||
find_barcode = BatchLineItem.find_by_barcode(barcode)
|
||||
if !find_barcode.nil?
|
||||
find_batch = Batch.find_by_id(find_barcode.batch_id)
|
||||
if find_batch.export_to_seller_id == seller_id
|
||||
if find_barcode.is_activated == false
|
||||
find_barcode.is_activated = true
|
||||
find_barcode.activated_date = DateTime.now
|
||||
find_barcode.save
|
||||
@out = true,"Success"
|
||||
else
|
||||
@out = false,"This is already activated!"
|
||||
end
|
||||
else
|
||||
@out = false,"Not Authorized Seller"
|
||||
end
|
||||
else
|
||||
@out = false,"Fail"
|
||||
end
|
||||
else
|
||||
@out = false, "Not Authorized"
|
||||
end
|
||||
end
|
||||
|
||||
# def check_ticket
|
||||
# session_token = params[:session_token]
|
||||
# barcode =params[:barcode]
|
||||
# find_seller = Member.find_by_session_token(session_token)
|
||||
# if !find_seller.nil?
|
||||
# seller_id = find_seller.user_id
|
||||
# find_barcode = BatchLineItem.find_by_barcode(barcode)
|
||||
# if !find_barcode.nil?
|
||||
# @out = true,"valid"
|
||||
# end
|
||||
# else
|
||||
# @out = false, "Not Authorized"
|
||||
# end
|
||||
# end
|
||||
|
||||
def activated_list
|
||||
session_token = params[:session_token]
|
||||
find_seller = Member.find_by_session_token(session_token)
|
||||
if !find_seller.nil?
|
||||
total_page_count= 0
|
||||
page_no = params[:page]
|
||||
if !page_no.nil? && page_no != ""
|
||||
offset = (page_no.to_i - 1 ) * 10
|
||||
else
|
||||
offset = 0
|
||||
end
|
||||
seller_id = find_seller.user_id
|
||||
get_list = BatchLineItem.select("batch_line_items.id,batch_line_items.barcode,batch_line_items.activated_date").joins("join batches on batches.id=batch_line_items.batch_id").where("batch_line_items.is_activated=? and batches.export_to_seller_id=?",true,seller_id).limit(10).offset(offset)
|
||||
|
||||
if get_list.count%10 > 0
|
||||
total_page_count = get_list.count/10 + 1
|
||||
else
|
||||
total_page_count = get_list.count/10
|
||||
end
|
||||
|
||||
if !get_list.nil?
|
||||
@out = true, get_list, total_page_count
|
||||
else
|
||||
@out = false, "No data"
|
||||
end
|
||||
else
|
||||
@out = false, "Not Authorized"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def seller_info
|
||||
session_token = params[:session_token]
|
||||
find_seller = Member.find_by_session_token(session_token)
|
||||
if !find_seller.nil?
|
||||
seller_id = find_seller.user_id
|
||||
total_export_qty = BatchLineItem.select("count(batch_line_items.id)as count").joins("join batches on batches.id=batch_line_items.batch_id").where("batches.export_to_seller_id=?",seller_id)
|
||||
total_activated_qty = BatchLineItem.select("count(batch_line_items.id)as count").joins("join batches on batches.id=batch_line_items.batch_id").where("batches.export_to_seller_id=? and batch_line_items.is_activated=?",seller_id,true)
|
||||
@out = true,total_export_qty[0]["count"],total_activated_qty[0]["count"]
|
||||
else
|
||||
@out = false,"Not Authorized"
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -9,16 +9,19 @@ class BatchLineItemsController < ApplicationController
|
||||
@product_category_id=""
|
||||
@clients=Client.all.order('id desc')
|
||||
@product_categories=ProductCategory.all.order('id desc')
|
||||
@sellers=User.where("user_type=?","Seller")
|
||||
|
||||
find_client=Client.select(:id).order('id desc').last
|
||||
if !find_client.nil?
|
||||
client_id=find_client.id
|
||||
|
||||
find_batch=Batch.where('client_id=?',client_id).order('id desc').first
|
||||
|
||||
if !find_batch.nil?
|
||||
@product_category_id=find_batch.product_category_id
|
||||
end
|
||||
sub_query="(select * from batches where client_id="+client_id.to_s+" and product_category_id ="+@product_category_id.to_s+" )"
|
||||
|
||||
@batchLineItems=BatchLineItem.joins('inner join '+sub_query+' as batches on batches.id=batch_line_items.batch_id')
|
||||
.select('batch_line_items.*,batches.order_ref as batch_name').order('batch_line_items.id desc').page(params[:page]).per(10)
|
||||
@result_count= @batchLineItems.total_count
|
||||
@@ -76,6 +79,7 @@ class BatchLineItemsController < ApplicationController
|
||||
@batches=Batch.where('user_id=?',user_id)
|
||||
client_id=params[:client]
|
||||
product_category_id=params[:product_category]
|
||||
seller_id = params[:seller]
|
||||
find_client=Client.find_by_id(client_id)
|
||||
location_code=find_client.location_code
|
||||
client_name=find_client.name.downcase
|
||||
@@ -91,7 +95,7 @@ class BatchLineItemsController < ApplicationController
|
||||
end
|
||||
|
||||
if !batch_list.empty?
|
||||
res=Batch.where("client_id=? and product_category_id=? and id in (?)",client_id,product_category_id,batch_list).update_all("export_count = export_count + 1,exported_by='"+exported_by+"'")
|
||||
res=Batch.where("client_id=? and product_category_id=? and id in (?)",client_id,product_category_id,batch_list).update_all("export_count = export_count + 1,exported_by='"+exported_by+"',export_to_seller_id='"+seller_id+"'")
|
||||
|
||||
|
||||
sub_query= "(select * from batches where client_id="+client_id.to_s+" and product_category_id="+ product_category_id.to_s+")"
|
||||
@@ -101,7 +105,7 @@ class BatchLineItemsController < ApplicationController
|
||||
.where('batch_id in (?)',batch_list)
|
||||
.select("*,product.product_type_id ,product.name,'' as secret_token,'' as location_name")
|
||||
else
|
||||
Batch.where("client_id=? ",client_id).update_all("export_count = export_count + 1,exported_by='"+exported_by+"'")
|
||||
Batch.where("client_id=? ",client_id).update_all("export_count = export_count + 1,exported_by='"+exported_by+"',export_to_seller_id='"+seller_id+"'")
|
||||
sub_query="(select * from batches where client_id ="+client_id+" and product_category_id="+ product_category_id+")"
|
||||
@batchLineItems = BatchLineItem.joins('inner join '+sub_query+' as batches on batches.id=batch_line_items.batch_id')
|
||||
.joins('inner join product_categories as product on product.id=batches.product_category_id')
|
||||
|
||||
@@ -100,6 +100,6 @@ class UsersController < ApplicationController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :nrc, :email, :phone, :address,:is_active)
|
||||
params.require(:user).permit(:name, :nrc, :email, :phone, :address,:is_active,:user_type)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user