Origami update commit
This commit is contained in:
@@ -1,20 +1,12 @@
|
||||
class Origami::HomeController < BaseOrigamiController
|
||||
def index
|
||||
@order = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
||||
order_items.id as order_items_id,dining_facilities.name as table_name")
|
||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
||||
left join bookings on bookings.id = booking_orders.id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("orders.order_type=? and dining_facilities.is_active=?","dine_in",true)
|
||||
.group("orders.id")
|
||||
@order_table = Order.get_order_table()
|
||||
@order_rooms = Order.get_order_rooms()
|
||||
@orders = Order.get_orders()
|
||||
end
|
||||
def show
|
||||
@order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
.joins("left join orders on orders.id = order_items.order_id")
|
||||
.where("order_items.order_id=?",params[:order_id])
|
||||
# render :json => @order_details.to_json
|
||||
str = []
|
||||
str = []
|
||||
@order_details = OrderItem.get_order_items_details(params[:order_id])
|
||||
@order_details.each do |ord_detail|
|
||||
str.push(ord_detail)
|
||||
end
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
class DiningFacility < ApplicationRecord
|
||||
belongs_to :zone
|
||||
|
||||
TABLE_TYPE = "Table"
|
||||
ROOM_TYPE = "Room"
|
||||
|
||||
default_scope { order('order_by asc') }
|
||||
|
||||
scope :active, -> {where(is_active: true)}
|
||||
|
||||
@@ -201,4 +201,38 @@ class Order < ApplicationRecord
|
||||
#Send to background job for processing
|
||||
OrderQueueProcessorJob.perform_later(self.id)
|
||||
end
|
||||
|
||||
#Origami: Cashier : to view order type Table
|
||||
def self.get_order_table
|
||||
order_table = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
||||
order_items.id as order_items_id,dining_facilities.name as table_name")
|
||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
||||
left join bookings on bookings.id = booking_orders.id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
|
||||
.group("orders.id")
|
||||
end
|
||||
#Origami: Cashier : to view order type Room
|
||||
def self.get_order_rooms
|
||||
order_rooms = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
||||
order_items.id as order_items_id,dining_facilities.name as room_name")
|
||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
||||
left join bookings on bookings.id = booking_orders.id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
|
||||
.group("orders.id")
|
||||
end
|
||||
#Origami: Cashier : to view orders
|
||||
def self.get_orders
|
||||
orders = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
||||
order_items.id as order_items_id,dining_facilities.name as table_or_room_name")
|
||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
||||
left join bookings on bookings.id = booking_orders.id
|
||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||
left join order_items on order_items.order_id = orders.id")
|
||||
.where("dining_facilities.is_active=?",true)
|
||||
.group("orders.id")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -33,4 +33,10 @@ class OrderItem < ApplicationRecord
|
||||
|
||||
|
||||
end
|
||||
#Origami : Cashier : to show order items details
|
||||
def self.get_order_items_details(order_id)
|
||||
order_details = OrderItem.select("order_items.item_name,order_items.qty,order_items.price,(order_items.qty*order_items.price) as total_price")
|
||||
.joins("left join orders on orders.id = order_items.order_id")
|
||||
.where("order_items.order_id=?",order_id)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -22,70 +22,16 @@
|
||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<% @order.each do |order| %>
|
||||
<div class="card" onclick="callOrderDetails('<%=order.order_id%>')">
|
||||
|
||||
<% @order_table.each do |order_table| %>
|
||||
<div class="card" id="table-order-<%=order_table.order_id%>" onclick="callOrderDetails('<%=order_table.order_id%>')">
|
||||
|
||||
<div class="card-block">
|
||||
<!-- <h4 class="card-title">Card title that wraps to a new line</h4> -->
|
||||
|
||||
<h4 class="card-title"><span class="table-name"><%=order.table_name%></span></h4>
|
||||
<!-- <p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p> -->
|
||||
<p class="card-text"><%=order.total_price%></p>
|
||||
<h4 class="card-title"><span id="table-name-<%=order_table.order_id%>" class="table-name"><%=order_table.table_name%></span></h4>
|
||||
<p class="card-text"><%=order_table.total_price%></p>
|
||||
</div>
|
||||
</div>
|
||||
<%end %>
|
||||
<!-- <div class="card p-3">
|
||||
<blockquote class="card-block card-blockquote">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
|
||||
<footer>
|
||||
<small class="text-muted">
|
||||
Someone famous in <cite title="Source Title">Source Title</cite>
|
||||
</small>
|
||||
</footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-inverse card-primary p-3 text-center">
|
||||
<blockquote class="card-blockquote">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
|
||||
<footer>
|
||||
<small>
|
||||
Someone famous in <cite title="Source Title">Source Title</cite>
|
||||
</small>
|
||||
</footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="card text-center">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-3 text-right">
|
||||
<blockquote class="card-blockquote">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
|
||||
<footer>
|
||||
<small class="text-muted">
|
||||
Someone famous in <cite title="Source Title">Source Title</cite>
|
||||
</small>
|
||||
</footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This is a wider card with supporting text below as a natural lead-in to additional content. This card has even longer content than the first to show that equal height action.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
|
||||
</div>
|
||||
@@ -94,46 +40,16 @@
|
||||
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<div class="card">
|
||||
<% @order_rooms.each do |order_room| %>
|
||||
<div class="card" id="table-order-<%=order_room.order_id%>" onclick="callOrderDetails('<%=order_room.order_id%>')">
|
||||
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title that wraps to a new line</h4>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card p-3">
|
||||
<blockquote class="card-block card-blockquote">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat a ante.</p>
|
||||
<footer>
|
||||
<small class="text-muted">
|
||||
Someone famous in <cite title="Source Title">Source Title</cite>
|
||||
</small>
|
||||
</footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card card-inverse card-primary p-3 text-center">
|
||||
<blockquote class="card-blockquote">
|
||||
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer posuere erat.</p>
|
||||
<footer>
|
||||
<small>
|
||||
Someone famous in <cite title="Source Title">Source Title</cite>
|
||||
</small>
|
||||
</footer>
|
||||
</blockquote>
|
||||
</div>
|
||||
<div class="card text-center">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
<% tablename = order_room.room_name%>
|
||||
<h4 class="card-title"><span id="table-name-<%=order_room.order_id%>" class="table-name"><%=order_room.room_name%></span></h4>
|
||||
<p class="card-text"><%=order_room.total_price%></p>
|
||||
</div>
|
||||
</div>
|
||||
<%end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -144,27 +60,15 @@
|
||||
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<!-- <div class="card">
|
||||
<% @orders.each do |order| %>
|
||||
<div class="card" id="table-order-<%=order.order_id%>" onclick="callOrderDetails('<%=order.order_id%>')">
|
||||
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title that wraps to a new line</h4>
|
||||
<p class="card-text">This is a longer card with supporting text below as a natural lead-in to additional content. This content is a little bit longer.</p>
|
||||
<h4 class="card-title"><span id="table-name-<%=order.order_id%>" class="table-name"><%=order.table_or_room_name%></span></h4>
|
||||
<p class="card-text"><%=order.total_price%></p>
|
||||
</div>
|
||||
</div> -->
|
||||
<!-- <div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div> -->
|
||||
|
||||
<!-- <div class="card text-center">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">Card title</h4>
|
||||
<p class="card-text">This card has supporting text below as a natural lead-in to additional content.</p>
|
||||
<p class="card-text"><small class="text-muted">Last updated 3 mins ago</small></p>
|
||||
</div>
|
||||
</div> -->
|
||||
</div>
|
||||
<%end %>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -179,7 +83,7 @@
|
||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
||||
<div class="card" >
|
||||
<div class="card-header">
|
||||
<div id="order-title"><strong>ORDER DETAILS</strong> <% if @order_details%>- Table 4<%end%></div>
|
||||
<div id="order-title"><strong>ORDER DETAILS</strong> <span id="order-detail-header"></span></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
@@ -194,7 +98,7 @@
|
||||
</table>
|
||||
</div>
|
||||
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<table class="table">
|
||||
<table class="table" id="append-table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
@@ -218,27 +122,6 @@
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"></span></strong></td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong>0</strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left">Discounts</td>
|
||||
<td style="width:20%; text-align:right">(-250.00)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left">Service Tax</td>
|
||||
<td style="width:20%; text-align:right">50.00</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left">Commercial Tax</td>
|
||||
<td style="width:20%; text-align:right">39.50</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left"><strong>Grand Total</strong></td>
|
||||
<td style="width:20%; text-align:right"><strong>589.50</strong></td>
|
||||
</tr> -->
|
||||
</tfooter>
|
||||
</table>
|
||||
</div>
|
||||
@@ -262,11 +145,21 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
<script>
|
||||
var old_order_id = 0
|
||||
var old_table_name = ""
|
||||
function callOrderDetails(order_id){
|
||||
$("#item-name-price").html("")
|
||||
$("#item-qty").html("")
|
||||
$("#item-total-price").html("")
|
||||
var tbody = ""
|
||||
$("#append-table").html("")
|
||||
if (old_order_id != order_id){
|
||||
$("#table-order-"+old_order_id).removeClass("selected_color")
|
||||
$("#table-order-"+order_id).addClass("selected_color")
|
||||
old_order_id = order_id
|
||||
|
||||
}
|
||||
|
||||
$("#order-detail-header").html("")
|
||||
$("#order-detail-header").append(document.getElementById("table-name-"+order_id).innerHTML)
|
||||
$("#sub-total").html("")
|
||||
url = "origami/"+order_id
|
||||
$.ajax({type: "GET",
|
||||
@@ -276,19 +169,31 @@ function callOrderDetails(order_id){
|
||||
var sub_total = 0
|
||||
for (i = 0; i < result.length; i++) {
|
||||
var data = JSON.stringify(result[i]);
|
||||
// console.log(parse_data)
|
||||
var parse_data = JSON.parse(data)
|
||||
sub_total += (parse_data.qty*parse_data.price)
|
||||
$("#item-name-price").append(parse_data.item_name+"@"+parse_data.price+"<br/>")
|
||||
$("#item-qty").append(parse_data.qty+"<br/>")
|
||||
$("#item-total-price").append((parse_data.qty*parse_data.price)+"<br/>")
|
||||
row = '<tbody><tr><td style="width:60%; text-align:left"><span id="item-name-price">'+parse_data.item_name+"@"+(parse_data.price*1)+'</span></td>'
|
||||
+'<td style="width:20%; text-align:right"><span id="item-qty">'+(parse_data.qty*1)+'</span></td>s'
|
||||
+'<td style="width:20%; text-align:right"><span id="item-total-price">'+(parse_data.qty*parse_data.price)+'</span></td>'
|
||||
+'</tr></tbody>'
|
||||
tbody += row
|
||||
|
||||
}
|
||||
|
||||
$("#append-table").append(tbody)
|
||||
$("#sub-total").append((sub_total)+"<br/>")
|
||||
|
||||
|
||||
},
|
||||
error:function(result){
|
||||
alert('error');
|
||||
// alert('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
|
||||
</script>
|
||||
<style type="text/css">
|
||||
.selected_color{
|
||||
color:white;
|
||||
background-color: blue;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user