diff --git a/app/controllers/settings/menu_item_instances_controller.rb b/app/controllers/settings/menu_item_instances_controller.rb index f34dc5c5..66f67522 100755 --- a/app/controllers/settings/menu_item_instances_controller.rb +++ b/app/controllers/settings/menu_item_instances_controller.rb @@ -67,7 +67,7 @@ class Settings::MenuItemInstancesController < ApplicationController respond_to do |format| if @settings_menu_item_instances.save - @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].reject(&:blank?) + @settings_menu_item_instances.item_attributes = params[:menu_item_instance][:item_attributes].split("") @settings_menu_item_instances.save format.html { redirect_to settings_menu_category_simple_menu_item_path(category,catID), notice: 'Menu item instance was successfully created.' } format.json { render :show, status: :created, location: @settings_menu_item_instances } diff --git a/app/controllers/transactions/bookings_controller.rb b/app/controllers/transactions/bookings_controller.rb index 3b8e241e..63090c9c 100644 --- a/app/controllers/transactions/bookings_controller.rb +++ b/app/controllers/transactions/bookings_controller.rb @@ -4,7 +4,7 @@ class Transactions::BookingsController < ApplicationController def index - filter = params[:filter] + filter = params[:receipt_no] from = params[:from] to = params[:to] diff --git a/app/controllers/transactions/credit_notes_controller.rb b/app/controllers/transactions/credit_notes_controller.rb index 09f48d66..e35baa77 100755 --- a/app/controllers/transactions/credit_notes_controller.rb +++ b/app/controllers/transactions/credit_notes_controller.rb @@ -14,7 +14,8 @@ class Transactions::CreditNotesController < ApplicationController to = params[:to] if filter.nil? && from.nil? && to.nil? && customer.nil? - @credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) + @credit_notes = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING) + @credit_notes = Kaminari.paginate_array(@credit_notes).page(params[:page]).per(20) else sale = Sale.search_credit_sales(customer,filter,from,to) if sale.count > 0 diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index a76fa385..17a117bb 100755 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -3,16 +3,13 @@ class Transactions::OrdersController < ApplicationController def index filter = params[:filter] - count = params[:count] from = params[:from] to = params[:to] - if filter.nil? && from.nil? && to.nil? && count.nil? + if filter.nil? && from.nil? && to.nil? orders = Order.order("order_id desc") - else - orders = Order.search(filter,from,to,count) - + orders = Order.search(filter,from,to) end if !orders.nil? diff --git a/app/models/order.rb b/app/models/order.rb index 33022eec..dd6f6d66 100755 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -363,18 +363,18 @@ class Order < ApplicationRecord end - def self.search(filter,from,to,count) - if count.to_i > 0 - item_count = "and item_count = '#{count}'" + def self.search(filter,from,to) + if filter.blank? + keyword = '' else - item_count = '' + keyword = "order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%" end - if from.present? && to.present? - Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ? #{item_count}", from,to) - elsif !from.present? && !to.present? && count.present? - Order.where("item_count = '#{count}'") + + if from.present? && to.present? + order = Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to) + query = order.where(keyword) else - Order.where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",) + where("order_id LIKE ? OR status LIKE ? OR order_type LIKE ? OR source='#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%") end end diff --git a/app/models/sale.rb b/app/models/sale.rb index 17f49a12..14ff6266 100755 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -449,7 +449,7 @@ class Sale < ApplicationRecord 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) else - where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%",) + where("receipt_no LIKE ? OR cashier_name LIKE ? OR sale_status ='#{filter}'","%#{filter}%","%#{filter}%") end end diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 091d8e51..89900056 100755 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -11,7 +11,7 @@