diff --git a/Gemfile b/Gemfile index 551503f9..1487492d 100644 --- a/Gemfile +++ b/Gemfile @@ -61,7 +61,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 93c2a58f..e7deca12 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) @@ -109,7 +110,6 @@ GEM nokogiri (1.7.2) mini_portile2 (~> 2.1.0) pdf-core (0.7.0) - pg (0.20.0) prawn (2.2.2) pdf-core (~> 0.7.0) ttfunk (~> 1.5) @@ -238,6 +238,7 @@ DEPENDENCIES database_cleaner factory_girl_rails (~> 4.0) faker + filterrific font-awesome-rails httparty (~> 0.15.5) jbuilder (~> 2.5) @@ -245,7 +246,6 @@ DEPENDENCIES kaminari (~> 0.16.3) listen (~> 3.0.5) mysql2 (>= 0.3.18, < 0.5) - pg prawn prawn-table puma (~> 3.0) 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/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 295a0d8f..fff260e2 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -5,12 +5,21 @@ class Crm::CustomersController < ApplicationController # GET /crm/customers.json def index @sale_id = 0 - @crm_customers = Customer.all - @crm_customer = Customer.new - @membership = Customer.get_member_group - if @membership["status"] == true - @member_group = @membership["data"] + filter = params[:filter] + + if filter.nil? + @crm_custome = 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]) 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 respond_to do |format| format.html # index.html.erb format.json { render json: @crm_customers } diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb new file mode 100644 index 00000000..235703d2 --- /dev/null +++ b/app/controllers/crm/dining_queues_controller.rb @@ -0,0 +1,74 @@ +class Crm::DiningQueuesController < ApplicationController + 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..c8d919e5 100644 --- a/app/controllers/crm/home_controller.rb +++ b/app/controllers/crm/home_controller.rb @@ -1,8 +1,12 @@ 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) + # .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 6d2bd561..b0667206 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/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..9e1046c3 100644 --- a/app/views/crm/customers/_form.html.erb +++ b/app/views/crm/customers/_form.html.erb @@ -16,5 +16,13 @@ <%= 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..786a9f42 100644 --- a/app/views/crm/customers/index.html.erb +++ b/app/views/crm/customers/index.html.erb @@ -11,7 +11,7 @@ -
+
@@ -21,6 +21,17 @@ + + + + @@ -48,6 +59,9 @@ <% end %>
+ <%= form_tag crm_customers_path, :method => :get do %> +
+ + +
+ <% end %> +
Select Name
+
+

asdfj;l

+ <%= paginate @crm_customers %>
@@ -81,15 +95,7 @@ <%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%> -
- -
+
diff --git a/app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder b/app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder new file mode 100644 index 00000000..f2580e52 --- /dev/null +++ b/app/views/crm/dining_queues/_crm_dining_queue.json.jbuilder @@ -0,0 +1,2 @@ +json.extract! crm_dining_queue, :id, :name, :contact, :queue_no, :created_at, :updated_at +json.url crm_dining_queue_url(crm_dining_queue, format: :json) diff --git a/app/views/crm/dining_queues/_form.html.erb b/app/views/crm/dining_queues/_form.html.erb new file mode 100644 index 00000000..a99f6b76 --- /dev/null +++ b/app/views/crm/dining_queues/_form.html.erb @@ -0,0 +1,16 @@ + +<%= simple_form_for([:crm,@dining_queue]) do |f| %> + <%= f.error_notification %> + +
+ <%= f.input :name %> + <%= f.input :contact_no %> + <%= f.input :queue_no %> + +
+ +
+ <%= f.button :submit %> +
+<% end %> + diff --git a/app/views/crm/dining_queues/edit.html.erb b/app/views/crm/dining_queues/edit.html.erb new file mode 100644 index 00000000..e5ca3b9f --- /dev/null +++ b/app/views/crm/dining_queues/edit.html.erb @@ -0,0 +1,11 @@ + +
+ + <%= render 'form', dining_queue: @dining_queue %> +
diff --git a/app/views/crm/dining_queues/index.html.erb b/app/views/crm/dining_queues/index.html.erb new file mode 100644 index 00000000..e7834b98 --- /dev/null +++ b/app/views/crm/dining_queues/index.html.erb @@ -0,0 +1,38 @@ + + + + +
+
+ + + + + + + + + + + + <% @dining_queues.each do |dining_queue| %> + + + + + + + <% end %> + +
NameContact NoQueue NoAction
<%= 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?' } %>
+
+ diff --git a/app/views/crm/dining_queues/index.json.jbuilder b/app/views/crm/dining_queues/index.json.jbuilder new file mode 100644 index 00000000..979087b7 --- /dev/null +++ b/app/views/crm/dining_queues/index.json.jbuilder @@ -0,0 +1 @@ +json.array! @crm_dining_queues, partial: 'crm_dining_queues/crm_dining_queue', as: :crm_dining_queue diff --git a/app/views/crm/dining_queues/new.html.erb b/app/views/crm/dining_queues/new.html.erb new file mode 100644 index 00000000..280a59b2 --- /dev/null +++ b/app/views/crm/dining_queues/new.html.erb @@ -0,0 +1,11 @@ + +
+ + <%= render 'form', dining_queue: @dining_queue %> +
\ No newline at end of file diff --git a/app/views/crm/dining_queues/show.html.erb b/app/views/crm/dining_queues/show.html.erb new file mode 100644 index 00000000..5e52a611 --- /dev/null +++ b/app/views/crm/dining_queues/show.html.erb @@ -0,0 +1,19 @@ +

<%= 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..b9cf7296 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" %>
-
- -

- <%= @i += 1 %> . <%= booking.dining_facility.name %> - - <%= booking.id %> -

- -

- - Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %> - -

-
-