Files
sx-fc/app/views/origami/pending_order/index.html.erb
2020-07-30 13:06:04 +06:30

174 lines
7.9 KiB
Plaintext

<div class="container-fluid m-top-100">
<div class="row clearfix">
<!-- Column One -->
<div class="col-lg-10 col-md-10 col-sm-10">
<!-- Nav tabs -->
<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>
<!-- Nav tabs - End -->
<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">
<% @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;">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>
<!-- Credit Sales 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 %></th>
<th> <%= t :customer %></th>
<th> <%= t("views.right_panel.detail.credit_amount") %> </th>
</thead>
<tbody class="tbd_credit_lists"></tbody>
</table>
</div>
</div>
</div>
<% end %>
<!-- Credit Sales Panel -->
</div>
</div>
</div>
<!-- Column Three -->
<div class="col-lg-2 col-md-2 col-sm-2">
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
<i class="material-icons">reply</i>
<%= t("views.btn.back") %>
</button>
<% 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;
});
$('#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);
});
$('#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';
});
});
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",
html: true,
showCancelButton: true
}, function() {
// Redirect the user
window.location.href = linkURL;
});
}
</script>