diff --git a/Gemfile b/Gemfile
index 01a87af7..02dca6af 100644
--- a/Gemfile
+++ b/Gemfile
@@ -59,6 +59,8 @@ gem 'sidekiq'
# Pagination
gem 'kaminari', '~> 0.16.3'
+# Datatable
+gem 'filterrific'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
diff --git a/Gemfile.lock b/Gemfile.lock
index 051e1595..4235d035 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -72,6 +72,7 @@ GEM
faker (1.7.3)
i18n (~> 0.5)
ffi (1.9.18)
+ filterrific (2.1.2)
font-awesome-rails (4.7.0.2)
railties (>= 3.2, < 5.2)
globalid (0.4.0)
@@ -238,6 +239,7 @@ DEPENDENCIES
database_cleaner
factory_girl_rails (~> 4.0)
faker
+ filterrific
font-awesome-rails
httparty (~> 0.15.5)
jbuilder (~> 2.5)
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/assets/javascripts/crm/dining_queues.coffee b/app/assets/javascripts/crm/dining_queues.coffee
new file mode 100644
index 00000000..24f83d18
--- /dev/null
+++ b/app/assets/javascripts/crm/dining_queues.coffee
@@ -0,0 +1,3 @@
+# Place all the behaviors and hooks related to the matching controller here.
+# All this logic will automatically be available in application.js.
+# You can use CoffeeScript in this file: http://coffeescript.org/
diff --git a/app/assets/stylesheets/CRM.scss b/app/assets/stylesheets/CRM.scss
index b0f802f1..f43cc3f9 100644
--- a/app/assets/stylesheets/CRM.scss
+++ b/app/assets/stylesheets/CRM.scss
@@ -7,3 +7,5 @@
// min-height: 75rem;
// padding-top: 4.5rem;
// }
+
+
diff --git a/app/controllers/api/customers_controller.rb b/app/controllers/api/customers_controller.rb
index 8ce2041c..2adc7c8a 100644
--- a/app/controllers/api/customers_controller.rb
+++ b/app/controllers/api/customers_controller.rb
@@ -9,4 +9,9 @@ class Api::CustomersController < ActionController::API
def show
@customer = Customer.find_by(params[:id])
end
+
+ #Show customer detail by Order item
+ def get_customer_order
+ @customer = Customer.find(params[:id])
+ end
end
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 325ac7dd..7896fa45 100644
--- a/app/controllers/crm/customers_controller.rb
+++ b/app/controllers/crm/customers_controller.rb
@@ -1,11 +1,19 @@
-class Crm::CustomersController < ApplicationController
+class Crm::CustomersController < BaseCrmController
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy]
# GET /crm/customers
# GET /crm/customers.json
def index
@sale_id = 0
- @crm_customers = Customer.all
+ filter = params[:filter]
+
+ if filter.nil?
+ @crm_customers = Customer.order("name").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.all
@crm_customer = Customer.new
@membership = Customer.get_member_group
if @membership["status"] == true
@@ -65,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
@@ -133,7 +142,7 @@ class Crm::CustomersController < ApplicationController
else
- format.html { render :edit }
+ format.html { render :index }
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb
new file mode 100644
index 00000000..9e8cd06c
--- /dev/null
+++ b/app/controllers/crm/dining_queues_controller.rb
@@ -0,0 +1,74 @@
+class Crm::DiningQueuesController < BaseCrmController
+ before_action :set_dining_queue, only: [:show, :edit, :update, :destroy]
+
+ # GET /crm/dining_queues
+ # GET /crm/dining_queues.json
+ def index
+ @dining_queues = DiningQueue.all
+ end
+
+ # GET /crm/dining_queues/1
+ # GET /crm/dining_queues/1.json
+ def show
+ end
+
+ # GET /crm/dining_queues/new
+ def new
+ @dining_queue = DiningQueue.new
+ end
+
+ # GET /crm/dining_queues/1/edit
+ def edit
+ end
+
+ # POST /crm/dining_queues
+ # POST /crm/dining_queues.json
+ def create
+ @dining_queue = DiningQueue.new(dining_queue_params)
+
+ respond_to do |format|
+ if @dining_queue.save
+ format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully created.' }
+ format.json { render :show, status: :created, location: @dining_queue }
+ else
+ format.html { render :new }
+ format.json { render json: @dining_queue.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # PATCH/PUT /crm/dining_queues/1
+ # PATCH/PUT /crm/dining_queues/1.json
+ def update
+ respond_to do |format|
+ if @dining_queue.update(dining_queue_params)
+ format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully updated.' }
+ format.json { render :show, status: :ok, location: @dining_queue }
+ else
+ format.html { render :edit }
+ format.json { render json: @dining_queue.errors, status: :unprocessable_entity }
+ end
+ end
+ end
+
+ # DELETE /crm/dining_queues/1
+ # DELETE /crm/dining_queues/1.json
+ def destroy
+ @dining_queue.destroy
+ respond_to do |format|
+ format.html { redirect_to crm_dining_queues_path, notice: 'Dining queue was successfully destroyed.' }
+ format.json { head :no_content }
+ end
+ end
+
+ private
+ # Use callbacks to share common setup or constraints between actions.
+ def set_dining_queue
+ @dining_queue = DiningQueue.find(params[:id])
+ end
+
+ # Never trust parameters from the scary internet, only allow the white list through.
+ def dining_queue_params
+ params.require(:dining_queue).permit(:name, :contact_no, :queue_no)
+ end
+end
diff --git a/app/controllers/crm/home_controller.rb b/app/controllers/crm/home_controller.rb
index 9ae2b413..d1ee475b 100644
--- a/app/controllers/crm/home_controller.rb
+++ b/app/controllers/crm/home_controller.rb
@@ -1,8 +1,13 @@
class Crm::HomeController < BaseCrmController
def index
- @booking = Booking.all
+ @booking = Booking.all
@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).order('queue_no ASC')
+
+ # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
end
diff --git a/app/helpers/crm/dining_queues_helper.rb b/app/helpers/crm/dining_queues_helper.rb
new file mode 100644
index 00000000..af60bd52
--- /dev/null
+++ b/app/helpers/crm/dining_queues_helper.rb
@@ -0,0 +1,2 @@
+module Crm::DiningQueuesHelper
+end
diff --git a/app/models/crm.rb b/app/models/crm.rb
new file mode 100644
index 00000000..3407e215
--- /dev/null
+++ b/app/models/crm.rb
@@ -0,0 +1,5 @@
+module Crm
+ def self.table_name_prefix
+ 'crm_'
+ end
+end
diff --git a/app/models/customer.rb b/app/models/customer.rb
index afc17d79..3286a319 100644
--- a/app/models/customer.rb
+++ b/app/models/customer.rb
@@ -9,7 +9,8 @@ class Customer < ApplicationRecord
validates_presence_of :name, :contact_no, :email
validates :contact_no, uniqueness: true
validates :email, uniqueness: true
-
+
+ paginates_per 50
def self.get_member_group
@@ -30,6 +31,14 @@ class Customer < ApplicationRecord
end
+ def self.search(search)
+ if search
+ find(:all, :conditions => ['name LIKE ?', "%#{search}%"])
+ else
+ find(:all)
+ end
+ end
+
def lastest_invoices
sales.where(:customer_id => self.id).order("created_at desc").limit(5)
end
diff --git a/app/models/dining_queue.rb b/app/models/dining_queue.rb
new file mode 100644
index 00000000..dfcc5b43
--- /dev/null
+++ b/app/models/dining_queue.rb
@@ -0,0 +1,3 @@
+class DiningQueue < ApplicationRecord
+
+end
diff --git a/app/pdf/crm_order_pdf.rb b/app/pdf/crm_order_pdf.rb
index 94fc5503..55d08ecc 100644
--- a/app/pdf/crm_order_pdf.rb
+++ b/app/pdf/crm_order_pdf.rb
@@ -1,6 +1,6 @@
class CrmOrderPdf < Prawn::Document
attr_accessor :receipt_width,:price_column_width,:p_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_column_width,:item_description_width
- def initialize(booking,order_items,print_settings)
+ def initialize(booking,order_items,printer_settings)
self.p_width = 200
self.page_height = 1450
self.margin = 10
@@ -18,20 +18,19 @@ class CrmOrderPdf < Prawn::Document
@half_qty = @qty_width / 2
#setting page margin and width
super(:margin => [self.margin, self.margin, self.margin, self.margin], :page_size => [self.p_width, self.page_height])
- self.header_font_size = 7
+ self.header_font_size = 10
self.item_font_size = 9
- header( booking.type, booking.dining_facility.name)
+ header( printer_settings.printer_name, printer_settings.name)
stroke_horizontal_rule
- order_detail(booking.checkin_by,booking.checkin_at,booking.dining_facility.name)
+ cashier_info(booking)
line_items(order_items)
- #all_total(order_items)
end
- def header (type, name)
- text "#{type}", :size => self.header_font_size,:align => :center
+ def header (printer_name, name)
+ text "#{printer_name}", :size => self.header_font_size,:align => :center
move_down 5
text "#{name}", :size => self.header_font_size,:align => :center
# move_down self.item_height
@@ -41,37 +40,37 @@ class CrmOrderPdf < Prawn::Document
end
- def order_detail(order_by,order_at,customer)
+ def cashier_info(booking)
move_down 5
move_down 2
y_position = cursor
- qty_column_width = self.p_width * 0.2
- item_description_width = self.p_width * 0.5
- price_column_width = self.p_width * 0.3
+ bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
+ text "Order By:", :size => self.item_font_size,:align => :left
+ end
-
-
- stroke_horizontal_rule
+ bounding_box([self.price_width, y_position], :width =>self.receipt_width) do
+ text "#{booking.checkin_by}" , :size => self.item_font_size, :align => :left
+ end
move_down 5
+
y_position = cursor
- pad_top(15) {
- # @item_width.to_i + @half_qty.to_i
- text_box "Order By", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
- text_box "Order At", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
- text_box "Customer", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
-
- }
-
+ bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
+ text "Customer:", :size => self.item_font_size,:align => :left
+ end
+ bounding_box([self.price_width,y_position], :width =>self.price_width) do
+ text "#{booking.customer_id}" , :size => self.item_font_size,:align => :left
+ end
move_down 5
- stroke_horizontal_rule
-y_position = cursor
- pad_top(15) {
- text_box "#{order_by}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
- text_box "#{order_at.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
- text_box "#{customer}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
-
- }
+ y_position = cursor
+ bounding_box([0,y_position], :width =>self.price_width, :height => self.item_height) do
+ text "Date:", :size => self.item_font_size,:align => :left
+ end
+ bounding_box([self.price_width,y_position], :width =>self.price_width) do
+ text "#{booking.checkin_at.strftime('%Y %m %d %h:%m')}" , :size => self.item_font_size,:align => :left
+ end
+ # stroke_horizontal_rule
+ move_down 5
end
def line_items(order_items)
@@ -97,10 +96,41 @@ y_position = cursor
move_down 5
stroke_horizontal_rule
-
+ add_line_item_row(order_items)
+
end
-
+ def add_line_item_row(order_items)
+ y_position = cursor
+ move_down 5
+ sub_total = 0.0
+ order_items.each do |item|
+
+ sub_total += item.qty*item.price
+ qty = item.qty
+ total_price = item.qty*item.price
+ price = item.price
+ item_name = item.item_name
+
+
+ y_position = cursor
+
+ pad_top(15) {
+ # @item_width.to_i + @half_qty.to_i
+ text_box "#{item_name}", :at =>[0,y_position], :width => @item_width.to_i - @half_qty.to_i , :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size
+ text_box "#{price}", :at =>[@item_width.to_i - @half_qty.to_i,y_position], :width => @qty_width, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
+ text_box "#{qty.to_i}", :at =>[@item_width.to_i-@qty_width,y_position], :width => @half_qty, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
+ text_box "#{total_price}", :at =>[@item_width.to_i + @half_qty.to_i,y_position], :width => @double, :height =>15, :overflow => :shrink_to_fix, :size => self.item_font_size, :align => :right
+
+ }
+ move_down 3
+ end
+ stroke_horizontal_rule
+ move_down 5
+ y_position = cursor
+
+ end
+
end
diff --git a/app/views/api/customers/get_customer_order.json.jbuilder b/app/views/api/customers/get_customer_order.json.jbuilder
new file mode 100644
index 00000000..f00ce173
--- /dev/null
+++ b/app/views/api/customers/get_customer_order.json.jbuilder
@@ -0,0 +1,38 @@
+if (@customer)
+ json.id @customer.customer_id
+ json.name @customer.name
+ json.email @customer.email
+ json.contact_no @customer.contact_no
+ json.date_of_birth @customer.date_of_birth
+
+
+ @total_amount = 0.00
+ @total_tax = 0.00
+
+ if @customer.orders
+ order_items = []
+ @customer.orders.each do |bo|
+ order = Order.find(bo.order_id)
+ #if (order.status == "new")
+ order_items = order_items + order.order_items
+ #end
+ end
+
+ json.order_items order_items do |item|
+ json.item_instance_code item.item_code
+ json.item_name item.item_name
+ json.price item.price
+ json.qty item.qty
+ json.options item.options
+ json.remark item.remark
+ json.item_status item.order_item_status
+ @total_amount = @total_amount + (item.price * item.qty)
+ end
+
+ end
+
+ json.sub_total @total_amount
+ json.commerical_tax @total_amount * 0.05
+ json.total @total_amount + (@total_amount * 0.05)
+
+end
\ No newline at end of file
diff --git a/app/views/crm/customers/_form.html.erb b/app/views/crm/customers/_form.html.erb
index 758a52a2..c913651a 100644
--- a/app/views/crm/customers/_form.html.erb
+++ b/app/views/crm/customers/_form.html.erb
@@ -16,5 +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 86f267b0..184bce41 100644
--- a/app/views/crm/customers/index.html.erb
+++ b/app/views/crm/customers/index.html.erb
@@ -11,7 +11,7 @@
-
+
|
+ <%= form_tag crm_customers_path, :method => :get do %>
+
+
+
+
+ <% end %>
+ |
+ |||||
| Select | Name | @@ -48,40 +59,43 @@ <% end %>||||
|---|---|---|---|---|---|
| Name | +Contact No | +Queue No | +Action | +
|---|---|---|---|
| <%= dining_queue.name %> | +<%= dining_queue.contact_no %> | +<%= dining_queue.queue_no %> | ++ <%= link_to 'Edit', edit_crm_dining_queue_path(dining_queue) %> | <%= link_to 'Destroy', crm_dining_queue_path(dining_queue), method: :delete, data: { confirm: 'Are you sure?' } %> | +
<%= notice %>
+ ++ Name: + <%= @crm_dining_queue.name %> +
+ ++ Contact: + <%= @crm_dining_queue.contact %> +
+ ++ Queue no: + <%= @crm_dining_queue.queue_no %> +
+ +<%= link_to 'Edit', edit_crm_dining_queue_path(@crm_dining_queue) %> | +<%= link_to 'Back', crm_dining_queues_path %> diff --git a/app/views/crm/dining_queues/show.json.jbuilder b/app/views/crm/dining_queues/show.json.jbuilder new file mode 100644 index 00000000..83c09bea --- /dev/null +++ b/app/views/crm/dining_queues/show.json.jbuilder @@ -0,0 +1 @@ +json.partial! "crm_dining_queues/crm_dining_queue", crm_dining_queue: @crm_dining_queue diff --git a/app/views/crm/home/_booking.html.erb b/app/views/crm/home/_booking.html.erb index 3a2a7684..5d865002 100644 --- a/app/views/crm/home/_booking.html.erb +++ b/app/views/crm/home/_booking.html.erb @@ -6,29 +6,29 @@ <% @booking.each do |booking| %> <% if booking.booking_status == "new" %><%= booking.id %>
-- - Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %> - -
-