From e2e8045d0fc989b1f885eeaf94503ef3c4525f7e Mon Sep 17 00:00:00 2001 From: Aung Myo Date: Fri, 9 Jun 2017 11:55:50 +0630 Subject: [PATCH] update crm layout --- app/assets/javascripts/CRM.js | 17 ++++ app/controllers/crm/bookings_controller.rb | 2 +- app/controllers/crm/customers_controller.rb | 16 +-- .../crm/dining_queues_controller.rb | 2 +- app/controllers/crm/home_controller.rb | 3 +- app/views/crm/customers/_form.html.erb | 10 +- app/views/crm/customers/index.html.erb | 99 +++++++++---------- app/views/crm/home/_booking.html.erb | 13 +-- app/views/crm/home/index.html.erb | 7 +- app/views/layouts/CRM.html.erb | 4 +- app/views/layouts/_header_crm.html.erb | 2 +- config/initializers/assets.rb | 4 + config/routes.rb | 4 +- 13 files changed, 98 insertions(+), 85 deletions(-) create mode 100644 app/assets/javascripts/CRM.js diff --git a/app/assets/javascripts/CRM.js b/app/assets/javascripts/CRM.js new file mode 100644 index 00000000..66f161af --- /dev/null +++ b/app/assets/javascripts/CRM.js @@ -0,0 +1,17 @@ +// This is a manifest file that'll be compiled into application.js, which will include all the files +// listed below. +// +// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, +// or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. +// +// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the +// compiled file. JavaScript code in this file should be added after the last require_* statement. +// +// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details +// about supported directives. +// +//= require jquery +//= require bootstrap +//= require jquery_ujs +//= require turbolinks +//= require cable \ No newline at end of file diff --git a/app/controllers/crm/bookings_controller.rb b/app/controllers/crm/bookings_controller.rb index eeb19f75..65511512 100644 --- a/app/controllers/crm/bookings_controller.rb +++ b/app/controllers/crm/bookings_controller.rb @@ -1,4 +1,4 @@ -class Crm::BookingsController < ApplicationController +class Crm::BookingsController < BaseCrmController def update_booking booking = Booking.find(params[:booking_id]) diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index fff260e2..886f66d6 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -1,4 +1,4 @@ -class Crm::CustomersController < ApplicationController +class Crm::CustomersController < BaseCrmController before_action :set_crm_customer, only: [:show, :edit, :update, :destroy] # GET /crm/customers @@ -8,18 +8,17 @@ class Crm::CustomersController < ApplicationController filter = params[:filter] if filter.nil? - @crm_custome = Customer.order("name").page(params[:page]) + @crm_customers = Customer.order("name").page(params[:page]) #@products = Product.order("name").page(params[:page]).per(5) else - @crm_custome = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) + @crm_customers = Customer.where("name LIKE ?", "%#{filter}%").order("name").page(params[:page]) end - @crm_customers = Kaminari.paginate_array(@crm_custome).page(params[:page]).per(5) #@crm_customers = Customer.all @crm_customer = Customer.new - # @membership = Customer.get_member_group - # if @membership["status"] == true - # @member_group = @membership["data"] - # end + @membership = Customer.get_member_group + if @membership["status"] == true + @member_group = @membership["data"] + end respond_to do |format| format.html # index.html.erb format.json { render json: @crm_customers } @@ -74,6 +73,7 @@ class Crm::CustomersController < ApplicationController if response["status"] == true puts "hhhhhhhhhhhhhhhhhh" puts params[:sale_id] + puts response.to_json customer = Customer.find(@crm_customers.customer_id) status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) if params[:sale_id] != 0 diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index 235703d2..9e8cd06c 100644 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -1,4 +1,4 @@ -class Crm::DiningQueuesController < ApplicationController +class Crm::DiningQueuesController < BaseCrmController before_action :set_dining_queue, only: [:show, :edit, :update, :destroy] # GET /crm/dining_queues diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb index c8d919e5..d1ee475b 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -5,7 +5,8 @@ class Crm::HomeController < BaseCrmController @customer = Customer.all from = Time.now.beginning_of_day.utc to = Time.now.end_of_day.utc - @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to) + @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') + # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) end diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb index 9e1046c3..c913651a 100644 --- a/app/views/crm/customers/_form.html.erb +++ b/app/views/crm/customers/_form.html.erb @@ -16,13 +16,5 @@ <%= f.button :submit %> <% end %> - + \ No newline at end of file diff --git a/app/views/crm/customers/index.html.erb b/app/views/crm/customers/index.html.erb index 786a9f42..d76c94ac 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -68,52 +68,64 @@
- <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> - - - <%= f.hidden_field :id, :class => "form-control col-md-6 " %> - -
- <%= f.input :name, :class => "form-control col-md-6 name" %> + <%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %> + + + <%= f.hidden_field :id, :class => "form-control col-md-6 " %> +
+ <%= f.button :submit, "Update Customer",:class => 'btn btn-primary btn-sm', :disabled =>'', :id => 'update_customer' %> +
+
+ <%= f.input :name, :class => "form-control col-md-6 name" %> -
-
- <%= f.input :company, :class => "form-control col-md-6 company" %> -
-
- <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> +
+
+ <%= f.input :company, :class => "form-control col-md-6 company" %> +
+
+ <%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %> -
+
-
- <%= f.input :email, :class => "form-control col-md-6 email" %> +
+ <%= f.input :email, :class => "form-control col-md-6 email" %> +
+ +
+ + <%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%> +
+ +
+
-
- - <%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%> -
- - - -
- <%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %> -
-
- <%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %> - -
-
- <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> - <%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %> -
- <%end%> +
+ <%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
+
+ <%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %> +
+ +
+ <%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %> +
+ + <%end%>
+
+ + diff --git a/app/views/crm/home/_booking.html.erb b/app/views/crm/home/_booking.html.erb index b9cf7296..5d865002 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -38,7 +38,6 @@ $(function(){ $(".booking_click").on("click", function(){ - $(this).css('background-color', '#CCC'); $(".summary-items tbody tr").remove(); $("#cancel").removeAttr("disabled"); $("#assign").removeAttr("disabled"); @@ -94,7 +93,6 @@ $(function(){ $(".customer_detail").on("click", function(){ - $(this).css('background-color', '#CCC'); $(".summary-items tbody tr").remove(); $("#crm_print").removeAttr("disabled"); var id = $(this).attr('data-ref'); @@ -118,13 +116,14 @@ function show_details(url_item){ success: function(data) { item_data = data.order_items; //console.log(item_data.length); - + $("#table").text(data.table_name) $("#order_at").text(data.checkin_at) $("#order_by").text(data.checkin_by) $("#assign").val(data.id) $("#cancel").val(data.id) - + $('.no_record').addClass('hide'); + for(var field in item_data) { if (item_data[field].item_name){ var price = parseFloat(item_data[field].price).toFixed(2); @@ -157,13 +156,14 @@ function customer_details(id){ $("#for-booking").remove(); var div_data = "CUSTOMER DETAILS"; $("#order-title").replaceWith(div_data); - + $('.no_record').addClass('hide'); $('.customer-detail').removeClass('hide') ; $("#cus_name").text(data.name) $("#cus_email").text(data.email) $("#cus_contact_no").text(data.contact_no) + if(item_data.length>0){ for(var field in item_data) { if (item_data[field].item_name){ @@ -178,7 +178,8 @@ function customer_details(id){ $(".summary-items tbody").append(row); } }else{ - + $('.no_record').removeClass('hide'); + $("#crm_print").attr("disabled","disabled"); } } }); diff --git a/app/views/crm/home/index.html.erb b/app/views/crm/home/index.html.erb index 787b2e39..0912ee70 100644 --- a/app/views/crm/home/index.html.erb +++ b/app/views/crm/home/index.html.erb @@ -18,7 +18,7 @@
-
+
<%= render :partial => 'queue' %>
@@ -30,7 +30,7 @@
-
+
<%= render :partial => 'customer' %>
@@ -90,6 +90,9 @@ Qty Price + + No Order Items + diff --git a/app/views/layouts/CRM.html.erb b/app/views/layouts/CRM.html.erb index 41de0ca2..fb851d68 100644 --- a/app/views/layouts/CRM.html.erb +++ b/app/views/layouts/CRM.html.erb @@ -9,8 +9,8 @@ SmartSales : Restaurant <%= csrf_meta_tags %> - <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> - <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> + <%= stylesheet_link_tag 'CRM', media: 'all', 'data-turbolinks-track': 'reload' %> + <%= javascript_include_tag 'CRM', 'data-turbolinks-track': 'reload' %> diff --git a/app/views/layouts/_header_crm.html.erb b/app/views/layouts/_header_crm.html.erb index 31dee08d..e004853e 100644 --- a/app/views/layouts/_header_crm.html.erb +++ b/app/views/layouts/_header_crm.html.erb @@ -4,7 +4,7 @@ CRM
- Queue | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %> + <%= link_to 'Queue', crm_dining_queues_path, :html=>":color:white" %> | Bookings | Online Orders | <%= link_to 'Customer', crm_customers_path, :html=>":color:white" %>
diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 6f563b42..fe5eec86 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -18,3 +18,7 @@ Rails.application.config.assets.precompile += %w( OQS.css ) Rails.application.config.assets.precompile += %w( OQS.js ) Rails.application.config.assets.precompile += %w( settings.css ) + +# --- Customer/ Customer - Crm ---- +Rails.application.config.assets.precompile += %w( CRM.css ) +Rails.application.config.assets.precompile += %w( CRM.js ) diff --git a/config/routes.rb b/config/routes.rb index e2e58781..aa3c878f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,10 +94,10 @@ Rails.application.routes.draw do #--------- Customer Relationship Management ------------# namespace :crm do - root "home#index" #queue number - get 'customers/:sale_id/assign_sale_id', to: "customers#get_sale_id", :as => "assign_sale"#get sale id with customer for crm + root "home#index" resources :customers resources :dining_queues + get 'customers/:sale_id/assign_sale_id', to: "customers#get_sale_id", :as => "assign_sale"#get sale id with customer for crm post "update_booking" , to: "bookings#update_booking", as: "update_booking"#assign and cancel post "update_sale" , to: "home#update_sale_by_customer"#update customer id in sale table get '/print/:id', to: "home#print_order"#print order for crm