Files
sx-fc/app/views/origami/table_invoices/show.html.erb
2018-02-22 18:51:57 +06:30

261 lines
9.3 KiB
Plaintext
Executable File

<div class="container-fluid">
<div class="row">
<% if !@print_settings.nil? %>
<% if @print_settings.precision.to_i > 0
precision = @print_settings.precision
else
precision = 0
end
#check delimiter
if @print_settings.delimiter
delimiter = ","
else
delimiter = ""
end
%>
<% end %>
<div class="col-lg-4 col-md-6 col-sm-6">
<!-- <div class="card-columns" style="padding-top:10px; column-gap: 1.2rem;"> -->
<% @sale_array.each do |sale| %>
<div class="card tables receipt_block" data-id="<%= sale.id %>">
<% if sale.id == @sale.id %>
<div class="card-block selected-item">
<%= sale.receipt_no %>
</div>
<% else %>
<div class="card-block">
<%= sale.receipt_no %>
</div>
<% end %>
</div>
<% end %>
</div>
<div class="col-lg-7 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">
&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.utc.getlocal.strftime("%d/%m/%Y - %I:%M %p") rescue '-'%></span>&nbsp;
</div>
</div>
<div class="card-title row customer_detail">
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @sale.customer_id rescue '' %></p>
&nbsp; Customer : <%= @sale.customer.name rescue '-' %>
<%else%>
<p class="hidden customer-id"><%= @customer.customer_id rescue "" %></p>
&nbsp; Customer : <%= @customer.name rescue "-" %>
<%end%>
</div>
</div>
<div id="order-detail-slimscroll" data-height="160">
<div class="card-text" style="">
<table class="table table-striped" id="order-items-table">
<thead>
<tr>
<th>#</th>
<th class="item-name">Items</th>
<th class="item-attr">QTY</th>
<th class="item-attr">Price</th>
</tr>
</thead>
<tbody>
<%
count = 0
sub_total = 0
if @status_sale == "sale"
@sale.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 %>">
<%
# Can't check for discount
# unless sale_item.price == 0
%>
<tr>
<td><%= count %></td>
<td class='item-name'><%= sale_item.product_name %></td>
<td class='item-attr'><%= sale_item.qty %></td>
<td class='item-attr'><%= number_with_precision(sale_item.price, precision: precision.to_i ) %></td>
</tr>
<%
# end
end
end
if @status_order == 'order' && @status_sale != 'sale'
unless @order_items.nil?
count = 0
@order_items.each do |order_item |
count += 1
sub_total = sub_total + order_item.price
unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'><%= order_item.item_name %></td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= number_with_precision(order_item.qty*order_item.price, precision: precision.to_i ) %></td>
</tr>
<%
end
end
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"><span id="sub_total"><%= number_with_precision(sub_total, precision: precision.to_i ) %></span></strong></td>
</tr>
<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">(<%= number_with_precision(@sale.total_discount, precision: precision.to_i ) rescue 0%>)</strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax:</strong></td>
<td class="item-attr"><strong id="order-Tax"><%= number_with_precision(@sale.total_tax, precision: precision.to_i ) rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong id="order-round-adj"><%= number_with_precision(@sale.rounding_adjustment, precision: precision.to_i ) rescue 0%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total:</strong></td>
<td class="item-attr"><strong id="order-grand-total"><span id="grand_total"><%= number_with_precision(@sale.grand_total, precision: precision.to_i ) rescue 0%></span></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 id="back" type="button" class="btn btn-block btn-lg bg-default"> <i class="material-icons">reply</i> <%= t("views.btn.back") %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button>
<button type="button" id="void" class="btn bg-danger btn-block" active="<%= can? :overall_void, :void %>" > Void </button>
</div>
</div>
</div>
<script>
$(document).ready(function(){
$(".tables").on('click', function(){
var dining_id = $(this).attr("data-id");
window.location.href = '/origami/table/<%= @table.id %>/table_invoice/' + dining_id;
})
});
// $('#pay').on('click',function() {
// window.location.href = '/origami/sale/<%= @sale.id %>/payment';
// });
$('#pay').on('click',function() {
var sale_id = '<%= @sale.id %>';
var url = '<%= @calculate_rouding_adj_path %>';
$.ajax({
type: "GET",
url: url,
success:function(result){
// location.reload();
}
});
window.location.href = '/origami/sale/'+ sale_id + "/cashier/payment";
});
$('#back').on('click',function(){
var lookup_split_bill = '<%= @split_bill %>';
if(lookup_split_bill == '1'){
window.location.href = '/origami/table/<%= @table.id %>/split_bills';
}else{
window.location.href = '/origami/table/<%= @table.id %>';
}
});
$('#void').on('click',function () {
if ($(this).attr('active')=== "true") {
swal({
title: "Alert",
text: "Are you sure want to Void?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, void it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
var sale_id = $('#sale_id').val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami';
}
});
}
});
}else{
swal("Opps","You are not authorized for void","warning");
}
});
$('#foc').click(function() {
var cash = $('#grand_total').text();
var sub_total = $('#sub_total').text();
var sale_id = '';
if($('.receipt_block > div').hasClass('selected-item')){
sale_id = $('.receipt_block > div.selected-item').parent().attr('data-id');
}
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
// console.log(sale_id);
if(sale_id != ''){
if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
window.location.href = '/origami';
});
}
}
});
}else{
swal("Oops","You are not authorized for foc","warning")
}
}
});
</script>