400 lines
17 KiB
Plaintext
400 lines
17 KiB
Plaintext
<div class="container-fluid m-top-100">
|
|
<div class="row">
|
|
<!-- Column One -->
|
|
<div class="col-lg-5 col-md-5 col-sm-5">
|
|
<ul class="nav nav-tabs tab-col-teal" role="tablist">
|
|
<li class="nav-item">
|
|
<a class="nav-link" data-toggle="tab" href="#completed" role="tab"><%= t :competed %></a>
|
|
</li>
|
|
<li class="nav-item">
|
|
<a class="nav-link active" data-toggle="tab" href="#pending_order" role="tab">Pending</a>
|
|
</li>
|
|
<% if @cashier_type == "quick_service" %>
|
|
<li class="nav-item credit_items">
|
|
<a class="nav-link" data-toggle="tab" href="#credits" role="tab"><%= t :credits %></a>
|
|
</li>
|
|
<% end %>
|
|
</ul>
|
|
<div id="custom-slimscroll">
|
|
<div class="tab-content m-t-15">
|
|
<div class="tab-pane" id="completed" role="tabpanel">
|
|
<div class="card-columns">
|
|
<% @completed.each do |sale| %>
|
|
<div class="card completed 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>
|
|
</div>
|
|
|
|
<div class="tab-pane active" id="pending_order" role="tabpanel">
|
|
<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;">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>
|
|
|
|
<!-- Credit Sale Panel -->
|
|
<% if @cashier_type == "quick_service" %>
|
|
<div class="tab-pane dining" id="credits" role="tabpanel">
|
|
<div class="card-block">
|
|
<div class="row m-t-10 m-l-10 clearfix">
|
|
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
|
<input type="text" name="filter" id="filter" onchange="getCreditData('quick_service');" style="height: 32px;" placeholder="Receipt No." class="form-control">
|
|
</div>
|
|
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-12">
|
|
<select class="form-control" id="sel_customer" name="sel_customer" placeholder="Select Customer" onchange="getCreditData('quick_service');">
|
|
<option value="">-- Select Customer --</option>
|
|
<% if !@customers.empty? %>
|
|
<% @customers.each do |cus| %>
|
|
<option value="<%= cus[0] %>"><%= cus[1] %></option>
|
|
<% end %>
|
|
<% end %>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
<div class="row clearfix m-t-20 m-l-10">
|
|
<table class="table table-responsive tbl_credit_lists">
|
|
<thead>
|
|
<th><%= t :credit %> <%= t :sale %> <%= t("views.right_panel.detail.date") %></th>
|
|
<th><%= t("views.right_panel.detail.receipt_no") %></th>
|
|
<th> <%= t :cashier %> <%= t("views.right_panel.detail.name") %></th>
|
|
<th> <%= t :customer %> <%= t("views.right_panel.detail.name") %></th>
|
|
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
|
|
</thead>
|
|
<tbody class="tbd_credit_lists"></tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<% end %>
|
|
<!-- Credit Sale Panel -->
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- Column One -->
|
|
|
|
<!-- Column Two -->
|
|
<div class="col-lg-5 col-md-5 col-sm-5">
|
|
<div class="card" style="height: 100%">
|
|
<div class="card-header">
|
|
<div><strong id="order-title">INVOICE DETAILS </strong>| Table <%= @dining.name rescue "" %></div>
|
|
</div>
|
|
<div class="card-block">
|
|
<div class="card-title row p-l-5 p-r-5">
|
|
|
|
<% if @status == 'sale' %>
|
|
<div class="col-lg-6 col-md-6 col-sm-6">
|
|
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">
|
|
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 '-'%> </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 '-'%> </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">
|
|
<% if @status == 'sale' %>
|
|
Customer : <%= @sale.customer.name rescue "-" %>
|
|
<% else%>
|
|
Customer : <%= @order.customer.name rescue "-" %>
|
|
<% end%>
|
|
</div>
|
|
|
|
</div>
|
|
<div id="order-detail-slimscroll" data-height="140">
|
|
<div class="card-text" style="">
|
|
<table class="table table-striped" id="order-items-table">
|
|
<thead>
|
|
<tr>
|
|
<th class="item-name">Items</th>
|
|
<th class="item-attr">QTY</th>
|
|
<th class="item-attr">Price</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<% 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 %>">
|
|
<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
|
|
total = 0
|
|
@order_items.each do |order_item|
|
|
total = order_item.qty * order_item.price
|
|
sub_total = sub_total + total %>
|
|
<input type="hidden" id="sale_id" value="<%= @bookings.booking_id %>">
|
|
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
|
|
<td class='item-name'><%= order_item.item_name %></td>
|
|
<td class='item-attr'><%= order_item.qty %></td>
|
|
<td class='item-attr'><%= total %></td>
|
|
</tr>
|
|
<% end%>
|
|
<% end%>
|
|
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
</div>
|
|
<div class="pending-order card-footer">
|
|
<table class="table" id="order-charges-table" border="0">
|
|
<% 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>
|
|
<% 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>
|
|
</div>
|
|
</div>
|
|
<!-- Column Three -->
|
|
<div class="col-lg-2 col-md-2 col-sm-2">
|
|
<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">Update Order</button>
|
|
<%end%>
|
|
<!-- <% if @status != "order"%>
|
|
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
|
|
<% end %>
|
|
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
|
|
<% if @status != "order"%>
|
|
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
|
|
<button type="button" id="other-charges" class="btn btn-block bg-blue waves-effect">Charges</button>
|
|
<% end %> -->
|
|
<% if current_user.role != "waiter" && @status != "order"%>
|
|
<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%>
|
|
<% if current_user.role != "waiter" %>
|
|
<button id="close_cashier" type="button" data-count="<%=@occupied_table%>" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.close_cashier") %></button>
|
|
<!-- <button id="cash_in" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_in") %> </button>
|
|
<button id="cash_out" type="button" class="btn btn-block btn-lg bg-blue waves-effect"> <%= t("views.btn.cash_out") %> </button> -->
|
|
<% end %>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<!-- script data for credit lists -->
|
|
<script type="text/html" id="html_credit_items">
|
|
<tr class="row_{key} credit_detail" data-id="{sale_id}" data-type="{cashier_type}">
|
|
<td>{receipt_date}</td>
|
|
<td>{receipt_no}</td>
|
|
<td>{cashier_name}</td>
|
|
<td>{customer_name}</td>
|
|
<td>{credit_amount}</td>
|
|
</tr>
|
|
</script>
|
|
<!-- script data for credit lists -->
|
|
|
|
<script>
|
|
var cashier_type = "<%= @cashier_type %>";
|
|
$(document).ready(function(){
|
|
getCreditSales("","",cashier_type); //credit sales script data binding
|
|
|
|
$(".sales").on('click',function(){
|
|
var sale_id = $(this).attr("data-id");
|
|
window.location.href = '/origami/'+cashier_type+'/pending_order/' + sale_id;
|
|
})
|
|
$(".completed").on('click',function(){
|
|
var sale_id = $(this).attr("data-id");
|
|
window.location.href = '/origami/'+cashier_type+'/completed_sale/' + sale_id;
|
|
})
|
|
$('#pay').on('click', function () {
|
|
var sale_id = $('#sale_id').val();
|
|
window.location.href = '/origami/sale/' + sale_id + "/"+cashier_type+"/payment";
|
|
});
|
|
$('#back').on('click', function () {
|
|
window.location.href = '/origami/'+cashier_type;
|
|
});
|
|
$('#addorder').on('click', function () {
|
|
var table_id = "<%=@table_id%>";
|
|
var booking_id = "<%=@bookings.booking_id%>";
|
|
var sale_id = $("#sale_id").val();
|
|
if (table_id) {
|
|
window.location.href = '/origami/'+cashier_type+'/modify_order/' + table_id+"/"+sale_id;
|
|
}else{
|
|
window.location.href = '/origami/'+cashier_type+'/modify_order/'+ booking_id+"/" +sale_id;
|
|
}
|
|
|
|
});
|
|
// Bill Request
|
|
$('#request_bills').click(function () {
|
|
var order_id = $('#save_order_id').val();
|
|
var ajax_url = "/origami/" +order_id+ "/request_bills";
|
|
console.log(ajax_url);
|
|
$.ajax({
|
|
type: "GET",
|
|
url: ajax_url,
|
|
// data: 'order_id='+ order_id,
|
|
success: function (result) {
|
|
if (!result.status) {
|
|
swal ( "Oops" , result.error_message , "warning" );
|
|
}
|
|
else {
|
|
window.location.href = '/origami/sale/'+result.data+'/'+cashier_type+'/payment';
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
// bind survey to order or sale
|
|
$("#survey").on('click', function () {
|
|
var sale_id = $('#sale_id').val();
|
|
window.location.href = '/origami/' + sale_id +"/"+ cashier_type + "/surveys";
|
|
});
|
|
|
|
// bind customer to order or sale
|
|
$("#customer").on('click', function () {
|
|
var sale = $('#sale_id').val();
|
|
|
|
if (sale.includes("SAL")) {
|
|
var sale_id = sale;
|
|
} else {
|
|
var sale_id = $('#save_order_id').val();
|
|
}
|
|
window.location.href = '/origami/' + sale_id + "/"+cashier_type+"/customers/pending";
|
|
});
|
|
|
|
// Add Other Charges
|
|
$('#other-charges').click(function () {
|
|
var sale = $('#sale_id').val();
|
|
if (sale != "") {
|
|
var sale_id = sale
|
|
} else {
|
|
var sale_id = $('#save_order_id').val();
|
|
}
|
|
if (sale_id != "") {
|
|
window.location.href = '/origami/' + sale_id +"/"+cashier_type+ '/other_charges';
|
|
}
|
|
else {
|
|
swal ( "Oops" , "Please select an table!" , "warning" );
|
|
}
|
|
return false;
|
|
});
|
|
// Discount for Payment
|
|
$('#discount').click(function () {
|
|
if ($(this).attr('active')=== "true") {
|
|
var sale = $('#sale_id').val();
|
|
if (sale != "") {
|
|
var sale_id = sale
|
|
} else {
|
|
var sale_id = $('#save_order_id').val();
|
|
}
|
|
|
|
if (sale_id != "") {
|
|
window.location.href = '/origami/' + sale_id + "/"+cashier_type+'/discount';
|
|
}
|
|
else {
|
|
swal ( "Oops" , "Please select an table!" , "warning" );
|
|
}
|
|
}else{
|
|
swal("Oops","You are not authorized for Discount","warning")
|
|
}
|
|
return false;
|
|
});
|
|
|
|
$('#close_cashier').on('click',function(e){
|
|
e.preventDefault(); // Prevent the href from redirecting directly
|
|
var linkURL = '/origami/shift/'+cashier_type+'/close';
|
|
occupied_count = $(this).data("count");
|
|
warnBeforeRedirect(linkURL,occupied_count);
|
|
});
|
|
|
|
function warnBeforeRedirect(linkURL,occupied_count) {
|
|
|
|
if (occupied_count>0) {
|
|
text = "<h5><span style=\"color: #CC0000\"> We have "+occupied_count+" pending orders and sales</span> </h5>.<br>Are you sure you want to close cashier? ";
|
|
}else{
|
|
text = "Are you sure you want to close cashier?";
|
|
}
|
|
swal({
|
|
title: "Alert!",
|
|
text: text,
|
|
type: "warning",
|
|
showCancelButton: true,
|
|
html: true
|
|
}, function() {
|
|
// Redirect the user
|
|
window.location.href = linkURL;
|
|
});
|
|
}
|
|
|
|
/*edit order in oqs*/
|
|
$('.edit_order').on('click',function(){
|
|
var assigned_order_item_id = $(this).attr('data-id');
|
|
if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){
|
|
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/pending";
|
|
}
|
|
});
|
|
|
|
$('#cash_in').on('click',function(){
|
|
window.location.href = '/origami/'+cashier_type+'/cash_ins';
|
|
})
|
|
|
|
$('#cash_out').on('click',function(){
|
|
window.location.href = '/origami/'+cashier_type+'/cash_outs';
|
|
})
|
|
});
|
|
</script>
|