diff --git a/app/controllers/api/authenticate_controller.rb b/app/controllers/api/authenticate_controller.rb index 8816b7af..6bd15a28 100755 --- a/app/controllers/api/authenticate_controller.rb +++ b/app/controllers/api/authenticate_controller.rb @@ -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 diff --git a/app/controllers/api/bill_controller.rb b/app/controllers/api/bill_controller.rb index b3742d44..22f1ede8 100755 --- a/app/controllers/api/bill_controller.rb +++ b/app/controllers/api/bill_controller.rb @@ -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]) diff --git a/app/controllers/api/payment/mobilepayment_controller.rb b/app/controllers/api/payment/mobilepayment_controller.rb index 7608f722..24461ae9 100644 --- a/app/controllers/api/payment/mobilepayment_controller.rb +++ b/app/controllers/api/payment/mobilepayment_controller.rb @@ -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 diff --git a/app/controllers/api/survey_controller.rb b/app/controllers/api/survey_controller.rb index 4736ba13..2f2da0e2 100644 --- a/app/controllers/api/survey_controller.rb +++ b/app/controllers/api/survey_controller.rb @@ -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]) diff --git a/app/controllers/base_crm_controller.rb b/app/controllers/base_crm_controller.rb index 08bc8138..2cf47467 100755 --- a/app/controllers/base_crm_controller.rb +++ b/app/controllers/base_crm_controller.rb @@ -1,5 +1,5 @@ class BaseCrmController < ActionController::Base - include LoginVerification, + include LoginVerification, MultiTenancy layout "CRM" before_action :check_user diff --git a/app/controllers/crm/customers_controller.rb b/app/controllers/crm/customers_controller.rb index 9cd67dde..6d7783fa 100644 --- a/app/controllers/crm/customers_controller.rb +++ b/app/controllers/crm/customers_controller.rb @@ -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) diff --git a/app/controllers/crm/dining_queues_controller.rb b/app/controllers/crm/dining_queues_controller.rb index cbb19b35..3eb6622e 100755 --- a/app/controllers/crm/dining_queues_controller.rb +++ b/app/controllers/crm/dining_queues_controller.rb @@ -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. diff --git a/app/controllers/foodcourt/addorders_controller.rb b/app/controllers/foodcourt/addorders_controller.rb index b0ea689d..7abbdd90 100755 --- a/app/controllers/foodcourt/addorders_controller.rb +++ b/app/controllers/foodcourt/addorders_controller.rb @@ -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) diff --git a/app/controllers/foodcourt/cash_ins_controller.rb b/app/controllers/foodcourt/cash_ins_controller.rb index 9f96dffd..7245ffa7 100755 --- a/app/controllers/foodcourt/cash_ins_controller.rb +++ b/app/controllers/foodcourt/cash_ins_controller.rb @@ -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]) diff --git a/app/controllers/foodcourt/cash_outs_controller.rb b/app/controllers/foodcourt/cash_outs_controller.rb index f890f51c..1dbf62d2 100755 --- a/app/controllers/foodcourt/cash_outs_controller.rb +++ b/app/controllers/foodcourt/cash_outs_controller.rb @@ -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]) diff --git a/app/controllers/foodcourt/dashboard_controller.rb b/app/controllers/foodcourt/dashboard_controller.rb index 4f6c5627..23c905b7 100644 --- a/app/controllers/foodcourt/dashboard_controller.rb +++ b/app/controllers/foodcourt/dashboard_controller.rb @@ -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| diff --git a/app/controllers/foodcourt/discounts_controller.rb b/app/controllers/foodcourt/discounts_controller.rb index 80d30cd9..e2ef8fcc 100755 --- a/app/controllers/foodcourt/discounts_controller.rb +++ b/app/controllers/foodcourt/discounts_controller.rb @@ -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 diff --git a/app/controllers/foodcourt/food_court_controller.rb b/app/controllers/foodcourt/food_court_controller.rb index 365bbc4b..519973ae 100644 --- a/app/controllers/foodcourt/food_court_controller.rb +++ b/app/controllers/foodcourt/food_court_controller.rb @@ -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 diff --git a/app/controllers/foodcourt/home_controller.rb b/app/controllers/foodcourt/home_controller.rb index 3d424f14..f894afc9 100755 --- a/app/controllers/foodcourt/home_controller.rb +++ b/app/controllers/foodcourt/home_controller.rb @@ -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) diff --git a/app/controllers/inventory/stock_checks_controller.rb b/app/controllers/inventory/stock_checks_controller.rb index e753b751..fea1ff0c 100755 --- a/app/controllers/inventory/stock_checks_controller.rb +++ b/app/controllers/inventory/stock_checks_controller.rb @@ -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' diff --git a/app/controllers/print_settings_controller.rb b/app/controllers/print_settings_controller.rb index 0d8c5280..f1f6ed68 100755 --- a/app/controllers/print_settings_controller.rb +++ b/app/controllers/print_settings_controller.rb @@ -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.' } diff --git a/app/views/origami/surveys/_form.html.erb b/app/views/origami/surveys/_form.html.erb index a4d8a666..b7ec4ca1 100755 --- a/app/views/origami/surveys/_form.html.erb +++ b/app/views/origami/surveys/_form.html.erb @@ -99,7 +99,7 @@ Foreigner - <% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %> + <% Lookup.where("lookup_type = ?", "country" ).each do |ct| %> <%= ct.name %> <%end %> @@ -293,7 +293,7 @@ var cashier_type = "<%= @cashier_type %>"; +'' +' ' - +'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' + +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>' +'' +'<%= ct.name %>' +'<%end %>' @@ -321,7 +321,7 @@ var cashier_type = "<%= @cashier_type %>"; +'' +' ' - +'<% Lookup.where("lookup_type = ? and shop_code='#{@shop.shop_code}'", "country" ).each do |ct| %>' + +'<% Lookup.where("lookup_type = ?", "country" ).each do |ct| %>' +'' +'<%= ct.name %>' +'<%end %>' @@ -470,7 +470,7 @@ var cashier_type = "<%= @cashier_type %>"; +'' +' ' - +'<% 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