add req bill and payment #left order and sale
This commit is contained in:
@@ -19,7 +19,7 @@
|
||||
<div class="row clearfix">
|
||||
<div class="col-lg-4 col-md-4 col-sm-4 col-xs-4">
|
||||
<label><%= t("views.right_panel.detail.enter_keyboards") %></label>
|
||||
<input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="Booking/Sale ID" style="margin-right: 10px">
|
||||
<input type="text" id="receipt_no" name="receipt_no" class="form-control" placeholder="Booking/ Sale ID/ Table/ Room" style="margin-right: 10px">
|
||||
</div>
|
||||
<div class="col-lg-3 col-md-3 col-sm-3 col-xs-3">
|
||||
<label class=""><%= t("views.right_panel.detail.from") %></label>
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
<a class="nav-link" data-toggle="tab" href="#sale" role="tab"><%= t :sale_details %></a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<!-- Nav tabs - End -->
|
||||
<div class="tab-content" style="min-height:670px; max-height:670px;">
|
||||
<div class="tab-pane active" id="booking" role="tabpanel">
|
||||
@@ -39,13 +40,18 @@
|
||||
<th> <%= t("views.right_panel.detail.checkout_by") %></th>
|
||||
<th><%= t("views.right_panel.detail.booking_status") %></th>
|
||||
<th><%= t("views.right_panel.detail.booking_date") %></th>
|
||||
<%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %>
|
||||
<th>
|
||||
<button id="request_bill" class="btn bg-blue btn-md waves-effect">Req. Bill</button>
|
||||
</th>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
<tbody>
|
||||
<tr>
|
||||
<td><%= @booking.booking_id%></td>
|
||||
<td><%= link_to @booking.sale_id, transactions_sale_path(booking.sale_id) rescue '-' %></td>
|
||||
<td><%= link_to @booking.sale_id, transactions_sale_path(@booking.sale_id) rescue '-' %></td>
|
||||
<td><%= @booking.dining_facility.name rescue '' %></td>
|
||||
<td><%= @booking.checkin_at.utc.getlocal.strftime("%I:%M %p") %></td>
|
||||
<td><%= @booking.checkout_at.utc.getlocal.strftime("%I:%M %p") rescue '-' %></td>
|
||||
@@ -53,6 +59,9 @@
|
||||
<td><%= @booking.checkout_by rescue '-' %></td>
|
||||
<td><%= @booking.booking_status %> </td>
|
||||
<td><%= @booking.created_at.utc.getlocal.strftime("%d-%m-%Y %I:%M %p") %> </td>
|
||||
<%if (@booking.sale_id.nil?) && (current_login_employee.role == "administrator") && (!@order.nil?) %>
|
||||
<td></td>
|
||||
<% end %>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
@@ -135,6 +144,37 @@
|
||||
|
||||
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function(){
|
||||
$("#request_bill").on('click', function(){
|
||||
var order_id = '';
|
||||
<%if !@order.nil? %>
|
||||
order_id ='<%= @order.order_id %>';
|
||||
<% end %>
|
||||
var ajax_url = "/origami/" + order_id + "/request_bills";
|
||||
localStorage.setItem("tax_type", "all");
|
||||
if(order_id!=undefined && order_id!=null && order_id!=""){
|
||||
if($('#request_bill').is(":visible")) {
|
||||
$('#request_bill').prop("disabled",true);
|
||||
}
|
||||
$.ajax({
|
||||
type: "GET",
|
||||
url: ajax_url,
|
||||
success: function (result) {
|
||||
if (!result.status) {
|
||||
$('#request_bill').prop("disabled",false);
|
||||
swal("Information!", result.error_message);
|
||||
}
|
||||
else {
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
});
|
||||
}else{
|
||||
swal("Opps","There is no orders!","warning");
|
||||
}
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
|
||||
@@ -41,10 +41,22 @@
|
||||
<th><%= t :cashier %></th>
|
||||
<th><%= t("views.right_panel.detail.sales_status") %></th>
|
||||
<th><%= t("views.right_panel.detail.receipt_generated_at") %></th>
|
||||
<% if @sale["sale_status"] == "completed" %>
|
||||
<% if @sale.sale_status == "completed" %>
|
||||
<th>
|
||||
<button type="button" class="btn btn-block bg-red waves-effect" data-toggle="modal" data-target="#voidModal" <%= (can? :overall_void, :void)? ' ': 'disabled=' %> > Void</button>
|
||||
</th>
|
||||
<% else %>
|
||||
<% if current_login_employee.role == "administrator" %>
|
||||
<%if @membership.discount && @sale.customer.membership_id %>
|
||||
<th>
|
||||
<button type="button" class="btn btn-block bg-blue waves-effect" data-toggle="modal" data-target="#paymentModal">Pay</button>
|
||||
</th>
|
||||
<%else%>
|
||||
<th>
|
||||
<button type="button" id="pay" class="btn btn-block bg-blue waves-effect">Pay</button>
|
||||
</th>
|
||||
<%end%>
|
||||
<%end%>
|
||||
<% end %>
|
||||
</tr>
|
||||
</thead>
|
||||
@@ -266,7 +278,107 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<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"><%= @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 Method</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<!-- <select class="form-control show-tick payment_method" multiple="true" id="payment_method" > -->
|
||||
<!-- <option value="Cash">Cash</option> -->
|
||||
<div class="row text-center">
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<button class='btn btn-md waves-effect payment-btn-box payment_btn bg-green' data-type='Credit' data-value='Credit'>Credit</button>
|
||||
</div>
|
||||
|
||||
<% @payment_methods.each_with_index do |pay, pay_index| %>
|
||||
<%if (pay_index+1)%3 == 0 %>
|
||||
<div class="row clearfix"></div>
|
||||
<% end %>
|
||||
<div class="col-xs-4 col-sm-4 col-md-4 col-lg-4">
|
||||
<button class='btn btn-md payment-btn-box waves-effect payment_btn bg-green' data-type='<%= pay.payment_method %>' data-value='<%= pay.payment_method %>'><%= pay.payment_method %></button>
|
||||
</div>
|
||||
<%end %>
|
||||
|
||||
</div>
|
||||
|
||||
<!-- </select> -->
|
||||
</div>
|
||||
<div class="modal-footer p-r-30 pb-3">
|
||||
<button type="button" class="btn btn-md btn-link btn-danger waves-effect" data-dismiss="modal">CLOSE</button>
|
||||
|
||||
<button type="button" class="btn btn-md btn-link bg-blue waves-effect choose_payment">SAVE</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
// Get Selected Class
|
||||
function get_selected_attributes(selected_class) {
|
||||
var item_row = $('.'+selected_class);
|
||||
var attribute_arr = [];
|
||||
$(item_row).each(function(i){
|
||||
value = $(item_row[i]).attr('data-value');
|
||||
str = value;
|
||||
attribute_arr.push(str);
|
||||
});
|
||||
return attribute_arr;
|
||||
}
|
||||
|
||||
function calculate_member_discount(sale_id,type,tax_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,'cashier_type':'cashier','tax_type':tax_type },
|
||||
async: false,
|
||||
success:function(result){ }
|
||||
});
|
||||
}
|
||||
|
||||
function createReceiptNoInFirstBillData(receipt_no,payment) {
|
||||
var arr_data = [];
|
||||
var json_data = [];
|
||||
if(localStorage.hasOwnProperty("receipt_lists") === true){
|
||||
arr_data = JSON.parse(localStorage.getItem("receipt_lists"));
|
||||
json_data = arr_data.filter(function(e) { return e.receipt_no == receipt_no });
|
||||
if (payment) {
|
||||
jdata = arr_data.filter(function(e) { return e.receipt_no !== receipt_no });
|
||||
jdata.push({'receipt_no':receipt_no,'payment':payment});
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(jdata));
|
||||
}
|
||||
}
|
||||
if(((arr_data.length == 0) && (json_data.length == 0)) || ((arr_data.length > 0) && (json_data.length == 0))){
|
||||
arr_data.push({'receipt_no':receipt_no,'payment':payment});
|
||||
localStorage.setItem("receipt_lists",JSON.stringify(arr_data));
|
||||
}
|
||||
}
|
||||
|
||||
// click select option icon for add
|
||||
$('.payment_btn').on('click', function(event){
|
||||
active = $(this).hasClass('selected-payment');
|
||||
value = $(this).data('value');
|
||||
type = $(this).data('type');
|
||||
group = $(this).data('group');
|
||||
payments = $(".payment_btn");
|
||||
|
||||
if (active) {
|
||||
$(this).removeClass('selected-payment');
|
||||
}else{
|
||||
$(this).addClass('selected-payment');
|
||||
}
|
||||
}); //End selecct attribute buttom
|
||||
|
||||
$('#void').on('click', function () {
|
||||
var access_code = localStorage.getItem("access_code");
|
||||
if ($(this).attr('active')=== "true") {
|
||||
@@ -280,7 +392,7 @@
|
||||
closeOnConfirm: false
|
||||
}, function (isConfirm) {
|
||||
if (isConfirm) {
|
||||
var sale_id = "<%= @sale.sale_id %>"
|
||||
var sale_id = "<%= @sale.sale_id %>";
|
||||
// console.log(sale_id)
|
||||
var ajax_url = "/transactions/sales/" + sale_id + '/cashier/void';
|
||||
var remark = $("#remark").val();
|
||||
@@ -291,10 +403,10 @@
|
||||
data: "remark="+ remark + "&sale_id=" + sale_id+ "&access_code=" + access_code,
|
||||
success: function (result) {
|
||||
// For Server Print - from jade
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
window.location.href = '/transactions/sales/';
|
||||
if ($("#server_mode").val() == "cloud") {
|
||||
code2lab.printFile(result.filepath.substr(6), result.printer_url);
|
||||
}
|
||||
window.location.href = '/transactions/sales/';
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -303,5 +415,38 @@
|
||||
swal("Opps","You are not authorized for void","warning")
|
||||
}
|
||||
});
|
||||
|
||||
$(".choose_payment").on('click', function () {
|
||||
$("#loading_wrapper").show();
|
||||
var sale_id = "<%= @sale.sale_id %>";
|
||||
var type = get_selected_attributes('selected-payment');
|
||||
var tax_type = localStorage.getItem("tax_type") ? localStorage.getItem("tax_type") : 'all';
|
||||
|
||||
// console.log(type);
|
||||
|
||||
if(parseInt(jQuery.inArray("Credit", type)) == -1){
|
||||
if (parseInt(jQuery.inArray("MPU", type)) != -1 || parseInt(jQuery.inArray("VISA", type)) != -1 || parseInt(jQuery.inArray("JCB", type)) != -1 || parseInt(jQuery.inArray("Master", type)) != -1 || parseInt(jQuery.inArray("UNIONPAY", type)) != -1 || parseInt(jQuery.inArray("Redeem", type)) != -1 || parseInt(jQuery.inArray("PAYMAL",type))!= -1) {
|
||||
if(!location.pathname.includes("credit_payment")){
|
||||
calculate_member_discount(sale_id,"Card",tax_type);
|
||||
}
|
||||
}else{
|
||||
if(!location.pathname.includes("credit_payment")){
|
||||
calculate_member_discount(sale_id,"Cash",tax_type);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$( "#loading_wrapper" ).hide();
|
||||
receipt_no = "<%= @sale.receipt_no %>";
|
||||
if((receipt_no!=undefined) && (receipt_no!=""))
|
||||
createReceiptNoInFirstBillData(receipt_no,type);
|
||||
|
||||
window.location = '/origami/sale/'+sale_id+'/transaction/payment';
|
||||
});
|
||||
|
||||
$('#pay').on('click', function() {
|
||||
var sale_id = "<%= @sale.sale_id %>";
|
||||
window.location = '/origami/sale/'+sale_id+'/transaction/payment';
|
||||
});
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user