Merge branch 'crm' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
2
Gemfile
2
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
|
||||
|
||||
@@ -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)
|
||||
|
||||
17
app/assets/javascripts/CRM.js
Normal file
17
app/assets/javascripts/CRM.js
Normal file
@@ -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
|
||||
3
app/assets/javascripts/crm/dining_queues.coffee
Normal file
3
app/assets/javascripts/crm/dining_queues.coffee
Normal file
@@ -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/
|
||||
@@ -7,3 +7,5 @@
|
||||
// min-height: 75rem;
|
||||
// padding-top: 4.5rem;
|
||||
// }
|
||||
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
class Crm::BookingsController < ApplicationController
|
||||
class Crm::BookingsController < BaseCrmController
|
||||
|
||||
def update_booking
|
||||
booking = Booking.find(params[:booking_id])
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
74
app/controllers/crm/dining_queues_controller.rb
Normal file
74
app/controllers/crm/dining_queues_controller.rb
Normal file
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
2
app/helpers/crm/dining_queues_helper.rb
Normal file
2
app/helpers/crm/dining_queues_helper.rb
Normal file
@@ -0,0 +1,2 @@
|
||||
module Crm::DiningQueuesHelper
|
||||
end
|
||||
5
app/models/crm.rb
Normal file
5
app/models/crm.rb
Normal file
@@ -0,0 +1,5 @@
|
||||
module Crm
|
||||
def self.table_name_prefix
|
||||
'crm_'
|
||||
end
|
||||
end
|
||||
@@ -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
|
||||
|
||||
3
app/models/dining_queue.rb
Normal file
3
app/models/dining_queue.rb
Normal file
@@ -0,0 +1,3 @@
|
||||
class DiningQueue < ApplicationRecord
|
||||
|
||||
end
|
||||
@@ -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
|
||||
|
||||
38
app/views/api/customers/get_customer_order.json.jbuilder
Normal file
38
app/views/api/customers/get_customer_order.json.jbuilder
Normal file
@@ -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
|
||||
@@ -16,5 +16,5 @@
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
<!-- -->
|
||||
<!---->
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
</ol>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="col-lg-8">
|
||||
@@ -21,6 +21,17 @@
|
||||
<table class="table table-striped">
|
||||
|
||||
<thead>
|
||||
|
||||
<tr>
|
||||
<td colspan="6">
|
||||
<%= form_tag crm_customers_path, :method => :get do %>
|
||||
<div class="input-append form-group pull-left">
|
||||
<input type="text" name="filter" placeholder="Search" class="form-control input-sm col-md-8">
|
||||
<button type="submit" class="btn btn-primary btn-sm">Search</button>
|
||||
</div>
|
||||
<% end %>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th>Select</th>
|
||||
<th>Name</th>
|
||||
@@ -48,40 +59,43 @@
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
<%= paginate @crm_customers %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-4">
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :name, :class => "form-control col-md-6 name" %>
|
||||
<%= simple_form_for @crm_customer,:url => crm_customers_path, :method => :post do |f| %>
|
||||
<span class="patch_method"></span>
|
||||
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
|
||||
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :name, :class => "form-control col-md-6 name" %>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :company, :class => "form-control col-md-6 company" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :company, :class => "form-control col-md-6 company" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :contact_no, :class => "form-control col-md-6 contact_no" %>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :email, :class => "form-control col-md-6 email" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :email, :class => "form-control col-md-6 email" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label>Date Of Birth</label>
|
||||
<%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label>Date Of Birth</label>
|
||||
<%= f.text_field :date_of_birth,:class=>"form-control date_of_birth datepicker"%>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<select class="selectpicker form-control col-md-12" name="membership_id">
|
||||
<option>Select Member Group</option>
|
||||
<% @member_group.each do |member| %>
|
||||
@@ -92,22 +106,24 @@
|
||||
</div>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
|
||||
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_type, :class => "form-control col-md-6 membership_type" %>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<%= f.input :membership_authentication_code, :class => "form-control col-md-6 membership_authentication_code" %>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<%= f.button :submit, "Submit",:class => 'btn btn-primary ', :id => 'submit_customer' %>
|
||||
<%= f.button :submit, "Update",:class => 'btn btn-primary ', :disabled =>'', :id => 'update_customer' %>
|
||||
</div>
|
||||
<%end%>
|
||||
</div>
|
||||
<%end%>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.css">
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery-confirm/3.2.0/jquery-confirm.min.js"></script>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(function () {
|
||||
if (jQuery().datepicker) {
|
||||
@@ -207,23 +223,6 @@
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*function changeMethod() {
|
||||
$("#update_customer").attr('method', 'put');
|
||||
}*/
|
||||
|
||||
|
||||
/* $("#update_customer").click(function() {
|
||||
$("#new_customer").attr('class', 'edit_customer');
|
||||
var id = "edit_customer_"+$('#customer_id').val();alert(id);
|
||||
$("#new_customer").attr('id', id);
|
||||
alert(";;")
|
||||
//$('#new_customer').removeClass('new_customer');
|
||||
//$('#new_customer').addClass('edit_customer')
|
||||
}); */
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -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)
|
||||
16
app/views/crm/dining_queues/_form.html.erb
Normal file
16
app/views/crm/dining_queues/_form.html.erb
Normal file
@@ -0,0 +1,16 @@
|
||||
|
||||
<%= simple_form_for([:crm,@dining_queue]) do |f| %>
|
||||
<%= f.error_notification %>
|
||||
|
||||
<div class="form-inputs">
|
||||
<%= f.input :name %>
|
||||
<%= f.input :contact_no %>
|
||||
<%= f.input :queue_no %>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="form-actions">
|
||||
<%= f.button :submit %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
11
app/views/crm/dining_queues/edit.html.erb
Normal file
11
app/views/crm/dining_queues/edit.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= crm_dining_queues_path %>">Queue</a></li>
|
||||
<li>Edit</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', dining_queue: @dining_queue %>
|
||||
</div>
|
||||
38
app/views/crm/dining_queues/index.html.erb
Normal file
38
app/views/crm/dining_queues/index.html.erb
Normal file
@@ -0,0 +1,38 @@
|
||||
|
||||
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= %>">Home</a></li>
|
||||
<li>Queue</li>
|
||||
<span style="float: right">
|
||||
<%= link_to t('.new', :default => t("helpers.links.new")),new_crm_dining_queue_path,:class => 'btn btn-primary btn-sm' %>
|
||||
</span>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<br>
|
||||
<div class="card">
|
||||
<table class="table table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:25%">Name</th>
|
||||
<th style="width:25%">Contact No</th>
|
||||
<th style="width:25%">Queue No</th>
|
||||
<th style="width:25%">Action</th>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<% @dining_queues.each do |dining_queue| %>
|
||||
<tr>
|
||||
<td><%= dining_queue.name %></td>
|
||||
<td><%= dining_queue.contact_no %></td>
|
||||
<td><%= dining_queue.queue_no %></td>
|
||||
<td>
|
||||
<%= 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?' } %></td>
|
||||
</tr>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
1
app/views/crm/dining_queues/index.json.jbuilder
Normal file
1
app/views/crm/dining_queues/index.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.array! @crm_dining_queues, partial: 'crm_dining_queues/crm_dining_queue', as: :crm_dining_queue
|
||||
11
app/views/crm/dining_queues/new.html.erb
Normal file
11
app/views/crm/dining_queues/new.html.erb
Normal file
@@ -0,0 +1,11 @@
|
||||
|
||||
<div class="span12">
|
||||
<div class="page-header">
|
||||
<ul class="breadcrumb">
|
||||
<li><a href="<%= root_path %>">Home</a></li>
|
||||
<li><a href="<%= crm_dining_queues_path %>">Queue</a></li>
|
||||
<li>New</li>
|
||||
</ul>
|
||||
</div>
|
||||
<%= render 'form', dining_queue: @dining_queue %>
|
||||
</div>
|
||||
19
app/views/crm/dining_queues/show.html.erb
Normal file
19
app/views/crm/dining_queues/show.html.erb
Normal file
@@ -0,0 +1,19 @@
|
||||
<p id="notice"><%= notice %></p>
|
||||
|
||||
<p>
|
||||
<strong>Name:</strong>
|
||||
<%= @crm_dining_queue.name %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Contact:</strong>
|
||||
<%= @crm_dining_queue.contact %>
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<strong>Queue no:</strong>
|
||||
<%= @crm_dining_queue.queue_no %>
|
||||
</p>
|
||||
|
||||
<%= link_to 'Edit', edit_crm_dining_queue_path(@crm_dining_queue) %> |
|
||||
<%= link_to 'Back', crm_dining_queues_path %>
|
||||
1
app/views/crm/dining_queues/show.json.jbuilder
Normal file
1
app/views/crm/dining_queues/show.json.jbuilder
Normal file
@@ -0,0 +1 @@
|
||||
json.partial! "crm_dining_queues/crm_dining_queue", crm_dining_queue: @crm_dining_queue
|
||||
@@ -6,29 +6,29 @@
|
||||
<% @booking.each do |booking| %>
|
||||
<% if booking.booking_status == "new" %>
|
||||
<div class="card">
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
</h4>
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="card-block booking_click" data-id="sfddf" data-ref="<%= api_booking_path booking.id%>" id="card-block booking_block" >
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
</h4>
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
@@ -38,67 +38,94 @@
|
||||
$(function(){
|
||||
|
||||
$(".booking_click").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#cancel").removeAttr("disabled");
|
||||
$("#assign").removeAttr("disabled");
|
||||
|
||||
var booking_id = $(this).find(".booking-id").text();
|
||||
$("#crm_print").val(booking_id);
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#cancel").removeAttr("disabled");
|
||||
$("#assign").removeAttr("disabled");
|
||||
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
var booking_id = $(this).find(".booking-id").text();
|
||||
$("#crm_print").val(booking_id);
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
|
||||
});
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
|
||||
}); //End Booking Click
|
||||
|
||||
$('.nav-link').click(function () {
|
||||
var href = $(this).attr('href');
|
||||
if(href== "#customer" || href == "#queue"){
|
||||
$("#cancel").attr("disabled","disabled");
|
||||
$("#assign").attr("disabled","disabled");
|
||||
}
|
||||
});
|
||||
//End nav-liik
|
||||
|
||||
$('.crm_print').click(function() {
|
||||
var booking_id = $('#crm_print').val();
|
||||
var booking_id = $('#crm_print').val();
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "crm/print/"+booking_id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "crm/print/"+booking_id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
//End Print Click
|
||||
|
||||
$('.assign').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
|
||||
update_booking(booking_id,type)
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
//End Assing Click
|
||||
|
||||
$('.cancel').click(function(e){
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
var booking_id = $(this).val()
|
||||
var type = $(this).attr("data-type")
|
||||
|
||||
update_booking(booking_id,type)
|
||||
update_booking(booking_id,type)
|
||||
});
|
||||
//End cancle Click
|
||||
|
||||
|
||||
$(".customer_detail").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
$("#crm_print").removeAttr("disabled");
|
||||
var id = $(this).attr('data-ref');
|
||||
$('.customer_detail').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
customer_details(id);
|
||||
|
||||
});
|
||||
//end customer click
|
||||
|
||||
|
||||
});
|
||||
|
||||
function show_details(url_item){
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
item_data = data.order_items;
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
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){
|
||||
if (item_data[field].item_name){
|
||||
var price = parseFloat(item_data[field].price).toFixed(2);
|
||||
|
||||
row = "<tr>"
|
||||
@@ -106,32 +133,82 @@ function show_details(url_item){
|
||||
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
|
||||
+'<td style="width:33%; text-align:right">' + price + '</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
});
|
||||
//end Ajax
|
||||
$('.booking_click').removeClass('selected-item');
|
||||
$(this).addClass('selected-item');
|
||||
}
|
||||
|
||||
function customer_details(id){
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "api/customers/get_order/"+id,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
item_data = data.order_items;
|
||||
|
||||
$("#for-booking").remove();
|
||||
var div_data = "<strong>CUSTOMER DETAILS</strong>";
|
||||
$("#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){
|
||||
var price = parseFloat(item_data[field].price).toFixed(2);
|
||||
|
||||
row = "<tr>"
|
||||
+'<td style="width:33%; text-align:left">' + item_data[field].item_name +'</td>'
|
||||
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
|
||||
+'<td style="width:33%; text-align:right">' + price + '</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
}else{
|
||||
$('.no_record').removeClass('hide');
|
||||
$("#crm_print").attr("disabled","disabled");
|
||||
}
|
||||
}
|
||||
});
|
||||
//End Ajax
|
||||
}
|
||||
|
||||
function update_booking(booking_id,type) {
|
||||
//Start Ajax
|
||||
$.ajax({
|
||||
type: "POST",
|
||||
url: "update_booking/" ,
|
||||
data: {booking_id:booking_id,type:type},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true && data.type == "cancel")
|
||||
{
|
||||
alert('Booking has canceled!');
|
||||
}else{
|
||||
alert('Booking has completed!');
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});
|
||||
type: "POST",
|
||||
url: "update_booking/" ,
|
||||
data: {booking_id:booking_id,type:type},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if(data.status == true && data.type == "cancel")
|
||||
{
|
||||
alert('Booking has canceled!');
|
||||
}else{
|
||||
alert('Booking has completed!');
|
||||
}
|
||||
location.reload();
|
||||
}
|
||||
});//End Ajax
|
||||
}
|
||||
|
||||
</script>
|
||||
</script>
|
||||
|
||||
<style type="text/css">
|
||||
.selected-item {
|
||||
background-color: #ccc;
|
||||
}
|
||||
</style>
|
||||
@@ -1,7 +1,7 @@
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<% @customer.each do |customer| %>
|
||||
<div class="card">
|
||||
<div class="card customer_detail" data-ref="<%= customer.id%>">
|
||||
<div class="card-block">
|
||||
<!-- <h4 class="card-title">Customer Name : <%= customer.name %></h4> -->
|
||||
<p class="card-text">Name : <%= customer.name %></p>
|
||||
|
||||
@@ -1,33 +1,21 @@
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
|
||||
<% @i = 0 %>
|
||||
<% @booking.each do |booking| %>
|
||||
<% if booking.booking_status == "assign" %>
|
||||
<div class="card booking_click" data-ref="<%= api_booking_path booking.id%>" id="booking_block">
|
||||
<div class="card-block" id="card-block" style="width:100%;">
|
||||
<p class="hidden booking-id"><%= booking.id %></p>
|
||||
<% @queue.each do |queue| %>
|
||||
|
||||
<div class="card">
|
||||
<div class="card-block" style="width:100%;">
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
<%= @i += 1 %> . <%= queue.name %>
|
||||
</h4>
|
||||
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
Contact No - <%= queue.contact_no %>
|
||||
</p>
|
||||
</div>
|
||||
<!-- <div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button id="assign" data-ref="<%= booking.id%>" data-type="complete" class="btn assign btn-primary btn-sm btn-block">ASSIGN</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button id="cancel" data-ref="<%= booking.id%>" data-type="cancel" class="btn btn-danger cancel btn-sm btn-block">CANCLE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<% end %>
|
||||
</div>
|
||||
@@ -5,32 +5,32 @@
|
||||
<!-- Nav tabs -->
|
||||
<ul class="nav nav-tabs" role="tablist">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Queue <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","assign").count %></span></a>
|
||||
<a class="nav-link" data-toggle="tab" href="#queue" role="tab">Queue <span class="badge badge-pill badge-default"><%= @queue.count %></span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","new").count %></span></a>
|
||||
<a class="nav-link active" data-toggle="tab" href="#booking" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.where("booking_status=?","new").count %></span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Customers</a>
|
||||
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Customers</a>
|
||||
</li>
|
||||
</ul>
|
||||
<!-- Nav tabs - End -->
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<!--- Panel 0 - Completed -->
|
||||
<div class="tab-pane" id="completed" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<div class="tab-pane" id="queue" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<%= render :partial => 'queue' %>
|
||||
|
||||
</div>
|
||||
<!-- Panel 1 - Tables -->
|
||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||
<div class="tab-pane active" id="booking" role="tabpanel">
|
||||
|
||||
<%= render :partial => 'booking' %>
|
||||
|
||||
</div>
|
||||
<!-- Panel 1 - Tables - End -->
|
||||
<!-- Panel 2 - Rooms -->
|
||||
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<div class="tab-pane" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:">
|
||||
<%= render :partial => 'customer' %>
|
||||
</div>
|
||||
<!-- Panel 2 - Rooms - End -->
|
||||
@@ -47,12 +47,12 @@
|
||||
<div id="station"></div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<table class="table" >
|
||||
<table class="table for-booking" id="for-booking">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:33%; text-align:left">Order By</th>
|
||||
<th style="width:33%; text-align:center;">Order At</td>
|
||||
<th style="width:33%; text-align:right">Customer</td>
|
||||
<th style="width:33%; text-align:center;">Order At</th>
|
||||
<th style="width:33%; text-align:right">Customer</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -67,17 +67,38 @@
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table customer-detail hide">
|
||||
<thead>
|
||||
<tr>
|
||||
<td style="width:44%; text-align:center"><strong>Name</strong></td>
|
||||
<td style="width:44%; text-align:" id="cus_name"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:44%; text-align:center"><strong>Email</strong></td>
|
||||
<td style="width:44%; text-align:" id="cus_email"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:44%; text-align:center"><strong>Contact No</strong></td>
|
||||
<td style="width:44%; text-align:" id="cus_contact_no"></td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:33%; text-align:left">Items</th>
|
||||
<th style="width:33%; text-align:center">Qty</th>
|
||||
<th style="width:33%; text-align:right">Price</td>
|
||||
<th style="width:33%; text-align:right">Price</th>
|
||||
</tr>
|
||||
<tr class="hide no_record">
|
||||
<td style="width:44%; text-align:center;" id="no_record">No Order Items</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
<div class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<table class="table summary-items">
|
||||
<tbody>
|
||||
@@ -95,12 +116,10 @@
|
||||
<button id="crm_print" value="" disabled="disabled" data-type="assign" class="btn crm_print btn-primary btn-lg btn-block" >
|
||||
Print
|
||||
</button>
|
||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button>
|
||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Print <br/>Order<br/>Summary</button> -->
|
||||
<button id="assign" value="" disabled="disabled" data-type="assign" class="btn assign btn-primary btn-lg btn-block">ASSIGN</button>
|
||||
<button id="cancel" value="" disabled="disabled" data-type="cancel" class="btn btn-danger cancel btn-lg btn-block">CANCLE</button>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
<title>SmartSales : Restaurant</title>
|
||||
<%= 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' %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<strong>CRM</strong>
|
||||
</div>
|
||||
<div style="float:left;margin-top:3px;text-align:left; width:600px">
|
||||
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" %>
|
||||
</div>
|
||||
|
||||
<div style="float:right; margin-top:3px; text-align:right;width:200px;color:#ffffff">
|
||||
|
||||
@@ -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 )
|
||||
|
||||
10
config/initializers/kaminari_config.rb
Normal file
10
config/initializers/kaminari_config.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
Kaminari.configure do |config|
|
||||
# config.default_per_page = 25
|
||||
# config.max_per_page = nil
|
||||
# config.window = 4
|
||||
# config.outer_window = 0
|
||||
# config.left = 0
|
||||
# config.right = 0
|
||||
# config.page_method_name = :page
|
||||
# config.param_name = :page
|
||||
end
|
||||
@@ -1,23 +1,17 @@
|
||||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
||||
views:
|
||||
pagination:
|
||||
first: "« First"
|
||||
last: "Last »"
|
||||
previous: "‹ Prev"
|
||||
next: "Next ›"
|
||||
truncate: "…"
|
||||
helpers:
|
||||
page_entries_info:
|
||||
one_page:
|
||||
display_entries:
|
||||
zero: "No %{entry_name} found"
|
||||
one: "Displaying <b>1</b> %{entry_name}"
|
||||
other: "Displaying <b>all %{count}</b> %{entry_name}"
|
||||
more_pages:
|
||||
display_entries: "Displaying %{entry_name} <b>%{first} - %{last}</b> of <b>%{total}</b> in total"
|
||||
|
||||
@@ -51,7 +51,9 @@ Rails.application.routes.draw do
|
||||
|
||||
#Current active bookings
|
||||
resources :bookings, only: [:index, :show, :create, :update]
|
||||
resources :customers, only: [:index, :show, :create, :update]
|
||||
resources :customers
|
||||
#get customer details by order items
|
||||
get "customers/get_order/:id" => "customers#get_customer_order"
|
||||
|
||||
#Generating Invoice and making payments - output render @sale
|
||||
resources :invoices, only: [:index, :show, :create, :update, :destroy ] do
|
||||
@@ -97,9 +99,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
|
||||
|
||||
12
db/migrate/20170608105644_create_crm_dining_queues.rb
Normal file
12
db/migrate/20170608105644_create_crm_dining_queues.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
class CreateCrmDiningQueues < ActiveRecord::Migration[5.1]
|
||||
def change
|
||||
create_table :crm_dining_queues do |t|
|
||||
t.string :name
|
||||
t.string :contact_no
|
||||
t.string :queue_no
|
||||
t.string :status
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Crm::BookingsController, type: :controller do
|
||||
|
||||
end
|
||||
@@ -1,159 +0,0 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
||||
# It demonstrates how one might use RSpec to specify the controller code that
|
||||
# was generated by Rails when you ran the scaffold generator.
|
||||
#
|
||||
# It assumes that the implementation code is generated by the rails scaffold
|
||||
# generator. If you are using any extension libraries to generate different
|
||||
# controller code, this generated spec may or may not pass.
|
||||
#
|
||||
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
||||
# of tools you can use to make these specs even more expressive, but we're
|
||||
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
||||
#
|
||||
# Compared to earlier versions of this generator, there is very limited use of
|
||||
# stubs and message expectations in this spec. Stubs are only used when there
|
||||
# is no simpler way to get a handle on the object needed for the example.
|
||||
# Message expectations are only used when there is no simpler way to specify
|
||||
# that an instance is receiving a specific message.
|
||||
|
||||
RSpec.describe Crm::CustomersController, type: :controller do
|
||||
|
||||
# This should return the minimal set of attributes required to create a valid
|
||||
# Crm::Customer. As you add validations to Crm::Customer, be sure to
|
||||
# adjust the attributes here as well.
|
||||
let(:valid_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
let(:invalid_attributes) {
|
||||
skip("Add a hash of attributes invalid for your model")
|
||||
}
|
||||
|
||||
# This should return the minimal set of values that should be in the session
|
||||
# in order to pass any filters (e.g. authentication) defined in
|
||||
# Crm::CustomersController. Be sure to keep this updated too.
|
||||
let(:valid_session) { {} }
|
||||
|
||||
describe "GET #index" do
|
||||
it "assigns all crm_customers as @crm_customers" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
get :index, params: {}, session: valid_session
|
||||
expect(assigns(:crm_customers)).to eq([customer])
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #show" do
|
||||
it "assigns the requested crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
get :show, params: {id: customer.to_param}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #new" do
|
||||
it "assigns a new crm_customer as @crm_customer" do
|
||||
get :new, params: {}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to be_a_new(Crm::Customer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "GET #edit" do
|
||||
it "assigns the requested crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
get :edit, params: {id: customer.to_param}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
end
|
||||
|
||||
describe "POST #create" do
|
||||
context "with valid params" do
|
||||
it "creates a new Crm::Customer" do
|
||||
expect {
|
||||
post :create, params: {crm_customer: valid_attributes}, session: valid_session
|
||||
}.to change(Crm::Customer, :count).by(1)
|
||||
end
|
||||
|
||||
it "assigns a newly created crm_customer as @crm_customer" do
|
||||
post :create, params: {crm_customer: valid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to be_a(Crm::Customer)
|
||||
expect(assigns(:crm_customer)).to be_persisted
|
||||
end
|
||||
|
||||
it "redirects to the created crm_customer" do
|
||||
post :create, params: {crm_customer: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(Crm::Customer.last)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns a newly created but unsaved crm_customer as @crm_customer" do
|
||||
post :create, params: {crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to be_a_new(Crm::Customer)
|
||||
end
|
||||
|
||||
it "re-renders the 'new' template" do
|
||||
post :create, params: {crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(response).to render_template("new")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "PUT #update" do
|
||||
context "with valid params" do
|
||||
let(:new_attributes) {
|
||||
skip("Add a hash of attributes valid for your model")
|
||||
}
|
||||
|
||||
it "updates the requested crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: new_attributes}, session: valid_session
|
||||
customer.reload
|
||||
skip("Add assertions for updated state")
|
||||
end
|
||||
|
||||
it "assigns the requested crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: valid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
|
||||
it "redirects to the crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: valid_attributes}, session: valid_session
|
||||
expect(response).to redirect_to(customer)
|
||||
end
|
||||
end
|
||||
|
||||
context "with invalid params" do
|
||||
it "assigns the crm_customer as @crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(assigns(:crm_customer)).to eq(customer)
|
||||
end
|
||||
|
||||
it "re-renders the 'edit' template" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
put :update, params: {id: customer.to_param, crm_customer: invalid_attributes}, session: valid_session
|
||||
expect(response).to render_template("edit")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe "DELETE #destroy" do
|
||||
it "destroys the requested crm_customer" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
expect {
|
||||
delete :destroy, params: {id: customer.to_param}, session: valid_session
|
||||
}.to change(Crm::Customer, :count).by(-1)
|
||||
end
|
||||
|
||||
it "redirects to the crm_customers list" do
|
||||
customer = Crm::Customer.create! valid_attributes
|
||||
delete :destroy, params: {id: customer.to_param}, session: valid_session
|
||||
expect(response).to redirect_to(crm_customers_url)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
15
spec/helpers/crm/dining_queues_helper_spec.rb
Normal file
15
spec/helpers/crm/dining_queues_helper_spec.rb
Normal file
@@ -0,0 +1,15 @@
|
||||
require 'rails_helper'
|
||||
|
||||
# Specs in this file have access to a helper object that includes
|
||||
# the Crm::DiningQueuesHelper. For example:
|
||||
#
|
||||
# describe Crm::DiningQueuesHelper do
|
||||
# describe "string concat" do
|
||||
# it "concats two strings with spaces" do
|
||||
# expect(helper.concat_strings("this","that")).to eq("this that")
|
||||
# end
|
||||
# end
|
||||
# end
|
||||
RSpec.describe Crm::DiningQueuesHelper, type: :helper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
10
spec/requests/crm/crm_dining_queues_spec.rb
Normal file
10
spec/requests/crm/crm_dining_queues_spec.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "Crm::DiningQueues", type: :request do
|
||||
describe "GET /crm_dining_queues" do
|
||||
it "works! (now write some real specs)" do
|
||||
get crm_dining_queues_path
|
||||
expect(response).to have_http_status(200)
|
||||
end
|
||||
end
|
||||
end
|
||||
39
spec/routing/crm/dining_queues_routing_spec.rb
Normal file
39
spec/routing/crm/dining_queues_routing_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe Crm::DiningQueuesController, type: :routing do
|
||||
describe "routing" do
|
||||
|
||||
it "routes to #index" do
|
||||
expect(:get => "/crm/dining_queues").to route_to("crm/dining_queues#index")
|
||||
end
|
||||
|
||||
it "routes to #new" do
|
||||
expect(:get => "/crm/dining_queues/new").to route_to("crm/dining_queues#new")
|
||||
end
|
||||
|
||||
it "routes to #show" do
|
||||
expect(:get => "/crm/dining_queues/1").to route_to("crm/dining_queues#show", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #edit" do
|
||||
expect(:get => "/crm/dining_queues/1/edit").to route_to("crm/dining_queues#edit", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #create" do
|
||||
expect(:post => "/crm/dining_queues").to route_to("crm/dining_queues#create")
|
||||
end
|
||||
|
||||
it "routes to #update via PUT" do
|
||||
expect(:put => "/crm/dining_queues/1").to route_to("crm/dining_queues#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #update via PATCH" do
|
||||
expect(:patch => "/crm/dining_queues/1").to route_to("crm/dining_queues#update", :id => "1")
|
||||
end
|
||||
|
||||
it "routes to #destroy" do
|
||||
expect(:delete => "/crm/dining_queues/1").to route_to("crm/dining_queues#destroy", :id => "1")
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
24
spec/views/crm/dining_queues/edit.html.erb_spec.rb
Normal file
24
spec/views/crm/dining_queues/edit.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/edit", type: :view do
|
||||
before(:each) do
|
||||
@crm_dining_queue = assign(:crm_dining_queue, Crm::DiningQueue.create!(
|
||||
:name => "MyString",
|
||||
:contact => "MyString",
|
||||
:queue_no => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders the edit crm_dining_queue form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", crm_dining_queue_path(@crm_dining_queue), "post" do
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[name]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[contact]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[queue_no]"
|
||||
end
|
||||
end
|
||||
end
|
||||
25
spec/views/crm/dining_queues/index.html.erb_spec.rb
Normal file
25
spec/views/crm/dining_queues/index.html.erb_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/index", type: :view do
|
||||
before(:each) do
|
||||
assign(:crm_dining_queues, [
|
||||
Crm::DiningQueue.create!(
|
||||
:name => "Name",
|
||||
:contact => "Contact",
|
||||
:queue_no => "Queue No"
|
||||
),
|
||||
Crm::DiningQueue.create!(
|
||||
:name => "Name",
|
||||
:contact => "Contact",
|
||||
:queue_no => "Queue No"
|
||||
)
|
||||
])
|
||||
end
|
||||
|
||||
it "renders a list of crm/dining_queues" do
|
||||
render
|
||||
assert_select "tr>td", :text => "Name".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Contact".to_s, :count => 2
|
||||
assert_select "tr>td", :text => "Queue No".to_s, :count => 2
|
||||
end
|
||||
end
|
||||
24
spec/views/crm/dining_queues/new.html.erb_spec.rb
Normal file
24
spec/views/crm/dining_queues/new.html.erb_spec.rb
Normal file
@@ -0,0 +1,24 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/new", type: :view do
|
||||
before(:each) do
|
||||
assign(:crm_dining_queue, Crm::DiningQueue.new(
|
||||
:name => "MyString",
|
||||
:contact => "MyString",
|
||||
:queue_no => "MyString"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders new crm_dining_queue form" do
|
||||
render
|
||||
|
||||
assert_select "form[action=?][method=?]", crm_dining_queues_path, "post" do
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[name]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[contact]"
|
||||
|
||||
assert_select "input[name=?]", "crm_dining_queue[queue_no]"
|
||||
end
|
||||
end
|
||||
end
|
||||
18
spec/views/crm/dining_queues/show.html.erb_spec.rb
Normal file
18
spec/views/crm/dining_queues/show.html.erb_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe "crm/dining_queues/show", type: :view do
|
||||
before(:each) do
|
||||
@crm_dining_queue = assign(:crm_dining_queue, Crm::DiningQueue.create!(
|
||||
:name => "Name",
|
||||
:contact => "Contact",
|
||||
:queue_no => "Queue No"
|
||||
))
|
||||
end
|
||||
|
||||
it "renders attributes in <p>" do
|
||||
render
|
||||
expect(rendered).to match(/Name/)
|
||||
expect(rendered).to match(/Contact/)
|
||||
expect(rendered).to match(/Queue No/)
|
||||
end
|
||||
end
|
||||
9
test/system/dining_queues_test.rb
Normal file
9
test/system/dining_queues_test.rb
Normal file
@@ -0,0 +1,9 @@
|
||||
require "application_system_test_case"
|
||||
|
||||
class Crm::DiningQueuesTest < ApplicationSystemTestCase
|
||||
# test "visiting the index" do
|
||||
# visit crm_dining_queues_url
|
||||
#
|
||||
# assert_selector "h1", text: "Crm::DiningQueue"
|
||||
# end
|
||||
end
|
||||
Reference in New Issue
Block a user