barcode update
This commit is contained in:
@@ -29,7 +29,7 @@ a {
|
||||
|
||||
&:hover {
|
||||
color: #fff;
|
||||
// background-color: #000;
|
||||
background-color: #000;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -72,20 +72,21 @@ class BatchLineItem < ApplicationRecord
|
||||
if !find_client.nil?
|
||||
encrypt_key=find_client.secrect_key
|
||||
end
|
||||
attributes = %w{serial_no asset_identity batch_id manufacture_uid asset_type secret_token location security_code}
|
||||
attributes = %w{serial_no asset_identity batch_id manufacture_uid asset_type secret_token location}
|
||||
CSV.generate(headers: true) do |csv|
|
||||
csv << attributes
|
||||
all.each do |encoder|
|
||||
all.each do |encoder|
|
||||
if encoder.product_type_id ==1
|
||||
|
||||
str="account_no="+encoder.asset_identity.to_s+"&manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
|
||||
|
||||
elsif encoder.product_type_id == 3
|
||||
|
||||
attributes = attributes+ %w{security_code}
|
||||
str="account_no="+encoder.asset_identity.to_s+"&manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s+"&security_code="+encoder.security_code.to_s
|
||||
else
|
||||
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
|
||||
else
|
||||
str="manufacture_uid="+encoder.manufacture_uid.to_s+"&serial_no="+encoder.serial_no.to_s
|
||||
end
|
||||
|
||||
# security_code = encoder.security_code
|
||||
# digest = Digest::MD5.hexdigest(security_code)
|
||||
|
||||
encryptd_data=BatchLineItem.encrypted(str,encrypt_key)
|
||||
encoder.secret_token=encryptd_data
|
||||
|
||||
@@ -6,6 +6,7 @@ class Member < ApplicationRecord
|
||||
devise :database_authenticatable, :registerable,
|
||||
:recoverable, :rememberable, :trackable, :validatable,:uid, :confirmable, :lockable
|
||||
|
||||
|
||||
def self.authenticate_session_token(token)
|
||||
if token.nil? || token.blank? || token.to_s == ' '
|
||||
return false
|
||||
|
||||
@@ -14,11 +14,20 @@
|
||||
<label><strong>Select Product:</strong></label>
|
||||
<%= select_tag "product_category", options_from_collection_for_select(@product_categories, "id", "name"), :class => 'form-control'%>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="col-lg-4">
|
||||
<label><strong>Select Batch:</strong></label><br>
|
||||
<select class='selectpicker' id='batch' name='batch[]' multiple= "multiple"></select>
|
||||
<select class='selectpicker' id='batch' name='batch[]' multiple= "multiple"></select>
|
||||
<%= button_tag "Export csv?",:class =>'btn btn-primary btn-sm',:id =>"btnexport" %>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="col-lg-3">
|
||||
<label><strong>Export to Seller:</strong></label>
|
||||
<%= select_tag "seller", options_from_collection_for_select(@sellers, "id", "name"), :class => 'form-control'%>
|
||||
</div>
|
||||
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="row show_image">
|
||||
@@ -50,7 +59,7 @@
|
||||
<th>Asset Identity</th>
|
||||
<th>Manufacture UID</th>
|
||||
<th>Batch No</th>
|
||||
<th>Asset Type</th>
|
||||
<th>Barcode</th>
|
||||
<th>Created At </th>
|
||||
<th>Updated At </th>
|
||||
</tr>
|
||||
@@ -62,7 +71,7 @@
|
||||
<td><%= item.asset_identity rescue '' %></td>
|
||||
<td><%= item.manufacture_uid rescue '' %></td>
|
||||
<td><%= item.batch_name rescue '' %></td>
|
||||
<td><%= item.asset_type rescue '' %></td>
|
||||
<td><%= item.barcode rescue '' %></td>
|
||||
<td><%= item.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td><%= item.updated_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
</tr>
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<%= link_to "Client",clients_path, :class => "nav-link" %>
|
||||
</li>
|
||||
</li>
|
||||
</ul>
|
||||
<div class="float-xs-right">
|
||||
<ul class="nav navbar-nav right">
|
||||
|
||||
@@ -28,6 +28,11 @@
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="col-md-6" id="textbox_group">
|
||||
<div class="form-group">
|
||||
<label for="user_type" class="string optional control-label">User Type:</label>
|
||||
|
||||
<%= f.select(:user_type, ['User', "Seller"], {}, { :class => 'form-control' }) %>
|
||||
</div>
|
||||
<div class ="form-group" >
|
||||
<label for="name" class="string optional control-label">Name:</label>
|
||||
<%= f.input :name ,:label =>false,:error => false,:placeholder =>'Please enter user name',input_html: { class: "form-control" } %>
|
||||
|
||||
@@ -18,26 +18,25 @@
|
||||
<table class="table" style="border-top:none">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Name</th>
|
||||
<th>Name</th>
|
||||
<th>User Type</th>
|
||||
<th>Nrc</th>
|
||||
<th>Email</th>
|
||||
<th>Phone</th>
|
||||
<th>Address</th>
|
||||
<th>Status</th>
|
||||
<th>Created At </th>
|
||||
<th>Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<% @users.each do |user| %>
|
||||
<tr>
|
||||
<td><%= user.name rescue '' %></td>
|
||||
<td><%= user.name rescue '' %></td>
|
||||
<td><%= user.user_type rescue '' %></td>
|
||||
<td><%= user.nrc rescue '' %></td>
|
||||
<td><%= user.email rescue '' %></td>
|
||||
<td><%= user.phone rescue '' %></td>
|
||||
<td><%= user.address rescue '' %></td>
|
||||
<td></td>
|
||||
<td><%= user.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
|
||||
<td></td>
|
||||
<td>
|
||||
<%= link_to 'Detail',
|
||||
user_path(user), :class => 'btn btn-primary btn-sm' %>
|
||||
|
||||
Reference in New Issue
Block a user