commit by nda
This commit is contained in:
@@ -73,5 +73,93 @@ class Api::BatchLineItemsController < ApplicationController
|
|||||||
else
|
else
|
||||||
@out=false,'Sorry!Unauthorized user!'
|
@out=false,'Sorry!Unauthorized user!'
|
||||||
end
|
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
|
end
|
||||||
@@ -98,4 +98,6 @@ class Api::BatchesController < ApplicationController
|
|||||||
@out = false, "Sorry!Unauthorized user!"
|
@out = false, "Sorry!Unauthorized user!"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
@@ -179,7 +179,7 @@ class BatchLineItemsController < ApplicationController
|
|||||||
# @out=false,'Sorry!Unauthorized user!'
|
# @out=false,'Sorry!Unauthorized user!'
|
||||||
# end
|
# end
|
||||||
# Generate Code
|
# Generate Code
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
BIN
app/views/api/.DS_Store
vendored
BIN
app/views/api/.DS_Store
vendored
Binary file not shown.
BIN
app/views/api/batch_line_items/.DS_Store
vendored
Normal file
BIN
app/views/api/batch_line_items/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :message, @out[1]
|
||||||
|
json.set! :line_item, @out[2]
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
if @out[0] == true
|
||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :data, @out[1]
|
||||||
|
else
|
||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :message,@out[1]
|
||||||
|
end
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
json.set! :status, @out[0]
|
||||||
|
json.set! :message, @out[1]
|
||||||
BIN
app/views/api/batches/.DS_Store
vendored
Normal file
BIN
app/views/api/batches/.DS_Store
vendored
Normal file
Binary file not shown.
@@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
default: &default
|
default: &default
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
# host: http://192.168.1.81
|
host: localhost
|
||||||
pool: 5
|
pool: 5
|
||||||
timeout: 5000
|
timeout: 5000
|
||||||
encoding: utf8
|
encoding: utf8
|
||||||
@@ -15,8 +15,9 @@ default: &default
|
|||||||
development:
|
development:
|
||||||
<<: *default
|
<<: *default
|
||||||
|
|
||||||
database: nemo_production
|
database: nemo_august
|
||||||
username: mayzin
|
username: nda
|
||||||
|
password: 123
|
||||||
|
|
||||||
default: &default
|
default: &default
|
||||||
adapter: postgresql
|
adapter: postgresql
|
||||||
|
|||||||
@@ -39,11 +39,16 @@ Rails.application.routes.draw do
|
|||||||
post "batches/end" => "batches#batch_end"
|
post "batches/end" => "batches#batch_end"
|
||||||
get "batches/resume_batch" =>"batches#resume_batch"
|
get "batches/resume_batch" =>"batches#resume_batch"
|
||||||
get "batches/batch_progress_list" =>"batches#batch_progress_list"
|
get "batches/batch_progress_list" =>"batches#batch_progress_list"
|
||||||
|
get "get_item_by_batch" =>"batch_line_items#get_item_by_batch"
|
||||||
|
|
||||||
#client
|
#client
|
||||||
get "clients" => 'clients#index'
|
get "clients" => 'clients#index'
|
||||||
|
|
||||||
#product
|
#product
|
||||||
get "products" => "products#index"
|
get "products" => "products#index"
|
||||||
|
|
||||||
|
#batch_line_items
|
||||||
|
post "generate_card_account_items" =>"batch_line_items#generate_card_account_items"
|
||||||
|
post "update_manufacture_uid" => "batch_line_items#update_manufacture_uid"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@@ -14,6 +14,7 @@ ActiveRecord::Schema.define(version: 20180226100816) do
|
|||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
enable_extension "uuid-ossp"
|
||||||
|
|
||||||
create_table "batch_line_items", force: :cascade do |t|
|
create_table "batch_line_items", force: :cascade do |t|
|
||||||
t.integer "batch_id"
|
t.integer "batch_id"
|
||||||
|
|||||||
Reference in New Issue
Block a user