Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant into adminbsb_ui_changes
This commit is contained in:
@@ -4,7 +4,7 @@ class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
# lookup domain for db from provision
|
||||
before_action :check_license, :lookup_domain, :set_locale
|
||||
before_action :lookup_domain, :set_locale
|
||||
|
||||
helper_method :current_company,:current_login_employee,:current_user
|
||||
# alias_method :current_user, :current_login_employee,:current_user
|
||||
@@ -24,7 +24,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def lookup_domain
|
||||
if request.subdomain.present? && request.subdomain != "www"
|
||||
@license = current_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase)
|
||||
@license = cache_license(ENV["SX_PROVISION_URL"], request.subdomain.downcase) # request.subdomain.downcase
|
||||
if (!@license.nil?)
|
||||
# logger.info "Location - " + @license.name
|
||||
ActiveRecord::Base.establish_connection(website_connection(@license))
|
||||
@@ -35,19 +35,31 @@ class ApplicationController < ActionController::Base
|
||||
# redirect_to root_url(:host => request.domain) + "store_error"
|
||||
render :json => [{ status: false, message: 'Invalid Access!'}]
|
||||
end
|
||||
else
|
||||
# check for license file
|
||||
if check_license
|
||||
current_license(ENV["SX_PROVISION_URL"])
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def current_license(url, subdomain)
|
||||
@license = License.new(url, subdomain)
|
||||
def current_license(url)
|
||||
@license = License.new(url)
|
||||
|
||||
##creating md5 hash
|
||||
# md5_hostname = Digest::MD5.new
|
||||
# md5key = md5_hostname.update(request.host)
|
||||
if (@license.detail_with_local_file() == true)
|
||||
puts "RUN SAY BYAR"
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
# if (@license.detail_with_local_cache(subdomain, md5key.to_s) == true)
|
||||
#if (@license.detail == true)
|
||||
if (@license.detail_with_local_cache(subdomain) == true)
|
||||
def cache_license(url, lookup)
|
||||
@license = License.new(url, lookup)
|
||||
# Export for Key
|
||||
aes = MyAesCrypt.new
|
||||
aes_key, aes_iv = aes.export_key(lookup)
|
||||
|
||||
if (@license.detail_with_local_cache(lookup, aes_key, aes_iv) == true)
|
||||
return @license
|
||||
else
|
||||
return nil
|
||||
@@ -96,9 +108,7 @@ class ApplicationController < ActionController::Base
|
||||
private
|
||||
def check_license
|
||||
if License.check_license_file
|
||||
# if !License.check_license_valid
|
||||
# redirect_to install_path
|
||||
# end
|
||||
return true
|
||||
else
|
||||
redirect_to install_path
|
||||
end
|
||||
|
||||
@@ -137,7 +137,7 @@ class Crm::CustomersController < BaseCrmController
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json; version=2'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -241,9 +241,10 @@ end
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
# if paypar_account_no != nil || paypar_account_no != ''
|
||||
@@ -252,6 +253,7 @@ end
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
@@ -260,7 +262,7 @@ end
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json; version=2'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -273,7 +275,8 @@ end
|
||||
rescue SocketError
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
puts "ssssssss"
|
||||
puts response.to_json
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
|
||||
if response["status"] == true
|
||||
@@ -299,9 +302,10 @@ end
|
||||
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
|
||||
|
||||
member_params = { name: name,phone: phone,email: email,
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
|
||||
# Check for paypar account exists
|
||||
if paypar_account_no.present?
|
||||
@@ -309,6 +313,7 @@ end
|
||||
dob: dob,address: address,nrc:nrc,card_no:card_no,
|
||||
paypar_account_no: paypar_account_no,
|
||||
member_group_id: member_group_id,
|
||||
id:id,
|
||||
merchant_uid:merchant_uid,auth_token:auth_token}.to_json
|
||||
end
|
||||
|
||||
@@ -317,7 +322,7 @@ end
|
||||
:body => member_params,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json; version=2'
|
||||
},
|
||||
:timeout => 10
|
||||
)
|
||||
@@ -331,7 +336,17 @@ end
|
||||
response = { status: false}
|
||||
end
|
||||
|
||||
puts "ssssssss"
|
||||
puts response.to_json
|
||||
|
||||
if response["status"] == true
|
||||
customer = Customer.find(@crm_customer.customer_id)
|
||||
# Check membership id and bind to user
|
||||
if response["membership_id"] != nil
|
||||
status = customer.update_attributes(membership_id: response["membership_id"],membership_type:member_group_id )
|
||||
else
|
||||
status = customer.update_attributes(membership_type:member_group_id )
|
||||
end
|
||||
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @crm_customer }
|
||||
else
|
||||
|
||||
@@ -67,7 +67,7 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
|
||||
@order.guest = params[:guest_info]
|
||||
@order.table_id = params[:table_id] # this is dining facilities's id
|
||||
@order.new_booking = true
|
||||
@order.employee_name = current_login_employee.name
|
||||
@order.waiters = current_login_employee.name
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil?
|
||||
# check booking id is already completed.
|
||||
|
||||
@@ -6,7 +6,9 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
sale_id = params[:id]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
end
|
||||
|
||||
@member_discount = MembershipSetting.find_by_discount(1)
|
||||
@accounts = Account.all
|
||||
end
|
||||
@@ -197,7 +199,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
auth_token:auth_token}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json; version=2'
|
||||
}, :timeout => 10)
|
||||
rescue HTTParty::Error
|
||||
response = {"status": false, "message": "Can't open membership server " }
|
||||
@@ -213,7 +215,8 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
else
|
||||
response = {"status": false, "message": "You have no selected discount item" }
|
||||
end
|
||||
|
||||
puts "discount"
|
||||
puts response.to_json
|
||||
# Re-calc All Amount in Sale
|
||||
if response["status"] == true
|
||||
discount_amount = response["discount_earned"]
|
||||
@@ -227,7 +230,7 @@ class Origami::DiscountsController < BaseOrigamiController
|
||||
else
|
||||
result = {:status=> response["message"],:title=>"Alert", :table_id => table_id,:table_type => table_type }
|
||||
end
|
||||
|
||||
|
||||
render :json => result.to_json
|
||||
|
||||
end #end Is Card Payment
|
||||
|
||||
@@ -24,6 +24,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
|
||||
@dining.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
|
||||
@order_items = Array.new
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
@@ -31,26 +32,42 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
@date = order.created_at
|
||||
@booking= booking
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
@status_order = 'order'
|
||||
else
|
||||
sale = Sale.find(booking.sale_id)
|
||||
if sale.sale_status != "completed" && sale.sale_status != 'void'
|
||||
|
||||
@sale_array.push(sale)
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking= booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
@customer = sale.customer
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
@@ -5,6 +5,7 @@ class Origami::OtherChargesController < BaseOrigamiController
|
||||
sale_id = params[:sale_id]
|
||||
if Sale.exists?(sale_id)
|
||||
@sale_data = Sale.find(sale_id)
|
||||
@table = DiningFacility.find(@sale_data.bookings[0].dining_facility_id)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
# get member information
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
if customer.membership_id != nil && rebate
|
||||
member_info = Customer.get_member_account(customer)
|
||||
member_info = Customer.get_member_account(customer)
|
||||
rebate_amount = Customer.get_membership_transactions(customer,saleObj.receipt_no)
|
||||
end
|
||||
|
||||
@@ -116,12 +116,20 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
|
||||
#get customer amount
|
||||
@customer = Customer.find(@sale_data.customer_id)
|
||||
accounts = @customer.tax_profiles
|
||||
@account_arr =[]
|
||||
accounts.each do |acc|
|
||||
account = TaxProfile.find(acc)
|
||||
@account_arr.push(account)
|
||||
end
|
||||
|
||||
rebate = MembershipSetting.find_by_rebate(1)
|
||||
# get member information
|
||||
if @customer.membership_id != nil && rebate
|
||||
response = Customer.get_member_account(@customer)
|
||||
puts response.to_json
|
||||
if response["status"]==true
|
||||
response["data"].each do |res|
|
||||
response["account_data"].each do |res|
|
||||
if res["accountable_type"] == "RebateAccount" || res["accountable_type"] == "RebatebonusAccount"
|
||||
@balance += res["balance"]
|
||||
# @accountable_type = res["accountable_type"]
|
||||
@@ -136,6 +144,7 @@ class Origami::PaymentsController < BaseOrigamiController
|
||||
@sale_data.bookings.each do |sbk|
|
||||
df = DiningFacility.find(sbk.dining_facility_id)
|
||||
@table_no = df.type + ' ' + df.name
|
||||
@checkin_time = sbk.checkin_at
|
||||
break
|
||||
end
|
||||
|
||||
|
||||
@@ -24,10 +24,12 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@order_items = Array.new
|
||||
booking.booking_orders.each do |booking_order|
|
||||
order = Order.find(booking_order.order_id)
|
||||
@customer = order.customer
|
||||
if (order.status == "new")
|
||||
@obj_order = order
|
||||
@customer = order.customer
|
||||
|
||||
@date = order.created_at
|
||||
@booking = booking
|
||||
order.order_items.each do |item|
|
||||
@order_items.push(item)
|
||||
end
|
||||
@@ -42,6 +44,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
if @status_order == 'order'
|
||||
@status_order = 'sale'
|
||||
end
|
||||
@booking = booking
|
||||
@date = sale.created_at
|
||||
@status_sale = 'sale'
|
||||
@obj_sale = sale
|
||||
|
||||
@@ -45,7 +45,7 @@ class Origami::VoucherController < BaseOrigamiController
|
||||
}.to_json,
|
||||
:headers => {
|
||||
'Content-Type' => 'application/json',
|
||||
'Accept' => 'application/json'
|
||||
'Accept' => 'application/json; version=2'
|
||||
}, :timeout => 10
|
||||
)
|
||||
rescue Net::OpenTimeout
|
||||
|
||||
59
app/controllers/transactions/bookings_controller.rb
Normal file
59
app/controllers/transactions/bookings_controller.rb
Normal file
@@ -0,0 +1,59 @@
|
||||
class Transactions::BookingsController < ApplicationController
|
||||
load_and_authorize_resource except: [:create]
|
||||
before_action :set_transactions_booking, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
def index
|
||||
|
||||
filter = params[:filter]
|
||||
from = params[:from]
|
||||
to = params[:to]
|
||||
|
||||
if filter.nil? && from.nil? && to.nil?
|
||||
@bookings = Booking.all.order("sale_id desc")
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2)
|
||||
else
|
||||
sale = Sale.search(filter,from,to)
|
||||
if sale.count > 0
|
||||
@bookings = sale
|
||||
@bookings = Kaminari.paginate_array(@bookings).page(params[:page]).per(2)
|
||||
else
|
||||
@bookings = 0
|
||||
end
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @bookings }
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
# GET /transactions/bookings/1
|
||||
# GET /transactions/bookings/1.json
|
||||
def show
|
||||
|
||||
@booking = Booking.find(params[:id])
|
||||
|
||||
@order_items = []
|
||||
@booking.booking_orders.each do |booking_order|
|
||||
@order = Order.find(booking_order.order_id)
|
||||
#if (order.status == "new")
|
||||
@order_items = @order_items + @order.order_items
|
||||
#end
|
||||
end
|
||||
if @booking.sale_id.present?
|
||||
@sale = Sale.find(@booking.sale_id)
|
||||
end
|
||||
|
||||
respond_to do |format|
|
||||
format.html # show.html.erb
|
||||
format.json { render json: @booking }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_transactions_booking
|
||||
@transactions_booking = Booking.find(params[:id])
|
||||
end
|
||||
end
|
||||
@@ -15,12 +15,11 @@ class Transactions::CreditNotesController < ApplicationController
|
||||
|
||||
if filter.nil? && from.nil? && to.nil? && customer.nil?
|
||||
@sales = Sale.where('payment_status = ?', Sale::SALE_STATUS_OUTSTANDING)
|
||||
puts "cccccccccccc"
|
||||
else
|
||||
sale = Sale.search_credit_sales(customer,filter,from,to)
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
@sales = 0
|
||||
end
|
||||
|
||||
@@ -9,19 +9,18 @@ class Transactions::OrdersController < ApplicationController
|
||||
|
||||
if filter.nil? && from.nil? && to.nil? && count.nil?
|
||||
orders = Order.order("order_id desc")
|
||||
puts "ssssss"
|
||||
|
||||
else
|
||||
orders = Order.search(filter,from,to,count)
|
||||
puts "aaaaa"
|
||||
|
||||
end
|
||||
|
||||
if !orders.nil?
|
||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(50)
|
||||
@orders = Kaminari.paginate_array(orders).page(params[:page]).per(20)
|
||||
else
|
||||
@orders = []
|
||||
end
|
||||
puts @orders.to_json
|
||||
|
||||
respond_to do |format|
|
||||
format.html # index.html.erb
|
||||
format.json { render json: @orders }
|
||||
|
||||
@@ -11,13 +11,13 @@ class Transactions::SalesController < ApplicationController
|
||||
to = params[:to]
|
||||
|
||||
if receipt_no.nil? && from.nil? && to.nil?
|
||||
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc").limit(500)
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
@sales = Sale.where("NOT sale_status = 'void' " ).order("sale_id desc")
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
sale = Sale.search(receipt_no,from,to)
|
||||
if sale.count > 0
|
||||
@sales = sale
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(50)
|
||||
@sales = Kaminari.paginate_array(@sales).page(params[:page]).per(20)
|
||||
else
|
||||
@sales = 0
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user