qr code generate

This commit is contained in:
nandar
2018-03-05 11:07:59 +06:30
parent 55bf089d8d
commit b81a6dbc96
10 changed files with 190 additions and 15 deletions

View File

@@ -2,7 +2,7 @@ class BatchLineItemsController < ApplicationController
require "csv"
skip_before_filter :verify_authenticity_token
before_action :authenticate_member!
require 'digest/md5'
def index
# user_id=current_member.user_id
@@ -99,13 +99,13 @@ class BatchLineItemsController < ApplicationController
@batchLineItems = BatchLineItem.joins('inner join '+sub_query +" as batches on batches.id=batch_line_items.batch_id")
.joins('inner join product_categories product on product.id=batches.product_category_id')
.where('batch_id in (?)',batch_list)
.select("*,product.product_type_id ,product.name,'' as secret_token,'' as location")
.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+"'")
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')
.select("*,product.product_type_id ,product.name,'' as secret_token,'' as location")
.select("*,product.product_type_id ,product.name,'' as secret_token,'' as location_name")
end
datestr= Time.now.strftime("%Y/%m/%d %H:%M:%S")
@@ -115,4 +115,71 @@ class BatchLineItemsController < ApplicationController
format.csv { send_data @batchLineItems.to_csv(client_id,location_code), filename: "#{filename}.csv" }
end
end
def generate_cards
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?
puts 'hkjfklasj'
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?
# 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)
total_count+=1
end
respond_to do |format|
format.html { redirect_to batch_url(batch_id), notice: 'Successfully generated.' }
format.json { head :no_content }
end
# 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
end