change query for transactions/order and transactions/bookings, transactions/credit

This commit is contained in:
phyusin
2017-11-27 18:16:46 +06:30
parent 9ad9e9ae57
commit ad34002789
8 changed files with 19 additions and 21 deletions

View File

@@ -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 }

View File

@@ -4,7 +4,7 @@ class Transactions::BookingsController < ApplicationController
def index
filter = params[:filter]
filter = params[:receipt_no]
from = params[:from]
to = params[:to]

View File

@@ -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

View File

@@ -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?

View File

@@ -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

View File

@@ -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

View File

@@ -11,7 +11,7 @@
</div>
<div class="row clearfix">
<div class="col-lg-9 col-md-9 col-sm-9">
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="card">
<div class="body table-responsive">
<table class="table table-hover table-striped">
@@ -83,7 +83,7 @@
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-3">
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card">
<div class="body" id="custom-slimscroll">
<%= render 'new_form', crm_customer: @crm_customer, taxes: @taxes %>

View File

@@ -19,7 +19,7 @@
<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>
<input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="" style="margin-right: 10px">
<input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="Booking/Sale ID" style="margin-right: 10px">
</div>
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
<label class=""><%= t("views.right_panel.detail.from") %></label>