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
skip_before_action :authenticate
before_action :find_shop
# before_action :find_shop
def create
emp_id = params[:emp_id]
password = params[:password]
if emp_id && password
@employee = Employee.login(@shop, emp_id, password)
@employee = Employee.login(emp_id, password)
if @employee && @employee.role == "waiter"
render json: JSON.generate({:status => true, :session_token => @employee.token_session, :name => @employee.name, :role => @employee.role})
else

View File

@@ -6,7 +6,7 @@ class Api::BillController < Api::ApiController
@status = false
@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 !ShiftSale.current_shift(@shop.shop_code).nil?
if !ShiftSale.current_shift(Shop.current_shop.shop_code).nil?
#create Bill by Booking ID
table = 0
if (params[:booking_id])

View File

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

View File

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

View File

@@ -1,5 +1,5 @@
class BaseCrmController < ActionController::Base
include LoginVerification,
include LoginVerification, MultiTenancy
layout "CRM"
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.customer_type = "Dinein"
@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 = Customer.search(filter)
flash[:member_notice]='Customer was successfully created.'
@@ -130,7 +130,7 @@ class Crm::CustomersController < BaseCrmController
params[:type] = nil
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
@customer = Customer.find(params[:id])
@@ -255,7 +255,7 @@ class Crm::CustomersController < BaseCrmController
if @checked_contact.nil?
respond_to do |format|
@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
# update tax profile
customer = Customer.find(@crm_customers.customer_id)

View File

@@ -6,8 +6,8 @@ class Crm::DiningQueuesController < BaseCrmController
# GET /crm/dining_queues.json
def index
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")
@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")
@dining_queues = DiningQueue.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and status is NULL ", 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]
@customer = Customer.order(:name).where('lower(name) LIKE ?', "%#{params[:term].downcase}%")
@@ -40,7 +40,7 @@ class Crm::DiningQueuesController < BaseCrmController
# POST /crm/dining_queues.json
def create
@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|
if @dining_queue.save
@@ -87,7 +87,7 @@ class Crm::DiningQueuesController < BaseCrmController
def assign
@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|
format.html # index.html.erb
end
@@ -108,8 +108,7 @@ class Crm::DiningQueuesController < BaseCrmController
:type => type,
:checkin_at => Time.now.utc,
:customer_id => queue.customer_id,
:booking_status => "assign",
:shop_code => @shop.shop_code})
:booking_status => "assign"})
booking.save!
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
@@ -138,7 +137,7 @@ class Crm::DiningQueuesController < BaseCrmController
private
# Use callbacks to share common setup or constraints between actions.
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
# 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
end
@tables = Table.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
@rooms = Room.all.active.where("shop_code='#{@shop.shop_code}'").order('zone_id asc').group("zone_id")
@all_table = Table.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
@all_room = Room.all.where("shop_code='#{@shop.shop_code}'").active.order('status desc')
@tables = Table.all.active.order('zone_id asc').group("zone_id")
@rooms = Room.all.active.order('zone_id asc').group("zone_id")
@all_table = Table.all.active.order('status desc')
@all_room = Room.all.active.order('status desc')
end
def detail
@@ -19,7 +19,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
if check_mobile
@webview = true
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
@display_type = display_type.value
else
@@ -233,7 +233,7 @@ class Foodcourt::AddordersController < BaseFoodcourtController
#Send to background job for processing
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'
cup_status = `#{"sudo service cups 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)
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
if shift != nil
shift = shift
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
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)
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
if shift != nil
shift = shift
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
shift = ShiftSale.current_open_shift(open_cashier[0])

View File

@@ -3,9 +3,10 @@ class Foodcourt::DashboardController < BaseFoodcourtController
def index
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
@shop = Shop.current_shop
@total_payment_methods = Sale.total_payment_methods(@shop,today,current_user)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|

View File

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

View File

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

View File

@@ -4,6 +4,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
def index
@webview = check_mobile
@shop = Shop.current_shop
@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')
@complete = Sale.completed_sale("cashier",@shop.shop_code)
@@ -19,7 +20,7 @@ class Foodcourt::HomeController < BaseFoodcourtController
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
@webview = check_mobile
@shop = Shop.current_shop
@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')
@complete = Sale.completed_sale("cashier",@shop.shop_code)

View File

@@ -32,15 +32,15 @@ class Inventory::StockChecksController < BaseInventoryController
def save_to_journal
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|
StockJournal.from_stock_check(item,@shop)
StockJournal.from_stock_check(item,Shop.current_shop)
end
end
def print_stock_check
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
member_info = nil
unique_code = 'StockCheckPdf'

View File

@@ -11,7 +11,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1
# GET /print_settings/1.json
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
# GET /print_settings/new
@@ -22,7 +22,7 @@ class PrintSettingsController < ApplicationController
# GET /print_settings/1/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"]
end
@@ -30,7 +30,7 @@ class PrintSettingsController < ApplicationController
# POST /print_settings.json
def create
@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|
if @print_setting.save
format.html { redirect_to @print_setting, notice: 'Print setting was successfully created.' }
@@ -48,7 +48,7 @@ class PrintSettingsController < ApplicationController
respond_to do |format|
if @print_setting.update(print_setting_params)
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
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>
<!-- <input type="text" class="form-control" name="survey[foreigner][]"> -->
<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 %>">
<%= ct.name %></option>
<%end %>
@@ -293,7 +293,7 @@ var cashier_type = "<%= @cashier_type %>";
+'<div class="form-group p-l-10 p-r-10">'
+' <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 %>">'
+'<%= ct.name %></option>'
+'<%end %>'
@@ -321,7 +321,7 @@ var cashier_type = "<%= @cashier_type %>";
+'<div class="form-group p-l-10 p-r-10">'
+' <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 %>">'
+'<%= ct.name %></option>'
+'<%end %>'
@@ -470,7 +470,7 @@ var cashier_type = "<%= @cashier_type %>";
+'<div class="form-group p-l-10 p-r-10">'
+' <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| %>'
// if (key.toString() == '<%= ct.value.to_s %>')
// var selected = "selected";
// else