update origamitable,room query
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
GIT
|
GIT
|
||||||
remote: git://github.com/amatsuda/kaminari.git
|
remote: git://github.com/amatsuda/kaminari.git
|
||||||
revision: c3c853a944cd2bff072ae05e48c563b2c9a29597
|
revision: bc52ae73d41386d344b5d1b18e689e5a988f1a03
|
||||||
branch: master
|
branch: master
|
||||||
specs:
|
specs:
|
||||||
kaminari (1.0.1)
|
kaminari (1.0.1)
|
||||||
@@ -92,7 +92,7 @@ GEM
|
|||||||
railties (>= 3.2, < 5.2)
|
railties (>= 3.2, < 5.2)
|
||||||
globalid (0.4.0)
|
globalid (0.4.0)
|
||||||
activesupport (>= 4.2.0)
|
activesupport (>= 4.2.0)
|
||||||
i18n (0.8.1)
|
i18n (0.8.4)
|
||||||
jbuilder (2.6.4)
|
jbuilder (2.6.4)
|
||||||
activesupport (>= 3.0.0)
|
activesupport (>= 3.0.0)
|
||||||
multi_json (>= 1.2)
|
multi_json (>= 1.2)
|
||||||
@@ -124,7 +124,7 @@ GEM
|
|||||||
ttfunk (~> 1.5)
|
ttfunk (~> 1.5)
|
||||||
prawn-table (0.2.2)
|
prawn-table (0.2.2)
|
||||||
prawn (>= 1.3.0, < 3.0.0)
|
prawn (>= 1.3.0, < 3.0.0)
|
||||||
puma (3.8.2)
|
puma (3.9.1)
|
||||||
rack (2.0.3)
|
rack (2.0.3)
|
||||||
rack-cors (0.4.1)
|
rack-cors (0.4.1)
|
||||||
rack-protection (2.0.0)
|
rack-protection (2.0.0)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
def show
|
def show
|
||||||
str = []
|
str = []
|
||||||
|
|
||||||
if !params[:sale_id].nil?
|
if !params[:sale_id].nil?
|
||||||
@order_details = SaleItem.get_order_items_details(params[:sale_id])
|
@order_details = SaleItem.get_order_items_details(params[:sale_id])
|
||||||
@order_details.each do |ord_detail|
|
@order_details.each do |ord_detail|
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
class Customer < ApplicationRecord
|
class Customer < ApplicationRecord
|
||||||
|
|
||||||
|
#self.primary_key = :customer_id
|
||||||
|
|
||||||
before_create :generate_custom_id
|
before_create :generate_custom_id
|
||||||
has_many :orders
|
has_many :orders
|
||||||
has_many :sales
|
has_many :sales
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
class MenuItem < ApplicationRecord
|
class MenuItem < ApplicationRecord
|
||||||
belongs_to :account
|
#belongs_to :account
|
||||||
belongs_to :menu_category, :optional => true
|
belongs_to :menu_category, :optional => true
|
||||||
has_many :menu_item_instances
|
has_many :menu_item_instances
|
||||||
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
belongs_to :parent, :class_name => "MenuItem", foreign_key: "menu_item_id", :optional => true
|
||||||
|
|||||||
@@ -209,54 +209,63 @@ class Order < ApplicationRecord
|
|||||||
#Origami: Cashier : to view order type Table
|
#Origami: Cashier : to view order type Table
|
||||||
|
|
||||||
def self.get_booking_order_table
|
def self.get_booking_order_table
|
||||||
booking_orders = Booking.select("sales.receipt_no,orders.status as order_status,bookings.id,sales.id as sale_id,dining_facilities.name as table_name")
|
booking_orders = Booking.select("sales.receipt_no,
|
||||||
.joins("left join booking_orders on booking_orders.booking_id = bookings.id")
|
orders.status as order_status,
|
||||||
|
bookings.booking_id,
|
||||||
|
sales.sale_id as sale_id,
|
||||||
|
dining_facilities.name as table_name")
|
||||||
|
.joins("left join booking_orders on booking_orders.booking = bookings.booking_id")
|
||||||
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||||
.joins("left join orders on orders.id = booking_orders.order_id")
|
.joins("left join orders on orders.order_id = booking_orders.order")
|
||||||
.joins("left join sale_orders on sale_orders.order_id = orders.id")
|
.joins("left join sale_orders on sale_orders.order = orders.order_id")
|
||||||
.joins("left join sales on sales.id = sale_orders.sale_id")
|
.joins("left join sales on sales.sale_id = sale_orders.sale")
|
||||||
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
|
.where("booking_orders.order IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
|
||||||
.group("bookings.id")
|
.group("bookings.booking_id")
|
||||||
|
|
||||||
end
|
end
|
||||||
#Origami: Cashier : to view order type Room
|
#Origami: Cashier : to view order type Room
|
||||||
def self.get_booking_order_rooms
|
def self.get_booking_order_rooms
|
||||||
booking_rooms = Booking.select("sales.receipt_no,orders.status as order_status,bookings.id,sales.id as sale_id,dining_facilities.name as room_name")
|
booking_rooms = Booking.select("sales.receipt_no,
|
||||||
.joins("left join booking_orders on booking_orders.booking_id = bookings.id")
|
orders.status as order_status,bookings.booking_id,
|
||||||
|
sales.sale_id as sale_id,
|
||||||
|
dining_facilities.name as room_name")
|
||||||
|
.joins("left join booking_orders on booking_orders.booking = bookings.booking_id")
|
||||||
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||||
.joins("left join orders on orders.id = booking_orders.order_id")
|
.joins("left join orders on orders.order_id = booking_orders.order")
|
||||||
.joins("left join sale_orders on sale_orders.order_id = orders.id")
|
.joins("left join sale_orders on sale_orders.order = orders.order_id")
|
||||||
.joins("left join sales on sales.id = sale_orders.sale_id")
|
.joins("left join sales on sales.sale_id = sale_orders.sale")
|
||||||
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
|
.where("booking_orders.order IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
|
||||||
.group("bookings.id")
|
.group("bookings.booking_id")
|
||||||
|
end
|
||||||
#Origami: Cashier : to view order type Room
|
#Origami: Cashier : to view order type Room
|
||||||
def self.get_order_rooms
|
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_rooms = Order.select("orders.order_id as order_id,
|
||||||
order_items.id as order_items_id,dining_facilities.name as room_name")
|
sum(order_items.qty*order_items.price) as total_price,
|
||||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
order_items.order_items_id as order_items_id,dining_facilities.name as room_name")
|
||||||
left join bookings on bookings.id = booking_orders.id
|
.joins("left join booking_orders on booking_orders.order = orders.order_id
|
||||||
|
left join bookings on bookings.booking_id = booking_orders.booking_order_id
|
||||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||||
left join order_items on order_items.order_id = orders.id")
|
left join order_items on order_items.order_id = orders.order_id")
|
||||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
|
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
|
||||||
.group("orders.id,order_items.id,dining_facilities.name")
|
.group("orders.order_id,order_items.order_items_id,dining_facilities.name")
|
||||||
|
|
||||||
end
|
end
|
||||||
#Origami: Cashier : to view orders
|
#Origami: Cashier : to view orders
|
||||||
def self.get_orders
|
def self.get_orders
|
||||||
from = Time.now.beginning_of_day.utc
|
from = Time.now.beginning_of_day.utc
|
||||||
to = Time.now.end_of_day.utc
|
to = Time.now.end_of_day.utc
|
||||||
orders = Order.select("orders.id as order_id,sales.receipt_no,orders.status as order_status,bookings.id,sales.id as sale_id,dining_facilities.name as table_name")
|
orders = Order.select("orders.order_id as order_id,
|
||||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
sales.receipt_no,orders.status as order_status,bookings.booking_id,
|
||||||
left join bookings on bookings.id = booking_orders.id
|
sales.sale_id as sale_id,dining_facilities.name as table_name")
|
||||||
|
.joins("left join booking_orders on booking_orders.order = orders.order_id
|
||||||
|
left join bookings on bookings.booking_id = booking_orders.booking_order_id
|
||||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
||||||
|
|
||||||
left join order_items on order_items.order_id = orders.id
|
left join order_items on order_items.order_id = orders.order_id
|
||||||
left join sale_orders on sale_orders.order_id = orders.id
|
left join sale_orders on sale_orders.order = orders.order_id
|
||||||
left join sales on sales.id = sale_orders.sale_id")
|
left join sales on sales.sale_id = sale_orders.sale")
|
||||||
|
|
||||||
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
.where("dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||||
.group("orders.id")
|
.group("orders.order_id")
|
||||||
|
|
||||||
# Booking.select("sales.receipt_no,orders.status as order_status,bookings.id,sales.id as sale_id,dining_facilities.name as table_name")
|
# Booking.select("sales.receipt_no,orders.status as order_status,bookings.id,sales.id as sale_id,dining_facilities.name as table_name")
|
||||||
# .joins("left join booking_orders on booking_orders.booking_id = bookings.id")
|
# .joins("left join booking_orders on booking_orders.booking_id = bookings.id")
|
||||||
|
|||||||
@@ -39,18 +39,21 @@ class OrderItem < ApplicationRecord
|
|||||||
#Origami : Cashier : to show order items details
|
#Origami : Cashier : to show order items details
|
||||||
|
|
||||||
def self.get_order_items_details(booking_id)
|
def self.get_order_items_details(booking_id)
|
||||||
booking_orders = BookingOrder.where("booking_id=?",booking_id)
|
booking_orders = BookingOrder.where("booking=?",booking_id)
|
||||||
|
puts booking_orders.to_json
|
||||||
if booking_orders
|
if booking_orders
|
||||||
booking_orders.each do |book_order|
|
booking_orders.each do |book_order|
|
||||||
|
puts "booooooooo"
|
||||||
|
puts book_order.booking_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")
|
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")
|
.joins("left join orders on orders.order_id = order_items.order_id")
|
||||||
.where("order_items.order_id=?",book_order.order_id)
|
.where("order_items.order_id=?",book_order.order)
|
||||||
return order_details
|
return order_details
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
|
|||||||
@@ -10,18 +10,19 @@ class SaleItem < ApplicationRecord
|
|||||||
|
|
||||||
|
|
||||||
def self.get_order_items_details(sale_id)
|
def self.get_order_items_details(sale_id)
|
||||||
sale_orders = SaleOrder.where("sale_id=?",sale_id)
|
sale_orders = SaleOrder.where("sale=?",sale_id)
|
||||||
if sale_orders
|
if sale_orders
|
||||||
sale_orders.each do |sale_order|
|
sale_orders.each do |sale_order|
|
||||||
order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
|
order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,sales.cashier_name,sales.receipt_no,sale_items.product_name as item_name,sale_items.qty,sale_items.price,sale_items.unit_price as total_price")
|
||||||
.joins("left join sales on sales.id = sale_items.sale_id")
|
.joins("left join sales on sales.sale_id = sale_items.sale_id")
|
||||||
.where("sale_items.sale_id=?",sale_order.sale_id)
|
.where("sale_items.sale_id=?",sale_order.sale)
|
||||||
return order_details
|
return order_details
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
def generate_custom_id
|
def generate_custom_id
|
||||||
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
self.sale_item_id = SeedGenerator.generate_id(self.class.name, "SLI")
|
||||||
|
|||||||
@@ -14,9 +14,9 @@ class SeedGenerator < ApplicationRecord
|
|||||||
seed.current = current_no
|
seed.current = current_no
|
||||||
seed.save
|
seed.save
|
||||||
end
|
end
|
||||||
padding_len = 16 - prefix.len
|
padding_len = 12 - prefix.length
|
||||||
|
|
||||||
return prefix +"-"+ seed.current.to_s.to_s.rjust((16-prefix.length)+1,'0')
|
return prefix +"-"+ seed.current.to_s.to_s.rjust((12-prefix.length)+1,'0')
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.new_receipt_no
|
def self.new_receipt_no
|
||||||
|
|||||||
@@ -31,13 +31,15 @@
|
|||||||
<span id="table-name-<%=booking_order.sale_id%>" class="table-name"><%=booking_order.table_name%></span></h4>
|
<span id="table-name-<%=booking_order.sale_id%>" class="table-name"><%=booking_order.table_name%></span></h4>
|
||||||
<span>Receipt No : <%=booking_order.receipt_no%></span><br/>
|
<span>Receipt No : <%=booking_order.receipt_no%></span><br/>
|
||||||
<span>Order Status : <%=booking_order.order_status %></span>
|
<span>Order Status : <%=booking_order.order_status %></span>
|
||||||
|
<span>sale_<%=booking_order.sale_id %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="card" id="table-order-<%=booking_order.id%>" onclick="callOrderDetails('order_<%=booking_order.id%>')">
|
<div class="card" id="table-order-<%=booking_order.booking_id%>" onclick="callOrderDetails('order_<%=booking_order.booking_id%>')">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<h4 class="card-title"><span id="table-name-<%=booking_order.id%>" class="table-name"><%=booking_order.table_name%></span></h4>
|
<h4 class="card-title"><span id="table-name-<%=booking_order.booking_id%>" class="table-name"><%=booking_order.table_name%></span></h4>
|
||||||
<span>Order Status : <%=booking_order.order_status %></span>
|
<span>Order Status : <%=booking_order.order_status %></span>
|
||||||
|
<span>sale_<%=booking_order.sale_id %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
@@ -53,18 +55,18 @@
|
|||||||
<% if @booking_rooms %>
|
<% if @booking_rooms %>
|
||||||
<% @booking_rooms.each do |booking_room| %>
|
<% @booking_rooms.each do |booking_room| %>
|
||||||
<% if !booking_room.order_status = 'new'%>
|
<% if !booking_room.order_status = 'new'%>
|
||||||
<div style="background-color: red;color: white;" class="card" id="table-order-<%=booking_room.id%>" onclick="callOrderDetails('sale_<%=booking_room.id%>')">
|
<div style="background-color: red;color: white;" class="card" id="table-order-<%=booking_room.booking_id%>" onclick="callOrderDetails('sale_<%=booking_room.booking_id%>')">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<h4 class="card-title">
|
<h4 class="card-title">
|
||||||
<span id="table-name-<%=booking_room.id%>" class="table-name"><%=booking_room.room_name%></span></h4>
|
<span id="table-name-<%=booking_room.booking_id%>" class="table-name"><%=booking_room.room_name%></span></h4>
|
||||||
<span>Receipt No : <%=booking_room.receipt_no%></span><br/>
|
<span>Receipt No : <%=booking_room.receipt_no%></span><br/>
|
||||||
<span>Order Status : <%=booking_room.order_status %></span>
|
<span>Order Status : <%=booking_room.order_status %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% else %>
|
<% else %>
|
||||||
<div class="card" id="table-order-<%=booking_room.id%>" onclick="callOrderDetails('order_<%=booking_room.id%>')">
|
<div class="card" id="table-order-<%=booking_room.booking_id%>" onclick="callOrderDetails('order_<%=booking_room.booking_id%>')">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<h4 class="card-title"><span id="table-name-<%=booking_room.id%>" class="table-name"><%=booking_room.room_name%>ddd</span></h4> \
|
<h4 class="card-title"><span id="table-name-<%=booking_room.booking_id%>" class="table-name"><%=booking_room.room_name%>ddd</span></h4> \
|
||||||
<span>Order Status : <%=booking_room.order_status %></span>
|
<span>Order Status : <%=booking_room.order_status %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -203,21 +205,26 @@
|
|||||||
var table_or_order_id = 0
|
var table_or_order_id = 0
|
||||||
|
|
||||||
function callOrderDetails(sale_order_id){
|
function callOrderDetails(sale_order_id){
|
||||||
|
|
||||||
var order_id = 0
|
var order_id = 0
|
||||||
var data_val = ""
|
var data_val = ""
|
||||||
sale_order = sale_order_id.split("_")[0]
|
sale_order = sale_order_id.split("_")[0]
|
||||||
if (sale_order == 'sale') {
|
if (sale_order == 'sale') {
|
||||||
order_id = sale_order_id.split("_")[1]
|
order_id = sale_order_id.split("_")[1]
|
||||||
url = "origami/"+sale_order_id.split("_")[1]
|
url = "origami/"+sale_order_id.split("_")[1]
|
||||||
|
|
||||||
data_val = { sale_id: sale_order_id.split("_")[1]}
|
data_val = { sale_id: sale_order_id.split("_")[1]}
|
||||||
|
|
||||||
}else{
|
}else{
|
||||||
order_id = sale_order_id.split("_")[1]
|
order_id = sale_order_id.split("_")[1]
|
||||||
url = "origami/"+order_id
|
url = "origami/"+order_id
|
||||||
|
|
||||||
data_val = { order_id: sale_order_id.split("_")[1]}
|
data_val = { order_id: sale_order_id.split("_")[1]}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
table_or_order_id = order_id
|
table_or_order_id = order_id
|
||||||
|
|
||||||
var tbody = ""
|
var tbody = ""
|
||||||
$("#append-table").html("")
|
$("#append-table").html("")
|
||||||
if (old_order_id != order_id){
|
if (old_order_id != order_id){
|
||||||
@@ -230,8 +237,10 @@ function callOrderDetails(sale_order_id){
|
|||||||
$("#sub-total").html("")
|
$("#sub-total").html("")
|
||||||
$.ajax({type: "GET",
|
$.ajax({type: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
|
|
||||||
data: data_val,
|
data: data_val,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
|
|
||||||
var sub_total = 0
|
var sub_total = 0
|
||||||
var discount_amount = 0
|
var discount_amount = 0
|
||||||
var receipt_no = ""
|
var receipt_no = ""
|
||||||
|
|||||||
Reference in New Issue
Block a user