update discount
This commit is contained in:
@@ -97,6 +97,29 @@ $(document).ready(function(){
|
|||||||
return false;
|
return false;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// Pay Discount for Payment
|
||||||
|
$("#pay-discount").on('click', function(){
|
||||||
|
var sale_id = $('#sale-id').text();
|
||||||
|
var sub_total = $('#order-sub-total').text();
|
||||||
|
var grand_total = $('#order-grand-total').text();
|
||||||
|
var discount_type = $('#discount-type').val();
|
||||||
|
var discount_value = $('#discount-amount').val();
|
||||||
|
var discount_amount = discount_value;
|
||||||
|
|
||||||
|
// For Percentage Discount
|
||||||
|
if(discount_type == 1){
|
||||||
|
discount_amount=(sub_total*discount_value)/100;
|
||||||
|
}
|
||||||
|
|
||||||
|
var params = {'sale_id': sale_id, 'grand_total' : grand_total, 'discount_type':discount_type, 'discount_value':discount_value, 'discount_amount':discount_amount};
|
||||||
|
$.ajax({
|
||||||
|
type: "POST",
|
||||||
|
url: "/origami/discount",
|
||||||
|
data: params,
|
||||||
|
success:function(result){ }
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
// Payment for Bill
|
// Payment for Bill
|
||||||
$('#pay').click(function() {
|
$('#pay').click(function() {
|
||||||
var sale_id=$(".selected-item").find(".orders-id").text();
|
var sale_id=$(".selected-item").find(".orders-id").text();
|
||||||
@@ -105,7 +128,7 @@ $(document).ready(function(){
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
/* For Receipt - discount or tax */
|
/* For Receipt - Calculate discount or tax */
|
||||||
$(document).on('click', '.cashier_number', function(event){
|
$(document).on('click', '.cashier_number', function(event){
|
||||||
if(event.handled !== true) {
|
if(event.handled !== true) {
|
||||||
var original_value=0;
|
var original_value=0;
|
||||||
@@ -151,6 +174,7 @@ $(document).on('click', '.cashier_number', function(event){
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
/* For Receipt - Update Balance */
|
||||||
function update_balance(){
|
function update_balance(){
|
||||||
var discount_type = $('#discount-type').val();
|
var discount_type = $('#discount-type').val();
|
||||||
var discount_amount = $('#discount-amount').val();
|
var discount_amount = $('#discount-amount').val();
|
||||||
@@ -158,8 +182,8 @@ function update_balance(){
|
|||||||
var tax = $('#order-Tax').text();
|
var tax = $('#order-Tax').text();
|
||||||
|
|
||||||
// For Percentage Discount
|
// For Percentage Discount
|
||||||
if(discount_type='1'){
|
if(discount_type == 1){
|
||||||
discount-amount=(sub_total*discount-amount)/100;
|
discount_amount=(sub_total*discount_amount)/100;
|
||||||
}
|
}
|
||||||
|
|
||||||
var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount;
|
var total = (parseFloat(sub_total) + parseFloat(tax)) - discount_amount;
|
||||||
|
|||||||
@@ -8,8 +8,44 @@ class Origami::DiscountsController < BaseOrigamiController
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#discount for selected order
|
||||||
def create
|
def create
|
||||||
|
sale_id = params[:sale_id]
|
||||||
|
discount_type = params[:discount_type]
|
||||||
|
discount_value = params[:discount_value]
|
||||||
|
discount_amount = params[:discount_amount]
|
||||||
|
grand_total = params[:grand_total]
|
||||||
|
|
||||||
|
if discount_type == 0
|
||||||
|
remark="Discount " + discount_amount + " as net"
|
||||||
|
else
|
||||||
|
remark="Discount " + discount_amount + " as percentage"
|
||||||
|
end
|
||||||
|
|
||||||
|
#update discount for sale
|
||||||
|
sale = Sale.find(sale_id)
|
||||||
|
sale.total_discount = discount_amount
|
||||||
|
sale.grand_total = grand_total
|
||||||
|
sale.save
|
||||||
|
|
||||||
|
#save sale item for discount
|
||||||
|
sale_item = SaleItem.new
|
||||||
|
|
||||||
|
#pull
|
||||||
|
sale_item.sale_id = sale_id
|
||||||
|
sale_item.product_code = 0
|
||||||
|
sale_item.product_name = "Discount"
|
||||||
|
sale_item.remark = remark
|
||||||
|
|
||||||
|
sale_item.qty = 1
|
||||||
|
sale_item.unit_price = (0-discount_amount.to_f)
|
||||||
|
sale_item.taxable_price = discount_amount
|
||||||
|
sale_item.is_taxable = 0
|
||||||
|
|
||||||
|
sale_item.price = sale_item.qty * sale_item.unit_price
|
||||||
|
sale_item.save
|
||||||
|
|
||||||
|
redirect_to origami_root_path
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -26,4 +26,4 @@ class Origami::RequestBillsController < BaseOrigamiController
|
|||||||
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer_name)
|
printer.print_receipt_bill(print_settings,@sale_items,@sale_data,customer_name)
|
||||||
redirect_to origami_root_path
|
redirect_to origami_root_path
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ class SaleItem < ApplicationRecord
|
|||||||
|
|
||||||
|
|
||||||
def self.get_order_items_details(sale_id)
|
def self.get_order_items_details(sale_id)
|
||||||
order_details = SaleItem.select("sales.total_discount as discount_amount,DATE_FORMAT(sales.receipt_date,'%Y-%m-%d %h:%m') as receipt_date,
|
order_details = SaleItem.select("sales.total_tax as tax_amount, sales.grand_total as grand_total_amount , 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")
|
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.sale_id = sale_items.sale_id")
|
.joins("left join sales on sales.sale_id = sale_items.sale_id")
|
||||||
.where("sale_items.sale_id=?",sale_id)
|
.where("sale_items.sale_id=?",sale_id)
|
||||||
|
|||||||
@@ -5,7 +5,8 @@
|
|||||||
<!-- Order Details -->
|
<!-- Order Details -->
|
||||||
<div class="card" >
|
<div class="card" >
|
||||||
<div class="card-header">
|
<div class="card-header">
|
||||||
<div><strong id="order-title">ORDER DETAILS -</strong></div>
|
<p id="sale-id" class="hidden"><%=@sale_data.sale_id %></p>
|
||||||
|
<div><strong id="order-title">ORDER DETAILS</strong></div>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="card-title row">
|
<div class="card-title row">
|
||||||
@@ -87,12 +88,12 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="card-block">
|
<div class="card-block">
|
||||||
<div class="card-title">
|
<div class="card-title">
|
||||||
<form class="form-horizontal">
|
<div class="form-horizontal">
|
||||||
<div class="form-group">
|
<div class="form-group">
|
||||||
<div class="col-md-3">
|
<div class="col-md-3">
|
||||||
<select name="discount_type" id="discount-type" class="form-control">
|
<select name="discount_type" id="discount-type" class="form-control">
|
||||||
<option val=0 >Net</option>
|
<option value=0 >Net</option>
|
||||||
<option val=1 >Percentage</option>
|
<option value=1 >Percentage</option>
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-9">
|
<div class="col-md-9">
|
||||||
@@ -100,8 +101,11 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<button id="pay-discount" class="btn btn-primary long">Discount</button>
|
<button id="pay-discount" class="btn btn-primary long">Discount</button>
|
||||||
</form>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<hr />
|
||||||
|
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-md-7">
|
<div class="col-md-7">
|
||||||
|
|||||||
@@ -206,14 +206,15 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div><p id="sale" value=""></p>
|
</div>
|
||||||
|
|
||||||
<!-- 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-lg btn-block" disabled>Add Order</button>
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
|
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
|
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
|
||||||
<button type="button" id="customer" value="SAL-000000000001" class="btn btn-primary btn-lg btn-block">Customer</button>
|
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Customer</button>
|
||||||
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
|
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">Req.Bill</button>
|
||||||
<!-- 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-lg btn-block">Discount</button>
|
||||||
@@ -222,146 +223,3 @@
|
|||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
|
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script>
|
|
||||||
var old_order_id = 0
|
|
||||||
var old_table_name = ""
|
|
||||||
var table_or_order_id = 0
|
|
||||||
var pay_sale_id = 0
|
|
||||||
|
|
||||||
function callOrderDetails(sale_order_id){
|
|
||||||
|
|
||||||
var order_id = 0
|
|
||||||
var sale_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]}
|
|
||||||
$("#pay").prop('disabled',false);
|
|
||||||
$("#customer").prop('disabled',false);
|
|
||||||
$("#request_bills").prop('disabled',true);
|
|
||||||
}else{
|
|
||||||
order_id = sale_order_id.split("_")[1]
|
|
||||||
url = "origami/"+order_id
|
|
||||||
data_val = { order_id: sale_order_id.split("_")[1]}
|
|
||||||
$("#request_bills").prop('disabled',false);
|
|
||||||
$("#pay").prop('disabled',true);
|
|
||||||
$("#customer").prop('disabled',true);
|
|
||||||
}
|
|
||||||
|
|
||||||
table_or_order_id = order_id
|
|
||||||
pay_sale_id = sale_id
|
|
||||||
alert(table_or_order_id)
|
|
||||||
var tbody = ""
|
|
||||||
$("#append-table").html("")
|
|
||||||
if (old_order_id != order_id){
|
|
||||||
$("#table-order-"+old_order_id).removeClass("selected_color")
|
|
||||||
$("#table-order-"+order_id).addClass("selected_color")
|
|
||||||
old_order_id = order_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#order-detail-header").html("")
|
|
||||||
$("#order-detail-header").append("Table Name : "+document.getElementById("table-name-"+order_id).innerHTML)
|
|
||||||
$("#sub-total").html("")
|
|
||||||
$.ajax({type: "GET",
|
|
||||||
url: url,
|
|
||||||
data: data_val,
|
|
||||||
success:function(result){
|
|
||||||
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++) {
|
|
||||||
var data = JSON.stringify(result[i]);
|
|
||||||
var parse_data = JSON.parse(data)
|
|
||||||
sub_total += (parse_data.qty*parse_data.price)
|
|
||||||
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-total-price">'+(parse_data.qty*parse_data.price)+'</span></td>'
|
|
||||||
+'</tr>>'
|
|
||||||
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)
|
|
||||||
|
|
||||||
$("#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){
|
|
||||||
// alert('error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$( document ).ready(function() {
|
|
||||||
$('#request_bills').click(function() {
|
|
||||||
window.location.href = '/origami/request_bills/'+ table_or_order_id
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
$('#pay').click(function() {
|
|
||||||
window.location.href = '/origami/sale/'+ pay_sale_id + "/payment"
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#customer').click(function() {
|
|
||||||
var sale_id = $(this).val();
|
|
||||||
window.location.href = '/crm/customers/'+ sale_id + "/assign_sale_id"
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<style type="text/css">
|
|
||||||
.selected_color{
|
|
||||||
color:white;
|
|
||||||
background-color: blue;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|||||||
@@ -1,328 +0,0 @@
|
|||||||
<div class="row">
|
|
||||||
<div class="col-lg-6 col-md-6 col-sm-8">
|
|
||||||
<!-- Column One -->
|
|
||||||
|
|
||||||
<!-- Nav tabs -->
|
|
||||||
<ul class="nav nav-tabs" role="tablist">
|
|
||||||
<li class="nav-item">
|
|
||||||
<a class="nav-link active" 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="min-height:670px; max-height:670px; overflow-y:scroll">
|
|
||||||
<!-- Panel 1 - Tables -->
|
|
||||||
|
|
||||||
<div class="tab-pane active" id="tables" role="tabpanel">
|
|
||||||
<!--- Booking Items -->
|
|
||||||
<div class="card-columns" style="padding-top:10px">
|
|
||||||
|
|
||||||
<% if @booking_orders %>
|
|
||||||
<% @booking_orders.each do |booking_order| %>
|
|
||||||
<% 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">
|
|
||||||
<h4 class="card-title">
|
|
||||||
<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>
|
|
||||||
<% end %>
|
|
||||||
<%end %>
|
|
||||||
<%end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Panel 1 - Tables - End -->
|
|
||||||
<!-- Panel 2 - Rooms -->
|
|
||||||
<div class="tab-pane" id="rooms" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
|
||||||
<!--- Booking Items -->
|
|
||||||
<div class="card-columns" style="padding-top:10px">
|
|
||||||
|
|
||||||
<% if @booking_rooms %>
|
|
||||||
<% @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">
|
|
||||||
<h4 class="card-title">
|
|
||||||
<span id="table-name-<%=booking_room.id%>" class="table-name"><%=booking_room.room_name%></span></h4>
|
|
||||||
<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>
|
|
||||||
<% end %>
|
|
||||||
<%end %>
|
|
||||||
<%end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Panel 2 - Rooms - End -->
|
|
||||||
<!-- Panel 3 - Orders -->
|
|
||||||
<div class="tab-pane" id="orders" role="tabpanel" style="min-height:670px; max-height:670px; overflow-y:scroll">
|
|
||||||
|
|
||||||
<!--- Booking Items -->
|
|
||||||
<div class="card-columns" style="padding-top:10px">
|
|
||||||
|
|
||||||
<% if @orders %>
|
|
||||||
<% @orders.each do |order| %>
|
|
||||||
<% 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">
|
|
||||||
<h4 class="card-title">
|
|
||||||
<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>
|
|
||||||
<% end %>
|
|
||||||
<%end %>
|
|
||||||
<%end %>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<!-- Panel 3 - Orders - End -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<!-- Column Two -->
|
|
||||||
<div class="col-lg-5 col-md-5 col-sm-3">
|
|
||||||
<div class="card" >
|
|
||||||
<div class="card-header">
|
|
||||||
<div id="order-title"><strong><span id="receipt-no">ORDER DETAILS</span></strong>
|
|
||||||
<strong><span id ="receipt-date" style="margin-left: 30%"></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 class="card-block">
|
|
||||||
<div class="card-title">
|
|
||||||
<table class="table">
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th style="width:60%; text-align:left">Items</th>
|
|
||||||
<th style="width:20%; text-align:right">QTY</td>
|
|
||||||
<th style="width:20%; text-align:right">Price</td>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
|
|
||||||
<table class="table" id="append-table">
|
|
||||||
<tbody>
|
|
||||||
<tr>
|
|
||||||
<td style="width:60%; text-align:left">
|
|
||||||
<span id="item-name-price"></span>
|
|
||||||
</td>
|
|
||||||
<td style="width:20%; text-align:right">
|
|
||||||
<span id="item-qty"></span>
|
|
||||||
</td>
|
|
||||||
<td style="width:20%; text-align:right">
|
|
||||||
<span id="item-total-price"></span>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
<div class="card-footer">
|
|
||||||
<table class="table" style="margin-bottom:0px">
|
|
||||||
<tfooter>
|
|
||||||
<tr>
|
|
||||||
<td style="width:80%; text-align:left; border-top:none"><strong>Sub Total</strong></td>
|
|
||||||
<td style="width:20%; text-align:right; border-top:none"><strong><span id="sub-total"></span></strong></td>
|
|
||||||
</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>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</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-lg btn-block" disabled>Add Order</button>
|
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Edit</button>
|
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Move</button>
|
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Customer</button>
|
|
||||||
<!-- <button type="button" class="btn btn-primary btn-lg btn-block" disabled>Req.Bill</button> -->
|
|
||||||
<button type="button" id="request_bills" class="btn btn-primary btn-lg btn-block">
|
|
||||||
Req.Bill
|
|
||||||
</button>
|
|
||||||
<!-- Cashier Buttons -->
|
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>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-lg btn-block" >Pay</button>
|
|
||||||
<button type="button" class="btn btn-primary btn-lg btn-block" disabled>Re.Print</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
var old_order_id = 0
|
|
||||||
var old_table_name = ""
|
|
||||||
var table_or_order_id = 0
|
|
||||||
var pay_sale_id = 0
|
|
||||||
|
|
||||||
function callOrderDetails(sale_order_id){
|
|
||||||
var order_id = 0
|
|
||||||
var sale_id = 0
|
|
||||||
var data_val = ""
|
|
||||||
sale_order = sale_order_id.split("_")[0]
|
|
||||||
|
|
||||||
if (sale_order == 'sale') {
|
|
||||||
sale_id = sale_order_id.split("_")[1]
|
|
||||||
url = "origami/"+sale_id
|
|
||||||
data_val = { sale_id: sale_id }
|
|
||||||
sale_or_order_id=sale_id
|
|
||||||
}else{
|
|
||||||
order_id = sale_order_id.split("_")[1]
|
|
||||||
url = "origami/"+order_id
|
|
||||||
data_val = { order_id: sale_order_id.split("_")[1]}
|
|
||||||
sale_or_order_id=order_id
|
|
||||||
}
|
|
||||||
|
|
||||||
table_or_order_id = order_id
|
|
||||||
pay_sale_id = sale_id
|
|
||||||
var tbody = ""
|
|
||||||
|
|
||||||
// clear data in table
|
|
||||||
$("#append-table").html("")
|
|
||||||
|
|
||||||
if (old_order_id != order_id){
|
|
||||||
$("#table-order-"+old_order_id).removeClass("selected_color")
|
|
||||||
$("#table-order-"+order_id).addClass("selected_color")
|
|
||||||
old_order_id = order_id
|
|
||||||
}
|
|
||||||
|
|
||||||
$("#order-detail-header").html("")
|
|
||||||
$("#order-detail-header").append("Table Name : "+document.getElementById("table-name-" + sale_or_order_id).innerHTML)
|
|
||||||
$("#sub-total").html("")
|
|
||||||
$.ajax({type: "GET",
|
|
||||||
url: url,
|
|
||||||
data: data_val,
|
|
||||||
success:function(result){
|
|
||||||
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++) {
|
|
||||||
var data = JSON.stringify(result[i]);
|
|
||||||
var parse_data = JSON.parse(data)
|
|
||||||
|
|
||||||
sub_total += (parse_data.qty*parse_data.price)
|
|
||||||
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-total-price">'+(parse_data.qty*parse_data.price)+'</span></td>'
|
|
||||||
+'</tr>>'
|
|
||||||
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);
|
|
||||||
|
|
||||||
$("#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){
|
|
||||||
// alert('error');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
$( document ).ready(function() {
|
|
||||||
$('#request_bills').click(function() {
|
|
||||||
console.log(table_or_order_id);
|
|
||||||
window.location.href = '/origami/request_bills/'+ table_or_order_id
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#pay').click(function() {
|
|
||||||
window.location.href = '/origami/sale/'+ pay_sale_id + "/payment"
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
|
||||||
<style type="text/css">
|
|
||||||
.selected_color{
|
|
||||||
color:white;
|
|
||||||
background-color: blue;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
@@ -72,9 +72,9 @@ Rails.application.routes.draw do
|
|||||||
resources :customers, only: [:index,:new, :create ] #add customer type
|
resources :customers, only: [:index,:new, :create ] #add customer type
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
get "/request_bills/:id" => "request_bills#print"
|
get "/request_bills/:id" => "request_bills#print"
|
||||||
get "/discount/:id" => "discounts#index"
|
get "/discount/:id" => "discounts#index"
|
||||||
|
post "/discount" => "discounts#create"
|
||||||
|
|
||||||
#--------- Payment ------------#
|
#--------- Payment ------------#
|
||||||
get 'sale/:sale_id/payment' => 'payments#show'
|
get 'sale/:sale_id/payment' => 'payments#show'
|
||||||
|
|||||||
Reference in New Issue
Block a user