Merge branch 'master' of bitbucket.org:code2lab/sxrestaurant
This commit is contained in:
superuser
2017-06-23 18:00:18 +06:30
49 changed files with 922 additions and 463 deletions

View File

@@ -12,7 +12,7 @@ gem 'rails', '~> 5.1.0'
gem 'mysql2', '>= 0.3.18', '< 0.5' gem 'mysql2', '>= 0.3.18', '< 0.5'
#Use PosgreSQL #Use PosgreSQL
# gem 'pg' gem 'pg'
# redis server for cable # redis server for cable
# gem 'redis', '~> 3.0' # gem 'redis', '~> 3.0'

View File

@@ -37,7 +37,7 @@ $(document).ready(function(){
control_button(order_status); control_button(order_status);
var customer_id=$(this).find(".customer-id").text(); var customer_id=$(this).find(".customer-id").text();
//show_customer_details(customer_id); show_customer_details(customer_id);
$("#re-print").val(unique_id); $("#re-print").val(unique_id);

View File

@@ -9,6 +9,8 @@
// min-height: 75rem; // min-height: 75rem;
// padding-top: 4.5rem; // padding-top: 4.5rem;
// } // }
.card-columns {
font-size: 18px !important;}
.others-payment{ .others-payment{
line-height:100px; line-height:100px;
@@ -128,6 +130,11 @@
text-align: right; text-align: right;
} }
.item-attr-edit{
width: 10%;
text-align: left;
}
.display-none{ .display-none{
display: none; display: none;
} }

View File

@@ -34,12 +34,11 @@ class Api::BillController < Api::ApiController
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total # Calculate Price by accounts
item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) 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, item_price_by_accounts)
end end

View File

@@ -14,6 +14,7 @@ class ApplicationController < ActionController::Base
# redirect_to root_path # redirect_to root_path
# end # end
def current_user def current_user
@current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token] @current_user ||= Employee.find_by_token_session(session[:session_token]) if session[:session_token]
end end

View File

@@ -63,61 +63,62 @@ class Crm::CustomersController < BaseCrmController
def edit def edit
end end
# POST /crm/customers # POST /crm/customers
# POST /crm/customers.json # POST /crm/customers.json
def create def create
@crm_customers = Customer.new(customer_params) @crm_customers = Customer.new(customer_params)
respond_to do |format| respond_to do |format|
puts @crm_customers.errors.to_json
if @crm_customers.save if @crm_customers.save
name = customer_params[:name] name = customer_params[:name]
phone = customer_params[:contact_no] phone = customer_params[:contact_no]
email = customer_params[:email] email = customer_params[:email]
dob = customer_params[:date_of_birth] dob = customer_params[:date_of_birth]
address = customer_params[:address] address = customer_params[:address]
nrc = customer_params[:nrc_no] nrc = customer_params[:nrc_no]
member_group_id = params[:member_group_id] member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url") if !member_group_id.nil?
memberaction = MembershipAction.find_by_membership_type("create_membership_customer") membership = MembershipSetting.find_by_membership_type("paypar_url")
merchant_uid = memberaction.merchant_account_id.to_s memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
auth_token = memberaction.auth_token.to_s merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s auth_token = memberaction.auth_token.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
begin begin
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email, response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc, dob: dob,address: address,nrc:nrc,
member_group_id: member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, member_group_id: member_group_id,
:headers => { merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
'Content-Type' => 'application/json', :headers => {
'Accept' => 'application/json' 'Content-Type' => 'application/json',
}, 'Accept' => 'application/json'
:timeout => 10 },
) :timeout => 10
rescue Net::OpenTimeout )
response = { status: false } rescue Net::OpenTimeout
end response = { status: false }
end
if response["status"] == true if response["status"] == true
customer = Customer.find(@crm_customers.customer_id) customer = Customer.find(@crm_customers.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"]) status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
if params[:sale_id] if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' } format.html { redirect_to '/origami/'+params[:sale_id]+'/customers', notice: 'Customer was successfully created.' }
else else
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'} format.html { redirect_to crm_customers_path, notice: 'Customer was successfully created'}
end end
# format.json { render :index, status: :created, location: @crm_customers } # format.json { render :index, status: :created, location: @crm_customers }
else
# @crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
else else
format.html { redirect_to crm_customers_path, notice: response["message"] } # @crm_customers.destroy
if params[:sale_id]
format.html { redirect_to '/origami/'+params[:sale_id]+'/customers'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
end end
end end
else else
@@ -135,7 +136,6 @@ class Crm::CustomersController < BaseCrmController
end end
end end
# PATCH/PUT /crm/customers/1 # PATCH/PUT /crm/customers/1
# PATCH/PUT /crm/customers/1.json # PATCH/PUT /crm/customers/1.json
def update def update
@@ -152,26 +152,66 @@ end
id = @crm_customer.membership_id id = @crm_customer.membership_id
member_group_id = params[:member_group_id] member_group_id = params[:member_group_id]
membership = MembershipSetting.find_by_membership_type("paypar_url") if id.nil? && !member_group_id.nil?
memberaction = MembershipAction.find_by_membership_type("update_membership_customer") membership = MembershipSetting.find_by_membership_type("paypar_url")
merchant_uid = memberaction.merchant_account_id.to_s memberaction = MembershipAction.find_by_membership_type("create_membership_customer")
auth_token = memberaction.auth_token.to_s merchant_uid = memberaction.merchant_account_id.to_s
url = membership.gateway_url.to_s + memberaction.gateway_url.to_s auth_token = memberaction.auth_token.to_s
begin url = membership.gateway_url.to_s + memberaction.gateway_url.to_s
response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
dob: dob,address: address,nrc:nrc, begin
id: id,member_group_id:member_group_id,merchant_uid:merchant_uid,auth_token:auth_token}.to_json, response = HTTParty.post(url, :body => { name: name,phone: phone,email: email,
:headers => { dob: dob,address: address,nrc:nrc,
'Content-Type' => 'application/json', member_group_id: member_group_id,
'Accept' => 'application/json' merchant_uid:merchant_uid,auth_token:auth_token}.to_json,
}, :headers => {
:timeout => 10 'Content-Type' => 'application/json',
) 'Accept' => 'application/json'
rescue Net::OpenTimeout },
response = { status: false } :timeout 10
)
rescue Net::OpenTimeout
response = { status: false }
end
if response["status"] == true
customer = Customer.find(@crm_customer.customer_id)
status = customer.update_attributes(membership_id: response["customer_datas"]["id"],membership_type:member_group_id )
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated'}
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
else
membership = MembershipSetting.find_by_membership_type("paypar_url")
memberaction = MembershipAction.find_by_membership_type("update_membership_customer")
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,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'
},
:timeout => 10
)
rescue Net::OpenTimeout
response = { status: false }
end
if response["status"] == true
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else
format.html { redirect_to crm_customers_path, notice: response["message"] }
end
end end
format.html { redirect_to crm_customers_path, notice: 'Customer was successfully updated.' }
format.json { render :show, status: :ok, location: @crm_customer }
else else

View File

@@ -104,6 +104,6 @@ class Crm::DiningQueuesController < BaseCrmController
# Never trust parameters from the scary internet, only allow the white list through. # Never trust parameters from the scary internet, only allow the white list through.
def dining_queue_params def dining_queue_params
params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status) params.require(:dining_queue).permit(:name, :contact_no, :queue_no,:status,:seater,:remark)
end end
end end

View File

@@ -1,12 +1,12 @@
class Crm::HomeController < BaseCrmController class Crm::HomeController < BaseCrmController
def index def index
@booking = Booking.all # @booking = Booking.all
@customer = Customer.all # @customer = Customer.all
from = Time.now.beginning_of_day.utc # from = Time.now.beginning_of_day.utc
to = Time.now.end_of_day.utc # to = Time.now.end_of_day.utc
@queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC') # @queue = DiningQueue.where('created_at BETWEEN ? AND ?', from, to).order('queue_no ASC')
redirect_to crm_customers_path
# .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to) # .where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
end end

View File

@@ -83,6 +83,32 @@ class Oqs::HomeController < BaseOqsController
# Query for OQS with delivery status # Query for OQS with delivery status
def queue_items_query(status) def queue_items_query(status)
# queue_items = []
# AssignedOrderItem.all.each do |aoi|
# oqs = OrderQueueStation.find(aoi.order_queue_station_id)
# order = Order.find(aoi.order_id)
# order_items = OrderItem.find_by_order_id(aoi.order_id)
# booking_orders = BookingOrder.find_by_order_id(aoi.order_id)
# booking = Booking.find(booking_orders.booking_id)
# dining = DiningFacility.find(booking.dining_facility_id)
# customer = Customer.find_by_customer_id(order.customer_id)
# queue_item = {
# :assigned_order_item_id => aoi.assigned_order_item_id,
# :station_name => oqs.station_name,
# :is_active => oqs.is_active,
# :zone => dining.name,
# :item_code => aoi.item_code,
# :item_name => order_items.item_name,
# :price => order_items.price,
# :qty => order_items.qty,
# :item_order_by => order_items.item_order_by,
# :options => order_items.options,
# :customer_name => customer.name,
# :created_at => order_items.created_at
# }
# queue_items.push(queue_item)
# end
# return queue_items
AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at") AssignedOrderItem.select("assigned_order_items.assigned_order_item_id, oqs.station_name, oqs.is_active, df.name as zone, odt.item_code, odt.item_name, odt.price, odt.qty, odt.item_order_by, odt.options, cus.name as customer_name, odt.created_at")
.joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id .joins(" left join order_queue_stations as oqs on oqs.id = assigned_order_items.order_queue_station_id
left join orders as od ON od.order_id = assigned_order_items.order_id left join orders as od ON od.order_id = assigned_order_items.order_id

View File

@@ -12,8 +12,17 @@ class Origami::CustomersController < BaseOrigamiController
def add_customer def add_customer
@sale_id = params[:sale_id] @sale_id = params[:sale_id]
filter = params[:filter] if(@sale_id[0,3] == "SAL")
@booking = Booking.find_by_sale_id(@sale_id)
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
else
@booking_order = BookingOrder.find_by_order_id(@sale_id)
@booking = Booking.find(@booking_order.booking_id)
@dining_facility = DiningFacility.find(@booking.dining_facility_id)
end
filter = params[:filter]
filter = params[:filter] filter = params[:filter]

View File

@@ -19,6 +19,8 @@ class Origami::DiscountsController < BaseOrigamiController
if Sale.exists?(sale_id) if Sale.exists?(sale_id)
sale = Sale.find(sale_id) sale = Sale.find(sale_id)
table_id = sale.bookings[0].dining_facility_id
table_type = DiningFacility.find(table_id).type
sale.total_discount = overall_discount.to_f sale.total_discount = overall_discount.to_f
sale.total_amount = sub_total.to_f sale.total_amount = sub_total.to_f
sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax; sale.grand_total = (sub_total.to_f - overall_discount.to_f) + sale.total_tax;
@@ -45,6 +47,9 @@ class Origami::DiscountsController < BaseOrigamiController
end end
end end
end end
dining = {:table_id => table_id, :table_type => table_type }
render :json => dining.to_json
end end
#discount for selected order #discount for selected order

View File

@@ -25,11 +25,11 @@ class Origami::HomeController < BaseOrigamiController
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
if (order.status == "new") if (order.status == "new")
@obj_order = order @obj_order = order
@customer = order.customer
@date = order.created_at @date = order.created_at
order.order_items.each do |item| order.order_items.each do |item|
@order_items.push(item) @order_items.push(item)
end end
end
end end
@status_order = 'order' @status_order = 'order'
else else
@@ -43,6 +43,7 @@ class Origami::HomeController < BaseOrigamiController
@date = sale.created_at @date = sale.created_at
@status_sale = 'sale' @status_sale = 'sale'
@obj_sale = sale @obj_sale = sale
@customer = sale.customer
end end
end end
end end

View File

@@ -23,10 +23,10 @@ class Origami::PaymentsController < BaseOrigamiController
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total # Calculate Food and Beverage Total
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount)
end end
end end
@@ -53,7 +53,8 @@ class Origami::PaymentsController < BaseOrigamiController
response["data"].each do |res| response["data"].each do |res|
if res["accountable_type"] == "RebateAccount" if res["accountable_type"] == "RebateAccount"
@balance = res["balance"] @balance = res["balance"]
@accountable_type = res["accountable_type"] # @accountable_type = res["accountable_type"]
@accountable_type = "Rebate Balance"
end end
end end
end end
@@ -94,11 +95,11 @@ class Origami::PaymentsController < BaseOrigamiController
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
# Calculate Food and Beverage Total # Calculate price_by_accounts
food_total, beverage_total = SaleItem.calculate_food_beverage(saleObj.sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, food_total, beverage_total, member_info,rebate_amount) printer.print_receipt_bill(print_settings,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, member_info,rebate_amount)
end end

View File

@@ -24,19 +24,19 @@ class Origami::RequestBillsController < BaseOrigamiController
customer= Customer.find(@sale_data.customer_id) customer= Customer.find(@sale_data.customer_id)
# get member information # get member information
member_info = Customer.get_member_account(customer) member_info = Customer.get_member_account(customer)
# get printer info # get printer info
print_settings=PrintSetting.find_by_unique_code(unique_code) print_settings=PrintSetting.find_by_unique_code(unique_code)
# find order id by sale id # find order id by sale id
# sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id) # sale_order = SaleOrder.find_by_sale_id(@sale_data.sale_id)
# Calculate Food and Beverage Total # Calculate price_by_accounts
food_total, beverage_total = SaleItem.calculate_food_beverage(@sale_items) item_price_by_accounts = SaleItem.calculate_price_by_accounts(@sale_items)
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total,member_info) printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info)
# redirect_to origami_path(@sale_data.sale_id) # redirect_to origami_path(@sale_data.sale_id)
end end

View File

@@ -9,9 +9,11 @@ class Origami::RoomsController < BaseOrigamiController
@room.bookings.each do |booking| @room.bookings.each do |booking|
if booking.sale_id.nil? if booking.sale_id.nil?
@order_items = Array.new @order_items = Array.new
booking.booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id) order = Order.find(booking_order.order_id)
@obj = order @obj = order
@customer = order.customer
order.order_items.each do |item| order.order_items.each do |item|
@order_items.push(item) @order_items.push(item)
end end
@@ -23,6 +25,7 @@ class Origami::RoomsController < BaseOrigamiController
if sale.sale_status != "completed" if sale.sale_status != "completed"
@status = 'sale' @status = 'sale'
@obj = sale @obj = sale
@customer = sale.customer
end end
end end
end end

View File

@@ -0,0 +1,8 @@
class Origami::SaleEditController < BaseOrigamiController
def edit
sale_id = params[:sale_id]
@table_id = params[:table_id]
@saleobj = Sale.find(sale_id)
end
end

View File

@@ -53,7 +53,7 @@ class Transactions::SalesController < ApplicationController
#get customer amount #get customer amount
@customer = Customer.find(@sale.customer_id) @customer = Customer.find(@sale.customer_id)
@response = Customer.get_membership_transactions(@customer) @response = Customer.get_membership_transactions(@customer)
#end customer amount #end customer amount
respond_to do |format| respond_to do |format|

View File

@@ -20,8 +20,6 @@ class DiningFacility < ApplicationRecord
def get_booking def get_booking
booking = self.get_current_booking booking = self.get_current_booking
puts "is bookig?"
puts booking
if booking if booking
if booking.dining_facility_id.to_i == self.id if booking.dining_facility_id.to_i == self.id
if booking.booking_status == 'assign' if booking.booking_status == 'assign'

View File

@@ -22,10 +22,11 @@ class OrderQueueStation < ApplicationRecord
#Assign OQS id to order Items #Assign OQS id to order Items
oqs_stations.each do |oqs| oqs_stations.each do |oqs|
is_auto_printed = false
#Get List of items - #Get List of items -
pq_items = JSON.parse(oqs.processing_items) pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items #Loop through the processing items
pq_items.each do |pq_item| pq_items.each do |pq_item|
#Processing through the looping items #Processing through the looping items
order_items.each do |order_item| order_items.each do |order_item|
@@ -38,8 +39,10 @@ class OrderQueueStation < ApplicationRecord
AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs) AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# end # end
if oqs.auto_print # Auto Printing
if oqs.auto_print && is_auto_printed == false
print_slip(oqs, order, order_items) print_slip(oqs, order, order_items)
is_auto_printed = true
end end
end end
end end

View File

@@ -65,11 +65,11 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end end
#Bill Receipt Print #Bill Receipt Print
def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount=nil) def print_receipt_bill(printer_settings,sale_items,sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount=nil)
#Use CUPS service #Use CUPS service
#Generate PDF #Generate PDF
#Print #Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info,rebate_amount) pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info,rebate_amount)
pdf.render_file "tmp/receipt_bill.pdf" pdf.render_file "tmp/receipt_bill.pdf"
self.print("tmp/receipt_bill.pdf") self.print("tmp/receipt_bill.pdf")

View File

@@ -30,9 +30,24 @@ class SaleItem < ApplicationRecord
# end # end
end end
# Calculate food total and beverage total def self.calculate_price_by_accounts(sale_items)
def self.calculate_food_beverage(sale_items) price_accounts = []
Account.all.each do |a|
account_price = {:name => a.title, :price => 0}
sale_items.each do |si|
if si.account_id == a.id
account_price[:price] = account_price[:price] + si.price
end
end
price_accounts.push(account_price)
end
return price_accounts
end
# Calculate rebate_by_account
def self.calculate_rebate_by_account(sale_items)
rebateacc = Account.where("rebate=?",true) rebateacc = Account.where("rebate=?",true)
puts "Account that can rebate" puts "Account that can rebate"
rebateacc.each do |i| rebateacc.each do |i|
@@ -40,7 +55,7 @@ class SaleItem < ApplicationRecord
end end
prices=0 prices=0
sale_items.each do |si| sale_items.each do |si|
price = self.get_price(si.sale_item_id,rebateacc) price = self.get_rebate_price(si.sale_item_id,rebateacc)
prices = prices + price prices = prices + price
end end
@@ -48,7 +63,7 @@ class SaleItem < ApplicationRecord
end end
# get food price or beverage price for item # get food price or beverage price for item
def self.get_price(sale_item_id,rebateacc) def self.get_rebate_price(sale_item_id,rebateacc)
price=0 price=0
item=SaleItem.select("sale_items.price , menu_items.account_id") item=SaleItem.select("sale_items.price , menu_items.account_id")

View File

@@ -265,7 +265,7 @@ class SalePayment < ApplicationRecord
end end
def rebat(sObj) def rebat(sObj)
rebate_prices = SaleItem.calculate_food_beverage(sObj.sale_items) rebate_prices = SaleItem.calculate_rebate_by_account(sObj.sale_items)
puts "eeeeeeeeeeeeeeeeeeeeeeee" puts "eeeeeeeeeeeeeeeeeeeeeeee"
puts rebate_prices puts rebate_prices
generic_customer_id = sObj.customer.membership_id generic_customer_id = sObj.customer.membership_id

View File

@@ -2,7 +2,7 @@ class OrderItemPdf < Prawn::Document
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 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
def initialize(order_item, print_status, options) def initialize(order_item, print_status, options)
self.page_width = 210 self.page_width = 210
self.page_height = 2500 self.page_height = 1450
self.margin = 5 self.margin = 5
self.price_width = 40 # No Need for item self.price_width = 40 # No Need for item
self.qty_width = 30 self.qty_width = 30

View File

@@ -2,7 +2,7 @@ class OrderSummaryPdf < Prawn::Document
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 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
def initialize(order, print_status) def initialize(order, print_status)
self.page_width = 210 self.page_width = 210
self.page_height = 2500 self.page_height = 1450
self.margin = 5 self.margin = 5
self.price_width = 40 # No Need for item self.price_width = 40 # No Need for item
self.qty_width = 30 self.qty_width = 30

View File

@@ -2,7 +2,7 @@ class QueueNoPdf < Prawn::Document
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 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
def initialize(printer_settings, queue) def initialize(printer_settings, queue)
self.page_width = 210 self.page_width = 210
self.page_height = 2500 self.page_height = 1450
self.margin = 5 self.margin = 5
self.price_width = 35 self.price_width = 35
self.qty_width = 20 self.qty_width = 20

View File

@@ -1,6 +1,6 @@
class ReceiptBillPdf < Prawn::Document class ReceiptBillPdf < Prawn::Document
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 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
def initialize(printer_settings, sale_items, sale_data, customer_name, food_total, beverage_total, member_info = nil,rebate_amount = nil) def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, member_info = nil,rebate_amount = nil)
self.page_width = 210 self.page_width = 210
self.page_height = 2500 self.page_height = 2500
self.margin = 5 self.margin = 5
@@ -29,7 +29,8 @@ class ReceiptBillPdf < Prawn::Document
stroke_horizontal_rule stroke_horizontal_rule
cashier_info(sale_data, customer_name) cashier_info(sale_data, customer_name)
line_items(sale_items, food_total, beverage_total) line_items(sale_items)
items_account(item_price_by_accounts)
all_total(sale_data) all_total(sale_data)
@@ -103,26 +104,24 @@ class ReceiptBillPdf < Prawn::Document
move_down 5 move_down 5
end end
def line_items(sale_items, food_total, beverage_total) def line_items(sale_items)
y_position = cursor y_position = cursor
pad_top(15) { pad_top(15) {
# @item_width.to_i + @half_qty.to_i # @item_width.to_i + @half_qty.to_i
text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix text_box "Items", :at =>[0,y_position], :width => self.item_width, :height =>self.item_height, :size => self.item_font_size, :overflow => :shrink_to_fix
text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "Price", :at =>[self.item_width,y_position], :width => self.price_width, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix text_box "Qty", :at =>[(self.item_width+self.price_width),y_position], :width => self.qty_width, :height =>self.item_height, :size => self.item_font_size, :align => :center, :overflow => :shrink_to_fix
text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix text_box "Total", :at =>[(self.item_width+self.price_width+4),y_position], :width => self.total_width+3, :height =>self.item_height, :size => self.item_font_size, :align => :right, :overflow => :shrink_to_fix
}
}
move_down 5 move_down 5
stroke_horizontal_rule stroke_horizontal_rule
add_line_item_row(sale_items, food_total, beverage_total) add_line_item_row(sale_items)
end end
def add_line_item_row(sale_items, food_total, beverage_total) def add_line_item_row(sale_items)
item_name_width = (self.item_width+self.price_width) item_name_width = (self.item_width+self.price_width)
y_position = cursor y_position = cursor
move_down 5 move_down 5
@@ -156,24 +155,25 @@ class ReceiptBillPdf < Prawn::Document
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ sub_total }" , :size => self.item_font_size,:align => :right text "#{ sub_total }" , :size => self.item_font_size,:align => :right
end end
# Food and Beverage
food_beverage_total = food_total.to_s + "/" + beverage_total.to_s
move_down 5 move_down 5
end
def items_account(item_price_by_accounts)
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width => self.item_description_width, :height => self.item_height) do item_price_by_accounts.each do |ipa|
text "Food/Beverage Total", :size => self.item_font_size,:align => :left y_position = cursor
end bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do
bounding_box([self.item_description_width,y_position], :width => self.label_width) do text "#{ ipa[:name] }", :size => self.item_font_size,:align => :left
text "#{ food_beverage_total }" , :size => self.item_font_size,:align => :right end
bounding_box([self.item_description_width,y_position], :width =>self.label_width) do
text "#{ ipa[:price] }" , :size => self.item_font_size,:align => :right
end
move_down 5
end end
end end
def all_total(sale_data) def all_total(sale_data)
item_name_width = self.item_width item_name_width = self.item_width
move_down 5
y_position = cursor y_position = cursor
bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do bounding_box([0,y_position], :width =>self.item_description_width, :height => self.item_height) do

View File

@@ -104,6 +104,7 @@
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label> <label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" > <select class="selectpicker form-control col-md-12" name="member_group_id" style="height: 40px" >
<option value="">Select Membership Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %> <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>"> <option value="<%= member.value %>">
<%= member.name %></option> <%= member.name %></option>

View File

@@ -37,9 +37,10 @@
<th>Select</th> <th>Select</th>
<th>Sr.no</th> <th>Sr.no</th>
<th>Name</th> <th>Name</th>
<th>Company</th> <th>Card No</th>
<th>Contact no</th> <th>Contact no</th>
<th>Email</th> <th>Email</th>
<th>Action</th>
</tr> </tr>
</thead> </thead>
@@ -52,7 +53,7 @@
<input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td> <input type="radio" style="width:20px;" name="checkbox" class="checkbox_check" ></td>
<td><%= @i += 1 %></td> <td><%= @i += 1 %></td>
<td><%= crm_customer.name %></td> <td><%= crm_customer.name %></td>
<td><%= crm_customer.company rescue '-' %></td> <td><%= crm_customer.card_no rescue '-' %></td>
<td><%= crm_customer.contact_no %></td> <td><%= crm_customer.contact_no %></td>
<td><%= crm_customer.email %></td> <td><%= crm_customer.email %></td>
<td><%= link_to 'Show', crm_customer_path(crm_customer) %></td> <td><%= link_to 'Show', crm_customer_path(crm_customer) %></td>
@@ -126,7 +127,7 @@ $(document).on('click',".customer_tr",function(){
$('#customer_address').val(data.address); $('#customer_address').val(data.address);
$('#customer_date_of_birth').val(data.date_of_birth); $('#customer_date_of_birth').val(data.date_of_birth);
$('#customer_membership_type').val(data.membership_type); $('#customer_membership_type').val(data.membership_type);
$('.selectpicker > option[value="'+data.membership_type+'"]').attr('selected','selected');
if (data.gender == 'Male') { if (data.gender == 'Male') {
$('.male').prop( "checked", true ) $('.male').prop( "checked", true )
}else{ }else{
@@ -142,7 +143,7 @@ $(document).on('click',".customer_tr",function(){
}else{ }else{
$('.mdm').prop( "checked", true ) $('.mdm').prop( "checked", true )
} }
// $('.selectpicker > option[value="'+data.membership_id+'"]').attr('selected','selected');
$('.membership_authentication_code').val(data.membership_authentication_code); $('.membership_authentication_code').val(data.membership_authentication_code);
$('#update_customer').removeAttr('disabled').val(''); $('#update_customer').removeAttr('disabled').val('');
@@ -150,11 +151,14 @@ $(document).on('click',".customer_tr",function(){
$('#submit_customer').attr('disabled','disabled'); $('#submit_customer').attr('disabled','disabled');
$("#new_customer").attr('class', 'simple_form edit_customer'); $("#new_customer").attr('class', 'simple_form edit_customer');
var id = "edit_customer_"+$('#customer_id').val(); var id = "edit_customer_"+customer_id;
alert(id)
$("#new_customer").attr('id', id); $("#new_customer").attr('id', id);
$(".edit_customer").attr('id', id);
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val()); $(".edit_customer").attr('action', '/crm/customers/' + $('#customer_id').val());
$(".patch_method").append('<input type="hidden" name="_method" value="patch">'); $(".patch_method").html('<input type="hidden" name="_method" value="patch">');
//$(".edit_customer").attr('method', 'PATCH'); //$(".edit_customer").attr('method', 'PATCH');
} }
}); });

View File

@@ -1,126 +1,166 @@
<div class="row"> <div class="row">
<div class="col-lg-12"> <div class="col-lg-11 col-md-11 col-sm-11">
<ol class="breadcrumb"> <!-- Column One -->
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
<li><%= @customer.customer_id%></li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11">
<!-- Column One -->
<div class="tab-pane active" id="queue" role="tabpanel"">
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Card No</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<th>NRC/Passport No</th>
<th>Address</th>
<th>DOB</th>
</tr>
</thead>
<tbody> <!-- Nav tabs -->
<tr> <ul class="nav nav-tabs" role="tablist">
<td><%= @customer.card_no rescue '-'%></td> <li class="nav-item">
<td><%= @customer.name %></td> <a class="nav-link active" data-toggle="tab" href="#customer" role="tab">Customer Details</a>
<td><%= @customer.company rescue '-' %></td> </li>
<td><%= @customer.contact_no %></td> <li class="nav-item">
<td><%= @customer.email %></td> <a class="nav-link " data-toggle="tab" href="#order" role="tab">Order Details</a>
<td><%= @customer.nrc_no %></td> </li>
<td><%= @customer.address%></td> <li class="nav-item">
<td><%= @customer.date_of_birth %></td> <a class="nav-link" data-toggle="tab" href="#sale" role="tab">Sale Details</a>
</tr> </li>
<tr> </ul>
<th colspan="8">Membership Transactions</th> <!-- Nav tabs - End -->
</tr>
<tr>
<th>Date</th>
<th>Redeem</th>
<th>Rebate</th>
<th>Balance</th>
<!-- <th>Account No</th> -->
<th>Status</th>
<th>Receipt No</th>
</tr>
<% <div class="tab-content" style="min-height:670px; max-height:670px; ">
if @response["status"] == true %>
<% @response["data"].each do |transaction| %>
<tr>
<td><%= transaction["date"]%></td>
<td><%= transaction["redeem"]%></td>
<td><%= transaction["rebate"] %></td>
<td><%= transaction["balance"] %></td>
<!-- <td><%= transaction["account_no"] %></td> -->
<td><%= transaction["status"] %></td>
<td><%= transaction["receipt_no"] %></td>
</tr> <div class="tab-pane active" id="customer" role="tabpanel" style="min-height:670px; max-height:670px; ">
<% end %> <div class="table-responsive">
<% end %> <br><br>
</tbody> <table class="table table-striped">
</table> <thead>
</div> <tr>
<th>Card No</th>
<th>Name</th>
<th>Company</th>
<th>Contact no</th>
<th>Email</th>
<th>NRC/Passport No</th>
<th>Address</th>
<th>DOB</th>
</tr>
</thead>
</div> <tbody>
<!-- Nav tabs --> <tr>
<ul class="nav nav-tabs" role="tablist"> <td><%= @customer.card_no rescue '-'%></td>
<!-- <li class="nav-item"> <td><%= @customer.name %></td>
<a class="nav-link active" data-toggle="tab" href="#queue" role="tab">Customer Details </a> <td><%= @customer.company rescue '-' %></td>
</li> --> <td><%= @customer.contact_no %></td>
<li class="nav-item"> <td><%= @customer.email %></td>
<a class="nav-link " data-toggle="tab" href="#booking" role="tab">Orders </a> <td><%= @customer.nrc_no %></td>
</li> <td><%= @customer.address%></td>
<li class="nav-item"> <td><%= @customer.date_of_birth %></td>
<a class="nav-link" data-toggle="tab" href="#customer" role="tab">Sales</a> </tr>
</li> <tr><th colspan="8"></th></tr>
</ul>
<!-- Nav tabs - End --> </tbody>
<div class="tab-content"> </table>
<div class="tab-pane" id="booking" role="tabpanel"> </div>
<h3>Order Details</h3>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th colspan="5">Membership Transactions</th>
<% if @response["status"] == true %>
<th>Current Balance : <%= @response["data"][0]["balance"]%></th>
<% end %>
</tr>
<tr>
<th>Date</th>
<th>Redeem</th>
<th>Rebate</th>
<th>Balance</th>
<!-- <th>Account No</th> -->
<th>Status</th>
<th>Receipt No</th>
</tr>
</thead>
<tbody>
<% if @response["status"] == true %>
<% @response["data"].each do |transaction| %>
<tr>
<td><%= transaction["date"]%></td>
<td><%= transaction["redeem"]%></td>
<td><%= transaction["rebate"] %></td>
<td><%= transaction["balance"] %></td>
<!-- <td><%= transaction["account_no"] %></td> -->
<td><%= transaction["status"] %></td>
<td><%= transaction["receipt_no"] %></td>
</tr>
<% end %>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="order" role="tabpanel" style="min-height:670px; max-height:670px; ">
<h3>Order Details</h3>
<div class="table-responsive">
<table class="table table-striped">
<thead>
<tr>
<th>Order ID</th>
<th>Menu Item</th>
<th>QTY</th>
<th>Unit Price </th>
<th>Option</th>
<th>Status</th>
<th>Waiter</th>
<th>Created at </th>
</tr>
</thead>
<tbody>
<% @order_items.each do |order_item| %>
<tr>
<td><%= order_item.order_id %></td>
<td><%= order_item.item_name %></td>
<td><%= order_item.qty %></td>
<td><%= order_item.price %></td>
<td><%= order_item.options %></td>
<td><%= order_item.order_item_status %></td>
<td><%= order_item.item_order_by %> </td>
<td><%= order_item.created_at.strftime("%d-%m-%y") %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
<div class="tab-pane" id="sale" role="tabpanel" style="min-height:670px; max-height:670px; ">
<h3>Sale Details</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
<thead> <thead>
<tr> <tr>
<th>Order ID</th> <th>Sale ID </th>
<th>Menu Item</th> <th>Menu Item</th>
<th>QTY</th> <th>QTY</th>
<th>Unit Price </th> <th>Unit Price </th>
<th>Option</th> <th>Tax Price</th>
<th>Status</th> <th>Created At</th>
<th>Waiter</th>
<th>Created at </th>
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<% @order_items.each do |order_item| %> <% @sale_items.each do |sale_item| %>
<tr> <tr>
<td><%= order_item.order_id %></td> <td><%= sale_item.sale_id %></td>
<td><%= order_item.item_name %></td> <td><%= sale_item.product_name %></td>
<td><%= order_item.qty %></td> <td><%= sale_item.qty %></td>
<td><%= order_item.price %></td> <td><%= sale_item.unit_price %></td>
<td><%= order_item.options %></td>
<td><%= order_item.order_item_status %></td> <td><%= sale_item.taxable_price %></td>
<td><%= order_item.item_order_by %> </td> <td><%= sale_item.created_at %></td>
<td><%= order_item.created_at.strftime("%d-%m-%y") %></td>
</tr> </tr>
<% end %> <% end %>
</tbody> </tbody>
</table> </table>
</div> </div>
</div> </div>
<div class="tab-pane" id="customer" role="tabpanel"> <div class="tab-pane" id="customer" role="tabpanel">
<h3>Sale Details</h3> <h3>Sale Details</h3>
<div class="table-responsive"> <div class="table-responsive">
<table class="table table-striped"> <table class="table table-striped">
@@ -150,18 +190,17 @@
</tbody> </tbody>
</table> </table>
</div> </div>
</div>
</div> </div>
</div> </div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<br><br> <br><br>
<a href="<%= crm_customers_path%>" class="btn btn-primary pull"> <a href="<%= crm_customers_path%>" class="btn btn-primary btn-lg">
<i class="fa fa-arrow-left fa-xs"></i> Back <i class="fa fa-arrow-left fa-lg"></i> Back
</a> </a>
</div> </div>
</div> </div>

View File

@@ -1,85 +0,0 @@
<div class="row">
<div class="col-lg-12">
<ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li>
<li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li>
<li class="active">Details
</li>
</ol>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<div class="main-box-body clearfix">
<div class="table-responsive">
<hr>
<table class="table table-striped">
<thead>
<tr>
<th>Name</th>
<th>Email</th>
<th>Contact no</th>
<th>Company</th>
<th>Date Of Birth</th>
<th>Membership Account</th>
</tr>
</thead>
<tbody>
<tr>
<td><%= @crm_customer.name %></td>
<td><%= @crm_customer.email %></td>
<td><%= @crm_customer.contact_no %></td>
<td><%= @crm_customer.company %></td>
<td><%= @crm_customer.date_of_birth %> </td>
</tr>
</tbody>
</table>
<br>
<h3>Sale Items</h3>
<table class="table table-striped">
<thead>
<tr>
<th>Sale ID </th>
<th>Menu Item</th>
<th>QTY</th>
<th>Unit Price </th>
<th>Tax Price</th>
<th>Created At</th>
</tr>
</thead>
<tbody>
<% @sale_items.each do |sale_item| %>
<tr>
<td><%= sale_item.sale_id %></td>
<td><%= sale_item.product_name %></td>
<td><%= sale_item.qty %></td>
<td><%= sale_item.unit_price %></td>
<td><%= sale_item.taxable_price %></td>
<td><%= sale_item.created_at %></td>
</tr>
<% end %>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>

View File

@@ -2,15 +2,20 @@
<%= simple_form_for([:crm,@dining_queue]) do |f| %> <%= simple_form_for([:crm,@dining_queue]) do |f| %>
<%= f.error_notification %> <%= f.error_notification %>
<p class="hidden generate_no"><%= @queue_no %></p> <p class="hidden generate_no"><%= @queue_no %></p>
<div class="form-inputs"> <div class="col-md-6">
<%= f.input :name %> <div class="form-inputs">
<%= f.input :contact_no %> <%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%>
<%= f.input :queue_no , :class => "dining",:id => "dining", :readonly => true%> <%= f.input :name %>
<%= f.input :contact_no %>
<%= f.input :seater %>
<%= f.input :remark %>
</div>
<br> </div>
<div class="form-actions"> <br>
<%= f.button :submit,"Create Queue" %> <div class="form-actions">
<%= f.button :submit,"Create Queue" %>
</div>
</div> </div>
<% end %> <% end %>

View File

@@ -24,6 +24,7 @@
<p class="hidden queue-id"><%= @queue.id %></p> <p class="hidden queue-id"><%= @queue.id %></p>
<p class="hidden queue-status"><%= table.status %></p> <p class="hidden queue-status"><%= table.status %></p>
<p style="text-align: center"><%= table.name %></p> <p style="text-align: center"><%= table.name %></p>
<p style="text-align: center">Seat : <%= table.seater %></p>
</div> </div>
</div> </div>

View File

@@ -26,6 +26,7 @@
<p class="hidden queue-status"><%= queue.status %></p> <p class="hidden queue-status"><%= queue.status %></p>
<span class="card-title"> <span class="card-title">
<%= @i += 1 %> . Queue No </span> <%= @i += 1 %> . Queue No </span>
<span class="card-title pull-right">Seater : <%= queue.seater %> </span>
<p style="font-size: 30px ;text-align: center;"> <p style="font-size: 30px ;text-align: center;">
<strong><%= queue.queue_no %></strong> <strong><%= queue.queue_no %></strong>
</p> </p>

View File

@@ -73,6 +73,8 @@
<span class="patch_method"></span> <span class="patch_method"></span>
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" /> <input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<input type="hidden" id="table_id" name="table_id" value="<%= @dining_facility.id %>" />
<input type="hidden" id="type" name="type" value="<%= @dining_facility.type %>" />
<%= f.error_notification %> <%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %> <%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>"> <div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
@@ -171,6 +173,7 @@
<div class="form-group"> <div class="form-group">
<label>Select Member Group</label> <label>Select Member Group</label>
<select class="selectpicker form-control col-md-12" name="member_group_id"> <select class="selectpicker form-control col-md-12" name="member_group_id">
<option value="">Select Membership Group</option>
<% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %> <% Lookup.where("lookup_type = ?", "member_group_type" ).each do |member| %>
<option value="<%= member.value %>"> <option value="<%= member.value %>">
<%= member.name %></option> <%= member.name %></option>
@@ -186,9 +189,9 @@
</div> </div>
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<br> <br>
<a href="<%= origami_root_path%>" class="btn btn-primary"> <button id="back" class="btn btn-primary">
<i class="fa fa-arrow-left fa-lg"></i> Back <i class="fa fa-arrow-left fa-lg"></i> Back
</a> </button>
</div> </div>
</div> </div>
@@ -292,8 +295,14 @@
success: function(data) { success: function(data) {
if(data.status == true) if(data.status == true)
{ {
var id = $("#table_id").val()
var type = $("#type").val()
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
window.location.href = '/origami'
}else{ }else{
alert('Record not found!'); alert('Record not found!');
location.reload(); location.reload();
@@ -307,4 +316,27 @@
}); });
} }
$('#back').on('click',function(){
var id = $("#table_id").val()
var type = $("#type").val()
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
})
</script> </script>
class CreateDiningQueues < ActiveRecord::Migration[5.1]
def change
create_table :dining_queues do |t|
t.string :name
t.string :contact_no
t.string :queue_no
t.string :status
t.references :dining_facility, foreign_key: true
t.timestamps
end
end
end

View File

@@ -80,7 +80,7 @@
<!-- Column One --> <!-- Column One -->
<!-- Column Two --> <!-- Column Two -->
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-5 col-md-5 col-sm-5">
<!-- Discount Amount --> <!-- Discount Amount -->
<div class="card"> <div class="card">
<div class="card-header"> <div class="card-header">
@@ -168,13 +168,22 @@
<div class="form-group"> <div class="form-group">
<button id="net" class="btn btn-warning fluid action-btn">Net</button> <button id="net" class="btn btn-warning fluid action-btn">Net</button>
<button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button> <button id="percentage" class="btn btn-primary fluid action-btn">Percentage</button>
<button id="pay-discount" class="btn btn-danger fluid action-btn">Enter</button> <button id="remove-item" class="btn btn-default fluid action-btn">Remove</button>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Action Panel -->
<div>
<button type="button" class="btn btn-primary btn-block" onclick="window.location.href = '/origami';"><i class="fa fa-arrow-left"></i> Back </button>
<button id="pay-discount" class="btn btn-danger btn-block action-btn">Enter</button>
</div>
</div>
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
@@ -233,6 +242,16 @@ $(document).ready(function(){
} }
}); });
// Select discount-item
$('#order-items-table tbody').on('click', '.discount-item-row',function(){
if($(this).hasClass('selected-item') == true){
$(this).removeClass('selected-item');
}
else {
$(this).addClass('selected-item');
}
});
// Select for account types // Select for account types
$(".accounts-type").on('click', function(e){ $(".accounts-type").on('click', function(e){
if($(this).hasClass('selected-account') == true){ if($(this).hasClass('selected-account') == true){
@@ -241,6 +260,13 @@ $(document).ready(function(){
else { else {
$(this).addClass('selected-account'); $(this).addClass('selected-account');
} }
var account_id = $(this).attr('id').substr(8);
$(".item-row").each(function(i){
if($(this).children().find("#item-account-type").text() == account_id){
$(this).addClass("selected-item");
}
});
}); });
// Calculate Net Discount for Payment // Calculate Net Discount for Payment
@@ -262,6 +288,9 @@ $(document).ready(function(){
else { else {
calculate_item_discount(0, discount_value, sale_items, account_types); calculate_item_discount(0, discount_value, sale_items, account_types);
} }
// Remove Selection
selection_remove();
}); });
// Calculate Percentage Discount for Payment // Calculate Percentage Discount for Payment
@@ -283,9 +312,20 @@ $(document).ready(function(){
else { else {
calculate_item_discount(1, discount_value, sale_items, account_types); calculate_item_discount(1, discount_value, sale_items, account_types);
} }
// Remove Selection
selection_remove();
});
// Remove selected discount items
$("#remove-item").on('click', function(e){
e.preventDefault();
$('.discount-item-row.selected-item').each(function(i){
$(this).remove();
});
}); });
// Pay Discount
// Pay Discount for Payment // Pay Discount for Payment
$("#pay-discount").on('click', function(e){ $("#pay-discount").on('click', function(e){
e.preventDefault(); e.preventDefault();
@@ -309,7 +349,14 @@ $(document).ready(function(){
data: params, data: params,
success:function(result){ success:function(result){
alert("Successfully Discount!"); alert("Successfully Discount!");
window.history.back(); if(result.table_type == "Table"){
window.location.href = "/origami/table/" + result.table_id
}
else {
window.location.href = "/origami/room/" + result.table_id
}
// window.history.back();
} }
}); });
}); });
@@ -331,6 +378,13 @@ function update_balance(){
$('#order-grand-total').text(total); $('#order-grand-total').text(total);
} }
/* Remove Selection */
function selection_remove(){
$(".item-row").removeClass("selected-item");
$(".discount_item_row").removeClass("selected-item");
$(".accounts-type").removeClass("selected-account");
}
/* Get Item rows but not discount*/ /* Get Item rows but not discount*/
function get_item_rows(){ function get_item_rows(){
var sale_items = []; var sale_items = [];
@@ -359,11 +413,24 @@ function get_discount_item_rows(){
return sale_items; return sale_items;
} }
/* Get discount Item rows */
// function get_selected_discount_items(){
// var sale_items = [];
// $('.discount-item-row').hasClass('.selected-item').each(function(i){
// var sale_item = {};
// sale_item.id = $(this).attr('id');
// sale_item.name = $(this).find('#item-name-price').text();
// sale_item.account_id = $(this).find('#item_account_type').text();
// sale_item.price = $(this).find('#item-total-price').text();
// sale_items.push(sale_item);
// });
// return sale_items;
// }
/* Get Selected Sale Item's ID and Price */ /* Get Selected Sale Item's ID and Price */
function get_selected_sale_items(){ function get_selected_sale_items(){
var sale_items = []; var sale_items = [];
$('.selected-item').each(function(i){ $('.item-row.selected-item').each(function(i){
var sale_item = {}; var sale_item = {};
sale_item.id = $(this).attr('id').substr(0,16); sale_item.id = $(this).attr('id').substr(0,16);
sale_item.name = $(this).find('#item-name-price').text().split('@')[0]; sale_item.name = $(this).find('#item-name-price').text().split('@')[0];
@@ -526,7 +593,7 @@ function item_row_template(type, item, discount_amount, amount){
if(type == 1){ if(type == 1){
dis_str = dis_str + "(" + amount + "%)" dis_str = dis_str + "(" + amount + "%)"
} }
var discount_item_row = "<tr class='item-row discount-item-row' id='" + item.id + "'>" + var discount_item_row = "<tr class='discount-item-row' id='" + item.id + "'>" +
"<td style='width: 60%; text-align: left;'>" + "<td style='width: 60%; text-align: left;'>" +
"<span id='item_account_type' class='hidden'>" + "<span id='item_account_type' class='hidden'>" +
item.account_id + item.account_id +

View File

@@ -41,6 +41,11 @@
<div class="card tables red text-white" data-id="<%= table.id %>"> <div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if table.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -62,6 +67,11 @@
<div class="card rooms red text-white" data-id="<%= room.id %>"> <div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if room.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -113,12 +123,14 @@
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p> <p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p>
</div> </div>
</div> </div>
@@ -259,22 +271,24 @@
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button> <button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
<% if @dining.bookings.length >= 1 %> <% if @dining.bookings.length >= 1 %>
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button> <button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<% if @status_order == 'order' && @status_sale != 'sale' %> <% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button> <button type="button" class="btn btn-primary btn-block" >Add Order</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button> <button type="button" class="btn btn-primary btn-block" disabled >Edit</button>
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button> <button type="button" id="discount" class="btn btn-primary btn-block" disabled >Discount</button>
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button> <button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<% else %> <button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button>
<% else %>
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-block" id='edit'>Edit</button>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button> <button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button> <button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button> <button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
<button type="button" class="btn btn-primary btn-block" > Void </button> <button type="button" class="btn btn-primary btn-block" > Void </button>
<% end %> <% end %>
<!-- Cashier Buttons --> <!-- Cashier Buttons -->
@@ -285,23 +299,39 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".tables").on('click', function(){ $(".tables").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id; window.location.href = '/origami/table/' + dining_id;
}); });
$(".sales").on('click',function(){ $(".sales").on('click',function(){
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id; var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id;
}); });
$(".rooms").on('click', function(){ $(".rooms").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id; window.location.href = '/origami/room/' + dining_id;
}); });
$(".orders").on('click',function(){ $(".orders").on('click',function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id; var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
}); });
// bind customer to order or sale // bind customer to order or sale
@@ -312,8 +342,10 @@ $(document).ready(function(){
}else{ }else{
var sale_id = $('#save_order_id').attr('data-order'); var sale_id = $('#save_order_id').attr('data-order');
} }
var table_id = $('.tables').attr("data-id");
window.location.href = '/origami/'+ sale_id + "/customers" window.location.href = '/origami/'+ sale_id + "/customers"
}); });
// Discount for Payment // Discount for Payment
@@ -382,4 +414,45 @@ $('#add_invoice').on('click',function(){
} }
}); });
}) })
//show cusotmer rebate amount
function show_customer_details(customer_id){
var url = '<%= @show_customer_details_path %>'
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
if (data["response_data"]["data"].length) {
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
if (data["response_data"]["status"]==true) {
$('.rebate_amount').removeClass('hide');
row =
'<td class="charges-name">' + "Rebate Balance" +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row);
}
}
});
}else{
$('.rebate_amount').addClass('hide');
}
}
});
//End Ajax
}
$('#edit').on('click',function(){
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
window.location.href = '/origami/table/'+ dining_id + "/sale/"+ sale_id + "/edit";
})
</script> </script>

View File

@@ -86,7 +86,7 @@
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">

View File

@@ -86,7 +86,7 @@
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @date.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">

View File

@@ -41,6 +41,11 @@
<div class="card tables red text-white" data-id="<%= table.id %>"> <div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if table.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -62,6 +67,11 @@
<div class="card rooms red text-white" data-id="<%= room.id %>"> <div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if room.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -119,7 +129,7 @@
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @order.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @order.created_at.utc.getlocal.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">

View File

@@ -243,7 +243,6 @@
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button> <button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block"> FOC </button> <button type="button" class="btn btn-primary btn-block"> FOC </button>
</div> </div>
</div> </div>

View File

@@ -41,6 +41,11 @@
<div class="card tables red text-white" data-id="<%= table.id %>"> <div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if table.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -62,6 +67,11 @@
<div class="card rooms red text-white" data-id="<%= room.id %>"> <div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if room.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -97,11 +107,12 @@
<div class="col-lg-5 col-md-5 col-sm-5"> <div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" > <div class="card" >
<div class="card-header"> <div class="card-header">
<% if @status == "order" %> <% if @status == 'order' %>
<div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div> <div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div>
<% else %> <% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong></div> <div><strong id="order-title">INVOICE DETAILS </strong></div>
<% end %> <% end %>
</div> </div>
<div class="card-block"> <div class="card-block">
<div class="card-title row"> <div class="card-title row">
@@ -113,12 +124,13 @@
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @obj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @obj.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p> <p class="hidden customer-id"><%= @customer.customer_id %></p>
<p>Customer : <%= @customer.name %></p>
</div> </div>
</div> </div>
@@ -178,7 +190,7 @@
</tr> </tr>
<tr> <tr>
<td class="charges-name"><strong>Discount:</strong></td> <td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td> <td class="item-attr"><strong id="order-discount">(<%=@obj.total_discount rescue 0%>)</strong></td>
</tr> </tr>
<% if @status == "sale" %> <% if @status == "sale" %>
<tr> <tr>
@@ -244,24 +256,36 @@
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".tables").on('click', function(){ $(".tables").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id; window.location.href = '/origami/table/' + dining_id;
}) })
$(".sales").on('click',function(){ $(".sales").on('click',function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var sale_id = $(this).attr("data-id"); var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id; window.location.href = '/origami/sale/' + sale_id;
}) })
$(".rooms").on('click', function(){ $(".rooms").on('click', function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id; window.location.href = '/origami/room/' + dining_id;
}) })
$(".orders").on('click',function(){ $(".orders").on('click',function(){
var customer_id=$(".customer-id").text();
show_customer_details(customer_id);
var order_id = $(this).attr("data-id"); var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id; window.location.href = '/origami/order/' + order_id;
}) })
// bind customer to order or sale // bind customer to order or sale
$("#customer").on('click', function(){ $("#customer").on('click', function(){
var sale = $('#sale_id').val(); var sale = $('#sale_id').val();
if (sale) { if (sale) {
var sale_id = sale var sale_id = sale
@@ -321,4 +345,40 @@ $('#move').on('click',function(){
$('#back').on('click',function(){ $('#back').on('click',function(){
window.location.href = '/origami/'; window.location.href = '/origami/';
}) })
//show cusotmer rebate amount
function show_customer_details(customer_id){
var url = '<%= @show_customer_details_path %>'
//Start Ajax
$.ajax({
type: "GET",
url: url,
data: {},
dataType: "json",
success: function(data) {
$("#customer_name").text(data["customer"].name);
if (data["response_data"]["data"].length) {
$.each(data["response_data"]["data"], function (i) {
if(data["response_data"]["data"][i]["accountable_type"] == "RebateAccount"){
var balance = data["response_data"]["data"][i]["balance"];
if (data["response_data"]["status"]==true) {
$('.rebate_amount').removeClass('hide');
row =
'<td class="charges-name">' + "Rebate Balance" +'</td>'
+'<td class="item-attr">' + balance + '</td>';
$(".rebate_amount").html(row);
}
}
});
}else{
$('.rebate_amount').addClass('hide');
}
}
});
//End Ajax
}
</script> </script>

View File

@@ -0,0 +1,120 @@
<div class="row">
<!-- Column Two -->
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<%= @saleobj.receipt_no rescue '' %>
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @saleobj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="card-text">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th style="item-attr-edit">QTY</td>
<th class="item-attr-edit">Price</td>
<th class='item-attr'> Action </th>
</tr>
</thead>
<tbody>
<%
count = 0
sub_total = 0
@saleobj.sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @saleobj.sale_id %>">
<%
# Can't check for discount
unless sale_item.price == 0
%>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr-edit'><input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" /></td>
<td class='item-attr-edit'><input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" /></td>
<td class='item-attr'><button data-id ="<%= sale_item.id %>" class='btn btn-primary btn-sm update'>Update</button>
<button data-id ="<%= sale_item.id %>" class='btn btn-danger btn-sm void'>Void</button></td></td>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%= @saleobj.total_discount rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @saleobj.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @saleobj.grand_total rescue 0%></strong></td>
</tr>
<tr class="rebate_amount"></tr>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" id='back' >Back</button>
</div>
</div>
<script>
// Bill Request
$(document).ready(function(){
$(".update").on('click',function() {
var sale_item_id = $(this).attr('data-id');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "POST",
url: ajax_url,
data: 'order_id='+ order_id,
success:function(result){
location.reload();
}
});
});
$('.void').on('click',function(){
var sale_item_id = $(this).attr('data-id');
})
})
$('#back').on('click',function(){
var table_id = '<%= @table_id %>'
window.location.href = '/origami/table/'+ table_id;
})
</script>

View File

@@ -41,6 +41,11 @@
<div class="card tables red text-white" data-id="<%= table.id %>"> <div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
<% if table.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -62,6 +67,11 @@
<div class="card rooms red text-white" data-id="<%= room.id %>"> <div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
<% if room.get_booking.nil? %>
<span style="font-size:12px;float:right;line-height:inherit;"> billed</span>
<% else %>
<span style="font-size:12px;float:right;line-height:inherit;"> new</span>
<% end %>
</div> </div>
</div> </div>
<% else %> <% else %>
@@ -107,7 +117,7 @@
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @sale.created_at.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">

View File

@@ -22,7 +22,7 @@
<tbody> <tbody>
<% @employees.each do |employee| %> <% @employees.each do |employee| %>
<tr> <tr>
<td><%= link_to employee.name, employee[:setting] %></td> <td><%= link_to employee.name,settings_employee_path(employee) %></td>
<td><%= employee.role %></td> <td><%= employee.role %></td>
<td> <td>
<%= link_to 'Edit', edit_settings_employee_path(employee) %> | <%= link_to 'Destroy', employee[:setting], method: :delete, data: { confirm: 'Are you sure?' } %></td> <%= link_to 'Edit', edit_settings_employee_path(employee) %> | <%= link_to 'Destroy', employee[:setting], method: :delete, data: { confirm: 'Are you sure?' } %></td>

View File

@@ -9,3 +9,8 @@
<strong>Role:</strong> <strong>Role:</strong>
<%= @employee.role %> <%= @employee.role %>
</p> </p>
<p>
<strong>Employee ID:</strong>
<%= @employee.emp_id %>
</p>

View File

@@ -110,14 +110,14 @@
<tr><td colspan="5">&nbsp;<td></tr> <tr><td colspan="5">&nbsp;<td></tr>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Pay Amount</td> <td>Total Pay Amount</td>
<td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td> <td colspan="2"><%= number_with_precision(@sale.amount_received, :precision => 2, :delimiter => ',') rescue ' '%></td>
</tr> </tr>
<% @sale_receivables.each do |r|%> <% @sale_receivables.each do |r|%>
<tr> <tr>
<td colspan=2 style="text-align:center"></td> <td colspan=2 style="text-align:center"></td>
<td>Payment <%= r.payment_method rescue ' '%></td> <td> <%= r.payment_method.capitalize rescue ' '%> Payment</td>
<td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%> <td colspan="2"><%= number_with_precision(r.payment_amount, :precision => 2, :delimiter => ',') rescue ' '%>
</td> </td>
</tr> </tr>

View File

@@ -76,7 +76,7 @@ Rails.application.routes.draw do
resources :customers #add customer type resources :customers #add customer type
end end
post 'moving' => "movetable#moving" post 'moving' => "movetable#moving"
get "/table/:table_id/sale/:sale_id/edit" => "sale_edit#edit"
get 'table/:dining_id/movetable' => "movetable#move_dining" get 'table/:dining_id/movetable' => "movetable#move_dining"
get 'table/:dining_id/moveroom' => "moveroom#move_dining" get 'table/:dining_id/moveroom' => "moveroom#move_dining"
get 'sale/:sale_id' => 'sales#show' get 'sale/:sale_id' => 'sales#show'
@@ -112,7 +112,7 @@ Rails.application.routes.draw do
#---------Add Customer --------------# #---------Add Customer --------------#
#resources :customers #resources :customers
get '/:sale_id/customers', to: "customers#add_customer" get '/:sale_id/customers', to: "customers#add_customer"
get '/:customer_id/get_customer' => 'home#get_customer' get '/:customer_id/get_customer' => 'home#get_customer',:as => "show_customer_details"
post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table post '/:sale_id/update_sale' , to: "customers#update_sale_by_customer"#update customer id in sale table
end end

View File

@@ -6,7 +6,8 @@ class CreateDiningQueues < ActiveRecord::Migration[5.1]
t.string :queue_no t.string :queue_no
t.string :status t.string :status
t.references :dining_facility, foreign_key: true t.references :dining_facility, foreign_key: true
t.integer :seater
t.string :remark
t.timestamps t.timestamps
end end
end end