Append Order Detail view finished
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
class Api::BookingsController < Api::ApiController
|
||||
|
||||
skip_before_action :authenticate
|
||||
|
||||
#Show customer by ID
|
||||
def index
|
||||
@@ -10,6 +10,15 @@ class Api::BookingsController < Api::ApiController
|
||||
@booking = Booking.find(params[:id])
|
||||
end
|
||||
|
||||
def update_booking
|
||||
|
||||
|
||||
booking = Booking.find_by(id: params[:booking])
|
||||
booking.update_all(booking_status: 'Dave')
|
||||
|
||||
|
||||
end
|
||||
|
||||
# private
|
||||
# def Bookings_params
|
||||
# params.permit(:id, :order_id)
|
||||
|
||||
@@ -7,7 +7,10 @@ class Api::OrdersController < Api::ApiController
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
def get_order
|
||||
order = Order.find(params[:order_id])
|
||||
order.order_items
|
||||
end
|
||||
|
||||
# Description
|
||||
# This API allow new order creation
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
class Crm::HomeController < BaseCrmController
|
||||
def index
|
||||
|
||||
# @booking = Booking.all
|
||||
|
||||
@booking = Booking.select("bookings.id as booking_id,
|
||||
bookings.checkin_at,
|
||||
bookings.checkin_by,
|
||||
bookings.dining_facility_id,
|
||||
od.customer_id as customer,
|
||||
od.item_count as count,
|
||||
odt.id as order_item_id,
|
||||
odt.item_name as item_name")
|
||||
.joins("join booking_orders as bko ON bko.booking_id = bookings.id")
|
||||
.joins("right join orders as od ON od.id = bko.order_id")
|
||||
.joins("right join order_items as odt ON odt.order_id=od.id")
|
||||
.order("bookings.id DESC")
|
||||
|
||||
@booking = Booking.all
|
||||
@customer = Customer.all
|
||||
|
||||
#@booking = Booking.select("bookings.id as booking_id,
|
||||
# bookings.checkin_at,
|
||||
# bookings.checkin_by,
|
||||
# bookings.dining_facility_id,
|
||||
# od.customer_id as customer,
|
||||
# od.id as order_id,
|
||||
# od.item_count as count,
|
||||
# odt.id as order_item_id,
|
||||
# odt.item_name as item_name")
|
||||
# .joins("join booking_orders as bko ON bko.booking_id = bookings.id")
|
||||
# .joins("right join orders as od ON od.id = bko.order_id")
|
||||
# .joins("right join order_items as odt ON odt.order_id=od.id")
|
||||
# .order("bookings.id DESC")
|
||||
|
||||
end
|
||||
def show
|
||||
|
||||
@@ -2,6 +2,8 @@ if (@booking)
|
||||
json.id @booking.id
|
||||
json.status @booking.booking_status
|
||||
json.checkin_at @booking.checkin_at
|
||||
json.checkin_by @booking.checkin_by
|
||||
json.table_name @booking.dining_facility.name
|
||||
|
||||
if @booking.type == "TableBooking"
|
||||
json.table_id @booking.dining_facility_id
|
||||
|
||||
@@ -1,26 +1,111 @@
|
||||
<!--- Booking Items -->
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
|
||||
<% @i = 0 %>
|
||||
<% @booking.each do |booking| %>
|
||||
<div class="card">
|
||||
<div class="card-block">
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.item_name %>
|
||||
</h4>
|
||||
<p class="card-text">Medium, Fries, Salad
|
||||
</p>
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<button id="#id" class="btn btn-primary btn-lg btn-block">COMPLETE</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!--- end of Items-->
|
||||
</div>
|
||||
<div class="card-columns" style="padding-top:10px">
|
||||
|
||||
<% @i = 0 %>
|
||||
<% @booking.each do |booking| %>
|
||||
<div class="card booking_click" data-ref="<%= api_booking_path booking.id%>" id="booking_block">
|
||||
<div class="card-block" id="card-block" style="width:100%;">
|
||||
<h4 class="card-title">
|
||||
<%= @i += 1 %> . <%= booking.dining_facility.name %>
|
||||
- <%= booking.id %>
|
||||
</h4>
|
||||
<!-- <p class="card-text">Medium, Fries, Salad</p> -->
|
||||
<p class="card-text">
|
||||
<small class="text-muted">
|
||||
Order at <%= booking.checkin_at.strftime("%H,%m") %>, <%= booking.checkin_by %>
|
||||
</small>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<div class="row">
|
||||
<div class="col-md-6">
|
||||
<button id="#id" class="btn btn-primary btn-sm btn-block">ASSIGN</button>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<button id="cancel" data-ref="<%= booking.id%>" class="btn btn-danger cancel btn-sm btn-block">CANCLE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<!--- end of Items-->
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
$(function(){
|
||||
|
||||
$(".booking_click").on("click", function(){
|
||||
$(".summary-items tbody tr").remove();
|
||||
var url = $(this).attr('data-ref');
|
||||
show_details(url);
|
||||
});
|
||||
|
||||
$('.cancel').click(function(e){
|
||||
var booking = $('#cancel').attr('data-booking-id');
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: "api/update_booking",
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
/*$.getJSON(update_booking_url,{booking: booking, type: "cancel"}, function(data) {
|
||||
if(data.status == 'ok'){
|
||||
|
||||
|
||||
showMessage('Order set has delivered!');
|
||||
}
|
||||
else{
|
||||
if(data.status == false){
|
||||
clear_storage();
|
||||
window.location.href = data.url;
|
||||
}
|
||||
showMessage('Order record not found');
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
function show_details(url_item){
|
||||
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: url_item,
|
||||
data: {},
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
item_data = data.order_items;
|
||||
//console.log(item_data.length);
|
||||
|
||||
$("#table").text(data.table_name)
|
||||
$("#order_at").text(data.checkin_at)
|
||||
$("#order_by").text(data.checkin_by)
|
||||
|
||||
for(var field in item_data) {
|
||||
if (item_data[field].item_name){
|
||||
var price = parseFloat(item_data[field].price).toFixed(2);
|
||||
|
||||
row = "<tr>"
|
||||
+'<td style="width:33%; text-align:left">' + item_data[field].item_name +'</td>'
|
||||
+'<td style="width:33%; text-align:center">' + item_data[field].qty + '</td>'
|
||||
+'<td style="width:33%; text-align:right">' + price + '</td>'
|
||||
+'</tr>';
|
||||
}
|
||||
$(".summary-items tbody").append(row);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
</script>
|
||||
@@ -8,7 +8,7 @@
|
||||
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Queue <span class="badge badge-pill badge-default">2000</span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @count %></span></a>
|
||||
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Bookings <span class="badge badge-pill badge-default"><%= @booking.count %></span></a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Customers</a>
|
||||
@@ -47,51 +47,47 @@
|
||||
<div class="card-header">
|
||||
<div id="order-title"><strong>ORDER DETAILS</strong> - Table 4</div>
|
||||
</div>
|
||||
<div id="station"></div>
|
||||
<div class="card-block">
|
||||
<div class="card-title">
|
||||
<table class="table">
|
||||
<table class="table" >
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:33%; text-align:left">Order By</th>
|
||||
<th style="width:33%; text-align:right">Order At</td>
|
||||
<th style="width:33%; text-align:center;">Order At</td>
|
||||
<th style="width:33%; text-align:right">Customer</td>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:33%; text-align:left">Kyaw Lwin</td>
|
||||
<td style="width:33%; text-align:right">20/04/17 9:30PM</td>
|
||||
<td style="width:33%; text-align:right">John Smith</td>
|
||||
<tr id="">
|
||||
<td style="width:33%; text-align:left" id="order_by"></td>
|
||||
<td style="width:33%; text-align:center" id="order_at"></td>
|
||||
<td style="width:33%; text-align:right" id="customer"></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<tr id="">
|
||||
<td><strong>Table/Room</strong></td>
|
||||
<td colspan="2">Table 4</td>
|
||||
<td colspan="2" style="text-align:left" id="table"></td>
|
||||
|
||||
</tr>
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
<table class="table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th style="width:80%; text-align:left">Items</th>
|
||||
<th style="width:20%; text-align:right">QTY</td>
|
||||
<th style="width:33%; text-align:left">Items</th>
|
||||
<th style="width:33%; text-align:center">Qty</th>
|
||||
<th style="width:33%; text-align:right">Price</td>
|
||||
</tr>
|
||||
</thead>
|
||||
</table>
|
||||
|
||||
</div>
|
||||
<div class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
||||
<table class="table">
|
||||
<table class="table summary-items">
|
||||
<tbody>
|
||||
<tr>
|
||||
<td style="width:80%; text-align:left">
|
||||
Menu Items Name <br/>
|
||||
Less Sweet, No MSG
|
||||
</td>
|
||||
<td style="width:20%; text-align:right">
|
||||
5
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
|
||||
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -35,14 +35,20 @@ Rails.application.routes.draw do
|
||||
post "bill/:booking_id" => "bill#create"
|
||||
post "move" => "move#create"
|
||||
|
||||
|
||||
#Order Controller
|
||||
resources :orders, only: [:create, :show, :update] do
|
||||
|
||||
post "bill" => "bill#create"
|
||||
|
||||
end
|
||||
|
||||
#Current active bookings
|
||||
resources :bookings, only: [:index, :show, :create, :update]
|
||||
resources :customers, only: [:index, :show, :create, :update]
|
||||
|
||||
get "update_booking" , to: "bookings#update_booking", as: "update_booking"
|
||||
|
||||
#Generating Invoice and making payments - output render @sale
|
||||
resources :invoices, only: [:index, :show, :create, :update, :destroy ] do
|
||||
resources :sale_items, only:[:create, :update, :destroy]
|
||||
|
||||
Reference in New Issue
Block a user