This commit is contained in:
Nweni
2017-06-20 18:59:34 +06:30
parent bdb42daad7
commit a9e1d8c3d1
20 changed files with 970 additions and 149 deletions

View File

@@ -4,21 +4,39 @@ class Origami::HomeController < BaseOrigamiController
def index def index
@tables = Table.all.active.order('status desc') @tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc') @rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
end end
# origami table detail
def show def show
@tables = Table.all.active.order('status desc') @tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc') @rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
@status_order = ""
@dining.bookings.each do |booking| @dining.bookings.each do |booking|
if booking.sale_id.nil? if booking.sale_id.nil?
booking_orders = booking.booking_orders @order_items = Array.new
booking_orders.each do |booking_order| booking.booking_orders.each do |booking_order|
@order = booking_order.order order = Order.find(booking_order.order_id)
@obj_order = order
@date = order.created_at
order.order_items.each do |item|
@order_items.push(item)
end end
@status = 'order' end
@status_order = 'order'
else else
@status = 'sale' sale = Sale.find(booking.sale_id)
@obj = Sale.find(booking.sale_id) if sale.sale_status != "completed"
if @status_order == 'order'
@status_order = 'sale'
end
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
end
end end
end end
end end

View File

@@ -0,0 +1,10 @@
class Origami::OrdersController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
@order = Order.find(params[:order_id])
end
end

View File

@@ -4,8 +4,9 @@ class Origami::RequestBillsController < BaseOrigamiController
@sale = Sale.new @sale = Sale.new
sale_order=SaleOrder.new sale_order=SaleOrder.new
booking_id = params[:id] order_id = params[:id] # order_id
check_booking = Booking.find_by_booking_id(booking_id) bk_order = BookingOrder.find_by_order_id(order_id)
check_booking = Booking.find_by_booking_id(bk_order.booking_id)
if check_booking.sale_id.nil? if check_booking.sale_id.nil?
# Create Sale if it doesn't exist # Create Sale if it doesn't exist
puts "current_login_employee" puts "current_login_employee"
@@ -32,6 +33,5 @@ class Origami::RequestBillsController < BaseOrigamiController
printer = Printer::ReceiptPrinter.new(print_settings) printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total) printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer.name, food_total, beverage_total)
redirect_to origami_path(@sale_data.sale_id)
end end
end end

View File

@@ -0,0 +1,32 @@
class Origami::RoomsController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
@room = DiningFacility.find(params[:room_id])
@room.bookings.each do |booking|
if booking.sale_id.nil?
@order_items = Array.new
booking.booking_orders.each do |booking_order|
order = Order.find(booking_order.order_id)
@obj = order
order.order_items.each do |item|
@order_items.push(item)
end
end
@status = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed"
@status = 'sale'
@obj = sale
end
end
end
end
end

View File

@@ -0,0 +1,10 @@
class Origami::SalesController < BaseOrigamiController
def show
@tables = Table.all.active.order('status desc')
@rooms = Room.all.active.order('status desc')
@complete = Sale.all
@orders = Order.all.order('date desc')
@sale = Sale.find(params[:sale_id])
end
end

View File

@@ -11,7 +11,7 @@ class Order < ApplicationRecord
#internal references attributes for business logic control #internal references attributes for business logic control
attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id attr_accessor :items, :guest, :table_id, :new_booking, :booking_type, :employee_name, :booking_id
scope :active, -> { where("date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
#Main Controller method to create new order - validate all inputs and generate new order #Main Controller method to create new order - validate all inputs and generate new order
# order_item : { # order_item : {
# order_item_code : "", # order_item_code : "",

View File

@@ -1,4 +1,4 @@
class Room < DiningFacility class Room < DiningFacility
# has_many :bookings, :foreign_key => 'dining_facility_id' has_many :bookings, :foreign_key => 'dining_facility_id'
end end

View File

@@ -15,6 +15,7 @@ class Sale < ApplicationRecord
has_many :bookings has_many :bookings
scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") } scope :open_invoices, -> { where("sale_status = 'new' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
scope :complete_sale, -> { where("sale_status = 'completed' and receipt_date BETWEEN '#{DateTime.now.utc.end_of_day}' AND '#{DateTime.now.utc.beginning_of_day}'") }
def generate_invoice_from_booking(booking_id, requested_by) def generate_invoice_from_booking(booking_id, requested_by)
booking = Booking.find(booking_id) booking = Booking.find(booking_id)

View File

@@ -238,10 +238,17 @@ class SalePayment < ApplicationRecord
end end
def table_update_status(sale_obj) def table_update_status(sale_obj)
status = true
booking = Booking.find_by_sale_id(sale_obj.id) booking = Booking.find_by_sale_id(sale_obj.id)
if booking if booking
table = DiningFacility.find(booking.dining_facility_id) table = DiningFacility.find(booking.dining_facility_id)
if table bookings = table.bookings
bookings.each do |tablebooking|
if tablebooking.sale.sale_status != 'completed'
status = false
end
end
if status
table.status = "available" table.status = "available"
table.save table.save
end end

View File

@@ -1,4 +1,4 @@
class Table < DiningFacility class Table < DiningFacility
has_many :dining_ins has_many :dining_ins
# has_many :bookings, :foreign_key => 'dining_facility_id' has_many :bookings, :foreign_key => 'dining_facility_id'
end end

View File

@@ -1,3 +1,2 @@
class TableBooking < Booking class TableBooking < Booking
belongs_to :sale
end end

View File

@@ -2,12 +2,6 @@
<div class="col-lg-12"> <div class="col-lg-12">
<ol class="breadcrumb"> <ol class="breadcrumb">
<li><a href="<%= crm_root_path %>">Home</a></li> <li><a href="<%= crm_root_path %>">Home</a></li>
<!-- <li class="active">
<a href="<%= crm_customers_path %>">Customer</a>
</li> -->
<!-- <a href="<%= new_crm_customer_path%>" class="btn btn-primary pull-right">
<i class="fa fa-plus-circle fa-lg"></i> Add Customer
</a> -->
</ol> </ol>
</div> </div>
</div> </div>
@@ -227,13 +221,8 @@
}); });
} }
} }
} }
}); });
} }
</script> </script>

View File

@@ -1,6 +1,6 @@
<div class="row"> <div class="row">
<!-- Column One --> <!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-11 col-md-11 col-sm-11">
<!-- Nav tabs --> <!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist">
@@ -23,14 +23,13 @@
<!--- Panel 0 - Completed Orders --> <!--- Panel 0 - Completed Orders -->
<div class="tab-pane" id="Completed" role="tabpanel"> <div class="tab-pane" id="Completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @complete.each do |sale| %>
<div class="card orders "> <div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block"> <div class="card-block">
<%= sale.receipt_no %>
</div> </div>
</div> </div>
<% end %>
</div> </div>
</div> </div>
@@ -39,15 +38,17 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @tables.each do |table| %> <% @tables.each do |table| %>
<% if table.status == 'occupied' %> <% if table.status == 'occupied' %>
<div class="card orders red text-white" data-id="<%= table.id %>"> <div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div> </div>
</div> </div>
<% else %> <% else %>
<div class="card orders green text-white" data-id="<%= table.id %>"> <div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> Zone <%= table.zone_id %> <br>
Table <%= table.name %> ( <%= table.seater %> Seat )
</div> </div>
</div> </div>
<% end %> <% end %>
@@ -60,13 +61,13 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @rooms.each do |room| %> <% @rooms.each do |room| %>
<% if room.status == 'occupied' %> <% if room.status == 'occupied' %>
<div class="card orders red text-white" data-id="<%= room.id %>"> <div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
</div> </div>
</div> </div>
<% else %> <% else %>
<div class="card orders green text-white" data-id="<%= room.id %>"> <div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
</div> </div>
@@ -79,26 +80,41 @@
<!--- Panel 3 - Orders --> <!--- Panel 3 - Orders -->
<div class="tab-pane" id="orders" role="tabpanel"> <div class="tab-pane" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @orders.each do |order| %>
<div class="card orders"> <div class="card orders red text-white" data-id = "<%= order.order_id %>">
<div class="card-block"> <div class="card-block">
<%= order.order_id %>
</div> </div>
</div> </div>
<% end %>
</div> </div>
</div> </div>
</div> </div>
<!-- tabs - End --> <!-- tabs - End -->
</div> </div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block"> Refresh </button>
</div>
</div> </div>
<!-- Column One --> <!-- Column One -->
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".orders").on('click', function(){ $(".tables").on('click', function(){
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/' + dining_id; window.location.href = '/origami/table/' + dining_id;
})
$(".sales").on('click',function(){
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id;
})
$(".rooms").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id;
})
$(".orders").on('click',function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
}) })
}); });
</script> </script>

View File

@@ -3,9 +3,9 @@
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<!-- Nav tabs --> <!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist"> <ul class="nav nav-tabs" role="tablist" id="mytab">
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#Completed" role="tab">Completed</a> <a class="nav-link" data-toggle="tab" href="#completed" role="tab">Completed</a>
</li> </li>
<li class="nav-item"> <li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a> <a class="nav-link active" data-toggle="tab" href="#tables" role="tab">Tables</a>
@@ -21,15 +21,15 @@
<div class="tab-content" style="max-height:670px; overflow:auto"> <div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed Orders --> <!--- Panel 0 - Completed Orders -->
<div class="tab-pane" id="Completed" role="tabpanel"> <div class="tab-pane" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @complete.each do |sale| %>
<div class="card orders "> <div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block"> <div class="card-block">
<%= sale.receipt_no %>
</div> </div>
</div> </div>
<% end %>
</div> </div>
</div> </div>
@@ -38,13 +38,13 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @tables.each do |table| %> <% @tables.each do |table| %>
<% if table.status == 'occupied' %> <% if table.status == 'occupied' %>
<div class="card orders red text-white" data-id="<%= table.id %>"> <div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
</div> </div>
</div> </div>
<% else %> <% else %>
<div class="card orders green text-white" data-id="<%= table.id %>"> <div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block"> <div class="card-block">
<%= table.name %> <%= table.name %>
</div> </div>
@@ -59,13 +59,13 @@
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @rooms.each do |room| %> <% @rooms.each do |room| %>
<% if room.status == 'occupied' %> <% if room.status == 'occupied' %>
<div class="card orders red text-white" data-id="<%= room.id %>"> <div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
</div> </div>
</div> </div>
<% else %> <% else %>
<div class="card orders green text-white" data-id="<%= room.id %>"> <div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block"> <div class="card-block">
<%= room.name %> <%= room.name %>
</div> </div>
@@ -78,16 +78,17 @@
<!--- Panel 3 - Orders --> <!--- Panel 3 - Orders -->
<div class="tab-pane" id="orders" role="tabpanel"> <div class="tab-pane" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @orders.each do |order| %>
<div class="card orders "> <div class="card orders red text-white" data-id = "<%= order.order_id %>">
<div class="card-block"> <div class="card-block">
<%= order.order_id %>
</div> </div>
</div> </div>
<% end %>
</div>
</div> </div>
</div> </div>
</div>
<!-- tabs - End --> <!-- tabs - End -->
</div> </div>
<!-- Column One --> <!-- Column One -->
@@ -96,19 +97,23 @@
<div class="col-lg-5 col-md-5 col-sm-5"> <div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" > <div class="card" >
<div class="card-header"> <div class="card-header">
<div><strong id="order-title">ORDER DETAILS </strong></div> <% if @status_order == 'order' %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div>
<% elsif @status_sale == 'sale' %>
<div><strong id="order-title">INVOICE DETAILS </strong></div>
<% end %>
</div> </div>
<div class="card-block"> <div class="card-block">
<div class="card-title row"> <div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6"> <div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no"> <p> Receipt No: <span id="receipt_no">
<% if @status == 'sale' %> <% if @status_sale == 'sale' %>
<%= @obj.receipt_no rescue '' %> <%= @obj_sale.receipt_no rescue '' %>
<% end %> <% end %>
</span></p> </span></p>
</div> </div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right"> <div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @obj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p> <p>Date: <span id="receipt_date"><%= @date.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div> </div>
</div> </div>
<div class="card-title row customer_detail hide"> <div class="card-title row customer_detail hide">
@@ -128,12 +133,12 @@
</thead> </thead>
<tbody> <tbody>
<% <%
# For Sale Items
sub_total = 0 sub_total = 0
if @status == "sale" if @status_sale == "sale"
@obj.sale_items.each do |sale_item| @obj_sale.sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price sub_total = sub_total + sale_item.price
%> %>
<input type="hidden" id="sale_id" value="<%= @obj_sale.sale_id %>">
<% unless sale_item.price <= 0 %> <% unless sale_item.price <= 0 %>
<tr> <tr>
<td class='item-name'><%= sale_item.product_name %></td> <td class='item-name'><%= sale_item.product_name %></td>
@@ -144,15 +149,13 @@
end end
end end
end end
%>
<% if @status_order == 'order'
# For Order Items unless @order_items.nil?
if @status == "order" @order_items.each do |order_item |
sub_total = 0 sub_total = sub_total + order_item.price
@order.order_items.each do |order_item|
sub_total = sub_total + (order_item.qty*order_item.price) unless order_item.price <= 0 %>
%>
<tr> <tr>
<td class='item-name'><%= order_item.item_name %></td> <td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td> <td class='item-attr'><%= order_item.qty %></td>
@@ -161,6 +164,8 @@
<% <%
end end
end end
end
end
%> %>
</tbody> </tbody>
</table> </table>
@@ -173,21 +178,49 @@
</tr> </tr>
<tr> <tr>
<td class="charges-name"><strong>Discount:</strong></td> <td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td> <td class="item-attr"><strong id="order-discount">(<%= @obj_order.total_discount rescue 0%>)</strong></td>
</tr> </tr>
<% if @status_sale == "sale" %>
<!-- <tr> <tr>
<td class="charges-name"><strong>Tax:</strong></td> <td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%=@selected_item.total_tax rescue 0%></strong></td> <td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
</tr> </tr>
<tr> <tr>
<td class="charges-name"><strong>Grand Total:</strong></td> <td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%=@selected_item.grand_total rescue 0%></strong></td> <td class="item-attr"><strong id="order-grand-total"><%= @obj_sale.grand_total rescue 0%></strong></td>
</tr> --> </tr>
<% end %>
<tr class="rebate_amount"></tr> <tr class="rebate_amount"></tr>
</table> </table>
</div> </div>
<br>
<%
if @status_sale == 'sale'
unless @order_items.nil?
%>
Pending New Order
<table class="table table-striped">
<%
@order_items.each do |order_item |
%>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%>
</table>
<button class='btn btn-primary'> Add to existing invoice </button>
<%
end
end
%>
</div> </div>
</div> </div>
</div> </div>
@@ -195,23 +228,58 @@
<!-- Column Three --> <!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1"> <div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons --> <!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Add Order</button> <button type="button" class="btn btn-primary btn-block" >Back</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button> <button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button> <button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
<button type="button" id="customer" class="btn btn-primary btn-lg btn-block">Customer</button> <button type="button" class="btn btn-primary btn-block" disabled>Move</button>
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button> <button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status == 'order' %>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block" disabled>Pay</button>
<% else %>
<button type="button" id="request_bills" class="btn btn-primary btn-block" disabled> Req.Bill</button>
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
<% end %>
<!-- Cashier Buttons --> <!-- Cashier Buttons -->
<button type="button" id="discount" class="btn btn-primary btn-lg btn-block">Discount</button> <button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> --> <button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button>
<button type="button" id="pay-bill" class="btn btn-primary btn-lg btn-block">Pay</button>
<button type="button" id="re-print" class="btn btn-primary btn-lg btn-block">Re.Print</button>
</div> </div>
</div> </div>
<script> <script>
$(document).ready(function(){ $(document).ready(function(){
$(".orders").on('click', function(){ $(".tables").on('click', function(){
var dining_id = $(this).attr("data-id"); var dining_id = $(this).attr("data-id");
window.location.href = '/origami/' + dining_id; window.location.href = '/origami/table/' + dining_id;
})
$(".sales").on('click',function(){
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id;
})
$(".rooms").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id;
})
$(".orders").on('click',function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
}) })
}); });
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
$('#request_bills').click(function() {
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "POST",
url: ajax_url,
data: 'order_id='+ order_id,
success:function(result){
location.reload();
}
});
});
</script> </script>

View File

@@ -0,0 +1,194 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist" id="mytab">
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#completed" role="tab">Completed</a>
</li>
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#tables" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
</li>
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#orders" role="tab">Orders</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed Orders -->
<div class="tab-pane " id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @complete.each do |sale| %>
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block">
<%= sale.receipt_no %>
</div>
</div>
<% end %>
</div>
</div>
<!--- Panel 1 - Table Orders -->
<div class="tab-pane " id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 2 - Room Orders -->
<div class="tab-pane" id="rooms" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% else %>
<div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 3 - Orders -->
<div class="tab-pane active" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @orders.each do |order| %>
<div class="card orders red text-white" data-id = "<%= order.order_id %>">
<div class="card-block">
<%= order.order_id %>
</div>
</div>
<% end %>
</div>
</div>
</div>
<!-- tabs - End -->
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">ORDERS DETAILS </strong></div>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @order.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="card-text">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
</tr>
</thead>
<tbody>
<%
sub_total = 0
@order.order_items.each do |sale_item|
sub_total = sub_total + sale_item.price
%>
<% unless sale_item.price <= 0 %>
<tr>
<td class='item-name'><%= sale_item.item_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td>
</tr>
<tr class="rebate_amount"></tr>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" >Back</button>
<button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button>
</div>
</div>
<script>
$(document).ready(function(){
$(".tables").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id;
})
$(".sales").on('click',function(){
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id;
})
$(".rooms").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id;
})
$(".orders").on('click',function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
})
});
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
</script>

View File

@@ -0,0 +1 @@
json.status true

View File

@@ -0,0 +1,267 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist" id="mytab">
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#completed" role="tab">Completed</a>
</li>
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#tables" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed Orders -->
<div class="tab-pane" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @complete.each do |sale| %>
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block">
<%= sale.receipt_no %>
</div>
</div>
<% end %>
</div>
</div>
<!--- Panel 1 - Table Orders -->
<div class="tab-pane " id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 2 - Room Orders -->
<div class="tab-pane active" id="rooms" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% else %>
<div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 3 - Orders -->
<div class="tab-pane" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @orders.each do |order| %>
<div class="card orders red text-white" data-id = "<%= order.order_id %>">
<div class="card-block">
<%= order.order_id %>
</div>
</div>
<% end %>
</div>
</div>
</div>
<!-- tabs - End -->
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >
<div class="card-header">
<% if @status == "order" %>
<div><strong id="order-title">ORDER DETAILS </strong></div>
<% else %>
<div><strong id="order-title">INVOICE DETAILS </strong></div>
<% end %>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<% if @status == 'sale' %>
<%= @obj.receipt_no rescue '' %>
<% end %>
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @obj.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="card-text">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
</tr>
</thead>
<tbody>
<%
sub_total = 0
if @status == "sale"
@obj.sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @obj.sale_id %>">
<% unless sale_item.price <= 0 %>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
end
end
end
if @status == 'order'
unless @order_items.nil?
@order_items.each do |order_item |
sub_total = sub_total + order_item.price
unless order_item.price <= 0 %>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
end
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%=@selected_item.total_discount rescue 0%>)</strong></td>
</tr>
<% if @status == "sale" %>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @obj.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @obj.grand_total rescue 0%></strong></td>
</tr>
<% end %>
<tr class="rebate_amount"></tr>
</table>
</div>
<br>
<%
if @status == 'sale'
unless @order_items.nil?
%>
Added New Order
<table class="table table-striped">
<%
@order_items.each do |order_item |
%>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%>
</table>
<button class='btn btn-primary'> Add to existing invoice </button>
<%
end
end
%>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" >Back</button>
<button type="button" class="btn btn-primary btn-block" disabled>Add Order</button>
<button type="button" class="btn btn-primary btn-block" disabled>Edit</button>
<button type="button" class="btn btn-primary btn-block" disabled>Move</button>
<button type="button" id="customer" class="btn btn-primary btn-block">Customer</button>
<button type="button" id="request_bills" class="btn btn-primary btn-block">Req.Bill</button>
<!-- Cashier Buttons -->
<button type="button" id="discount" class="btn btn-primary btn-block">Discount</button>
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Tax</button> -->
<button type="button" id="pay" class="btn btn-primary btn-block">Pay</button>
<button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button>
</div>
</div>
<script>
$(document).ready(function(){
$(".tables").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id;
})
$(".sales").on('click',function(){
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id;
})
$(".rooms").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id;
})
$(".orders").on('click',function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
})
});
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
</script>

View File

@@ -0,0 +1,206 @@
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
<!-- Nav tabs -->
<ul class="nav nav-tabs" role="tablist" id="mytab">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#completed" role="tab">Completed</a>
</li>
<li class="nav-item">
<a class="nav-link " data-toggle="tab" href="#tables" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#rooms" role="tab">Rooms</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#orders" role="tab">Orders</a>
</li>
</ul>
<!-- Nav tabs - End -->
<div class="tab-content" style="max-height:670px; overflow:auto">
<!--- Panel 0 - Completed Orders -->
<div class="tab-pane active" id="completed" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @complete.each do |sale| %>
<div class="card sales red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block">
<%= sale.receipt_no %>
</div>
</div>
<% end %>
</div>
</div>
<!--- Panel 1 - Table Orders -->
<div class="tab-pane " id="tables" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @tables.each do |table| %>
<% if table.status == 'occupied' %>
<div class="card tables red text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% else %>
<div class="card tables green text-white" data-id="<%= table.id %>">
<div class="card-block">
<%= table.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 2 - Room Orders -->
<div class="tab-pane" id="rooms" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<div class="card rooms red text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% else %>
<div class="card rooms green text-white" data-id="<%= room.id %>">
<div class="card-block">
<%= room.name %>
</div>
</div>
<% end %>
<% end %>
</div>
</div>
<!--- Panel 3 - Orders -->
<div class="tab-pane" id="orders" role="tabpanel">
<div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;">
<% @orders.each do |order| %>
<div class="card orders red text-white" data-id = "<%= order.order_id %>">
<div class="card-block">
<%= order.order_id %>
</div>
</div>
<% end %>
</div>
</div>
</div>
<!-- tabs - End -->
</div>
<!-- Column One -->
<!-- Column Two -->
<div class="col-lg-5 col-md-5 col-sm-5">
<div class="card" >
<div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div>
</div>
<div class="card-block">
<div class="card-title row">
<div class="col-lg-6 col-md-6 col-sm-6">
<p> Receipt No: <span id="receipt_no">
<%= @sale.receipt_no rescue '' %>
</span></p>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
<p>Date: <span id="receipt_date"><%= @sale.created_at.utc.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span></p>
</div>
</div>
<div class="card-title row customer_detail hide">
<div class="col-lg-6 col-md-6 col-sm-6">
<p>Customer : <span id="customer_name"></span></p>
</div>
</div>
<div class="card-text">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th class="item-name">Items</th>
<th class="item-attr">QTY</td>
<th class="item-attr">Price</td>
</tr>
</thead>
<tbody>
<%
sub_total = 0
@sale.sale_items.each do |sale_item|
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @sale.sale_id %>">
<% unless sale_item.price <= 0 %>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
end
end
%>
</tbody>
</table>
</div>
<div class="card-footer">
<table class="table" id="order-charges-table" border="0">
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%= @sale.total_discount rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= @sale.total_tax rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><%= @sale.grand_total rescue 0%></strong></td>
</tr>
<tr class="rebate_amount"></tr>
</table>
</div>
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-primary btn-block" >Back</button>
<button type="button" id="re-print" class="btn btn-primary btn-block">VOID</button>
<button type="button" id="re-print" class="btn btn-primary btn-block">Re.Print</button>
</div>
</div>
<script>
$(document).ready(function(){
$(".tables").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/' + dining_id;
})
$(".sales").on('click',function(){
var sale_id = $(this).attr("data-id");
window.location.href = '/origami/sale/' + sale_id;
})
$(".rooms").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/room/' + dining_id;
})
$(".orders").on('click',function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
})
});
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
</script>

View File

@@ -72,18 +72,21 @@ Rails.application.routes.draw do
#--------- Cashier ------------# #--------- Cashier ------------#
namespace :origami do namespace :origami do
root "home#index" root "home#index"
get "/:dining_id" => "home#show" do #origami/:booking_id will show get "table/:dining_id" => "home#show" do #origami/:booking_id will show
# resources :discounts, only: [:index,:new, :create ] #add discount type # resources :discounts, only: [:index,:new, :create ] #add discount type
resources :customers #add customer type resources :customers #add customer type
end end
get 'sale/:sale_id' => 'sales#show'
get 'room/:room_id' => 'rooms#show'
get 'order/:order_id' => "orders#show"
post '/:booking_id' => 'home#item_show' post '/:booking_id' => 'home#item_show'
get "/:id/discount" => "discounts#index" get "/:id/discount" => "discounts#index"
post "/:id/discount" => "discounts#create" post "/:id/discount" => "discounts#create"
get "/:id/request_bills" => "request_bills#print" post "/:id/request_bills" => "request_bills#print"
get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' } get '/:sale_id/reprint' => 'payments#reprint' ,:defaults => { :format => 'json' }
#--------- Payment ------------# #--------- Payment ------------#
get 'sale/:sale_id/payment' => 'payments#show' get 'sale/:sale_id/payment' => 'payments#show'