Merge branch 'master' into settings_backend

This commit is contained in:
Phyo
2017-06-23 09:14:32 +06:30
32 changed files with 328 additions and 175 deletions

View File

@@ -75,7 +75,15 @@
<input type="hidden" id="sale_id" name="sale_id" value="<%= @sale_id %>" />
<%= f.error_notification %>
<%= f.hidden_field :id, :class => "form-control col-md-6 " %>
<div class="form-group <%= (flash["errors"]) ? "has-error" : "" %>">
<%= f.input :card_no, :class => "form-control col-md-6 card_no"%>
<% flash.each do |name, msg| %>
<% str="[\"#{msg['name']}\"]"
str.gsub!('["', '')
str.gsub!('"]', '') %>
<span class="help-block" style="margin-top:-10px"><%= str %></span>
<% end -%>
</div>
<div class="form-group">
<label>Salutation :</label><br>
<label>

View File

@@ -137,13 +137,15 @@
count = 0
sub_total = 0
if @status_sale == "sale"
puts @sale_array[0]
@sale_array[0].sale_items.each do |sale_item|
count += 1
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @sale_array[0].sale_id %>">
<% unless sale_item.price <= 0 %>
<%
# Can't check for discount
unless sale_item.price == 0
%>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
@@ -151,7 +153,7 @@
<td class='item-attr'><%= sale_item.price %></td>
</tr>
<%
end
end
end
end
@@ -159,12 +161,10 @@
unless @order_items.nil?
count = 0
@order_items.each do |order_item |
puts @order_items.size
puts "view"
count += 1
sub_total = sub_total + order_item.price
unless order_item.price <= 0 %>
unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td>
@@ -188,7 +188,7 @@
</tr>
<tr>
<td class="charges-name"><strong>Discount:</strong></td>
<td class="item-attr"><strong id="order-discount">(<%= @obj_order.total_discount rescue 0%>)</strong></td>
<td class="item-attr"><strong id="order-discount">(<%= @obj_sale.total_discount rescue 0%>)</strong></td>
</tr>
<% if @status_sale == "sale" %>
<tr>
@@ -212,10 +212,13 @@
Pending New Order
<table class="table table-striped">
<%
count = 0
@order_items.each do |order_item |
count += 1
%>
<tr>
<td><%= count %>
<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>
@@ -225,14 +228,15 @@
end
%>
</table>
<button class='btn btn-primary'> Add to existing invoice </button>
<button class='btn btn-primary' id='add_invoice'> Add to existing invoice </button>
<%
else
end
@sale_array.each do |sale|
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
Pending New Invoice
<br><br>
Pending Payment
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>
@@ -240,7 +244,6 @@
</tr>
</table>
<%
end
end
end
end
@@ -258,17 +261,23 @@
<% if @dining.bookings.length >= 1 %>
<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" id='move'>Move</button>
<button type="button" id="customer" class="btn btn-primary btn-block" >Customer</button>
<% if @status_order == 'order' %>
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" class="btn btn-primary btn-block" id='move'>Move</button>
<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>
<button type="button" class="btn btn-primary btn-block" disabled=""> Void </button>
<% else %>
<button type="button" class="btn btn-primary btn-block" id='move' disabled="">Move</button>
<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>
<button type="button" class="btn btn-primary btn-block" > Void </button>
<% end %>
<!-- Cashier Buttons -->
<button type="button" id="discount" class="btn btn-primary btn-block" >Discount</button>
<button type="button" id="re-print" class="btn btn-primary btn-block" >Re.Print</button>
<% end %>
</div>
@@ -335,6 +344,7 @@ $('#pay').on('click',function() {
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
// Bill Request
$('#request_bills').click(function() {
var order_id = $('#save_order_id').attr('data-order');
var ajax_url = "/origami/" + order_id + "/request_bills";
@@ -357,4 +367,19 @@ $('#move').on('click',function(){
$('#back').on('click',function(){
window.location.href = '/origami/';
})
$('#add_invoice').on('click',function(){
var dining_id = "<%= @dining.id %>"
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var ajax_url = "/origami/sale/append_order";
$.ajax({
type: "POST",
url: ajax_url,
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
success:function(result){
alert("Invoice updated")
window.location.reload();
}
});
})
</script>

View File

@@ -180,7 +180,7 @@
if @sale_array.size > 1
unless sale.receipt_no == @sale_array[0].receipt_no
%>
Pending New Invoice
Pending Payment
<table class="table table-striped">
<tr>
<td>Receipt No - <%= sale.receipt_no %></td>

View File

@@ -24,7 +24,8 @@
<table >
<!-- <thead> -->
<tr>
<th style="width:80%;">Items</th>
<th style="width:5%">#</th>
<th style="width:76%;">Items</th>
<th style="width:20%;">QTY</td>
<th style="width:20%;">Price</td>
</tr>
@@ -34,10 +35,16 @@
<div id="table-details" class="card-text" style="min-height:400px; max-height:400px; overflow-x:scroll">
<table class="table" id="append-table">
<tbody>
<% sub_total = 0 %>
<% @sale_data.sale_items.each do |sale_item| %>
<% sub_total = 0
count = 0
%>
<% @sale_data.sale_items.each do |sale_item|
count += 1
%>
<% sub_total += sale_item.qty*sale_item.unit_price%>
<tr>
<td><%= count %></td>
<td style="width:60%; text-align:left">
<span id="item-name-price"><%=sale_item.product_name%>@<%=sale_item.unit_price%></span>
</td>
@@ -236,7 +243,6 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-primary btn-block" onclick="localStorage.removeItem('cash');window.location.href = '/origami';"> Back </button>
<button type="button" class="btn btn-primary btn-block"> FOC </button>
<button type="button" class="btn btn-primary btn-block"> Void </button>
</div>
</div>

View File

@@ -98,7 +98,7 @@
<div class="card" >
<div class="card-header">
<% if @status == "order" %>
<div><strong id="order-title">ORDER DETAILS </strong></div>
<div id="save_order_id" data-order="<%= @obj.order_id %>"><strong id="order-title">ORDER DETAILS </strong></div>
<% else %>
<div><strong id="order-title">INVOICE DETAILS </strong></div>
<% end %>
@@ -139,7 +139,7 @@
sub_total = sub_total + sale_item.price
%>
<input type="hidden" id="sale_id" value="<%= @obj.sale_id %>">
<% unless sale_item.price <= 0 %>
<% unless sale_item.price == 0 %>
<tr>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
@@ -155,7 +155,7 @@
@order_items.each do |order_item |
sub_total = sub_total + order_item.price
unless order_item.price <= 0 %>
unless order_item.price == 0 %>
<tr>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
@@ -259,15 +259,65 @@ $(document).ready(function(){
var order_id = $(this).attr("data-id");
window.location.href = '/origami/order/' + order_id;
})
// bind customer to order or sale
$("#customer").on('click', function(){
var sale = $('#sale_id').val();
if (sale) {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
}
window.location.href = '/origami/'+ sale_id + "/customers"
});
// Discount for Payment
$('#discount').click(function() {
var sale = $('#sale_id').val();
if (sale!="") {
var sale_id = sale
}else{
var sale_id = $('#save_order_id').attr('data-order');
}
if(sale_id!=""){
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
alert("Please select an table!");
}
return false;
});
});
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
window.location.href = '/origami/sale/'+ sale_id + "/payment";
});
// Bill Request
$('#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();
}
});
});
$('#move').on('click',function(){
var dining_id = "<%= @room.id %>"
window.location.href = '/origami/table/'+ dining_id + "/moveroom";
})
$('#back').on('click',function(){
window.location.href = '/origami/';
})

View File

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