order controller updated
This commit is contained in:
@@ -37,6 +37,7 @@ class Api::OrdersController < Api::ApiController
|
||||
#Create Table Booking or Room Booking
|
||||
if !params["booking_id"].nil? && params[:booking_id].to_i > 0
|
||||
@order.new_booking = false
|
||||
# @order.new_booking = true
|
||||
@order.booking_id = params[:booking_id]
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,25 @@
|
||||
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")
|
||||
|
||||
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])
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json{
|
||||
render :json => @order_details.to_json
|
||||
}
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
@@ -18,16 +18,23 @@
|
||||
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||
<!-- Panel 1 - Tables -->
|
||||
|
||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<div class="card">
|
||||
<% @order.each do |order| %>
|
||||
<div class="card" 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">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>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card p-3">
|
||||
<%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>
|
||||
@@ -78,7 +85,7 @@
|
||||
<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>
|
||||
|
||||
</div>
|
||||
@@ -137,27 +144,27 @@
|
||||
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
<div class="card">
|
||||
<!-- <div class="card">
|
||||
<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">
|
||||
</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> -->
|
||||
|
||||
<div class="card text-center">
|
||||
<!-- <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> -->
|
||||
</div>
|
||||
|
||||
|
||||
@@ -172,7 +179,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> - Table 4</div>
|
||||
<div id="order-title"><strong>ORDER DETAILS</strong> <% if @order_details%>- Table 4<%end%></div>
|
||||
</div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
@@ -186,120 +193,26 @@
|
||||
</thead>
|
||||
</table>
|
||||
</div>
|
||||
<div class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<table class="table">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
Menu Items Name @ 50.00
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
250.00
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
<% sub_total = 0%>
|
||||
<% if @order_details%>
|
||||
<% @order_details.each do |order_detail| %>
|
||||
<tr>
|
||||
<td style="width:60%; text-align:left">
|
||||
<%=order_detail.item_name%> @ <%=order_detail.price%>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<%=order_detail.qty%>
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
<%=order_detail.total_price%>
|
||||
<%sub_total+=order_detail.total_price%>
|
||||
</td>
|
||||
</tr>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -307,8 +220,13 @@
|
||||
<table class="table" style="margin-bottom:0px">
|
||||
<tfooter>
|
||||
<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>750.00</strong></td>
|
||||
<td style="width:80%; text-align:left; border-top:none"><strong>Total Amount</strong></td>
|
||||
<td style="width:20%; text-align:right; border-top:none"><strong><%=sub_total%></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><%=sub_total%></strong></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left">Discounts</td>
|
||||
@@ -325,7 +243,7 @@
|
||||
<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>
|
||||
</tr> -->
|
||||
</tfooter>
|
||||
</table>
|
||||
</div>
|
||||
@@ -349,3 +267,18 @@
|
||||
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
function callOrderDetails(order_id){
|
||||
url = "origami/"+order_id
|
||||
$.ajax({type: "GET",
|
||||
url: url,
|
||||
data: { order_id: order_id},
|
||||
success:function(result){
|
||||
alert('ok'+result);
|
||||
},
|
||||
error:function(result){
|
||||
alert('error');
|
||||
}
|
||||
});
|
||||
}
|
||||
</script>
|
||||
Reference in New Issue
Block a user