Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
@@ -62,6 +62,9 @@ section .content{
|
||||
.nav-tabs {
|
||||
background-color: #eeeeee;
|
||||
}
|
||||
.nav-tabs .nav-link {
|
||||
padding: 0.7286rem 0.2575
|
||||
}
|
||||
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
|
||||
background-color: #fff;
|
||||
border-left: 6px solid #111;
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
class ApplicationController < ActionController::Base
|
||||
include LoginVerification
|
||||
include LicenseVerification
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
# lookup domain for db from provision
|
||||
before_action :lookup_domain, :set_locale
|
||||
before_action :set_locale
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
# alias_method :current_user, :current_login_employee,:current_user
|
||||
@@ -22,67 +23,6 @@ class ApplicationController < ActionController::Base
|
||||
{ locale: I18n.locale }
|
||||
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.name
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
# 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
|
||||
else
|
||||
# check for license file
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
puts "RUN SAY BYAR"
|
||||
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
|
||||
|
||||
rescue_from CanCan::AccessDenied do |exception|
|
||||
flash[:warning] = exception.message
|
||||
redirect_to root_path
|
||||
@@ -111,14 +51,6 @@ class ApplicationController < ActionController::Base
|
||||
@employee = Employee.find_by_token_session(session[:session_token])
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
def check_license
|
||||
if License.check_license_file
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseCrmController < ActionController::Base
|
||||
include LoginVerification
|
||||
class BaseCrmController < ApplicationController
|
||||
layout "CRM"
|
||||
|
||||
#before_action :check_installation
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseInventoryController < ActionController::Base
|
||||
include LoginVerification
|
||||
class BaseInventoryController < ApplicationController
|
||||
layout "inventory"
|
||||
|
||||
#before_action :check_installation
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseOqsController < ActionController::Base
|
||||
include LoginVerification
|
||||
class BaseOqsController < ApplicationController
|
||||
layout "OQS"
|
||||
|
||||
#before_action :check_installation
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseOrigamiController < ActionController::Base
|
||||
include LoginVerification
|
||||
class BaseOrigamiController < ApplicationController
|
||||
layout "origami"
|
||||
|
||||
# before_action :checkin_process
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
class BaseReportController < ActionController::Base
|
||||
include LoginVerification
|
||||
class BaseReportController < ApplicationController
|
||||
layout "application"
|
||||
|
||||
#before_action :check_installation
|
||||
|
||||
@@ -1,9 +1,6 @@
|
||||
class BaseWaiterController < ActionController::Base
|
||||
include LoginVerification
|
||||
class BaseWaiterController < ApplicationController
|
||||
layout "waiter"
|
||||
|
||||
#before_action :check_installation
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
|
||||
end
|
||||
|
||||
83
app/controllers/concerns/license_verification.rb
Normal file
83
app/controllers/concerns/license_verification.rb
Normal file
@@ -0,0 +1,83 @@
|
||||
module LicenseVerification
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
before_action :lookup_domain
|
||||
end
|
||||
|
||||
protected
|
||||
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.name
|
||||
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
|
||||
else
|
||||
# check for license file
|
||||
# if check_license
|
||||
# current_license(ENV["SX_PROVISION_URL"])
|
||||
# else
|
||||
# redirect_to activate_path
|
||||
# end
|
||||
end
|
||||
end
|
||||
|
||||
def authenticate_session_token
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
#Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if !@user
|
||||
flash[:notice] = 'Invalid Access!'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
flag = @license.detail_with_local_file()
|
||||
if (flag == 0)
|
||||
flash[:notice] = 'Expired or No License!'
|
||||
elsif (flag == 2)
|
||||
flash[:notice] = 'Expiring! Please, License extend...'
|
||||
else
|
||||
puts "RUN SAY BYAR"
|
||||
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
|
||||
end
|
||||
@@ -4,13 +4,12 @@ module LoginVerification
|
||||
included do
|
||||
before_action :authenticate
|
||||
helper_method :current_company,:current_login_employee
|
||||
|
||||
end
|
||||
|
||||
|
||||
protected
|
||||
# Authenticate the user with token based authentication
|
||||
def authenticate
|
||||
def authenticate
|
||||
authenticate_session_token || render_unauthorized
|
||||
end
|
||||
|
||||
@@ -18,12 +17,14 @@ module LoginVerification
|
||||
token = session[:session_token]
|
||||
if (token)
|
||||
#@current_user = User.find_by(api_key: token)
|
||||
Rails.logger.debug "token - " + token.to_s
|
||||
#Rails.logger.debug "token - " + token.to_s
|
||||
|
||||
@user = Employee.authenticate_by_token(token)
|
||||
if @user
|
||||
return true
|
||||
#Maybe log - login?
|
||||
else
|
||||
flash[:notice] = 'Invalid Access!'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -50,6 +51,10 @@ module LoginVerification
|
||||
end
|
||||
|
||||
private
|
||||
def check_license
|
||||
License.check_license_file
|
||||
end
|
||||
|
||||
def check_installation
|
||||
if current_company.nil?
|
||||
redirect_to install_path
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
class HomeController < ApplicationController
|
||||
class HomeController < ApplicationController
|
||||
# layout "application", except: [:index, :show]
|
||||
skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
|
||||
# skip_before_action only: [:index, :show, :create, :update, :destroy]
|
||||
|
||||
def index
|
||||
# @employees = Employee.all_emp_except_waiter.order("name asc")
|
||||
|
||||
@@ -33,7 +33,7 @@ class License
|
||||
##Get redis connection from connection pool
|
||||
redis = Redis.new
|
||||
cache_license = redis.get(cache_key)
|
||||
|
||||
|
||||
Rails.logger.info "Cache key - " + cache_key.to_s
|
||||
if cache_license.nil?
|
||||
##change the d/e key
|
||||
|
||||
@@ -82,16 +82,17 @@ class Sale < ApplicationRecord
|
||||
current_shift = ShiftSale.current_shift
|
||||
shift = ShiftSale.current_open_shift(cashier.id)
|
||||
|
||||
# set cashier
|
||||
# set cashier
|
||||
if shift != nil
|
||||
self.cashier_id = cashier.id
|
||||
self.cashier_name = cashier.name
|
||||
self.shift_sale_id = shift.id
|
||||
else
|
||||
if open_cashier.nil?
|
||||
self.cashier_id = requested_by.id
|
||||
self.cashier_name = requested_by.name
|
||||
self.shift_sale_id = current_shift.id
|
||||
if open_cashier.count>0
|
||||
self.cashier_id = open_cashier[0].id
|
||||
self.cashier_name = open_cashier[0].name
|
||||
shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
|
||||
self.shift_sale_id = shift_id.id
|
||||
else
|
||||
self.cashier_id = current_shift.employee_id
|
||||
self.cashier_name = Employee.find(current_shift.employee_id).name
|
||||
@@ -99,6 +100,7 @@ class Sale < ApplicationRecord
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
# set waiter
|
||||
self.requested_by = requested_by.name
|
||||
|
||||
|
||||
@@ -29,12 +29,12 @@
|
||||
<table class="table " id="order-items-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th width="4%">#</th>
|
||||
<th width="2%">#</th>
|
||||
<th class="" width="20%">Items</th>
|
||||
<th style="" width="13%">QTY
|
||||
</td>
|
||||
<th class="" width="13%">Price
|
||||
</td>
|
||||
<th style="" width="5%">QTY
|
||||
</th>
|
||||
<th class="" width="10%">Price
|
||||
</th>
|
||||
<!-- <th class='' width="17%"> Total </th> -->
|
||||
<th class='' width="20%"> Action</th>
|
||||
</tr>
|
||||
@@ -53,46 +53,46 @@
|
||||
unless sale_item.price == 0
|
||||
%>
|
||||
<tr>
|
||||
<td width="4%"><%= count %></td>
|
||||
<td class='' width="20%">
|
||||
<td class="p-1" width="2%"><%= count %></td>
|
||||
<td class="p-2" width="20%">
|
||||
<%= sale_item.product_name %>
|
||||
</td>
|
||||
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
|
||||
<td class='' width="10%">
|
||||
<td class="p-1" width="5%">
|
||||
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
|
||||
</td>
|
||||
<td class='' width="13%">
|
||||
<td class="p-1" width="10%">
|
||||
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
|
||||
</td>
|
||||
<!-- <td class='' width="17%">
|
||||
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
|
||||
</td> -->
|
||||
<td class='' width="25%">
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
|
||||
</td>
|
||||
|
||||
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
|
||||
<td class='' width="10%">
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class='' width="13%">
|
||||
<td class='' width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<!-- <td class='' width="17%">
|
||||
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
|
||||
</td> -->
|
||||
<td class='' width="25%">
|
||||
<td class="p-1" width="25%">
|
||||
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect cancel'>Cancel
|
||||
Void/Update
|
||||
</button>
|
||||
</td>
|
||||
<% else %>
|
||||
<td class='' width="13%">
|
||||
<td class="p-1" width="5%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td class='' width="13%">
|
||||
<td class="p-1" width="10%">
|
||||
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
|
||||
</td>
|
||||
<td></td>
|
||||
@@ -108,7 +108,7 @@
|
||||
<div class="card-footer">
|
||||
<table class="table" id="order-charges-table" border="0">
|
||||
<tr>
|
||||
<td width="50%"><strong>Sub Total:</strong></td>
|
||||
<td class="p-1" width="50%"><strong>Sub Total:</strong></td>
|
||||
<td><strong id="order-sub-total"><%= sub_total %></strong></td>
|
||||
</tr>
|
||||
<tr class="rebate_amount"></tr>
|
||||
@@ -117,12 +117,42 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="col-md-3">
|
||||
<div class="card p-l-15 p-r-15">
|
||||
<div class="card-block">
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="1" data-type="num">1</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="2" data-type="num">2</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="3" data-type="num">3</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="4" data-type="num">4</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="5" data-type="num">5</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="6" data-type="num">6</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="7" data-type="num">7</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="8" data-type="num">8</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="9" data-type="num">9</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="0" data-type="num">0</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="." data-type="num">.</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left" data-value="00" data-type="num">00</div>
|
||||
</div>
|
||||
<div class="row bottom">
|
||||
<div class="col-md-4 cashier_number border-top border- border-left green" data-type="nett">Nett</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left red" data-type="del">Del</div>
|
||||
<div class="col-md-4 cashier_number border-top border- border-left orange" data-type="clr">Clr</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- Column Three -->
|
||||
<div class="col-lg-2 col-md-2 col-sm-2">
|
||||
<div class="col-lg-1 col-md-1 col-sm-1">
|
||||
<!-- Waiter Buttons -->
|
||||
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
|
||||
<button type="button" class="btn btn-block btn-lg bg-danger waves-effect" id='cancel_all_void'>Cancel All Void</button>
|
||||
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
|
||||
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -225,4 +255,49 @@
|
||||
}
|
||||
});
|
||||
})
|
||||
|
||||
$( "input" ).focusin(function() {
|
||||
$('.addfocus').removeClass('addfocus');
|
||||
$( this ).addClass('addfocus');
|
||||
});
|
||||
|
||||
$(".cashier_number").on('click', function(event){
|
||||
if(event.handled !== true) {
|
||||
|
||||
var original_value='';
|
||||
original_value = $('.addfocus').val();
|
||||
|
||||
var input_type = $(this).attr("data-type");
|
||||
|
||||
switch (input_type) {
|
||||
case 'num':
|
||||
var input_value = $(this).attr("data-value");
|
||||
if (original_value == "0.0"){
|
||||
$('.addfocus').val(input_value);
|
||||
}
|
||||
else{
|
||||
$('.addfocus').val(original_value + '' + input_value);
|
||||
}
|
||||
break;
|
||||
|
||||
case 'add':
|
||||
var input_value = $(this).attr("data-value");
|
||||
amount = parseInt(input_value);
|
||||
$('.addfocus').val(amount);
|
||||
break;
|
||||
|
||||
case 'del' :
|
||||
var discount_text=$('.addfocus').val();
|
||||
$('.addfocus').val(discount_text.substr(0,discount_text.length-1));
|
||||
break;
|
||||
|
||||
case 'clr':
|
||||
$('.addfocus').val("");
|
||||
break;
|
||||
}
|
||||
event.handled = true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
development:
|
||||
secret_key_base: b61d85f8ed2a1a9e0eeece3443b3e8f838d002cc1d9f32115d8e93db920e2957adfedc57501d44741211538f3108b742cdeada87d5bfae796c53da1f90a3cd61
|
||||
sx_provision_url: connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||
server_mode: application
|
||||
sx_provision_url: 192.168.1.125:3002/api #connect.smartsales.dev/api #connect.smartsales.asia/api #provision.zsai.ws/api
|
||||
server_mode: cloud
|
||||
cipher_type: AES-256-CBC
|
||||
sx_key: Wh@t1$C2L
|
||||
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
{
|
||||
"data": []
|
||||
"data": [
|
||||
{
|
||||
"lookup": "chromis-1.zsai.ws",
|
||||
"value": {
|
||||
"key": "877eY5iPvpVzaYnIkc2FgIy0U85FtqpTpQGqoM/RCG0=\n",
|
||||
"iv": "qSVQaKzOm3TYmRP3DhHdig==\n"
|
||||
}
|
||||
},
|
||||
{
|
||||
"lookup": "gw2a-13.zsai.dev",
|
||||
"value": {
|
||||
"key": "R0uRkGlvCD5DGaPV4SkhGlwaMR0ohYBBmNna+tpRXMc=\n",
|
||||
"iv": "AP5iuLM36oJmnvLsWCo9+Q==\n"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user