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

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