update filter order
This commit is contained in:
@@ -320,12 +320,18 @@ class Order < ApplicationRecord
|
||||
|
||||
end
|
||||
|
||||
def self.search(filter,from,to)
|
||||
if !from.nil? && !to.nil?
|
||||
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to)
|
||||
def self.search(filter,from,to,count)
|
||||
if count.to_i > 0
|
||||
item_count = "and item_count = '#{count}'"
|
||||
else
|
||||
# find(:all)
|
||||
where("order_id LIKE ? OR item_count ='#{filter}'","%#{filter}%",)
|
||||
item_count = ''
|
||||
end
|
||||
if from.present? && to.present?
|
||||
Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ? #{item_count}", from,to)
|
||||
elsif !from.present? && !to.present? && count.present?
|
||||
Order.where("item_count = '#{count}'")
|
||||
else
|
||||
Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -414,7 +414,7 @@ class Sale < ApplicationRecord
|
||||
.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to)
|
||||
else
|
||||
sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id")
|
||||
.where("sp.payment_method =? #{keyword} #{custo}",'creditnote')
|
||||
.where("sp.payment_method ='creditnote' #{keyword} #{custo}")
|
||||
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user