diff --git a/app/controllers/origami/shifts_controller.rb b/app/controllers/origami/shifts_controller.rb index f7690fef..b9298a32 100644 --- a/app/controllers/origami/shifts_controller.rb +++ b/app/controllers/origami/shifts_controller.rb @@ -42,10 +42,6 @@ class Origami::ShiftsController < BaseOrigamiController @total_amount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'amount') @total_discount_by_account = ShiftSale.calculate_total_price_by_accounts(@shift,'discount') - - puts "sssssssssss" - puts @total_amount_by_account.to_json - # get printer info print_settings=PrintSetting.find_by_unique_code(unique_code) diff --git a/app/controllers/transactions/orders_controller.rb b/app/controllers/transactions/orders_controller.rb index 4df88787..bd079d83 100644 --- a/app/controllers/transactions/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -3,18 +3,17 @@ 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? + if filter.nil? && from.nil? && to.nil? && count.nil? orders = Order.order("order_id desc") + puts "ssssss" else - orders = Order.search(filter,from,to) - # if order.count > 0 - # orders = order - # else - # orders = Order.order("order_id desc") - # end + orders = Order.search(filter,from,to,count) + puts "aaaaa" + end if !orders.nil? @@ -22,6 +21,7 @@ class Transactions::OrdersController < ApplicationController else @orders = [] end + puts @orders.to_json respond_to do |format| format.html # index.html.erb format.json { render json: @orders } diff --git a/app/models/order.rb b/app/models/order.rb index 4d54f41f..398fb0f2 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -320,12 +320,18 @@ class Order < ApplicationRecord end - def self.search(filter,from,to) - if !from.nil? && !to.nil? - Order.where("DATE_FORMAT(date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(date,'%d-%m-%Y') <= ?", from,to) + def self.search(filter,from,to,count) + if count.to_i > 0 + item_count = "and item_count = '#{count}'" else - # find(:all) - where("order_id LIKE ? OR item_count ='#{filter}'","%#{filter}%",) + item_count = '' + 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}'") + else + Order.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 57794048..b06dc54f 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -414,7 +414,7 @@ class Sale < ApplicationRecord .where("DATE_FORMAT(receipt_date,'%d-%m-%Y') >= ?" + " AND DATE_FORMAT(receipt_date,'%d-%m-%Y') <= ? and sp.payment_method = 'creditnote' #{keyword} #{custo}", from,to) else sale = Sale.all.joins("JOIN sale_payments sp on sp.sale_id = sales.sale_id") - .where("sp.payment_method =? #{keyword} #{custo}",'creditnote') + .where("sp.payment_method ='creditnote' #{keyword} #{custo}") end diff --git a/app/views/transactions/credit_notes/index.html.erb b/app/views/transactions/credit_notes/index.html.erb index ac291115..19327139 100644 --- a/app/views/transactions/credit_notes/index.html.erb +++ b/app/views/transactions/credit_notes/index.html.erb @@ -43,7 +43,7 @@
- +
<% end %> diff --git a/app/views/transactions/orders/index.html.erb b/app/views/transactions/orders/index.html.erb index 21cae24a..180c9d5b 100644 --- a/app/views/transactions/orders/index.html.erb +++ b/app/views/transactions/orders/index.html.erb @@ -14,13 +14,17 @@
<%= form_tag transactions_orders_path, :method => :get do %>
- +
- - +
+ + + 0 +
+
@@ -32,7 +36,7 @@
- +
<% end %> @@ -76,6 +80,132 @@
+ +