merge with master

This commit is contained in:
Yan
2018-01-09 16:40:45 +06:30
91 changed files with 2666 additions and 744 deletions

View File

@@ -1,4 +1,7 @@
<div class="container-fluid">
<div id="loading_wrapper" style="display:none;">
<div id="loading"></div>
</div>
<div class="row">
<!-- Column One -->
<div class="col-lg-6 col-md-6 col-sm-6">
@@ -183,7 +186,7 @@
<div class="card-title row customer_detail p-l-5 p-r-5" >
<div class="col-lg-6 col-md-6 col-sm-6">
<% if @status_sale == 'sale' %>
<p class="hidden customer-id"><%= @obj_sale_sale.customer_id rescue '' %></p>
<p class="hidden customer-id"><%= @obj_sale.customer_id rescue '' %></p>
&nbsp; Customer : <%= @obj_sale.customer.name rescue '-' %>
<%else%>
<p class="hidden customer-id"><%= @obj_order.customer_id rescue "-" %></p>
@@ -260,7 +263,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="sub-total"><%= sub_total %></strong></td>
</tr>
<tr>
<%if @obj_sale != nil && @obj_sale.discount_type == 'member_discount'%>
@@ -353,12 +356,14 @@
<!-- <button type="button" class="btn bg-blue btn-block" disabled >Edit</button> -->
<!-- <button type="button" id="discount" class="btn bg-blue btn-block" disabled >Discount</button> -->
<!-- <button type="button" id="other-charges" class="btn bg-blue btn-block" disabled>Charges</button> -->
<button type="button" id="customer" class="btn bg-blue btn-block" >Customer</button>
<button type="button" class="btn bg-blue btn-block" id='move'>Move</button>
<button type="button" id="request_bills" class="btn bg-blue btn-block">Req.Bill</button>
<!-- <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> -->
<% else %>
<% 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>
<button type="button" class="btn bg-blue btn-block" id='edit'>Edit</button>
@@ -369,10 +374,40 @@
<button type="button" id="in_duties" class="btn btn-block bg-blue waves-effect">In Duties</button>
<!-- <button type="button" class="btn bg-blue btn-block" id='move' disabled="">Move</button> -->
<!-- <button type="button" id="request_bills" class="btn bg-blue btn-block" disabled> Req.Bill</button> -->
<!-- <button type="button" id="first_bill" class="btn bg-blue btn-block">First Bill</button> -->
<button type="button" id="pay" class="btn bg-blue btn-block">Pay</button>
<button type="button" id="void" class="btn bg-blue btn-block" > Void </button>
<% end %>
<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">
<select class="form-control show-tick payment_method" id="payment_method" >
<option value="Cash">Cash</option>
<% @payment_methods.each do |pay| %>
<option value="<%= pay.payment_method %>">
<%= pay.payment_method %>
</option>
<%end %>
</select>
</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 -->
<!-- <button type="button" id="re-print" class="btn bg-blue btn-block" >Re.Print</button> -->
@@ -411,6 +446,19 @@ $(document).ready(function(){
// window.location.href = '/origami/order/' + order_id;
// })
/* start check first bill or not*/
var receipt_no = "";
if(($("#receipt_no").html()!=undefined) && ($("#receipt_no").html()!="")){
receipt_no = ($("#receipt_no").html()).trim();
}
// console.log(checkReceiptNoInFirstBillData(receipt_no));
if(checkReceiptNoInFirstBillData(receipt_no,"")){
$("#pay").show();
}else{
$("#pay").hide();
}
/* end check first bill or not*/
$('.invoicedetails').on('click',function(){
var dining_id = "<%= @room.id %>";
var sale_id = this.id;
@@ -498,7 +546,7 @@ $(document).ready(function(){
window.location.href = '/origami/' + sale_id + '/discount'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -517,7 +565,7 @@ $(document).ready(function(){
window.location.href = '/origami/' + sale_id + '/other_charges'
}
else {
alert("Please select an table!");
swal ( "Oops" , "Please select an table!" , "warning" );
}
return false;
@@ -533,11 +581,54 @@ $("#first_bill").on('click', function(){
type: "GET",
url: ajax_url,
success:function(result){
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,"");
location.reload();
}
});
});
$(".choose_payment").on('click', function () {
$( "#loading_wrapper").show();
var sale_id = $('#sale_id').val();
type = $('.payment_method').val();
calculate_member_discount(sale_id,type);
var ajax_url = "/origami/sale/" + sale_id + "/first_bill";
$.ajax({
type: "GET",
url: ajax_url,
success: function (result) {
$( "#loading_wrapper" ).hide();
receipt_no = ($("#receipt_no").html()).trim();
if((receipt_no!=undefined) && (receipt_no!=""))
createReceiptNoInFirstBillData(receipt_no,type);
location.reload();
}
});
});
function calculate_member_discount(sale_id,type) {
var sub_total = $('#sub-total').text();
if (type == "Cash") {
is_card = false
}else{
is_card = true
}
$.ajax({
type: "POST",
url: "/origami/" + sale_id + "/member_discount",
data: {'sale_id':sale_id, 'sub_total':sub_total,'is_card':is_card },
async: false,
success:function(result){
}
});
}
$('#pay').on('click',function() {
var sale_id = $('#sale_id').val();
var url = '/origami/sale/'+ sale_id + "/rounding_adj" ;
@@ -600,8 +691,16 @@ $('#add_invoice').on('click',function(){
url: ajax_url,
data: 'dining_id='+ dining_id + "&sale_id=" + sale_id,
success:function(result){
alert("Invoice updated")
window.location.reload();
swal({
title: "Information!",
text: "Invoice updated",
html: true,
closeOnConfirm: false,
closeOnCancel: false,
allowOutsideClick: false
}, function () {
window.location.reload();
});
}
});
});