add change tax in table/room and check-in for room

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

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>