update booking search
This commit is contained in:
@@ -10,12 +10,12 @@ class Transactions::BookingsController < ApplicationController
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@bookings = Booking.all.order("sale_id desc")
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2)
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search(filter,from,to)
|
||||
if sale.count > 0
|
||||
@bookings = sale
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2)
|
||||
booking = Booking.search(filter,from,to)
|
||||
if booking.count > 0
|
||||
@bookings = booking
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
|
||||
else
|
||||
@bookings = 0
|
||||
end
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
<tbody>
|
||||
<tr>
|
||||
<td colspan="8">
|
||||
<%= form_tag transactions_orders_path, :method => :get do %>
|
||||
<%= form_tag transactions_bookings_path, :method => :get do %>
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
|
||||
<label><%= t("views.right_panel.detail.enter_keyboards") %></label>
|
||||
|
||||
Reference in New Issue
Block a user