Merge branch 'master' of bitbucket.org:code2lab/nemo_encoder

This commit is contained in:
nandar
2017-02-11 13:22:24 +06:30
8 changed files with 39 additions and 29 deletions

View File

@@ -260,4 +260,10 @@ hr
.show_image{
padding-top: 30px;
}
.multiselect-container{
width: 250px;
}
.ul.multiselect-container > li> a> label{
padding-left: 10px;
}

View File

@@ -10,15 +10,13 @@ class Api::BatchesController < ApplicationController
client_id=params[:client_id]
product_category_id=params[:product_category_id]
find_user=User.find_by_id(check_member.user_id)
created_by=find_user.name
find_client=Client.find_by_id(client_id)
if !find_client.nil?
find_product_category=ProductCategory.find_by_id(product_category_id)
if !find_product_category.nil?
user_id=check_member.user_id
batch = Batch.create_batch(date,order_ref,user_id,created_by,adult_or_child,client_id,product_category_id)
batch = Batch.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
if !batch.nil?
@out=true,batch.id
else
@@ -76,16 +74,16 @@ class Api::BatchesController < ApplicationController
end
def batch_progress_list
session_token=params[:session_token]
created_by=params[:created_by]
user_id=params[:created_by]
check_member= Member.authenticate_session_token(session_token)
if !check_member.nil?
if !created_by.nil?
batches = Batch.where('batch_end is null and created_by=?', created_by)
if !batches.blank?
if !user_id.nil?
batches = Batch.where('batch_end is null and user_id=?', user_id)
if !batches.empty?
@out=true,batches
else
@out = false, "No Batch"
@out = false, batches
end
else
@out = false, "Sorry!Unauthorized user!"

View File

@@ -5,36 +5,35 @@ class BatchLineItemsController < ApplicationController
def index
user_id=current_member.user_id
# user_id=current_member.user_id
@clients=Client.all.order('id asc')
find_client=Client.select(:id).order('id asc').first
if !find_client.nil?
client_id=find_client.id
sub_query="(select * from batches where user_id="+user_id.to_s+" and client_id="+client_id.to_s+")"
sub_query="(select * from batches where client_id="+client_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)
else
sub_query="(select * from batches where user_id="+user_id.to_s+")"
@batchLineItems=BatchLineItem.joins('inner join '+ sub_query + ' as batches on batches.id=batch_line_items.batch_id')
@batchLineItems=BatchLineItem.joins('inner join 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)
end
end
def search
user_id=current_member.user_id
# user_id=current_member.user_id
batch_list=params[:batch]
client_id=params[:client]
@batchLineItems=nil
if !batch_list.empty?
sub_query="(select * from batches where id in ("+batch_list+") and user_id="+user_id.to_s+" and client_id="+client_id.to_s+")"
sub_query="(select * from batches where id in ("+batch_list+") and client_id="+client_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)
else
sub_query="(select * from batches where user_id="+user_id.to_s+" and client_id="+client_id.to_s+")"
sub_query="(select * from batches where client_id="+client_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)
@@ -65,23 +64,27 @@ class BatchLineItemsController < ApplicationController
find_client=Client.find_by_id(client_id)
location_code=find_client.location_code
find_user=User.find_by_id(user_id)
if !find_user.nil?
exported_by=find_user.name
end
if params[:batch].present?
batch_list=params[:batch]
end
if !batch_list.empty?
res=Batch.where("client_id=? and id in (?)",client_id,batch_list).update_all("export_count = export_count + 1")
res=Batch.where("client_id=? and id in (?)",client_id,batch_list).update_all("export_count = export_count + 1,exported_by='"+exported_by+"'")
# sub_query=Batch.where('id in (?)',batch_list).select('*').to_sql
sub_query= "(select * from batches where user_id="+user_id.to_s+" and client_id="+client_id.to_s+")"
sub_query= "(select * from batches where client_id="+client_id.to_s+")"
@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")
else
Batch.where("client_id=? ",client_id).update_all("export_count = export_count + 1")
sub_query="(select * from batches where client_id ="+client_id+" and user_id="+user_id.to_s+")"
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+")"
@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")

View File

@@ -1,9 +1,9 @@
class Batch < ApplicationRecord
has_many :batch_line_item
def self.create_batch(date,order_ref,user_id,created_by,adult_or_child,client_id,product_category_id)
def self.create_batch(date,order_ref,user_id,adult_or_child,client_id,product_category_id)
batch = Batch.new
batch.created_by=created_by
batch.exported_by=""
batch.order_ref = order_ref
batch.date = date
batch.batch_start = true

View File

@@ -120,7 +120,7 @@ class BatchLineItem < ApplicationRecord
end
def self.get_array
arr=Array.new
(1..1000).each do |i|
(1..100).each do |i|
str= SecureRandom.hex
uid=str[0..13]
arr.push(uid)

View File

@@ -130,6 +130,7 @@ $(document).ready(function(){
}
});
}
$("ul.multiselect-container > li> a > label").attr("style","padding-left:10px");
})
</script>

View File

@@ -19,6 +19,7 @@
<th>Qty Success</th>
<th>Qty Fail</th>
<th>Export Count</th>
<th>Exported By</th>
<th>Creatd At</th>
</tr>
</thead>
@@ -31,6 +32,7 @@
<td><%= batch.qty_success rescue '' %></td>
<td><%= batch.qty_fail rescue '' %></td>
<td><%= batch.export_count %></td>
<td><%= batch.exported_by %></td>
<td><%= batch.created_at.strftime("%e,%b %Y %I:%M %p") rescue '' %></td>
</tr>
<% end %>

View File

@@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20170209102414) do
ActiveRecord::Schema.define(version: 20170210103359) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -35,7 +35,7 @@ ActiveRecord::Schema.define(version: 20170209102414) do
t.string "order_ref", null: false
t.boolean "batch_start"
t.boolean "batch_end"
t.string "created_by", null: false
t.string "exported_by", null: false
t.integer "qty_processing", null: false
t.integer "qty_success", null: false
t.integer "qty_fail", null: false