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

@@ -10,12 +10,12 @@ class Transactions::BookingsController < ApplicationController
if filter.nil? && from.nil? && to.nil? if filter.nil? && from.nil? && to.nil?
@bookings = Booking.all.order("sale_id desc") @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 else
sale = Sale.search(filter,from,to) booking = Booking.search(filter,from,to)
if sale.count > 0 if booking.count > 0
@bookings = sale @bookings = booking
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2) @bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(20)
else else
@bookings = 0 @bookings = 0
end end

View File

@@ -45,14 +45,14 @@ class Booking < ApplicationRecord
if filter.blank? if filter.blank?
keyword = '' keyword = ''
else 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 end
if from.present? && to.present? 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) 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 = sale.where(keyword) query = booking.where(keyword)
else 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
end end

View File

@@ -15,7 +15,7 @@
<tbody> <tbody>
<tr> <tr>
<td colspan="8"> <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="row clearfix">
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4"> <div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
<label><%= t("views.right_panel.detail.enter_keyboards") %></label> <label><%= t("views.right_panel.detail.enter_keyboards") %></label>