From 3db625230428429e4456debdb161ce3661acc352 Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Wed, 14 Jun 2017 00:09:54 +0630 Subject: [PATCH] update search and crm --- app/assets/javascripts/application.js | 3 +- app/assets/stylesheets/application.css | 0 app/assets/stylesheets/application.scss | 2 + .../origami/customers_controller.rb | 2 - app/controllers/settings/orders_controller.rb | 32 --- app/controllers/settings/sales_controller.rb | 32 --- .../transactions/sales_controller.rb | 24 +- app/models/order.rb | 9 + app/models/sale.rb | 3 +- app/views/crm/customers/index.html.erb | 25 +- app/views/crm/customers/show.html.erb | 218 +++++++++--------- app/views/layouts/_header.html.erb | 4 +- app/views/origami/customers/index.html.erb | 23 +- app/views/settings/orders/index.html.erb | 68 ------ app/views/settings/orders/show.html.erb | 85 ------- app/views/settings/sales/index.html.erb | 84 ------- app/views/settings/sales/show.html.erb | 103 --------- app/views/transactions/sales/index.html.erb | 133 ++++++----- app/views/transactions/sales/show.html.erb | 174 +++++++------- config/routes.rb | 5 +- 20 files changed, 352 insertions(+), 677 deletions(-) delete mode 100644 app/assets/stylesheets/application.css delete mode 100644 app/controllers/settings/orders_controller.rb delete mode 100644 app/controllers/settings/sales_controller.rb delete mode 100644 app/views/settings/orders/index.html.erb delete mode 100644 app/views/settings/orders/show.html.erb delete mode 100644 app/views/settings/sales/index.html.erb delete mode 100644 app/views/settings/sales/show.html.erb diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index b0937554..202d4387 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -17,6 +17,8 @@ //= require turbolinks //= require cable //= require settings/processing_items +//= require jquery-ui +//= require bootstrap-datepicker $(document).on("focus", "[data-behaviour~='datepicker']", function(e){ $(this).datepicker({"format": "yyyy-M-dd", "weekStart": 1, "autoclose": true}); @@ -153,4 +155,3 @@ $(function(){ } }); */ ->>>>>>> d54fd19d1c18384ee6b21c43ca51587fb7fa843f diff --git a/app/assets/stylesheets/application.css b/app/assets/stylesheets/application.css deleted file mode 100644 index e69de29b..00000000 diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss index bed2e04f..a4fa6b9f 100644 --- a/app/assets/stylesheets/application.scss +++ b/app/assets/stylesheets/application.scss @@ -2,6 +2,8 @@ @import "bootstrap"; @import "font-awesome"; @import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; /* Show it is fixed to the top */ diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index e3fc7378..3215f9e6 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -10,8 +10,6 @@ class Origami::CustomersController < BaseOrigamiController def show end - - def add_customer @sale_id = params[:sale_id] diff --git a/app/controllers/settings/orders_controller.rb b/app/controllers/settings/orders_controller.rb deleted file mode 100644 index b5bbdc1c..00000000 --- a/app/controllers/settings/orders_controller.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Settings::OrdersController < ApplicationController - def index - - filter = params[:filter] - if filter.nil? - orders = Order.order("order_id desc").limit(1000) - else - order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page]) - if order.count > 0 - orders = order - else - orders = Order.order("order_id desc").limit(1000) - flash[:notice] = "There is no data." - end - end - @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) - respond_to do |format| - format.html # index.html.erb - format.json { render json: @orders } - end - end - def show - - @order = Order.find(params[:id]) - - respond_to do |format| - format.html # show.html.erb - format.json { render json: @order } - end - end - -end diff --git a/app/controllers/settings/sales_controller.rb b/app/controllers/settings/sales_controller.rb deleted file mode 100644 index aabc2282..00000000 --- a/app/controllers/settings/sales_controller.rb +++ /dev/null @@ -1,32 +0,0 @@ -class Settings::SalesController < ApplicationController - def index - - search_date = params[:date] - receipt_no = params[:receipt_no] - today = Date.today - - if receipt_no.nil? - @sales = Sale.order("sale_id").page(params[:page]) - #@products = Product.order("name").page(params[:page]).per(5) - else - @sales = Sale.where("receipt_no LIKE ?", "%#{receipt_no}%").order("receipt_no").page(params[:page]) - end - #@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) - respond_to do |format| - format.html # index.html.erb - format.json { render json: @sales } - end - end - - def show - - @sale = Sale.find(params[:id]) - # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) - respond_to do |format| - format.html # show.html.erb - format.json { render json: @sale } - end - end - - -end \ No newline at end of file diff --git a/app/controllers/transactions/sales_controller.rb b/app/controllers/transactions/sales_controller.rb index ea9e8ccd..edafb1db 100644 --- a/app/controllers/transactions/sales_controller.rb +++ b/app/controllers/transactions/sales_controller.rb @@ -4,12 +4,34 @@ class Transactions::SalesController < ApplicationController # GET /transactions/sales # GET /transactions/sales.json def index - @transactions_sales = Sale.all + + search_date = params[:date] + receipt_no = params[:receipt_no] + today = Date.today + + if receipt_no.nil? + @sales = Sale.order("sale_id").page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) + else + @sales = Sale.search(receipt_no) + end + @sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50) + respond_to do |format| + format.html # index.html.erb + format.json { render json: @sales } + end end # GET /transactions/sales/1 # GET /transactions/sales/1.json def show + + @sale = Sale.find(params[:id]) + # @sale_receivables = SaleReceivable.where('sale_id = ?', @sale.id) + respond_to do |format| + format.html # show.html.erb + format.json { render json: @sale } + end end # GET /transactions/sales/new diff --git a/app/models/order.rb b/app/models/order.rb index 21c00580..10c1a6c2 100644 --- a/app/models/order.rb +++ b/app/models/order.rb @@ -292,6 +292,15 @@ class Order < ApplicationRecord end + def self.search(search) + if search + # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) + where("order_id LIKE ?", "%#{search}%") + else + find(:all) + end + end + private def generate_custom_id diff --git a/app/models/sale.rb b/app/models/sale.rb index c0a73f3d..681bed64 100644 --- a/app/models/sale.rb +++ b/app/models/sale.rb @@ -261,7 +261,8 @@ class Sale < ApplicationRecord def self.search(search) if search - find(:all, :conditions => ['receipt_no LIKE ?', "%#{search}%"]) + # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) + where("receipt_no LIKE ?", "%#{search}%",) else find(:all) end diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 17f207c3..f3819466 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -25,8 +25,8 @@ <%= form_tag crm_customers_path, :method => :get do %> -
- +
+
<% end %> @@ -44,9 +44,9 @@ <% if @crm_customers.count > 0 %> <% @crm_customers.each do |crm_customer| %> - + - + <%= crm_customer.name %> <%= crm_customer.company rescue '-' %> <%= crm_customer.contact_no %> @@ -117,8 +117,9 @@ <%end%>
- - Back +
+
+ Back
@@ -135,11 +136,10 @@ $(function() { $('.datepicker').css('cursor','pointer'); }); - $(document).on('click',".checkbox_check",function(){ - if(this.checked){ - + $(document).on('click',".customer_tr",function(){ + // if(this.checked){ var sale_id = $("#sale_id").val() || 0; - var customer_id = $(this).val(); + var customer_id = $(this).attr('data-ref'); if(sale_id != 0){ // var url = "/"+customer_id; @@ -178,9 +178,9 @@ $(function() { //$(".edit_customer").attr('method', 'PATCH'); } }); - }else{ + // }else{ - } + // } }) function update_sale(customer_id,sale_id) { @@ -205,7 +205,6 @@ $(function() { success: function(data) { if(data.status == true) { - alert('Customer has assigned'); window.location.href = '/origami' }else{ alert('Record not found!'); diff --git a/app/views/crm/customers/show.html.erb b/app/views/crm/customers/show.html.erb index 62ebf9c0..e3530017 100644 --- a/app/views/crm/customers/show.html.erb +++ b/app/views/crm/customers/show.html.erb @@ -1,120 +1,130 @@
-
- -
-
+
+ + + + -
-
- -
-
-
- - - - - - - - - - - - - +
-
- - - - - - - - - <% -puts "hhhhhhhhhhhhhhhhhhhhh" - puts @member_data.to_json %> - - -
NameEmailContact noCompanyDate Of BirthMembership AccountBalanceType
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %> <%= @balance %> <%= @type %>
-
-

Order Items

+
+
+ + + + + + + + + + + + + + + + + + + + + + + +
Name<%= @crm_customer.name %>
Email<%= @crm_customer.email %>
Contact no<%= @crm_customer.contact_no %>
Company<%= @crm_customer.company %>
Date Of Birth<%= @crm_customer.date_of_birth %>
+
+
- - - - - - - - - - - - +
+

Order Details

+
+
Created at Menu ItemQTYUnit Price OptionStatusWaiter
+ + + + + + + + + + + + - - <% @order_items.each do |order_item| %> - - - - - - - - - - <% end %> - -
Order IDMenu ItemQTYUnit Price OptionStatusWaiterCreated at
<%= order_item.created_at %><%= order_item.item_name %><%= order_item.qty %><%= order_item.price %><%= order_item.options %><%= order_item.order_item_status %><%= order_item.item_order_by %>
+ + <% @order_items.each do |order_item| %> + + <%= order_item.order_id %> + <%= order_item.item_name %> + <%= order_item.qty %> + <%= order_item.price %> + <%= order_item.options %> + <%= order_item.order_item_status %> + <%= order_item.item_order_by %> + <%= order_item.created_at.strftime("%d-%m-%y") %> + + <% end %> + + +
+
-

Sale Items

+
+

Sale Details

+
+ + + + + + + + + + + -
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
- - - - - - - - - - + + <% @sale_items.each do |sale_item| %> + + + + + + + + + + <% end %> + +
Sale ID Menu ItemQTYUnit Price Tax PriceCreated At
<%= sale_item.sale_id %><%= sale_item.product_name %><%= sale_item.qty %><%= sale_item.unit_price %><%= sale_item.taxable_price %><%= sale_item.created_at %>
+
+
- - <% @sale_items.each do |sale_item| %> - - <%= sale_item.sale_id %> - <%= sale_item.product_name %> - <%= sale_item.qty %> - <%= sale_item.unit_price %> - - <%= sale_item.taxable_price %> - <%= sale_item.created_at %> - - <% end %> - -
-
-
+ +
+

+ + Back + +
- - - diff --git a/app/views/layouts/_header.html.erb b/app/views/layouts/_header.html.erb index 4a74c7b1..58ecd9b5 100644 --- a/app/views/layouts/_header.html.erb +++ b/app/views/layouts/_header.html.erb @@ -28,8 +28,8 @@