remove conflict data

This commit is contained in:
phyusin
2018-03-05 16:24:45 +06:30
111 changed files with 3612 additions and 1386 deletions

View File

@@ -1,4 +1,3 @@
<%= stylesheet_link_tag 'addorder', media: 'all', 'data-turbolinks-track': 'reload' %>
<%= javascript_include_tag 'addorder', 'data-turbolinks-track': 'reload' %>
<div id="oqs_loading_wrapper" style="display:none;">
@@ -7,8 +6,8 @@
<% type = request.path_info.include?('quick_service')%>
<% modify_order = request.path_info.include?('modify_order')%>
<input type="hidden" name="type" id="type" value="<%=type%>">
<input type="hidden" name="type" id="modify_order" value="<%=modify_order%>">
<input type="hidden" name="type" id="role" value="<%= current_user.role%>">
<div class="row m-t--20">
<div class="col-lg-2 col-md-2 col-sm-2">
<!-- <a href="javascript:void(0);" class="dropdown-toggle waves-block p-t-15 p-l-15 p-b-15" data-toggle="dropdown" aria-haspopup="" aria-expanded="true" style="background-color: #eeeeee;border-bottom: .214rem solid #fff;border-left: 1px solid #54A5AF;
@@ -46,10 +45,10 @@
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
<ul class="sub_category_list hidden fadeInTop animated" id="sub_category_list">
</ul>
</a>
</li>
@@ -58,7 +57,7 @@
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -67,7 +66,7 @@
</li>
<% end%>
<% else %>
<li class="nav-item menu_category sub_click" data-id="<%=menu.id%>">
<li class="nav-item menu_category sub_click first_<%=menu.id%>" data-id="<%=menu.id%>">
<p class="hidden menu-id"><%= menu.id %></p>
<a class="nav-link" data-toggle="tab" href="" role="tab"> <%= menu.name%>
<ul class=" sub_category_list hidden fadeInTop animated" id="sub_category_list">
@@ -82,46 +81,55 @@
<%end %>
</ul>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 10px;">
<!-- append data -->
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %>
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- else quick_service or cashier for table -->
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<div class="col-md-7 col-lg-7 col-sm-7 m-t-10" >
<div class="card">
<div class="card-block">
<div id="custom-slimscroll">
<div class="card-columns custom-card-columns menu_items_list" style="column-gap: 0.5rem;">
<!-- append data -->
<% @menu.each do |menu| %>
<% if !menu.valid_time.nil? %>
<% if menu.menu_category_id.nil? %>
<!--if type quick_service or cashier for table -->
<% if type %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- else quick_service or cashier for table -->
<% else %>
<% if @table.get_current_checkout_booking.nil? %>
<% if !menu.code.include? "SPL" %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<% else %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- end quick_service or cashier for table -->
<% end %>
<% end%>
<% else %>
<div class="card custom-card testimonial-card animated fadeInRight menu_category sub_click" data-id="<%=menu.id%>">
<div class='card-block custom-card-block'>
<p><%=menu.name%> <p>
<p><%=menu.code%> <p>
</div>
</div>
<% end%>
<!-- end quick_service or cashier for table -->
<% end %>
<% end%>
<% end %>
<%end %>
<% end %>
<%end %>
</div>
</div>
</div>
</div>
</div>
@@ -132,15 +140,19 @@
<!-- <i class="material-icons">reply</i> -->
Back
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-7" id='pending_order'>Pending Order
</button>
<%elsif !modify_order && type%>
<button type="button" class="btn btn-lg btn-default waves-effect col-md-2" id='back' style=" padding: .5rem 0.15rem !important;">
<!-- <i class="material-icons">reply</i> -->
Back
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button>
<button type="button" class="btn btn-lg btn-primary waves-effect col-md-6" id='pending_order' style="padding: .5rem 0.15rem !important;">Pending Order
</button>
<a class="btn btn-lg bg-blue waves-effect select_table col-md-3" data-toggle="modal" data-target="#TableModal" style=" padding: .5rem 0.15rem !important;">Select</a>
<input type="hidden" name="table_id" value="" id="table_id">
@@ -169,7 +181,7 @@
<% end%>
<p class="hidden" id="booking_id"><%=@booking_id%></p>
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : ''%></p>
<p class="hidden" id="customer_id"><%=@customer ? @customer.customer_id : '---'%></p>
<p class="hidden" id="sale_id"><%=@sale_id%></p>
<% else%>
<p class="hidden" id="table_type"></p>
@@ -204,23 +216,29 @@
</div>
<div class="card-footer custom-card-footer" style="padding: 0.35rem 0.15rem !important;">
<!-- <table class="table" id="order-charges-table" border="0">
<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="sub_total">0.00</strong></td>
<td style="padding:2px;" width="5%"></td>
<td style="padding:2px;" width="15%"></td>
<td style="padding:2px; text-align:" class="charges-name" width="25%"><strong>Total:</strong></td>
<td style="padding:2px; text-align:" width="25%" class="item-attr"><strong id="sub_total">0.00</strong></td>
</tr>
</table> -->
</table>
<% if type && modify_order%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary action-btn create col-md-10" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Update Order & Pay</button>
<%elsif !modify_order && type%>
<input type="hidden" name="customer_id" id="customer_id" value="CUS-000000000001">
<button type="button" class="btn btn-primary action-btn create col-md-6" id="create_pay_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create & Pay</button>
<button type="button" class="btn btn-primary action-btn create col-md-5" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<% if current_user.role != "waiter"%>
<button type="button" class="btn btn-primary action-btn create col-md-4" id="create_pay_order" disabled="disabled" style="padding-top:4px !important;padding-bottom:4px !important;"><i class="material-icons" style="font-size:34px;width:34px">attach_money</i></button>
<button type="button" class="btn btn-primary action-btn create col-md-7" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<%end%>
<% if current_user.role == "waiter"%>
<button type="button" class="btn btn-primary action-btn create col-md-7" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<%end%>
<%else%>
<button type="button" class="btn btn-primary action-btn create col-md-10" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Create Order</button>
<button type="button" class="btn btn-primary action-btn create col-md-11" id="create_order" disabled="disabled" style="padding-top:15px !important;padding-bottom:15px !important;">Add Order</button>
<%end%>
@@ -465,6 +483,10 @@
</div>
<% end %>
<script>
jQuery(function(){
id = "<%=@menu[0].id%>";
jQuery('.first_'+id).click();
});
$(document).ready(function () {
$(".tables").on('click', function () {
$('.tables').css('background-color','');

View File

@@ -1,111 +0,0 @@
<div class="row">
<div class="col-lg-11 col-md-11 col-sm-11">
<ul class="nav nav-tabs" role="tablist">
<li class="nav-item">
<a class="nav-link active" data-toggle="tab" href="#table" role="tab">Tables</a>
</li>
<li class="nav-item">
<a class="nav-link" data-toggle="tab" href="#room" role="tab">Rooms</a>
</li>
</ul>
<div class="tab-content" style="max-height:650px; overflow:auto">
<div class="tab-pane active" id="table" role="tabpanel" style="max-height:; overflow:auto">
<% @tables.each do |zone| %>
<h3>Zone : <%=zone.zone.name%></h3>
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @all_table.each do |table| %>
<% if zone.zone_id == table.zone_id %>
<div class="card click_table <%= table.status=="available" ? "available" : "occupied"%>" data-id = "<%= table.id %>">
<div class="card-block">
<p class="hidden table-status"><%= table.status %></p>
<p style="text-align: center"><%= table.name %></p>
<p style="text-align: center">Seat : <%= table.seater %></p>
</div>
</div>
<% end %> <% end %>
</div>
<% end %>
</div>
<div class="tab-pane" id="room" role="tabpanel" style="max-height:; overflow:auto">
<% @rooms.each do |zone| %>
<h3>Zone : <%=zone.zone.name%></h3>
<div class="card-columns" style="padding-top:10px; column-gap: 2.2rem;">
<% @all_room.each do |room| %>
<% if zone.zone_id == room.zone_id %>
<div class="card click_table <%= room.status=="available" ? "available" : "occupied"%>" data-id = "<%= room.id %>">
<div class="card-block">
<p class="hidden table-status"><%= room.status %></p>
<p style="text-align: center"><%= room.name %></p>
<p style="text-align: center">Seat : <%= room.seater %></p>
</div>
</div>
<% end %> <% end %>
</div>
<% end %>
</div>
</div>
</div>
<div class="col-lg-1 col-md-1 col-sm-1">
<button type="button" class="btn btn-block btn-default waves-effect" id='back'>
<i class="material-icons">reply</i>
Back
</button>
</div>
</div>
<script>
$(document).on('click',".click_table",function(){
var dining_id = $(this).attr('data-id');
var status = $(this).find(".table-status").text();
if (status == "available") {
$.confirm({
title: 'Confirmation !',
content: 'Are you sure to assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-green',
action: function(){
window.location.href = '/origami/addorders/'+dining_id;
}
}
}
});
} else {
$.confirm({
title: 'Alert!',
content: 'You cannot assign this table',
buttons: {
confirm: {
text: 'Ok',
btnClass: 'btn-red',
}
}
});
}
})
</script>
<style type="text/css">
.card-columns {
-webkit-column-count:5;
-moz-column-count:5;
column-count:5;
}
.occupied{
color: #fff !important;
background-color: red;
}
.available{
color: #fff !important;
background-color: #009900;
}
</style>

View File

@@ -14,55 +14,7 @@
delimiter = ""
end
%>
<!-- Widgets -->
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-cyan hover-expand-effect">
<div class="icon">
<i class="material-icons">help</i>
</div>
<div class="content">
<div class="text"><%= t :sale_count %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_count%>" data-speed="1000" data-fresh-interval="20"></div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-pink hover-expand-effect">
<div class="icon">
<i class="material-icons">attach_money</i>
</div>
<div class="content">
<div class="text"><%= t :total_sale %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_sale%>" data-speed="15" data-fresh-interval="20"></div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-light-green hover-expand-effect">
<div class="icon">
<i class="material-icons">person_add</i>
</div>
<div class="content">
<div class="text"><%= t :total_credit %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_credit%>" data-speed="1000" data-fresh-interval="20"></div>
</div>
</div>
</div>
<div class="col-lg-3 col-md-3 col-sm-6 col-xs-12">
<div class="info-box bg-orange hover-expand-effect">
<div class="icon">
<i class="material-icons">credit_card</i>
</div>
<div class="content">
<div class="text"><%= t :total_card %></div>
<div class="number count-to" data-from="0" data-to="<%= @total_card%>" data-speed="1000" data-fresh-interval="20"></div>
</div>
</div>
</div>
</div>
<!-- #END# Widgets -->
<!-- Widgets -->
<div class="row clearfix">
<div class="col-lg-3 col-md-3 col-sm-4 col-xs-12 qs_view">
@@ -83,6 +35,7 @@
</div>
</div>
<!-- #END# Widgets -->
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<!-- CPU Usage -->
<div class="row clearfix">
@@ -234,6 +187,7 @@
</div>
</div>
</div>
<% end %>
</div>
<script>

View File

@@ -31,6 +31,7 @@
</div>
<div id="order-detail-slimscroll" data-height="160">
<div class="card-text dining">
<span id="discount_itemsErr" style="color:red;"></span>
<table class="table table-default" id="order-items-table">
<thead>
<tr>
@@ -44,7 +45,7 @@
<% @sale_data.sale_items.each do |sale_item| %>
<%
sub_total += sale_item.qty*sale_item.unit_price
if sale_item.price != 0 && sale_item.remark != "void" && sale_item.remark != "foc"
if sale_item.price != 0 && sale_item.status != "void" && sale_item.status != "foc"
%>
<tr class="item-row" id=<%= sale_item.sale_item_id %> >
<td style="width:60%; text-align:left">
@@ -117,6 +118,7 @@
<div class="col-md-12">
<div class="form-group">
<input type="text" id="discount-amount" name="discount-amount" value="<%= @sale_data.total_discount rescue 0 %>" class="form-control" />
<span id="discount-amountErr" style="color:red;"></span>
</div>
<br>
<div class="form-group">
@@ -253,34 +255,29 @@ var cashier_type = "<%= @cashier_type %>";
if(event.handled !== true) {
var original_value=0;
original_value = $('#discount-amount').val();
var input_type = $(this).attr("data-type");
switch (input_type) {
case 'num':
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
}
break;
var input_value = $(this).attr("data-value");
if (original_value == "0.0"){
$('#discount-amount').val(input_value);
}
else{
$('#discount-amount').val(original_value + '' + input_value);
}
break;
case 'add':
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
break;
var input_value = $(this).attr("data-value");
amount = parseInt(input_value);
$('#discount-amount').val(amount);
break;
case 'del' :
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
var discount_text=$('#discount-amount').val();
$('#discount-amount').val(discount_text.substr(0,discount_text.length-1));
break;
case 'clr':
$('#discount-amount').val("0.0");
break;
$('#discount-amount').val("0.0");
break;
}
event.handled = true;
} else {
@@ -334,24 +331,40 @@ var cashier_type = "<%= @cashier_type %>";
$("#net").on('click', function(e){
e.preventDefault();
var sale_id = $('#sale-id').text();
var discount_value = parseFloat($('#discount-amount').val());
var discount_value = $('#discount-amount').val();
var sub_total = parseFloat($('#order-sub-total').text());
var ajax_url = "/origami/" + sale_id + "/discount";
if(discount_value!=""){
if(discount_value > 0){
if(parseFloat(discount_value) > sub_total){
$("#discount-amount").val("");
$("#discount-amountErr").html("Discount is greater than sub total!");
}else{
$("#discount-amountErr").html("");
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Items
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
// Selected Account
var account_types = get_selected_account_types();
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(0, discount_value);
}
else {
calculate_item_discount(0, discount_value, sale_items, account_types);
}
if(sale_items.length == 0 && account_types.length == 0){
calculate_overall_discount(0, discount_value);
// Remove Selection
selection_remove();
}
}else{
$("#discount-amountErr").html("Discount must be greater than 0!");
}
}else{
$("#discount-amountErr").html("can't be blank");
}
else {
calculate_item_discount(0, discount_value, sale_items, account_types);
}
// Remove Selection
selection_remove();
});
// Calculate Percentage Discount for Payment
@@ -362,8 +375,7 @@ var cashier_type = "<%= @cashier_type %>";
var ajax_url = "/origami/" + sale_id + "/discount";
// Selected Items
var sale_items = get_selected_sale_items();
var sale_items = get_selected_sale_items();
// Selected Account
var account_types = get_selected_account_types();
@@ -437,7 +449,6 @@ var cashier_type = "<%= @cashier_type %>";
// Selected Items
var sale_items = get_selected_sale_items();
console.log(sale_items.length);
if(sale_items.length == 0){
//swal("Information!", "You have no selected item!");
swal ( "Oops" , "You have no selected item!" , "error" );
@@ -671,113 +682,150 @@ function calculate_item_discount(type, amount, sale_items, account_types){
var dis_amount = 0;
var sub_total = 0;
var total_discount = 0;
var arrItemName = "";
$("#discount_itemsErr").html("");
$("#discount-amountErr").html("");
// For Net Pay
if(type == 0){
dis_amount = (0 - amount);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// else {
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + amount;
// }
}
}
// No Needs For Auto Selected
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
sub_total = origin_sub_total - total_discount;
}
// For Percentage Pay
if(type == 1){
if(amount > 100 ){
swal({
title:"Oops!",
text:'Percentage Value over 100!',
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
}
else{
// Check sale items exists
if(origin_sub_total > 0){
if(type == 0){
dis_amount = (0 - amount);
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
// var discount_item_row = item_row_template(type, sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// total_discount = total_discount + amount;
// }
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
$("#order-items-table tbody").append(discount_item_row);
total_discount = total_discount + dis_amount;
if(parseFloat(amount) > parseFloat(sale_items[i].price)){
arrItemName += ", " + sale_items[i].name;
}else{
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = parseFloat(total_discount) + parseFloat(amount);
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
}else{
total_discount = parseFloat(total_discount) - parseFloat(amount);
$("#discount-amountErr").html("Discount is greater than sub total!");
}
}
// }
}
sub_total = origin_sub_total + total_discount;
}
if(arrItemName!=""){
arrItemName = arrItemName.substr(2);
if(arrItemName.match(/,/g || []) != null){
if(arrItemName.match(/,/g || []).length >= 1){
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" prices");
}
}else{
$("#discount_itemsErr").html("Discount is greater than "+arrItemName+" price");
}
}
// No Needs For Auto Selected
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
sub_total = parseFloat(origin_sub_total) - parseFloat(total_discount);
}
// No Needs For Auto Selected
// Check account types exists
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// console.log(account_types);
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
// For Percentage Pay
if(type == 1){
if(amount > 100 ){
swal({
title:"Oops!",
text:'Percentage Value over 100!',
type: "error",
confirmButtonText: 'OK',
confirmButtonColor:"red"
});
}
else{
// Check sale items exists
if(sale_items.length > 0){
for(var i=0;i < sale_items.length;i++){
// if(account_types.length > 0){
// for(var j=0; j < account_types.length; j++){
// if(sale_items[i].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((sale_items[i].price * amount)/100);
// var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// else {
dis_amount = 0 - ((sale_items[i].price * amount)/100);
var discount_item_row = item_row_template(type,sale_items[i], dis_amount, amount);
total_discount = total_discount + dis_amount;
if(parseFloat(origin_sub_total) >= parseFloat(total_discount)){
$("#order-items-table tbody").append(discount_item_row);
}else{
total_discount = total_discount - dis_amount;
$("#discount-amountErr").html("Discount is greater than sub total!");
}
// }
}
sub_total = parseFloat(origin_sub_total) + parseFloat(total_discount);
}
}
// No Needs For Auto Selected
// Check account types exists
// if(account_types.length > 0){
// var item_rows=get_item_rows();
// console.log(account_types);
// if(item_rows.length > 0){
// for(var k=0; k < item_rows.length; k++){
// for(var j=0; j < account_types.length; j++){
// if(item_rows[k].account_id == account_types[j].id){
// // Discount Items
// dis_amount = 0 - ((item_rows[k].price * amount)/100);
// var discount_item_row = item_row_template(type, item_rows[k], dis_amount, amount);
// $("#order-items-table tbody").append(discount_item_row);
// total_discount = total_discount + dis_amount;
// }
// }
// }
// }
// else {
// alert("No Items!");
// }
// }
}
$("#order-sub-total").text(parseFloat(sub_total).toFixed(2));
}else{
$("#discount-amountErr").html("Discount is greater than sub total!");
}
$("#order-sub-total").text(sub_total);
}
function item_row_template(type, item, discount_amount, amount){

View File

@@ -276,11 +276,11 @@
</tr>
<%
# end
end
end
if @status_order == 'order' && @status_sale != 'sale'
puts
unless @order_items.nil? || @order_items.empty?
count = 0
@order_items.each do |order_item|
@@ -288,19 +288,19 @@
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
# end
@@ -367,21 +367,19 @@
@order_items.each do |order_item|
count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
%>
@@ -427,8 +425,10 @@
<%= t("views.btn.back") %>
</button>
<button type="button" id="add_order" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.add") %> <%= t("views.right_panel.detail.order") %></button>
<% if current_login_employee.role != "waiter" %>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect"><%= t("views.right_panel.detail.survey") %></button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<% if @dining.status != "available" %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect" >Customer</button>
@@ -447,13 +447,24 @@
<!-- <button type="button" class="btn btn-block bg-blue waves-effect" disabled> Void</button> -->
<% end %>
<% if @status_sale == 'sale' %>
<% if current_login_employee.role != "waiter" %>
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<% end %>
<button type="button" id="customer" class="btn btn-block bg-blue waves-effect">Customer</button>
<% if current_login_employee.role != "waiter" %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
<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 !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<% if current_login_employee.role != "waiter" %>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
@@ -464,14 +475,9 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<% end %>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
<% end %>
<% end %>
<!-- Cashier Buttons -->
<!-- <button type="button" id="re-print" class="btn btn-block bg-blue waves-effect" >Re.Print</button> -->
@@ -513,6 +519,30 @@
</div>
</div>
</div>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect " id="void" active="true">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
cashier_type = "cashier"
$(document).ready(function () {
@@ -845,9 +875,12 @@
if (isConfirm) {
var sale_id = "<%= @obj_sale.sale_id rescue "" %>"
var ajax_url = "/origami/sale/" + sale_id + '/void';
var remark = $("#remark").val();
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
window.location.href = '/origami/';
}
@@ -898,4 +931,13 @@
}
});
});
/*edit order in oqs*/
$('.edit_order').on('click',function(){
var assigned_order_item_id = $(this).attr('data-id');
var dining_id = "<%= @dining.id %>";
if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/"+dining_id;
}
});
</script>

View File

@@ -2,6 +2,21 @@
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<% 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="row clearfix">
<div class="col-lg-6 col-md-6 col-sm-6 col-xs-6">
<div class="card">
@@ -56,9 +71,9 @@
<% sub_total += sale_item.price%>
<tr>
<td><%= count %></td>
<td class="item-name"><%=sale_item.product_name%>@<%=sale_item.unit_price%></td>
<td class="item-name"><%=sale_item.product_name%>@<%=number_with_precision( sale_item.unit_price, precision: precision.to_i )%></td>
<td class="item-attr"><%=sale_item.qty%></td>
<td class="item-attr"><%=(sale_item.price)%></td>
<td class="item-attr"><%=(number_with_precision(sale_item.price, precision: precision.to_i ))%></td>
</tr>
<%end %>
</tbody>
@@ -71,7 +86,7 @@
<tfooter>
<tr>
<td class="charges-name"><strong>Sub Total</strong></td>
<td class="item-attr"><strong><span id="sub-total"><%=sub_total%></span></strong></td>
<td class="item-attr"><strong><span id="sub-total"><%=number_with_precision(sub_total, precision: precision.to_i)%></span></strong></td>
</tr>
<tr>
<%if @sale_data.discount_type == 'member_discount'%>
@@ -79,7 +94,7 @@
<%else%>
<td class="charges-name"><strong>(Discount)</strong></td>
<%end%>
<td class="item-attr"><strong><span>(<%=@sale_data.total_discount rescue 0%>)</span></strong></td>
<td class="item-attr"><strong><span>(<%= number_with_precision(@sale_data.total_discount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %>)</span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Tax
@@ -91,22 +106,36 @@
<%end%>
<%end %>)
</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.total_tax rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.total_tax, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Rounding Adj:</strong></td>
<td class="item-attr"><strong><%= @sale_data.rounding_adjustment rescue 0%></strong></td>
<td class="item-attr"><strong><%= number_with_precision(@sale_data.rounding_adjustment, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></strong></td>
</tr>
<tr>
<td class="charges-name"><strong>Grand Total</strong></td>
<td class="item-attr"><strong><span><%=@sale_data.grand_total rescue 0%></span></strong></td>
<td class="item-attr"><strong><span><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i )%></span></strong></td>
</tr>
<%if @balance > 0%>
<tr>
<td class="charges-name"><strong><%= @accountable_type %></strong></td>
<td class="item-attr"><strong><span><%=@balance%></span></strong></td>
<td class="item-attr"><strong><span><%=number_with_precision(@balance, precision: precision.to_i )%></span></strong></td>
</tr>
<% end %>
<% if !@individual_total[0].nil? %>
<tr>
<td class="charges-name">
<strong>Split Bill for <%= @individual_total[0]['total_customer'] %> persons</strong>
</td>
<td></td>
</tr>
<tr>
<td class="charges-name">
<strong>Amount Due (per person)</strong>
</td>
<td class="item-attr"><strong><span><%= number_with_precision(@individual_total[0]['per_person_amount'], precision: precision.to_i )%></span></strong></td>
</tr>
<% end %>
</tfooter>
</table>
</div>
@@ -124,24 +153,24 @@
<div class="col-md-8"><strong>Amount Due</strong></div>
<div class="col-md-4">
<strong>
<span id="grand_total" class="hidden"><%= @sale_data.grand_total rescue 0%></span>
<span id="amount_due"><%= @sale_data.grand_total rescue 0%></span></strong>
<span id="grand_total" class="hidden"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i)%></span>
<span id="amount_due"><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong>
</div>
</div>
<div class="row payment cash-color p-l-5 p-r-5">
<div class="col-md-8">Cash</div>
<div class="col-md-4" id="cash" ><%= @cash %></div>
<div class="col-md-4" id="cash" ><%= number_with_precision(@cash, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<div class="row payment credit-color p-l-5 p-r-5" id="credit_payment" >
<div class="col-md-8">Credit</div>
<div class="col-md-4" id="credit"><%= @credit %></div>
<div class="col-md-4" id="credit"><%= number_with_precision(@credit, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% if @other == 0.0 && @ppamount == 0.0 && @visacount == 0.0 && @jcbcount == 0.0 && @mastercount == 0.0%>
<div class="row payment other-payment-color" id="card_payment" >
<div class="col-md-8">Other Payments</div>
<div class="col-md-4" id="others"><%= @other %></div>
<div class="col-md-4" id="others"><%= number_with_precision(@other, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i) %></div>
</div>
<% else %>
<div class="row payment other-payment-color" id="card_payment" >
@@ -156,13 +185,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4 mpu is_card" id="others"><%= @other %></div>
<div class="col-md-4 mpu is_card" id="others"><%= number_with_precision(@other, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">MPU</div>
<div class="col-md-4" id="others">0.0</div>
<div class="col-md-4" id="others"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- paypar -->
@@ -170,13 +199,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount"><%= @ppamount %></div>
<div class="col-md-4" id="ppamount"><%= number_with_precision(@ppamount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">Redeem</div>
<div class="col-md-4" id="ppamount">0.0</div>
<div class="col-md-4" id="ppamount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- Visa -->
@@ -184,13 +213,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<div class="col-md-4 visa is_card" id="visacount"><%= @visacount %></div>
<div class="col-md-4 visa is_card" id="visacount"><%= number_with_precision(@visacount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">VISA</div>
<div class="col-md-4" id="visacount">0.0</div>
<div class="col-md-4" id="visacount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- JCB -->
@@ -198,13 +227,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= @jcbcount %></div>
<div class="col-md-4 jcb is_card" id="jcbcount"><%= number_with_precision(@jcbcount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">JCB</div>
<div class="col-md-4" id="jcbcount">0.0</div>
<div class="col-md-4" id="jcbcount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- Master -->
@@ -212,13 +241,13 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4 master is_card" id="mastercount"><%= @mastercount %></div>
<div class="col-md-4 master is_card" id="mastercount"><%= number_with_precision(@mastercount, precision: precision.to_i) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">MASTER</div>
<div class="col-md-4" id="mastercount">0.0</div>
<div class="col-md-4" id="mastercount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<!-- <br> -->
@@ -227,18 +256,18 @@
<div class="row payment others-color">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4 master is_card" id="unionpaycount"><%= @unionpaycount %></div>
<div class="col-md-4 master is_card" id="unionpaycount"><%= number_with_precision(@unionpaycount, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% else %>
<div class="row hidden">
<div class="col-md-5"></div>
<div class="col-md-3">UNIONPAY</div>
<div class="col-md-4" id="unionpaycount">0.0</div>
<div class="col-md-4" id="unionpaycount"><%= number_with_precision(0, precision: precision.to_i ) %></div>
</div>
<% end %>
<div class="row m-l-5 m-r-5">
<div class="col-md-8"><strong>Balance</strong></div>
<div class="col-md-4"><strong><span id='balance'><%= @sale_data.grand_total rescue 0 %></span></strong></div>
<div class="col-md-4"><strong><span id='balance'><%= number_with_precision(@sale_data.grand_total, precision: precision.to_i ) rescue number_with_precision(0, precision: precision.to_i ) %></span></strong></div>
</div>
<!-- <br> -->
</div>
@@ -295,8 +324,8 @@
<i class="material-icons">reply</i>
Back
</button>
<button type="button" class="btn bg-deep-purple btn-block" id="foc" active="<%= can? :foc, :payment %>"> FOC </button>
<button type="button" class="btn bg-red btn-block" id="void" active="<%= can? :overall_void, :void %>"> Void </button>
<button type="button" class="btn bg-deep-purple btn-block" data-toggle="modal" data-target="#focModal" <%= (can? :foc, :payment)? ' ': 'disabled=' %> active="true"> FOC </button>
<button type="button" class="btn bg-red btn-block" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void </button>
<% if @cashier_type=="quick_service" %>
<hr>
@@ -310,8 +339,52 @@
</div>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
</div>
<div class="modal fade" id="voidModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="voidModalLabel">Please Enter Reason for Void</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect " id="void" active="true">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="modal fade" id="focModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="focModalLabel">Please Enter Reason for FOC</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="foc_remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link bg-red waves-effect " id="foc" active="true">FOC</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
$(document).ready(function(){
@@ -422,7 +495,7 @@ console.log("fffffffffffff")
swal ( "Oops" , "Please select an table!" , "warning" );
}
}else{
swal("Opps","You are not authorized for Discount","warning")
swal("Oops","You are not authorized for Discount","warning")
}
return false;
});
@@ -438,7 +511,7 @@ console.log("fffffffffffff")
}
}else{
swal("Opps","You are not authorized for void","warning")
swal("Oops","You are not authorized for void","warning")
}
});
@@ -488,8 +561,13 @@ console.log("fffffffffffff")
var unionpay1 = $('#unionpaycount').text();
var othertotal = parseFloat(credit1) + parseFloat(card1) + parseFloat(paypar1) + parseFloat(visa1) + parseFloat(jcb1) + parseFloat(master1) + parseFloat(unionpay1);
var total = $('#amount_due').text();
var amt = parseFloat(total) - parseFloat(othertotal);
$('#cash').text(parseFloat(amt).toFixed(1));
var amt = 0;
<% if precision.to_i > 0 %>;
amt = parseFloat(parseFloat(total) - parseFloat(othertotal)).toFixed(<%= precision %>);
<% else %>
amt = parseFloat(parseFloat(total) - parseFloat(othertotal));
<% end %>
$('#cash').text(amt);
update_balance();
break;
}
@@ -520,23 +598,23 @@ console.log("fffffffffffff")
$('#pay').click(function() {
sub_total = $('#sub-total').text();
if (payment_type == 'MPU' && $('.mpu').text() == 0 && sub_total != 0.0) {
swal("Opps","Please Pay with MPU Payment","warning");
swal("Oops","Please Pay with MPU Payment","warning");
}else if(payment_type == "Redeem" && $('#ppamount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Redeem Payment","warning");
swal("Oops","Please Pay with Redeem Payment","warning");
}else if(payment_type == "VISA" && $('#visacount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Visa Payment","warning");
swal("Oops","Please Pay with Visa Payment","warning");
}else if(payment_type == "JCB" && $('#jcbcount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with jcb Payment","warning");
swal("Oops","Please Pay with jcb Payment","warning");
}
else if(payment_type == "Master" && $('#mastercount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Master Payment","warning");
swal("Oops","Please Pay with Master Payment","warning");
}
else if(payment_type == "UNIONPAY" && $('#unionpaycount').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with UNIONPAY Payment","warning");
swal("Oops","Please Pay with UNIONPAY Payment","warning");
}
else if(payment_type == "Credit" && $('#credit').text()==0 && sub_total != 0.0){
swal("Opps","Please Pay with Credit Payment","warning");
swal("Oops","Please Pay with Credit Payment","warning");
}else{
$( "#loading_wrapper").show();
@@ -615,30 +693,55 @@ console.log("fffffffffffff")
}
});
$('#void').on('click',function () {
if ($(this).attr('active') === "true") {
// $('#void').on('click',function () {
// if ($(this).attr('active') === "true") {
// var sale_id = $('#sale_id').text();
// var remark = $("#remark").val();
// var ajax_url = "/origami/sale/" + sale_id + '/void';
// $.ajax({
// type: 'POST',
// url: ajax_url,
// data: "remark="+ remark + "&sale_id=" + sale_id,
// success: function () {
// window.location.href = '/origami/';
// }
// })
// }else{
// swal("Opps","You are not authorized for void","warning")
// }
// });
$('#void').on('click', function () {
if ($(this).attr('active')=== "true") {
swal({
title: "Information!",
text: 'Are you sure want to Void !',
}, function () {
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').text();
var remark = $("#remark").val();
var ajax_url = "/origami/sale/" + sale_id + '/void';
$.ajax({
type: 'POST',
url: ajax_url,
data: "remark="+ remark + "&sale_id=" + sale_id,
success: function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
}
}
})
});
}
});
}else{
swal("Opps","You are not authorized for void","warning")
swal("Oops","You are not authorized for void","warning")
}
});
});
@@ -654,43 +757,57 @@ console.log("fffffffffffff")
var amount_due = $('#amount_due').text();
var total = parseFloat(cash) + parseFloat(credit) + parseFloat(card) + parseFloat(paypar) + parseFloat(visa) + parseFloat(jcb) + parseFloat(master) + parseFloat(unionpay)
var result = parseFloat(amount_due) - parseFloat(total);
$('#balance').text(result.toFixed(2));
<% if precision.to_i > 0 %>
$('#balance').text(parseFloat(result).toFixed(<%= precision %>));
<% else %>
$('#balance').text(parseFloat(result));
<% end %>
}
$('#foc').click(function() {
//$( "#loading_wrapper" ).show();
// payment
var remark = $("#foc_remark").val();
var cash = $('#grand_total').text();
var sub_total = $('#sub-total').text();
var sale_id = $('#sale_id').text();
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total };
var params = { 'cash':cash,'sale_id':sale_id,'sub_total':sub_total,'remark':remark,'type':cashier_type };
if ($(this).attr('active')=== "true") {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
//$( "#loading_wrapper" ).hide();
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
}
swal({
title: "Alert",
text: "Are you sure want to FOC This Receipt?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, FOC it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "<%= origami_payment_foc_path %>",
data: params,
success:function(result){
if (cash >= 0) {
swal({
title: "Information!",
text: 'Thank You !',
}, function () {
if (cashier_type=="cashier") {
window.location.href = '/origami';
}else{
window.location.href = '/origami/quick_service';
}
});
}
}
});
}
});
});
}else{
swal("Opps","You are not authorized for foc","warning")
swal("Oops","You are not authorized for foc","warning")
}
});

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" && @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%>
</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>

View File

@@ -277,19 +277,19 @@
sub_total = sub_total + (order_item.price * order_item.qty)
# unless order_item.price == 0 %>
<tr>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %></td>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
# end
@@ -345,20 +345,19 @@
@order_items.each do |order_item |
count += 1
%>
<tr>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<tr class="edit_order" data-id='<%= order_item.order_items_id %>'>
<td><%= count %>
<td class='item-name'>
<%= order_item.item_name %>
<% if !order_item.set_menu_items.nil?
order_item.set_menu_items.each do |item_instance| %>
<br><span class="font-13"><%= item_instance %></span>
<% end
end %>
</td>
<td class='item-attr'><%= order_item.qty %></td>
<td class='item-attr'><%= order_item.qty*order_item.price %></td>
</tr>
<%
end
@@ -397,7 +396,10 @@
<!-- Waiter Buttons -->
<button type="button" class="btn btn-default btn-block" id='back'><i class="material-icons">reply</i> Back</button>
<button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button>
<% if current_login_employee.role == "administrator" || current_login_employee.role == "manager" || current_login_employee.role == "supervisor" || current_login_employee.role == "cashier" || current_login_employee.role == "waiter" %>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button>
<% end %>
<% if current_login_employee.role != "waiter" %>
<% if @room.bookings.length >= 1 %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> -->
@@ -420,6 +422,7 @@
<% if @status_sale == 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" disabled>Add Order</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<% if current_login_employee.role != "waiter" %>
<button type="button" class="btn btn-block bg-blue waves-effect" id='edit' <%= (can? :edit, :sale_edit)? ' ': 'disabled=' %> active="true">Edit</button>
<button type="button" id="void" class="btn btn-block bg-blue waves-effect" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true"> Void</button>
<button type="button" id="discount" class="btn btn-block bg-blue waves-effect" <%= (can? :index, :discount)? ' ': 'disabled=' %> active="true">Discount</button>
@@ -427,6 +430,13 @@
<button type="button" id="commissions" class="btn btn-block bg-blue waves-effect">Commissions</button>
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<% end %>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<% if current_login_employee.role != "waiter" %>
<!-- first bill not used in cloud -->
<% if ENV["SERVER_MODE"] == "cloud" %>
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
@@ -437,14 +447,11 @@
<button type="button" id="first_bill" class="btn btn-block bg-blue waves-effect">First Bill</button>
<%end%>
<%end%>
<% if !@split_bill.nil? %>
<% if @split_bill == '1' %>
<button type="button" id="split_bills" class="btn btn-block bg-blue waves-effect">Split Bill</button>
<% end %>
<% end %>
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<% end %>
<!-- <button type="button" id="void" class="btn bg-blue btn-block" > Void </button> -->
<% end %>
<% if current_login_employee.role != "waiter" %>
<input type="hidden" id="server_mode" value="<%= ENV["SERVER_MODE"] %>">
<span class="hidden" id="member_discount"><%= @membership.discount%></span>
<span class="hidden" id="membership_id"><%= @obj_sale.customer.membership_id rescue 0%></span>
@@ -475,9 +482,10 @@
</div>
</div>
<!-- Cashier Buttons -->
<% end %>
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
<% end %>
<% end %>
</div>
</div>
</div>
@@ -901,4 +909,13 @@ $('#add_invoice').on('click',function(){
}
});
});
/*edit order in oqs*/
$('.edit_order').on('click',function(){
var assigned_order_item_id = $(this).attr('data-id');
var dining_id = "<%= @room.id %>";
if((assigned_order_item_id!=undefined) && (assigned_order_item_id!='')){
window.location.href = '/oqs/'+ assigned_order_item_id + "/edit/"+dining_id;
}
});
</script>

View File

@@ -1,7 +1,7 @@
<div class="container-fluid">
<div class="row">
<!-- Column Two -->
<div class="col-lg-10 col-md-10 col-sm-10">
<div class="col-lg-11 col-md-11 col-sm-11">
<div class="card">
<div class="card-header">
<div><strong id="order-title">INVOICE DETAILS </strong></div>
@@ -57,23 +57,26 @@
<td class="p-2" width="20%">
<%= sale_item.product_name %>
</td>
<% if sale_item.remark != 'void' && sale_item.remark != 'edit' && sale_item.remark != 'foc' %>
<% if sale_item.status != 'void' && sale_item.status != 'edit' && sale_item.status != 'foc' %>
<td class="p-1" width="5%">
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control "/>
<input id="<%= sale_item.id %>_qty" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control " onkeyup="checkQuantity(this.value,'<%= sale_item.id %>');" onkeypress="return isNumberKey(event);" />
<span id="<%= sale_item.id %>_qtyErr" style="color:red;"></span>
</td>
<td class="p-1" width="10%">
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control"/>
<input id="<%= sale_item.id %>_price" data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.unit_price %>" class="form-control" onkeypress="return isNumberKey(event);"/>
<span id="<%= sale_item.id %>_priceErr" style="color:red;"></span>
</td>
<!-- <td class='' width="17%">
<input id="<%= sale_item.id %>_price" data-id ="<%= sale_item.id %>" type="text" value="<%= sale_item.price %>" class="form-control"/>
</td> -->
<td class="p-1" width="25%">
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-blue waves-effect update'>Update</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-danger waves-effect void'>Void</button>
<button data-id="<%= sale_item.id %>" class='btn btn-lg bg-red waves-effect foc'>FOC</button>
<button data-id="<%= sale_item.id %>" data-type="void" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">Void</button>
<button data-id="<%= sale_item.id %>" data-type="foc" class='editModal btn btn-lg bg-danger waves-effect' data-toggle="modal" data-target="#editModal">FOC</button>
</td>
<% elsif sale_item.qty.to_i < 0 || sale_item.remark == 'edit' %>
<% elsif sale_item.qty.to_i < 0 || sale_item.status == 'edit' %>
<td class="p-1" width="5%">
<input data-id="<%= sale_item.id %>" type="text" value="<%= sale_item.qty %>" class="form-control" disabled/>
</td>
@@ -148,48 +151,114 @@
</div>
</div>
</div> -->
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
<!-- Column Three -->
<div class="col-lg-1 col-md-1 col-sm-1">
<!-- Waiter Buttons -->
<button type="button" class="btn btn-block btn-lg bg-default waves-effect" id='back'><i class="material-icons">reply</i>Back</button>
<button type="button" class="btn btn-danger btn- action-btn" id='cancel_all_void'>Cancel All Void</button>
<button type="button" class="btn btn-block btn-lg bg-blue waves-effect" id='apply'>Apply</button>
</div>
</div>
</div>
<div class="modal fade" id="editModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="editModalLabel">Please Enter Remark</h4>
</div>
<div class="modal-body">
<input type="textarea" name="remark" class="form-control col-md-12 remark" id="remark">
</div>
<div class="modal-footer ">
<div class="row p-r-20">
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-red waves-effect" id="action">VOID</button>
</div>
<div class="col-md-5">
<button type="button" class="btn btn-link p-t-5 p-b-5 bg-blue waves-effect" data-dismiss="modal">CLOSE</button>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
var cashier_type = "<%= @cashier_type %>";
// Bill Request
$(document).ready(function () {
$('.editModal').on('click', function () {
$("#action").attr('data-type', $(this).attr('data-type'));
$("#action").attr('data-id', $(this).attr('data-id'));
$("#action").text($(this).attr('data-type'))
})
$(".update").on('click', function () {
var sale_item_id = $(this).attr('data-id');
var qty = $('#' + sale_item_id + "_qty").val();
var price = $('#' + sale_item_id + "_price").val();
console.log(qty + "|" + price)
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
swal({
title: "Information!",
text: "Qty and Price was successfully Updated",
}, function () {
location.reload();
});
}
});
console.log(qty + "|" + price);
var qty_status = true;
var price_status = true;
if((qty > 0) && (price > 0)){
qty_status = true;
price_status = true;
$('#' + sale_item_id + "_qtyErr").html("");
$('#' + sale_item_id + "_priceErr").html("");
}else if((qty > 0) && (price <= 0 || price == '')){
price_status = false;
$('#' + sale_item_id + "_qtyErr").html("");
if(price == ''){
$('#' + sale_item_id + "_priceErr").html("can't be blank");
}else{
$('#' + sale_item_id + "_price").val("");
$('#' + sale_item_id + "_priceErr").html("Price must be greater than 0");
}
}else if((qty <= 0 || qty == '') && (price > 0)){
qty_status = false;
if(qty == ''){
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
}else{
$('#' + sale_item_id + "_qty").val("");
$('#' + sale_item_id + "_qtyErr").html("Quantity must be greater than 0");
}
$('#' + sale_item_id + "_priceErr").html("");
}else{
qty_status = false;
price_status = false;
$('#' + sale_item_id + "_qtyErr").html("can't be blank");
$('#' + sale_item_id + "_priceErr").html("can't be blank");
}
if(qty_status && price_status){
var ajax_url = "/origami/item_edit";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&update_qty=" + qty + "&update_price=" + price,
success: function (result) {
swal({
title: "Information!",
text: "Qty and Price was successfully Updated",
}, function () {
location.reload();
});
}
});
}
});
$('.void').on('click', function () {
/*$('.void').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var remark = $("#remark").val();
var ajax_url = "/origami/item_void";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
@@ -202,7 +271,27 @@ var cashier_type = "<%= @cashier_type %>";
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
});
})*/
$('#action').on('click', function () {
var sale_item_id = $(this).attr('data-id');
var type = $(this).attr('data-type');
var remark = $("#remark").val();
if (type=='foc') {
var ajax_url = "/origami/item_foc";
}else{
var ajax_url = "/origami/item_void";
}
$.ajax({
type: "POST",
url: ajax_url,
data: 'sale_item_id=' + sale_item_id + "&remark=" + remark,
success: function (result) {
location.reload();
}
@@ -225,6 +314,7 @@ var cashier_type = "<%= @cashier_type %>";
})
$('#back').on('click', function () {
var table_id = '<%= @table_id %>'
var sale_id = "<%= @saleobj.sale_id %>"
@@ -311,4 +401,24 @@ var cashier_type = "<%= @cashier_type %>";
return false;
}
});
//check for isNumber
function isNumberKey(evt) {
var charCode = (evt.which) ? evt.which : event.keyCode;
if (charCode > 31 && (charCode < 48 || charCode > 57)) {
return false;
} else {
return true;
}
}
function checkQuantity(obj_value,sale_item_id) {
if(obj_value == '0'){
$("#"+sale_item_id+"_qty").val('1');
}
}
function checkPrice(obj_value,sale_item_id) {
}
</script>

View File

@@ -65,6 +65,8 @@
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=odr_item['order_id'] %></span>
<span id="item-account-type" class="hidden"><%=odr_item['account_id'] %></span>
<span id="item-code" class="hidden"><%=odr_item['item_code'] %></span>
<span id="item-instance-code" class="hidden"><%=odr_item['item_instance_code'] %></span>
<span id="item-name-price">
<%=odr_item['item_name'] %>
<% if !odr_item['set_menu_items'].nil?
@@ -132,6 +134,8 @@
<td style="width:60%; text-align:left">
<span id="item-order-id" class="hidden"><%=order_item[order.order_id.to_s]['order_id'] %></span>
<span id="item-account-type" class="hidden"><%=order_item[order.order_id.to_s]['account_id'] %></span>
<span id="item-code" class="hidden"><%=order_item[order.order_id.to_s]['item_code'] %></span>
<span id="item-instance-code" class="hidden"><%=order_item[order.order_id.to_s]['item-instance-code'] %></span>
<span id="item-name-price">
<%=order_item[order.order_id.to_s]['item_name'] %>
<% if !order_item[order.order_id.to_s]['set_menu_items'].nil?
@@ -194,7 +198,9 @@
<th>#</th>
<th>Receipt No.</th>
<th>Total</th>
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<th>Action</th>
<% end %>
</thead>
<tbody>
<% @sale_data.each_with_index do |sale_data, sale_index| %>
@@ -207,9 +213,12 @@
<td><input type="radio" name="rdn_receipt" id="rdn_receipt" value="<%= sale_data.sale_id %>" <%= checked %>></td>
<td><span id="receipt_no"><%= sale_data.receipt_no %></span></td>
<td><span id="grand_total"><%= sale_data.grand_total %></span></td>
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<td>
<button type="button" class="btn btn-block waves-effect btn-primary btn_pay" id=<%= sale_data.sale_id %> >Pay</button>
</td>
<% end %>
</tr>
<% end %>
<% end %>
@@ -228,9 +237,15 @@
<!-- Action Panel -->
<div>
<button type="button" class="btn bg-default btn-block waves-effect" id="back" ><i class="material-icons">reply</i> Back </button>
<button id="equal_split" class="btn btn-block waves-effect bg-blue">= Split</button>
<button id="order_split" class="btn btn-block waves-effect bg-blue">By Order</button>
<button id="order_item_split" class="btn btn-block waves-effect bg-blue">By Order Item</button>
<% if !@current_user.nil? && @current_user.role != 'waiter' %>
<% if !@sale_data.empty? %>
<button id="equal_split" class="btn btn-block waves-effect bg-blue">= Split</button>
<% end %>
<% end %>
<% if !@orders.empty? %>
<button id="order_split" class="btn btn-block waves-effect bg-blue">By Order</button>
<button id="order_item_split" class="btn btn-block waves-effect bg-blue">By Order Item</button>
<% end %>
</div>
</div>
<!-- Column Three -->
@@ -249,7 +264,7 @@
<div class="modal-body">
<div class="form-horizontal">
<div class="col-lg-12 col-md-12 col-sm-12">
<div class="form-group">
<div class="form-group">
<input type="text" id="per_person" name="per_person" class="form-control" onkeypress="return isNumberKey(event);"/><br>
<span id="per_personErr" style="color:red;"></span>
</div>
@@ -316,9 +331,7 @@
<script type="text/javascript">
var split_sale_id = "";
var split_receipt_no = "";
var split_total_amount = 0;
$(document).ready(function(){
$('#back').on('click',function(){
backToOrigami();
})
@@ -395,7 +408,7 @@
// orderItemSplitBillProcess(cnt_items);
// }
}else{
swal("Opps","Please select at least one item!","warning");
swal("Oops","Please select at least one item!","warning");
}
});
@@ -459,7 +472,7 @@
// orderSplitBillProcess(cnt_odrs);
// }
}else{
swal("Opps","Please select at least one order!","warning");
swal("Oops","Please select at least one order!","warning");
}
});
@@ -472,14 +485,15 @@
//equal split process
$('#equal_split').on('click', function(){
var dining_id = $("#table_id").text();
split_sale_id = $("input[type='radio'][name='rdn_receipt']:checked").val();
split_receipt_no = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('id');
split_total_amount = $("input[type='radio'][name='rdn_receipt']:checked").parent().parent().attr('data');
if(split_sale_id != undefined && split_sale_id != ""){
$('#equal_split_modal').modal({backdrop: 'static', keyboard: true, show: true});
}
else{
swal("Opps","Please select one receipt!","warning");
swal("Oops","Please select one receipt!","warning");
}
});
@@ -490,15 +504,15 @@
$("#per_personErr").html('');
$('#equal_split_modal').modal('hide');
if(person > 1){
var ajax_url = "/origami/split_bills/surveys";
var dining_id = $("#table_id").text();
var ajax_url = "/origami/split_bills/equal_person";
var dining_id = $("#table_id").text();
var type = $("#table_type").text();
$.ajax({
type: "POST",
url: ajax_url,
dataType: 'JSON',
data: {'dining_id':dining_id, 'sale_id':split_sale_id, 'receipt_no':split_receipt_no, 'total_customer': person, 'total_amount':split_total_amount },
data: { 'sale_id':split_sale_id, 'total_customer': person },
success: function (result) {
console.log(result);
if(result.status){
@@ -688,6 +702,8 @@ function get_selected_order_items(){
var order_item = {};
order_item.id = $(this).attr('id').substr(0,16);
order_item.order_id = $(this).find('#item-order-id').text().trim();
order_item.item_code = $(this).find('#item-code').text().trim();
order_item.item_instance_code = $(this).find('#item-instance-code').text().trim();
order_item.name = $(this).find('#item-name-price').text().split('@')[0];
order_item.account_id = $(this).find('#item-account-type').text();
order_item.qty = $(this).find('#item-qty').text();

View File

@@ -1,11 +1,26 @@
<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" data-id="<%= sale.id %>">
<div class="card tables receipt_block" data-id="<%= sale.id %>">
<% if sale.id == @sale.id %>
<div class="card-block" style="background-color:#6080f0;">
<div class="card-block selected-item">
<%= sale.receipt_no %>
</div>
<% else %>
@@ -15,7 +30,7 @@
<% end %>
</div>
<% end %>
</div>
</div>
<div class="col-lg-7 col-md-5 col-sm-5">
<div class="card" >
@@ -74,7 +89,7 @@
<td><%= count %></td>
<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>
<td class='item-attr'><%= number_with_precision(sale_item.price, precision: precision.to_i ) %></td>
</tr>
<%
# end
@@ -93,7 +108,7 @@
<td><%= count %></td>
<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>
<td class='item-attr'><%= number_with_precision(order_item.qty*order_item.price, precision: precision.to_i ) %></td>
</tr>
<%
end
@@ -109,7 +124,7 @@
<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>
<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'%>
@@ -117,19 +132,19 @@
<%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>
<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"><%= @sale.total_tax rescue 0%></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"><%= @sale.rounding_adjustment rescue 0%></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"><%= @sale.grand_total rescue 0%></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>
@@ -142,7 +157,8 @@
<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" id="void" class="btn bg-danger btn-block" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> active="true" > Void </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>
@@ -200,13 +216,45 @@ $('#void').on('click',function () {
type: 'POST',
url: ajax_url,
success: function () {
window.location.href = '/origami/';
window.location.href = '/origami';
}
});
}
});
}else{
swal("Opps","You are not authorized for void","warning")
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>