current shop

This commit is contained in:
Nweni
2019-12-03 14:54:53 +06:30
parent 23b5d0d344
commit 78838a7718
17 changed files with 44 additions and 43 deletions

View File

@@ -1,13 +1,13 @@
class Api::AuthenticateController < Api::ApiController class Api::AuthenticateController < Api::ApiController
skip_before_action :authenticate skip_before_action :authenticate
before_action :find_shop # before_action :find_shop
def create def create
emp_id = params[:emp_id] emp_id = params[:emp_id]
password = params[:password] password = params[:password]
if emp_id && password if emp_id && password
@employee = Employee.login(@shop, emp_id, password) @employee = Employee.login(emp_id, password)
if @employee && @employee.role == "waiter" if @employee && @employee.role == "waiter"
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role}) render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
else else

View File

@@ -6,7 +6,7 @@ class Api::BillController < Api::ApiController
@status = false @status = false
@error_message = "Order ID or Booking ID is require to request for a bill." @error_message = "Order ID or Booking ID is require to request for a bill."
# if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id) # if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
if !ShiftSale.current_shift(@shop.shop_code).nil? if !ShiftSale.current_shift(Shop.current_shop.shop_code).nil?
#create Bill by Booking ID #create Bill by Booking ID
table = 0 table = 0
if (params[:booking_id]) if (params[:booking_id])

View File

@@ -19,7 +19,7 @@ class Api::Payment::MobilepaymentController < Api::ApiController
# rounding adjustment # rounding adjustment
if !path.include? ("credit_payment") if !path.include? ("credit_payment")
if @shop.is_rounding_adj if shop_detail.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus a = saleObj.grand_total % 25 # Modulus
b = saleObj.grand_total / 25 # Division b = saleObj.grand_total / 25 # Division
#not calculate rounding if modulus is 0 and division is even #not calculate rounding if modulus is 0 and division is even

View File

@@ -15,8 +15,8 @@ class Api::SurveyController < Api::ApiController
def create def create
dining_facility = DiningFacility.find(params[:id]) dining_facility = DiningFacility.find(params[:id])
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
current_shift = ShiftSale.current_shift(@shop.shop_code) current_shift = ShiftSale.current_shift(Shop.current_shop.shop_code)
current_shift_user =Employee.find_by_id(current_shift.employee_id) current_shift_user =Employee.find_by_id(current_shift.employee_id)
if open_cashier.count>0 if open_cashier.count>0
shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0]) shift_by_terminal = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -1,5 +1,5 @@
class BaseCrmController < ActionController::Base class BaseCrmController < ActionController::Base
include LoginVerification, include LoginVerification, MultiTenancy
layout "CRM" layout "CRM"
before_action :check_user before_action :check_user

View File

@@ -38,7 +38,7 @@ class Crm::CustomersController < BaseCrmController
@crm_customers.membership_type = response["customer_data"]["member_group_id"] @crm_customers.membership_type = response["customer_data"]["member_group_id"]
@crm_customers.customer_type = "Dinein" @crm_customers.customer_type = "Dinein"
@crm_customers.tax_profiles = ["1", "2"] @crm_customers.tax_profiles = ["1", "2"]
@crm_customers.shop_code = @shop.shop_code @crm_customers.shop_code = Shop.current_shop.shop_code
@crm_customers.save @crm_customers.save
@crm_customers = Customer.search(filter) @crm_customers = Customer.search(filter)
flash[:member_notice]='Customer was successfully created.' flash[:member_notice]='Customer was successfully created.'
@@ -130,7 +130,7 @@ class Crm::CustomersController < BaseCrmController
params[:type] = nil params[:type] = nil
params[:customer_id] = params[:id] params[:customer_id] = params[:id]
@credit_sales = SalePayment.get_credit_sales(params,@shop.shop_code) @credit_sales = SalePayment.get_credit_sales(params,Shop.current_shop.shop_code)
#get customer amount #get customer amount
@customer = Customer.find(params[:id]) @customer = Customer.find(params[:id])
@@ -255,7 +255,7 @@ class Crm::CustomersController < BaseCrmController
if @checked_contact.nil? if @checked_contact.nil?
respond_to do |format| respond_to do |format|
@crm_customers = Customer.new(customer_params) @crm_customers = Customer.new(customer_params)
@crm_customers.shop_code = @shop.shop_code @crm_customers.shop_code = Shop.current_shop.shop_code
if @crm_customers.save if @crm_customers.save
# update tax profile # update tax profile
customer = Customer.find(@crm_customers.customer_id) customer = Customer.find(@crm_customers.customer_id)

View File

@@ -6,8 +6,8 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues.json # GET /crm/dining_queues.json
def index def index
today = DateTime.now.strftime('%Y-%m-%d') today = DateTime.now.strftime('%Y-%m-%d')
@dining_queues = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc") @dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", today).order("queue_no asc")
@complete_queue = DiningQueue.where("shop_code='#{@shop.shop_code}' and DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc") @complete_queue = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status = 'Assign' ", today).order("queue_no asc")
if params[:term] if params[:term]
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%") @customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
@@ -40,7 +40,7 @@ class Crm::DiningQueuesController < BaseCrmController
# POST /crm/dining_queues.json # POST /crm/dining_queues.json
def create def create
@dining_queue = DiningQueue.new(dining_queue_params) @dining_queue = DiningQueue.new(dining_queue_params)
@dining_queue.shop_code = @shop.shop_code @dining_queue.shop_code = Shop.current_shop.shop_code
respond_to do |format| respond_to do |format|
if @dining_queue.save if @dining_queue.save
@@ -87,7 +87,7 @@ class Crm::DiningQueuesController < BaseCrmController
def assign def assign
@queue = DiningQueue.find(params[:id]) @queue = DiningQueue.find(params[:id])
@tables = DiningFacility.where("status = 'available' and shop_code='#{@shop.shop_code}' and type!='HotelRoom'") @tables = DiningFacility.where("status = 'available' and type!='HotelRoom'")
respond_to do |format| respond_to do |format|
format.html # index.html.erb format.html # index.html.erb
end end
@@ -108,8 +108,7 @@ class Crm::DiningQueuesController < BaseCrmController
:type => type, :type => type,
:checkin_at => Time.now.utc, :checkin_at => Time.now.utc,
:customer_id => queue.customer_id, :customer_id => queue.customer_id,
:booking_status => "assign", :booking_status => "assign"})
:shop_code => @shop.shop_code})
booking.save! booking.save!
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign") status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
@@ -138,7 +137,7 @@ class Crm::DiningQueuesController < BaseCrmController
private private
# Use callbacks to share common setup or constraints between actions. # Use callbacks to share common setup or constraints between actions.
def set_dining_queue def set_dining_queue
@dining_queue = DiningQueue.find_by_id_and_shop_code(params[:id],@shop.shop_code) @dining_queue = DiningQueue.find_by_id(params[:id])
end end
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -7,10 +7,10 @@ class Foodcourt::AddordersController < BaseFoodcourtController
@webview = true @webview = true
end end
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @tables = Table.all.active.order('zone_id asc').group("zone_id")
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id") @rooms = Room.all.active.order('zone_id asc').group("zone_id")
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') @all_table = Table.all.active.order('status desc')
@all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc') @all_room = Room.all.active.order('status desc')
end end
def detail def detail
@@ -19,7 +19,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
if check_mobile if check_mobile
@webview = true @webview = true
end end
display_type = Lookup.find_by_lookup_type_and_shop_code("display_type",@shop.shop_code) display_type = Lookup.find_by_lookup_type("display_type")
if !display_type.nil? && display_type.value.to_i ==2 if !display_type.nil? && display_type.value.to_i ==2
@display_type = display_type.value @display_type = display_type.value
else else
@@ -233,7 +233,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
#Send to background job for processing #Send to background job for processing
order = Order.find(order_id) order = Order.find(order_id)
sidekiq = Lookup.find_by_lookup_type_and_shop_code("sidekiq",@shop.shop_code) sidekiq = Lookup.find_by_lookup_type("sidekiq")
if ENV["SERVER_MODE"] != 'cloud' if ENV["SERVER_MODE"] != 'cloud'
cup_status = `#{"sudo service cups status"}` cup_status = `#{"sudo service cups status"}`
print_status = check_cup_status(cup_status) print_status = check_cup_status(cup_status)

View File

@@ -15,13 +15,13 @@ class Foodcourt::CashInsController < BaseFoodcourtController
p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user) p_jour.cash_in(reference, remark, amount, payment_method, payment_method_reference, current_user)
shift = ShiftSale.current_open_shift(current_user) shift = ShiftSale.current_open_shift(current_user)
current_shift = ShiftSale.current_shift(@shop.shop_code) current_shift = ShiftSale.current_shift(Shop.current_shopshop_code)
# set cashier # set cashier
if shift != nil if shift != nil
shift = shift shift = shift
else else
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0 if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0]) shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -10,13 +10,13 @@ class Foodcourt::CashOutsController < BaseFoodcourtController
p_jour.cash_out(reference, remark, amount, current_user) p_jour.cash_out(reference, remark, amount, current_user)
shift = ShiftSale.current_open_shift(current_user) shift = ShiftSale.current_open_shift(current_user)
current_shift = ShiftSale.current_shift(@shop.shop_code) current_shift = ShiftSale.current_shift(Shop.current_shop.shop_code)
# set cashier # set cashier
if shift != nil if shift != nil
shift = shift shift = shift
else else
open_cashier = Employee.where("shop_code='#{@shop.shop_code}' and role = 'cashier' AND token_session <> ''") open_cashier = Employee.where("role = 'cashier' AND token_session <> ''")
if open_cashier.count>0 if open_cashier.count>0
shift = ShiftSale.current_open_shift(open_cashier[0]) shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -3,9 +3,10 @@ class Foodcourt::DashboardController < BaseFoodcourtController
def index def index
today = DateTime.now.strftime('%Y-%m-%d') today = DateTime.now.strftime('%Y-%m-%d')
@display_type = Lookup.where("shop_code='#{@shop.shop_code}'").find_by_lookup_type("display_type") @display_type = Lookup.find_by_lookup_type("display_type")
@sale_data = Array.new @sale_data = Array.new
@shop = Shop.current_shop
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user) @total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
if !@total_payment_methods.nil? if !@total_payment_methods.nil?
@total_payment_methods.each do |payment| @total_payment_methods.each do |payment|

View File

@@ -21,8 +21,8 @@ class Foodcourt::DiscountsController < BaseFoodcourtController
end end
end end
@member_discount = MembershipSetting.find_by_discount_and_shop_code(1,@shop.shop_code) @member_discount = MembershipSetting.find_by_discount(1)
@accounts = Account.where("shop_code='#{@shop.shop_code}'") @accounts = Account.where("shop_code='#{Shop.current_shop.shop_code}'")
end end
#discount page show from origami index with selected order #discount page show from origami index with selected order

View File

@@ -157,7 +157,7 @@ class Foodcourt::FoodCourtController < ApplicationController
end end
def get_all_product() def get_all_product()
@product = Product..where("shop_code='#{@shop.shop_code}'") @product = Product.where("shop_code='#{Shop.current_shop.shop_code}'")
end end
# render json for http status code # render json for http status code

View File

@@ -4,6 +4,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
def index def index
@webview = check_mobile @webview = check_mobile
@shop = Shop.current_shop
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @complete = Sale.completed_sale("cashier",@shop.shop_code)
@@ -19,7 +20,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
# get printer info # get printer info
@print_settings = PrintSetting.get_precision_delimiter() @print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile @webview = check_mobile
@shop = Shop.current_shop
@tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @tables = Table.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc') @rooms = Room.unscoped.all.active.where("shop_code='#{@shop.shop_code}'").order('status desc')
@complete = Sale.completed_sale("cashier",@shop.shop_code) @complete = Sale.completed_sale("cashier",@shop.shop_code)

View File

@@ -32,15 +32,15 @@ class Inventory::StockChecksController < BaseInventoryController
def save_to_journal def save_to_journal
check = params[:data] check = params[:data]
stockCheck = StockCheck.find_by_id_and_shop_code(check,@shop.shop_code) stockCheck = StockCheck.find_by_id(check)
stockCheck.stock_check_items.each do |item| stockCheck.stock_check_items.each do |item|
StockJournal.from_stock_check(item,@shop) StockJournal.from_stock_check(item,Shop.current_shop)
end end
end end
def print_stock_check def print_stock_check
stock_id = params[:stock_check_id] # sale_id stock_id = params[:stock_check_id] # sale_id
stockcheck = StockCheck.find_by_id_and_shop_code(stock_id,@shop.shop_code) stockcheck = StockCheck.find_by_id(stock_id)
stockcheck_items = stockcheck.stock_check_items stockcheck_items = stockcheck.stock_check_items
member_info = nil member_info = nil
unique_code = 'StockCheckPdf' unique_code = 'StockCheckPdf'

View File

@@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1 # GET /print_settings/1
# GET /print_settings/1.json # GET /print_settings/1.json
def show def show
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) @lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code)
end end
# GET /print_settings/new # GET /print_settings/new
@@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1/edit # GET /print_settings/1/edit
def edit def edit
@lookup = Lookup.shift_sale_items_lookup_value(@shop.shop_code) @lookup = Lookup.shift_sale_items_lookup_value(Shop.current_shop.shop_code)
@server_mode = ENV["SERVER_MODE"] @server_mode = ENV["SERVER_MODE"]
end end
@@ -30,7 +30,7 @@ class PrintSettingsController < ApplicationController
# POST /print_settings.json # POST /print_settings.json
def create def create
@print_setting = PrintSetting.new(print_setting_params) @print_setting = PrintSetting.new(print_setting_params)
@print_setting.shop_code = @shop.shop_code @print_setting.shop_code = Shop.current_shop.shop_code
respond_to do |format| respond_to do |format|
if @print_setting.save if @print_setting.save
format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' } format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' }
@@ -48,7 +48,7 @@ class PrintSettingsController < ApplicationController
respond_to do |format| respond_to do |format|
if @print_setting.update(print_setting_params) if @print_setting.update(print_setting_params)
if @print_setting.unique_code == 'CloseCashierPdf' if @print_setting.unique_code == 'CloseCashierPdf'
Lookup.save_shift_sale_items_settings(params[:shift_sale_items],@shop.shop_code) Lookup.save_shift_sale_items_settings(params[:shift_sale_items],Shop.current_shop.shop_code)
end end
format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' } format.html { redirect_to @print_setting, notice: 'Print setting was successfully updated.' }

View File

@@ -99,7 +99,7 @@
<label class="p-l-10">Foreigner</label> <label class="p-l-10">Foreigner</label>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> --> <!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " > <select class="form-control col-md-12 selectpicker show-tick" name="survey[foreigner][]" style="height: " >
<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %> <% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>
<option value="<%= ct.value %>"> <option value="<%= ct.value %>">
<%= ct.name %></option> <%= ct.name %></option>
<%end %> <%end %>
@@ -293,7 +293,7 @@ var cashier_type = "<%= @cashier_type %>";
+'<div class="form-group p-l-10 p-r-10">' +'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" ' +' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >' +' name="survey[foreigner][]" style="height: " >'
+'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
+'<option value="<%= ct.value %>">' +'<option value="<%= ct.value %>">'
+'<%= ct.name %></option>' +'<%= ct.name %></option>'
+'<%end %>' +'<%end %>'
@@ -321,7 +321,7 @@ var cashier_type = "<%= @cashier_type %>";
+'<div class="form-group p-l-10 p-r-10">' +'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" ' +' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >' +' name="survey[foreigner][]" style="height: " >'
+'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
+'<option value="<%= ct.value %>">' +'<option value="<%= ct.value %>">'
+'<%= ct.name %></option>' +'<%= ct.name %></option>'
+'<%end %>' +'<%end %>'
@@ -470,7 +470,7 @@ var cashier_type = "<%= @cashier_type %>";
+'<div class="form-group p-l-10 p-r-10">' +'<div class="form-group p-l-10 p-r-10">'
+' <select class="form-control col-md-12 selectpicker show-tick" ' +' <select class="form-control col-md-12 selectpicker show-tick" '
+' name="survey[foreigner][]" style="height: " >' +' name="survey[foreigner][]" style="height: " >'
+'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>'
// if (key.toString() == '<%= ct.value.to_s %>') // if (key.toString() == '<%= ct.value.to_s %>')
// var selected = "selected"; // var selected = "selected";
// else // else