Merge branch 'r-1902001-01' into foodcourt

This commit is contained in:
Thein Lin Kyaw
2020-07-11 04:00:55 +06:30
99 changed files with 2085 additions and 1781 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

@@ -373,25 +373,10 @@ function setCommPorts(comPortLists) {
}
/** pay with CB bank **/
function pay_withBank(
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
cashier_type
) {
$("#loading_wrapper").show();
function pay_withBank(cmd_type, payment_type, bnk_bill_amount,sale_id,receipt_no,cashier_type) {
$("#loading_wrapper").show();
var com_port = $("#com_port_name").val();
reqCardSaleTrans(
cmd_type,
payment_type,
bnk_bill_amount,
sale_id,
receipt_no,
com_port,
cashier_type
);
reqCardSaleTrans(cmd_type, payment_type, bnk_bill_amount, sale_id, receipt_no, com_port,cashier_type);
}
//add req data to card_sale_trans table

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 api/menu_item_groups 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 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

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

View File

@@ -6,7 +6,7 @@ class Api::BillController < Api::ApiController
def create
@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 shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0])
if !ShiftSale.current_shift.nil?
#create Bill by Booking ID
table = 0

View File

@@ -1,8 +1,8 @@
module LoginVerification
extend ActiveSupport::Concern
included do
before_action :authenticate_session_token
helper_method :current_company, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :current_shop
before_action :authenticate
helper_method :current_company, :current_shop, :current_login_employee, :current_user, :get_cashier, :order_reservation, :bank_integration, :shop_detail
end
#this is base api base controller to need to inherit.
@@ -74,9 +74,10 @@ module LoginVerification
def authenticate_session_token
token = session[:session_token]
puts "token #{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
@@ -86,6 +87,6 @@ module LoginVerification
end
def render_unauthorized
redirect_to root_path
redirect_to login_path
end
end

View File

@@ -15,14 +15,8 @@ module MultiTenancy
def find_tenant_by_subdomain_or_name
if request.subdomains.last && request.subdomains.last != "www"
set_current_tenant(Shop.find_by(subdomain: request.subdomains.last))
elsif ENV["SERVER_MODE"] == "application"
license = License.new(ENV["SX_PROVISION_URL"], request.host)
shop_name = license.read_license_no_decrypt("shop_name")
if Rails.env.production? || shop_name
set_current_tenant(Shop.find_by(name: shop_name))
else
set_current_tenant(Shop.first)
end
elsif Shop.count == 1
set_current_tenant(Shop.first)
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)
@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

@@ -87,6 +87,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
def current_shift_order_count
@current_shift = ShiftSale.current_shift
status = ['completed', 'void']
@pending_sales = Sale.where('shift_sale_id = ? AND sale_status NOT IN (?)', @current_shift.id, status)
@pending_orders = Sale.pending_order('food_court')
@occupied_table = @pending_sales.length + @pending_orders.length
@@ -97,10 +98,10 @@ class Foodcourt::OrdersController < BaseFoodcourtController
@cashier_type = "food_court"
today = DateTime.now
day = Date.today.wday
@menus = []
@menu = []
if params[:id].include? "BKI"
@table_id = nil
@table = nil
@@ -266,7 +267,7 @@ class Foodcourt::OrdersController < BaseFoodcourtController
if ["quick_service", "food_court"].include? order.source
redirect_to "/foodcourt/sale/#{sale_data.sale_id}/food_court/payment#"
end
#
#
end
def completed

View File

@@ -69,8 +69,6 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server
# if !close_cashier_print[0].nil?
# @close_cashier_print = close_cashier_print[0][1]
# end
@@ -112,6 +110,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
@@ -125,7 +124,7 @@ class Foodcourt::ShiftsController < BaseFoodcourtController
end
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
if find_close_cashier_print[0][1].to_i > 0
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,"foocourt")
printer.print_close_cashier(print_settings,cashier_terminal,@shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods,"foodcourt")
end
end
end

View File

@@ -8,11 +8,6 @@ class Foodcourt::VoidController < BaseFoodcourtController
access_code = params[:access_code]
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(0, nil, order_source)
end
# update count for shift sale
if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
@@ -28,6 +23,11 @@ class Foodcourt::VoidController < BaseFoodcourtController
end
end
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(0, nil, order_source)
end
sale.rounding_adjustment = 0.0
sale.payment_status = 'void'
sale.sale_status = 'void'

View File

@@ -1,256 +1,54 @@
class HomeController < ApplicationController
# layout "application", except: [:index, :show]
# skip_before_action :authenticate, only: [:index, :show, :create, :update, :destroy]
include PrecisionHelper
before_action :check_user, only: :dashboard
# Special check for only dashboard
def check_user
if current_user.nil?
redirect_to root_path
end
end
##already check current_user with helper_method
# 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(current_shop,@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
elsif @employee.role == "foodcourt_cashier"
session[:session_token] = @employee.token_session
route_by_role(@employee)
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)
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"
food_court = Lookup.find_by_lookup_type_and_value("food_court", "1")
#check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee)
shift = ShiftSale.current_open_shift(current_user)
if food_court
if !shift.nil?
redirect_to foodcourt_food_court_path(:anchor => "")
foodcourt_food_court_path(:anchor => "")
else
redirect_to new_foodcourt_shift_path
new_foodcourt_shift_path
end
else
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
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
elsif employee.role == "foodcourt_cashier"
#check if cashier has existing open cashier
shift = ShiftSale.current_open_shift(employee)
if !shift.nil?
redirect_to foodcourt_food_court_path
foodcourt_food_court_path
else
redirect_to new_foodcourt_shift_path
new_foodcourt_shift_path
end
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

@@ -1,6 +1,6 @@
class InstallController < BaseController
skip_before_action :set_current_tenant_by_subdomain_or_name
skip_before_action :verify_authenticity_token
before_action :lookup_domain
def index
end
@@ -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

@@ -14,7 +14,7 @@ class Origami::DashboardController < BaseOrigamiController
@sale_data.push({payment.payment_method => pay.payment_amount})
end
else
@sale_data = nil
@sale_data = nil
end
@summ_sale = Sale.summary_sale_receipt(current_user)
@@ -35,7 +35,7 @@ class Origami::DashboardController < BaseOrigamiController
end
@total_accounts = @total_accounts.reject.with_index { |x, i| @account_data[i].nil? }
else
@account_data = nil
@account_data = nil
end

View File

@@ -390,7 +390,7 @@ class Origami::PaymentsController < BaseOrigamiController
# else
# table = DiningFacility.find(bookings[0].dining_facility_id)
# end
shift = ShiftSale.current_open_shift(current_user.id)
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else
@@ -506,7 +506,7 @@ class Origami::PaymentsController < BaseOrigamiController
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
shift = ShiftSale.current_open_shift(current_user.id)
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
cashier_terminal = CashierTerminal.find(shift.cashier_terminal_id)
else

View File

@@ -111,7 +111,7 @@ class Origami::ShiftsController < BaseOrigamiController
@total_takeway = ShiftSale.get_total_takeway(@shift).total_takeway_amount
@total_other_charges = ShiftSale.get_total_other_charges(@shift).total_other_charges_amount
@total_credit_payments = ShiftSale.get_shift_sales_with_credit_payment(shift_id).total_credit_payments
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
# get printer info
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::CashierStationPrinter.new(print_settings)
@@ -124,9 +124,7 @@ class Origami::ShiftsController < BaseOrigamiController
end
find_close_cashier_print = Lookup.collection_of('close_cashier_print')
if find_close_cashier_print[0][1].to_i > 0
printer.print_close_cashier(print_settings,cashier_terminal, @shift, @sale_items, @total_other_charges_info, current_shop,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments)
printer.print_close_cashier(print_settings,cashier_terminal, @shift, @sale_items, @total_other_charges_info, shop_details,@sale_taxes,@other_payment,@total_amount_by_account,@total_discount_by_account,@total_member_discount,@total_dinein,@total_takeway,@total_other_charges,@total_waste,@total_spoile,@total_credit_payments,@payment_methods)
end
end
end

View File

@@ -9,11 +9,6 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(0, nil, order_source)
end
# update count for shift sale
if(sale.sale_status == "completed")
if sale.shift_sale_id != nil
@@ -29,6 +24,11 @@ class Origami::VoidController < BaseOrigamiController
end
end
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(0, nil, order_source)
end
sale.rounding_adjustment = 0.0
sale.payment_status = 'void'
sale.sale_status = 'void'
@@ -94,47 +94,47 @@ class Origami::VoidController < BaseOrigamiController
customer= Customer.find(sale.customer_id)
#shop detail
shop_details = Shop.current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
#shop detail
shop_details = Shop.current_shop
# get member information
rebate = MembershipSetting.find_by_rebate(1)
if customer.membership_id != nil && rebate
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer,sale.receipt_no)
# current_balance = SaleAudit.paymal_search(sale_id)
current_balance = 0
end
printer = PrintSetting.all
printer = PrintSetting.all
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
unique_code="ReceiptBillPdf"
if !printer.empty?
printer.each do |printer_setting|
if printer_setting.unique_code == 'ReceiptBillPdf'
unique_code="ReceiptBillPdf"
elsif printer_setting.unique_code == 'ReceiptBillA5Pdf'
unique_code="ReceiptBillA5Pdf"
elsif printer_setting.unique_code == 'ReceiptBillStarPdf'
unique_code="ReceiptBillStarPdf"
end
end
end
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total
item_price_by_accounts = SaleItem.calculate_price_by_accounts(sale.sale_items)
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
other_amount = SaleItem.calculate_other_charges(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
filename, sale_receipt_no, printer_name = printer.print_receipt_bill(print_settings, false, nil,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,other_amount,nil,nil,nil)
result = {
:filepath => filename,
:printer_model => print_settings.brand_name,
:printer_url => print_settings.api_settings
}
# Mobile Print
render :json => result.to_json
# Mobile Print
render :json => result.to_json
# end
#end print

View File

@@ -9,10 +9,7 @@ class Origami::WasteSpoileController < BaseOrigamiController
SaleTax.where("sale_id='#{sale_id}'").find_each do |existing_tax|
existing_tax.delete
end
sale.update_attributes(total_discount: 0,total_tax: 0,grand_total: sale.total_amount,rounding_adjustment:0)
sale.payment_status = remark
sale.sale_status = remark
sale.save
sale.update_attributes(total_discount: 0, total_tax: 0, grand_total: sale.total_amount, rounding_adjustment:0, payment_status: remark, sale_status: remark)
# add to sale item with foc
# sale_items = SaleItem.where("sale_id='#{ sale_id }' and status is null")

View File

@@ -19,5 +19,4 @@ class Reports::DailysaleController < BaseReportController
def show
end
end

View File

@@ -1,69 +1,65 @@
class Reports::PaymentMethodController < BaseReportController
# authorize_resource :class => false
def index
# authorize_resource :class => false
def index
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
@payment_methods = PaymentMethodSetting.where("is_active='1'").pluck("payment_method")
@payments = [["All",''], ["Cash","cash"], ["Credit","creditnote"], ["FOC","foc"]]
@payments += PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method.parameterize == 'paymal' ? 'Card' : payment_method, payment_method.parameterize] }
@payments = [["All",''], ["Cash","cash"], ["Card", "card"], ["Credit","creditnote"],
["FOC","foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
# @payment_methods.each do |m|
# @payments.push(["#{m} Payment", m.parameterize])
# end
from, to = get_date_range_from_params
# @payment_methods.each do |m|
# @payments.push(["#{m} Payment", m.parameterize])
# end
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@payment_type = params[:payment_type]
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift,from,to,@payment_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
from, to = get_date_range_from_params
@shift = ''
if params[:shift_name].to_i != 0
shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',shift_sale.shift_started_at, shift_sale.shift_closed_at)
end
end
@payment_type = params[:payment_type]
@sale_data,@pyament_method = Sale.get_payment_method_by_shift(@shift,from,to,@payment_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
respond_to do |format|
format.html
format.xls
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -1,69 +1,67 @@
class Reports::ReceiptNoDetailController < BaseReportController
authorize_resource :class => false
def index
@payment_methods = [["All", ''], ["Cash", "cash"], ["Card", "card"], ["Credit", "creditnote"], ["FOC", "foc"]] + PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method, payment_method.parameterize] }
from, to = get_date_range_from_params
def index
@payment_methods = [["All", ''], ["Cash", "cash"], ["Credit", "creditnote"], ["FOC", "foc"]]
@payment_methods += PaymentMethodSetting.pluck(:payment_method).map { |payment_method| [payment_method.parameterize == 'paymal' ? 'Card' : payment_method, payment_method.parameterize] }
@shift_sale_range = ''
from, to = get_date_range_from_params
@shift = ''
if params[:shift_name].to_i != 0
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift = ''
if params[:shift_name].to_i != 0
@shift_sale_range = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
@shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else
if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end
end
end
@shift_sale = ShiftSale.find(params[:shift_name])
if to.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL ',@shift_sale.shift_started_at)
else
if @shift_sale.shift_closed_at.blank?
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at is NULL',@shift_sale.shift_started_at)
else
@shift = ShiftSale.where('shift_started_at = ? and shift_closed_at = ? ',@shift_sale.shift_started_at, @shift_sale.shift_closed_at)
end
end
end
payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
payment_type = params[:payment_type]
@sale_data = Sale.get_shift_sales_by_receipt_no_detail(@shift_sale_range,@shift,from,to,payment_type)
@from = from
@to = to
# get printer info
@print_settings = PrintSetting.get_precision_delimiter()
if @shift.present?
@shift.each do |sh|
@shift_from = sh.shift_started_at.nil? ? '-' : sh.shift_started_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_to = sh.shift_closed_at.nil? ? '-' : sh.shift_closed_at.utc.getlocal.strftime("%e %b %I:%M%p")
@shift_data = sh
end
end
respond_to do |format|
format.html
format.xls
end
end
def show
from, to = get_date_range_from_params
@sale_data = Sale.get_by_shift_sale_by_item(from,to,Sale::SALE_STATUS_COMPLETED)
date_arr = Array.new
@sale_data.each do |sale|
local_opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc.getlocal.strftime("%e %b %I:%M%p")
local_closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc.getlocal.strftime("%e %b %I:%M%p")
opening_date = sale.opening_date.nil? ? '-' : sale.opening_date.utc
closing_date = sale.closing_date.nil? ? '-' : sale.closing_date.utc
shift_id = sale.id.nil? ? '-' : sale.id
str = {:shift_id => shift_id, :local_opening_date => local_opening_date, :local_closing_date => local_closing_date, :opening_date => opening_date, :closing_date => closing_date}
date_arr.push(str)
end
out = {:status => 'ok', :message => date_arr}
respond_to do |format|
format.json { render json: out }
end
end
end

View File

@@ -0,0 +1,34 @@
class ReviewLicenseController < BaseController
before_action :lookup_domain
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,59 @@
class Settings::MenuItemGroupsController < ApplicationController
def index
@menu_item_group = Lookup.where(lookup_type:'menu_item_groups')
end
def new
@settings_menu_item_group = Lookup.new
@menu_category = MenuCategory.order(:name)
end
def create
@settings_menu_item_group = Lookup.new(settings_lookup_params)
menu_item = settings_lookup_params[:value].reject(&:empty?)
menu_category = "{\"#{settings_lookup_params[:lookup_type]}\" : #{menu_item} }"
@settings_menu_item_group.lookup_type = "menu_item_groups"
@settings_menu_item_group.value = menu_category
respond_to do |format|
if @settings_menu_item_group.save
format.html { redirect_to settings_menu_item_groups_path, notice: 'Menu item group was successfully created.' }
format.json { render :show, status: :created, location: @settings_menu_item_group }
else
format.html { render :new }
format.json { render json: settings_menu_item_groups_path.errors, status: :unprocessable_entity }
end
end
end
def edit
@settings_menu_item_group = Lookup.find(params[:id])
@menu_category = MenuCategory.order(:name)
end
def update
@settings_menu_item_group = Lookup.find(params[:id])
menu_item = settings_lookup_params[:value].reject(&:empty?)
menu_category = "{\"#{settings_lookup_params[:lookup_type]}\" : #{menu_item} }"
@settings_menu_item_group.lookup_type = "menu_item_groups"
@settings_menu_item_group.value = menu_category
@settings_menu_item_group.name = settings_lookup_params[:name]
respond_to do |format|
if @settings_menu_item_group.save
format.html { redirect_to settings_menu_item_groups_path, notice: 'Menu item group was successfully updated.' }
format.json { render :show, status: :ok, location: @settings_menu_item_group }
else
format.html { render :edit }
format.json { render json: settings_menu_item_groups_path.errors, status: :unprocessable_entity }
end
end
end
def destroy
@settings_menu_item_group = Lookup.find(params[:id])
if @settings_menu_item_group.destroy
flash[:notice] = 'Menu item group was successfully deleted.'
redirect_to settings_menu_item_groups_path
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.
def settings_lookup_params
params.require(:lookup).permit(:lookup_type, :name, :value=>[])
end
end

View File

@@ -0,0 +1,2 @@
module Api::MenuItemGroupsHelper
end

View File

@@ -5,8 +5,8 @@ module ApplicationHelper
case level
when :notice then "alert alert-info fade-in"
when :success then "alert alert-success fade-in"
when :error then "alert alert-error fade-in"
when :alert then "alert alert-error fade-in"
when :error then "alert alert-warning fade-in"
when :alert then "alert alert-danger fade-in"
end
end

View File

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

View File

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

View File

@@ -0,0 +1,2 @@
module Settings::MenuItemGroupsHelper
end

View File

@@ -62,7 +62,6 @@ class Booking < ApplicationRecord
scope :active, -> {where("booking_status != 'moved'")}
scope :today, -> {where("created_at >= #{Time.now.utc}")}
scope :assign, -> { where(booking_status: 'assign')}
scope :within_time_limit, -> { where(checkin_at: Lookup.get_checkin_time_limit.hours.ago..DateTime::Infinity.new) }
def self.sync_booking_records(bookings)
if !bookings.nil?

View File

@@ -9,12 +9,12 @@ class DiningFacility < ApplicationRecord
has_many :order_queue_stations, -> { where(is_active: true) }, through: :order_queue_process_by_zones
has_many :bookings
has_many :current_bookings, -> { left_joins(:sale).assign.within_time_limit.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
has_one :current_checkin_booking, -> { left_joins(:sale).assign.within_time_limit.merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
has_one :current_checkout_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(checkout_at: nil).merge(Sale.where(sale_status: 'new')) }, class_name: "Booking"
has_one :current_reserved_booking, -> { left_joins(:sale).assign.within_time_limit.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
has_many :current_bookings, -> { left_joins(:sale).assign.merge(Booking.where(checkout_at: nil).or(Booking.merge(Sale.where(sale_status: ['new', nil])))) }, class_name: "Booking"
has_one :current_checkin_booking, -> { left_joins(:sale).assign.merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
has_one :current_checkout_booking, -> { left_joins(:sale).assign.where.not(checkout_at: nil).merge(Sale.where(sale_status: 'new')) }, class_name: "Booking"
has_one :current_reserved_booking, -> { left_joins(:sale).assign.where.not(reserved_at: nil).merge(Sale.where(sale_status: nil)) }, class_name: "Booking"
has_many :current_sales, -> { where(sale_status: 'new').merge(Booking.assign.within_time_limit) }, through: :bookings, class_name: "Sale", source: "sale"
has_many :current_sales, -> { where(sale_status: 'new').merge(Booking.assign) }, through: :bookings, class_name: "Sale", source: "sale"
TABLE_TYPE = "Table"
ROOM_TYPE = "Room"
@@ -45,9 +45,7 @@ class DiningFacility < ApplicationRecord
end
def get_current_booking
checkin_time_lookup = Lookup.get_checkin_time_limit
Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).where("checkin_at > ?", checkin_time_lookup.hours.ago).first #and checkout_at is null
Booking.where(dining_facility_id: self.id, booking_status: 'assign', checkout_at: nil).first #and checkout_at is null
end
def get_checkout_booking
@@ -89,8 +87,6 @@ class DiningFacility < ApplicationRecord
end
def self.get_checkin_booking
checkin_time_lookup = Lookup.get_checkin_time_limit
bookings = self.current_checkin_booking
arr_booking = Array.new
if bookings

View File

@@ -1,6 +1,5 @@
class Employee < ApplicationRecord
has_secure_password
# has_secure_token :auth_token
has_many :commissioners
has_many :shit_sales
has_one :current_shift, -> { where.not(shift_started_at: nil).where(shift_closed_at: nil) },class_name: "ShiftSale"
@@ -34,6 +33,7 @@ class Employee < ApplicationRecord
if (user)
#user.authenticate(password)
if (user.authenticate(password))
puts user
user.generate_token
user.session_expiry = DateTime.now.utc + expiry_time.minutes
user.session_last_login = DateTime.now.utc
@@ -44,20 +44,21 @@ class Employee < ApplicationRecord
return nil
end
def self.authenticate_by_token(token)
if token
if user = Employee.find_by_token_session(token)
expiry_time = login_expiry_time
if user.session_expiry && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
user.session_expiry = user.session_expiry.utc + expiry_time.minutes
user.save
return user
end
elsif user = Employee.find_by_app_token(token)
return user
def self.authenticate_by_token(session_token)
if (session_token)
user = Employee.find_by_token_session(session_token)
expiry_time = login_expiry_time
puts expiry_time
if user && user.session_expiry.utc > DateTime.now.utc
#Extend the login time each time authenticatation take place
user.session_expiry = user.session_expiry.utc + expiry_time.minutes
user.save
return true
else
return false
end
end
return false
end

View File

@@ -27,7 +27,7 @@ class License
end
# For Cloud
def detail_with_local_cache(lookup)
def detail_with_local_cache
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_to_file(lookup)
@@ -75,21 +75,14 @@ class License
end
# For Local System
def detail_with_local_file()
renewal_date_str = read_license("renewable_date")
if check_expiring(renewal_date_str)
# return for all ok
return 1
def detail_with_local_file
if expired?
return 0
elsif expire_in?(10)
return 2
else
has_license = verify_license()
if has_license
# return for expiring
return 2
else
return 0
end
return 1
end
# end
end
# License Activation
@@ -99,42 +92,58 @@ class License
aes_key, aes_iv = aes.export_key(license_key)
@params = { query: { lookup_type: self.server_mode, iv_key: aes_iv, license_key: license_key } }
response = self.class.get("/activate", @params)
@activate = response.parsed_response
if (@activate["status"])
begin
response = self.class.get("/activate", @params)
@activate = response.parsed_response
##Check from local redis - if available load local otherwise get from remote
cache_key = "shop:#{@activate["shop_name"]}"
if (@activate["status"])
##Get redis connection from connection pool
# redis = Redis.new
# cache_license = redis.get(cache_key)
##Check from local redis - if available load local otherwise get from remote
cache_key = "shop:#{@activate["shop_name"]}"
Rails.logger.info "Cache key - " + cache_key.to_s
##Get redis connection from connection pool
# redis = Redis.new
# cache_license = redis.get(cache_key)
# if cache_license.nil?
cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
redis = Redis.new
redis.set(cache_key, Marshal.dump(cache))
# end
Rails.logger.info "Cache key - " + cache_key.to_s
Rails.logger.info "License - " + response.parsed_response.to_s
# if cache_license.nil?
cache = {"shop" => @activate["shop_name"], "key" => aes_key, "iv" => @activate["iv_key"], "renewable_date" => @activate["renewable_date"] }
redis = Redis.new
redis.set(cache_key, Marshal.dump(cache))
# end
response = create_license_file(@activate)
Rails.logger.info "License - " + response.parsed_response.to_s
if(response[:status])
#sym_path = "/home/user/symmetric/"
sym_path = File.expand_path("~/symmetric/")
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
response = create_license_file(@activate)
if(response[:status])
response = run_symmetric(sym_path)
#sym_path = "/home/user/symmetric/"
sym_path = File.expand_path("~/symmetric/")
response = create_symmetric_config(sym_path, db_host, db_schema, db_user, db_password)
if(response[:status])
response = run_symmetric(sym_path)
end
end
else
response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"}
end
else
response = { "status": false, "message": "Activation Failed! Please contact code2lab call center!"}
rescue SocketError => e
Rails.logger.debug "In SocketError No Internet connection !"
response = { "status": false, "message": "In SocketError No Internet connection !"}
rescue HTTParty::Error
Rails.logger.debug "Server Error HTTParty"
response = { "status": false, "message": "Server Error HTTParty"}
rescue Net::OpenTimeout
Rails.logger.debug "connection Timeout"
response = { "status": false, "message": "Connection Timeout"}
rescue OpenURI::HTTPError
Rails.logger.debug "Can't connect server"
response = { "status": false, "message": "Can't connect server"}
end
return response
end
@@ -144,39 +153,50 @@ class License
@params = { query: {lookup_type: "application", api_token: api_token} }
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 (!check_expired(@varified["renewable_date"]))
return true
end
else
delete_license_file
response = self.class.get("/verify", @params)
@varified = response.parsed_response
Rails.logger.debug "License Remote Response - " + response.parsed_response.to_s
if (@varified["status"])
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'])
return true
end
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
# Check Expired before 30 days
def check_expiring(renewal_date_str)
if !renewal_date_str.empty?
def expired?
if renewal_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str)
renewal_date > Date.today.advance(:days => 30)
renewal_date < Date.today
end
end
def expire_in?(days)
if renewal_date_str = read_license("renewable_date")
renewal_date = DateTime.parse(renewal_date_str)
renewal_date < days.days.from_now
end
end
def days_to_expire
if renewal_date_str = read_license("renewable_date")
Date.today - DateTime.parse(renewal_date_str).to_date
end
end
@@ -195,13 +215,14 @@ class License
end
end
def check_license_subdomain(lookup)
def check_license_subdomain
aes = MyAesCrypt.new
aes_key, aes_iv = aes.export_key(lookup)
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
@@ -209,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
@@ -228,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'])
@@ -252,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

@@ -38,7 +38,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
# self.print(filename, cashier_terminal.printer_name)
# end
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,foodcourt=nil)
def print_close_cashier(printer_settings,cashier_terminal,shift_sale, sale_items, total_other_charges_info,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods,foodcourt=nil)
if !sale_items.blank? or !sale_items.nil?
@account_cate_count = Hash.new {|hash, key| hash[key] = 0}
@@ -59,7 +59,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
cashier = shift_sale.employee.name
shift_name = shift_sale.shift_started_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") + "_" + shift_sale.shift_closed_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p")
filename = "tmp/close_cashier_#{cashier}_#{shift_name}.pdf"
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,foodcourt)
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods,foodcourt)
close_cashier_pdf = Lookup.collection_of("print_settings") #print_settings with name:CloseCashierPdf
if !close_cashier_pdf.empty?
@@ -68,7 +68,7 @@ class Printer::CashierStationPrinter < Printer::PrinterWorker
if close_cashier[1] == '1'
pdf = CloseCashierCustomisePdf.new(printer_settings,shift_sale,shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,foodcourt)
else
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,foodcourt)
pdf = CloseCashierPdf.new(printer_settings,shift_sale, sale_items, total_other_charges_info, @account_cate_count, @menu_cate_count, @totalByAccount, shop_details,sale_taxes,other_payment,amount,discount,member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods,foodcourt)
end
end
end

View File

@@ -684,7 +684,7 @@ class Sale < ApplicationRecord
.joins("JOIN orders ON orders.order_id=booking_orders.order_id")
.joins("JOIN order_items ON orders.order_id=order_items.order_id")
.joins("JOIN customers ON orders.customer_id=customers.customer_id")
.where("sales.sale_status =? and sales.payment_status =? and orders.source='app' and sales.shift_sale_id = ?",
.where("sales.sale_status =? and sales.payment_status =? and orders.source='app' and sales.shift_sale_id = ?",
'completed','paid', @current_shift.id
).order("bookings.created_at desc").uniq
@@ -791,20 +791,20 @@ class Sale < ApplicationRecord
return num
end
def self.daily_sales_list(from,to)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
def self.daily_sales_list(from,to)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sales = select(Sale.column_names)
.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.push('').join(', ')}
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) -
SUM(case when (sale_payments.payment_method not in('creditnote') and sale_audits.sale_audit_id IS NOT NULL) then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
.sale_payments_with_audit_except_void_between(from, to)
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
.group("sale_id").to_sql
sales = select(Sale.column_names)
.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.push('').join(', ')}
SUM(case when (sale_payments.payment_method='cash') then sale_payments.payment_amount else 0 end) as cash_amount,
SUM(case when (sale_payments.payment_method='creditnote') then sale_payments.payment_amount else 0 end) -
SUM(case when (sale_payments.payment_method not in('creditnote') and sale_audits.sale_audit_id IS NOT NULL) then sale_payments.payment_amount else 0 end) as credit_amount,
SUM(case when (sale_payments.payment_method='foc') then sale_payments.payment_amount else 0 end) as foc_amount")
.sale_payments_with_audit_except_void_between(from, to)
.where("(sale_status = ? OR sale_status = ?) AND sales.receipt_date between ? AND ? ", 'completed', 'void', from, to)
.group("sale_id").to_sql
daily_total = connection.select_all("SELECT
daily_total = connection.select_all("SELECT
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as grand_total,
IFNULL(SUM(case when (sale_status='completed') then grand_total else 0 end),0) as total_sale,
IFNULL(SUM(case when (sale_status='completed') then old_grand_total else 0 end),0) as old_grand_total,
@@ -1238,11 +1238,21 @@ def self.get_shift_sales_by_receipt_no_detail(shift_sale_range,shift,from,to,pay
.includes(:bookings => :dining_facility)
.select("sales.*, SUM(sale_payments.payment_amount) AS payments_for_credits_amount")
.joins(:bookings)
.joins("INNER JOIN sale_payments sp ON sp.sale_id = sales.sale_id")
.left_joins(:payments_for_credits)
.completed
.where.not(total_amount: 0)
.group(:sale_id)
.order(:receipt_date)
if payment_type.present?
if payment_type == 'card'
query = query.where(sanitize_sql_array(["sp.payment_method IN (?)", SalePayment::CARD]))
else
query = query.where("sp.payment_method = (?)", payment_type)
end
end
if shift.present?
query = query.where("sales.shift_sale_id in (?)", shift.to_a)
elsif shift_sale_range.present?
@@ -1528,7 +1538,7 @@ end
def self.employee_sales(current_user,from,to)
shift = if current_user.present? && !(current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor')
ShiftSale.current_open_shift(current_user.id)
ShiftSale.current_open_shift(current_user)
end
payments_for_credits = SalePayment.joins(:sale_audit).to_sql
@@ -1575,7 +1585,7 @@ end
end
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)
if shift = ShiftSale.current_open_shift(current_user)
query = query.where("sales.shift_sale_id = ?", shift.id)
end
end
@@ -1631,10 +1641,10 @@ end
def self.total_payment_methods(current_user=nil,from=nil,to=nil)
query = Sale.select("CASE WHEN sp.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' ELSE sp.payment_method END as payment_method")
query = Sale.select(sanitize_sql_array(["CASE WHEN sp.payment_method IN (?) THEN 'card' ELSE sp.payment_method END as payment_method", SalePayment::CARD]))
.where("sales.sale_status = 'completed'")
.joins("JOIN sale_payments as sp ON sp.sale_id = sales.sale_id")
.group("CASE WHEN sp.payment_method IN ('mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher') THEN 'card' ELSE sp.payment_method END")
.group(sanitize_sql_array(["CASE WHEN sp.payment_method IN (?) THEN 'card' ELSE sp.payment_method END", SalePayment::CARD]))
if (!from.nil? && !to.nil?)
query = query.receipt_date_between(from, to)
@@ -1777,7 +1787,7 @@ end
# query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ?',from,to)
# end
# else
# shift = ShiftSale.current_open_shift(current_user.id)
# shift = ShiftSale.current_open_shift(current_user)
# if !shift.nil?
# if !from_time.nil? && !to_time.nil?
# query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") between ? and ? and DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%H:%i") between ? and ? and sales.shift_sale_id=?',from,to,from_time,to_time,shift.id)
@@ -1794,7 +1804,7 @@ end
# if current_user.role == 'administrator' || current_user.role == 'manager' || current_user.role == 'account' || current_user.role == 'supervisor'
# query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ?',today)
# else
# shift = ShiftSale.current_open_shift(current_user.id)
# shift = ShiftSale.current_open_shift(current_user)
# if !shift.nil?
# query = query.where('DATE_FORMAT(CONVERT_TZ(sales.receipt_date,"+00:00","+06:30"),"%Y-%m-%d") = ? and sales.shift_sale_id=?',today,shift.id)
# end
@@ -2311,7 +2321,7 @@ def self.get_daily_sale_data(transaction_date)
CASE WHEN sale_payments.payment_method = 'giftvoucher' THEN SUM(sale_payments.payment_amount) ELSE SUM(0) END as voucher_sales
FROM sale_payments
GROUP BY sale_payments.sale_id, sale_payments.payment_method"
query = Sale.select("
sales.receipt_no as check_num,
sales.receipt_date as business_date,
@@ -2348,49 +2358,50 @@ def self.get_daily_sale_data(transaction_date)
.where("DATE(sales.receipt_date) = ? AND sales.sale_status != ?", transaction_date, :void)
.group("sales.receipt_no,sales.sale_status")
end
def paymal_payment_void
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_actions_data = MembershipAction.find_by_membership_type("void")
if !membership_actions_data.nil?
sale_payments =self.sale_payments.where("payment_reference is not null")
if !sale_payments.empty?
account_no =sale_payments[0].payment_reference
url = membership_setting.gateway_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
params = { receipt_no:self.receipt_no,
account_no:account_no,
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
},
:timeout => 10
)
rescue Errno::ECONNREFUSED
response = { "status" => false, "message" => "Can't open membership server"}
rescue Net::OpenTimeout
response = { "status" => false, "message" => "No internet connection " }
rescue OpenURI::HTTPError
response = { "status" => false, "message" => "No internet connection "}
rescue SocketError
response = { "status" => false, "message" => "No internet connection "}
end
def paymal_payment_void
membership_setting = MembershipSetting.find_by_membership_type("paypar_url")
membership_actions_data = MembershipAction.find_by_membership_type("void")
if !membership_actions_data.nil?
sale_payments =self.sale_payments.where("payment_reference is not null")
if !sale_payments.empty?
account_no =sale_payments[0].payment_reference
url = membership_setting.gateway_url.to_s + membership_actions_data.gateway_url.to_s
merchant_uid = membership_actions_data.merchant_account_id
auth_token = membership_actions_data.auth_token
params = { receipt_no:self.receipt_no,
account_no:account_no,
merchant_uid:merchant_uid,
auth_token:auth_token}.to_json
# Control for Paypar Cloud
begin
response = HTTParty.post(url,
:body => params,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json; version=3'
},
:timeout => 10
)
rescue Errno::ECONNREFUSED
response = { "status" => false, "message" => "Can't open membership server"}
rescue Net::OpenTimeout
response = { "status" => false, "message" => "No internet connection " }
rescue OpenURI::HTTPError
response = { "status" => false, "message" => "No internet connection "}
rescue SocketError
response = { "status" => false, "message" => "No internet connection "}
end
end
else
response = { "status" => false}
end
else
response = { "status" => false}
end
Rails.logger.debug "Void Payment response"
Rails.logger.debug response.to_json
return response;
end
Rails.logger.debug "Void Payment response"
Rails.logger.debug response.to_json
return response;
end
# Loader Service SFTP End
private
@@ -2408,7 +2419,9 @@ private
self.total_tax = self.total_tax.round(precision)
end
self.grand_total = (self.total_amount - self.total_discount) + self.total_tax
adjust_rounding
if (!['foc', 'waste', 'spoile', 'void'].include? self.payment_status)
adjust_rounding
end
end
def update_stock_journal

View File

@@ -142,8 +142,9 @@ class SaleAudit < ApplicationRecord
if paymal[0]
remark = paymal[0].remark.split("}")
response = "["+remark[0]+'}]'
response = JSON.parse(response)
# puts response
# response = JSON.parse(response)
if response[0]["status"] == true
if response[0]["current_rebate_amount"].present?
amount = response[0]["current_rebate_amount"]

View File

@@ -1,4 +1,7 @@
class SalePayment < ApplicationRecord
CARD = ['mpu', 'visa', 'master', 'jcb', 'unionpay']
self.primary_key = "sale_payment_id"
#primary key - need to be unique generated for multiple shops
@@ -11,7 +14,7 @@ class SalePayment < ApplicationRecord
attr_accessor :received_amount, :card_payment_reference, :voucher_no, :giftcard_no, :customer_id, :external_payment_status,:action_by
scope :credits, -> { where(payment_method: 'creditnote') }
scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay', 'alipay', 'paymal', 'dinga', 'JunctionPay', 'giftvoucher']) }
scope :cards, -> { where(payment_method: ['mpu', 'visa', 'master', 'jcb', 'unionpay']) }
def self.sync_sale_payment_records(sale_payments)
if !sale_payments.nil?
@@ -36,7 +39,8 @@ class SalePayment < ApplicationRecord
def self.get_kbz_pay_amount(sale_id, current_user)
amount = 0
kbz_pay_method = PaymentMethodSetting.where(:payment_method => KbzPay::KBZ_PAY).last
kbz_pay_method = PaymentMethodSetting.where(payment_method: KbzPay::KBZ_PAY, gateway_communication_type: ['api', 'Api'], is_active: true)
.where.not(gateway_url: [nil, ''], auth_token: [nil, ''], merchant_account_id: [nil, '']).last
sale_payment = SalePayment.where('sale_id=? and payment_method=? and payment_status!=?', sale_id, KbzPay::KBZ_PAY, 'dead').last
if !sale_payment.nil? and !kbz_pay_method.nil?
if sale_payment.payment_status == 'pending'
@@ -120,10 +124,8 @@ class SalePayment < ApplicationRecord
payment_status,membership_data = dinga_payment
when "GiftVoucher"
payment_status = giftvoucher_payment
when KbzPay::KBZ_PAY
payment_status = kbz_payment
else
puts "it was something else"
else
payment_status = external_terminal_card_payment(payment_method, payment_for)
end
if payment_status
@@ -361,10 +363,16 @@ class SalePayment < ApplicationRecord
# Check for Card Payment
def self.get_sale_payments_by_card(sale_payments)
# Check for Card Payment
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
sale_payments.each do |sp|
if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay"
return true;
payment_methods.each do |m|
if sp.payment_method == m
return true;
end
end
# if sp.payment_method == "jcb" || sp.payment_method == "mpu" || sp.payment_method == "visa" || sp.payment_method == "master" || sp.payment_method == "unionpay" || sp.payment_method == "alipay"
# return true;
# end
end
end
@@ -616,22 +624,12 @@ class SalePayment < ApplicationRecord
return payment_status
end
def kbz_payment
payment_status = false
self.payment_amount = self.received_amount
self.payment_reference = self.payment_reference
self.outstanding_amount = self.sale.grand_total.to_f - self.received_amount.to_f
self.payment_status = "paid"
payment_status = self.save!
# sale_update_payment_status(self.received_amount)
return payment_status
end
def sale_update_payment_status(paid_amount, check_foc = false)
#update amount_outstanding
if ['completed'].include? sale.sale_status
if !self.sale || ['completed'].include?(self.sale.sale_status)
return
end
sale = self.sale
sale_payments = sale.sale_payments.reload
@@ -639,18 +637,14 @@ class SalePayment < ApplicationRecord
is_foc = sale_payments.any? { |x| x.payment_method == "foc" } || check_foc
if is_foc
total_payment_amount = 0.0
else
total_payment_amount = sale_payments.sum(&:payment_amount)
end
sale.amount_received = sale.amount_received.to_f + paid_amount.to_f
sale.amount_changed = total_payment_amount - sale.grand_total.to_f
if is_foc
sale.amount_received = 0.0
sale.amount_changed = 0.0
sale.payment_status = 'foc'
sale.sale_status = 'completed'
elsif sale.grand_total <= total_payment_amount && sale.sale_status == "new"
elsif sale.grand_total <= sale_payments.sum(&:payment_amount) && sale.sale_status == "new"
sale.amount_received = sale.amount_received + paid_amount.to_d
sale.amount_changed = sale_payments.sum(&:payment_amount) - sale.grand_total
sale.payment_status = "paid"
if is_credit
sale.payment_status = "outstanding"
@@ -682,19 +676,9 @@ class SalePayment < ApplicationRecord
end
end
end
sale.save!
if check_foc
table_update_status(sale)
update_shift
elsif paid_amount.to_f > 0 #|| paid_amount != "0.0"
table_update_status(sale)
update_shift
elsif paid_amount.to_f == 0 && !is_credit
table_update_status(sale)
update_shift
end
table_update_status(sale)
update_shift
end
# update for cashier shift

View File

@@ -28,7 +28,7 @@ class ShiftSale < ApplicationRecord
#find open shift where is open today and is not closed and login by current cashier
#DATE(shift_started_at)=? and
today_date = DateTime.now.strftime("%Y-%m-%d")
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = #{current_user.id}").take
shift = ShiftSale.where("shift_started_at is not null and shift_closed_at is null and employee_id = ?", current_user).take
return shift
#end
end
@@ -150,23 +150,15 @@ class ShiftSale < ApplicationRecord
end
def self.get_by_shift_other_payment(shift)
payment_methods = SalePayment.where.not(payment_method: ['cash', 'creditnote', 'foc']).distinct.pluck(:payment_method)
other_payment = Sale.select("sale_payments.payment_method as name,
SUM(case when (sale_payments.payment_method='mpu') then (sale_payments.payment_amount) else 0 end) as mpu_amount,
SUM(case when (sale_payments.payment_method='visa') then (sale_payments.payment_amount) else 0 end) as visa_amount,
SUM(case when (sale_payments.payment_method='master') then (sale_payments.payment_amount) else 0 end) as master_amount,
SUM(case when (sale_payments.payment_method='jcb') then (sale_payments.payment_amount) else 0 end) as jcb_amount,
SUM(case when (sale_payments.payment_method='unionpay') then (sale_payments.payment_amount) else 0 end) as unionpay_amount,
SUM(case when (sale_payments.payment_method='alipay') then (sale_payments.payment_amount) else 0 end) as alipay_amount,
SUM(case when (sale_payments.payment_method='KBZPay') then (sale_payments.payment_amount) else 0 end) as kbzpay_amount,
SUM(case when (sale_payments.payment_method='dinga') then (sale_payments.payment_amount) else 0 end) as dinga_amount,
SUM(case when (sale_payments.payment_method='giftvoucher') then (sale_payments.payment_amount) else 0 end) as giftvoucher_amount,
SUM(case when (sale_payments.payment_method='JunctionPay') then (sale_payments.payment_amount) else 0 end) as junctionpay_amount,
SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount,
SUM(case when (sale_payments.payment_method='paymal') then (sale_payments.payment_amount) else 0 end) as paymal_amount,
SUM(case when (sale_payments.payment_method='paypar') then (sale_payments.payment_amount) else 0 end) as paypar_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
shift_other_payments = Sale.select("sales.sale_id,sale_payments.payment_method as name")
if payment_methods.present?
shift_other_payments = shift_other_payments.select("#{payment_methods.map { |method| "SUM(case when (sale_payments.payment_method='#{method}') then sale_payments.payment_amount else 0 end) as #{method == 'paypar' ? 'redeem' : method}"}.join(', ')}")
end
shift_other_payments.select("SUM(case when (sale_payments.payment_method='foc') then (sale_payments.payment_amount) else 0 end) as foc_amount")
.joins("join sale_payments on sale_payments.sale_id = sales.sale_id")
.where("sales.shift_sale_id =? and sale_status = 'completed' and sale_payments.payment_amount != 0 ", shift.id)
end
def self.calculate_total_price_by_accounts(shift,type)

View File

@@ -2,7 +2,7 @@ class CloseCashierPdf < Prawn::Document
include NumberFormattable
attr_accessor :label_width,:price_column_width,:page_width, :page_height, :margin, :price_width, :item_width, :header_font_size, :item_font_size,:item_height,:qty_width,:total_width,:item_description_width,:text_width
def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,foodcourt)
def initialize(printer_settings, shift_sale, sale_items, total_other_charges_info, acc_cate_count, menu_cate_count, total_by_acc, shop_details,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,total_dinein,total_takeway,total_other_charges,total_waste,total_spoile,total_credit_payments,payment_methods,foodcourt)
self.page_width = printer_settings.page_width #PrintSetting.where("name = ?","Close Cashier").first.page_width
self.page_height = printer_settings.page_height
self.header_font_size = printer_settings.header_font_size.to_i
@@ -43,7 +43,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,foodcourt)
shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,payment_methods,foodcourt)
if !sale_items.nil? or !sale_items.blank?
sale_items_detail(sale_items, acc_cate_count, menu_cate_count, total_by_acc, total_other_charges_info)
@@ -63,7 +63,7 @@ class CloseCashierPdf < Prawn::Document
stroke_horizontal_rule
end
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,foodcourt)
def shift_detail(shift_sale,sale_taxes,other_payment,total_amount_by_account,total_discount_by_account,total_member_discount,precision,delimiter,total_waste,total_spoile,total_other_charges,total_credit_payments,payment_methods,foodcourt)
move_down 7
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width, :height => self.item_height) do
@@ -131,10 +131,12 @@ class CloseCashierPdf < Prawn::Document
text "#{number_format(shift_sale.closing_balance, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
if foodcourt.nil?
y_position = cursor
y_position = cursor
unless foodcourt
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash In:", :size => self.item_font_size, :align => :right
text "Cash In :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_format(shift_sale.cash_in, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
@@ -142,18 +144,19 @@ class CloseCashierPdf < Prawn::Document
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Out:", :size => self.item_font_size, :align => :right
text "Cash Out :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_format(shift_sale.cash_out, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
move_down -5
stroke_horizontal_rule
move_down 7
@total_foc = 0
if foodcourt.nil?
unless foodcourt
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Cash Payment :", :size => self.item_font_size, :align => :right
@@ -174,125 +177,19 @@ class CloseCashierPdf < Prawn::Document
if shift_sale.other_sales > 0
other_payment.each do |other|
@total_foc = other.foc_amount.round(2)
if other.mpu_amount && other.mpu_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "MPU Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.mpu_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
if !payment_methods.nil?
payment_methods.each do |method|
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "#{method.parameterize == 'paymal' ? 'Card' : method} Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_format(other[method.parameterize.to_sym], :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
end
if other.visa_amount && other.visa_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "VISA Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{number_format(other.visa_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.master_amount && other.master_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Master Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.master_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.jcb_amount && other.jcb_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JCB Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.jcb_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.unionpay_amount && other.unionpay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "UNIONPAY Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.unionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.alipay_amount && other.alipay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Alipay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.alipay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.kbzpay_amount && other.kbzpay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "KBZ Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.kbzpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.junctionpay_amount && other.junctionpay_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "JunctionPay Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.junctionpay_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.dinga_amount && other.dinga_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Dinga Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.dinga_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.paypar_amount && other.paypar_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Redeem Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.paypar_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.paymal_amount && other.paymal_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "Card Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.paymal_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
if other.giftvoucher_amount && other.giftvoucher_amount.to_f > 0
y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
text "GiftVoucher Payment :", :size => self.item_font_size, :align => :right
end
bounding_box([self.item_description_width,y_position], :width =>self.price_width, :height => 20) do
text "#{ number_format(other.giftvoucher_amount, :precision => precision.to_i, :delimiter => delimiter)}", :size => self.item_font_size, :align => :right
end
end
end
else
y_position = cursor
@@ -362,7 +259,7 @@ class CloseCashierPdf < Prawn::Document
end
end
#end for service charges and commercial tax
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
#COMMENTED FOR NO NEED AND NOT CORRECT WHEN OTHER CHARGES
# y_position = cursor
# bounding_box([0,y_position], :width =>self.item_description_width, :height => 20) do
# text "Total Sale :", :size => self.item_font_size, :align => :right

View File

@@ -214,13 +214,15 @@
<tr>
<% if payment.payment_method == 'paypar' %>
<td>Redeem Sale : </td>
<% elsif payment.payment_method == 'paymal' %>
<td>Card Sales : </td>
<% else %>
<td><%= payment.payment_method.to_s.capitalize %> Sale : </td>
<% end %>
<td align="right">
<% @sale_data.each do |data| %>
<% pay_mth = payment.payment_method %>
<%= data[""+pay_mth+""] %>
<%= data[pay_mth] %>
<% end %>
</td>
</tr>

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,4 @@
<form action="/activate" method="POST" class="row">
<%= form_tag activate_path, class: "row" do %>
<div class="col-md-6">
<div class="form-group">
<label for="exampleInputEmail1">Business Name</label>
@@ -27,11 +27,11 @@
</div>
<div class="form-group">
<label for="lblDBName">Database Schema</label>
<input type="text" class="form-control" name="db_schema" aria-describedby="db_schema" placeholder="Database Schema">
<input type="text" class="form-control" name="db_schema" aria-describedby="db_schema" placeholder="Database Schema">
</div>
<div class="form-group">
<label for="lblAdministrator">Database Username</label>
<input type="text" class="form-control" name="db_user" aria-describedby="db_user" placeholder="Database Username">
<input type="text" class="form-control" name="db_user" aria-describedby="db_user" placeholder="Database Username">
</div>
<div class="form-group">
<label for="admin_password">Database Password</label>
@@ -41,4 +41,4 @@
<div class="col-md-12 text-center">
<button type="submit" class="btn btn-primary">Activate</button>
</div>
</form>
<% end %>

View File

@@ -31,6 +31,7 @@
<p>Please wait...</p>
</div>
</div>
<%= render 'shared/license_expire_warning' if Rails.env.production? %>
<!-- #END# Page Loader -->
<!-- Overlay For Sidebars -->
<div class="overlay"></div>

View File

@@ -35,24 +35,25 @@
<p>Please wait...</p>
</div>
</div>
<%= render 'shared/license_expire_warning' if Rails.env.production? %>
<!-- #END# Page Loader -->
<!-- Overlay For Sidebars -->
<div class="overlay"></div>
<!-- #END# Overlay For Sidebars -->
<%= render 'layouts/header' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
</section>
<!-- Main Content -->
<section class="content">
<section class="content">
<% flash.each do |type, message| %>
<div class="alert fade in">
<button class="close" aria-hidden="true" data-dismiss="alert" type="button">×</button>
<%= message %>
</div>
<% end %>
<%= yield %>
<% end %>
<%= yield %>
</section>
</body>
</body>

View File

@@ -51,8 +51,18 @@
<% end %>
<% if can? :index, :home %>
<% if current_login_employee.role != "kitchen" %>
<% if current_user.role == "cashier"
shift = ShiftSale.current_open_shift(current_user)
if !shift.nil?
path = origami_dashboard_path
else
path = new_origami_shift_path
end
else current_user.role == "administrator"
path = origami_dashboard_path
end %>
<li class="menu-up">
<a href="<%= origami_dashboard_path %>">
<a href="<%= path %>">
<i class="material-icons">monetization_on</i>
<span><%= t :origami %></span>
</a>

View File

@@ -32,6 +32,8 @@
<p>Please wait...</p>
</div>
</div>
<%= render 'shared/license_expire_warning' if Rails.env.production? %>
<!-- #END# Page Loader -->
<!-- Overlay For Sidebars -->
<div class="overlay"></div>
@@ -39,7 +41,6 @@
<%= render 'layouts/header' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
</section>

View File

@@ -10,34 +10,34 @@
<%= csrf_meta_tags %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
<style>
.page {
padding-left: 0;
max-width: 80%;
margin: 2% auto;
overflow-x: hidden;
overflow-x: hidden;
background-color: #2790a5;
}
.page .box {
display: block;
width: 100%;
color: #000;
color: #000;
}
</style>
</head>
<body class="page">
<% flash.each do |type, message| %>
<% if type == "notice"
<% if type == "notice"
color = "alert-success"
elsif type == "error"
color = "alert-danger"
else
color = "bg-black"
end %>
<p id="notify_message" class="hidden" data-placement-from="top" data-message="<%=message%>" data-placement-align="center"
data-animate-enter="" data-animate-exit="" data-color-name="<%=color%>" >
</p>

View File

@@ -31,14 +31,15 @@
<p>Please wait...</p>
</div>
</div>
<%= render 'shared/license_expire_warning' if Rails.env.production? %>
<!-- #END# Page Loader -->
<!-- Overlay For Sidebars -->
<div class="overlay"></div>
<!-- #END# Overlay For Sidebars -->
<%= render 'layouts/header' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
</section>
<!-- Main Content -->
@@ -54,8 +55,8 @@
<% end %>
<%= render_breadcrumb %>
<%= yield %>
<%= yield %>
</section>
</body>
</html>
</html>

View File

@@ -31,14 +31,15 @@
<p>Please wait...</p>
</div>
</div>
<%= render 'shared/license_expire_warning' if Rails.env.production? %>
<!-- #END# Page Loader -->
<!-- Overlay For Sidebars -->
<div class="overlay"></div>
<!-- #END# Overlay For Sidebars -->
<%= render 'layouts/header' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
<section>
<%= render 'layouts/left_sidebar' %>
<%= render 'layouts/right_sidebar' %>
</section>
<!-- Notify -->
@@ -46,21 +47,20 @@
<!-- Notify -->
<!-- Main Content -->
<section class="content">
<section class="content">
<% flash.each do |type, message| %>
<% if type == "notice"
<% if type == "notice"
color = "alert-success"
elsif type == "error"
color = "alert-danger"
else
color = "bg-black"
end %>
<p id="notify_message" class="hidden" data-placement-from="top" data-message="<%=message%>" data-placement-align="center"
data-animate-enter="" data-animate-exit="" data-color-name="<%=color%>" >
</p>
<% end %>
<%= yield %>
<% end %>
<%= yield %>
</section>
</body>

View File

@@ -14,6 +14,7 @@
</head>
<body>
<%= render 'shared/license_expire_warning' %>
<%= render 'layouts/header' %>
<div class="container-fluid">
<% flash.each do |type, message| %>

View File

@@ -1,5 +1,5 @@
<!-- Column One -->
<div class="row clearfix" style="">
<div class="row clearfix m-top-100" style="">
<div class="col-lg-7 col-md-7 col-sm-7">
<p class="hidden filter"><%= @filter %></p>
<div class="card">

View File

@@ -4,7 +4,7 @@
<% type = request.path_info.include?('quick_service') || request.path_info.include?('food_court')%>
<% modify_order = request.path_info.include?('modify_order')%>
<div class="container-fluid " style="padding:0px 3px 0px 3px; overflow-x: hidden; ">
<div class="container-fluid addorder-pages" style="padding:0px 3px 0px 3px;">
<div id="oqs_loading_wrapper" style="display:none;">
<div id="oqs_loading"></div>
</div>

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div class='row'>
<div class="col-lg-10 col-md-10 col-sm-10">
<h2> <%= t :cash_in %> </h2>

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div class='row'>
<div class="col-lg-10 col-md-10 col-sm-10">
<h2><%= t :cash_out %></h2>

View File

@@ -176,25 +176,40 @@
<div class="body">
<h6><%= t("views.right_panel.detail.order") %></h6>
<table class="table">
<% if !@total_order.nil? %>
<tr>
<td width="40px"><%= t("views.right_panel.detail.total") %> <%= t("views.right_panel.detail.order") %> : </td>
<td align="right" width="60px"><%= @total_order.total_order %></td>
</tr>
<% end %>
<% if !@total_accounts.nil? %>
<% @total_accounts.each do |account| %>
<tr>
<td width="40px"><%= account.title %> (Account) : </td>
<td align="right" width="60px">
<% @account_data.each do |data| %>
<% acc = account.title %>
<%= data[""+acc+""] %> <% if !data[''+acc+''].nil? %> ( <%= data[''+acc+'_amount'] %> ) <% end %>
<% if !(@total_payment_methods.nil?) %>
<% @total_payment_methods.each do |payment| %>
<% if !@sale_data[0].empty? %>
<% if payment.payment_method != 'mpu' && payment.payment_method != 'visa' && payment.payment_method != 'master' && payment.payment_method != 'jcb' %>
<tr>
<% if payment.payment_method == 'paypar' %>
<td>Redeem Sales : </td>
<% elsif payment.payment_method == 'paymal' %>
<td>Card Sales : </td>
<% else %>
<td><%= payment.payment_method.to_s.capitalize %> Sales : </td>
<% end %>
<td align="right">
<% @sale_data.each do |data| %>
<% pay_mth = payment.payment_method %>
<%= data[pay_mth] %>
<% end %>
</td>
</tr>
<% end %>
<% end %>
</td>
</tr>
<% end %>
<% end %>
<% total_card = @sale_data.select { |hash| hash["card"]!=nil } %>
<% if !total_card.nil? %>
<tr>
<td><%= t("views.right_panel.detail.other_payment") %> : </td>
<td align="right">
<% total_other_amt = 0 %>
<% @sale_data.map { |k,v| k.map{|meth,amt| meth != 'cash' && meth != 'foc' && meth != 'creditnote' ? total_other_amt += amt : meth }} %>
<%= total_other_amt %>
</td>
</tr>
<% end %>
<% end %>
<% if !@top_items.nil? %>
<tr>

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
@@ -300,12 +300,14 @@ var originalDiscount = totalDiscount;
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (parseFloat(original_value) == 0){
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
}
if (input_value == "." && original_value.includes(".")) {
break;
}
if (parseFloat(input_value) >= 0 && !original_value.includes(".") && (parseFloat(original_value) == 0)) {
$('#discount-amount').val(parseFloat(input_value));
} else {
$('#discount-amount').val(original_value + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>

View File

@@ -1,6 +1,6 @@
<%= stylesheet_link_tag 'order_reservation', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'order_reservation', 'data-turbolinks-track': 'reload' %>
<div class="container-fluid">
<div class="container-fluid m-top-100">
<!-- start count function -->
<%
pending_count = 0

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -202,7 +202,7 @@
<%else%>
<button type="button" class="btn bg-default btn-block" onclick="window.location.href = '/origami/sale/<%=@sale_data.sale_id%>/<%=@cashier_type%>/payment'"><i class="material-icons">reply</i> Back </button>
<%end%>
<button id="charge_other" class="btn bg-primary btn-block action-btn">Enter</button>
<button id="charge_other" class="btn bg-primary btn-block action-btn" style="height: 35px">Enter</button>
</div>
</div>
</div>

View File

@@ -680,8 +680,10 @@ $(document).ready(function(){
$('#pay').click(function() {
sub_total = $('#sub-total').text();
member = $('#membership_id').text();
if (payment_type && payment_type.length > 0 && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0) && sub_total != 0.0 && member) {
if (payment_type && payment_type.length > 0 && parseInt(jQuery.inArray("Credit", payment_type)) == -1 && !other_payments.some(x => payment_type.indexOf(x[0]) >= 0 && x[1] > 0) && sub_total != 0.0 && member) {
swal("Oops","Please Pay with " + payment_methods.find(x => payment_type.indexOf(x) >= 0) + " Payment","warning");
} else if (payment_type && payment_type.length > 0 && parseInt(jQuery.inArray("Credit", payment_type)) != -1 && $('#credit').text() == 0 && sub_total != 0.0 && member) {
swal("Oops","Please Pay with Credit Payment","warning");
} else {
$( "#loading_wrapper").show();
if($('#balance').text() > 0){

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div class="row clearfix">
<!-- Column One -->
<div class="col-lg-10 col-md-10 col-sm-10">

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div class="row">
<!-- Column One -->
<div class="col-lg-5 col-md-5 col-sm-5">

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>

View File

@@ -1,4 +1,4 @@
<div class="container-fluid">
<div class="container-fluid m-top-100">
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-7 col-lg-7">
<div class="card">

View File

@@ -83,7 +83,7 @@
<th style='text-align:center;'><%= t("views.right_panel.detail.sr") %></th>
<th style='text-align:center;'><%= t("views.righ_panel.detail.date") %></th>
<% @payment_methods.each do |method| %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method.parameterize == 'paymal' ? 'card_sales' : method.parameterize}") %></th>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>

View File

@@ -28,7 +28,7 @@
<th style='text-align:center;'><%= t("views.right_panel.detail.date") %></th>
<% @payment_methods.each do |method| %>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method}") %></th>
<th style='text-align:center;' class="d-none d-sm-table-cell"><%= t("views.right_panel.detail.#{method.parameterize == 'paymal' ? 'card_sales' : method.parameterize}") %></th>
<% end %>
<th style='text-align:center;'><%= t("views.right_panel.detail.cash_sales") %></th>
<th style='text-align:center;'><%= t("views.right_panel.detail.credit_sales") %></th>

View File

@@ -41,7 +41,7 @@
<% end %>
<tr>
<% @payment_methods.each do |method| %>
<th><%= t("views.right_panel.detail.#{method} Sales") %></th>
<th><%= t("views.right_panel.detail.#{method.parameterize == 'paymal' ? 'card_sales' : method.parameterize}") %></th>
<% end %>
<th><%= t("views.right_panel.detail.cash_sales") %></th>
<th><%= t("views.right_panel.detail.credit_sales") %></th>

View File

@@ -28,7 +28,7 @@
<% end %>
<tr>
<% @payment_methods.each do |method| %>
<th><%= t("views.right_panel.detail.#{method} Sales") %></th>
<th><%= t("views.right_panel.detail.#{method.parameterize == 'paymal' ? 'card_sales' : method.parameterize}") %></th>
<% end %>
<th><%= t("views.right_panel.detail.cash_sales") %></th>
<th><%= t("views.right_panel.detail.credit_sales") %></th>

View File

@@ -0,0 +1,78 @@
<% renewable_date = current_license.read_license("renewable_date") %>
<% 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.' %>
<% else %>
<% text = "Your license will expire in #{day}." %>
<% end %>
<style>
.centered {
position: fixed;
/*width: 850px;*/
padding: 10px;
top: 50%;
left: 50%;
-webkit-transform: translate(-50%, -50%);
transform: translate(-50%, -50%);
}
</style>
<div class="container-fluid">
<div class="row">
<div class="col-sm-2"></div>
<div class="card col-sm-8 centered">
<div class="card-block">
<%= link_to origami_dashboard_url do %>
<img src="/image/logo.png" class="mr-4 mt-2 float-right" style="width: 150px">
<% end %>
<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>
<% end %>
<h6 class="mb-2">Call Center Phone No: <a href="tel:+6494461709">+959 445 665 311</a></h6>
<br>
<h6>License Info:</h6>
<br>
<div class="container">
<div class="form-group row">
<label class="card-subtitle mb-2 col-md-4">Business Name:</label>
<label class="card-subtitle mb-2 "><strong><%= @bis_name %></strong></label>
</div>
<div class="form-group row">
<label class="card-subtitle mb-2 col-md-4">Plan:</label>
<label class="card-subtitle mb-2 "><strong><%= @plan %></strong></label>
</div>
</div>
<div class="form-group row">
<label class="card-subtitle mb-2 col-md-4 pl-4">Expired At: </label>
<label class="card-subtitle mb-2 "><strong><%= @expired_at.to_date.strftime('%B %d, %Y') %></strong></label>
</div>
</div>
<br>
<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>
</div>
</div>
<script>
$(document).ready(function() {
$('.alert-danger, .navbar').hide()
$('html, section').css('background-color', '#61B8C9')
// $('html').css('overflow-x', 'hidden')
$('section.content').css('margin', '70px 0 0 0')
})
</script>

View File

@@ -0,0 +1,70 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item"><a href="<%= settings_menu_item_groups_path %>">Menu Item Groups</a></li>
<li class="breadcrumb-item active">Edit</li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), settings_menu_item_groups_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<%= simple_form_for ([:settings,@settings_menu_item_group]), :url => settings_menu_item_group_path do |f| %>
<%= f.error_notification %>
<div class="form-inputs p-l-15">
<%= f.input :name, :label => "Group Name" ,input_html: {required: true }%>
<%= f.label :lookup_type, label: 'Menu Category', :class => "control-label string optional bmd-label-static" %>
<%= f.collection_select :lookup_type, @menu_category, :id, :name, {}, {:class =>"form-control"} %>
<%= f.label :value, label: 'Menu Items', :class => "control-label string optional bmd-label-static" %>
<%= f.grouped_collection_select :value, @menu_category, :menu_items, :name, :item_code, :name, {}, {:class =>"form-control", :multiple=> true} %>
</div>
<div class="form-actions p-l-15">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div>
<% end %>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
<p>
1) <%= t("views.right_panel.detail.lookup") + " " + t("views.right_panel.detail.type_txt") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
2) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
3) <%= t("views.right_panel.detail.value") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.value_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
</p>
</div>
</div>
</div>
</div>
<script>
jQuery(function() {
$( document ).ready(function() {
menu_items = $("#lookup_value").html();
menu_category = $('#lookup_lookup_type :selected').text();
options = $(menu_items).filter('optgroup[label="' + menu_category + '"]').html();
$('#lookup_value').html(options)
$('#lookup_lookup_type').change(function() {
menu_category = $('#lookup_lookup_type :selected').text();
options = $(menu_items).filter('optgroup[label="' + menu_category + '"]').html();
if (options != null)
$('#lookup_value').html(options);
else
$('#lookup_value').empty();
});
});
});
</script>

View File

@@ -0,0 +1,69 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item active">Menu Item Group</li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), dashboard_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-9 col-lg-9">
<div class="m-b-10 clearfix">
<%= link_to t("views.btn.new"),new_settings_menu_item_group_path,:class => 'btn btn-primary btn-lg float-right waves-effect"' %>
</div>
<div class="card" id="custom-slimscroll">
<table class="table table-striped">
<thead>
<tr>
<th><%= t("views.right_panel.detail.menu_item_groups") %></th>
<th><%= t("views.right_panel.detail.group_names") %></th>
<th><%= t("views.right_panel.detail.menu_items") %></th>
<th><%= t("views.right_panel.detail.actions") %></th>
</tr>
</thead>
<tbody>
<% @menu_item_group.each do |menu_item_group| %>
<tr>
<td><%= menu_item_group.lookup_type %></td>
<td><%= menu_item_group.name %></td>
<td><%= menu_item_group.value %></td>
<td>
<%= link_to t("views.btn.edit"), edit_settings_menu_item_group_path(menu_item_group),:class => 'btn btn-primary btn-sm waves-effect' %>
<%= link_to t("views.btn.delete"), settings_menu_item_group_path(menu_item_group),:class => 'btn btn-danger btn-sm waves-effect', method: :delete, data: {confirm: 'Are you sure you want to delete this row ?'} %>
</button>
</td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="col-xs-12 col-sm-12 col-md-3 col-lg-3">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
<p>
1) <%= t("views.right_panel.detail.lookup") + " " + t("views.right_panel.detail.type_txt") %> - <%= t("views.right_panel.detail.type_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
2) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.name_txt2") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
3) <%= t("views.right_panel.detail.value") %> - <%= t("views.right_panel.detail.value_txt") %> <%= t("views.right_panel.detail.for") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
4) <%= t("views.right_panel.detail.actions") %> - <%= t("views.right_panel.detail.actions_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.new") %> - <%= t("views.right_panel.detail.new_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
2) <%= t("views.right_panel.button.edit") %> - <%= t("views.right_panel.detail.edit_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.dashboard_txt") %> <br>
</p>
</div>
</div>
</div>
</div>

View File

@@ -0,0 +1,70 @@
<div class="page-header">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="<%= dashboard_path %>">Home</a></li>
<li class="breadcrumb-item"><a href="<%= settings_menu_item_groups_path %>">Menu Item Group</a></li>
<li class="breadcrumb-item active">New</li>
<span class="float-right">
<%= link_to t('.back', :default => t("views.btn.back")), settings_menu_item_groups_path %>
</span>
</ol>
</div>
<div class="row">
<div class="col-xs-12 col-sm-12 col-md-8 col-lg-8">
<%= simple_form_for ([:settings,@settings_menu_item_group]), :url => settings_menu_item_groups_path do |f| %>
<%= f.error_notification %>
<div class="form-inputs p-l-15">
<%= f.input :name, :label => "Group Name" ,input_html: {required: true }%>
<%= f.label :lookup_type, label: 'Menu Category', :class => "control-label string optional bmd-label-static" %>
<%= f.collection_select :lookup_type, @menu_category, :id, :name, {}, {:class =>"form-control"} %>
<%= f.label :value, label: 'Menu Items', :class => "control-label string optional bmd-label-static" %>
<%= f.grouped_collection_select :value, @menu_category, :menu_items, :name, :item_code, :name, {}, {:class =>"form-control", :multiple=> true} %>
</div>
<div class="form-actions p-l-15">
<%= f.submit "Submit",:class => 'btn btn-primary btn-lg waves-effect' %>
</div>
<% end %>
</div>
<div class="col-xs-12 col-sm-12 col-md-4 col-lg-4">
<div class="card">
<div class="body">
<h5><i class="material-icons md-18">view_headline <%= t("views.right_panel.header.page_detail") %></i></h5>
<p>
1) <%= t("views.right_panel.detail.lookup") + " " + t("views.right_panel.detail.type_txt") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
2) <%= t("views.right_panel.detail.name") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.name_txt2") %> <br>
3) <%= t("views.right_panel.detail.value") %> - <%= t("views.right_panel.detail.write_txt") %> <%= t("views.right_panel.detail.value_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.button_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.submit") %> - <%= t("views.right_panel.detail.submit_btn_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
</p>
<h5><i class="material-icons md-18">list <%= t("views.right_panel.header.link_lists") %></i> </h5>
<p>
1) <%= t("views.right_panel.button.home") %> - <%= t("views.right_panel.detail.home_txt") %> <br>
2) <%= t("views.right_panel.button.back") %> - <%= t("views.right_panel.detail.back_txt") %> <%= t("views.right_panel.detail.lookup_txt") %> <br>
</p>
</div>
</div>
</div>
</div>
<script>
jQuery(function() {
$( document ).ready(function() {
menu_items = $("#lookup_value").html();
menu_category = $('#lookup_lookup_type :selected').text();
options = $(menu_items).filter('optgroup[label="' + menu_category + '"]').html();
$('#lookup_value').html(options)
$('#lookup_lookup_type').change(function() {
menu_category = $('#lookup_lookup_type :selected').text();
options = $(menu_items).filter('optgroup[label="' + menu_category + '"]').html();
if (options != null)
$('#lookup_value').html(options);
else
$('#lookup_value').empty();
});
});
});
</script>

View File

@@ -0,0 +1,56 @@
<% license_status = current_license.detail_with_local_file %>
<% renewable_date = current_license.read_license("renewable_date") %>
<% date_count = (renewable_date.to_date - Date.today).to_i %>
<% day = pluralize( date_count, 'day' )%>
<% if license_status == 0
text = 'Your license has 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 || 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', 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>
</div>
<% end %>
<script>
$(document).ready(function() {
divLicnese = $('#license-alert');
navbar = $('.navbar');
leftsidebar = $('#leftsidebar');
if (<%= license_status %> == 1) {
navbar.css("top", "");
leftsidebar.css("top", "");
$('section.content').css('margin-top', '0 !important');
}
else {
navbar.css("top", divLicnese.outerHeight() + 'px');
leftsidebar.css("top", navbar.outerHeight() + divLicnese.outerHeight() + 'px');
$('.block-header, .addorder-pages').css('margin-top', '115px');
$('.page-header, .m-top-100').css('margin-top', '100px');
$('.alert-danger').css({
'top': 0,
'position': 'fixed',
'z-index': 999,
'width': '100%'
})
}
$('.btn-close').on ('click', function() {
navbar.css("top", '0')
$('.block-header, .addorder-pages').css('margin-top', '')
$('.page-header, .m-top-100').css('margin-top', '')
})
})
</script>

View File

@@ -135,7 +135,7 @@
<% @payment_methods.each do |method| %>
<tr>
<th></th>
<td style="text-align: right;"><%= method %> Payment</td>
<td style="text-align: right;"><%= method.parameterize == 'paymal' ? 'Card' : method.parameterize %> Payment</td>
<td><%= @other_payment[method.parameterize.to_sym] || 0.0 %></td>
<% total_other_amount = total_other_amount + (@other_payment[method.parameterize.to_sym] || 0.0) %>
</tr>
@@ -154,7 +154,7 @@
<tr>
<th></th>
<th style="text-align: right;">Total Payment </th>
<th><%= total_other_amount + @other_payment.foc_amount + @shift.cash_sales + @shift.credit_sales %></th>
<th><%= total_other_amount + @other_payment.foc_amount.to_d + @shift.cash_sales.to_d + @shift.credit_sales.to_d %></th>
</tr>
</table>
</td>