update shift sale detail

This commit is contained in:
Aung Myo
2017-11-16 10:03:01 +06:30
parent bf0a8135f6
commit ccbdd5b2c8
10 changed files with 442 additions and 0 deletions

View File

@@ -135,4 +135,20 @@ class ShiftSale < ApplicationRecord
end
def self.search(filter,from,to)
if filter.blank?
keyword = ''
else
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?
booking = ShiftSale.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("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
end