Merge branch 'quick_service' of bitbucket.org:code2lab/sxrestaurant into split_bill

This commit is contained in:
phyusin
2018-02-21 13:41:50 +06:30
8 changed files with 177 additions and 78 deletions

View File

@@ -69,6 +69,9 @@ section .content{
.nav-tabs { .nav-tabs {
background-color: #eeeeee; background-color: #eeeeee;
} }
.nav-tabs .nav-link {
padding: 0.7286rem 0.2575
}
.nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link { .nav-tabs .nav-link.active, .nav-tabs .nav-item.show .nav-link {
background-color: #fff; background-color: #fff;
border-left: 6px solid #111; border-left: 6px solid #111;
@@ -225,10 +228,13 @@ i.logout_icon{
background-color: #eee; background-color: #eee;
border-bottom: 1px solid #fff; border-bottom: 1px solid #fff;
} }
.list-menu > a:focus{
background-color:initial;
}
.menu_list{ .menu_list{
display: block; display: block;
background-color: #eeeeee; background-color: #eeeeee;
border-bottom: .214rem solid #fff; border-bottom: .014rem solid #fff;
border-left: 1px solid #54A5AF; border-left: 1px solid #54A5AF;
border-right: 1px solid #54A5AF; border-right: 1px solid #54A5AF;
margin-bottom: -1px; margin-bottom: -1px;

View File

@@ -157,8 +157,14 @@ class Origami::PaymentsController < BaseOrigamiController
if params[:type] == "quick_service" if params[:type] == "quick_service"
booking = Booking.find_by_sale_id(sale_id) booking = Booking.find_by_sale_id(sale_id)
if booking.dining_facility_id.to_i>0
table_id = booking.dining_facility_id
else
table_id = 0
end
booking.booking_orders.each do |order| booking.booking_orders.each do |order|
Order.pay_process_order_queue(order.order_id,booking.dining_facility_id) Order.pay_process_order_queue(order.order_id,table_id,sale_id)
end end
end end
end end

View File

@@ -1,7 +1,7 @@
class OrderQueueProcessorJob < ApplicationJob class OrderQueueProcessorJob < ApplicationJob
queue_as :default queue_as :default
def perform(order_id, table_id) def perform(order_id, table_id,sale_id=nil)
# Do something later # Do something later
#Order ID #Order ID
order = Order.find(order_id) order = Order.find(order_id)
@@ -9,7 +9,7 @@ class OrderQueueProcessorJob < ApplicationJob
#Execute orders and send to order stations #Execute orders and send to order stations
if order if order
oqs = OrderQueueStation.new oqs = OrderQueueStation.new
oqs.process_order(order, table_id) oqs.process_order(order, table_id,sale_id)
end end
assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id) assign_order = AssignedOrderItem.assigned_order_item_by_job(order_id)

View File

@@ -309,9 +309,9 @@ class Order < ApplicationRecord
end end
#Process order items and send to order queue #Process order items and send to order queue
def self.pay_process_order_queue(id,table_id) def self.pay_process_order_queue(id,table_id,sale_id=nil)
#Send to background job for processing #Send to background job for processing
OrderQueueProcessorJob.perform_later(id, table_id) OrderQueueProcessorJob.perform_later(id, table_id,sale_id)
end end
def check_cup_status(status) def check_cup_status(status)

View File

@@ -13,46 +13,22 @@ class OrderQueueStation < ApplicationRecord
# validations # validations
validates_presence_of :station_name, :printer_name validates_presence_of :station_name, :printer_name
def process_order (order, table_id) def process_order (order, table_id,sale_id=nil)
oqs_stations = OrderQueueStation.active oqs_stations = OrderQueueStation.active
dining=DiningFacility.find(table_id)
# oqpbz = OrderQueueProcessByZone.find_by_zone_id(dining.zone_id)
order_items = order.order_items order_items = order.order_items
# get dining if table_id > 0
booking = Booking.find_by_dining_facility_id(dining.id) # get dining
dining=DiningFacility.find(table_id)
#Assign OQS id to order Items oqs_by_zones = OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}")
# oqs_stations.each do |oqs| booking = Booking.find_by_dining_facility_id(dining.id)
# is_auto_printed = false
# oqs_order_items = []
# #Get List of items -
# pq_items = JSON.parse(oqs.processing_items)
# #Loop through the processing items
# pq_items.each do |pq_item|
# #Processing through the looping items
# order_items.each do |order_item|
# if (pq_item == order_item.item_code)
# # if oqs.id == oqpbz.order_queue_station_id
# # #Same Order_items can appear in two location.
# # AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# # else
# if (order_item.price != 0)
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# oqs_order_items.push(order_item)
# end
# # end
# end
# end
# end
# ToDo per item per printer # ToDo per item per printer
OrderQueueProcessByZone.where("zone_id=#{dining.zone_id}").find_each do |oqpbz| oqs_by_zones.each do |oqpbz|
oqs = OrderQueueStation.find(oqpbz.order_queue_station_id) oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
is_auto_printed = false is_auto_printed = false
oqs_order_items = [] oqs_order_items = []
@@ -86,17 +62,51 @@ class OrderQueueStation < ApplicationRecord
end end
end end
end end
# if oqs.id == oqpbz.order_queue_station_id end
# # Auto Printing else
# if oqs.auto_print # get dining
# if oqs_order_items.length > 0 sale = Sale.find(sale_id).shift_sale_id
# print_slip(oqs, order, oqs_order_items) terminal_by_zones = CashierTerminalByZones.where("cashier_terminal_id=#{shift.cashier_terminal_id}")
# is_auto_printed = true
# end # ToDo per item per printer
# end terminal_by_zones.each do |tbz|
# end OrderQueueProcessByZone.where("zone_id=#{tbz.zone_id}").find_each do |oqpbz|
end oqs = OrderQueueStation.find(oqpbz.order_queue_station_id)
# end is_auto_printed = false
oqs_order_items = []
if oqs.is_active
#Get List of items -
pq_items = JSON.parse(oqs.processing_items)
#Loop through the processing items
pq_items.each do |pq_item|
#Processing through the looping items
order_items.each do |order_item|
if (pq_item == order_item.item_code)
# if oqs.id == oqpbz.order_queue_station_id
# #Same Order_items can appear in two location.
# AssignedOrderItem.assigned_order_item(order, order_item.item_code, oqs)
# else
# if (order_item.price != 0)
AssignedOrderItem.assigned_order_item(order, order_item.item_code, order_item.item_instance_code, oqs)
oqs_order_items.push(order_item)
# end
# end
end
end
end
if oqs.auto_print
if oqs_order_items.length > 0
print_slip(oqs, order, oqs_order_items)
is_auto_printed = true
end
end
end
end
end
end #end else
end end
private private

View File

@@ -82,16 +82,17 @@ class Sale < ApplicationRecord
current_shift = ShiftSale.current_shift current_shift = ShiftSale.current_shift
shift = ShiftSale.current_open_shift(cashier.id) shift = ShiftSale.current_open_shift(cashier.id)
# set cashier # set cashier
if shift != nil if shift != nil
self.cashier_id = cashier.id self.cashier_id = cashier.id
self.cashier_name = cashier.name self.cashier_name = cashier.name
self.shift_sale_id = shift.id self.shift_sale_id = shift.id
else else
if open_cashier.nil? if open_cashier.count>0
self.cashier_id = requested_by.id self.cashier_id = open_cashier[0].id
self.cashier_name = requested_by.name self.cashier_name = open_cashier[0].name
self.shift_sale_id = current_shift.id shift_id = ShiftSale.current_open_shift(open_cashier[0].id)
self.shift_sale_id = shift_id.id
else else
self.cashier_id = current_shift.employee_id self.cashier_id = current_shift.employee_id
self.cashier_name = Employee.find(current_shift.employee_id).name self.cashier_name = Employee.find(current_shift.employee_id).name
@@ -99,6 +100,7 @@ class Sale < ApplicationRecord
end end
end end
# set waiter # set waiter
self.requested_by = requested_by.name self.requested_by = requested_by.name

View File

@@ -28,7 +28,7 @@
<span class="main_menu" id="main_menu" ><%= @menus[0].name %></span> <span class="main_menu" id="main_menu" ><%= @menus[0].name %></span>
<!-- <i class="material-icons material-icons m-l-50 p-r-30">arrow_drop_down</i> --> <!-- <i class="material-icons material-icons m-l-50 p-r-30">arrow_drop_down</i> -->
</a> </a>
<ul class="ml-menu menu_list aria-hidden " style=""> <ul class="ml-menu menu_list aria-hidden " style="border-top: 1px solid #fff">
<% @menus.each do |menu| %> <% @menus.each do |menu| %>
<li class="nav-item menu_click" data-name="<%=menu.name%>" data-id="<%=menu.id%>" style=""> <li class="nav-item menu_click" data-name="<%=menu.name%>" data-id="<%=menu.id%>" style="">
<a class="nav-link" data-toggle="tab" href="" role="tab" style="text-transform: lowercase;"><%=menu.name%></a> <a class="nav-link" data-toggle="tab" href="" role="tab" style="text-transform: lowercase;"><%=menu.name%></a>
@@ -213,14 +213,14 @@
<% if type && modify_order%> <% if type && modify_order%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001"> <input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary btn-lg create col-md-10" id="create_pay_order" disabled="disabled">Update Order & Pay</button> <button type="button" class="btn btn-primary action-btn create col-md-10" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<%elsif !modify_order && type%> <%elsif !modify_order && type%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001"> <input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary btn-lg create col-md-6" id="create_pay_order" disabled="disabled">Create & Pay</button> <button type="button" class="btn btn-primary action-btn create col-md-6" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create & Pay</button>
<button type="button" class="btn btn-primary btn-lg create col-md-5" id="create_order" disabled="disabled">Create Order</button> <button type="button" class="btn btn-primary action-btn create col-md-5" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<%else%> <%else%>
<button type="button" class="btn btn-primary btn-lg create col-md-10" id="create_order" disabled="disabled">Create Order</button> <button type="button" class="btn btn-primary action-btn create col-md-10" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<%end%> <%end%>

View File

@@ -29,12 +29,12 @@
<table class="table " id="order-items-table"> <table class="table " id="order-items-table">
<thead> <thead>
<tr> <tr>
<th width="4%">#</th> <th width="2%">#</th>
<th class="" width="20%">Items</th> <th class="" width="20%">Items</th>
<th style="" width="13%">QTY <th style="" width="5%">QTY
</td> </th>
<th class="" width="13%">Price <th class="" width="10%">Price
</td> </th>
<!-- <th class='' width="17%"> Total </th> --> <!-- <th class='' width="17%"> Total </th> -->
<th class='' width="20%"> Action</th> <th class='' width="20%"> Action</th>
</tr> </tr>
@@ -53,46 +53,46 @@
unless sale_item.price == 0 unless sale_item.price == 0
%> %>
<tr> <tr>
<td width="4%"><%= count %></td> <td class="p-1" width="2%"><%= count %></td>
<td class='' width="20%"> <td class="p-2" width="20%">
<%= sale_item.product_name %> <%= sale_item.product_name %>
</td> </td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %> <% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<td class='' width="10%"> <td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/> <input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
</td> </td>
<td class='' width="13%"> <td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/> <input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
</td> </td>
<!-- <td class='' width="17%"> <!-- <td class='' width="17%">
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/> <input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
</td> --> </td> -->
<td class='' width="25%"> <td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button> <button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button> <button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button> <button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
</td> </td>
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %> <% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<td class='' width="10%"> <td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td> </td>
<td class='' width="13%"> <td class='' width="10%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" disabled/>
</td> </td>
<!-- <td class='' width="17%"> <!-- <td class='' width="17%">
<input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/> <input data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td> --> </td> -->
<td class='' width="25%"> <td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect cancel'>Cancel <button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect cancel'>Cancel
Void/Update Void/Update
</button> </button>
</td> </td>
<% else %> <% else %>
<td class='' width="13%"> <td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td> </td>
<td class='' width="13%"> <td class="p-1" width="10%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/> <input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control" disabled/>
</td> </td>
<td></td> <td></td>
@@ -108,7 +108,7 @@
<div class="card-footer"> <div class="card-footer">
<table class="table" id="order-charges-table" border="0"> <table class="table" id="order-charges-table" border="0">
<tr> <tr>
<td width="50%"><strong>Sub Total:</strong></td> <td class="p-1" width="50%"><strong>Sub Total:</strong></td>
<td><strong id="order-sub-total"><%= sub_total %></strong></td> <td><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr> </tr>
<tr class="rebate_amount"></tr> <tr class="rebate_amount"></tr>
@@ -117,12 +117,42 @@
</div> </div>
</div> </div>
</div> </div>
<!-- <div class="col-md-3">
<div class="card p-l-15 p-r-15">
<div class="card-block">
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="1" data-type="num">1</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="2" data-type="num">2</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="3" data-type="num">3</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="4" data-type="num">4</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="5" data-type="num">5</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="6" data-type="num">6</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="7" data-type="num">7</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="8" data-type="num">8</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="9" data-type="num">9</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left" data-value="0" data-type="num">0</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="." data-type="num">.</div>
<div class="col-md-4 cashier_number border-top border- border-left" data-value="00" data-type="num">00</div>
</div>
<div class="row bottom">
<div class="col-md-4 cashier_number border-top border- border-left green" data-type="nett">Nett</div>
<div class="col-md-4 cashier_number border-top border- border-left red" data-type="del">Del</div>
<div class="col-md-4 cashier_number border-top border- border-left orange" data-type="clr">Clr</div>
</div>
</div>
</div>
</div> -->
<!-- Column Three --> <!-- Column Three -->
<div class="col-lg-2 col-md-2 col-sm-2"> <div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button> <button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-block btn-lg bg-danger waves-effect" id='cancel_all_void'>Cancel All Void</button> <button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button> <button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
</div> </div>
</div> </div>
@@ -236,4 +266,49 @@ var cashier_type = "<%= @cashier_type %>";
} }
}); });
}) })
$( "input" ).focusin(function() {
$('.addfocus').removeClass('addfocus');
$( this ).addClass('addfocus');
});
$(".cashier_number").on('click', function(event){
if(event.handled !== true) {
var original_value='';
original_value = $('.addfocus').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('.addfocus').val(input_value);
}
else{
$('.addfocus').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('.addfocus').val(amount);
break;
case 'del' :
var discount_text=$('.addfocus').val();
$('.addfocus').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('.addfocus').val("");
break;
}
event.handled = true;
} else {
return false;
}
});
</script> </script>