Update
This commit is contained in:
@@ -4,8 +4,25 @@ class Api::Restaurant::MenuController < Api::ApiController
|
||||
# Pull the default menu details and also other available (active) menus
|
||||
# Input Params - order_id
|
||||
def index
|
||||
@menus = Menu.all
|
||||
# @current_menu = Menu.current_menu
|
||||
param_checksum = params[:checksum]
|
||||
# checksum = File.readlines("public/checksums/menu_json.txt").pop.chomp
|
||||
|
||||
all_menu = Menu.all
|
||||
|
||||
# to hash
|
||||
menu_array = []
|
||||
all_menu.each do |m|
|
||||
menu_array.push(m.to_json(:include => {:menu_categories => { :include => { :menu_items => { :include => [:menu_item_sets, :menu_item_instances => {:include => :menu_instance_item_sets}]} } }}))
|
||||
end
|
||||
|
||||
#export Checksum file generate by md5
|
||||
menu_checksum = Digest::MD5.hexdigest(menu_array.to_json)
|
||||
|
||||
if menu_checksum != param_checksum
|
||||
response.headers['CHECKSUM'] = menu_checksum
|
||||
@menus = all_menu
|
||||
end
|
||||
# @current_menu = Menu.current_menu
|
||||
end
|
||||
|
||||
#Description
|
||||
|
||||
@@ -6,13 +6,33 @@ class Crm::CustomersController < BaseCrmController
|
||||
# GET /crm/customers.json
|
||||
def index
|
||||
filter = params[:filter]
|
||||
type = params[:type]
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.all
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
|
||||
# search account no from paypar
|
||||
if !@crm_customers.present? && type == "card"
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@crm_customers.contact_no = response["customer_data"]["phone"]
|
||||
@crm_customers.email = response["customer_data"]["email"]
|
||||
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
|
||||
@crm_customers.nrc_no = response["customer_data"]["NRC"]
|
||||
@crm_customers.address = response["customer_data"]["address"]
|
||||
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
|
||||
@crm_customers.paypar_account_no = filter
|
||||
@crm_customers.membership_id = response["customer_data"]["id"]
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
end
|
||||
end
|
||||
end
|
||||
#@crm_customers = Customer.all
|
||||
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
|
||||
@crm_customer = Customer.new
|
||||
@count_customer = Customer.count_customer
|
||||
|
||||
@@ -1,75 +0,0 @@
|
||||
class Origami::CommissionersController < BaseOrigamiController
|
||||
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /commissioners
|
||||
# GET /commissioners.json
|
||||
def index
|
||||
@commissioners = Commissioner.all.order("id asc")
|
||||
end
|
||||
|
||||
# GET /commissioners/1
|
||||
# GET /commissioners/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /commissioners/new
|
||||
def new
|
||||
@commissioner = Commissioner.new
|
||||
@employee = Employee.all.order('name asc')
|
||||
end
|
||||
|
||||
# GET /commissioners/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /commissioners
|
||||
# POST /commissioners.json
|
||||
def create
|
||||
@commissioner = Commissioner.new(commissioner_params)
|
||||
@commissioner.created_by = current_user.id
|
||||
respond_to do |format|
|
||||
if @commissioner.save
|
||||
format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @commissioner }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /commissioners/1
|
||||
# PATCH/PUT /commissioners/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commissioner.update(commissioner_params)
|
||||
format.html { redirect_to origami_commissioner_path(@commissioner) , notice: 'Commissioner was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @commissioner }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @commissioner.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /commissioners/1
|
||||
# DELETE /commissioners/1.json
|
||||
def destroy
|
||||
@commissioner.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_commissioners_path , notice: 'Commissioner was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commissioner
|
||||
@commissioner = Commissioner.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commissioner_params
|
||||
params.require(:commissioner).permit(:name,:emp_id,:created_by,:commission_type, :is_active)
|
||||
end
|
||||
end
|
||||
@@ -9,13 +9,40 @@ class Origami::CustomersController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def get_customer
|
||||
|
||||
filter = params[:filter]
|
||||
type = params[:type]
|
||||
|
||||
if filter.nil?
|
||||
@crm_customers = Customer.order("customer_id").page(params[:page])
|
||||
#@products = Product.order("name").page(params[:page]).per(5)
|
||||
else
|
||||
@crm_customers = Customer.search(filter)
|
||||
@crm_customers = Customer.search(filter)
|
||||
# search account no from paypar
|
||||
if !@crm_customers.present? && type == "card"
|
||||
response = Customer.search_paypar_account_no(filter)
|
||||
if response["status"] == true
|
||||
@crm_customers = Customer.new
|
||||
@crm_customers.name = response["customer_data"]["name"]
|
||||
@crm_customers.contact_no = response["customer_data"]["phone"]
|
||||
@crm_customers.email = response["customer_data"]["email"]
|
||||
@crm_customers.date_of_birth = response["customer_data"]["DOB"]
|
||||
@crm_customers.nrc_no = response["customer_data"]["NRC"]
|
||||
@crm_customers.address = response["customer_data"]["address"]
|
||||
@crm_customers.card_no = response["customer_data"]["customer_card_no"]
|
||||
@crm_customers.paypar_account_no = filter
|
||||
@crm_customers.membership_id = response["customer_data"]["id"]
|
||||
@crm_customers.membership_type = response["customer_data"]["member_group_id"]
|
||||
@crm_customers.customer_type = "Dinein"
|
||||
@crm_customers.tax_profiles = ["1", "2"]
|
||||
@crm_customers.save
|
||||
@crm_customers = Customer.search(filter)
|
||||
else
|
||||
@crm_customers = [{"customer_id": response["status"],"message": response["message"] }]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render :json => @crm_customers.to_json
|
||||
end
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
end
|
||||
|
||||
def index_in_juty
|
||||
@juties_in= InJuty.where("dinning_id=?",params[:table_id])
|
||||
@juty_in= InJuty.where("dinning_id=?",params[:table_id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@in_juty = InJuty.new
|
||||
|
||||
@juties_in = Kaminari.paginate_array(@juty_in).page(params[:page]).per(10)
|
||||
end
|
||||
# GET /in_juties/1
|
||||
# GET /in_juties/1.json
|
||||
@@ -31,6 +31,9 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
def edit_in_juty
|
||||
@in_juty = InJuty.find(params[:id])
|
||||
@table = DiningFacility.find(params[:table_id])
|
||||
@commissioner = @in_juty.commissioner
|
||||
|
||||
render json: {in_juty: @in_juty, commissioner: @commissioner}
|
||||
end
|
||||
|
||||
def assign_in_juty
|
||||
@@ -56,10 +59,10 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
def create_for_in_juty
|
||||
@in_juty = InJuty.new
|
||||
|
||||
@in_juty.dinning_id = in_juty_params[:dinning_id]
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_juty_params[:in_time]
|
||||
@in_juty.out_time = in_juty_params[:out_time]
|
||||
@in_juty.dinning_id = in_juty_params[:dinning_id]
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_juty_params[:in_time]
|
||||
@in_juty.out_time = in_juty_params[:out_time]
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
@@ -71,7 +74,7 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
# PATCH/PUT /in_juties/1
|
||||
@@ -90,11 +93,18 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
|
||||
|
||||
def update_for_in_juty
|
||||
@in_juty.dinning_id = params[:dining_id]
|
||||
@in_juty.commissioner_ids = params[:commissioner_ids]
|
||||
@in_juty.in_time = params[:in_time]
|
||||
@in_juty.out_time = params[:out_time]
|
||||
@in_juty.save
|
||||
@in_juty.commissioner_ids = in_juty_params[:commissioner_ids]
|
||||
@in_juty.in_time = in_juty_params[:in_time]
|
||||
@in_juty.out_time = in_juty_params[:out_time]
|
||||
respond_to do |format|
|
||||
if @in_juty.save
|
||||
format.html { redirect_to origami_index_in_juty_path(in_juty_params[:dinning_id]), notice: 'In juty was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @in_juty }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @in_juty.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /in_juties/1
|
||||
@@ -110,7 +120,7 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
def destroy_in_juty
|
||||
@table_id = params[:table_id]
|
||||
@in_juty.destroy
|
||||
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to origami_index_in_juty_path(@table_id), notice: 'In juty was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
@@ -125,6 +135,6 @@ class Origami::InJutiesController < BaseOrigamiController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def in_juty_params
|
||||
params.require(:in_juty).permit(:dinning_id,:commissioner_ids,:in_time,:out_time)
|
||||
params.require(:in_juty).permit(:id,:dinning_id,:commissioner_ids,:in_time,:out_time)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -62,15 +62,16 @@ class Origami::ProductCommissionsController < ApplicationController
|
||||
end
|
||||
|
||||
def set_commissioner_to_sale_item
|
||||
# byebug
|
||||
deselect = false
|
||||
sale_item_id = params[:sale_item_id]
|
||||
commissioner_id = params[:commissioner_id]
|
||||
@sale_item = SaleItem.find(sale_item_id)
|
||||
@menu_item = MenuItem.find_by_item_code(@sale_item.product_code)
|
||||
@commission = Commission.where('product_id = ? AND is_active = ?', @menu_item.id, true).take
|
||||
@commission = Commission.where('product_code = ? AND is_active = ?', @menu_item.id, true).take
|
||||
@commissioner = Commissioner.where('id = ? AND is_active = ?', commissioner_id, true).take
|
||||
@product_commission = ProductCommission.where('sale_item_id = ?', @sale_item.id).take
|
||||
# byebug
|
||||
|
||||
if !@product_commission.nil?
|
||||
if @product_commission.commissioner_id == @commissioner.id
|
||||
@product_commission.destroy
|
||||
@@ -81,7 +82,8 @@ class Origami::ProductCommissionsController < ApplicationController
|
||||
end
|
||||
else
|
||||
@product_commission = ProductCommission.new
|
||||
@product_commission.product_id = @menu_item.id
|
||||
@product_commission.product_code = @menu_item.id
|
||||
@product_commission.product_type = 'menu_item' # use for dummy data ToDo::need to change product type
|
||||
unless @commission.nil?
|
||||
@product_commission.commission_id = @commission.id
|
||||
if @commission.commission_type == 'Percentage'
|
||||
|
||||
49
app/controllers/reports/commission_controller.rb
Normal file
49
app/controllers/reports/commission_controller.rb
Normal file
@@ -0,0 +1,49 @@
|
||||
class Reports::CommissionController < BaseReportController
|
||||
# authorize_resource :class => false
|
||||
|
||||
def index
|
||||
from_date = DateTime.now.beginning_of_day.utc.getlocal
|
||||
to_date = DateTime.now.end_of_day.utc.getlocal
|
||||
unless params[:daterange].blank?
|
||||
from_date = Date.parse(params[:daterange].split(' - ')[0]).beginning_of_day.utc.getlocal
|
||||
to_date = Date.parse(params[:daterange].split(' - ')[1]).end_of_day.utc.getlocal
|
||||
@daterange = params[:daterange]
|
||||
end
|
||||
commissioner = params[:commissioner].to_i
|
||||
@com_id = commissioner
|
||||
@commissioner = Commissioner.active.all
|
||||
|
||||
@transaction = ProductCommission.get_transaction(from_date, to_date, commissioner)
|
||||
@from = from_date
|
||||
@to = to_date
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.xls
|
||||
end
|
||||
end
|
||||
|
||||
def show
|
||||
from, to = get_date_range_from_params
|
||||
|
||||
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
|
||||
|
||||
date_arr = Array.new
|
||||
@sale_data.each do |sale|
|
||||
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
|
||||
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
|
||||
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
|
||||
shift_id = sale.id.nil? ? '-' : sale.id
|
||||
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
|
||||
date_arr.push(str)
|
||||
end
|
||||
|
||||
out = {:status => 'ok', :message => date_arr}
|
||||
|
||||
respond_to do |format|
|
||||
format.json { render json: out }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
93
app/controllers/settings/commissioners_controller.rb
Normal file
93
app/controllers/settings/commissioners_controller.rb
Normal file
@@ -0,0 +1,93 @@
|
||||
class Settings::CommissionersController < ApplicationController
|
||||
before_action :set_commissioner, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /commissioners
|
||||
# GET /commissioners.json
|
||||
def index
|
||||
@commissioners = Commissioner.all.order("id asc")
|
||||
end
|
||||
|
||||
# GET /commissioners/1
|
||||
# GET /commissioners/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /commissioners/new
|
||||
def new
|
||||
@commissioner = Commissioner.new
|
||||
@employee = Employee.all.order('name asc')
|
||||
end
|
||||
|
||||
# GET /commissioners/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /commissioners
|
||||
# POST /commissioners.json
|
||||
def create
|
||||
@commissioner = Commissioner.new(commissioner_params)
|
||||
@commissioner.created_by = current_user.id
|
||||
unless @commissioner.joined_date.nil?
|
||||
@commissioner.joined_date = @commissioner.joined_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
unless @commissioner.resigned_date.nil?
|
||||
@commissioner.resigned_date = @commissioner.resigned_date.utc.getlocal.strftime('%Y-%b-%d')
|
||||
end
|
||||
respond_to do |format|
|
||||
if @commissioner.save
|
||||
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully created.'}
|
||||
format.json {render :show, status: :created, location: @commissioner}
|
||||
else
|
||||
format.html {render :new}
|
||||
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /commissioners/1
|
||||
# PATCH/PUT /commissioners/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commissioner.update(commissioner_params)
|
||||
format.html {redirect_to settings_commissioner_path(@commissioner), notice: 'Commissioner was successfully updated.'}
|
||||
format.json {render :show, status: :ok, location: @commissioner}
|
||||
else
|
||||
format.html {render :edit}
|
||||
format.json {render json: @commissioner.errors, status: :unprocessable_entity}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /commissioners/1
|
||||
# DELETE /commissioners/1.json
|
||||
def destroy
|
||||
@commissioner.destroy
|
||||
respond_to do |format|
|
||||
format.html {redirect_to settings_commissioners_path, notice: 'Commissioner was successfully destroyed.'}
|
||||
format.json {head :no_content}
|
||||
end
|
||||
end
|
||||
|
||||
def get_transaction_by_commissioner
|
||||
commissioner_id = params[:commissioner_id]
|
||||
@transactions = []
|
||||
@product_commissions = ProductCommission.where(commissioner_id: commissioner_id).order('updated_at desc')
|
||||
@product_commissions.each_with_index do |p, i|
|
||||
@transactions[i] = []
|
||||
@transactions[i] << p
|
||||
@transactions[i] << p.commission.menu_item.name
|
||||
end
|
||||
render json: @transactions
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_commissioner
|
||||
@commissioner = Commissioner.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commissioner_params
|
||||
params.require(:commissioner).permit(:name, :emp_id, :created_by, :commission_id, :joined_date, :resigned_date, :is_active)
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,4 @@
|
||||
class Origami::CommissionsController < BaseOrigamiController
|
||||
class Settings::CommissionsController < ApplicationController
|
||||
before_action :set_commission, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /commissions
|
||||
@@ -27,10 +27,11 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
# POST /commissions.json
|
||||
def create
|
||||
@commission = Commission.new(commission_params)
|
||||
@commission.product_type = 'menu_item'
|
||||
|
||||
respond_to do |format|
|
||||
if @commission.save
|
||||
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully created.'}
|
||||
format.html {redirect_to settings_commissions_path, notice: 'Commission was successfully created.'}
|
||||
format.json {render :show, status: :created, location: @commission}
|
||||
else
|
||||
format.html {render :new}
|
||||
@@ -44,7 +45,7 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @commission.update(commission_params)
|
||||
format.html {redirect_to origami_commission_path(@commission), notice: 'Commission was successfully updated.'}
|
||||
format.html {redirect_to settings_commission_path(@commission), notice: 'Commission was successfully updated.'}
|
||||
format.json {render :show, status: :ok, location: @commission}
|
||||
else
|
||||
format.html {render :edit}
|
||||
@@ -58,7 +59,7 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
def destroy
|
||||
@commission.destroy
|
||||
respond_to do |format|
|
||||
format.html {redirect_to origami_commissions_path, notice: 'Commission was successfully destroyed.'}
|
||||
format.html {redirect_to settings_commissions_path, notice: 'Commission was successfully destroyed.'}
|
||||
format.json {head :no_content}
|
||||
end
|
||||
end
|
||||
@@ -96,6 +97,6 @@ class Origami::CommissionsController < BaseOrigamiController
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def commission_params
|
||||
params.require(:commission).permit(:product_id, :amount, :commission_type, :is_active)
|
||||
params.require(:commission).permit(:product_type, :product_code, :amount, :commission_type, :is_active)
|
||||
end
|
||||
end
|
||||
@@ -79,7 +79,7 @@ class Settings::SimpleMenuItemsController < ApplicationController
|
||||
respond_to do |format|
|
||||
if @settings_menu_item.save
|
||||
menu_item = MenuItem.find(@settings_menu_item.id)
|
||||
menu_item.update_attributes(item_options: params[:simple_menu_item][:item_options])
|
||||
menu_item.update_attributes(item_attributes: params[:simple_menu_item][:item_attributes], item_options: params[:simple_menu_item][:item_options])
|
||||
|
||||
format.html { redirect_to settings_menu_category_simple_menu_items_path, notice: 'Menu item was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_menu_item }
|
||||
|
||||
Reference in New Issue
Block a user