equal split and order split in order tab'

This commit is contained in:
phyusin
2018-02-16 12:13:35 +06:30
parent e77d523a7f
commit 0ddaee7444
16 changed files with 481 additions and 85 deletions

View File

@@ -5,6 +5,16 @@ class Origami::OrdersController < BaseOrigamiController
@complete = Sale.where("DATE_FORMAT(created_at,'%Y-%m-%d') = ? and sale_status != 'new'",DateTime.now.strftime('%Y-%m-%d'))
@orders = Order.where("DATE_FORMAT(date,'%Y-%m-%d') = ? and status != 'billed'",DateTime.now.strftime('%Y-%m-%d')).order('date desc')
@order = Order.find(params[:order_id])
booking = Booking.select('bookings.booking_id, bookings.dining_facility_id')
.joins(" JOIN booking_orders as bo on bo.booking_id = bookings.booking_id")
.where("bo.order_id='#{params[:order_id]}'").first()
@booking = Array.new
if !booking.nil?
dining_facilities = DiningFacility.find_by_id(booking.dining_facility_id)
@booking.push({'booking_id' => booking.booking_id, 'dining_facility_id' => booking.dining_facility_id, 'type' => dining_facilities.type})
end
sale_order = SaleOrder.find_by_order_id(@order.order_id)
if sale_order
unless sale_order.sale_id.nil?
@@ -13,18 +23,16 @@ class Origami::OrdersController < BaseOrigamiController
end
end
@orders.each do |order|
order.order_items.each_with_index do |item, index|
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)
item.price = item.price.to_f + instance_item["price"].to_f
end
order.order_items[index].set_menu_items = arr_instance_item_sets
@order.order_items.each_with_index do |item, order_item_index|
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)
item.price = item.price.to_f + instance_item["price"].to_f
end
@order.order_items[order_item_index].set_menu_items = arr_instance_item_sets
end
end

View File

@@ -8,6 +8,7 @@ class Origami::PaymentsController < BaseOrigamiController
sale_data = Sale.find_by_sale_id(sale_id)
sale_items = SaleItem.where("sale_id=?",sale_id)
member_info = nil
survey = Survey.find_by_receipt_no(sale_data.receipt_no)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -60,7 +61,7 @@ class Origami::PaymentsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil)
printer.print_receipt_bill(print_settings,cashier_terminal,sale_items,sale_data,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info, shop_details, "Frt",current_balance,nil,survey)
end
end
@@ -72,6 +73,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
shop_details = Shop::ShopDetail
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
# rounding adjustment
if shop_details.is_rounding_adj
a = saleObj.grand_total % 25 # Modulus
@@ -139,7 +141,7 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Paid",current_balance,card_data,survey)
end
end
end
@@ -245,6 +247,7 @@ class Origami::PaymentsController < BaseOrigamiController
member_info = nil
saleObj = Sale.find(sale_id)
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
# For Cashier by Zone
bookings = Booking.where("sale_id='#{sale_id}'")
@@ -292,7 +295,7 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "Re-print",current_balance,card_data,survey)
end
end
@@ -306,6 +309,7 @@ class Origami::PaymentsController < BaseOrigamiController
if(Sale.exists?(sale_id))
saleObj = Sale.find(sale_id)
survey = Survey.find_by_receipt_no(saleObj.receipt_no)
if saleObj.discount_type == "member_discount"
saleObj.update_attributes(rounding_adjustment: 0)
@@ -344,7 +348,7 @@ class Origami::PaymentsController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(saleObj.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil)
printer.print_receipt_bill(print_settings,cashier_terminal,saleObj.sale_items,saleObj,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "FOC",nil,nil,survey)
end
end
end

View File

@@ -18,10 +18,10 @@ class Origami::SplitBillController < BaseOrigamiController
if @booking
@booking.booking_orders.each do |booking_order|
arr_order_items = Array.new
@order = Order.find(booking_order.order_id)
if (@order.status == "new")
@orders.push(@order)
@order_items.push({'all_order' => @order.order_items})
@order.order_items.each do |item|
if !item.set_menu_items.nil?
@@ -59,19 +59,19 @@ class Origami::SplitBillController < BaseOrigamiController
'updated_at' => item.updated_at}
i += 1
@order_items.push({@order.order_id => arr_item})
arr_order_items.push(arr_item)
end
else
arr_order_items.push(item)
@order_items.push({@order.order_id => item})
end
end
@order_items.push({'all_order' => arr_order_items})
end
end
else
@booking = nil
end
puts "@order_items"
puts @order_items.to_json
end
def create
@@ -160,19 +160,19 @@ class Origami::SplitBillController < BaseOrigamiController
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.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"])
update_order_item(order_item)
update_order_item(order_id, order_item)
end
end
else
order_ids.each do |odr_id|
BookingOrder.find_by_order_id(odr_id).delete
# BookingOrder.find_by_order_id(odr_id).delete
BookingOrder.create({:booking_id => booking.booking_id, :order_id => odr_id})
end
end
@@ -181,12 +181,15 @@ class Origami::SplitBillController < BaseOrigamiController
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_id})
order_items.each do |order_item|
update_order_item(order_item)
update_order_item(order_id, order_item)
end
end
else
if order_ids.count == 1 && order_id_count > 0 && order_item_count == 1
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order_ids[0]})
order_items.each do |order_item|
update_order_item(order_ids[0], order_item)
end
else
customer = Customer.find(params[:customer_id])
order_type = "dine_in"
@@ -214,7 +217,7 @@ class Origami::SplitBillController < BaseOrigamiController
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
order_items.each do |order_item|
update_order_item(order_item)
update_order_item(order.id, order_item)
end
end
end
@@ -239,7 +242,7 @@ class Origami::SplitBillController < BaseOrigamiController
end
end
def update_order_item(order_item)
def update_order_item(order_id, order_item)
orderItem = OrderItem.find(order_item["id"])
if orderItem.qty.to_f != order_item['qty'].to_f
OrderItem.processs_item(orderItem.item_code,
@@ -251,13 +254,13 @@ class Origami::SplitBillController < BaseOrigamiController
orderItem.price,
orderItem.options,
orderItem.set_menu_items,
orderItem.order_id,
order_id,
orderItem.item_order_by,
orderItem.taxable)
orderItem.qty = orderItem.qty.to_f - order_item['qty'].to_f
else
orderItem.order_id = order.order_id
orderItem.order_id = order_id
end
orderItem.save!
end

View File

@@ -31,6 +31,33 @@ class Origami::SurveysController < BaseOrigamiController
# end
end
def create_survey
if shift_by_terminal = ShiftSale.current_open_shift(get_cashier[0].id)
dining_facility = DiningFacility.find(params[:dining_id])
cashier_zone = CashierTerminalByZone.find_by_zone_id(dining_facility.zone_id)
shift_by_terminal = ShiftSale.find_by_cashier_terminal_id_and_shift_closed_at(cashier_zone.cashier_terminal_id,nil)
survey = Survey.find_by_receipt_no(params[:receipt_no])
if survey.nil?
survey = Survey.new
survey.dining_name = dining_facility.name
survey.receipt_no = params[:receipt_no]
survey.shift_id = shift_by_terminal.id
survey.created_by = current_user.name
survey.total_customer = params[:total_customer]
survey.total_amount = params[:total_amount]
survey.save!
else
survey.total_customer = params[:total_customer]
survey.save!
end
render :json => {status: true}
else
render :json => { status: false, error_message: 'No Current Open Shift!'}
end
end
private
# Never trust parameters from the scary internet, only allow the white list through.

View File

@@ -59,6 +59,12 @@ class Origami::TableInvoicesController < BaseOrigamiController
@date = @sale.created_at
@status_sale = 'sale'
@customer = @sale.customer
#for split bill
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?
@split_bill = lookup_spit_bill[0][1]
end
end
#Shop Name in Navbor

View File

@@ -6,6 +6,8 @@ class Origami::VoidController < BaseOrigamiController
if Sale.exists?(sale_id)
sale = Sale.find_by_sale_id(sale_id)
survey = Survey.find_by_receipt_no(sale.receipt_no)
if sale.discount_type == "member_discount"
sale.update_attributes(total_discount: 0)
sale.compute_by_sale_items(sale_id, sale.sale_items,0)
@@ -107,7 +109,7 @@ class Origami::VoidController < BaseOrigamiController
discount_price_by_accounts = SaleItem.get_discount_price_by_accounts(sale.sale_items)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil)
printer.print_receipt_bill(print_settings,cashier_terminal,sale.sale_items,sale,customer.name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details, "VOID",current_balance,nil,survey)
end
#end print

View File

@@ -173,19 +173,19 @@ class Printer::ReceiptPrinter < Printer::PrinterWorker
end
#Bill Receipt Print
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data)
def print_receipt_bill(printer_settings,cashier_terminal,sale_items,sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount=nil,shop_details, printed_status,balance,card_data,survey)
#Use CUPS service
#Generate PDF
#Print
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey)
receipt_bill_a5_pdf = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf
if !receipt_bill_a5_pdf.empty?
receipt_bill_a5_pdf.each do |receipt_bilA5|
if receipt_bilA5[0] == 'ReceiptBillA5Pdf'
if receipt_bilA5[1] == '1'
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
pdf = ReceiptBillA5Pdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey)
else
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data)
pdf = ReceiptBillPdf.new(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info,rebate_amount,shop_details,printed_status,balance,card_data,survey)
end
end
end

View File

@@ -1,7 +1,7 @@
class ReceiptBillA5Pdf < Prawn::Document
include ActionView::Helpers::NumberHelper
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, :description_width, :price_num_width
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance)
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,survey)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 15
@@ -65,6 +65,12 @@ class ReceiptBillA5Pdf < Prawn::Document
customer(customer_name)
#start card sale trans data
if card_data != nil
card_sale_data(card_data)
end
#end card sale trans data
if discount_price_by_accounts.length > 0 && shop_details.show_account_info
discount_account(discount_price_by_accounts,printer_settings.precision,delimiter)
end
@@ -73,6 +79,12 @@ class ReceiptBillA5Pdf < Prawn::Document
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !survey.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
@@ -459,6 +471,22 @@ class ReceiptBillA5Pdf < Prawn::Document
end
end
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "Individual amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"
@@ -513,6 +541,29 @@ class ReceiptBillA5Pdf < Prawn::Document
move_down 10
end
#start card sale trans data
def card_sale_data(card_data)
if card_data != nil && !card_data.empty?
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
card_data.each do |data|
if data['app'] == 'CUP'
data['app'] = 'UNIONPAY'
elsif data['app'] == 'MASTERCARD'
data['app'] = 'MASTER'
end
text "DATE/TIME: #{data['res_date']} #{data['res_time']} ", :size => @item_font_size, :align => :left
text "BATCH NUM: #{data['batch_no']} TRACE#: #{data['trace']}",:size => @item_font_size, :align => :left
text "RREF NUM: #{data['ref_no']} APPR CODE: #{data['app_code']} ",:size => @item_font_size, :align => :left
text "TID: #{data['tid']} ",:size => @item_font_size, :align => :left
text "#{data['app']} #{data['pan']} ",:size => @item_font_size, :align => :left
end
end
end
#check ReceiptBillAltName included
def show_alt_name
bill_alt_name = Lookup.collection_of("print_settings") #print_settings with name:ReceiptBillA5Pdf

View File

@@ -1,7 +1,7 @@
class ReceiptBillPdf < Prawn::Document
include ActionView::Helpers::NumberHelper
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, :description_width, :price_num_width
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data)
def initialize(printer_settings, sale_items, sale_data, customer_name, item_price_by_accounts, discount_price_by_accounts, member_info = nil,rebate_amount = nil,shop_details, printed_status,current_balance,card_data,survey)
self.page_width = printer_settings.page_width
self.page_height = printer_settings.page_height
self.margin = 0
@@ -79,6 +79,12 @@ class ReceiptBillPdf < Prawn::Document
items_account(item_price_by_accounts,printer_settings.precision,delimiter)
end
#start for individual payment
if !survey.nil?
individual_payment(sale_data, survey, printer_settings.precision, delimiter)
end
#end for individual payment
sign(sale_data)
footer(printed_status)
@@ -465,6 +471,22 @@ class ReceiptBillPdf < Prawn::Document
end
end
#individual payment per person
def individual_payment(sale_data, survey, precision, delimiter)
per_person = sale_data.grand_total.to_f / survey.total_customer.to_i
move_down 5
stroke_horizontal_rule
move_down 5
y_position = cursor
bounding_box([0,y_position], :width =>self.label_width) do
text "Individual amount", :size => self.item_font_size,:align => :left
end
bounding_box([self.label_width,y_position], :width =>self.item_description_width) do
text "#{number_with_precision(per_person, :precision => precision.to_i, :delimiter => delimiter)} per person", :size => self.item_font_size,:align => :right
end
end
def sign(sale_data)
SalePayment.where('sale_id = ?', sale_data.sale_id).each do |payment|
if payment.payment_method == "creditnote"

View File

@@ -386,9 +386,14 @@
end
%>
</table>
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
<% if !@spit_bill.nil? && @spit_bill == '1' %>
<button class='btn btn-primary btn-block waves-effect' id='split_bill'> Split Bill</button>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button class='btn btn-primary waves-effect' id='add_invoice'> Add to existing invoice</button>
<button class='btn btn-primary waves-effect' id='split_bill'> Split Bill</button>
<% else %>
<button class='btn btn-primary btn-block waves-effect' id='add_invoice'> Add to existing invoice</button>
<% end %>
<% end %>
<% end %>
<% if @sale_array.size > 1 %>
@@ -407,6 +412,11 @@
<button class='btn btn-sm btn-primary invoicedetails' id="<%= sale.sale_id %>">Show
Detail
</button>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button class='btn btn-sm btn-primary waves-effect' id='split_bill'> Split Bill</button>
<% end %>
<% end %>
</td>
</tr>
</table>

View File

@@ -240,7 +240,8 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn bg-default btn-block " id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn bg-default btn-block waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn bg-blue btn-block waves-effect" id='by_order'>By Order</button>
<% if @sale_status != 'completed' %>
<!-- <button type="button" class="btn bg-blue btn-block" id='move'>MOVE</button> -->
<% end %>
@@ -285,5 +286,59 @@
})
$('#move').on('click',function(){
})
});
//order_split
$('#by_order').on('click',function () {
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();
}
});
});
/* function for order items split bill process */
function orderSplitBillProcess(){
var booking = JSON.parse('<%= @booking.to_json.html_safe %>');
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
var order = JSON.parse('<%= @order.to_json.html_safe %>');
var arr_order = [];
arr_order.push({id : order.order_id});
var dining_id = booking[0].dining_facility_id || 0;
var type = booking[0].type || '';
var customer_id = order.customer_id || '';
var booking_id = "";
if(orders.length == 1){
booking_id = booking[0].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(arr_order)},
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else{
if(type=='Table'){
window.location.href = '/origami/table/' + dining_id;
}else{
window.location.href = '/origami/room/' + dining_id;
}
}
}
});
}
</script>

View File

@@ -365,7 +365,7 @@
%>
</table>
<button class='btn bg-primary' id='add_invoice'> Add to existing invoice </button>
<% if !@spit_bill.nil? && @spit_bill == '1' %>
<% if !@split_bill.nil? && @split_bill == '1' %>
<button class='btn btn-primary' id='split_bill'> Split Bill</button>
<% end %>
<% end %>

View File

@@ -20,18 +20,18 @@
</div>
<div id="split-order-slimscroll" data-height="70">
<div class="card-text dining">
<% if !@orders.nil? %>
<% if !@orders.empty? %>
<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">
<li class="order-row active">
<a href="#all_order" data-toggle="tab">All</a>
<a href="#all_order" data-toggle="tab"><strong>All</strong></a>
</li>
<% @orders.each.with_index(0) do |order, order_index| %>
<li class="order-row">
<a href="#<%= order.order_id %>" data-toggle="tab"><%= order.order_id %></a>
<a href="#<%= order.order_id %>" data-toggle="tab"><strong><%= order.order_id %></strong></a>
</li>
<% end %>
</ul>
@@ -188,13 +188,28 @@
</div>
<div id="split-receipt-slimscroll" data-height="150">
<div class="card-text dining">
<% if !@sale_data.nil? %>
<% if !@sale_data.empty? %>
<table class="table table-default">
<thead>
<th>#</th>
<th>Receipt No.</th>
<th>Total</th>
<th>Action</th>
</thead>
<tbody>
<% @sale_data.each do |sale_data| %>
<% if sale_data.sale_status != 'completed' %>
<tr class="receipt_row" id=<%= sale_data.sale_id %> >
<td>Receipt No. - <span id="receipt_no"><%= sale_data.receipt_no %></span></td>
<% @sale_data.each_with_index do |sale_data, sale_index| %>
<% if sale_data.sale_status != 'completed' && sale_data.sale_status != 'void' %>
<% checked = "" %>
<% if sale_index == 0 %>
<% checked = "checked" %>
<% end %>
<tr class="receipt-row" id=<%= sale_data.receipt_no %> data=<%= sale_data.grand_total %> >
<td><input type="radio" name="rdn_receipt" id="rdn_receipt" value="<%= sale_data.sale_id %>" <%= checked %>></td>
<td><span id="receipt_no"><%= sale_data.receipt_no %></span></td>
<td><span id="grand_total"><%= sale_data.grand_total %></span></td>
<td>
<button type="button" class="btn btn-block waves-effect btn-primary btn_pay" id=<%= sale_data.sale_id %> >Pay</button>
</td>
</tr>
<% end %>
<% end %>
@@ -213,16 +228,94 @@
<!-- Action Panel -->
<div>
<button type="button" class="btn bg-default btn-block waves-effect" id="back" ><i class="material-icons">reply</i> Back </button>
<button id="equal_split" class="btn btn-primary text-center action-btn waves-effect">= Split </button>
<button id="order_split" class="btn btn-primary text-center action-btn waves-effect">By Order &nbsp;</button>
<button id="order_item_split" class="btn btn-primary text-center action-btn waves-effect">By Order Item</button>
<button id="equal_split" class="btn btn-block waves-effect bg-blue">= Split</button>
<button id="order_split" class="btn btn-block waves-effect bg-blue">By Order</button>
<button id="order_item_split" class="btn btn-block waves-effect bg-blue">By Order Item</button>
</div>
</div>
<!-- Column Three -->
</div>
<!-- modal for equal person -->
<div class="modal fade" id="equal_split_modal" tabindex="-1" role="dialog" aria-labelledby="equal_split_modal_label" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="equal_split_modal_label">Equal Split (per person)</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
<div class="form-horizontal">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="form-group">
<input type="text" id="per_person" name="per_person" class="form-control" onkeypress="return isNumberKey(event);"/>
</div>
</div>
</div>
<hr />
<div class="p-l-50">
<div class="row">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="row bottom">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" data-value="1" data-type="num" style="margin-left: 6px;">1</div>
<div class="col-md-3 left cashier_number" data-value="2" data-type="num">2</div>
<div class="col-md-3 left cashier_number" data-value="3" data-type="num">3</div>
</div>
</div>
</div>
<div class="row bottom clearfix">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" data-value="4" data-type="num" style="margin-left: 6px;">4</div>
<div class="col-md-3 left cashier_number" data-value="5" data-type="num">5</div>
<div class="col-md-3 left cashier_number" data-value="6" data-type="num">6</div>
</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" data-value="7" data-type="num" style="margin-left: 6px;">7</div>
<div class="col-md-3 left cashier_number" data-value="8" data-type="num">8</div>
<div class="col-md-3 left cashier_number" data-value="9" data-type="num">9</div>
</div>
</div>
</div>
<div class="row bottom">
<div class="col-md-9">
<div class="row">
<div class="col-md-3 cashier_number" style="margin-left: 6px;"></div>
<div class="col-md-3 left cashier_number red" data-type="del">DEL</div>
<div class="col-md-3 left cashier_number green" data-type="clr">CLR</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn bg-default" data-dismiss="modal">Close</button> &nbsp;&nbsp;
<button type="button" class="btn bg-blue btn_per_person">Split Bill</button>
</div>
</div>
</div>
</div>
<!-- modal for equal person -->
</div>
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var split_total_amount = 0;
$(document).ready(function(){
$('#back').on('click',function(){
@@ -236,28 +329,28 @@
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);
}
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);
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));
var discount_text=$('#per_person').val();
$('#per_person').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#per_person').val("0");
$('#per_person').val("");
break;
}
event.handled = true;
@@ -307,6 +400,21 @@
// Selected Order
$('.order-row').on('click',function(){
var orders = JSON.parse('<%= @orders.to_json.html_safe %>');
var check_order_id = $(this).find('a').attr('href').substr(1);
if(check_order_id == 'all_order'){
if(orders.length > 0){
$.each(orders, function(key,value){
if($("a[href$='#"+value.order_id+"']").parent().hasClass('selected-split-item')){
$("a[href$='#"+value.order_id+"']").parent().removeClass('selected-split-item');
}
});
}
}else{
$("a[href$='#all_order']").parent().removeClass('selected-split-item');
}
if($(this).hasClass('selected-split-item') == true){
$(this).removeClass('selected-split-item');
}
@@ -319,7 +427,17 @@
$('#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);
var cnt_odrs = 0;
if(orders.length == 1){
if(orders[0].id == 'all_order'){
cnt_odrs = 0;
}else{
cnt_odrs = parseInt(cnt_orders) - parseInt(orders.length);
}
}else{
cnt_odrs = parseInt(cnt_orders) - parseInt(orders.length);
}
if (orders.length > 0){
// if(cnt_odrs > 0){
swal({
@@ -345,12 +463,82 @@
});
//selected receipt row click
$('.receipt_row').on('click',function(){
$('.btn_pay').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;
});
//equal split process
$('#equal_split').on('click', function(){
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val();
split_receipt_no = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('id');
split_total_amount = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('data');
if(split_sale_id != undefined && split_sale_id != ""){
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
}
else{
swal("Opps","Please select one receipt!","warning");
}
});
$('.btn_per_person').on('click', function(){
$('#equal_split_modal').modal('hide');
var person = parseInt($('#per_person').val());
if(person > 1){
var ajax_url = "/origami/split_bills/surveys";
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id':dining_id, 'sale_id':split_sale_id, 'receipt_no':split_receipt_no, 'total_customer': person, 'total_amount':split_total_amount },
success: function (result) {
console.log(result);
if(result.status){
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
}
});
}
}
});
}else{
var ajax_url = "/origami/sale/" + split_sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
if((split_receipt_no!=undefined) && (split_receipt_no!=""))
createReceiptNoInFirstBillData(split_receipt_no,"");
location.reload();
// if(type=='Table'){
// window.location.href = '/origami/table/' + dining_id;
// }else{
// window.location.href = '/origami/room/' + dining_id;
// }
}
});
}
});
//equal split process
//slimscroll for order, order items, reciept
var height = ($(window).height() - ($('.legal').outerHeight() + $('.user-info').outerHeight() + $('.navbar').innerHeight()));

View File

@@ -142,7 +142,7 @@
<div class="col-lg-1 col-md-1 col-sm-1">
<button id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-danger btn-block"> Void </button>
<button type="button" id="void" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true" > Void </button>
</div>
</div>
</div>
@@ -173,22 +173,40 @@ $('#pay').on('click',function() {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
$('#back').on('click',function(){
window.location.href = '/origami/table/<%= @table.id %>';
});
$('#void').on('click',function () {
var sure = confirm("Are you sure want to Void");
if (sure == true) {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
})
} else {
var lookup_split_bill = '<%= @split_bill %>';
if(lookup_split_bill == '1'){
window.location.href = '/origami/table/<%= @table.id %>/split_bills';
}else{
window.location.href = '/origami/table/<%= @table.id %>';
}
});
$('#void').on('click',function () {
if ($(this).attr('active')=== "true") {
swal({
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
}
});
}
});
}else{
swal("Opps","You are not authorized for void","warning")
}
});
</script>

View File

@@ -224,6 +224,7 @@ scope "(:locale)", locale: /en|mm/ do
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"
post '/split_bills/surveys', to: 'surveys#create_survey'
end
#--------- Waiter/Ordering Station ------------#

View File

@@ -14,6 +14,7 @@ namespace :clear do
SalePayment.delete_all
ShiftSale.delete_all
PaymentJournal.delete_all
Survey.delete_all
DiningFacility.update_all(status:'available')
CashierTerminal.update_all(is_currently_login: 0)
puts "Clear Data Done."