Merge branch 'crm' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
Yan
2017-06-22 09:51:22 +06:30
53 changed files with 1580 additions and 574 deletions

View File

@@ -8,6 +8,16 @@ class ApplicationController < ActionController::Base
#this is base api base controller to need to inherit.
#all token authentication must be done here
#response format must be set to JSON
# rescue_from CanCan::AccessDenied do |exception|
# flash[:warning] = exception.message
# redirect_to root_path
# end
def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end
def current_company
begin
return Company.first

View File

@@ -7,23 +7,19 @@ class Crm::CustomersController < BaseCrmController
filter = params[:filter]
if filter.nil?
@crm_customers = Customer.order("customer_id").page(params[:page])
#@products = Product.order("name").page(params[:page]).per(5)
@crm_customers = Customer.all
else
@crm_customers = Customer.search(filter)
end
#@crm_customers = Customer.all
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customers = Kaminari.paginate_array(@crm_customers).page(params[:page]).per(50)
@crm_customer = Customer.new
@count_customer = Customer.count_customer
# if flash["errors"]
# @crm_customer.valid?
# end
# @membership = Customer.get_member_group
# if @membership["status"] == true
# @member_group = @membership["data"]
# end
respond_to do |format|
format.html # index.html.erb
format.json { render json: @crm_customers }
@@ -51,14 +47,7 @@ class Crm::CustomersController < BaseCrmController
#get customer amount
@customer = Customer.find(params[:id])
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
@response = Customer.get_membership_transactions(@customer)
#end customer amount
end
@@ -87,6 +76,8 @@ class Crm::CustomersController < BaseCrmController
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url")
@@ -95,14 +86,18 @@ class Crm::CustomersController < BaseCrmController
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
dob: dob,address: address,nrc:nrc,
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
rescue Net::OpenTimeout
response = { status: false }
end
if response["status"] == true
@@ -151,6 +146,8 @@ end
phone = customer_params[:contact_no]
email = customer_params[:email]
dob = customer_params[:date_of_birth]
address = customer_params[:address]
nrc = customer_params[:nrc_no]
id = @crm_customer.membership_id
member_group_id = params[:member_group_id]
@@ -159,22 +156,24 @@ end
merchant_uid = memberaction.merchant_account_id.to_s
auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,
dob: dob,address: address,nrc:nrc,
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
:headers => {
'Content-Type' => 'application/json',
'Accept' => 'application/json'
}
)
rescue Net::OpenTimeout
response = { status: false }
end
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else
flash[:errors] = @crm_customers.errors
flash[:errors] = @crm_customer.errors
format.html { redirect_to crm_customers_path}
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
end
@@ -201,6 +200,7 @@ end
# Never trust parameters from the scary internet, only allow the white list through.
def customer_params
params.require(:customer).permit(:name, :company, :contact_no, :email, :date_of_birth)
params.require(:customer).permit(:name, :company, :contact_no, :email,
:date_of_birth,:salution,:gender,:nrc_no,:address,:card_no)
end
end

View File

@@ -84,12 +84,15 @@ class Crm::DiningQueuesController < BaseCrmController
queue = DiningQueue.find(params[:id])
table_id = params[:table_id]
queue.update_attributes(dining_facility_id: table_id,status:"Assign")
DiningFacility.find(table_id).update_attributes(status: "occupied")
respond_to do |format|
format.html { redirect_to crm_dining_queues_path, notice: 'Table was successfully assigned.' }
format.json { head :no_content }
end
status = queue.update_attributes(dining_facility_id: table_id,status:"Assign")
status = DiningFacility.find(table_id).update_attributes(status: "occupied")
if status == true
render json: JSON.generate({:status => true , notice: 'Dining queue was successfully assigned .'})
else
render json: JSON.generate({:status => false, :error_message => "Record not found"})
end
end

View File

@@ -10,11 +10,13 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
sale_payment = SalePayment.new
sale_payment.process_payment(saleObj, @user, cash, "cash")
sale_payment.process_payment(saleObj, @user, cash, "cash")
rebate_amount = nil
unique_code = "ReceiptBillPdf"
customer= Customer.find(saleObj.customer_id)
rebate_amount = Customer.get_membership_transactions(customer)
# get member information
member_info = Customer.get_member_account(customer)
@@ -24,7 +26,7 @@ class Origami::PaymentsController < BaseOrigamiController
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
end
end
@@ -88,7 +90,7 @@ class Origami::PaymentsController < BaseOrigamiController
# get member information
member_info = Customer.get_member_account(customer)
rebate_amount = Customer.get_membership_transactions(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -96,7 +98,7 @@ class Origami::PaymentsController < BaseOrigamiController
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount)
end

View File

@@ -20,8 +20,11 @@ class Origami::RequestBillsController < BaseOrigamiController
end
unique_code = "ReceiptBillPdf"
customer= Customer.where('customer_id=' + @sale_data.customer_id)
# customer= Customer.where('customer_id=' +.customer_id)
customer= Customer.find( @sale_data.customer_id)
# get member information
member_info = Customer.get_member_account(customer)
# get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code)
@@ -32,6 +35,9 @@ class Origami::RequestBillsController < BaseOrigamiController
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info)
# redirect_to origami_path(@sale_data.sale_id)
end
end

View File

@@ -1,23 +1,11 @@
class Reports::DailySaleController < BaseReportController
def index
from, to = get_date_range_from_params
from, to ,report_type = get_date_range_from_params
@sale_data = Sale.daily_sales_list(from,to)
@tax = SaleTax.get_tax(from,to)
end
# @locations = Location.all
# branch,from, to, report_type = get_date_range_from_params
# @location = Location.find_by_id(current_location)
# @sale_data = Sale.daily_sales_report(current_location,from,to)
# @tax = SaleT.get_tax(current_location,from,to)
# if @sale_data.blank? && @tax.blank? && request.post?
# flash.now[:notice] = "No data available for selected filters"
# end
def show
end

View File

@@ -1,4 +1,5 @@
class Reports::ReceiptNoController < BaseReportController
def index
from, to = get_date_range_from_params
puts "from..."

View File

@@ -0,0 +1,14 @@
class Reports::SaleItemController < BaseReportController
def index
from, to, report_type = get_date_range_from_params
@sale_data = Sale.get_by_range_by_saleitems(from,to,Sale::SALE_STATUS_COMPLETED,report_type)
end
def show
end
end

View File

@@ -1,6 +1,8 @@
class Settings::EmployeesController < ApplicationController
# load_and_authorize_resource
before_action :set_employee, only: [:show, :edit, :update, :destroy]
# GET /employees
# GET /employees.json
def index

View File

@@ -53,13 +53,7 @@ class Transactions::SalesController < ApplicationController
#get customer amount
@customer = Customer.find(@sale.customer_id)
response = Customer.get_member_account(@customer)
if(response["status"] == true)
@membership = response["data"]
else
@membership = 0
end
@response = Customer.get_membership_transactions(@customer)
#end customer amount
respond_to do |format|