Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes

This commit is contained in:
phyusin
2018-04-23 19:21:20 +06:30
7 changed files with 112 additions and 52 deletions

View File

@@ -23,46 +23,45 @@ class Api::ApiController < ActionController::API
@employee = Employee.find_by_token_session(current_token)
end
def lookup_domain
if request.subdomain.present? && request.subdomain != "www"
from = request.subdomain.downcase + "." + request.domain.downcase
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
if (!@license.nil?)
logger.info "Location - " + @license.dbhost
ActiveRecord::Base.establish_connection(website_connection(@license))
# authenticate_session_token
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
else
# reconnect_default_db
logger.info 'License is nil'
# redirect_to root_url(:host => request.domain) + "store_error"
render :json => [{ status: false, message: 'Invalid Access!'}]
end
end
end
# def lookup_domain
# if request.subdomain.present? && request.subdomain != "www"
# from = request.subdomain.downcase + "." + request.domain.downcase
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
# if (!@license.nil?)
# logger.info "Location - " + @license.dbhost
# ActiveRecord::Base.establish_connection(website_connection(@license))
# # authenticate_session_token
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
# else
# # reconnect_default_db
# logger.info 'License is nil'
# # redirect_to root_url(:host => request.domain) + "store_error"
# render :json => [{ status: false, message: 'Invalid Access!'}]
# end
# end
# end
def website_connection(license)
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
:username => license.dbusername, :password => license.dbpassword)
# def website_connection(license)
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
# :username => license.dbusername, :password => license.dbpassword)
# end
end
# def reconnect_default_db
# ActiveRecord::Base.establish_connection(Rails.env)
# end
def reconnect_default_db
ActiveRecord::Base.establish_connection(Rails.env)
end
# # Regular database.yml configuration hash
# def default_connection
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
# end
# Regular database.yml configuration hash
def default_connection
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
end
# def cache_license(url, lookup)
# @license = License.new(url, lookup)
def cache_license(url, lookup)
@license = License.new(url, lookup)
if (@license.detail_with_local_cache(lookup) == true)
return @license
else
return nil
end
end
# if (@license.detail_with_local_cache(lookup) == true)
# return @license
# else
# return nil
# end
# end
end

View File

@@ -9,7 +9,7 @@ class Origami::HomeController < BaseOrigamiController
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@shop = Shop.first
# @shift = ShiftSale.current_open_shift(current_user.id)
end
@@ -21,7 +21,7 @@ class Origami::HomeController < BaseOrigamiController
@rooms = Room.all.active.order('status desc')
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@status_order = ""
@status_sale = ""
@sale_array = Array.new