diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb index b826cd52..66418caa 100644 --- a/app/controllers/transactions/bookings_controller.rb +++ b/app/controllers/transactions/bookings_controller.rb @@ -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 diff --git a/app/models/booking.rb b/app/models/booking.rb index b65063a4..826d585d 100755 --- a/app/models/booking.rb +++ b/app/models/booking.rb @@ -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 diff --git a/app/views/transactions/bookings/index.html.erb b/app/views/transactions/bookings/index.html.erb index 997d18b5..99eccc45 100755 --- a/app/views/transactions/bookings/index.html.erb +++ b/app/views/transactions/bookings/index.html.erb @@ -15,7 +15,7 @@ - <%= form_tag transactions_orders_path, :method => :get do %> + <%= form_tag transactions_bookings_path, :method => :get do %>