Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
@@ -23,46 +23,45 @@ class Api::ApiController < ActionController::API
|
|||||||
@employee = Employee.find_by_token_session(current_token)
|
@employee = Employee.find_by_token_session(current_token)
|
||||||
end
|
end
|
||||||
|
|
||||||
def lookup_domain
|
# def lookup_domain
|
||||||
if request.subdomain.present? && request.subdomain != "www"
|
# if request.subdomain.present? && request.subdomain != "www"
|
||||||
from = request.subdomain.downcase + "." + request.domain.downcase
|
# from = request.subdomain.downcase + "." + request.domain.downcase
|
||||||
@license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
# @license = cache_license(ENV["SX_PROVISION_URL"], from) # request.subdomain.downcase
|
||||||
if (!@license.nil?)
|
# if (!@license.nil?)
|
||||||
logger.info "Location - " + @license.dbhost
|
# logger.info "Location - " + @license.dbhost
|
||||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
# ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||||
# authenticate_session_token
|
# # authenticate_session_token
|
||||||
# logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
# # logger.info "Connecting to - " + @license.subdomain + " - "+ @license.dbhost + "@" + @license.dbschema
|
||||||
else
|
# else
|
||||||
# reconnect_default_db
|
# # reconnect_default_db
|
||||||
logger.info 'License is nil'
|
# logger.info 'License is nil'
|
||||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
# # redirect_to root_url(:host => request.domain) + "store_error"
|
||||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
# render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
end
|
# end
|
||||||
|
|
||||||
def website_connection(license)
|
# def website_connection(license)
|
||||||
default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
# default_connection.dup.update(:host => license.dbhost, :database => license.dbschema.to_s.downcase,
|
||||||
:username => license.dbusername, :password => license.dbpassword)
|
# :username => license.dbusername, :password => license.dbpassword)
|
||||||
|
# end
|
||||||
|
|
||||||
end
|
# def reconnect_default_db
|
||||||
|
# ActiveRecord::Base.establish_connection(Rails.env)
|
||||||
|
# end
|
||||||
|
|
||||||
def reconnect_default_db
|
# # Regular database.yml configuration hash
|
||||||
ActiveRecord::Base.establish_connection(Rails.env)
|
# def default_connection
|
||||||
end
|
# @default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
||||||
|
# end
|
||||||
|
|
||||||
# Regular database.yml configuration hash
|
# def cache_license(url, lookup)
|
||||||
def default_connection
|
# @license = License.new(url, lookup)
|
||||||
@default_config ||= ActiveRecord::Base.connection.instance_variable_get("@config").dup
|
|
||||||
end
|
|
||||||
|
|
||||||
def cache_license(url, lookup)
|
# if (@license.detail_with_local_cache(lookup) == true)
|
||||||
@license = License.new(url, lookup)
|
# return @license
|
||||||
|
# else
|
||||||
if (@license.detail_with_local_cache(lookup) == true)
|
# return nil
|
||||||
return @license
|
# end
|
||||||
else
|
# end
|
||||||
return nil
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -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'))
|
@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')
|
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||||
@shop = Shop.first
|
@shop = Shop.first
|
||||||
|
|
||||||
# @shift = ShiftSale.current_open_shift(current_user.id)
|
# @shift = ShiftSale.current_open_shift(current_user.id)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -21,7 +21,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
@rooms = Room.all.active.order('status desc')
|
@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'))
|
@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')
|
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
|
||||||
|
|
||||||
@status_order = ""
|
@status_order = ""
|
||||||
@status_sale = ""
|
@status_sale = ""
|
||||||
@sale_array = Array.new
|
@sale_array = Array.new
|
||||||
|
|||||||
@@ -60,8 +60,8 @@ class License
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
# @license = Marshal.load(cache_license)
|
@license = Marshal.load(cache_license)
|
||||||
# assign(aes_key, aes_iv)
|
assign(aes_key, aes_iv)
|
||||||
# Rails.logger.info 'API License'
|
# Rails.logger.info 'API License'
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ class MyAesCrypt
|
|||||||
shop_json["data"].each do |j|
|
shop_json["data"].each do |j|
|
||||||
if j["lookup"] == from
|
if j["lookup"] == from
|
||||||
# add [0...44] for production cloud for remove \n
|
# add [0...44] for production cloud for remove \n
|
||||||
if(j["value"]["key"][0...44] == token)
|
if(j["value"]["key"] == token)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -46,18 +46,18 @@
|
|||||||
<% else %>
|
<% else %>
|
||||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
Zone <%= table.zone_id %> <br>
|
Zone <%= table.zone_id %> <br>
|
||||||
Table <%= table.name %> ( <%= table.seater %> Seat )
|
Table <%= table.name %> ( <%= table.seater %> Seat )
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<% if table.get_checkout_booking.nil? %>
|
<% if table.get_checkout_booking.nil? %>
|
||||||
<div class="card tables blue text-white" data-id="<%= table.id %>">
|
<div class="card tables blue text-white" data-id="<%= table.id %>">
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
<div class="card tables orange text-white" data-id="<%= table.id %>">
|
||||||
<% end %>
|
<% end %>
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
Zone <%= table.zone_id %> <br>
|
Zone <%= table.zone_id %> <br>
|
||||||
Table <%= table.name %> ( <%= table.seater %> Seat )
|
Table <%= table.name %> ( <%= table.seater %> Seat )
|
||||||
</div>
|
</div>
|
||||||
@@ -112,7 +112,7 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- tabs - End -->
|
<!-- tabs - End -->
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -86,3 +86,64 @@ class ActionController::Base
|
|||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
class ActionController::API
|
||||||
|
before_action :lookup_domain
|
||||||
|
|
||||||
|
private
|
||||||
|
|
||||||
|
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 cache_license(url, lookup)
|
||||||
|
@license = License.new(url, lookup)
|
||||||
|
|
||||||
|
if (@license.detail_with_local_cache(lookup) == true)
|
||||||
|
return @license
|
||||||
|
else
|
||||||
|
return nil
|
||||||
|
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)
|
||||||
|
|
||||||
|
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
|
||||||
|
|
||||||
|
#change locallization
|
||||||
|
def set_locale
|
||||||
|
I18n.locale = params[:locale] || I18n.default_locale
|
||||||
|
end
|
||||||
|
|
||||||
|
# RESTful url for localize
|
||||||
|
def default_url_options
|
||||||
|
{ locale: I18n.locale }
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@
|
|||||||
development:
|
development:
|
||||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||||
sx_provision_url: https://connect.pos-myanmar.com/bensai/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
sx_provision_url: https://connect.pos-myanmar.com/bensai/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||||
server_mode: application
|
server_mode: cloud
|
||||||
cipher_type: AES-256-CBC
|
cipher_type: AES-256-CBC
|
||||||
sx_key: Wh@t1$C2L
|
sx_key: Wh@t1$C2L
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user