update waiter view add order

This commit is contained in:
Aung Myo
2018-02-26 09:19:14 +06:30
parent ac47501e01
commit f4f5915532
12 changed files with 259 additions and 160 deletions

View File

@@ -12,10 +12,17 @@
<% @sale.each do |sale| %>
<div class="card sales bg-red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block">
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;">Billed</span>
</div>
</div>
<% end %>
<% @order.each do |order| %>
<div class="card sales blue text-white" data-id = "<%= order.booking_id %>">
<div class="card-block">
<%= order.booking_id %><span style="font-size:12px;float:right;line-height:inherit;">new</span>
</div>
</div>
<% end %>
</div>
</div>
</div>

View File

@@ -10,12 +10,19 @@
<div id="custom-slimscroll">
<div class="card-columns">
<% @sales.each do |sale| %>
<div class="card sales bg-red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block">
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;"><%= sale.sale_status %></span>
</div>
</div>
<% end %>
<div class="card sales bg-red text-white" data-id = "<%= sale.sale_id %>">
<div class="card-block">
<%= sale.receipt_no %><span style="font-size:12px;float:right;line-height:inherit;">Billed</span>
</div>
</div>
<% end %>
<% @orders.each do |order| %>
<div class="card sales blue text-white" data-id = "<%= order.booking_id %>">
<div class="card-block">
<%= order.booking_id %><span style="font-size:12px;float:right;line-height:inherit;">new</span>
</div>
</div>
<% end %>
</div>
</div>
</div>
@@ -31,19 +38,38 @@
</div>
<div class="card-block">
<div class="card-title row p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Receipt No: <span id="receipt_no">
<%= @sale.receipt_no rescue '' %>
</span>
</div>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> &nbsp; </span>
</div>
<% if @status == 'sale' %>
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Receipt No: <span id="receipt_no">
<%= @sale.receipt_no rescue '' %></span>
</div>
<% else%>
<input type="hidden" id="save_order_id" value="<%=@bookings.booking_orders[0].order_id%>">
<div class="col-lg-8 col-md-8 col-sm-8">
&nbsp; Order No: <span id="receipt_no">
<%= @bookings.booking_orders[0].order_id rescue '' %></span>
</div>
<% end%>
<% if @status == 'sale' %>
<div class="col-lg-6 col-md-6 col-sm-6 text-right">
Date: <span id="receipt_date"><%= @sale.created_at.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%> &nbsp; </span>
</div>
<% else%>
<div class="col-lg-4 col-md-4 col-sm-4 text-right">
Date: <span id="receipt_date"><%= @order.created_at.strftime("%I:%M %p") rescue '-'%> &nbsp; </span>
</div>
<% end%>
</div>
<div class="card-title row customer_detail p-l-5 p-r-5">
<div class="col-lg-6 col-md-6 col-sm-6">
&nbsp; Customer : <%= @sale.customer.name rescue "-" %>
<% if @status == 'sale' %>
&nbsp; Customer : <%= @sale.customer.name rescue "-" %>
<% else%>
&nbsp; Customer : <%= @order.customer.name rescue "-" %>
<% end%>
</div>
</div>
@@ -58,55 +84,64 @@
</tr>
</thead>
<tbody>
<%
sub_total = 0
<% if @status == 'sale' %>
<% 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
%>
sub_total = sub_total + sale_item.price %>
<input type="hidden" id="sale_id" value="<%= @sale.sale_id %>">
<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%>
<% else%>
<% sub_total = 0
@order_items.each do |order_item|
sub_total = sub_total + order_item.price %>
<input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>">
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.price %></td>
</tr>
<% end%>
<% end%>
</tbody>
</table>
</div>
</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>
<% if @status == 'sale' %>
<tr>
<%if @sale.discount_type == 'member_discount'%>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<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>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment 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>
<td class="charges-name"><strong>Member Discount:</strong></td>
<%else%>
<td class="charges-name"><strong>Discount:</strong></td>
<%end%>
<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>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= @sale.rounding_adjustment 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>
<% else%>
<tr>
<td class="charges-name"><strong>Sub Total:</strong></td>
<td class="item-attr"><strong id="order-sub-total"><%= sub_total %></strong></td>
</tr>
<% end%>
</table>
</div>
</div>
@@ -115,8 +150,15 @@
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i>Back</button>
<% if current_user.role != "waiter" || @status != "sale"%>
<button type="button" id="addorder" class="btn bg-blue btn-block">Add Order</button>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<%end%>
<% if current_user.role != "waiter"%>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<%end%>
<% if @status != "sale"%>
<button type="button" id="request_bills" class="btn btn-block bg-blue waves-effect">Req.Bill</button>
<%end%>
</div>
</div>
</div>
@@ -135,7 +177,7 @@ $(document).ready(function(){
});
$('#addorder').on('click', function () {
var table_id = "<%=@table_id%>";
var booking_id = "<%=@booking%>";
var booking_id = "<%=@bookings.booking_id%>";
if (table_id) {
window.location.href = '/origami/quick_service/modify_order/' + table_id+"/"+$('#sale_id').val();
}else{
@@ -143,5 +185,23 @@ $(document).ready(function(){
}
});
// Bill Request
$('#request_bills').click(function () {
var order_id = $('#save_order_id').val();
var ajax_url = "/origami/" + order_id + "/request_bills";
$.ajax({
type: "GET",
url: ajax_url,
// data: 'order_id='+ order_id,
success: function (result) {
if (!result.status) {
swal("Information!", result.error_message);
}
else {
location.reload();
}
}
});
});
});
</script>