Sale Save
This commit is contained in:
@@ -1,11 +1,18 @@
|
|||||||
class Origami::HomeController < BaseOrigamiController
|
class Origami::HomeController < BaseOrigamiController
|
||||||
def index
|
def index
|
||||||
@order_table = Order.get_order_table()
|
@booking_orders = Order.get_booking_order_table()
|
||||||
@order_rooms = Order.get_order_rooms()
|
@booking_rooms = Order.get_booking_order_rooms()
|
||||||
@orders = Order.get_orders()
|
@orders = Order.get_orders()
|
||||||
end
|
end
|
||||||
def show
|
def show
|
||||||
str = []
|
str = []
|
||||||
|
if !params[:sale_id].nil?
|
||||||
|
@order_details = SaleItem.get_order_items_details(params[:sale_id])
|
||||||
|
@order_details.each do |ord_detail|
|
||||||
|
str.push(ord_detail)
|
||||||
|
end
|
||||||
|
render :json => str.to_json
|
||||||
|
else
|
||||||
@order_details = OrderItem.get_order_items_details(params[:order_id])
|
@order_details = OrderItem.get_order_items_details(params[:order_id])
|
||||||
@order_details.each do |ord_detail|
|
@order_details.each do |ord_detail|
|
||||||
str.push(ord_detail)
|
str.push(ord_detail)
|
||||||
@@ -13,3 +20,4 @@ class Origami::HomeController < BaseOrigamiController
|
|||||||
render :json => str.to_json
|
render :json => str.to_json
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
class Origami::RequestBillsController < BaseOrigamiController
|
class Origami::RequestBillsController < BaseOrigamiController
|
||||||
def show
|
def show
|
||||||
@sale = Sale.new
|
@sale = Sale.new
|
||||||
check_order = Order.find_by_id(params[:id])
|
booking_id = params[:id]
|
||||||
if check_order
|
check_booking = Booking.find_by_id(booking_id)
|
||||||
@order_details = OrderItem.get_order_items_details(check_order.id)
|
if check_booking.sale_id.nil?
|
||||||
@order_details = OrderItem.get_order_items_details(check_order.id)
|
#check if it doesn't exist
|
||||||
@status, @sale_id = @sale.generate_invoice_from_order(check_order.id, nil,current_login_employee.name)
|
@status = @sale.generate_invoice_from_booking(check_booking.id,current_login_employee.name)
|
||||||
@sale_data = Sale.find_by_id(@sale_id)
|
@sale_data = Sale.find_by_id(check_booking.sale_id)
|
||||||
@sale_items = SaleItem.where("sale_id=?",@sale_id)
|
@sale_items = SaleItem.where("sale_id=?",check_booking.sale_id)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -193,7 +193,7 @@ class Order < ApplicationRecord
|
|||||||
# Count number of different items
|
# Count number of different items
|
||||||
self.item_count = self.order_items.item_count
|
self.item_count = self.order_items.item_count
|
||||||
self.quantity_count = quantity_count
|
self.quantity_count = quantity_count
|
||||||
# Counter number of quantity
|
# Counter number of quantityf
|
||||||
end
|
end
|
||||||
|
|
||||||
#Process order items and send to order queue
|
#Process order items and send to order queue
|
||||||
@@ -203,38 +203,48 @@ class Order < ApplicationRecord
|
|||||||
end
|
end
|
||||||
|
|
||||||
#Origami: Cashier : to view order type Table
|
#Origami: Cashier : to view order type Table
|
||||||
def self.get_order_table
|
def self.get_booking_order_table
|
||||||
order_table = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
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")
|
||||||
order_items.id as order_items_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.order_id = orders.id
|
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||||
left join bookings on bookings.id = booking_orders.id
|
.joins("left join orders on orders.id = booking_orders.order_id")
|
||||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
.joins("left join sale_orders on sale_orders.order_id = orders.id")
|
||||||
left join order_items on order_items.order_id = orders.id")
|
.joins("left join sales on sales.id = sale_orders.sale_id")
|
||||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,"dine_in",true)
|
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::TABLE_TYPE,true)
|
||||||
.group("orders.id")
|
.group("bookings.id")
|
||||||
end
|
end
|
||||||
#Origami: Cashier : to view order type Room
|
#Origami: Cashier : to view order type Room
|
||||||
def self.get_order_rooms
|
def self.get_booking_order_rooms
|
||||||
order_rooms = Order.select("orders.id as order_id,sum(order_items.qty*order_items.price) as total_price,
|
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")
|
||||||
order_items.id as order_items_id,dining_facilities.name as room_name")
|
.joins("left join booking_orders on booking_orders.booking_id = bookings.id")
|
||||||
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
.joins("left join dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||||
left join bookings on bookings.id = booking_orders.id
|
.joins("left join orders on orders.id = booking_orders.order_id")
|
||||||
left join dining_facilities on dining_facilities.id = bookings.dining_facility_id
|
.joins("left join sale_orders on sale_orders.order_id = orders.id")
|
||||||
left join order_items on order_items.order_id = orders.id")
|
.joins("left join sales on sales.id = sale_orders.sale_id")
|
||||||
.where("dining_facilities.type=? and orders.order_type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,"dine_in",true)
|
.where("booking_orders.order_id IS NOT NULL and dining_facilities.type=? and dining_facilities.is_active=?",DiningFacility::ROOM_TYPE,true)
|
||||||
.group("orders.id")
|
.group("bookings.id")
|
||||||
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,sum(order_items.qty*order_items.price) as total_price,
|
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")
|
||||||
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
|
.joins("left join booking_orders on booking_orders.order_id = orders.id
|
||||||
left join bookings on bookings.id = booking_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 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.id
|
||||||
|
left join sale_orders on sale_orders.order_id = orders.id
|
||||||
|
left join sales on sales.id = sale_orders.sale_id")
|
||||||
.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.id")
|
||||||
|
|
||||||
|
# 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 dining_facilities on dining_facilities.id = bookings.dining_facility_id")
|
||||||
|
# .joins("left join orders on orders.id = booking_orders.order_id")
|
||||||
|
# .joins("left join sale_orders on sale_orders.order_id = orders.id")
|
||||||
|
# .joins("left join sales on sales.id = sale_orders.sale_id")
|
||||||
|
# .where("booking_orders.order_id IS NOT NULL and dining_facilities.is_active=? and orders.date between ? and ?",true,from,to)
|
||||||
|
# .group("orders.id")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -34,9 +34,17 @@ class OrderItem < ApplicationRecord
|
|||||||
|
|
||||||
end
|
end
|
||||||
#Origami : Cashier : to show order items details
|
#Origami : Cashier : to show order items details
|
||||||
def self.get_order_items_details(order_id)
|
def self.get_order_items_details(booking_id)
|
||||||
|
booking_orders = BookingOrder.where("booking_id=?",booking_id)
|
||||||
|
if booking_orders
|
||||||
|
booking_orders.each do |book_order|
|
||||||
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.id = order_items.order_id")
|
||||||
.where("order_items.order_id=?",order_id)
|
.where("order_items.order_id=?",book_order.order_id)
|
||||||
|
return order_details
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -20,9 +20,9 @@ class Sale < ApplicationRecord
|
|||||||
#get all order attached to this booking and combine into 1 invoice
|
#get all order attached to this booking and combine into 1 invoice
|
||||||
booking.booking_orders.each do |order|
|
booking.booking_orders.each do |order|
|
||||||
if booking.sale_id
|
if booking.sale_id
|
||||||
status, sale_id = generate_invoice_from_order(order.order_id, nil, requested_by)
|
status, sale_id = generate_invoice_from_order(order.order_id, nil, booking, requested_by)
|
||||||
else
|
else
|
||||||
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, requested_by)
|
status, sale_id = generate_invoice_from_order(order.order_id, booking.sale_id, booking, requested_by)
|
||||||
end
|
end
|
||||||
booking.sale_id = sale_id
|
booking.sale_id = sale_id
|
||||||
end
|
end
|
||||||
@@ -31,7 +31,7 @@ class Sale < ApplicationRecord
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def generate_invoice_from_order (order_id, sale_id, requested_by)
|
def generate_invoice_from_order (order_id, sale_id, booking, requested_by)
|
||||||
taxable = true
|
taxable = true
|
||||||
#if sale_id is exsit and validate
|
#if sale_id is exsit and validate
|
||||||
#add order to that invoice
|
#add order to that invoice
|
||||||
@@ -73,6 +73,11 @@ class Sale < ApplicationRecord
|
|||||||
|
|
||||||
#Update the order items that is billed
|
#Update the order items that is billed
|
||||||
order.update_items_status_to_billed(nil)
|
order.update_items_status_to_billed(nil)
|
||||||
|
order.status = "billed"
|
||||||
|
order.save
|
||||||
|
|
||||||
|
booking.sale_id = self.id
|
||||||
|
booking.save
|
||||||
|
|
||||||
return true, self.id
|
return true, self.id
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,4 +4,18 @@ class SaleItem < ApplicationRecord
|
|||||||
#compute items - discount, tax, price_change
|
#compute items - discount, tax, price_change
|
||||||
def compute_item
|
def compute_item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.get_order_items_details(sale_id)
|
||||||
|
sale_orders = SaleOrder.where("sale_id=?",sale_id)
|
||||||
|
if sale_orders
|
||||||
|
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")
|
||||||
|
.joins("left join sales on sales.id = sale_items.sale_id")
|
||||||
|
.where("sale_items.sale_id=?",sale_order.sale_id)
|
||||||
|
return order_details
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,34 +22,56 @@
|
|||||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
<div class="tab-pane active" id="tables" role="tabpanel">
|
||||||
<!--- Booking Items -->
|
<!--- Booking Items -->
|
||||||
<div class="card-columns" style="padding-top:10px">
|
<div class="card-columns" style="padding-top:10px">
|
||||||
<% if @order_table %>
|
<% if @booking_orders %>
|
||||||
<% @order_table.each do |order_table| %>
|
<% @booking_orders.each do |booking_order| %>
|
||||||
<div class="card" id="table-order-<%=order_table.order_id%>" onclick="callOrderDetails('<%=order_table.order_id%>')">
|
<% if !booking_order.order_status = 'new'%>
|
||||||
|
<div style="background-color: red;color: white;" class="card" id="table-order-<%=booking_order.sale_id%>" onclick="callOrderDetails('sale_<%=booking_order.sale_id%>')">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<h4 class="card-title"><span id="table-name-<%=order_table.order_id%>" class="table-name"><%=order_table.table_name%></span></h4>
|
<h4 class="card-title">
|
||||||
<p class="card-text"><%=order_table.total_price%></p>
|
<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>Order Status : <%=booking_order.order_status %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="card" id="table-order-<%=booking_order.id%>" onclick="callOrderDetails('order_<%=booking_order.id%>')">
|
||||||
|
<div class="card-block">
|
||||||
|
<h4 class="card-title"><span id="table-name-<%=booking_order.id%>" class="table-name"><%=booking_order.table_name%></span></h4>
|
||||||
|
<span>Order Status : <%=booking_order.order_status %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<%end %>
|
<%end %>
|
||||||
|
<%end %>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<!-- Panel 1 - Tables - End -->
|
<!-- Panel 1 - Tables - End -->
|
||||||
<!-- Panel 2 - Rooms -->
|
<!-- Panel 2 - Rooms -->
|
||||||
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
||||||
<!--- Booking Items -->
|
<!--- Booking Items -->
|
||||||
<div class="card-columns" style="padding-top:10px">
|
<div class="card-columns" style="padding-top:10px">
|
||||||
<% @order_rooms.each do |order_room| %>
|
<% if @booking_rooms %>
|
||||||
<div class="card" id="table-order-<%=order_room.order_id%>" onclick="callOrderDetails('<%=order_room.order_id%>')">
|
<% @booking_rooms.each do |booking_room| %>
|
||||||
|
<% 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 class="card-block">
|
<div class="card-block">
|
||||||
<% tablename = order_room.room_name%>
|
<h4 class="card-title">
|
||||||
<h4 class="card-title"><span id="table-name-<%=order_room.order_id%>" class="table-name"><%=order_room.room_name%></span></h4>
|
<span id="table-name-<%=booking_room.id%>" class="table-name"><%=booking_room.room_name%></span></h4>
|
||||||
<p class="card-text"><%=order_room.total_price%></p>
|
<span>Receipt No : <%=booking_room.receipt_no%></span><br/>
|
||||||
|
<span>Order Status : <%=booking_room.order_status %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="card" id="table-order-<%=booking_room.id%>" onclick="callOrderDetails('order_<%=booking_room.id%>')">
|
||||||
|
<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> \
|
||||||
|
<span>Order Status : <%=booking_room.order_status %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%end %>
|
||||||
|
<%end %>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -60,15 +82,29 @@
|
|||||||
|
|
||||||
<!--- Booking Items -->
|
<!--- Booking Items -->
|
||||||
<div class="card-columns" style="padding-top:10px">
|
<div class="card-columns" style="padding-top:10px">
|
||||||
|
<% if @orders %>
|
||||||
<% @orders.each do |order| %>
|
<% @orders.each do |order| %>
|
||||||
<div class="card" id="table-order-<%=order.order_id%>" onclick="callOrderDetails('<%=order.order_id%>')">
|
<% if !order.order_status = 'new'%>
|
||||||
|
<div style="background-color: green;color: white;" class="card" id="table-order-<%=order.order_id%>" onclick="callOrderDetails('sale_<%=order.order_id%>')">
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<h4 class="card-title"><span id="table-name-<%=order.order_id%>" class="table-name"><%=order.table_or_room_name%></span></h4>
|
<h4 class="card-title">
|
||||||
<p class="card-text"><%=order.total_price%></p>
|
<span id="table-name-<%=order.order_id%>" class="table-name">Order No:<%=order.order_id%></span></h4>
|
||||||
|
<span>Receipt No : <%=order.receipt_no%></span><br/>
|
||||||
|
<span>Order Status : <%=order.order_status %></span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<% else %>
|
||||||
|
<div class="card" id="table-order-<%=order.order_id%>" onclick="callOrderDetails('order_<%=order.order_id%>')">
|
||||||
|
<div class="card-block">
|
||||||
|
<h4 class="card-title"><span id="table-name-<%=order.order_id%>" class="table-name">Order No:<%=order.order_id%></span></h4>
|
||||||
|
<span>Order Status : <%=order.order_status %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
<%end %>
|
||||||
|
<%end %>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
@@ -83,7 +119,9 @@
|
|||||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
<div class="col-lg-5 col-md-5 col-sm-3">
|
||||||
<div class="card" >
|
<div class="card" >
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div id="order-title"><strong>ORDER DETAILS</strong> <span id="order-detail-header"></span></div>
|
<div id="order-title"><strong><span id="receipt-no">ORDER DETAILS</span></strong>
|
||||||
|
<strong><span id ="receipt-date" style="margin-left: 20%"></span></strong></div><br/>
|
||||||
|
<div ><strong><span id="cashier-name"></span></strong><strong><span style="margin-left: 36%" id="order-detail-header"></span></strong></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
@@ -122,6 +160,18 @@
|
|||||||
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
|
<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>
|
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width:80%; text-align:left; border-top:none"><strong><span id="discount-header"></strong></td>
|
||||||
|
<td style="width:20%; text-align:right; border-top:none"><strong><span id="discount_amount"></span></strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width:80%; text-align:left; border-top:none"><strong><span id="tax-header"></strong></td>
|
||||||
|
<td style="width:20%; text-align:right; border-top:none"><strong><span id="tax_amount"></span></strong></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td style="width:80%; text-align:left; border-top:none"><strong><span id="grand-total-header"></strong></td>
|
||||||
|
<td style="width:20%; text-align:right; border-top:none"><strong><span id="grand_total_amount"></span></strong></td>
|
||||||
|
</tr>
|
||||||
</tfooter>
|
</tfooter>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
@@ -152,9 +202,22 @@
|
|||||||
var old_table_name = ""
|
var old_table_name = ""
|
||||||
var table_or_order_id = 0
|
var table_or_order_id = 0
|
||||||
|
|
||||||
function callOrderDetails(order_id){
|
function callOrderDetails(sale_order_id){
|
||||||
|
var order_id = 0
|
||||||
|
var data_val = ""
|
||||||
|
sale_order = sale_order_id.split("_")[0]
|
||||||
|
if (sale_order == 'sale') {
|
||||||
|
order_id = sale_order_id.split("_")[1]
|
||||||
|
url = "origami/"+sale_order_id.split("_")[1]
|
||||||
|
data_val = { sale_id: sale_order_id.split("_")[1]}
|
||||||
|
|
||||||
|
}else{
|
||||||
|
order_id = sale_order_id.split("_")[1]
|
||||||
|
url = "origami/"+order_id
|
||||||
|
data_val = { order_id: sale_order_id.split("_")[1]}
|
||||||
|
|
||||||
|
}
|
||||||
table_or_order_id = order_id
|
table_or_order_id = order_id
|
||||||
$("#test").html(order_id)
|
|
||||||
var tbody = ""
|
var tbody = ""
|
||||||
$("#append-table").html("")
|
$("#append-table").html("")
|
||||||
if (old_order_id != order_id){
|
if (old_order_id != order_id){
|
||||||
@@ -163,30 +226,70 @@ function callOrderDetails(order_id){
|
|||||||
old_order_id = order_id
|
old_order_id = order_id
|
||||||
}
|
}
|
||||||
$("#order-detail-header").html("")
|
$("#order-detail-header").html("")
|
||||||
$("#order-detail-header").append(document.getElementById("table-name-"+order_id).innerHTML)
|
$("#order-detail-header").append("Table Name : "+document.getElementById("table-name-"+order_id).innerHTML)
|
||||||
$("#sub-total").html("")
|
$("#sub-total").html("")
|
||||||
url = "origami/"+order_id
|
|
||||||
$.ajax({type: "GET",
|
$.ajax({type: "GET",
|
||||||
url: url,
|
url: url,
|
||||||
data: { order_id: order_id},
|
data: data_val,
|
||||||
success:function(result){
|
success:function(result){
|
||||||
var sub_total = 0
|
var sub_total = 0
|
||||||
|
var discount_amount = 0
|
||||||
|
var receipt_no = ""
|
||||||
|
var cashier_name = ""
|
||||||
|
var receipt_date = ""
|
||||||
|
var tax_amount = 0
|
||||||
|
var grand_total_amount = 0
|
||||||
|
row = "<tbody>"
|
||||||
for (i = 0; i < result.length; i++) {
|
for (i = 0; i < result.length; i++) {
|
||||||
var data = JSON.stringify(result[i]);
|
var data = JSON.stringify(result[i]);
|
||||||
var parse_data = JSON.parse(data)
|
var parse_data = JSON.parse(data)
|
||||||
sub_total += (parse_data.qty*parse_data.price)
|
sub_total += (parse_data.qty*parse_data.price)
|
||||||
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>'
|
row = '<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-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>'
|
+'<td style="width:20%; text-align:right"><span id="item-total-price">'+(parse_data.qty*parse_data.price)+'</span></td>'
|
||||||
+'</tr></tbody>'
|
+'</tr>>'
|
||||||
tbody += row
|
tbody += row
|
||||||
|
discount_amount = result[i].discount_amount;
|
||||||
|
|
||||||
|
tax_amount = result[i].tax_amount;
|
||||||
|
grand_total_amount = result[i].grand_total_amount;
|
||||||
|
|
||||||
|
receipt_no = result[i].receipt_no;
|
||||||
|
cashier_name = result[i].cashier_name;
|
||||||
|
receipt_date = result[i].receipt_date;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
row = "</tbody>"
|
||||||
$("#append-table").append(tbody)
|
$("#append-table").append(tbody)
|
||||||
$("#sub-total").append((sub_total)+"<br/>")
|
$("#sub-total").append((sub_total)+"<br/>")
|
||||||
|
|
||||||
|
if (discount_amount > 0 ) {
|
||||||
|
$("#discount-header").html("(Discount)")
|
||||||
|
$("#discount_amount").html("("+discount_amount+")")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (tax_amount > 0 ) {
|
||||||
|
$("#tax-header").html("Tax")
|
||||||
|
$("#tax_amount").html(tax_amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (grand_total_amount > 0 ) {
|
||||||
|
$("#grand-total-header").html("Grand Total")
|
||||||
|
$("#grand_total_amount").html(grand_total_amount)
|
||||||
|
}
|
||||||
|
|
||||||
|
if (cashier_name == null){
|
||||||
|
cashier_name = ""
|
||||||
|
}
|
||||||
|
if(receipt_no != null){
|
||||||
|
$("#receipt-no").html("Receipt No : "+receipt_no)
|
||||||
|
}
|
||||||
|
if (receipt_date != null) {
|
||||||
|
$("#receipt-date").html("Receipt Date : "+receipt_date);
|
||||||
|
}
|
||||||
|
if (cashier_name != null) {
|
||||||
|
$("#cashier-name").html("Cashier Name : "+cashier_name);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
error:function(result){
|
error:function(result){
|
||||||
// alert('error');
|
// alert('error');
|
||||||
|
|||||||
@@ -3,7 +3,8 @@
|
|||||||
<div class="card" >
|
<div class="card" >
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div id="order-title">
|
<div id="order-title">
|
||||||
<span><strong>Receipt No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></span>
|
<span><strong>Receipt No : <%=@sale_data.receipt_no rescue ' '%></strong></span>
|
||||||
|
<span style="margin-left: 40%"><strong>Receipt Date : <%=@sale_data.receipt_date rescue '-'%></strong></span>
|
||||||
<span><strong>Table No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></span>
|
<span><strong>Table No</strong> <% if @sale_data%>- <%=@sale_data.receipt_no%><% end %></span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -51,18 +52,21 @@
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
|
<td style="width:80%; text-align:left; border-top:none"><strong>(Discount)</strong></td>
|
||||||
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount%>)</span></strong></td>
|
<td style="width:20%; text-align:right; border-top:none"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<td style="width:80%; text-align:left; border-top:none"><strong>Tax</strong></td>
|
<td style="width:80%; text-align:left; border-top:none"><strong>Tax</strong></td>
|
||||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.total_tax%></span></strong></td>
|
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
<td style="width:80%; text-align:left; border-top:none"><strong>Grand Total</strong></td>
|
<td style="width:80%; text-align:left; border-top:none"><strong>Grand Total</strong></td>
|
||||||
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.grand_total%></span></strong></td>
|
<td style="width:20%; text-align:right; border-top:none"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
|
||||||
</tr>
|
</tr>
|
||||||
</tfooter>
|
</tfooter>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
<div style='text-align:center;margin-top:20px'>
|
||||||
|
<INPUT TYPE="Button" class='btn btn-primary' VALUE="Reprint" onClick="" style='width:120px'/>
|
||||||
|
<INPUT TYPE="Submit" class='btn btn-primary' VALUE="CANCEL" action="origami/index" style='width:120px'/>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user