Merge branch 'crm' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-06-09 13:47:19 +06:30
47 changed files with 803 additions and 392 deletions

View 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

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

@@ -1,4 +1,4 @@
class Crm::BookingsController < ApplicationController
class Crm::BookingsController < BaseCrmController
def update_booking
booking = Booking.find(params[:booking_id])

View File

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

View 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

View File

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

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

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

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,5 @@
<%= f.button :submit %>
</div>
<% end %>
<!-- -->
<!---->

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

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

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:">
<%= 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>

View File

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

View File

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