update booking search

This commit is contained in:
Aung Myo
2017-11-15 13:40:09 +06:30
parent 1c0a93d56d
commit 308d9eefde
3 changed files with 10 additions and 10 deletions

View File

@@ -45,14 +45,14 @@ class Booking < ApplicationRecord
if filter.blank?
keyword = ''
else
keyword = "booking_id LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%"
keyword = "booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%"
end
if from.present? && to.present?
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)
booking = Booking.where("DATE_FORMAT(created_at,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(created_at,'%d-%m-%Y') <= ? and NOT booking_status = 'void' ", from,to)
query = booking.where(keyword)
else
where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",)
where("booking_id LIKE ? OR checkin_by LIKE ? OR booking_status LIKE? OR checkout_by LIKE? OR sale_id ='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%","%#{filter}%")
end
end