Merge branch 'adminbsb_ui_changes' of bitbucket.org:code2lab/sxrestaurant

This commit is contained in:
phyusin
2018-06-22 13:33:37 +06:30
10 changed files with 418 additions and 97 deletions

View File

@@ -64,9 +64,6 @@ class Api::CheckInProcessController < Api::ApiController
end
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
dining_facility.status = "occupied"
dining_facility.save!
if dining_facility.type == "Table"
type = "TableBooking"
else
@@ -75,7 +72,10 @@ class Api::CheckInProcessController < Api::ApiController
booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
booking.save!
if booking.save!
dining_facility.status = "occupied"
dining_facility.save!
end
render :json => { :status => true, :checkout_at => booking.checkout_at.utc.getlocal.strftime("%Y-%m-%d %H:%M") }
else

View File

@@ -28,14 +28,15 @@ class Inventory::StockChecksController < BaseInventoryController
stockcheck = StockCheck.find(stock_id)
stockcheck_items = stockcheck.stock_check_items
member_info = nil
unique_code = 'StockPrint'
unique_code = 'StockCheckPdf'
shop_details = Shop.find(1)
checker = Employee.find(stockcheck.check_by)
print_settings = PrintSetting.find_by_unique_code(unique_code)
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
if !print_settings.nil?
printer = Printer::ReceiptPrinter.new(print_settings)
printer.print_stock_check_result(print_settings, stockcheck, stockcheck_items, checker.name, shop_details)
end
end
#Shop Name in Navbor

View File

@@ -16,8 +16,6 @@ class Origami::CheckInProcessController < BaseOrigamiController
if checkout_at.strftime("%Y-%m-%d %H:%M%p") > today.strftime("%Y-%m-%d %H:%M%p")
@dining_facility = DiningFacility.find(params[:dining_id])
@dining_facility.status = "occupied"
@dining_facility.save!
if @dining_facility.type == "Table"
type = "TableBooking"
@@ -27,7 +25,11 @@ class Origami::CheckInProcessController < BaseOrigamiController
@booking = Booking.create({:dining_facility_id => params[:dining_id],:type => type,
:checkin_by=>current_login_employee.name,:checkin_at => Time.now.utc,:checkout_at =>checkout_at, :booking_status => "assign", :reserved_at => checkout_at, :reserved_by => current_login_employee.name })
@booking.save!
if @booking.save!
@dining_facility.status = "occupied"
@dining_facility.save!
end
end
if ENV["SERVER_MODE"] != "cloud" #no print in cloud server

View File

@@ -98,30 +98,44 @@ class Origami::HomeController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@booking= booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
end
end
@booking= booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
end
@sale_taxes = []
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
if !sale_taxes.empty?
sale_taxes.each do |sale_tax|
@sale_taxes.push(sale_tax)
end
end
end
end
#for bank integration
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
@tax_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc.id)
@tax_arr.push(account.name)
end
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?

View File

@@ -100,22 +100,30 @@ class Origami::RoomsController < BaseOrigamiController
@status_order = 'order'
else
sale = Sale.find(booking.sale_id)
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
if sale.sale_status != "completed" && sale.sale_status != 'void' && sale.sale_status != 'spoile' && sale.sale_status != 'waste'
@sale_array.push(sale)
if @status_order == 'order'
@status_order = 'sale'
end
@booking = booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
end
@booking = booking
@date = sale.created_at
@status_sale = 'sale'
@obj_sale = sale
@customer = sale.customer
accounts = @customer.tax_profiles
@account_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc)
@account_arr.push(account)
end
@sale_taxes = []
sale_taxes = SaleTax.where("sale_id = ?", sale.sale_id)
if !sale_taxes.empty?
sale_taxes.each do |sale_tax|
@sale_taxes.push(sale_tax)
end
end
end
end
end
@@ -145,6 +153,17 @@ class Origami::RoomsController < BaseOrigamiController
# end
# end
#for bank integration
@checkout_time = Lookup.collection_of('checkout_time')
@checkout_alert_time = Lookup.collection_of('checkout_alert_time')
accounts = TaxProfile.where("group_type = ?","cashier").order("order_by ASC")
@tax_arr =[]
accounts.each do |acc|
account = TaxProfile.find(acc.id)
@tax_arr.push(account.name)
end
lookup_spit_bill = Lookup.collection_of('split_bill')
@split_bill = 0
if !lookup_spit_bill[0].nil?

View File

@@ -60,6 +60,6 @@ class Booking < ApplicationRecord
private
def generate_custom_id
self.booking_id = SeedGenerator.generate_id(self.class.name, "BKI")
self.booking_id = SeedGenerator.generate_id("Booking", "BKI") #(self.class.name, "BKI")
end
end

View File

@@ -1822,18 +1822,23 @@ end
total_dinein_takeaway = self.total_dinein_takeaway(today,current_user,from,to,from_time,to_time)
dinein_cnt = 0
takeaway_cnt = 0
if !total_dinein_takeaway[0].nil?
dinein_cnt = total_dinein_takeaway[0].total_dinein_cus
takeaway_cnt = total_dinein_takeaway[0].total_take_cus
if !total_dinein_takeaway.nil?
if total_dinein_takeaway[0]
dinein_cnt = total_dinein_takeaway[0].total_dinein_cus
takeaway_cnt = total_dinein_takeaway[0].total_take_cus
end
end
membership_cnt = self.total_membership(today,current_user,from,to,from_time,to_time)
member_cnt = 0
if !membership_cnt.nil?
member_cnt = membership_cnt.total_memb_cus
end
total_cus = 0
if !dinein_cnt.nil? || !takeaway_cnt.nil? || !membership_cnt.nil?
total_cus = dinein_cnt.to_int + takeaway_cnt.to_int + membership_cnt.total_memb_cus.to_int
if dinein_cnt > dinein_cnt || takeaway_cnt > 0 || !membership_cnt.nil?
total_cus = dinein_cnt.to_int + takeaway_cnt.to_int + member_cnt.to_int
end
return total_cus, dinein_cnt, takeaway_cnt, membership_cnt.total_memb_cus
return total_cus, dinein_cnt, takeaway_cnt, member_cnt
end
def self.total_dinein_takeaway(today,current_user=nil,from=nil,to=nil,from_time=nil,to_time=nil)

View File

@@ -96,8 +96,16 @@
url: '<%= inventory_save_to_journal_path %>',
data: 'data=' + check_id,
success: function () {
alert('Successfully saved to journal.');
window.location.href = '/inventory';
swal({
title: "Information!",
text: "Successfully saved to journal",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.href = '/inventory';
});
}
})
});
@@ -107,7 +115,19 @@
$.ajax({
type: 'post',
url: '<%= inventory_print_stock_check_path %>',
data: 'stock_check_id=' + check_id
data: 'stock_check_id=' + check_id,
success: function(){
swal({
title: "Information!",
text: "Print successfully",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.reload();
});
}
})
});

View File

@@ -94,7 +94,11 @@
<% @rooms.each do |room| %>
<% if room.status == 'occupied' %>
<% if room.get_booking.nil? %>
<% if room.get_checkout_booking.nil? %>
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% else %>
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% end %>
<div class="card-block">
<%= room.name %>
<!-- <% if !@order_items_count.nil? %>
@@ -106,7 +110,11 @@
</div>
</div>
<% else %>
<% if room.get_checkout_booking.nil? %>
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% else %>
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% end %>
<div class="card-block">
<%= room.name %>
<!-- <% if !@order_items_count.nil? %>
@@ -350,15 +358,21 @@
</tr>
<% if @status_sale == "sale" %>
<tr>
<td class="charges-name"><strong>Tax:
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.name%>
<% if @account_arr.count != @i+1%>
<td class="charges-name"><strong>
<% if !@sale_taxes.empty? %>
Tax:
(<% @i = 0
@sale_taxes.each do |ct| %>
<%=ct.tax_name%>
<% if @sale_taxes.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
</strong></td>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
</td>
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
</tr>
<tr>
@@ -624,6 +638,61 @@
</div>
</div>
</div>
<!-- change tax modal -->
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="change_taxModalLabel">TAX</h1>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">&times;</button>
</div>
<div class="modal-body">
<% if !@tax_arr.empty? %>
<% if @tax_arr.count > 1 %>
<div class="row text-center">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="all">
<% @i = 0
@tax_arr.each do |tax| %>
<%= tax %>
<% if @tax_arr.count != @i+1%>
+ <% @i =+1 %><br>
<%end%>
<% end %>
</button>
</div>
<% @tax_arr.each_with_index do |tax, tax_index| %>
<% if (tax_index+1)%2 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>">
<%= tax %>
</button>
</div>
<% end %>
<% else %>
<div class="row clearfix"></div>
<div class="row text-center">
<% @tax_arr.each do |tax| %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>"><%= tax %></button>
</div>
<% end %>
<% end %>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="no_tax">No Tax</button>
</div>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<script>
var cashier_type = "cashier";
$(document).ready(function () {
@@ -1165,4 +1234,52 @@
});
}
/* Start function for tax changable */
$(".change_tax").on("click",function(){
var balance = parseFloat($("#order-grand-total").text());
var sub_total = parseFloat($("#sub-total").text());
var total_tax = parseFloat($("#order-Tax").text());
if(balance > 0 && (balance >= total_tax)){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
}
else{
swal("Oops","You cann't change tax!","warning");
}
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var cashier_type = 'cashier';
var sale_id = $('#sale_id').text();
var dining_id = "<%= @dining.id rescue "" %> ";
var sale_id = "<%= @obj_sale.sale_id rescue "" %>";
localStorage.removeItem("tax_type");
swal({
title: "Alert",
text: "Are you sure want to change tax?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, change it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
window.location.href = '/origami/table/'+dining_id;
}
}
});
}else{
swal.close();
}
});
});
/* End function for tax changable */
</script>

View File

@@ -94,7 +94,11 @@
<% if room.status == 'occupied' %>
<% if room.get_booking.nil? %>
<% if room.get_checkout_booking.nil? %>
<div class="card rooms red text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% else %>
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% end %>
<div class="card-block">
<%= room.name %>
<!-- <% if !@order_items_count.nil? %>
@@ -107,7 +111,11 @@
</div>
</div>
<% else %>
<% if room.get_checkout_booking.nil? %>
<div class="card rooms blue text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% else %>
<div class="card rooms orange text-white table_<%= room.id %>" data-id="<%= room.id %>">
<% end %>
<div class="card-block">
<%= room.name %>
<!-- <% if !@order_items_count.nil? %>
@@ -169,7 +177,12 @@
<div class="card" >
<div class="card-header">
<% if @status_order == 'order' %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>"><strong id="order-title">ORDER DETAILS </strong> | Table <%= @room.name rescue "" %>
<% if !@obj_order.nil? %>
<div id="save_order_id" data-order="<%= @obj_order.order_id %>">
<% else %>
<div id="save_order_id" data-order="">
<% end %>
<strong id="order-title">ORDER DETAILS </strong> | Table <%= @room.name rescue "" %>
<% if @booking.checkout_by.nil? && !@booking.reserved_by.nil? && %>
<span class="float-right"><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %> - <%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") %></span>
<% else %>
@@ -334,15 +347,21 @@
</tr>
<% if @status_sale == "sale" %>
<tr>
<td class="charges-name"><strong>Tax:
(<% @i = 0
@account_arr.each do |ct| %>
<%=ct.name%>
<% if @account_arr.count != @i+1%>
<td class="charges-name"><strong>
<% if !@sale_taxes.empty? %>
Tax:
(<% @i = 0
@sale_taxes.each do |ct| %>
<%=ct.tax_name%>
<% if @sale_taxes.count != @i+1%>
+ <% @i =+1 %>
<%end%>
<%end %>)
</strong></td>
<%end %>)
<% else %>
No Tax
<% end %></strong><br>
<button class="btn btn-link waves-effect bg-info change_tax">Change Tax</button>
</td>
<td class="item-attr"><strong id="order-Tax"><%= @obj_sale.total_tax rescue 0%></strong></td>
</tr>
<tr>
@@ -443,7 +462,7 @@
<button type="button" id="add_order" class="btn btn-block btn- bg-blue waves-effect">Add Order</button>
<button type="button" id="survey" class="btn btn-block bg-blue waves-effect">Survey</button>
<% if @room.status != "available" %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<% if @status_order == 'order' && @status_sale != 'sale' %>
<!-- <button type="button" class="btn bg-blue btn-block" >Add Order</button> -->
<!-- <button type="button" id="customer" class="btn bg-blue btn-block" disabled>Customer</button> -->
<!-- <button type="button" class="btn bg-blue btn-block" disabled >Edit</button> -->
@@ -460,8 +479,8 @@
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block" disabled>First Bill</button> -->
<!-- <button type="button" id="pay" class="btn bg-blue btn-block" disabled>Pay</button> -->
<!-- <button type="button" class="btn bg-blue btn-block" disabled=""> Void </button> -->
<% end %>
<% if @status_sale == 'sale' %>
<% end %>
<% 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" %>
@@ -493,37 +512,41 @@
<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>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<button class='btn waves-effect payment_btn green' data-type='Credit' data-value='Credit'>Credit</button>
<% @payment_methods.each do |pay| %>
<!-- <option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option> -->
<button class='btn btn-lg waves-effect payment_btn green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
<%end %>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<!-- Cashier Buttons -->
<% end %>
<% 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>
<div class="modal fade" id="paymentModal" tabindex="-1" role="dialog">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h4 class="modal-title" id="paymentModalLabel">Choose Payment</h4>
</div>
<div class="modal-body">
<button class='btn waves-effect payment_btn green' data-type='Credit' data-value='Credit'>Credit</button>
<% @payment_methods.each do |pay| %>
<!-- <option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option> -->
<button class='btn btn-lg waves-effect payment_btn green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
<%end %>
</div>
<div class="modal-footer p-r-30">
<button type="button" class="btn btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
&nbsp; &nbsp;
<button type="button" class="btn btn-link bg-blue waves-effect choose_payment">SAVE</button>
</div>
</div>
</div>
</div>
<!-- Cashier Buttons -->
<% end %>
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
<% else %>
<% if !@checkout_time.empty? && !@checkout_alert_time.empty? %>
<button type="button" id="check_in" class="btn btn-block bg-blue waves-effect"><%= t("views.btn.check_in") %></button>
<% end %>
<% end %>
</div>
</div>
@@ -610,6 +633,61 @@
</div>
</div>
<!-- change tax modal -->
<div class="modal fade" id="change_taxModal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-md" role="document">
<div class="modal-content">
<div class="modal-header">
<h1 class="modal-title" id="change_taxModalLabel">TAX</h1>
<button type="button" class="close" id="close" data-dismiss="modal" aria-hidden="true" style="font-size: 20px;color:#111;">&times;</button>
</div>
<div class="modal-body">
<% if !@tax_arr.empty? %>
<% if @tax_arr.count > 1 %>
<div class="row text-center">
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="all">
<% @i = 0
@tax_arr.each do |tax| %>
<%= tax %>
<% if @tax_arr.count != @i+1%>
+ <% @i =+1 %><br>
<%end%>
<% end %>
</button>
</div>
<% @tax_arr.each_with_index do |tax, tax_index| %>
<% if (tax_index+1)%2 == 0 %>
<div class="row clearfix"></div>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>">
<%= tax %>
</button>
</div>
<% end %>
<% else %>
<div class="row clearfix"></div>
<div class="row text-center">
<% @tax_arr.each do |tax| %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="<%= tax %>"><%= tax %></button>
</div>
<% end %>
<% end %>
<% end %>
<div class="col-xs-6 col-sm-6 col-md-6 col-lg-6">
<button type="button" class="btn btn-lg tax-btn-box btn-link bg-primary waves-effect" name="tax_type" data-value="no_tax">No Tax</button>
</div>
</div>
</div>
</div>
<div class="modal-footer"></div>
</div>
</div>
</div>
<script>
var cashier_type = "cashier";
$(document).ready(function(){
@@ -1206,4 +1284,69 @@ $('#add_invoice').on('click',function(){
});
}
/* check in process */
$('#check_in').on('click',function(){
var room_id = "<%= @room.id %>";
$.ajax({
type: 'POST',
data: {'dining_id' : room_id},
datatype: 'JSON',
url: '/origami/check_in',
success: function(data) {
if(data.status == 'ok'){
window.location.reload();
}
}
});
});
/* Start function for tax changable */
$(".change_tax").on("click",function(){
var balance = parseFloat($("#order-grand-total").text());
var sub_total = parseFloat($("#sub-total").text());
var total_tax = parseFloat($("#order-Tax").text());
if(balance > 0 && (balance >= total_tax)){
$("#change_taxModal").modal({show: true, backdrop: false, keyboard: false});
}
else{
swal("Oops","You cann't change tax!","warning");
}
});
$("button[name=tax_type]").on("click", function(){
var type = $(this).attr("data-value");
var cashier_type = 'cashier';
var sale_id = $('#sale_id').text();
var dining_id = "<%= @room.id rescue "" %> ";
var sale_id = "<%= @obj_sale.sale_id rescue "" %>";
localStorage.removeItem("tax_type");
swal({
title: "Alert",
text: "Are you sure want to change tax?",
type: "warning",
showCancelButton: true,
confirmButtonColor: "#DD6B55",
confirmButtonText: "Yes, change it!",
closeOnConfirm: false
}, function (isConfirm) {
if (isConfirm) {
$.ajax({
type: "POST",
url: "/origami/payment/"+cashier_type+"/change_tax",
data: {sale_id: sale_id, cashier_type: cashier_type, tax_type: type},
success:function(data){
if(data.status){
// console.log(type);
localStorage.setItem("tax_type", type);
window.location.href = '/origami/room/'+dining_id;
}
}
});
}else{
swal.close();
}
});
});
/* End function for tax changable */
</script>