update pull split bill

This commit is contained in:
Aung Myo
2018-02-09 14:31:34 +06:30
78 changed files with 1292 additions and 106 deletions

View File

@@ -53,7 +53,7 @@ GEM
bcrypt (3.1.11)
bindex (0.5.0)
builder (3.2.3)
byebug (9.1.0)
byebug (10.0.0)
cancancan (1.17.0)
capistrano (3.10.1)
airbrussh (>= 1.0.0)
@@ -66,7 +66,7 @@ GEM
capistrano-rails (1.3.1)
capistrano (~> 3.1)
capistrano-bundler (~> 1.1)
carrierwave (1.2.1)
carrierwave (1.2.2)
activemodel (>= 4.0.0)
activesupport (>= 4.0.0)
mime-types (>= 1.16)
@@ -81,7 +81,7 @@ GEM
coffee-script-source (1.12.2)
concurrent-ruby (1.0.5)
connection_pool (2.2.1)
crass (1.0.2)
crass (1.0.3)
cups (0.1.10)
database_cleaner (1.6.2)
diff-lcs (1.3)
@@ -92,17 +92,17 @@ GEM
factory_girl_rails (4.9.0)
factory_girl (~> 4.9.0)
railties (>= 3.0.0)
faker (1.8.4)
i18n (~> 0.5)
faker (1.8.7)
i18n (>= 0.7)
ffi (1.9.18)
filterrific (2.1.2)
font-awesome-rails (4.7.0.2)
filterrific (5.0.1)
font-awesome-rails (4.7.0.3)
railties (>= 3.2, < 5.2)
globalid (0.4.1)
activesupport (>= 4.2.0)
httparty (0.15.6)
multi_xml (>= 0.5.2)
i18n (0.9.1)
i18n (0.9.3)
concurrent-ruby (~> 1.0)
jbuilder (2.7.0)
activesupport (>= 4.2.0)
@@ -142,32 +142,32 @@ GEM
mini_magick (4.8.0)
mini_mime (1.0.0)
mini_portile2 (2.3.0)
minitest (5.10.3)
minitest (5.11.3)
momentjs-rails (2.17.1)
railties (>= 3.1)
multi_json (1.12.2)
multi_json (1.13.1)
multi_xml (0.6.0)
mysql2 (0.4.9)
mysql2 (0.4.10)
nested_form (0.3.2)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (4.2.0)
nio4r (2.1.0)
nokogiri (1.8.1)
nio4r (2.2.0)
nokogiri (1.8.2)
mini_portile2 (~> 2.3.0)
pdf-core (0.7.0)
pg (0.21.0)
pg (1.0.0)
prawn (2.2.2)
pdf-core (~> 0.7.0)
ttfunk (~> 1.5)
prawn-table (0.2.2)
prawn (>= 1.3.0, < 3.0.0)
puma (3.10.0)
rack (2.0.3)
puma (3.11.2)
rack (2.0.4)
rack-cors (1.0.2)
rack-protection (2.0.0)
rack
rack-test (0.7.0)
rack-test (0.8.2)
rack (>= 1.0, < 3)
rails (5.1.4)
actioncable (= 5.1.4)
@@ -192,12 +192,12 @@ GEM
method_source
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rake (12.2.1)
rake (12.3.0)
rb-fsevent (0.10.2)
rb-inotify (0.9.10)
ffi (>= 0.5.0, < 2)
redis (3.3.5)
rspec-core (3.7.0)
rspec-core (3.7.1)
rspec-support (~> 3.7.0)
rspec-expectations (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
@@ -205,7 +205,7 @@ GEM
rspec-mocks (3.7.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.7.0)
rspec-rails (3.7.1)
rspec-rails (3.7.2)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
@@ -213,14 +213,14 @@ GEM
rspec-expectations (~> 3.7.0)
rspec-mocks (~> 3.7.0)
rspec-support (~> 3.7.0)
rspec-support (3.7.0)
rspec-support (3.7.1)
ruby-ole (1.2.12.1)
sass (3.5.3)
sass (3.5.5)
sass-listen (~> 4.0.0)
sass-listen (4.0.0)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
sass-rails (5.0.6)
sass-rails (5.0.7)
railties (>= 4.0.0, < 6)
sass (~> 3.1)
sprockets (>= 2.8, < 4.0)
@@ -238,7 +238,7 @@ GEM
simple_form (3.5.0)
actionpack (> 4, < 5.2)
activemodel (> 4, < 5.2)
spreadsheet (1.1.4)
spreadsheet (1.1.5)
ruby-ole (>= 1.0)
spring (2.0.2)
activesupport (>= 4.2)
@@ -263,12 +263,12 @@ GEM
to_xls-rails (1.3.1)
spreadsheet (>= 0.8.5)
ttfunk (1.5.1)
turbolinks (5.0.1)
turbolinks-source (~> 5)
turbolinks-source (5.0.3)
turbolinks (5.1.0)
turbolinks-source (~> 5.1)
turbolinks-source (5.1.0)
tzinfo (1.2.4)
thread_safe (~> 0.1)
uglifier (3.2.0)
uglifier (4.1.5)
execjs (>= 0.3.0, < 3)
web-console (3.5.1)
actionview (>= 5.0)
@@ -277,8 +277,8 @@ GEM
railties (>= 5.0)
websocket-driver (0.6.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.2)
whenever (0.9.7)
websocket-extensions (0.1.3)
whenever (0.10.0)
chronic (>= 0.6.3)
PLATFORMS

View File

@@ -103,6 +103,9 @@ Change type in mysql
=> ALTER TABLE [table_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for table
=> ALTER DATABASE [database_name] CONVERT TO CHARACTER SET utf8 COLLATE utf8_unicode_ci #for database
For split bill
1) settings/lookups => { type:split_bill, name:SplitBill, value:1 }
###please open
sudo cat /etc/sudoers
### cope and parse

View File

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

View File

@@ -134,7 +134,7 @@ select.form-control {
}
.credit-color{
background-color:#FF5722;
background-color:#FFA500;
}
.other-payment-color{
@@ -390,3 +390,9 @@ i.logout_icon{
}
/* End Notify */
/* selected color for split bills */
.selected-split-item {
color: #fff !important;
background-color: #5DADE2 !important;
}

View File

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

View File

@@ -68,6 +68,15 @@
background-color: #ccc;
}
/*Shop Info color in navbar*/
.shopinfo {
color: #212529;
}
.link-buttoon {
text-decoration: none;
}
@media (min-width: 768px){
.dropdown-menu {
padding: .3rem 0;

View File

@@ -5,7 +5,7 @@ class Api::BillController < Api::ApiController
def create
@status = false
@error_message = "Order ID or Booking ID is require to request for a bill."
byebug
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
#create Bill by Booking ID
table = 0

View File

@@ -6,7 +6,7 @@ class ApplicationController < ActionController::Base
# lookup domain for db from provision
before_action :lookup_domain, :set_locale
helper_method :current_company,:current_login_employee,:current_user
helper_method :current_company,:current_login_employee,:current_user,:shop_detail
# alias_method :current_user, :current_login_employee,:current_user
#this is base api base controller to need to inherit.
#all token authentication must be done here
@@ -101,6 +101,10 @@ class ApplicationController < ActionController::Base
end
def shop_detail
@shop = Shop.first
end
def current_login_employee
if (!session[:session_token].nil?)
@employee = Employee.find_by_token_session(session[:session_token])

View File

@@ -19,4 +19,9 @@ class BaseOrigamiController < ActionController::Base
# def checkin_process
# CheckinJob.set(wait: 1.minute).perform_later()
# end
# Get current Cashier
def get_cashier
@cashier = Employee.where("role = 'cashier' AND token_session <> ''")
end
end

View File

@@ -14,5 +14,10 @@ class Crm::BookingsController < BaseCrmController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -398,4 +398,10 @@ end
params.require(:customer).permit(:id, :name, :company, :contact_no, :email,
:date_of_birth,:salutation,:gender,:nrc_no,:address,:card_no, :paypar_account_no, :customer_type)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -142,4 +142,10 @@ class Crm::DiningQueuesController < BaseCrmController
def dining_queue_params
params.require(:dining_queue).permit(:customer_id, :name, :contact_no, :queue_no,:status,:seater,:remark)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -55,6 +55,11 @@ class Crm::HomeController < BaseCrmController
# end
# end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -30,6 +30,12 @@ class Oqs::HomeController < BaseOqsController
@queue_stations_items
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
# Get Order items
def get_order_items
items = []
@@ -123,4 +129,9 @@ class Oqs::HomeController < BaseOqsController
# completed_order = AssignedOrderItem.group(:order_id).where('delivery_status=true');
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -50,4 +50,10 @@ class Oqs::EditController < BaseOqsController
order_queue_printer.print_order_item(print_settings, oqs, order_item.order_id, order_items_id, print_status=" (Cancelled)", before_updated_qty )
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -224,7 +224,12 @@ class Oqs::HomeController < BaseOqsController
.where("aoi.delivery_status = #{status} AND aoi.created_at >= '#{Time.now.beginning_of_day.utc}' ")
query = query.where("df.name LIKE ? OR odt.order_id LIKE ? OR odt.item_name LIKE ? OR cus.name = '#{filter}'","%#{filter}%","%#{filter}%","%#{filter}%",)
.group("order_queue_stations.id")
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -101,4 +101,10 @@ class Oqs::PrintController < ApplicationController
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -185,4 +185,9 @@ class Origami::AddordersController < ApplicationController#BaseOrigamiController
# @dining = DiningFacility.find(params[:id])
# end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -95,4 +95,10 @@ class Origami::BankIntegrationController < ApplicationController #BaseOrigamiCon
end
render json: response
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -24,4 +24,9 @@ class Origami::CardPaymentsController < BaseOrigamiController
def create
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -14,4 +14,10 @@ class Origami::CashInsController < BaseOrigamiController
shift.cash_in = shift.cash_in + amount.to_i
shift.save
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -7,4 +7,10 @@ class Origami::CashMgmtController < ApplicationController
def create
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -12,4 +12,10 @@ class Origami::CashOutsController < BaseOrigamiController
shift.cash_out = shift.cash_out + amount.to_i
shift.save
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -35,4 +35,10 @@ class Origami::CheckInProcessController < BaseOrigamiController
format.json { render json: respond }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -47,4 +47,10 @@ class Origami::CreditPaymentsController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -132,5 +132,9 @@ class Origami::CustomersController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -290,5 +290,9 @@ class Origami::DiscountsController < BaseOrigamiController
# redirect_to origami_path(sale_id)
# end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -114,6 +114,12 @@ class Origami::HomeController < BaseOrigamiController
#for bank integration
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
#for split bill
lookup_spit_bill = Lookup.collection_of('split_bill')
@spit_bill = 0
if !lookup_spit_bill[0].nil?
@spit_bill = lookup_spit_bill[0][1]
end
end
private
@@ -122,4 +128,9 @@ def set_dining
@dining = DiningFacility.find(params[:dining_id])
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -81,4 +81,9 @@ class Origami::HomeController < ApplicationController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -168,4 +168,10 @@ class Origami::InDutiesController < BaseOrigamiController
def in_duty_params
params.require(:in_duty).permit(:id, :dinning_id, :commissioner_ids, :in_time, :out_time)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -58,4 +58,9 @@ class Origami::JcbController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -57,4 +57,9 @@ class Origami::MasterController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -36,4 +36,10 @@ class Origami::MoveroomController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -70,4 +70,10 @@ class Origami::MovetableController < BaseOrigamiController
@get_type = Booking.update_dining_facility(booking_array,change_to,change_from)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -57,4 +57,9 @@ class Origami::MpuController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -39,4 +39,10 @@ class Origami::OrdersController < BaseOrigamiController
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -58,4 +58,10 @@ class Origami::OtherChargesController < BaseOrigamiController
dining = {:table_id => table_id, :table_type => table.type }
render :json => dining.to_json
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -37,4 +37,9 @@ class Origami::OthersPaymentsController < BaseOrigamiController
def create
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -376,4 +376,10 @@ class Origami::PaymentsController < BaseOrigamiController
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -28,4 +28,10 @@ class Origami::PayparPaymentsController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -136,4 +136,10 @@ class Origami::ProductCommissionsController < BaseOrigamiController
def product_commission_params
params.fetch(:product_commission, {})
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -68,4 +68,10 @@ class Origami::RedeemPaymentsController < BaseOrigamiController
end
@out = false, 0
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -55,4 +55,10 @@ class Origami::RequestBillsController < ApplicationController
# printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, item_price_by_accounts,member_info,shop_details)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -37,4 +37,9 @@ class Origami::RoomInvoicesController < BaseOrigamiController
@customer = @sale.customer
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -117,7 +117,17 @@ class Origami::RoomsController < BaseOrigamiController
# end
# end
# end
lookup_spit_bill = Lookup.collection_of('split_bill')
@spit_bill = 0
if !lookup_spit_bill[0].nil?
@spit_bill = lookup_spit_bill[0][1]
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -161,4 +161,10 @@ class Origami::SaleEditController < BaseOrigamiController
ProductCommission.remove_product_commission(item)
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -51,5 +51,9 @@ class Origami::SalesController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -108,4 +108,9 @@ class Origami::ShiftsController < BaseOrigamiController
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -0,0 +1,215 @@
class Origami::SplitBillController < BaseOrigamiController
authorize_resource :class => false
def index
dining_id = params[:dining_id]
@table = DiningFacility.find(dining_id)
@booking = @table.get_booking
@orders = Array.new
@order_items = Array.new
@sale_data = Array.new
table_bookings = Booking.where("dining_facility_id = #{dining_id} and sale_id IS NOT NULL")
if !table_bookings.nil?
table_bookings.each do |table_booking|
@sale_data.push(table_booking.sale)
end
end
if @booking
@booking.booking_orders.each do |booking_order|
@order = Order.find(booking_order.order_id)
if (@order.status == "new")
@orders.push(@order)
@order.order_items.each do |item|
if !item.set_menu_items.nil?
instance_item_sets = JSON.parse(item.set_menu_items)
arr_instance_item_sets = Array.new
instance_item_sets.each do |instance_item|
item_instance_name = MenuItemInstance.find_by_item_instance_code(instance_item["item_instance_code"]).item_instance_name
arr_instance_item_sets.push(item_instance_name)
end
item.set_menu_items = arr_instance_item_sets
end
@order_items.push(item)
end
end
end
else
@booking = nil
end
end
def create
order_ids = params[:order_ids]
orders = nil
if !params[:orders].empty?
orders = JSON.parse(params[:orders])
end
order_items = nil
if !params[:order_items].empty?
order_items = JSON.parse(params[:order_items])
end
status = false
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
#create Bill by Booking ID
table = 0
if !params[:booking_id].empty?
booking = Booking.find(params[:booking_id])
# for Multiple Cashier by Zone
table = DiningFacility.find(booking.dining_facility_id)
cashier_zone = CashierTerminalByZone.find_by_zone_id(table.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
get_cashier_by_terminal = Employee.find(shift_by_terminal.employee_id)
if booking
if booking.sale_id.nil?
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(params[:booking_id], current_user, get_cashier_by_terminal)
sale_data = Sale.find_by_sale_id(sale_id)
else
status = true
sale_id = booking.sale_id
sale_data = Sale.find_by_sale_id(sale_id)
end
end
else
if params[:type] == "Table"
type = "TableBooking"
else
type = "RoomBooking"
end
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_at => Time.now.utc, :checkin_by => current_user.name,
:booking_status => "assign" })
if !orders.nil?
orders.each do |order|
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order["id"]})
end
elsif !order_items.nil?
order_item_count = 0
order_id_count = 0
order_id = nil
order_items.each do |order_item|
order_item_count = 0
order = Order.find(order_item["order_id"])
if order.order_items.count == 1
order_id = order.id
order_id_count += 1
else
order_item_count += 1
end
end
if !order_id.nil?
if order_id_count > 1
updated_order_id = Array.new
order_ids.each do |odr_id|
odr = Order.find(odr_id)
if odr.order_items.count > 1
updated_order_id.push(odr_id)
end
end
if !updated_order_id.empty?
order_ids.each do |odr_id|
unless updated_order_id.include?(odr_id)
BookingOrder.find_by_order_id(odr_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
end
end
order_items.each do |order_item|
if updated_order_id.include?(order_item["order_id"])
orderItem = OrderItem.find(order_item["id"])
orderItem.order_id = order_id
orderItem.save!
end
end
else
order_ids.each do |odr_id|
BookingOrder.find_by_order_id(odr_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
end
end
else
BookingOrder.find_by_order_id(order_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
order_items.each do |order_item|
orderItem = OrderItem.find(order_item["id"])
orderItem.order_id = order_id
orderItem.save!
end
end
else
if order_ids.count == 1 && order_item_count == 1
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
else
customer = Customer.find(params[:customer_id])
order_type = "dine_in"
if !customer.nil?
if customer.customer_type == "Takeaway"
order_type = "takeaway"
elsif customer.customer_type == "Delivery"
order_type = "delivery"
end
end
# begin
order = Order.new
order.source = "cashier"
order.order_type = order_type
order.customer_id = params[:customer_id] == ""? "CUS-000000000001" : params[:customer_id] # for no customer id from mobile
order.item_count = order_items.count
order.status = "new"
order.table_id = params[:dining_id] # this is dining facilities's id
order.waiters = current_user.name
order.employee_name = current_user.name
order.guest_info = nil
order.save!
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
order_items.each do |order_item|
orderItem = OrderItem.find(order_item["id"])
orderItem.order_id = order.order_id
orderItem.save!
end
end
end
end
sale = Sale.new
status, sale_id = sale.generate_invoice_from_booking(booking.booking_id, current_user, get_cashier_by_terminal)
sale_data = Sale.find_by_sale_id(sale_id)
end
# Bind shift sale id to sale
sale_data.shift_sale_id = shift_by_terminal.id
sale_data.save
Promotion.promo_activate(sale)
BillBroadcastJob.perform_later(table)
render :json => { status: status }
else
render :json => { status: false, error_message: 'No Current Open Shift!'}
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -44,4 +44,10 @@ class Origami::SurveysController < BaseOrigamiController
def survey_params
params.require(:survey).permit(:child, :adult,:male,:female,:local,:foreigner, :dining_name,:receipt_no,:shift_id,:created_by,:total_customer,:total_amount)
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -61,4 +61,9 @@ class Origami::TableInvoicesController < BaseOrigamiController
@customer = @sale.customer
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -56,4 +56,10 @@ class Origami::UnionpayController < BaseOrigamiController
@status, @sale = sale_payment.process_payment(saleObj, @user, cash, "unionpay")
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -57,4 +57,9 @@ class Origami::VisaController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -112,4 +112,10 @@ class Origami::VoidController < BaseOrigamiController
end
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -78,4 +78,9 @@ class Origami::VoucherController < BaseOrigamiController
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -16,4 +16,10 @@ class Reports::SaleitemController < BaseReportController
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -49,5 +49,11 @@ class Reports::CommissionController < BaseReportController
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -59,4 +59,10 @@ authorize_resource :class => false
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -19,4 +19,10 @@ class Reports::DailysaleController < BaseReportController
def show
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -61,4 +61,10 @@ class Reports::PaymentMethodController < BaseReportController
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -61,4 +61,10 @@ authorize_resource :class => false
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -76,5 +76,10 @@ class Reports::SaleitemController < BaseReportController
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -47,5 +47,11 @@ class Reports::ShiftsaleController < BaseReportController
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -46,5 +46,11 @@ class Reports::StockCheckController < BaseReportController
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -58,4 +58,10 @@ authorize_resource :class => false
format.json { render json: out }
end
end
#Shop Name in Navbor
helper_method :shop_detail
def shop_detail
@shop = Shop.first
end
end

View File

@@ -0,0 +1,2 @@
module Origami::SplitBillHelper
end

View File

@@ -102,7 +102,9 @@ class Ability
can :menage, Booking
can :manage, OrderQueueStation
can :read, Sale
can :update, Sale
can :update, Sale
can :manage, Customer
can :get_customer, Customer
can :add_customer, Customer
can :update_sale_by_customer, Customer
@@ -126,12 +128,14 @@ class Ability
can :move_dining, :moveroom
can :manage, DiningQueue
can :manage, Commission
can :manage, Commissioner
can :manage, Promotion
can :manage, Product
#ability for split_bill
can :index, :split_bill
can :create, :split_bill
elsif user.role == "account"

View File

@@ -25,6 +25,13 @@
</a>
</div>
<!-- Start Shop Info -->
<div class="navbar-right">
<div class="col-lg-12 col-md-12 col-sm-12 navbar-brand">
<span class="navbar-brand-txt"><%= shop_detail.name %></span>
</div>
</div>
<!-- End Shop Info -->
<!-- Start Delete confirrm text !-->
<div class="navbar-right">
<a href="javascript:void(0);" class="dropdown-toggle waves-block" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true">
@@ -33,12 +40,26 @@
<% end %>
</a>
<ul class="dropdown-menu">
<%if current_login_employee.role =="administrator" %>
<li>
<p class="waves-effect waves-block p-l-30 m-b-5">
<a href="<%= settings_shops_path %>" style="text-decoration: none;">
<i class="material-icons font-7 logout_icon shopinfo">info</i>
<span class="font-15 shopinfo" >Shop Info</span>
</a>
</p>
</li>
<% end %>
<li>
<!-- <%if current_login_employee.role !="waiter" %> -->
<!-- <%end%> -->
<p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<!-- <p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-10 logout_icon">exit_to_app</i>
<span class="font-18">Logout</span>
</p> -->
<p class="delete waves-effect waves-block p-l-30 m-b-5" data-ref="<%=logout_path%>" data-method="delete">
<i class="material-icons font-7 logout_icon">exit_to_app</i>
<span class="font-15">Logout</span>
</p>
<span class="hidden" id="delete_text">
<h6>Are you sure you want to Logout ?</h6>

View File

@@ -51,22 +51,24 @@
</a>
</li>
<% end %>
<% if can? :menage, Customer %>
<li>
<a href="javascript:void(0);" class="menu-toggle">
<i class="material-icons">widgets</i>
<span><%= t :crm %></span>
</a>
<ul class="ml-menu">
<li>
<a href="<%= crm_customers_path %>"><%= t :customer %></a>
</li>
<li>
<a href="<%= crm_dining_queues_path %>"><%= t :queue %></a>
</li>
<% if can? :menage, Customer %>
<li>
<a href="<%= crm_customers_path %>"><%= t :customer %></a>
</li>
<% end %>
<% if can? :menage, DiningQueue %>
<li>
<a href="<%= crm_dining_queues_path %>"><%= t :queue %></a>
</li>
<% end %>
</ul>
</li>
<% end %>
<% if can? :menage, Inventory %>
<!-- <li>
<a href="<%= inventory_path %>">

View File

@@ -58,7 +58,7 @@
<!-- #END# Page Loader -->
<div class="container">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12 col-xs-12 text-center">
<div class="col-lg-12_ col-md-12 col-sm-12 col-xs-12 text-center">
<img src="/image/SX-logo.png" width="150px" height="150px">
<p>
<small>Version - 1.0.1</small>

View File

@@ -239,10 +239,25 @@ $('#cash_out').on('click',function(){
window.location.href = '/origami/cash_outs/new';
})
$('#close_cashier').on('click',function(){
window.location.href = '/origami/shift/close';
$('#close_cashier').on('click',function(e){
e.preventDefault(); // Prevent the href from redirecting directly
var linkURL = '/origami/shift/close';
warnBeforeRedirect(linkURL);
})
$('#back').on('click',function(){
window.location.href = '/origami/dashboard';
})
function warnBeforeRedirect(linkURL) {
swal({
title: "Oops",
text: "Are you sure you want to Logout ?",
type: "warning",
showCancelButton: true
}, function() {
// Redirect the user
window.location.href = linkURL;
});
}
</script>

View File

@@ -136,7 +136,22 @@
<% @orders.each do |order| %>
<div class="card orders red text-white" data-id="<%= order.order_id %>">
<div class="card-block">
<%= order.order_id %>
<%
order_status = ""
sale_order = SaleOrder.find_by_order_id(order)
if sale_order
unless sale_order.sale_id.nil?
sale = Sale.find(sale_order.sale_id)
order_status = sale.sale_status
if order_status == 'new'
order_status = order.status
end
end
else
order_status = order.status
end
%>
<%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
</div>
</div>
<% end %>
@@ -372,6 +387,9 @@
%>
</table>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice</button>
<% if !@spit_bill.nil? && @spit_bill == '1' %>
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
<% end %>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -426,14 +444,13 @@
<!-- <button type="button" class="btn btn-block bg-blue waves-effect" disabled> Void</button> -->
<% end %>
<% if @status_sale == 'sale' %>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect">Customer</button>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
@@ -695,24 +712,47 @@
// Bill Request
$('#request_bills').click(function () {
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "GET",
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
location.reload();
}
var lookup_split_bill = '<%= @spit_bill %>';
if(lookup_split_bill == '1'){
swal({
title: "Information!",
text: "Do you want to Split bill?",
type: "success",
showCancelButton: true,
confirmButtonColor: "#009900",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/split_bills";
}else{
requestBillProcess();
}
});
});
}else{
requestBillProcess();
}
});
function requestBillProcess(){
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "GET",
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
location.reload();
}
}
});
}
$('#move').on('click', function () {
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/movetable";
@@ -723,8 +763,8 @@
})
$('#add_invoice').on('click', function () {
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var dining_id = "<%= @dining.id %>";
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
var ajax_url = "/origami/sale/append_order";
$.ajax({
type: "POST",
@@ -850,4 +890,22 @@
}
});
});
/* split bill in add to existing invoice*/
$('#split_bill').on('click', function(){
swal({
title: "Alert",
text: "Are you sure, you want to split bill?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if(isConfirm){
var dining_id = "<%= @dining.id %>";
window.location.href = '/origami/table/' + dining_id + "/split_bills";
}
});
});
</script>

View File

@@ -160,7 +160,6 @@
<!-- tabs - End -->
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >

View File

@@ -137,7 +137,22 @@
<% @orders.each do |order| %>
<div class="card orders red text-white" data-id = "<%= order.order_id %>">
<div class="card-block">
<%= order.order_id %>
<%
order_status = ""
sale_order = SaleOrder.find_by_order_id(order)
if sale_order
unless sale_order.sale_id.nil?
sale = Sale.find(sale_order.sale_id)
order_status = sale.sale_status
if order_status == 'new'
order_status = order.status
end
end
else
order_status = order.status
end
%>
<%= order.order_id %> <% if !order_status.empty? %>| <%= order_status %> <% end %>
</div>
</div>
<% end %>
@@ -349,7 +364,10 @@
end
%>
</table>
<button class='btn bg-blue' id='add_invoice'> Add to existing invoice </button>
<button class='btn bg-primary' id='add_invoice'> Add to existing invoice </button>
<% if !@spit_bill.nil? && @spit_bill == '1' %>
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
<% end %>
<% end %>
<% if @sale_array.size > 1 %>
<br><br>
@@ -696,34 +714,46 @@ $('#pay').on('click',function() {
});
// Bill Request
$('#request_bills').click(function() {
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
var lookup_split_bill = '<%= @spit_bill %>';
if(lookup_split_bill == '1'){
swal({
title: "Information!",
text: "Do you want to Split bill?",
type: "success",
showCancelButton: true,
confirmButtonColor: "#009900",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var dining_id = "<%= @room.id %>";
window.location.href = '/origami/room/' + dining_id + "/split_bills";
}else{
requestBillProcess();
}
});
}else{
requestBillProcess();
}
});
function requestBillProcess(){
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "GET",
url: ajax_url,
// data: 'order_id='+ order_id,
success:function(result){
if(!result.status){
$.confirm({
title: 'Information!',
content: result.error_message,
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami';
}
}
}
});
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
else {
location.reload();
}
}
});
});
}
});
}
$('#move').on('click',function(){
var dining_id = "<%= @room.id %>"
@@ -736,7 +766,7 @@ $('#back').on('click',function(){
$('#add_invoice').on('click',function(){
var dining_id = "<%= @room.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var sale_id = $("#sale_id").val(); //<%= @obj_sale.sale_id rescue "" %>
var ajax_url = "/origami/sale/append_order";
$.ajax({
type: "POST",
@@ -864,4 +894,22 @@ $('#add_invoice').on('click',function(){
var dining_id = "<%= @room.id %>"
window.location.href = '/origami/addorders/' + dining_id;
});
/* split bill in add to existing invoice*/
$('#split_bill').on('click', function(){
swal({
title: "Alert",
text: "Are you sure, you want to split bill?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if(isConfirm){
var dining_id = "<%= @room.id %>";
window.location.href = '/origami/table/' + dining_id + "/split_bills";
}
});
});
</script>

View File

@@ -0,0 +1,445 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class="row">
<!-- Column One -->
<div class="col-lg-7 col-md-7 col-sm-7">
<!-- Order Details -->
<div class="card" >
<div class="card-block">
<div class="card-title row">
<div class="col-lg-12 col-md-12 col-sm-12">
<span class="hidden" id ="table_id" value="<%=@table.id%>"><%=@table.id%></span>
<span class="hidden" id="table_type" value="<%=@table.type%>"><%=@table.type%></span>
<% if !@order.nil? %>
<span class="hidden" id="customer_id" value="<%= @order.customer_id %>"><%= @order.customer_id %></span>
<% end %>
<p class="m-l-15">Order Lists</p>
</div>
</div>
<div id="split-order-slimscroll" data-height="70">
<div class="card-text dining">
<% if !@orders.nil? %>
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="row m-l-5">
<div class="col-lg-3 col-md-3 col-sm-3">
<ul class="nav nav-tabs tabs-left sideways">
<% @orders.each.with_index(0) do |order, order_index| %>
<% active_class = "" %>
<% if order_index == 0 %>
<% active_class = "active" %>
<% end %>
<li class="order-row <%= active_class %>">
<a href="#<%= order.order_id %>" data-toggle="tab"><%= order.order_id %></a>
</li>
<% end %>
</ul>
</div>
<div class="col-lg-8 col-md-8 col-sm-8">
<div class="tab-content">
<% @orders.each.with_index(0) do |order, order_index| %>
<% active_class = "" %>
<% if order_index == 0 %>
<% active_class = "active" %>
<% end %>
<div class="tab-pane <%= active_class %>" id="<%= order.order_id %>">
<div class="card-title">
<p class="m-l-2">Order Items</p>
</div>
<div id="order-detail-slimscroll-<%= order.order_id %>" data-height="200">
<div class="card-text dining">
<table class="table table-default" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
<% if !order.order_items.nil? %>
<% sub_total = 0 %>
<% order.order_items.each do |order_item| %>
<%
sub_total += order_item.qty*order_item.price
%>
<tr class="item-row" id=<%= order_item.order_items_id %> >
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=order_item.order_id%></span>
<span id="item-account-type" class="hidden"><%=order_item.account_id%></span>
<span id="item-name-price">
<%=order_item.item_name%>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</span>
</td>
<td style="width:20%; text-align:right">
<span id="item-qty"><%=order_item.qty%></span>
</td>
<td style="width:20%; text-align:right">
<span id="item-total-price"><%=(order_item.qty*order_item.price)%></span>
</td>
</tr>
<%
end
%>
<% end %>
</tbody>
</table>
</div>
</div>
<!-- <div class="card-footer"> -->
<table class="table m-b-20" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr align-right"><strong id="order-sub-total"><%=sub_total%></strong></td>
</tr>
</table>
<!-- </div> -->
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<% end %>
</div>
</div>
</div>
</div>
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-4 col-md-4 col-sm-4">
<div class="card">
<div class="card-block">
<div class="card-title row">
<p class="m-l-15">Receipt Lists</p>
</div>
<div id="split-receipt-slimscroll" data-height="150">
<div class="card-text dining">
<% if !@sale_data.nil? %>
<table class="table table-default">
<tbody>
<% @sale_data.each do |sale_data| %>
<tr class="receipt_row" id=<%= sale_data.sale_id %> >
<td>Receipt No. - <span id="receipt_no"><%= sale_data.receipt_no %></span></td>
</tr>
<% end %>
</tbody>
</table>
<% end %>
</div>
</div>
<div class="card-footer"></div>
</div>
</div>
</div>
<!-- Column Two -->
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Action Panel -->
<div>
<button type="button" class="btn bg-default btn-block" id="back" ><i class="material-icons">reply</i> Back </button>
<button id="order_split" class="btn btn-primary text-center action-btn" style="width:100%">Orders Split</button>
<button id="order_item_split" class="btn btn-primary text-center action-btn">Order Items Split</button>
</div>
</div>
<!-- Column Three -->
</div>
</div>
<script type="text/javascript">
$(document).ready(function(){
$('#back').on('click',function(){
backToOrigami();
})
$(".cashier_number").on('click', function(event){
if(event.handled !== true) {
var original_value=0;
original_value = $('#per_person').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0"){
$('#per_person').val(input_value);
}
else{
$('#per_person').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#per_person').val(amount);
break;
case 'del' :
var discount_text=$('#per_person').val();
$('#per_person').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#per_person').val("0");
break;
}
event.handled = true;
} else {
return false;
}
});
// Select Sale Item
$('.item-row').on('click',function(){
if($(this).hasClass('selected-split-item') == true){
$(this).removeClass('selected-split-item');
}
else {
$(this).addClass('selected-split-item');
}
});
//order_item_split
$('#order_item_split').on('click',function () {
var cnt_order_item = "<%= @order_items.count %>";
var order_items = get_selected_order_items();// Selected Order Items
var cnt_items = parseInt(cnt_order_item) - parseInt(order_items.length);
if (order_items.length > 0){
// if(cnt_items > 0){
swal({
title: "Alert",
text: "Are you sure, you want to Split?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if(isConfirm){
orderItemSplitBillProcess(cnt_items);
}
});
// }
// else{
// orderItemSplitBillProcess(cnt_items);
// }
}else{
swal("Opps","Please select at least one item!","warning");
}
});
// Selected Order
$('.order-row').on('click',function(){
if($(this).hasClass('selected-split-item') == true){
$(this).removeClass('selected-split-item');
}
else {
$(this).addClass('selected-split-item');
}
});
//order_item_split
$('#order_split').on('click',function () {
var cnt_orders = "<%= @orders.count %>";
var orders = get_selected_orders();// Selected Order Items
var cnt_odrs = parseInt(cnt_orders) - parseInt(orders.length);
if (orders.length > 0){
// if(cnt_odrs > 0){
swal({
title: "Alert",
text: "Are you sure, you want to Split?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, split it!",
closeOnConfirm: false
}, function (isConfirm) {
if(isConfirm){
orderSplitBillProcess(cnt_odrs);
}
});
// }
// else{
// orderSplitBillProcess(cnt_odrs);
// }
}else{
swal("Opps","Please select at least one order!","warning");
}
});
//selected receipt row click
$('.receipt_row').on('click',function(){
var dining_id = $("#table_id").text();
var sale_id = $(this).attr('id').substr(0,16);
window.location = '/origami/table/' + dining_id + "/table_invoice/" + sale_id;
});
//slimscroll for order, order items, reciept
var height = ($(window).height() - ($('.legal').outerHeight() + $('.user-info').outerHeight() + $('.navbar').innerHeight()));
$('#split-order-slimscroll').slimScroll({
height: height-$('#split-order-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0'
});
$('#split-receipt-slimscroll').slimScroll({
height: height-$('#split-receipt-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0'
});
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
if(orders.length > 0){
$.each(orders, function(key,order){
$('#order-detail-slimscroll-'+order.order_id).slimScroll({
height: height-$('#split-receipt-slimscroll').attr('data-height'),
size: '5px',
color: 'rgba(0,0,0,0.5)',
alwaysVisible: false,
borderRadius: '0',
railBorderRadius: '0'
});
});
}
});
/* function for order items split bill process */
function orderItemSplitBillProcess(cnt_items){
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
var customer_id = $("#customer_id").text();
var order_items = get_selected_order_items();// Selected Order Items
var json_booking = JSON.parse('<%= @booking.to_json.html_safe %>');
var booking_id = "";
if(cnt_items == 0){
booking_id = json_booking.booking_id;
}
var order_ids = [];
if(order_items!=undefined && order_items!=null){
$.each(order_items,function(key,value){
if($.inArray(value.order_id,order_ids) == -1){
order_ids.push(value.order_id);
}
});
}
var ajax_url = "/origami/split_bills";
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : order_ids, 'order_items' : JSON.stringify(order_items), 'orders' : ''},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
// if (cnt_items > 0){
window.location.reload();
// }else{
// backToOrigami();
// }
}
}
});
}
/* function for order items split bill process */
function orderSplitBillProcess(cnt_orders){
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
var customer_id = $("#customer_id").text();
var orders = get_selected_orders();// Selected Orders
var json_booking = JSON.parse('<%= @booking.to_json.html_safe %>');
var booking_id = "";
if(cnt_orders == 0){
booking_id = json_booking.booking_id;
}
var ajax_url = "/origami/split_bills";
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id' : dining_id, 'type': type, 'customer_id' : customer_id, 'booking_id' : booking_id, 'order_ids' : [], 'order_items' : '', 'orders' : JSON.stringify(orders)},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
// if (cnt_items > 0){
window.location.reload();
// }else{
// backToOrigami();
// }
}
}
});
}
/* back to origami */
function backToOrigami(){
var id = $("#table_id").text();
var type = $("#table_type").text();
if (type=="Table") {
window.location.href = '/origami/table/'+id
}else{
window.location.href = '/origami/room/'+id
}
}
/* Get Selected Order Items */
function get_selected_order_items(){
var order_items = [];
$('.item-row.selected-split-item').each(function(i){
var order_item = {};
order_item.id = $(this).attr('id').substr(0,16);
order_item.order_id = $(this).find('#item-order-id').text().trim();
order_item.name = $(this).find('#item-name-price').text().split('@')[0];
order_item.account_id = $(this).find('#item-account-type').text();
order_item.price = $(this).find('#item-total-price').text();
order_items.push(order_item);
});
return order_items;
}
/* Get Selected Orders */
function get_selected_orders(){
var orders = [];
$('.order-row.selected-split-item').each(function(i){
var order = {};
order.id = $(this).find('a').attr('href').substr(1);
orders.push(order);
});
return orders;
}
//check for isNumber
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
</script>

View File

@@ -230,8 +230,10 @@ scope "(:locale)", locale: /en|mm/ do
post "bank_integration/settle_trans", to: "bank_integration#settle_trans", as:"settle_trans"
post "bank_integration/sale_trans", to: "bank_integration#sale_trans", as:"sale_trans"
#split bill
get '/table/:dining_id/split_bills' => 'split_bill#index'
get '/room/:dining_id/split_bills' => 'split_bill#index'
post '/split_bills', to: 'split_bill#create', as:"order_item_split_bills"
end

View File

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

View File

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