queue and crm view updated

This commit is contained in:
Aung Myo
2017-06-09 09:29:25 +06:30
parent ea4f50e779
commit 35277ac000
41 changed files with 685 additions and 318 deletions

View File

@@ -61,7 +61,8 @@ gem 'sidekiq'
# Pagination
gem 'kaminari', '~> 0.16.3'
# Datatable
gem 'filterrific'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development

View File

@@ -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)

View 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/

View File

@@ -7,3 +7,5 @@
// min-height: 75rem;
// padding-top: 4.5rem;
// }

View File

@@ -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

View File

@@ -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 }

View File

@@ -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

View File

@@ -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

View File

@@ -0,0 +1,2 @@
module Crm::DiningQueuesHelper
end

5
app/models/crm.rb Normal file
View File

@@ -0,0 +1,5 @@
module Crm
def self.table_name_prefix
'crm_'
end
end

View File

@@ -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

View File

@@ -0,0 +1,3 @@
class DiningQueue < ApplicationRecord
end

View 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

View File

@@ -16,5 +16,13 @@
<%= f.button :submit %>
</div>
<% end %>
<!-- -->
<!-- <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| %>
<option value="<%= member["id"] %>">
<%= member["name"] %></option>
<%end %>
</select>
</div> -->

View File

@@ -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,6 +59,9 @@
<% end %>
</tbody>
</table>
<br>
<p>asdfj;l</p>
<%= paginate @crm_customers %>
</div>
</div>
@@ -81,15 +95,7 @@
<%= f.text_field :date_of_birth,:class=>"form-control datepicker date_of_birth",:readonly =>true, :value => @date_of_birth%>
</div>
<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| %>
<option value="<%= member["id"] %>">
<%= member["name"] %></option>
<%end %>
</select>
</div>
<div class="form-group">

View File

@@ -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)

View 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 %>

View 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>

View 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>

View File

@@ -0,0 +1 @@
json.array! @crm_dining_queues, partial: 'crm_dining_queues/crm_dining_queue', as: :crm_dining_queue

View 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>

View 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 %>

View File

@@ -0,0 +1 @@
json.partial! "crm_dining_queues/crm_dining_queue", crm_dining_queue: @crm_dining_queue

View File

@@ -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,95 @@
$(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");
$(this).css('background-color', '#CCC');
$(".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(){
$(this).css('background-color', '#CCC');
$(".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)
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 +134,80 @@ 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);
$('.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{
}
}
});
//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>

View File

@@ -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>

View File

@@ -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>

View File

@@ -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:scroll">
<%= 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:scroll">
<%= 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,35 @@
</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>
</thead>
</table>
</div>
<div class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table summary-items">
<tbody>
@@ -102,5 +120,3 @@
</div>
</div>
</script>

View 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

View File

@@ -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: "&laquo; First"
last: "Last &raquo;"
previous: "&lsaquo; Prev"
next: "Next &rsaquo;"
truncate: "&hellip;"
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}&nbsp;-&nbsp;%{last}</b> of <b>%{total}</b> in total"

View File

@@ -48,7 +48,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
@@ -95,6 +97,7 @@ Rails.application.routes.draw 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
resources :customers
resources :dining_queues
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

View 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

View File

@@ -1,5 +0,0 @@
require 'rails_helper'
RSpec.describe Crm::BookingsController, type: :controller do
end

View File

@@ -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

View 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

View 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

View 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

View 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

View 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

View 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

View 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

View 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