update license

This commit is contained in:
Thein Lin Kyaw
2020-06-19 10:46:52 +06:30
parent 02ba0f21e6
commit 7e9b4f7120
32 changed files with 387 additions and 393 deletions

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the dashboard controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -0,0 +1,3 @@
// Place all the styles related to the sessions controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View File

@@ -2,7 +2,8 @@ module LoginVerification
extend ActiveSupport::Concern
included do
before_action :authenticate_session_token
before_action :authenticate
puts "LoginVerification"
helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
end
@@ -86,7 +87,7 @@ 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
@@ -97,6 +98,6 @@ module LoginVerification
end
def render_unauthorized
redirect_to root_path
redirect_to login_path
end
end

View File

@@ -3,17 +3,32 @@ module MultiTenancy
included do
set_current_tenant_through_filter if respond_to? :set_current_tenant_through_filter
before_action :find_shop_by_subdomain_or_frist if respond_to? :before_action
before_action :set_current_tenant_by_subdomain_or_name if respond_to? :before_action
helper_method :current_shop if respond_to? :helper_method
end
private
def find_shop_by_subdomain_or_frist
if request.subdomain.present?
shop_code = request.subdomain.partition('-').last
shop = Shop.find_by(shop_code: shop_code)
else
shop = Shop.first
def set_current_tenant_by_subdomain_or_name
find_tenant_by_subdomain_or_name || not_found
end
def find_tenant_by_subdomain_or_name
if request.subdomains.last && request.subdomains.last != "www"
shop_code = request.subdomains.last.partition('-').last
set_current_tenant(Shop.find_by(shop_code: shop_code))
elsif Shop.count == 1
set_current_tenant(Shop.first)
end
set_current_tenant(shop)
end
def not_found
respond_to do |format|
format.html { render :file => "#{Rails.root}/public/404", :layout => false, :status => :not_found }
format.json { head :not_found }
end
end
def current_shop
ActsAsTenant.current_tenant
end
end

View File

@@ -0,0 +1,94 @@
class DashboardController < ApplicationController
def index
@from, @to = get_date_range_from_params
@shop = Shop.current_shop
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
@sales = Sale.receipt_date_between(@from, @to).completed
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
@orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id)
end
end
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top")
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom")
@hourly_sales = Sale.hourly_sales(current_user,@from,@to)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
employee_sales = Sale.employee_sales(current_user,@from,@to)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
@employee_sales = []
if !employee_sales.nil?
employee_sales.each do |emp|
emp_data = []
if emp.payment_amount > 0
emp_data.push([emp.e_name, emp.payment_amount])
@employee_sales.push({'name' => emp.payment_method, 'data' => emp_data})
end
end
end
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
@total_trans = Sale.total_trans(current_user,@from,@to)
@total_card = Sale.total_card_sale(current_user,@from,@to)
@total_credit = Sale.credit_payment(current_user,@from,@to)
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
pay = Sale.payment_sale(payment.payment_method, current_user,@from,@to)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
@summ_sale = Sale.summary_sale_receipt(current_user,@from,@to)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(current_user,@from,@to)
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id,current_user,@from,@to)
if !acc.nil? && acc.cnt_acc > 0
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
end
@top_items = Sale.top_items(current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(current_user,@from,@to)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
end
private
def get_date_range_from_params
if params[:from].present? && params[:to].present?
if params[:from_time].present? && params[:to_time].present?
from = Time.parse("#{params[:from]} #{params[:from_time]}")
to = Time.parse("#{params[:to]} #{params[:to_time]}")
else
from = Time.parse(params[:from])
to = Time.parse(params[:to]).end_of_day
end
else
from = Time.now.beginning_of_day
to = Time.now.end_of_day
end
return from, to
end
end

View File

@@ -1,234 +1,37 @@
class HomeController < ApplicationController
# layout "application", except: [:index, :show]
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
before_action :check_user, only: :dashboard
# Special check for only dashboard
def check_user
if current_user.nil?
redirect_to root_path
end
end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
def index
# @employees = Employee.all_emp_except_waiter.order("name asc")
@employees = Employee.all.where("is_active = true").order("name asc")
@roles = Employee.distinct.pluck(:role)
# byebug
# @roles = Lookup.collection_of("employee_roles")
@login_form = LoginForm.new()
render "layouts/login_dashboard", layout: false
redirect_to route_by_role
end
def show
@login_form = LoginForm.new()
@login_form.emp_id = params[:emp_id]
render "layouts/login", layout: false
end
private
def update
@login_form = LoginForm.new()
@login_form.emp_id = params[:emp_id]
@login_form.password = params[:login_form][:password]
@employee = Employee.login(@login_form.emp_id, @login_form.password)
if @employee != nil
session[:session_token] = @employee.token_session
route_by_role(@employee)
else
flash[:notice] ="Invalid PIN for Employee. Please try again!"
render :show
end
end
def create
@login_form = LoginForm.new()
@login_form.emp_id = params[:login_form][:emp_id]
@login_form.password = params[:login_form][:password]
@employee = Employee.login(@login_form.emp_id, @login_form.password)
if @employee != nil
if @employee.is_active
if @employee.role == "administrator"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "cashier"
session[:session_token] = @employee.token_session
route_by_role(@employee)
elsif @employee.role == "manager"
session[:session_token] = @employee.token_session
redirect_to dashboard_path
elsif @employee.role == "supervisor"
session[:session_token] = @employee.token_session
route_by_role(@employee)
# redirect_to origami_root_path
elsif @employee.role == "waiter"
session[:session_token] = @employee.token_session
route_by_role(@employee)
elsif @employee.role == "account"
session[:session_token] = @employee.token_session
redirect_to reports_dailysale_index_path
elsif @employee.role == "kitchen"
session[:session_token] = @employee.token_session
redirect_to oqs_root_path
else
render :index
end
else
redirect_to root_path, :notice => "This Employee is not active"
end
else
redirect_to root_path, :notice => "Username and Password doesn't match!"
end
end
def dashboard
@from, @to = get_date_range_from_params
@shop = Shop.current_shop
@orders = Sale.receipt_date_between(@from, @to).where("payment_status = 'new' and sale_status = 'bill'")
@sales = Sale.receipt_date_between(@from, @to).completed
if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
if shift = ShiftSale.current_open_shift(current_user.id)
@orders = @orders.where(shift_sale_id: shift.id)
@sales = @sales.where(shift_sale_id: shift.id)
end
end
@top_products = Sale.top_bottom_products(current_user,@from,@to,"top")
@bottom_products = Sale.top_bottom_products(current_user,@from,@to,"bottom")
@hourly_sales = Sale.hourly_sales(current_user,@from,@to)
# .group_by_hour(:created_at, :time_zone => 'Asia/Rangoon',format: '%I:%p')
# .sum(:grand_total)
employee_sales = Sale.employee_sales(current_user,@from,@to)
# .sum("(CASE WHEN sp.payment_method='cash' THEN ((sp.payment_amount) - (sales.amount_changed)) ELSE (sp.payment_amount) END)")
@employee_sales = []
if !employee_sales.nil?
employee_sales.each do |emp|
emp_data = []
if emp.payment_amount > 0
emp_data.push([emp.e_name, emp.payment_amount])
@employee_sales.push({'name' => emp.payment_method, 'data' => emp_data})
end
end
end
@inventories = StockJournal.inventory_balances(@from,@to).sum(:balance)
@total_trans = Sale.total_trans(current_user,@from,@to)
@total_card = Sale.total_card_sale(current_user,@from,@to)
@total_credit = Sale.credit_payment(current_user,@from,@to)
@sale_data = Array.new
@total_payment_methods = Sale.total_payment_methods(current_user,@from,@to)
if !@total_payment_methods.nil?
@total_payment_methods.each do |payment|
pay = Sale.payment_sale(payment.payment_method, current_user,@from,@to)
@sale_data.push({payment.payment_method => pay.payment_amount})
end
end
@summ_sale = Sale.summary_sale_receipt(current_user,@from,@to)
@total_customer, @total_dinein, @total_takeaway, @total_membership = Sale.total_customer(current_user,@from,@to)
# @total_other_customer = Sale.total_other_customer(today,current_user)
@total_order = Sale.total_order(current_user,@from,@to)
@total_accounts = Account.select("accounts.id as account_id, accounts.title as title")
@account_data = Array.new
if !@total_accounts.nil?
@total_accounts.each do |account|
acc = Sale.account_data(account.account_id,current_user,@from,@to)
if !acc.nil? && acc.cnt_acc > 0
@account_data.push({account.title => acc.cnt_acc, account.title + '_amount' => acc.total_acc})
end
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
end
@top_items = Sale.top_items(current_user,@from,@to)
@total_foc_items = Sale.total_foc_items(current_user,@from,@to)
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
end
def destroy
# clear in employee session
Employee.logout(session[:session_token])
session[:session_token] = nil
# redirect_to root_path
render :json => {:status=> "Success", :url => root_path }.to_json
end
def run_teamviewer
if File.directory?("/opt/teamviewer")
output = IO.popen('/opt/teamviewer/tv_bin/script/teamviewer')
render :json => {:status=> true}
else
render :json => {:status=> false}
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def settings_home_params
params.require(:login_form).permit(:emp_id, :password)
end
def route_by_role(employee)
if employee.role == "administrator"
# redirect_to dashboard_path
shift = ShiftSale.current_open_shift(employee.id)
if !shift.nil?
redirect_to origami_root_path
else
redirect_to dashboard_path
end
elsif employee.role == "cashier"
def route_by_role
if current_user.role == "administrator"
dashboard_path
elsif current_user.role == "cashier"
#check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee.id)
shift = ShiftSale.current_open_shift(current_user.id)
if !shift.nil?
redirect_to origami_dashboard_path
# redirect_to origami_root_path
origami_dashboard_path
else
redirect_to new_origami_shift_path
new_origami_shift_path
end
elsif employee.role == "manager"
redirect_to dashboard_path
elsif employee.role == "waiter"
redirect_to origami_dashboard_path
elsif employee.role == "crm"
redirect_to crm_root_path
elsif employee.role == "supervisor"
redirect_to origami_dashboard_path
elsif employee.role == "account"
redirect_to reports_dailysale_index_path
elsif current_user.role == "manager"
dashboard_path
elsif current_user.role == "supervisor"
origami_dashboard_path
elsif current_user.role == "waiter"
origami_dashboard_path
elsif current_user.role == "crm"
crm_root_path
elsif current_user.role == "account"
reports_dailysale_index_path
elsif @current_user.role == "kitchen"
oqs_root_path
else
login_path
end
end
def get_date_range_from_params
if params[:from].present? && params[:to].present?
if params[:from_time].present? && params[:to_time].present?
from = Time.parse("#{params[:from]} #{params[:from_time]}")
to = Time.parse("#{params[:to]} #{params[:to_time]}")
else
from = Time.parse(params[:from])
to = Time.parse(params[:to]).end_of_day
end
else
from = Time.now.beginning_of_day
to = Time.now.end_of_day
end
return from, to
end
end

View File

@@ -19,55 +19,31 @@ class InstallController < BaseController
db_password = params[:db_password]
phrase = license_key
# Check Exists IV
# if flag == "<%= ENV['AES_IV'] %>"
# # Export for Key
# aes = MyAesCrypt.new
# aes_key, aes_iv = aes.export_key(phrase)
# else
# aes_key = ENV["AES_KEY"]
# aes_iv = ENV["AES_IV"]
# end
@license = License.new(ENV["SX_PROVISION_URL"], request.host)
response = @license.license_activate(restaurant, license_key, db_host, db_schema, db_user, db_password)
if response[:status]
redirect_to root_url, notice: response["message"]
redirect_to root_path, notice: response["message"]
else
redirect_to activate_path, notice: response["message"]
end
end
private
def lookup_domain
if ENV["SERVER_MODE"] == "cloud"
not_found
elsif ENV["SERVER_MODE"] == "application"
if check_license #(request.host)
redirect_to root_url
end
elsif request.subdomains.last && request.subdomains.last != "www"
if check_license #(request.host)
redirect_to root_url
elsif !check_subdomain(request.host)
not_found
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
if current_license.exists? #(request.host)
if current_license.expired?
redirect_to review_license_path
else
redirect_to root_path
end
end
else
not_found
end
end
# def current_license(url, key)
# @license = License.new(url, key)
# ##creating md5 hash
# md5_hostname = Digest::MD5.new
# md5key = md5_hostname.update(request.host)
# if (@license.detail_with_local_cache(key, md5key.to_s) == true)
# #if (@license.detail == true)
# return @license
# else
# return nil
# end
# end
end

View File

@@ -1,16 +0,0 @@
class RenewLicenseController < ApplicationController
def expire
@license = current_license
@plan = @license.read_license("plan_name")
@bis_name = @license.read_license_no_decrypt("shop_name")
@expired_at = @license.read_license("renewable_date")
@license_status = @license.detail_with_local_file
end
def renew
status, message = current_license.verify_license
render json: {message: message, status: status}
end
end

View File

@@ -0,0 +1,33 @@
class ReviewLicenseController < ApplicationController
def index
@license = current_license
@plan = @license.read_license("plan_name")
@bis_name = @license.read_license_no_decrypt("shop_name")
@expired_at = @license.read_license("renewable_date")
@license_status = @license.detail_with_local_file
end
def create
if current_license.verify_license
redirect_to root_path
else
redirect_to review_license_path, flash: { message: '*** License can not be verified ***' }
end
end
private
def lookup_domain
if ENV["SERVER_MODE"] == "cloud"
not_found
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
if !current_license.exists? #(request.host)
redirect_to activate_path
end
else
not_found
end
end
end

View File

@@ -0,0 +1,76 @@
class SessionsController < ApplicationController
skip_before_action :authenticate, only: [:index, :show, :update, :create, :destroy]
# Special check for only dashboard
def index
# @employees = Employee.all_emp_except_waiter.order("name asc")
@employees = Employee.all.where("is_active = true").order("name asc")
@roles = Employee.distinct.pluck(:role)
# byebug
# @roles = Lookup.collection_of("employee_roles")
@login_form = LoginForm.new()
render "layouts/login_dashboard", layout: false
end
def show
@login_form = LoginForm.new()
@login_form.emp_id = params[:emp_id]
render "layouts/login", layout: false
end
def update
@login_form = LoginForm.new()
@login_form.emp_id = params[:emp_id]
@login_form.password = params[:login_form][:password]
@employee = Employee.login(@login_form.emp_id, @login_form.password)
if @employee != nil
session[:session_token] = @employee.token_session
redirect_to root_path
else
flash[:notice] = "Invalid PIN for Employee. Please try again!"
render :show
end
end
def create
@login_form = LoginForm.new(settings_home_params)
@employee = Employee.login(@login_form.emp_id, @login_form.password)
if @employee != nil
if @employee.is_active
session[:session_token] = @employee.token_session
redirect_to root_path
else
redirect_to login_path, :notice => "This Employee is not active"
end
else
redirect_to login_path, :notice => "Username and Password doesn't match!"
end
end
def destroy
# clear in employee session
Employee.logout(session[:session_token])
session[:session_token] = nil
# redirect_to root_path
render :json => {:status=> "Success", :url => root_path }.to_json
end
def run_teamviewer
if File.directory?("/opt/teamviewer")
output = IO.popen('/opt/teamviewer/tv_bin/script/teamviewer')
render :json => {:status=> true}
else
render :json => {:status=> false}
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def settings_home_params
params.require(:login_form).permit(:emp_id, :password)
end
end

View File

@@ -0,0 +1,2 @@
module DashboardHelper
end

View File

@@ -0,0 +1,2 @@
module SessionsHelper
end

View File

@@ -151,47 +151,35 @@ class License
def verify_license
api_token = read_license_no_decrypt("api_token")
@params = { query: {lookup_type: "application", api_token: api_token} }
old_renewable_date = read_license("renewable_date")
begin
response = self.class.get("/verify", @params)
@varified = response.parsed_response
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
if (@varified["status"])
if old_renewable_date.to_date == @varified['renewable_date'].to_date
message = "*** License can't be verified. ***"
status = 2
elsif old_renewable_date.to_date < @varified['renewable_date'].to_date
old_renewable_date = read_license("renewable_date")
if old_renewable_date.to_date < @varified['renewable_date'].to_date
update_license("renewable_date", @varified['renewable_date'])
status = 1
message = "*** License con be verified. ***"
return true
end
return status, message
else
delete_license_file
stauts = 0
message = "*** Your license has been expired. ***"
return status, message
end
rescue SocketError => e
Rails.logger.debug "In SocketError No Internet connection ! "
return true
rescue HTTParty::Error
Rails.logger.debug "Server Error HTTParty"
return true
rescue Net::OpenTimeout
Rails.logger.debug "connection Timeout"
return true
rescue OpenURI::HTTPError
Rails.logger.debug "Can't connect server"
return true
end
return false
end
def exists?
License.check_license_file(lookup)
end
def expired?
if renewal_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str)
@@ -234,6 +222,7 @@ class License
params = { query: { lookup_type: "cloud", lookup: lookup, iv_key: aes_iv} }
response = self.class.get("/subdomain", params)
response.parsed_response["status"]
rescue
end
# Check License File exists
@@ -241,15 +230,21 @@ class License
return unless File.exist?("config/license.yml")
if license = YAML.load_file("config/license.yml")
if license[lookup].nil?
if ENV["SERVER_MODE"] == "application"
license[lookup] = license.values.first
if license['iv_key']
license = { lookup => license }
else
tld_length = Rails.application.config.action_dispatch.tld_length
subdomains = URL.extract_subdomains(lookup, tld_length)
if key = license.keys.find { |k| URL.extract_subdomains(k, tld_length).last == subdomains.last}
license[lookup] = license[key]
if subdomains.last && subdomains.last != 'www'
if key = license.keys.find { |k| URL.extract_subdomains(k, tld_length).last == subdomains.last}
license[lookup] = license[key]
end
else
license[lookup] = license.values.first
end
end
if license[lookup]
File.open("config/license.yml", "w") { |file| file.write license.to_yaml }
end
@@ -260,9 +255,8 @@ class License
# read line by key for license file
def read_license(key_name)
key, iv = get_redis_key()
if File.exist?("config/license.yml")
key, iv = get_redis_key()
if license = YAML.load(File.read("config/license.yml"))
if license[lookup]
AESCrypt.decrypt_data(decode_str(license[lookup][key_name]), decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
@@ -284,13 +278,12 @@ class License
# Update license file for line
def update_license(content, new_content)
key, iv = get_redis_key()
if !new_content.include? "=="
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
if File.exist?("config/license.yml")
key, iv = get_redis_key()
if !new_content.include? "=="
crypted_str = AESCrypt.encrypt_data(new_content, decode_str(key), decode_str(iv), ENV['CIPHER_TYPE'])
end
if license = YAML.load_file("config/license.yml")
license[lookup][content] = encode_str(crypted_str)

View File

@@ -349,6 +349,7 @@
<% end %>
<% end %>
</div>
<% if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' %>
<% if isMobile.include? "Mobile" %>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-6 col-lg-6 ">
@@ -371,6 +372,7 @@
</div>
</div>
<% end %>
<% end %>
</div>
<script type="text/javascript">

View File

@@ -2,16 +2,11 @@
<% date_count = (renewable_date.to_date - Date.today).to_i %>
<% day = pluralize( date_count, 'day' )%>
<% if @license_status == 0
text = 'Your license has been expired.'
elsif @license_status == 2
if date_count == 0
text = "Your license will expire in tomorrow."
else
text = "Your license will expire in #{day}."
end
end
%>
<% if @license_status == 0 %>
<% text = 'Your license has been expired.' %>
<% else %>
<% text = "Your license will expire in #{day}." %>
<% end %>
<style>
.centered {
position: fixed;
@@ -29,13 +24,16 @@
<div class="col-sm-2"></div>
<div class="card col-sm-8 centered">
<div class="card-block">
<h3 class="pt-2 d-inline">Review Your License</h3>
<%= link_to origami_dashboard_url do %>
<img src="/image/logo.png" style="margin-left: 25pc; width: 140px">
<img src="/image/logo.png" class="mr-4 mt-2 float-right" style="width: 150px">
<% end %>
<p class="m-t--30" id="warning_text" style="font-weight: bold; font-size: 18px;"></p><br>
<h3 class="mt-4 mb-4">Review Your License</h3>
<% if flash[:message].present? %>
<p class="text-danger" style="font-weight: bold; font-size: 18px;"><%= flash[:message] %></p>
<% end %>
<br>
<% if text %>
<h6 class="mb-2 "><%= text %></h6><br>
<h6 class="mb-2"><%= text %></h6><br>
<% end %>
<h6 class="mb-2">Call Center Phone No: <a href="tel:+6494461709">+959 445 665 311</a></h6>
<br>
@@ -59,11 +57,11 @@
</div>
</div>
<br>
<div class="col-md-12" style="padding-bottom: 20px;">
<button type="button" class="btn btn-primary btn-lg float-right m-l-10 m-r-5" id="review_license">
Review License
</button>
<%= link_to 'Go To Home', origami_dashboard_url, class: 'btn btn-default btn-lg float-right', id: 'go_to_home' %>
<div class="col-md-12 mb-2">
<%= form_with url: review_license_url, local: true do %>
<%= submit_tag 'Review Licese', class: 'btn btn-primary btn-lg float-right m-l-10 m-r-5' %>
<%= link_to 'Go To Home', root_url, class: 'btn btn-default btn-lg float-right' %>
<% end %>
</div>
</div>
<div class="col-sm-2"></div>
@@ -72,28 +70,9 @@
<script>
$(document).ready(function() {
$('.alert-danger, .navbar, #warning_text').hide()
$('.alert-danger, .navbar').hide()
$('html, section').css('background-color', '#61B8C9')
// $('html').css('overflow-x', 'hidden')
$('section.content').css('margin', '70px 0 0 0')
$('#review_license').on ('click', function() {
$.ajax({
url: '/renew',
type: 'POST',
success: function(res) {
if (res.message.length != 0) {
if (res.status == 1) {
color = 'text-success'
} else if (res.status == 2) {
color = 'text-danger'
} else {
color = 'text-danger'
$('#go_to_home').hide()
}
$('#warning_text').addClass(color).text(res.message).show()
}
}
})
})
})
</script>

View File

@@ -16,7 +16,7 @@
<% if license_status == 0 || license_status == 2 %>
<div id="license-alert" class="alert alert-danger fade show text-center" role="alert">
<strong style="margin-left: 40px !important"><%= text %></strong>
<%= link_to 'Review License', expire_url, class: 'btn btn-sm btn-primary', style: "margin-left: 20px !important"%>
<%= link_to 'Review License', review_license_url, class: 'btn btn-sm btn-primary', style: "margin-left: 20px !important"%>
<button type="button" class="close btn-close" data-dismiss="alert" aria-label="Close" style="padding-top: 5px;">
<span aria-hidden="true" class="text-white">&times;</span>
</button>
@@ -30,8 +30,8 @@
navbar = $('.navbar');
leftsidebar = $('#leftsidebar');
if (<%= license_status %> == 1) {
navbar.css("top", 0);
leftsidebar.css("top", 0);
navbar.css("top", "");
leftsidebar.css("top", "");
$('section.content').css('margin-top', '0 !important');
}
else {

View File

@@ -1,5 +1,5 @@
class ActionController::Base
before_action :lookup_domain if Rails.env.production?
before_action :lookup_domain
before_action :set_locale
helper_method :current_license,
@@ -25,12 +25,10 @@ class ActionController::Base
end
elsif ENV["SERVER_MODE"] == "application" || request.subdomains.last && request.subdomains.last != "www"
# check for license file
if !check_license
if ENV["SERVER_MODE"] == "application" || check_subdomain
redirect_to activate_path
else
not_found
end
if !current_license.exists?
redirect_to activate_path
elsif current_license.expired?
redirect_to review_license_path
end
else
not_found
@@ -53,15 +51,6 @@ class ActionController::Base
current_license.check_license_subdomain
end
def check_license
if License.check_license_file(request.host)
if current_license.expired?
return false
end
return true
end
end
def check_installation
if current_company.nil?
redirect_to install_path
@@ -117,7 +106,7 @@ class ActionController::API
not_found
end
elsif ENV["SERVER_MODE"] == "application" || (request.subdomains.last && request.subdomains.last != "www")
not_found unless check_license
not_found unless current_license.exists? && !current_license.expired?
else
not_found
end
@@ -135,15 +124,6 @@ class ActionController::API
end
end
def check_license
if License.check_license_file(request.host)
if current_license.expired?
return false
end
return true
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)

View File

@@ -22,15 +22,17 @@ scope "(:locale)", locale: /en|mm/ do
get 'get_key' => 'sym_control#get_key'
#--------- Login/Authentication ------------#
get 'auth/:emp_id' => 'home#show', as: :emp_login
patch "auth/:emp_id" => 'home#update', as: :emp_login_update
get 'login' => 'sessions#index'
get 'auth/:emp_id' => 'sessions#show', as: :emp_login
patch "auth/:emp_id" => 'sessions#update', as: :emp_login_update
post 'login' => 'home#create'
delete 'logout' => 'home#destroy'
get 'dashboard' => 'home#dashboard'
post 'login' => 'sessions#create'
delete 'logout' => 'sessions#destroy'
get 'expire' => 'renew_license#expire'
post 'renew' => 'renew_license#renew'
get 'review_license' => 'review_license#index'
post 'review_license' => 'review_license#create'
get 'dashboard' => 'dashboard#index'
namespace :induties do
# resources :assign_in_duties

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe DashboardController, type: :controller do
end

View File

@@ -0,0 +1,5 @@
require 'rails_helper'
RSpec.describe SessionsController, type: :controller do
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the DashboardHelper. For example:
#
# describe DashboardHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe DashboardHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end

View File

@@ -0,0 +1,15 @@
require 'rails_helper'
# Specs in this file have access to a helper object that includes
# the SessionsHelper. For example:
#
# describe SessionsHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# expect(helper.concat_strings("this","that")).to eq("this that")
# end
# end
# end
RSpec.describe SessionsHelper, type: :helper do
pending "add some examples to (or delete) #{__FILE__}"
end