Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-11-27 19:42:16 +06:30
10 changed files with 40 additions and 23 deletions

View File

@@ -363,18 +363,18 @@ class Order < ApplicationRecord
end
def self.search(filter,from,to,count)
if count.to_i > 0
item_count = "and item_count = '#{count}'"
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
item_count = ''
keyword = "order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%"
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}'")
if from.present? && to.present?
order = Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to)
query = order.where(keyword)
else
Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%")
end
end

View File

@@ -1,4 +1,4 @@
class PrintSetting < ApplicationRecord
# validations
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height
validates_presence_of :name, :unique_code, :printer_name, :page_width, :page_height, :print_copies
end

View File

@@ -449,7 +449,7 @@ class Sale < ApplicationRecord
sale = Sale.where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and NOT sale_status = 'void' ", from,to)
query = sale.where(keyword)
else
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%")
end
end