batch_line_item
This commit is contained in:
@@ -35,7 +35,6 @@ class BatchLineItemsController < ApplicationController
|
||||
client_id=params[:client]
|
||||
product_category_id=params[:product_category]
|
||||
|
||||
|
||||
@batchLineItems=nil
|
||||
|
||||
if !batch_list.empty?
|
||||
|
||||
@@ -2,8 +2,53 @@ class BatchesController < ApplicationController
|
||||
skip_before_filter :verify_authenticity_token
|
||||
before_action :authenticate_member!
|
||||
def index
|
||||
@product_category_id=""
|
||||
@clients=Client.all.order('id desc')
|
||||
@product_categories=ProductCategory.all.order('id desc')
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').order('batches.id desc').page(params[:page])
|
||||
@count = Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*').count
|
||||
|
||||
end
|
||||
|
||||
def search
|
||||
client_id=params[:client_id]
|
||||
product_category_id=params[:product_category_id]
|
||||
search_keyword = params[:search_keyword]
|
||||
|
||||
if client_id == "" && product_category_id == "" && search_keyword == "" then
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').order('batches.id desc').page(params[:page])
|
||||
@count = Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*').count
|
||||
|
||||
elsif client_id == "" && product_category_id == "" then
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').where('LOWER(order_ref) like ?', "%#{params[:search_keyword]}%").order('batches.id desc').page(params[:page])
|
||||
@count=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*').where('LOWER(order_ref) like ?', "%#{params[:search_keyword]}%").count
|
||||
|
||||
elsif client_id == "" then
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').where('product_category_id=? and LOWER(order_ref) like ?',params[:product_category_id], "%#{params[:search_keyword]}%").order('batches.id desc').page(params[:page])
|
||||
|
||||
@count=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*').where('product_category_id=? and LOWER(order_ref) like ?',params[:product_category_id], "%#{params[:search_keyword]}%").count
|
||||
|
||||
|
||||
elsif product_category_id == "" then
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').where('client_id=? and LOWER(order_ref) like ?', params[:client_id], "%#{params[:search_keyword]}%").order('batches.id desc').page(params[:page])
|
||||
|
||||
@count=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*').where('client_id=? and LOWER(order_ref) like ?', params[:client_id], "%#{params[:search_keyword]}%").count
|
||||
else
|
||||
@batches=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*,users.name as user_name').where('product_category_id=? and client_id=? and LOWER(order_ref) like ?',params[:product_category_id], params[:client_id], "%#{params[:search_keyword]}%").order('batches.id desc').page(params[:page])
|
||||
@count=Batch.joins('inner join users on users.id=batches.user_id')
|
||||
.select('batches.*').where('product_category_id=? and client_id=? and LOWER(order_ref) like ?',params[:product_category_id], params[:client_id], "%#{params[:search_keyword]}%").count
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user