for all items
This commit is contained in:
@@ -27,9 +27,9 @@ class Origami::HomeController < BaseOrigamiController
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
@order_items_count = Hash.new
|
||||
bookings = Booking.all
|
||||
if !bookings.nil?
|
||||
@order_items_count = Hash.new
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
@@ -51,7 +51,7 @@ class Origami::HomeController < BaseOrigamiController
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += sale.sale_items.count
|
||||
@order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -59,6 +59,9 @@ class Origami::HomeController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
puts "@order_items_count"
|
||||
puts @order_items_count.to_json
|
||||
|
||||
@dining.bookings.active.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
@order_items = Array.new
|
||||
|
||||
@@ -28,9 +28,9 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
@order_items_count = Hash.new
|
||||
bookings = Booking.all
|
||||
if !bookings.nil?
|
||||
@order_items_count = Hash.new
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
@@ -52,7 +52,7 @@ class Origami::OrdersController < BaseOrigamiController
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += sale.sale_items.count
|
||||
@order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,10 +22,10 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
@shop = Shop::ShopDetail
|
||||
@membership = MembershipSetting::MembershipSetting
|
||||
@payment_methods = PaymentMethodSetting.all
|
||||
|
||||
@order_items_count = Hash.new
|
||||
|
||||
bookings = Booking.all
|
||||
if !bookings.nil?
|
||||
@order_items_count = Hash.new
|
||||
bookings.each do |booking|
|
||||
if booking.sale_id.nil? && booking.booking_status != 'moved'
|
||||
if !booking.booking_orders.empty?
|
||||
@@ -47,7 +47,7 @@ class Origami::RoomsController < BaseOrigamiController
|
||||
if !@order_items_count.key?(booking.dining_facility_id)
|
||||
@order_items_count.store(booking.dining_facility_id, sale.sale_items.count)
|
||||
else
|
||||
@order_items_count[booking.dining_facility_id] += sale.sale_items.count
|
||||
@order_items_count[booking.dining_facility_id] = sale.sale_items.count
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -21,6 +21,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
@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?
|
||||
@@ -68,6 +69,9 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
else
|
||||
@booking = nil
|
||||
end
|
||||
|
||||
puts "@order_items"
|
||||
puts @order_items.to_json
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -163,9 +167,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
|
||||
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!
|
||||
update_order_item(order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -176,12 +178,10 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
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!
|
||||
update_order_item(order_item)
|
||||
end
|
||||
end
|
||||
else
|
||||
@@ -214,26 +214,7 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
BookingOrder.create({:booking_id => booking.booking_id, :order_id => order.order_id})
|
||||
|
||||
order_items.each do |order_item|
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
orderItem.item_instance_code,
|
||||
orderItem.item_name,
|
||||
orderItem.alt_name,
|
||||
orderItem.account_id,
|
||||
order_item['qty'],
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
orderItem.set_menu_items,
|
||||
orderItem.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
|
||||
end
|
||||
orderItem.save!
|
||||
update_order_item(order_item)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -258,6 +239,29 @@ class Origami::SplitBillController < BaseOrigamiController
|
||||
end
|
||||
end
|
||||
|
||||
def update_order_item(order_item)
|
||||
orderItem = OrderItem.find(order_item["id"])
|
||||
if orderItem.qty.to_f != order_item['qty'].to_f
|
||||
OrderItem.processs_item(orderItem.item_code,
|
||||
orderItem.item_instance_code,
|
||||
orderItem.item_name,
|
||||
orderItem.alt_name,
|
||||
orderItem.account_id,
|
||||
order_item['qty'],
|
||||
orderItem.price,
|
||||
orderItem.options,
|
||||
orderItem.set_menu_items,
|
||||
orderItem.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
|
||||
end
|
||||
orderItem.save!
|
||||
end
|
||||
|
||||
#Shop Name in Navbor
|
||||
helper_method :shop_detail
|
||||
def shop_detail
|
||||
|
||||
@@ -40,16 +40,25 @@ class Origami::VoidController < BaseOrigamiController
|
||||
# end
|
||||
|
||||
table_avaliable = true
|
||||
table_count = 0
|
||||
table = sale.bookings[0].dining_facility
|
||||
table.bookings.each do |booking|
|
||||
if !booking.sale.nil?
|
||||
if booking.sale.sale_status == 'new'
|
||||
if booking.booking_status != 'moved'
|
||||
if booking.sale_id
|
||||
if booking.sale.sale_status != 'completed' && booking.sale.sale_status != 'void'
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
else
|
||||
table_avaliable = true
|
||||
end
|
||||
else
|
||||
table_avaliable = false
|
||||
table_count += 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if table_avaliable
|
||||
if table_avaliable && table_count == 0
|
||||
table.status = 'available'
|
||||
table.save
|
||||
end
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
<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="active">
|
||||
<li class="order-row active">
|
||||
<a href="#all_order" data-toggle="tab">All</a>
|
||||
</li>
|
||||
<% @orders.each.with_index(0) do |order, order_index| %>
|
||||
@@ -38,12 +38,75 @@
|
||||
</div>
|
||||
<div class="col-lg-8 col-md-8 col-sm-8">
|
||||
<div class="tab-content">
|
||||
<div class="tab-pane active" id="all_order">
|
||||
<div class="card-title">
|
||||
<p class="m-l-2">Order Items</p>
|
||||
</div>
|
||||
<div id="order-detail-slimscroll-all_order" 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_items.nil? %>
|
||||
<% sub_total = 0 %>
|
||||
<% @order_items.each do |order_item| %>
|
||||
<% if order_item.include? ('all_order') %>
|
||||
<% order_item['all_order'].each do |odr_item| %>
|
||||
<%
|
||||
sub_total += odr_item['qty'].to_f * odr_item['price'].to_f
|
||||
%>
|
||||
<tr class="item-row" id=<%= odr_item['order_items_id'] %> >
|
||||
<td style="width:60%; text-align:left">
|
||||
<span id="item-order-id" class="hidden"><%=odr_item['order_id'] %></span>
|
||||
<span id="item-account-type" class="hidden"><%=odr_item['account_id'] %></span>
|
||||
<span id="item-name-price">
|
||||
<%=odr_item['item_name'] %>
|
||||
<% if !odr_item['set_menu_items'].nil?
|
||||
odr_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"><%=odr_item['qty']%></span>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<span id="item-total-price"><%=(odr_item['qty'].to_f * odr_item['price'].to_f)%></span>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%
|
||||
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>
|
||||
|
||||
<% @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="tab-pane" id="<%= order.order_id %>">
|
||||
<div class="card-title">
|
||||
<p class="m-l-2">Order Items</p>
|
||||
</div>
|
||||
@@ -150,6 +213,7 @@
|
||||
<!-- 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 </button>
|
||||
<button id="order_item_split" class="btn btn-primary text-center action-btn waves-effect">By Order Item</button>
|
||||
</div>
|
||||
@@ -308,6 +372,15 @@
|
||||
railBorderRadius: '0'
|
||||
});
|
||||
|
||||
$('#order-detail-slimscroll-all_order').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){
|
||||
|
||||
Reference in New Issue
Block a user