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/javascripts/transactions.js b/app/assets/javascripts/transactions.js new file mode 100644 index 00000000..12e8ee44 --- /dev/null +++ b/app/assets/javascripts/transactions.js @@ -0,0 +1,7 @@ +//= require jquery +//= require bootstrap +//= require jquery_ujs +//= require turbolinks +//= require cable +//= require jquery-ui +//= require bootstrap-datepicker \ No newline at end of file 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/assets/stylesheets/transactions.scss b/app/assets/stylesheets/transactions.scss new file mode 100644 index 00000000..5ca9b171 --- /dev/null +++ b/app/assets/stylesheets/transactions.scss @@ -0,0 +1,5 @@ +@import "bootstrap"; +@import "font-awesome"; +@import "theme"; +@import "jquery-ui"; +@import "bootstrap-datepicker3"; \ No newline at end of file diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 57f4eafc..eac87e1e 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -10,9 +10,12 @@ class Crm::CustomersController < BaseCrmController @crm_customers = Customer.order("customer_id").page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else - @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end + @crm_customers = Customer.search(filter) + + end #@crm_customers = Customer.all - @crm_customer = Customer.new + @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) + @crm_customer = Customer.new if flash["errors"] @crm_customer.valid? @@ -52,7 +55,7 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("get_all_member_account") - merchant_uid = memberaction.merchant_account_id.to_s + merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s @@ -104,7 +107,7 @@ class Crm::CustomersController < BaseCrmController membership = MembershipSetting.find_by_membership_type("paypar_url") memberaction = MembershipAction.find_by_membership_type("create_membership_customer") - merchant_uid = memberaction.merchant_account_id.to_s + merchant_uid = memberaction.merchant_account_id.to_s auth_token = memberaction.auth_token.to_s url = membership.gateway_url.to_s + memberaction.gateway_url.to_s diff --git a/app/controllers/origami/customers_controller.rb b/app/controllers/origami/customers_controller.rb index 7d0b5502..3215f9e6 100644 --- a/app/controllers/origami/customers_controller.rb +++ b/app/controllers/origami/customers_controller.rb @@ -10,19 +10,22 @@ class Origami::CustomersController < BaseOrigamiController def show end - - def add_customer @sale_id = params[:sale_id] filter = params[:filter] + filter = params[:filter] + if filter.nil? - @crm_customers = Customer.order("name").page params[:page] + @crm_customers = Customer.order("customer_id").page(params[:page]) + #@products = Product.order("name").page(params[:page]).per(5) else - @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page params[:page] + @crm_customers = Customer.search(filter) + end - # @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(2) + #@crm_customers = Customer.all + @crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50) @crm_customer = Customer.new if flash["errors"] 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/settings/orders_controller.rb b/app/controllers/transactions/orders_controller.rb similarity index 61% rename from app/controllers/settings/orders_controller.rb rename to app/controllers/transactions/orders_controller.rb index b5bbdc1c..35cefe6f 100644 --- a/app/controllers/settings/orders_controller.rb +++ b/app/controllers/transactions/orders_controller.rb @@ -1,16 +1,16 @@ -class Settings::OrdersController < ApplicationController +class Transactions::OrdersController < ApplicationController def index filter = params[:filter] if filter.nil? - orders = Order.order("order_id desc").limit(1000) + orders = Order.order("order_id desc") else - order = Order.where("order_id LIKE ?", "%#{filter}%").order("order_id desc").limit(1000).page(params[:page]) + order = Order.search(filter) if order.count > 0 orders = order else - orders = Order.order("order_id desc").limit(1000) - flash[:notice] = "There is no data." + orders = Order.order("order_id desc") + end end @orders = Kaminari.paginate_array(orders).page(params[:page]).per(50) 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/customer.rb b/app/models/customer.rb index b5e101cb..93834b43 100644 --- a/app/models/customer.rb +++ b/app/models/customer.rb @@ -34,12 +34,17 @@ class Customer < ApplicationRecord def self.search(search) if search - find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) + # find(:all, :conditions => ['name LIKE ? OR contact_no LIKE ?', "%#{search}%", "%#{search}%"]) + where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) else find(:all) end end + # def self.search(search) + # where("name LIKE ? OR contact_no LIKE ?", "%#{search}%", "%#{search}%",) + # end + def lastest_invoices sales.where(:customer_id => self.id).order("created_at desc").limit(5) end 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 d72c6a38..f3819466 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -14,7 +14,7 @@
-
+
@@ -25,8 +25,8 @@ <%= form_tag crm_customers_path, :method => :get do %> -
- +
+
<% end %> @@ -42,20 +42,21 @@ - <% @crm_customers.each do |crm_customer| %> - - - - <%= crm_customer.name %> - <%= crm_customer.company %> - <%= crm_customer.contact_no %> - <%= crm_customer.email %> - - <%= link_to 'Show', crm_customer_path(crm_customer) %> - - - - + <% if @crm_customers.count > 0 %> + <% @crm_customers.each do |crm_customer| %> + + + + <%= crm_customer.name %> + <%= crm_customer.company rescue '-' %> + <%= crm_customer.contact_no %> + <%= crm_customer.email %> + <%= link_to 'Show', crm_customer_path(crm_customer) %> + + + <% end %> + <%else%> +

There are no record for your search

<% end %> @@ -66,7 +67,7 @@
-
+
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> @@ -115,6 +116,12 @@
<%end%>
+
@@ -129,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; @@ -172,9 +178,9 @@ $(function() { //$(".edit_customer").attr('method', 'PATCH'); } }); - }else{ + // }else{ - } + // } }) function update_sale(customer_id,sale_id) { @@ -199,7 +205,6 @@ $(function() { success: function(data) { if(data.status == true) { - alert('Customer has assigned'); window.location.href = '/origami' }else{ alert('Record not found!'); @@ -216,7 +221,4 @@ $(function() { } - - - - + \ No newline at end of file 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 %> - -
-
-
+
+
-
- - diff --git a/app/views/crm/customers/showbackup.html.erb b/app/views/crm/customers/showbackup.html.erb new file mode 100644 index 00000000..936192cf --- /dev/null +++ b/app/views/crm/customers/showbackup.html.erb @@ -0,0 +1,85 @@ +
+
+ +
+
+ + +
+
+ +
+
+
+ + + + + + + + + + + + + + + + + + + + + +
NameEmailContact noCompanyDate Of BirthMembership Account
<%= @crm_customer.name %><%= @crm_customer.email %><%= @crm_customer.contact_no %><%= @crm_customer.company %><%= @crm_customer.date_of_birth %>
+
+ + +

Sale Items

+ + + + + + + + + + + + + + + <% @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 %>
+
+
+ +
+ + +
+ + + + + diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 42b559e2..f1a43726 100644 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -21,7 +21,7 @@ <% if !flash["errors"]%> - <%=message%> + <%=message%> <% end %> <% end %> 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 @@